plugins: HFS.Btn
Massimo Melina committed
Mar 16, 2025 at 14:24 UTC
2cac314a9121c335db4ece21c8f628dd7d7eb22d
3 files changed
+13
-6
dev-plugins.md
+6
-2
@@ -217,7 +217,7 @@ The `api` object you get as parameter of the `init` contains the following:
217
- `setConfig(key: string, value: any)` set plugin's config value.
218
219
- `subscribeConfig(key: string | string[], callback: (value: any) => void): Unsubscriber`
220
- will call `callback` with initial value and then at each change.
220
+ will immediately call `callback` with initial value, and then at each change.
221
Passing an array of keys, the `value` parameter becomes an object with the specified keys and respective values.
222
Will be automatically unsubscribed at plugin's unload.
223
@@ -353,6 +353,9 @@ The HFS object contains many properties:
353
- `Icon: ReactComponent` Properties:
354
- `name: string` refer to file `icons.ts` for names, but you can also enter an emoji instead.
355
- `iconBtn(icon: string, onClick: function, props?: any)` render a React Icon Button. For icons, refer to `Icon` component.
356
+- `Btn: ReactComponent}` Properties:
357
+ - `icon?: string`, `label?: string`, `tooltip?: string`, `toggled?: boolean`, `onClick?: function`,
358
+ `onClickAnimation?: boolean`, `asText?: boolean`, `successFeedback?: boolean`
359
- `domOn(eventName: string, cb: function, { target }?): function` convenient alternative to addEventListener/removeEventListener.
360
The default target is window. Returns a callback to remove the listener.
361
- `useBatch(worker, job): { data }` this is a bit complicated, please refer to source `shared/react.ts`.
@@ -793,13 +796,14 @@ If you want to override a text regardless of the language, use the special langu
796
797
## API version history
798
796
-- 12.0 (v0.57.0)
799
+- 12.1 (v0.57.0)
800
- backend event: finalizingLogin, httpsServerOptions, clearTextLogin
801
- frontend events: beforeLoginSubmit
802
- exports.changelog
803
- automatic unload of api.events listeners
804
- removed DirEntry.t
805
- api.setInterval, setTimeout
806
+ - HFS.Btn
807
- 11.6 (v0.56.0)
808
- api.setError
809
- frontend events: afterBreadcrumbs, afterFolderStats, afterFilter
frontend/src/misc.ts
+2
-2
@@ -1,7 +1,7 @@
1
// This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3
import React, { createElement as h } from 'react'
4
-import { iconBtn, Spinner } from './components'
4
+import { Btn, iconBtn, Spinner } from './components'
5
import { newDialog, toast } from './dialog'
6
import { Icon, IconProps } from './icons'
7
import { Callback, Dict, domOn, getHFS, getOrSet, Html, HTTP_MESSAGES, urlParams, useBatch } from '@hfs/shared'
@@ -96,7 +96,7 @@ export function formatTimestamp(x: number | string | Date, options?: Intl.DateTi
96
97
Object.assign(getHFS(), {
98
h, React, state, t, _, dialogLib, apiCall, useApi, reloadList, logout, Icon, hIcon, iconBtn, useBatch, fileShow,
99
- toast, domOn, getNotifications, debounceAsync, useSnapState, DirEntry,
99
+ toast, domOn, getNotifications, debounceAsync, useSnapState, DirEntry, Btn,
100
fileShowComponents: { Video, Audio },
101
misc: { ...cross, ...shared },
102
emit: hfsEvent,
src/const.ts
+5
-2
@@ -9,7 +9,7 @@ import { formatTimestamp } from './cross'
9
import { argv } from './argv'
10
export * from './cross-const'
11
12
-export const API_VERSION = 12
12
+export const API_VERSION = 12.1
13
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
14
15
// you can add arguments with this file, currently used for the update process on mac/linux
@@ -39,7 +39,10 @@ export const MIME_AUTO = 'auto'
39
export const CONFIG_FILE = 'config.yaml'
40
41
// we want this to be the first stuff to be printed, then we print it in this module, that is executed at the beginning
42
-if (DEV) console.clear()
42
+if (DEV) {
43
+ console.clear()
44
+ process.env.DEBUG = 'acme-client'
45
+}
46
else if (!argv.debug) console.debug = ()=>{}
47
console.log(`HFS ~ HTTP File Server`)
48
console.log(`© Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt`)