domma-js 0.56.0 → 0.58.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/README.md +2 -2
- 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 +339 -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 +4994 -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 +413 -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 +368 -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 +262 -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 -226
- package/package.json +5 -2
- package/public/dist/bundles/domma-complete.css +20 -14
- package/public/dist/bundles/domma-data-focused.css +20 -14
- package/public/dist/bundles/domma-essentials.css +20 -14
- package/public/dist/bundles/domma-full.css +20 -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 +9 -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/.claude/snippets.md +1 -1
- package/templates/kickstart/CLAUDE.md +1 -1
- package/templates/kickstart/frontend/types/domma.d.ts +7 -4
- package/templates/kickstart-spa/.claude/snippets.md +1 -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 -1168
- package/assets/types/flags.d.ts +0 -130
- package/assets/types/http.d.ts +0 -97
- package/assets/types/i18n.d.ts +0 -99
- 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,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A new modal in the shared dialog container.
|
|
3
|
+
* @param {ModalOptions} [options]
|
|
4
|
+
* @returns {Modal}
|
|
5
|
+
*/
|
|
6
|
+
export function createModal(options?: ModalOptions): Modal;
|
|
7
|
+
/**
|
|
8
|
+
* Open a new modal and resolve with the id of the button that closed it
|
|
9
|
+
* (null when it was closed another way - X, backdrop or Escape).
|
|
10
|
+
* @param {ModalOptions} [options]
|
|
11
|
+
* @returns {Promise<string|null>}
|
|
12
|
+
*/
|
|
13
|
+
export function showModal(options?: ModalOptions): Promise<string | null>;
|
|
14
|
+
/**
|
|
15
|
+
* A footer button.
|
|
16
|
+
* @typedef {object} ModalButton
|
|
17
|
+
* @property {string} [id] - Passed to onButtonClick (default `btn-<index>`)
|
|
18
|
+
* @property {string} [text='Button'] - Label
|
|
19
|
+
* @property {string} [variant='secondary'] - Adds `btn-<variant>`
|
|
20
|
+
* @property {string} [className] - Extra classes
|
|
21
|
+
* @property {boolean} [close=true] - false keeps the modal open after the click
|
|
22
|
+
* @property {(modal: ModalInstance, event: MouseEvent) => void} [onClick]
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {object} ModalOptions
|
|
26
|
+
* @property {boolean} [backdrop=true] - Show backdrop overlay
|
|
27
|
+
* @property {boolean} [backdropClose=true] - Close modal when clicking backdrop
|
|
28
|
+
* @property {boolean} [keyboard=true] - Close modal on Escape key
|
|
29
|
+
* @property {boolean} [closeOnEscape=true] - Same as `keyboard`; either false keeps Escape from closing
|
|
30
|
+
* @property {import('../elements.js').AnimationType|false} [animation='fade'] - Animation type
|
|
31
|
+
* @property {number} [animationDuration=300] - Animation duration in ms
|
|
32
|
+
* @property {boolean} [closeButton=true] - Show close button
|
|
33
|
+
* @property {'small'|'sm'|'medium'|'md'|'large'|'lg'|'xl'|'xlarge'|'full'|(string & {})} [size='medium'] - A named size or any CSS width (the factory's default is 'large')
|
|
34
|
+
* @property {boolean} [centered=true] - Centre vertically (false: near the top)
|
|
35
|
+
* @property {boolean} [scrollable=false] - Scroll the body inside a capped height
|
|
36
|
+
* @property {string} [title] - Title text
|
|
37
|
+
* @property {string|Node} [content] - Body content (factory mode): HTML (sanitised unless `safe: false`) or a Node
|
|
38
|
+
* @property {string} [footer] - Footer text
|
|
39
|
+
* @property {ModalButton[]} [buttons] - Footer buttons (the factory's default is one Close button)
|
|
40
|
+
* @property {boolean} [safe=true] - false: content is trusted HTML (not sanitised)
|
|
41
|
+
* @property {string} [className] - Extra classes on the dialog
|
|
42
|
+
* @property {string} [headerClass] - Extra classes on the header
|
|
43
|
+
* @property {string} [bodyClass] - Extra classes on the body
|
|
44
|
+
* @property {string} [footerClass] - Extra classes on the footer
|
|
45
|
+
* @property {boolean} [focus=true] - Focus the dialog on open
|
|
46
|
+
* @property {boolean} [trapFocus=true] - Keep Tab inside while open (default true; false without a backdrop unless given)
|
|
47
|
+
* @property {boolean} [returnFocus=true] - Put focus back where it was on close
|
|
48
|
+
* @property {boolean} [visible=false] - Open at once
|
|
49
|
+
* @property {((modal: ModalInstance) => void)|null} [onOpen] - When opening starts
|
|
50
|
+
* @property {((modal: ModalInstance) => void)|null} [onOpened] - After open animation completes
|
|
51
|
+
* @property {((modal: ModalInstance) => void)|null} [onClose] - When closing starts
|
|
52
|
+
* @property {((modal: ModalInstance) => void)|null} [onClosed] - After close animation completes
|
|
53
|
+
* @property {((modal: ModalInstance) => boolean|void)|null} [onBeforeOpen] - Return false to refuse the open
|
|
54
|
+
* @property {((modal: ModalInstance) => boolean|void)|null} [onBeforeClose] - Return false to refuse the close
|
|
55
|
+
* @property {((buttonId: string, modal: ModalInstance) => void)|null} [onButtonClick] - A footer button was clicked
|
|
56
|
+
*/
|
|
57
|
+
/** @typedef {Modal} ModalInstance */
|
|
58
|
+
export class Modal extends Component {
|
|
59
|
+
static defaults: {
|
|
60
|
+
backdrop: boolean;
|
|
61
|
+
backdropClose: boolean;
|
|
62
|
+
keyboard: boolean;
|
|
63
|
+
closeOnEscape: boolean;
|
|
64
|
+
animation: string;
|
|
65
|
+
animationDuration: number;
|
|
66
|
+
closeButton: boolean;
|
|
67
|
+
size: string;
|
|
68
|
+
centered: boolean;
|
|
69
|
+
scrollable: boolean;
|
|
70
|
+
title: string;
|
|
71
|
+
content: string;
|
|
72
|
+
footer: string;
|
|
73
|
+
buttons: any[];
|
|
74
|
+
safe: boolean;
|
|
75
|
+
className: string;
|
|
76
|
+
headerClass: string;
|
|
77
|
+
bodyClass: string;
|
|
78
|
+
footerClass: string;
|
|
79
|
+
focus: boolean;
|
|
80
|
+
trapFocus: boolean;
|
|
81
|
+
returnFocus: boolean;
|
|
82
|
+
visible: boolean;
|
|
83
|
+
onOpen: any;
|
|
84
|
+
onOpened: any;
|
|
85
|
+
onClose: any;
|
|
86
|
+
onClosed: any;
|
|
87
|
+
onBeforeOpen: any;
|
|
88
|
+
onBeforeClose: any;
|
|
89
|
+
onButtonClick: any;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* @param {import('./shared.js').ComponentTarget} selector - the element to make a modal; null makes one
|
|
93
|
+
* @param {ModalOptions} [options]
|
|
94
|
+
*/
|
|
95
|
+
constructor(selector: import("./shared.js").ComponentTarget, options?: ModalOptions);
|
|
96
|
+
_factoryMade: boolean;
|
|
97
|
+
_isOpen: boolean;
|
|
98
|
+
_timers: any[];
|
|
99
|
+
_restoreFocus: Element;
|
|
100
|
+
_given: ModalOptions;
|
|
101
|
+
_init(): void;
|
|
102
|
+
_authored: boolean;
|
|
103
|
+
_host: HTMLElement | HTMLDivElement;
|
|
104
|
+
_addedClasses: string[];
|
|
105
|
+
_addedAttrs: any[];
|
|
106
|
+
/** Whether this open traps focus: on by default, except over a page left usable (no backdrop). */
|
|
107
|
+
_wantsTrap(): boolean;
|
|
108
|
+
_startTrap(): void;
|
|
109
|
+
_trap: FocusTrap;
|
|
110
|
+
/** Options the caller passed, without the defaults. */
|
|
111
|
+
_givenOptions(): ModalOptions;
|
|
112
|
+
_render(): void;
|
|
113
|
+
_backdrop: HTMLDivElement;
|
|
114
|
+
_dialog: HTMLDivElement;
|
|
115
|
+
_titleEl: HTMLHeadingElement;
|
|
116
|
+
_header: HTMLDivElement;
|
|
117
|
+
_body: HTMLDivElement;
|
|
118
|
+
_footer: HTMLDivElement;
|
|
119
|
+
_footerText: HTMLSpanElement;
|
|
120
|
+
_renderButtons(): void;
|
|
121
|
+
_bind(): void;
|
|
122
|
+
_downOnBackdrop: boolean;
|
|
123
|
+
/** A node is ours unless it sits inside another modal nested in this one. */
|
|
124
|
+
_ownsNode(node: any): boolean;
|
|
125
|
+
_later(fn: any, ms: any): void;
|
|
126
|
+
_clearTimers(): void;
|
|
127
|
+
_duration(): number;
|
|
128
|
+
/**
|
|
129
|
+
* Open the modal.
|
|
130
|
+
* @returns {this}
|
|
131
|
+
*/
|
|
132
|
+
open(): this;
|
|
133
|
+
/**
|
|
134
|
+
* Close the modal (a `beforeclose` handler can refuse).
|
|
135
|
+
* @returns {this}
|
|
136
|
+
*/
|
|
137
|
+
close(): this;
|
|
138
|
+
/**
|
|
139
|
+
* Toggle modal visibility.
|
|
140
|
+
* @returns {this}
|
|
141
|
+
*/
|
|
142
|
+
toggle(): this;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the modal is open.
|
|
145
|
+
* @returns {boolean}
|
|
146
|
+
*/
|
|
147
|
+
isOpen(): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Permanent alias: delegates to open() by name, so a replaced open() is honoured.
|
|
150
|
+
* @returns {this}
|
|
151
|
+
*/
|
|
152
|
+
show(...args: any[]): this;
|
|
153
|
+
/**
|
|
154
|
+
* Permanent alias: delegates to close() by name.
|
|
155
|
+
* @returns {this}
|
|
156
|
+
*/
|
|
157
|
+
hide(...args: any[]): this;
|
|
158
|
+
/**
|
|
159
|
+
* Replace the title; empty hides it.
|
|
160
|
+
* @param {string|null} title
|
|
161
|
+
* @returns {this}
|
|
162
|
+
*/
|
|
163
|
+
setTitle(title: string | null): this;
|
|
164
|
+
/**
|
|
165
|
+
* Replace the body content (the element's children other than a footer slot).
|
|
166
|
+
* A string is HTML, sanitised unless `{safe: false}`; a Node is appended.
|
|
167
|
+
* @param {string|Node|null} content
|
|
168
|
+
* @param {{safe?: boolean}} [opts]
|
|
169
|
+
* @returns {this}
|
|
170
|
+
*/
|
|
171
|
+
setContent(content: string | Node | null, opts?: {
|
|
172
|
+
safe?: boolean;
|
|
173
|
+
}): this;
|
|
174
|
+
/**
|
|
175
|
+
* Replace the footer buttons.
|
|
176
|
+
* @param {ModalButton[]|null} buttons
|
|
177
|
+
* @returns {this}
|
|
178
|
+
*/
|
|
179
|
+
setButtons(buttons: ModalButton[] | null): this;
|
|
180
|
+
_applyOptions(): void;
|
|
181
|
+
_destroyed: boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Permanent alias of destroy().
|
|
184
|
+
* @returns {void}
|
|
185
|
+
*/
|
|
186
|
+
remove(...args: any[]): void;
|
|
187
|
+
}
|
|
188
|
+
export default Modal;
|
|
189
|
+
/**
|
|
190
|
+
* A footer button.
|
|
191
|
+
*/
|
|
192
|
+
export type ModalButton = {
|
|
193
|
+
/**
|
|
194
|
+
* - Passed to onButtonClick (default `btn-<index>`)
|
|
195
|
+
*/
|
|
196
|
+
id?: string;
|
|
197
|
+
/**
|
|
198
|
+
* - Label
|
|
199
|
+
*/
|
|
200
|
+
text?: string;
|
|
201
|
+
/**
|
|
202
|
+
* - Adds `btn-<variant>`
|
|
203
|
+
*/
|
|
204
|
+
variant?: string;
|
|
205
|
+
/**
|
|
206
|
+
* - Extra classes
|
|
207
|
+
*/
|
|
208
|
+
className?: string;
|
|
209
|
+
/**
|
|
210
|
+
* - false keeps the modal open after the click
|
|
211
|
+
*/
|
|
212
|
+
close?: boolean;
|
|
213
|
+
onClick?: (modal: ModalInstance, event: MouseEvent) => void;
|
|
214
|
+
};
|
|
215
|
+
export type ModalOptions = {
|
|
216
|
+
/**
|
|
217
|
+
* - Show backdrop overlay
|
|
218
|
+
*/
|
|
219
|
+
backdrop?: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* - Close modal when clicking backdrop
|
|
222
|
+
*/
|
|
223
|
+
backdropClose?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* - Close modal on Escape key
|
|
226
|
+
*/
|
|
227
|
+
keyboard?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* - Same as `keyboard`; either false keeps Escape from closing
|
|
230
|
+
*/
|
|
231
|
+
closeOnEscape?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* - Animation type
|
|
234
|
+
*/
|
|
235
|
+
animation?: import("../elements.js").AnimationType | false;
|
|
236
|
+
/**
|
|
237
|
+
* - Animation duration in ms
|
|
238
|
+
*/
|
|
239
|
+
animationDuration?: number;
|
|
240
|
+
/**
|
|
241
|
+
* - Show close button
|
|
242
|
+
*/
|
|
243
|
+
closeButton?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* - A named size or any CSS width (the factory's default is 'large')
|
|
246
|
+
*/
|
|
247
|
+
size?: "small" | "sm" | "medium" | "md" | "large" | "lg" | "xl" | "xlarge" | "full" | (string & {});
|
|
248
|
+
/**
|
|
249
|
+
* - Centre vertically (false: near the top)
|
|
250
|
+
*/
|
|
251
|
+
centered?: boolean;
|
|
252
|
+
/**
|
|
253
|
+
* - Scroll the body inside a capped height
|
|
254
|
+
*/
|
|
255
|
+
scrollable?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* - Title text
|
|
258
|
+
*/
|
|
259
|
+
title?: string;
|
|
260
|
+
/**
|
|
261
|
+
* - Body content (factory mode): HTML (sanitised unless `safe: false`) or a Node
|
|
262
|
+
*/
|
|
263
|
+
content?: string | Node;
|
|
264
|
+
/**
|
|
265
|
+
* - Footer text
|
|
266
|
+
*/
|
|
267
|
+
footer?: string;
|
|
268
|
+
/**
|
|
269
|
+
* - Footer buttons (the factory's default is one Close button)
|
|
270
|
+
*/
|
|
271
|
+
buttons?: ModalButton[];
|
|
272
|
+
/**
|
|
273
|
+
* - false: content is trusted HTML (not sanitised)
|
|
274
|
+
*/
|
|
275
|
+
safe?: boolean;
|
|
276
|
+
/**
|
|
277
|
+
* - Extra classes on the dialog
|
|
278
|
+
*/
|
|
279
|
+
className?: string;
|
|
280
|
+
/**
|
|
281
|
+
* - Extra classes on the header
|
|
282
|
+
*/
|
|
283
|
+
headerClass?: string;
|
|
284
|
+
/**
|
|
285
|
+
* - Extra classes on the body
|
|
286
|
+
*/
|
|
287
|
+
bodyClass?: string;
|
|
288
|
+
/**
|
|
289
|
+
* - Extra classes on the footer
|
|
290
|
+
*/
|
|
291
|
+
footerClass?: string;
|
|
292
|
+
/**
|
|
293
|
+
* - Focus the dialog on open
|
|
294
|
+
*/
|
|
295
|
+
focus?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* - Keep Tab inside while open (default true; false without a backdrop unless given)
|
|
298
|
+
*/
|
|
299
|
+
trapFocus?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* - Put focus back where it was on close
|
|
302
|
+
*/
|
|
303
|
+
returnFocus?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* - Open at once
|
|
306
|
+
*/
|
|
307
|
+
visible?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* - When opening starts
|
|
310
|
+
*/
|
|
311
|
+
onOpen?: ((modal: ModalInstance) => void) | null;
|
|
312
|
+
/**
|
|
313
|
+
* - After open animation completes
|
|
314
|
+
*/
|
|
315
|
+
onOpened?: ((modal: ModalInstance) => void) | null;
|
|
316
|
+
/**
|
|
317
|
+
* - When closing starts
|
|
318
|
+
*/
|
|
319
|
+
onClose?: ((modal: ModalInstance) => void) | null;
|
|
320
|
+
/**
|
|
321
|
+
* - After close animation completes
|
|
322
|
+
*/
|
|
323
|
+
onClosed?: ((modal: ModalInstance) => void) | null;
|
|
324
|
+
/**
|
|
325
|
+
* - Return false to refuse the open
|
|
326
|
+
*/
|
|
327
|
+
onBeforeOpen?: ((modal: ModalInstance) => boolean | void) | null;
|
|
328
|
+
/**
|
|
329
|
+
* - Return false to refuse the close
|
|
330
|
+
*/
|
|
331
|
+
onBeforeClose?: ((modal: ModalInstance) => boolean | void) | null;
|
|
332
|
+
/**
|
|
333
|
+
* - A footer button was clicked
|
|
334
|
+
*/
|
|
335
|
+
onButtonClick?: ((buttonId: string, modal: ModalInstance) => void) | null;
|
|
336
|
+
};
|
|
337
|
+
export type ModalInstance = Modal;
|
|
338
|
+
import Component from '../component.js';
|
|
339
|
+
import FocusTrap from './focus-trap.js';
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* E.rangeSlider: one instance per element; a second call updates it.
|
|
3
|
+
* @param {Element} el
|
|
4
|
+
* @param {RangeSliderOptions} [options]
|
|
5
|
+
* @returns {RangeSlider}
|
|
6
|
+
*/
|
|
7
|
+
export function rangeSliderFor(el: Element, options?: RangeSliderOptions): RangeSlider;
|
|
8
|
+
/** A number, or [low, high] with `range: true`. @typedef {number|[number, number]} RangeSliderValue */
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} RangeSliderMark
|
|
11
|
+
* @property {number} value
|
|
12
|
+
* @property {string} [label]
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {object} RangeSliderOptions
|
|
16
|
+
* @property {number} [min] Default: the input's min, else 0
|
|
17
|
+
* @property {number} [max] Default: the input's max, else 100
|
|
18
|
+
* @property {number|'any'} [step] Default: the input's step, else 1
|
|
19
|
+
* @property {RangeSliderValue|string|null} [value] A number, or [low, high] / "low,high" with range: true
|
|
20
|
+
* @property {boolean} [range] Two thumbs; two inputs, sharing `name` unless `names` is given
|
|
21
|
+
* @property {'horizontal'|'vertical'} [orientation]
|
|
22
|
+
* @property {boolean|number|number[]} [ticks] true = every step, n = every n units, or the values to draw at
|
|
23
|
+
* @property {boolean} [tickLabels] Label the ticks (always on for an array)
|
|
24
|
+
* @property {((value: number, where: 'tick'|'mark'|'tooltip'|'aria') => string)|null} [labels] Formats the value for ticks, marks, the tooltip and aria-valuetext
|
|
25
|
+
* @property {((value: number, where: 'tick'|'mark'|'tooltip'|'aria') => string)|null} [format] Read when `labels` is not set
|
|
26
|
+
* @property {'always'|'hover'|'never'} [tooltip] Default 'hover' (also shown on focus and while dragging)
|
|
27
|
+
* @property {RangeSliderMark[]|null} [marks]
|
|
28
|
+
* @property {boolean} [disabled]
|
|
29
|
+
* @property {string|null} [name]
|
|
30
|
+
* @property {[string, string]|null} [names] [lowName, highName] for range: true
|
|
31
|
+
* @property {number} [minDistance] range: true - the closest the thumbs may come
|
|
32
|
+
* @property {boolean|null} [rtl] null = follow the page's direction
|
|
33
|
+
* @property {string|null} [ariaLabel]
|
|
34
|
+
* @property {[string, string]|null} [ariaLabels]
|
|
35
|
+
* @property {string} [className]
|
|
36
|
+
* @property {((value: RangeSliderValue) => void)|null} [onInput] While dragging, and on each key press
|
|
37
|
+
* @property {((value: RangeSliderValue) => void)|null} [onChange] When the value is committed
|
|
38
|
+
* @property {((next: RangeSliderValue, current: RangeSliderValue) => boolean|void)|null} [onBeforeChange] Return false to refuse a move
|
|
39
|
+
*/
|
|
40
|
+
/** @typedef {RangeSlider} RangeSliderInstance */
|
|
41
|
+
export class RangeSlider extends Component {
|
|
42
|
+
/** @type {RangeSliderOptions} */
|
|
43
|
+
static defaults: RangeSliderOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Options not given are read from the input's own attributes, as a plain range input would.
|
|
46
|
+
* @param {*} element
|
|
47
|
+
* @param {RangeSliderOptions} [options]
|
|
48
|
+
* @returns {RangeSliderOptions}
|
|
49
|
+
*/
|
|
50
|
+
static fromInput(element: any, options?: RangeSliderOptions): RangeSliderOptions;
|
|
51
|
+
/**
|
|
52
|
+
* @param {string|Element|null} element - an <input type="range"> or a container
|
|
53
|
+
* @param {RangeSliderOptions} [options]
|
|
54
|
+
*/
|
|
55
|
+
constructor(element: string | Element | null, options?: RangeSliderOptions);
|
|
56
|
+
_isInput: boolean;
|
|
57
|
+
_made: any[];
|
|
58
|
+
_hooked: any[];
|
|
59
|
+
_dispatching: boolean;
|
|
60
|
+
_drag: {
|
|
61
|
+
index: number;
|
|
62
|
+
pointerId: any;
|
|
63
|
+
start: number[];
|
|
64
|
+
};
|
|
65
|
+
_timers: any[];
|
|
66
|
+
_values: number[];
|
|
67
|
+
get _min(): number;
|
|
68
|
+
get _max(): number;
|
|
69
|
+
/** The step used to snap values; null for step 'any'. */
|
|
70
|
+
get _step(): number;
|
|
71
|
+
/** The step the arrow keys move by. */
|
|
72
|
+
get _keyStep(): number;
|
|
73
|
+
/** Snap to the step grid (counted from min, as a native range input does) and clamp. */
|
|
74
|
+
_snap(v: any): number;
|
|
75
|
+
get _minDistance(): number;
|
|
76
|
+
/** Snap, order and space a candidate value (a number, [a, b] or "a,b"). */
|
|
77
|
+
_normalise(value: any): number[];
|
|
78
|
+
_initialValues(): number[];
|
|
79
|
+
_format(value: any, where: any): string;
|
|
80
|
+
_pct(v: any): number;
|
|
81
|
+
get _vertical(): boolean;
|
|
82
|
+
get _rtl(): boolean;
|
|
83
|
+
_setupInputs(): void;
|
|
84
|
+
_inputs: HTMLElement[];
|
|
85
|
+
_restore: {
|
|
86
|
+
name: string;
|
|
87
|
+
hidden: boolean;
|
|
88
|
+
tabindex: string;
|
|
89
|
+
ariaHidden: string;
|
|
90
|
+
min: string;
|
|
91
|
+
max: string;
|
|
92
|
+
step: string;
|
|
93
|
+
disabled: string;
|
|
94
|
+
};
|
|
95
|
+
_syncInputAttrs(): void;
|
|
96
|
+
/**
|
|
97
|
+
* Code (or M.bind, which writes `input.value`) setting a value programmatically fires
|
|
98
|
+
* no event, so the drawn slider would never move. The instance gets its own `value`
|
|
99
|
+
* property that writes through to the native one and then redraws. Removed on destroy.
|
|
100
|
+
*/
|
|
101
|
+
_hookValues(): void;
|
|
102
|
+
/** Push the current values into the real inputs. */
|
|
103
|
+
_writeInputs(): void;
|
|
104
|
+
_writing: boolean;
|
|
105
|
+
/** Read the inputs back after something outside changed them. */
|
|
106
|
+
_fromInputs(): void;
|
|
107
|
+
_bindInputs(): void;
|
|
108
|
+
_labels: any[];
|
|
109
|
+
_labelText(): any;
|
|
110
|
+
_render(): void;
|
|
111
|
+
_ticksEl: HTMLDivElement;
|
|
112
|
+
_marksEl: HTMLDivElement;
|
|
113
|
+
_thumbs: any[] | HTMLDivElement[];
|
|
114
|
+
_fillEl: HTMLDivElement;
|
|
115
|
+
_track: HTMLDivElement;
|
|
116
|
+
_root: HTMLDivElement;
|
|
117
|
+
/** Values a tick is drawn at. */
|
|
118
|
+
_tickValues(): number[];
|
|
119
|
+
_place(el: any, pct: any): void;
|
|
120
|
+
_renderTicks(root: any): HTMLDivElement;
|
|
121
|
+
_renderMarks(root: any): HTMLDivElement;
|
|
122
|
+
/** Move the thumbs and fill to the current values and update the ARIA. */
|
|
123
|
+
_paint(): void;
|
|
124
|
+
_applyDisabled(): void;
|
|
125
|
+
_bindRoot(): void;
|
|
126
|
+
_rootHandlers: any[] | (string | HTMLDivElement | ((e: any) => void))[][];
|
|
127
|
+
_unbindRoot(): void;
|
|
128
|
+
/** The value under a pointer. */
|
|
129
|
+
_valueAt(e: any): number;
|
|
130
|
+
/** Which thumb a press at `value` moves: the one pressed, else the nearer. */
|
|
131
|
+
_pickThumb(e: any, value: any): number;
|
|
132
|
+
_onPointerDown(e: any): void;
|
|
133
|
+
_onPointerMove(e: any): void;
|
|
134
|
+
_onPointerUp(e: any, cancelled?: boolean): void;
|
|
135
|
+
_onKeyDown(e: any): void;
|
|
136
|
+
_same(values: any): any;
|
|
137
|
+
/** The public value shape for an array of values. */
|
|
138
|
+
_shape(values: any): any;
|
|
139
|
+
/**
|
|
140
|
+
* Move one thumb towards `value`, held off the other thumb by minDistance.
|
|
141
|
+
* @returns {boolean} whether the value changed
|
|
142
|
+
*/
|
|
143
|
+
_propose(index: any, value: any): boolean;
|
|
144
|
+
/** Set values, redraw, and tell the input and listeners about it. */
|
|
145
|
+
_apply(values: any, index: any, phase: any): void;
|
|
146
|
+
_commit(index: any): void;
|
|
147
|
+
/**
|
|
148
|
+
* A native event on a real input, flagged so our own sync listener ignores it. The DOM
|
|
149
|
+
* event goes first: a form listening on change sees the input, then the component's
|
|
150
|
+
* own change (which Forma uses to store the [low, high] pair) has the last word.
|
|
151
|
+
*/
|
|
152
|
+
_dispatch(input: any, type: any): void;
|
|
153
|
+
/**
|
|
154
|
+
* The value: a number, or [low, high] with `range: true`.
|
|
155
|
+
* @returns {RangeSliderValue}
|
|
156
|
+
*/
|
|
157
|
+
getValue(): RangeSliderValue;
|
|
158
|
+
/**
|
|
159
|
+
* Set the value. Fires beforechange (cancelable), the inputs' native input and change
|
|
160
|
+
* events, then input and change - unless `{silent: true}`, which only moves it.
|
|
161
|
+
* @param {RangeSliderValue|number[]|string} value - a number, [low, high] or "low,high"
|
|
162
|
+
* @param {{silent?: boolean}} [opts]
|
|
163
|
+
* @returns {this}
|
|
164
|
+
*/
|
|
165
|
+
setValue(value: RangeSliderValue | number[] | string, opts?: {
|
|
166
|
+
silent?: boolean;
|
|
167
|
+
}): this;
|
|
168
|
+
/**
|
|
169
|
+
* Change the bounds. The value is pulled inside them; if that moves it, input and
|
|
170
|
+
* change fire (without beforechange - the bounds are not the user's to refuse).
|
|
171
|
+
* @param {number} min
|
|
172
|
+
* @param {number} max
|
|
173
|
+
* @returns {this}
|
|
174
|
+
*/
|
|
175
|
+
setRange(min: number, max: number): this;
|
|
176
|
+
/** @returns {this} */
|
|
177
|
+
enable(): this;
|
|
178
|
+
/** @returns {this} */
|
|
179
|
+
disable(): this;
|
|
180
|
+
/** @returns {boolean} */
|
|
181
|
+
isDisabled(): boolean;
|
|
182
|
+
_applyOptions(): void;
|
|
183
|
+
}
|
|
184
|
+
export default RangeSlider;
|
|
185
|
+
/**
|
|
186
|
+
* A number, or [low, high] with `range: true`.
|
|
187
|
+
*/
|
|
188
|
+
export type RangeSliderValue = number | [number, number];
|
|
189
|
+
export type RangeSliderMark = {
|
|
190
|
+
value: number;
|
|
191
|
+
label?: string;
|
|
192
|
+
};
|
|
193
|
+
export type RangeSliderOptions = {
|
|
194
|
+
/**
|
|
195
|
+
* Default: the input's min, else 0
|
|
196
|
+
*/
|
|
197
|
+
min?: number;
|
|
198
|
+
/**
|
|
199
|
+
* Default: the input's max, else 100
|
|
200
|
+
*/
|
|
201
|
+
max?: number;
|
|
202
|
+
/**
|
|
203
|
+
* Default: the input's step, else 1
|
|
204
|
+
*/
|
|
205
|
+
step?: number | "any";
|
|
206
|
+
/**
|
|
207
|
+
* A number, or [low, high] / "low,high" with range: true
|
|
208
|
+
*/
|
|
209
|
+
value?: RangeSliderValue | string | null;
|
|
210
|
+
/**
|
|
211
|
+
* Two thumbs; two inputs, sharing `name` unless `names` is given
|
|
212
|
+
*/
|
|
213
|
+
range?: boolean;
|
|
214
|
+
orientation?: "horizontal" | "vertical";
|
|
215
|
+
/**
|
|
216
|
+
* true = every step, n = every n units, or the values to draw at
|
|
217
|
+
*/
|
|
218
|
+
ticks?: boolean | number | number[];
|
|
219
|
+
/**
|
|
220
|
+
* Label the ticks (always on for an array)
|
|
221
|
+
*/
|
|
222
|
+
tickLabels?: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Formats the value for ticks, marks, the tooltip and aria-valuetext
|
|
225
|
+
*/
|
|
226
|
+
labels?: ((value: number, where: "tick" | "mark" | "tooltip" | "aria") => string) | null;
|
|
227
|
+
/**
|
|
228
|
+
* Read when `labels` is not set
|
|
229
|
+
*/
|
|
230
|
+
format?: ((value: number, where: "tick" | "mark" | "tooltip" | "aria") => string) | null;
|
|
231
|
+
/**
|
|
232
|
+
* Default 'hover' (also shown on focus and while dragging)
|
|
233
|
+
*/
|
|
234
|
+
tooltip?: "always" | "hover" | "never";
|
|
235
|
+
marks?: RangeSliderMark[] | null;
|
|
236
|
+
disabled?: boolean;
|
|
237
|
+
name?: string | null;
|
|
238
|
+
/**
|
|
239
|
+
* [lowName, highName] for range: true
|
|
240
|
+
*/
|
|
241
|
+
names?: [string, string] | null;
|
|
242
|
+
/**
|
|
243
|
+
* range: true - the closest the thumbs may come
|
|
244
|
+
*/
|
|
245
|
+
minDistance?: number;
|
|
246
|
+
/**
|
|
247
|
+
* null = follow the page's direction
|
|
248
|
+
*/
|
|
249
|
+
rtl?: boolean | null;
|
|
250
|
+
ariaLabel?: string | null;
|
|
251
|
+
ariaLabels?: [string, string] | null;
|
|
252
|
+
className?: string;
|
|
253
|
+
/**
|
|
254
|
+
* While dragging, and on each key press
|
|
255
|
+
*/
|
|
256
|
+
onInput?: ((value: RangeSliderValue) => void) | null;
|
|
257
|
+
/**
|
|
258
|
+
* When the value is committed
|
|
259
|
+
*/
|
|
260
|
+
onChange?: ((value: RangeSliderValue) => void) | null;
|
|
261
|
+
/**
|
|
262
|
+
* Return false to refuse a move
|
|
263
|
+
*/
|
|
264
|
+
onBeforeChange?: ((next: RangeSliderValue, current: RangeSliderValue) => boolean | void) | null;
|
|
265
|
+
};
|
|
266
|
+
export type RangeSliderInstance = RangeSlider;
|
|
267
|
+
import Component from '../component.js';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a component accepts as its host: a CSS selector, an element, or a Domma/jQuery-like
|
|
3
|
+
* collection (its first element is used).
|
|
4
|
+
* @typedef {string|Element|ArrayLike<Element>|null|undefined} ComponentTarget
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* An element from a selector, an element, or a Domma/jQuery-like collection.
|
|
8
|
+
* @param {ComponentTarget} target
|
|
9
|
+
* @returns {HTMLElement|null}
|
|
10
|
+
*/
|
|
11
|
+
export function resolveElement(target: ComponentTarget): HTMLElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Every element a selector matches (one for an element).
|
|
14
|
+
* @param {ComponentTarget} target
|
|
15
|
+
* @returns {HTMLElement[]}
|
|
16
|
+
*/
|
|
17
|
+
export function resolveAll(target: ComponentTarget): HTMLElement[];
|
|
18
|
+
/**
|
|
19
|
+
* A boolean option that may have arrived as a string ('false' from an attribute, or
|
|
20
|
+
* from a caller who worked around the old wrappers dropping a boolean false).
|
|
21
|
+
* @param {*} value
|
|
22
|
+
* @param {boolean} [fallback]
|
|
23
|
+
* @returns {boolean}
|
|
24
|
+
*/
|
|
25
|
+
export function flag(value: any, fallback?: boolean): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* A number option that may be a string; anything unparseable gives the fallback.
|
|
28
|
+
* @param {*} value
|
|
29
|
+
* @param {number} [fallback]
|
|
30
|
+
* @returns {number}
|
|
31
|
+
*/
|
|
32
|
+
export function num(value: any, fallback?: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Put content into an element. Strings are HTML, sanitised the way `$().html()` does
|
|
35
|
+
* (DOMPurify, or escaped without it) unless `{safe: false}`; Nodes are appended.
|
|
36
|
+
* @param {Element} el
|
|
37
|
+
* @param {string|Node|null} content
|
|
38
|
+
* @param {{safe?: boolean, text?: boolean}} [opts] - `text: true` writes a string as text
|
|
39
|
+
*/
|
|
40
|
+
export function fill(el: Element, content: string | Node | null, opts?: {
|
|
41
|
+
safe?: boolean;
|
|
42
|
+
text?: boolean;
|
|
43
|
+
}): void;
|
|
44
|
+
/**
|
|
45
|
+
* Scan new markup for `data-icon` placeholders when the icon module is loaded.
|
|
46
|
+
* @param {Element|null|undefined} el
|
|
47
|
+
*/
|
|
48
|
+
export function scanIcons(el: Element | null | undefined): void;
|
|
49
|
+
/**
|
|
50
|
+
* A page-unique id with a prefix.
|
|
51
|
+
* @param {string} prefix
|
|
52
|
+
* @returns {string}
|
|
53
|
+
*/
|
|
54
|
+
export function uniqueId(prefix: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Give the first of several instances a non-enumerable `all()` that returns every
|
|
57
|
+
* one, so `E.tooltip('.many')` initialises each match and still returns an instance.
|
|
58
|
+
* @template {object} T
|
|
59
|
+
* @param {T[]} list
|
|
60
|
+
* @returns {(T & {all(): T[]})|null}
|
|
61
|
+
*/
|
|
62
|
+
export function firstWithAll<T extends unknown>(list: T[]): (T & {
|
|
63
|
+
all(): T[];
|
|
64
|
+
}) | null;
|
|
65
|
+
/**
|
|
66
|
+
* The component of this kind already on an element, given any new options - so calling
|
|
67
|
+
* E.card(el) twice updates one card instead of stacking a second set of listeners on it.
|
|
68
|
+
* @param {Element} el
|
|
69
|
+
* @param {string} name - componentName
|
|
70
|
+
* @param {Record<string, any>} [options]
|
|
71
|
+
* @returns {any}
|
|
72
|
+
*/
|
|
73
|
+
export function reuse(el: Element, name: string, options?: Record<string, any>): any;
|
|
74
|
+
/** Whether the user asked for less motion. */
|
|
75
|
+
export function reducedMotion(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Lift a popup that lives on <body> above whatever stacking layer its trigger sits in.
|
|
78
|
+
* A date picker or dropdown opened from inside a slideover (z-index 9999) or a modal
|
|
79
|
+
* would otherwise draw underneath it, because its own stylesheet z-index (1000-1080)
|
|
80
|
+
* is only meant to beat ordinary page content. Sets an inline z-index only when the
|
|
81
|
+
* trigger's layer is higher than the popup's own; clears it otherwise.
|
|
82
|
+
* @param {Element} trigger - the element the popup belongs to
|
|
83
|
+
* @param {HTMLElement} popup - the popup, appended to <body>
|
|
84
|
+
* @returns {void}
|
|
85
|
+
*/
|
|
86
|
+
export function layerAbove(trigger: Element, popup: HTMLElement): void;
|
|
87
|
+
/**
|
|
88
|
+
* What a component accepts as its host: a CSS selector, an element, or a Domma/jQuery-like
|
|
89
|
+
* collection (its first element is used).
|
|
90
|
+
*/
|
|
91
|
+
export type ComponentTarget = string | Element | ArrayLike<Element> | null | undefined;
|