domma-js 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/types/generated/public/assets/flags/africa.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/americas.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/asia.d.ts +6 -0
- package/assets/types/generated/public/assets/flags/europe.d.ts +9 -0
- package/assets/types/generated/public/assets/flags/index.d.ts +11 -0
- package/assets/types/generated/public/assets/flags/oceania.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/buildings.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/code.d.ts +2 -0
- package/assets/types/generated/public/assets/icons/commerce.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/communication.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/devices.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/emojis.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/files.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/finance.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/forms.d.ts +5 -0
- package/assets/types/generated/public/assets/icons/health.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/index.d.ts +24 -0
- package/assets/types/generated/public/assets/icons/media.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/navigation.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/seasonal.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/social.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/sport.d.ts +6 -0
- package/assets/types/generated/public/assets/icons/status.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/transport.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/ui.d.ts +7 -0
- package/assets/types/generated/public/assets/icons/weather.d.ts +6 -0
- package/assets/types/generated/src/auth.d.ts +424 -0
- package/assets/types/generated/src/avatar.d.ts +270 -0
- package/assets/types/generated/src/binding-source.d.ts +58 -0
- package/assets/types/generated/src/butterfly-drawing.d.ts +2 -0
- package/assets/types/generated/src/component-factory.d.ts +150 -0
- package/assets/types/generated/src/component.d.ts +162 -0
- package/assets/types/generated/src/components/back-to-top.d.ts +150 -0
- package/assets/types/generated/src/components/badge.d.ts +208 -0
- package/assets/types/generated/src/components/card.d.ts +189 -0
- package/assets/types/generated/src/components/command-palette.d.ts +352 -0
- package/assets/types/generated/src/components/dropzone.d.ts +342 -0
- package/assets/types/generated/src/components/focus-trap.d.ts +238 -0
- package/assets/types/generated/src/components/loader.d.ts +133 -0
- package/assets/types/generated/src/components/modal.d.ts +341 -0
- package/assets/types/generated/src/components/range-slider.d.ts +267 -0
- package/assets/types/generated/src/components/shared.d.ts +91 -0
- package/assets/types/generated/src/components/split-pane.d.ts +239 -0
- package/assets/types/generated/src/components/toast.d.ts +284 -0
- package/assets/types/generated/src/components/tooltip.d.ts +200 -0
- package/assets/types/generated/src/components/virtual-list.d.ts +340 -0
- package/assets/types/generated/src/config.d.ts +193 -0
- package/assets/types/generated/src/context-cursor.d.ts +69 -0
- package/assets/types/generated/src/context-menu.d.ts +596 -0
- package/assets/types/generated/src/dates.d.ts +367 -0
- package/assets/types/generated/src/dom.d.ts +1221 -0
- package/assets/types/generated/src/effects.d.ts +1281 -0
- package/assets/types/generated/src/elements.d.ts +4996 -0
- package/assets/types/generated/src/escape.d.ts +5 -0
- package/assets/types/generated/src/flags-bundle.d.ts +4 -0
- package/assets/types/generated/src/flags.d.ts +338 -0
- package/assets/types/generated/src/forms.d.ts +1060 -0
- package/assets/types/generated/src/globals.d.ts +45 -0
- package/assets/types/generated/src/http.d.ts +131 -0
- package/assets/types/generated/src/i18n.d.ts +261 -0
- package/assets/types/generated/src/icons.d.ts +213 -0
- package/assets/types/generated/src/index.d.ts +249 -0
- package/assets/types/generated/src/input-group.d.ts +135 -0
- package/assets/types/generated/src/models.d.ts +968 -0
- package/assets/types/generated/src/popover.d.ts +412 -0
- package/assets/types/generated/src/router.d.ts +344 -0
- package/assets/types/generated/src/safe-url.d.ts +10 -0
- package/assets/types/generated/src/sanitize.d.ts +97 -0
- package/assets/types/generated/src/schema-builder.d.ts +420 -0
- package/assets/types/generated/src/skeleton.d.ts +135 -0
- package/assets/types/generated/src/smooth-caret.d.ts +61 -0
- package/assets/types/generated/src/sortable.d.ts +369 -0
- package/assets/types/generated/src/storage.d.ts +93 -0
- package/assets/types/generated/src/tables.d.ts +901 -0
- package/assets/types/generated/src/theme.d.ts +277 -0
- package/assets/types/generated/src/ticker-tape-drawing.d.ts +2 -0
- package/assets/types/generated/src/treeview.d.ts +504 -0
- package/assets/types/generated/src/utils.d.ts +1667 -0
- package/assets/types/generated/src/web-components/base/domma-element.d.ts +134 -0
- package/assets/types/generated/src/web-components/index.d.ts +14 -0
- package/assets/types/generated/vendor/domma-reactive.d.ts +587 -0
- package/assets/types/index.d.ts +104 -216
- package/package.json +5 -2
- package/public/dist/bundles/domma-complete.css +1084 -14
- package/public/dist/bundles/domma-data-focused.css +1084 -14
- package/public/dist/bundles/domma-essentials.css +1084 -14
- package/public/dist/bundles/domma-full.css +1084 -14
- package/public/dist/bundles/domma-minimal.css +8 -8
- package/public/dist/domma-flags.esm.js +3 -3
- package/public/dist/domma-flags.esm.js.map +1 -1
- package/public/dist/domma-flags.min.js +3 -3
- package/public/dist/domma-flags.min.js.map +1 -1
- package/public/dist/domma-syntax.min.js +3 -3
- package/public/dist/domma.css +3 -3
- package/public/dist/domma.esm.js +5 -5
- package/public/dist/domma.esm.js.map +1 -1
- package/public/dist/domma.min.js +5 -5
- package/public/dist/domma.min.js.map +1 -1
- package/public/dist/elements.css +1073 -3
- package/public/dist/grid.css +3 -3
- package/public/dist/syntax.css +3 -3
- package/public/dist/themes/domma-themes.css +3 -3
- package/templates/kickstart/frontend/types/domma.d.ts +2 -1
- package/assets/types/config.d.ts +0 -136
- package/assets/types/dates.d.ts +0 -209
- package/assets/types/dom.d.ts +0 -448
- package/assets/types/elements.d.ts +0 -682
- package/assets/types/flags.d.ts +0 -130
- package/assets/types/http.d.ts +0 -97
- package/assets/types/icons.d.ts +0 -147
- package/assets/types/models.d.ts +0 -260
- package/assets/types/smooth-caret.d.ts +0 -12
- package/assets/types/storage.d.ts +0 -93
- package/assets/types/tables.d.ts +0 -327
- package/assets/types/theme.d.ts +0 -137
- package/assets/types/utils.d.ts +0 -675
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/** Whether this is an Apple platform, where "mod" means Cmd rather than Ctrl. */
|
|
2
|
+
export function isMac(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* 'mod+shift+k' -> {key: 'k', mod: true, shift: true, ...}. `mod` is Cmd on a Mac and
|
|
5
|
+
* Ctrl elsewhere.
|
|
6
|
+
* @param {string} combo
|
|
7
|
+
* @returns {{key: string, mod: boolean, ctrl: boolean, meta: boolean, alt: boolean, shift: boolean}|null}
|
|
8
|
+
*/
|
|
9
|
+
export function parseHotkey(combo: string): {
|
|
10
|
+
key: string;
|
|
11
|
+
mod: boolean;
|
|
12
|
+
ctrl: boolean;
|
|
13
|
+
meta: boolean;
|
|
14
|
+
alt: boolean;
|
|
15
|
+
shift: boolean;
|
|
16
|
+
} | null;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a keydown matches a parsed hotkey.
|
|
19
|
+
* @param {KeyboardEvent} e
|
|
20
|
+
* @param {NonNullable<ReturnType<typeof parseHotkey>>} hotkey - from parseHotkey
|
|
21
|
+
* @param {boolean} [mac]
|
|
22
|
+
*/
|
|
23
|
+
export function matchesHotkey(e: KeyboardEvent, hotkey: NonNullable<ReturnType<typeof parseHotkey>>, mac?: boolean): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The keys of a shortcut as labels to show: 'mod+s' is ['⌘', 'S'] on a Mac, ['Ctrl', 'S'] elsewhere.
|
|
26
|
+
* @param {string} combo
|
|
27
|
+
* @param {boolean} [mac]
|
|
28
|
+
* @returns {string[]}
|
|
29
|
+
*/
|
|
30
|
+
export function formatShortcut(combo: string, mac?: boolean): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Fuzzy match: the query's letters appear in the text in order. Scored so an exact
|
|
33
|
+
* prefix beats a substring, a substring beats scattered letters, and letters at word
|
|
34
|
+
* starts or in unbroken runs beat ones in the middle of words.
|
|
35
|
+
* @param {string} query
|
|
36
|
+
* @param {string} text
|
|
37
|
+
* @returns {{score: number, indices: number[]}|null} null when it does not match
|
|
38
|
+
*/
|
|
39
|
+
export function fuzzyMatch(query: string, text: string): {
|
|
40
|
+
score: number;
|
|
41
|
+
indices: number[];
|
|
42
|
+
} | null;
|
|
43
|
+
/**
|
|
44
|
+
* Whether a live palette answers this keydown. A page script with its own shortcut
|
|
45
|
+
* (the site search's Ctrl/Cmd+K) asks this rather than relying on listener order.
|
|
46
|
+
* Exposed as E.commandPalette.claims(e).
|
|
47
|
+
* @param {KeyboardEvent} e
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
export function claimsHotkey(e: KeyboardEvent): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* A new command palette.
|
|
53
|
+
* @param {CommandPaletteOptions} [options]
|
|
54
|
+
* @returns {CommandPalette}
|
|
55
|
+
*/
|
|
56
|
+
export function createCommandPalette(options?: CommandPaletteOptions): CommandPalette;
|
|
57
|
+
export class CommandPalette extends Component {
|
|
58
|
+
/** @type {CommandPaletteOptions} */
|
|
59
|
+
static defaults: CommandPaletteOptions;
|
|
60
|
+
static _makeRoot(): HTMLDivElement;
|
|
61
|
+
/**
|
|
62
|
+
* @param {CommandPaletteOptions} [options]
|
|
63
|
+
*/
|
|
64
|
+
constructor(options?: CommandPaletteOptions);
|
|
65
|
+
_isOpen: boolean;
|
|
66
|
+
_commands: any[];
|
|
67
|
+
_pages: any[];
|
|
68
|
+
_query: string;
|
|
69
|
+
_results: any[];
|
|
70
|
+
_active: number;
|
|
71
|
+
_sourceResults: any[];
|
|
72
|
+
_loading: boolean;
|
|
73
|
+
_error: any;
|
|
74
|
+
_timers: Set<any>;
|
|
75
|
+
_known: Map<any, any>;
|
|
76
|
+
_abort: AbortController;
|
|
77
|
+
_sourceToken: number;
|
|
78
|
+
_trap: FocusTrap;
|
|
79
|
+
get _mac(): boolean;
|
|
80
|
+
_build(): void;
|
|
81
|
+
_idBase: string;
|
|
82
|
+
_backdrop: HTMLDivElement;
|
|
83
|
+
_panel: HTMLDivElement;
|
|
84
|
+
_crumbs: HTMLDivElement;
|
|
85
|
+
_back: HTMLButtonElement;
|
|
86
|
+
_trail: HTMLOListElement;
|
|
87
|
+
_input: HTMLInputElement;
|
|
88
|
+
_spinner: HTMLSpanElement;
|
|
89
|
+
_list: HTMLDivElement;
|
|
90
|
+
_status: HTMLDivElement;
|
|
91
|
+
_live: HTMLDivElement;
|
|
92
|
+
_bind(): void;
|
|
93
|
+
_downOnBackdrop: boolean;
|
|
94
|
+
_hotkeyList: {
|
|
95
|
+
key: string;
|
|
96
|
+
mod: boolean;
|
|
97
|
+
ctrl: boolean;
|
|
98
|
+
meta: boolean;
|
|
99
|
+
alt: boolean;
|
|
100
|
+
shift: boolean;
|
|
101
|
+
}[];
|
|
102
|
+
_hotkeys(): {
|
|
103
|
+
key: string;
|
|
104
|
+
mod: boolean;
|
|
105
|
+
ctrl: boolean;
|
|
106
|
+
meta: boolean;
|
|
107
|
+
alt: boolean;
|
|
108
|
+
shift: boolean;
|
|
109
|
+
}[];
|
|
110
|
+
_later(fn: any, ms: any): number;
|
|
111
|
+
_clearTimer(t: any): void;
|
|
112
|
+
_duration(): number;
|
|
113
|
+
/**
|
|
114
|
+
* Open at the top level, with an optional query typed in.
|
|
115
|
+
* @param {string} [query]
|
|
116
|
+
* @returns {this}
|
|
117
|
+
*/
|
|
118
|
+
open(query?: string): this;
|
|
119
|
+
/** @returns {this} */
|
|
120
|
+
close(): this;
|
|
121
|
+
_hideTimer: number;
|
|
122
|
+
/**
|
|
123
|
+
* @overload
|
|
124
|
+
* @param {string} [query]
|
|
125
|
+
* @returns {this}
|
|
126
|
+
*/
|
|
127
|
+
toggle(query?: string): this;
|
|
128
|
+
/** @returns {boolean} */
|
|
129
|
+
isOpen(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Permanent alias of open(), looked up by name.
|
|
132
|
+
* @overload
|
|
133
|
+
* @param {string} [query]
|
|
134
|
+
* @returns {this}
|
|
135
|
+
*/
|
|
136
|
+
show(query?: string): this;
|
|
137
|
+
/**
|
|
138
|
+
* Permanent alias of close(), looked up by name.
|
|
139
|
+
* @overload
|
|
140
|
+
* @returns {this}
|
|
141
|
+
*/
|
|
142
|
+
hide(): this;
|
|
143
|
+
/**
|
|
144
|
+
* Permanent alias of isOpen().
|
|
145
|
+
* @returns {boolean}
|
|
146
|
+
*/
|
|
147
|
+
isVisible(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Replace every top-level command.
|
|
150
|
+
* @param {PaletteCommand[]} list
|
|
151
|
+
* @returns {this}
|
|
152
|
+
*/
|
|
153
|
+
setCommands(list: PaletteCommand[]): this;
|
|
154
|
+
/**
|
|
155
|
+
* Add top-level commands (one, or a list). A command with the id of one already
|
|
156
|
+
* there replaces it in place.
|
|
157
|
+
* @param {PaletteCommand|PaletteCommand[]} list
|
|
158
|
+
* @returns {this}
|
|
159
|
+
*/
|
|
160
|
+
addCommands(list: PaletteCommand | PaletteCommand[]): this;
|
|
161
|
+
/**
|
|
162
|
+
* Remove a top-level command by id.
|
|
163
|
+
* @param {string} id
|
|
164
|
+
* @returns {this}
|
|
165
|
+
*/
|
|
166
|
+
removeCommand(id: string): this;
|
|
167
|
+
/** @returns {PaletteCommand[]} the top-level commands */
|
|
168
|
+
getCommands(): PaletteCommand[];
|
|
169
|
+
/**
|
|
170
|
+
* Up one nested page. At the top level it does nothing and returns false.
|
|
171
|
+
* @returns {boolean}
|
|
172
|
+
*/
|
|
173
|
+
back(): boolean;
|
|
174
|
+
/**
|
|
175
|
+
* The current query.
|
|
176
|
+
* @returns {string}
|
|
177
|
+
*/
|
|
178
|
+
query(): string;
|
|
179
|
+
/**
|
|
180
|
+
* The ids of the remembered recent commands, newest first.
|
|
181
|
+
* @returns {string[]}
|
|
182
|
+
*/
|
|
183
|
+
recent(): string[];
|
|
184
|
+
/**
|
|
185
|
+
* Forget the remembered recent commands.
|
|
186
|
+
* @returns {this}
|
|
187
|
+
*/
|
|
188
|
+
clearRecent(): this;
|
|
189
|
+
_destroyed: boolean;
|
|
190
|
+
_applyOptions(): void;
|
|
191
|
+
_refresh(): void;
|
|
192
|
+
_currentPage(): any;
|
|
193
|
+
_usesSource(): boolean;
|
|
194
|
+
_setQuery(value: any, opts?: {}): void;
|
|
195
|
+
_debounceTimer: number;
|
|
196
|
+
_cancelSource(): void;
|
|
197
|
+
_runSource(query: any): void;
|
|
198
|
+
/** Every command reachable without a request: the top level and array children. */
|
|
199
|
+
_findById(id: any, list?: any[], depth?: number): any;
|
|
200
|
+
_remember(command: any): void;
|
|
201
|
+
/** Group and order what is shown now. */
|
|
202
|
+
_compute(): {
|
|
203
|
+
name: any;
|
|
204
|
+
items: any;
|
|
205
|
+
}[];
|
|
206
|
+
_update(opts?: {}): void;
|
|
207
|
+
_nextEnabled(from: any, step: any, wrap?: boolean): any;
|
|
208
|
+
_setActive(index: any, opts?: {}): void;
|
|
209
|
+
_renderList(groups: any): void;
|
|
210
|
+
_renderItem(command: any, match: any, index: any, mac: any): HTMLDivElement;
|
|
211
|
+
_renderCrumbs(): void;
|
|
212
|
+
_renderStatus(): void;
|
|
213
|
+
_liveTimer: number;
|
|
214
|
+
_onKeyDown(e: any): void;
|
|
215
|
+
_choose(command: any, event: any): void;
|
|
216
|
+
_enter(command: any): void;
|
|
217
|
+
_run(command: any, event: any): void;
|
|
218
|
+
}
|
|
219
|
+
export default CommandPalette;
|
|
220
|
+
/**
|
|
221
|
+
* The context a `source` or async `children` function gets.
|
|
222
|
+
*/
|
|
223
|
+
export type PaletteSourceContext = {
|
|
224
|
+
signal?: AbortSignal;
|
|
225
|
+
palette: CommandPaletteInstance;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* One command in the palette.
|
|
229
|
+
*/
|
|
230
|
+
export type PaletteCommand = {
|
|
231
|
+
id?: string;
|
|
232
|
+
title: string;
|
|
233
|
+
subtitle?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Heading the command is listed under
|
|
236
|
+
*/
|
|
237
|
+
group?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Domma icon name
|
|
240
|
+
*/
|
|
241
|
+
icon?: string;
|
|
242
|
+
/**
|
|
243
|
+
* More words that find it
|
|
244
|
+
*/
|
|
245
|
+
keywords?: string[];
|
|
246
|
+
/**
|
|
247
|
+
* Shown as a hint, e.g. 'mod+s' (mod = Cmd on a Mac, Ctrl elsewhere)
|
|
248
|
+
*/
|
|
249
|
+
shortcut?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Followed when run (http(s), mailto, tel or relative only)
|
|
252
|
+
*/
|
|
253
|
+
href?: string;
|
|
254
|
+
/**
|
|
255
|
+
* '_blank' opens href in a new tab
|
|
256
|
+
*/
|
|
257
|
+
target?: string;
|
|
258
|
+
action?: (command: PaletteCommand, palette: CommandPaletteInstance, event?: Event) => void;
|
|
259
|
+
disabled?: boolean;
|
|
260
|
+
hidden?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* Running it leaves the palette open
|
|
263
|
+
*/
|
|
264
|
+
keepOpen?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* A nested page: a list, or a function returning one (called once on entering)
|
|
267
|
+
*/
|
|
268
|
+
children?: PaletteCommand[] | ((command: PaletteCommand, ctx: PaletteSourceContext) => Promise<PaletteCommand[]> | PaletteCommand[]);
|
|
269
|
+
/**
|
|
270
|
+
* Placeholder for the box while this command's page is open
|
|
271
|
+
*/
|
|
272
|
+
placeholder?: string;
|
|
273
|
+
};
|
|
274
|
+
export type CommandPaletteOptions = {
|
|
275
|
+
commands?: PaletteCommand[];
|
|
276
|
+
/**
|
|
277
|
+
* Search elsewhere: debounced, the previous request aborted through `signal`
|
|
278
|
+
*/
|
|
279
|
+
source?: ((query: string, ctx: PaletteSourceContext) => Promise<PaletteCommand[]> | PaletteCommand[]) | null;
|
|
280
|
+
/**
|
|
281
|
+
* ms (default 150)
|
|
282
|
+
*/
|
|
283
|
+
debounce?: number;
|
|
284
|
+
/**
|
|
285
|
+
* 'mod+k' (default), several, or false
|
|
286
|
+
*/
|
|
287
|
+
hotkey?: string | string[] | false;
|
|
288
|
+
placeholder?: string;
|
|
289
|
+
/**
|
|
290
|
+
* Accessible name of the dialog and list (default 'Command palette')
|
|
291
|
+
*/
|
|
292
|
+
label?: string;
|
|
293
|
+
maxResults?: number;
|
|
294
|
+
/**
|
|
295
|
+
* Storage (S) key for recent commands; null (default) = off
|
|
296
|
+
*/
|
|
297
|
+
recentKey?: string | null;
|
|
298
|
+
recentLimit?: number;
|
|
299
|
+
recentLabel?: string;
|
|
300
|
+
/**
|
|
301
|
+
* Heading for source results without their own group
|
|
302
|
+
*/
|
|
303
|
+
sourceGroup?: string | null;
|
|
304
|
+
emptyText?: string;
|
|
305
|
+
loadingText?: string;
|
|
306
|
+
/**
|
|
307
|
+
* While a nested page's async children load (default 'Loading…')
|
|
308
|
+
*/
|
|
309
|
+
pageLoadingText?: string;
|
|
310
|
+
errorText?: string;
|
|
311
|
+
backLabel?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Key hints under the list (default true)
|
|
314
|
+
*/
|
|
315
|
+
footer?: boolean;
|
|
316
|
+
resultsText?: (count: number) => string;
|
|
317
|
+
/**
|
|
318
|
+
* Replaces the default navigation for href commands
|
|
319
|
+
*/
|
|
320
|
+
navigate?: ((href: string, ctx: {
|
|
321
|
+
newTab: boolean;
|
|
322
|
+
command: PaletteCommand;
|
|
323
|
+
}) => void) | null;
|
|
324
|
+
animationDuration?: number;
|
|
325
|
+
className?: string;
|
|
326
|
+
/**
|
|
327
|
+
* Force Mac (true) or other (false) key names; default detects
|
|
328
|
+
*/
|
|
329
|
+
mac?: boolean;
|
|
330
|
+
onBeforeOpen?: ((palette: CommandPaletteInstance) => boolean | void) | null;
|
|
331
|
+
onOpen?: ((palette: CommandPaletteInstance) => void) | null;
|
|
332
|
+
onBeforeClose?: ((palette: CommandPaletteInstance) => boolean | void) | null;
|
|
333
|
+
onClose?: ((palette: CommandPaletteInstance) => void) | null;
|
|
334
|
+
onQuery?: ((query: string, palette: CommandPaletteInstance) => void) | null;
|
|
335
|
+
onBeforeSelect?: ((command: PaletteCommand, palette: CommandPaletteInstance) => boolean | void) | null;
|
|
336
|
+
onSelect?: ((command: PaletteCommand, palette: CommandPaletteInstance) => void) | null;
|
|
337
|
+
onRun?: ((command: PaletteCommand, palette: CommandPaletteInstance) => void) | null;
|
|
338
|
+
};
|
|
339
|
+
export type CommandPaletteInstance = CommandPalette;
|
|
340
|
+
/**
|
|
341
|
+
* `E.commandPalette(options)` with its helpers.
|
|
342
|
+
*/
|
|
343
|
+
export type CommandPaletteFactory = ((options?: CommandPaletteOptions) => CommandPaletteInstance) & {
|
|
344
|
+
formatShortcut: (combo: string, mac?: boolean) => string[];
|
|
345
|
+
fuzzyMatch: (query: string, text: string) => ({
|
|
346
|
+
score: number;
|
|
347
|
+
indices: number[];
|
|
348
|
+
} | null);
|
|
349
|
+
claims: (e: KeyboardEvent) => boolean;
|
|
350
|
+
};
|
|
351
|
+
import Component from '../component.js';
|
|
352
|
+
import FocusTrap from './focus-trap.js';
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "1.5 MB" - powers of 1024, the way file managers show sizes.
|
|
3
|
+
* @param {number|string} bytes
|
|
4
|
+
* @returns {string}
|
|
5
|
+
*/
|
|
6
|
+
export function formatBytes(bytes: number | string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a file matches an accept list (an empty list takes anything).
|
|
9
|
+
* @param {{name?: string, type?: string}|null|undefined} file
|
|
10
|
+
* @param {string|string[]|null} [accept]
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
export function accepts(file: {
|
|
14
|
+
name?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
} | null | undefined, accept?: string | string[] | null): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* E.dropzone: one instance per element; a second call updates it.
|
|
19
|
+
* @param {Element} el
|
|
20
|
+
* @param {DropzoneOptions} [options]
|
|
21
|
+
* @returns {Dropzone}
|
|
22
|
+
*/
|
|
23
|
+
export function dropzoneFor(el: Element, options?: DropzoneOptions): Dropzone;
|
|
24
|
+
export function _guardState(): {
|
|
25
|
+
zones: number;
|
|
26
|
+
armed: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** @typedef {'queued'|'uploading'|'done'|'error'|'cancelled'} DropzoneStatus */
|
|
29
|
+
/** @typedef {'type'|'size'|'count'} DropzoneRejectReason */
|
|
30
|
+
/**
|
|
31
|
+
* One file in a dropzone, as every event hands it over.
|
|
32
|
+
* @typedef {object} DropzoneEntry
|
|
33
|
+
* @property {string} id
|
|
34
|
+
* @property {File} file
|
|
35
|
+
* @property {string} name
|
|
36
|
+
* @property {number} size
|
|
37
|
+
* @property {string} type
|
|
38
|
+
* @property {DropzoneStatus} status
|
|
39
|
+
* @property {number} progress Upload progress, 0-100
|
|
40
|
+
* @property {any} response The upload's response (parsed when it was JSON)
|
|
41
|
+
* @property {DropzoneUploadError|null} error
|
|
42
|
+
* @property {number} attempts Upload attempts since the last (re)queue
|
|
43
|
+
* @property {string|null} preview Object URL of an image preview, revoked when the file goes
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* @typedef {object} DropzoneUploadError
|
|
47
|
+
* @property {number} status HTTP status, 0 for a network failure
|
|
48
|
+
* @property {string} message
|
|
49
|
+
* @property {any} response
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {object} DropzoneUploadOptions
|
|
53
|
+
* @property {string|((entry: DropzoneEntry) => string)} url
|
|
54
|
+
* @property {string} [method] Default 'POST'
|
|
55
|
+
* @property {string} [field] FormData field for the file. Default 'file'
|
|
56
|
+
* @property {Record<string, string>|((entry: DropzoneEntry) => Record<string, string>)} [headers]
|
|
57
|
+
* @property {boolean} [withCredentials]
|
|
58
|
+
* @property {number} [concurrency] Files sent at once. Default 2
|
|
59
|
+
* @property {Record<string, string|Blob>|((entry: DropzoneEntry) => Record<string, string|Blob>)} [data] Extra FormData fields
|
|
60
|
+
* @property {(entry: DropzoneEntry) => XMLHttpRequest} [xhr] Make the request object (tests, pages without a server). Default: new XMLHttpRequest()
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {object} DropzoneOptions
|
|
64
|
+
* @property {string|string[]|null} [accept] Like the input's accept: '.pdf,image/*' or ['.pdf', 'image/*']. Default: the input's
|
|
65
|
+
* @property {boolean|null} [multiple] Default: the input's `multiple`, or true when the component makes the input
|
|
66
|
+
* @property {number|null} [maxFiles]
|
|
67
|
+
* @property {number|null} [maxSize] Bytes
|
|
68
|
+
* @property {number|null} [minSize] Bytes
|
|
69
|
+
* @property {boolean} [previews] Image thumbnails. Default true
|
|
70
|
+
* @property {string|null} [name] Form field name. Default: the input's
|
|
71
|
+
* @property {string|HTMLInputElement|null} [input] The file input, when it is not inside or next to the area
|
|
72
|
+
* @property {boolean|string|HTMLElement} [list] true = after the area (default), an element/selector to draw into, false = no list
|
|
73
|
+
* @property {DropzoneUploadOptions|null} [upload]
|
|
74
|
+
* @property {boolean} [autoUpload] Default true
|
|
75
|
+
* @property {number} [retry] Automatic retries per file. Default 0
|
|
76
|
+
* @property {Record<string, string>} [labels] Text: prompt, hint, remove, retry, cancel, added, removed, type, size, small, count, uploading, done, failed, cancelled, required ({name}, {max}, {min}, {percent})
|
|
77
|
+
* @property {boolean} [disabled]
|
|
78
|
+
* @property {string} [className]
|
|
79
|
+
* @property {((entry: DropzoneEntry) => boolean|void)|null} [onBeforeAdd] Return false to refuse the file
|
|
80
|
+
* @property {((entry: DropzoneEntry) => void)|null} [onAdd]
|
|
81
|
+
* @property {((entry: DropzoneEntry, reason: DropzoneRejectReason) => void)|null} [onReject]
|
|
82
|
+
* @property {((entry: DropzoneEntry) => void)|null} [onRemove]
|
|
83
|
+
* @property {((files: File[]) => void)|null} [onChange]
|
|
84
|
+
* @property {((entry: DropzoneEntry) => void)|null} [onUploadStart]
|
|
85
|
+
* @property {((entry: DropzoneEntry, percent: number) => void)|null} [onProgress]
|
|
86
|
+
* @property {((entry: DropzoneEntry, response: any) => void)|null} [onSuccess]
|
|
87
|
+
* @property {((entry: DropzoneEntry, error: DropzoneUploadError) => void)|null} [onError]
|
|
88
|
+
* @property {((entries: DropzoneEntry[]) => void)|null} [onComplete]
|
|
89
|
+
*/
|
|
90
|
+
/** @typedef {Dropzone} DropzoneInstance */
|
|
91
|
+
export class Dropzone extends Component {
|
|
92
|
+
/** @type {DropzoneOptions} */
|
|
93
|
+
static defaults: DropzoneOptions;
|
|
94
|
+
/**
|
|
95
|
+
* @param {string|Element|null} element - The drop area, or the file input itself
|
|
96
|
+
* @param {DropzoneOptions} [options]
|
|
97
|
+
*/
|
|
98
|
+
constructor(element: string | Element | null, options?: DropzoneOptions);
|
|
99
|
+
_entries: any[];
|
|
100
|
+
_queue: any[];
|
|
101
|
+
_active: number;
|
|
102
|
+
_batch: boolean;
|
|
103
|
+
_added: any[];
|
|
104
|
+
_canSync: boolean;
|
|
105
|
+
_labels: any;
|
|
106
|
+
_guarded: boolean;
|
|
107
|
+
_setupZone(): void;
|
|
108
|
+
/** The drop area (the element, or the one drawn after a file input given as the target). @type {HTMLElement} */
|
|
109
|
+
zone: HTMLElement;
|
|
110
|
+
_givenInput: HTMLElement;
|
|
111
|
+
_restoreZone: {};
|
|
112
|
+
_zoneClasses: string[];
|
|
113
|
+
_isLabel: boolean;
|
|
114
|
+
_findInput(): any;
|
|
115
|
+
_setupInput(): void;
|
|
116
|
+
_restoreInput: {
|
|
117
|
+
hidden: any;
|
|
118
|
+
name: any;
|
|
119
|
+
multiple: any;
|
|
120
|
+
disabled: any;
|
|
121
|
+
tabindex: any;
|
|
122
|
+
accept: any;
|
|
123
|
+
};
|
|
124
|
+
/** The real file input. @type {HTMLInputElement} */
|
|
125
|
+
input: HTMLInputElement;
|
|
126
|
+
_setupList(): void;
|
|
127
|
+
_hintId: string;
|
|
128
|
+
_live: HTMLDivElement;
|
|
129
|
+
_list: HTMLUListElement;
|
|
130
|
+
_hint(): string;
|
|
131
|
+
_bind(): void;
|
|
132
|
+
_timers: any;
|
|
133
|
+
_applyDisabled(): void;
|
|
134
|
+
_entryFor(ref: any): any;
|
|
135
|
+
_makeEntry(file: any): {
|
|
136
|
+
id: string;
|
|
137
|
+
file: any;
|
|
138
|
+
name: string;
|
|
139
|
+
size: number;
|
|
140
|
+
type: string;
|
|
141
|
+
status: string;
|
|
142
|
+
progress: number;
|
|
143
|
+
response: any;
|
|
144
|
+
error: any;
|
|
145
|
+
attempts: number;
|
|
146
|
+
preview: any;
|
|
147
|
+
};
|
|
148
|
+
_rejectReason(entry: any, countSoFar: any): "size" | "type" | "count";
|
|
149
|
+
_rejectMessage(entry: any, reason: any): string;
|
|
150
|
+
/**
|
|
151
|
+
* Add files (a FileList, an array of File, or one File). Each passes the accept / size /
|
|
152
|
+
* count rules and `beforeadd`, or fires `reject` (type | size | count). Without
|
|
153
|
+
* `multiple`, a new file replaces the one there.
|
|
154
|
+
* @param {FileList|File[]|File} files
|
|
155
|
+
* @returns {DropzoneEntry[]} the entries added
|
|
156
|
+
*/
|
|
157
|
+
addFiles(files: FileList | File[] | File): DropzoneEntry[];
|
|
158
|
+
/**
|
|
159
|
+
* Remove a file (by entry, id or File). An upload in progress is cancelled.
|
|
160
|
+
* @param {DropzoneEntry|string|File} ref
|
|
161
|
+
* @returns {boolean}
|
|
162
|
+
*/
|
|
163
|
+
removeFile(ref: DropzoneEntry | string | File): boolean;
|
|
164
|
+
_drop(entry: any): void;
|
|
165
|
+
/** Remove every file. @returns {this} */
|
|
166
|
+
clear(): this;
|
|
167
|
+
/** @returns {File[]} the files shown, in order */
|
|
168
|
+
getFiles(): File[];
|
|
169
|
+
/** @returns {DropzoneEntry[]} the entries (file, status, progress, response...) */
|
|
170
|
+
getEntries(): DropzoneEntry[];
|
|
171
|
+
/** Open the file picker. @returns {this} */
|
|
172
|
+
browse(): this;
|
|
173
|
+
/** Keep the real input's FileList in step with the list (no upload), or empty (upload). */
|
|
174
|
+
_syncInput(): void;
|
|
175
|
+
_settingFiles: boolean;
|
|
176
|
+
_announce(message: any): void;
|
|
177
|
+
_preview(entry: any): void;
|
|
178
|
+
_renderEntry(entry: any): void;
|
|
179
|
+
_paintEntry(entry: any): void;
|
|
180
|
+
/**
|
|
181
|
+
* Upload every file not yet uploaded (queued, failed or cancelled). Needs `upload`.
|
|
182
|
+
* @returns {this}
|
|
183
|
+
*/
|
|
184
|
+
upload(): this;
|
|
185
|
+
/**
|
|
186
|
+
* Upload failed or cancelled files again - one by id/entry/File, or all of them.
|
|
187
|
+
* @param {string|DropzoneEntry|File} [ref]
|
|
188
|
+
* @returns {this}
|
|
189
|
+
*/
|
|
190
|
+
retry(ref?: string | DropzoneEntry | File): this;
|
|
191
|
+
/**
|
|
192
|
+
* Stop uploads - one file, or all of them. Queued files are taken out of the queue.
|
|
193
|
+
* @param {string|DropzoneEntry|File} [ref]
|
|
194
|
+
* @returns {this}
|
|
195
|
+
*/
|
|
196
|
+
cancel(ref?: string | DropzoneEntry | File): this;
|
|
197
|
+
_abort(entry: any): void;
|
|
198
|
+
_pump(): void;
|
|
199
|
+
_maybeComplete(): void;
|
|
200
|
+
/**
|
|
201
|
+
* One file, one request. XMLHttpRequest rather than H: H is built on fetch(), and fetch
|
|
202
|
+
* has no upload progress events - `xhr.upload.onprogress` is the only way a browser
|
|
203
|
+
* reports how much of a request body has been sent.
|
|
204
|
+
*/
|
|
205
|
+
_send(entry: any): void;
|
|
206
|
+
/** @returns {boolean} */
|
|
207
|
+
isDisabled(): boolean;
|
|
208
|
+
/** @returns {this} */
|
|
209
|
+
enable(): this;
|
|
210
|
+
/** @returns {this} */
|
|
211
|
+
disable(): this;
|
|
212
|
+
_applyOptions(): void;
|
|
213
|
+
}
|
|
214
|
+
export default Dropzone;
|
|
215
|
+
export type DropzoneStatus = "queued" | "uploading" | "done" | "error" | "cancelled";
|
|
216
|
+
export type DropzoneRejectReason = "type" | "size" | "count";
|
|
217
|
+
/**
|
|
218
|
+
* One file in a dropzone, as every event hands it over.
|
|
219
|
+
*/
|
|
220
|
+
export type DropzoneEntry = {
|
|
221
|
+
id: string;
|
|
222
|
+
file: File;
|
|
223
|
+
name: string;
|
|
224
|
+
size: number;
|
|
225
|
+
type: string;
|
|
226
|
+
status: DropzoneStatus;
|
|
227
|
+
/**
|
|
228
|
+
* Upload progress, 0-100
|
|
229
|
+
*/
|
|
230
|
+
progress: number;
|
|
231
|
+
/**
|
|
232
|
+
* The upload's response (parsed when it was JSON)
|
|
233
|
+
*/
|
|
234
|
+
response: any;
|
|
235
|
+
error: DropzoneUploadError | null;
|
|
236
|
+
/**
|
|
237
|
+
* Upload attempts since the last (re)queue
|
|
238
|
+
*/
|
|
239
|
+
attempts: number;
|
|
240
|
+
/**
|
|
241
|
+
* Object URL of an image preview, revoked when the file goes
|
|
242
|
+
*/
|
|
243
|
+
preview: string | null;
|
|
244
|
+
};
|
|
245
|
+
export type DropzoneUploadError = {
|
|
246
|
+
/**
|
|
247
|
+
* HTTP status, 0 for a network failure
|
|
248
|
+
*/
|
|
249
|
+
status: number;
|
|
250
|
+
message: string;
|
|
251
|
+
response: any;
|
|
252
|
+
};
|
|
253
|
+
export type DropzoneUploadOptions = {
|
|
254
|
+
url: string | ((entry: DropzoneEntry) => string);
|
|
255
|
+
/**
|
|
256
|
+
* Default 'POST'
|
|
257
|
+
*/
|
|
258
|
+
method?: string;
|
|
259
|
+
/**
|
|
260
|
+
* FormData field for the file. Default 'file'
|
|
261
|
+
*/
|
|
262
|
+
field?: string;
|
|
263
|
+
headers?: Record<string, string> | ((entry: DropzoneEntry) => Record<string, string>);
|
|
264
|
+
withCredentials?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Files sent at once. Default 2
|
|
267
|
+
*/
|
|
268
|
+
concurrency?: number;
|
|
269
|
+
/**
|
|
270
|
+
* Extra FormData fields
|
|
271
|
+
*/
|
|
272
|
+
data?: Record<string, string | Blob> | ((entry: DropzoneEntry) => Record<string, string | Blob>);
|
|
273
|
+
/**
|
|
274
|
+
* Make the request object (tests, pages without a server). Default: new XMLHttpRequest()
|
|
275
|
+
*/
|
|
276
|
+
xhr?: (entry: DropzoneEntry) => XMLHttpRequest;
|
|
277
|
+
};
|
|
278
|
+
export type DropzoneOptions = {
|
|
279
|
+
/**
|
|
280
|
+
* Like the input's accept: '.pdf,image/*' or ['.pdf', 'image/*']. Default: the input's
|
|
281
|
+
*/
|
|
282
|
+
accept?: string | string[] | null;
|
|
283
|
+
/**
|
|
284
|
+
* Default: the input's `multiple`, or true when the component makes the input
|
|
285
|
+
*/
|
|
286
|
+
multiple?: boolean | null;
|
|
287
|
+
maxFiles?: number | null;
|
|
288
|
+
/**
|
|
289
|
+
* Bytes
|
|
290
|
+
*/
|
|
291
|
+
maxSize?: number | null;
|
|
292
|
+
/**
|
|
293
|
+
* Bytes
|
|
294
|
+
*/
|
|
295
|
+
minSize?: number | null;
|
|
296
|
+
/**
|
|
297
|
+
* Image thumbnails. Default true
|
|
298
|
+
*/
|
|
299
|
+
previews?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Form field name. Default: the input's
|
|
302
|
+
*/
|
|
303
|
+
name?: string | null;
|
|
304
|
+
/**
|
|
305
|
+
* The file input, when it is not inside or next to the area
|
|
306
|
+
*/
|
|
307
|
+
input?: string | HTMLInputElement | null;
|
|
308
|
+
/**
|
|
309
|
+
* true = after the area (default), an element/selector to draw into, false = no list
|
|
310
|
+
*/
|
|
311
|
+
list?: boolean | string | HTMLElement;
|
|
312
|
+
upload?: DropzoneUploadOptions | null;
|
|
313
|
+
/**
|
|
314
|
+
* Default true
|
|
315
|
+
*/
|
|
316
|
+
autoUpload?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Automatic retries per file. Default 0
|
|
319
|
+
*/
|
|
320
|
+
retry?: number;
|
|
321
|
+
/**
|
|
322
|
+
* Text: prompt, hint, remove, retry, cancel, added, removed, type, size, small, count, uploading, done, failed, cancelled, required ({name}, {max}, {min}, {percent})
|
|
323
|
+
*/
|
|
324
|
+
labels?: Record<string, string>;
|
|
325
|
+
disabled?: boolean;
|
|
326
|
+
className?: string;
|
|
327
|
+
/**
|
|
328
|
+
* Return false to refuse the file
|
|
329
|
+
*/
|
|
330
|
+
onBeforeAdd?: ((entry: DropzoneEntry) => boolean | void) | null;
|
|
331
|
+
onAdd?: ((entry: DropzoneEntry) => void) | null;
|
|
332
|
+
onReject?: ((entry: DropzoneEntry, reason: DropzoneRejectReason) => void) | null;
|
|
333
|
+
onRemove?: ((entry: DropzoneEntry) => void) | null;
|
|
334
|
+
onChange?: ((files: File[]) => void) | null;
|
|
335
|
+
onUploadStart?: ((entry: DropzoneEntry) => void) | null;
|
|
336
|
+
onProgress?: ((entry: DropzoneEntry, percent: number) => void) | null;
|
|
337
|
+
onSuccess?: ((entry: DropzoneEntry, response: any) => void) | null;
|
|
338
|
+
onError?: ((entry: DropzoneEntry, error: DropzoneUploadError) => void) | null;
|
|
339
|
+
onComplete?: ((entries: DropzoneEntry[]) => void) | null;
|
|
340
|
+
};
|
|
341
|
+
export type DropzoneInstance = Dropzone;
|
|
342
|
+
import Component from '../component.js';
|