@sveltia/ui 0.15.16 → 0.17.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/package/components/alert/alert.svelte +22 -7
- package/package/components/alert/alert.svelte.d.ts +47 -31
- package/package/components/button/button-group.svelte +16 -6
- package/package/components/button/button-group.svelte.d.ts +38 -28
- package/package/components/button/button.svelte +41 -136
- package/package/components/button/button.svelte.d.ts +20 -162
- package/package/components/button/select-button-group.svelte +31 -37
- package/package/components/button/select-button-group.svelte.d.ts +91 -39
- package/package/components/button/select-button.svelte +19 -62
- package/package/components/button/select-button.svelte.d.ts +31 -65
- package/package/components/button/split-button.svelte +37 -47
- package/package/components/button/split-button.svelte.d.ts +54 -60
- package/package/components/calendar/calendar.svelte +80 -55
- package/package/components/calendar/calendar.svelte.d.ts +30 -26
- package/package/components/checkbox/checkbox-group.svelte +23 -20
- package/package/components/checkbox/checkbox-group.svelte.d.ts +64 -32
- package/package/components/checkbox/checkbox.svelte +57 -67
- package/package/components/checkbox/checkbox.svelte.d.ts +81 -53
- package/package/components/dialog/alert-dialog.svelte +9 -36
- package/package/components/dialog/alert-dialog.svelte.d.ts +20 -49
- package/package/components/dialog/confirmation-dialog.svelte +9 -41
- package/package/components/dialog/confirmation-dialog.svelte.d.ts +20 -51
- package/package/components/dialog/dialog.svelte +60 -105
- package/package/components/dialog/dialog.svelte.d.ts +19 -86
- package/package/components/dialog/prompt-dialog.svelte +32 -61
- package/package/components/dialog/prompt-dialog.svelte.d.ts +53 -65
- package/package/components/disclosure/disclosure.svelte +39 -34
- package/package/components/disclosure/disclosure.svelte.d.ts +88 -57
- package/package/components/divider/divider.svelte +18 -14
- package/package/components/divider/divider.svelte.d.ts +48 -26
- package/package/components/divider/spacer.svelte +13 -8
- package/package/components/divider/spacer.svelte.d.ts +37 -25
- package/package/components/drawer/drawer.svelte +63 -76
- package/package/components/drawer/drawer.svelte.d.ts +116 -70
- package/package/components/grid/grid-body.svelte +15 -10
- package/package/components/grid/grid-body.svelte.d.ts +45 -29
- package/package/components/grid/grid-cell.svelte +16 -6
- package/package/components/grid/grid-cell.svelte.d.ts +38 -28
- package/package/components/grid/grid-col-header.svelte +16 -6
- package/package/components/grid/grid-col-header.svelte.d.ts +38 -28
- package/package/components/grid/grid-foot.svelte +16 -6
- package/package/components/grid/grid-foot.svelte.d.ts +38 -28
- package/package/components/grid/grid-head.svelte +16 -6
- package/package/components/grid/grid-head.svelte.d.ts +38 -28
- package/package/components/grid/grid-row-header.svelte +16 -6
- package/package/components/grid/grid-row-header.svelte.d.ts +38 -28
- package/package/components/grid/grid-row.svelte +19 -23
- package/package/components/grid/grid-row.svelte.d.ts +63 -43
- package/package/components/grid/grid.svelte +26 -25
- package/package/components/grid/grid.svelte.d.ts +71 -37
- package/package/components/icon/icon.svelte +14 -9
- package/package/components/icon/icon.svelte.d.ts +37 -25
- package/package/components/listbox/listbox.svelte +46 -52
- package/package/components/listbox/listbox.svelte.d.ts +117 -45
- package/package/components/listbox/option-group.svelte +23 -19
- package/package/components/listbox/option-group.svelte.d.ts +64 -32
- package/package/components/listbox/option.svelte +44 -57
- package/package/components/listbox/option.svelte.d.ts +68 -74
- package/package/components/menu/menu-button.svelte +42 -63
- package/package/components/menu/menu-button.svelte.d.ts +35 -62
- package/package/components/menu/menu-item-checkbox.svelte +29 -41
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +20 -49
- package/package/components/menu/menu-item-group.svelte +22 -19
- package/package/components/menu/menu-item-group.svelte.d.ts +56 -32
- package/package/components/menu/menu-item-radio.svelte +29 -41
- package/package/components/menu/menu-item-radio.svelte.d.ts +20 -49
- package/package/components/menu/menu-item.svelte +66 -75
- package/package/components/menu/menu-item.svelte.d.ts +19 -68
- package/package/components/menu/menu.svelte +25 -22
- package/package/components/menu/menu.svelte.d.ts +65 -35
- package/package/components/radio/radio-group.svelte +36 -42
- package/package/components/radio/radio-group.svelte.d.ts +100 -40
- package/package/components/radio/radio.svelte +45 -48
- package/package/components/radio/radio.svelte.d.ts +111 -47
- package/package/components/select/combobox.svelte +76 -101
- package/package/components/select/combobox.svelte.d.ts +19 -54
- package/package/components/select/select-tags.svelte +48 -59
- package/package/components/select/select-tags.svelte.d.ts +127 -45
- package/package/components/select/select.svelte +18 -37
- package/package/components/select/select.svelte.d.ts +20 -45
- package/package/components/slider/slider.svelte +71 -68
- package/package/components/slider/slider.svelte.d.ts +159 -47
- package/package/components/switch/switch.svelte +36 -46
- package/package/components/switch/switch.svelte.d.ts +98 -42
- package/package/components/table/table-body.svelte +15 -11
- package/package/components/table/table-body.svelte.d.ts +45 -29
- package/package/components/table/table-cell.svelte +16 -6
- package/package/components/table/table-cell.svelte.d.ts +38 -28
- package/package/components/table/table-col-header.svelte +16 -6
- package/package/components/table/table-col-header.svelte.d.ts +38 -28
- package/package/components/table/table-foot.svelte +16 -6
- package/package/components/table/table-foot.svelte.d.ts +38 -28
- package/package/components/table/table-head.svelte +16 -6
- package/package/components/table/table-head.svelte.d.ts +38 -28
- package/package/components/table/table-row-header.svelte +16 -6
- package/package/components/table/table-row-header.svelte.d.ts +38 -28
- package/package/components/table/table-row.svelte +16 -6
- package/package/components/table/table-row.svelte.d.ts +38 -28
- package/package/components/table/table.svelte +16 -6
- package/package/components/table/table.svelte.d.ts +38 -28
- package/package/components/tabs/tab-box.svelte +16 -9
- package/package/components/tabs/tab-box.svelte.d.ts +47 -27
- package/package/components/tabs/tab-list.svelte +36 -35
- package/package/components/tabs/tab-list.svelte.d.ts +80 -38
- package/package/components/tabs/tab-panel.svelte +16 -6
- package/package/components/tabs/tab-panel.svelte.d.ts +38 -28
- package/package/components/tabs/tab-panels.svelte +16 -6
- package/package/components/tabs/tab-panels.svelte.d.ts +38 -26
- package/package/components/tabs/tab.svelte +28 -25
- package/package/components/tabs/tab.svelte.d.ts +31 -55
- package/package/components/text-editor/lexical-root.svelte +38 -32
- package/package/components/text-editor/lexical-root.svelte.d.ts +91 -29
- package/package/components/text-editor/text-editor.svelte +63 -79
- package/package/components/text-editor/text-editor.svelte.d.ts +114 -36
- package/package/components/text-editor/toolbar/editor-toolbar.svelte +41 -24
- package/package/components/text-editor/toolbar/editor-toolbar.svelte.d.ts +49 -23
- package/package/components/text-editor/toolbar/format-text-button.svelte +15 -5
- package/package/components/text-editor/toolbar/format-text-button.svelte.d.ts +30 -22
- package/package/components/text-editor/toolbar/insert-link-button.svelte +18 -16
- package/package/components/text-editor/toolbar/insert-link-button.svelte.d.ts +20 -23
- package/package/components/text-editor/toolbar/toggle-block-menu-item.svelte +19 -7
- package/package/components/text-editor/toolbar/toggle-block-menu-item.svelte.d.ts +30 -22
- package/package/components/text-field/number-input.svelte +63 -81
- package/package/components/text-field/number-input.svelte.d.ts +62 -68
- package/package/components/text-field/password-input.svelte +38 -57
- package/package/components/text-field/password-input.svelte.d.ts +30 -58
- package/package/components/text-field/search-bar.svelte +45 -62
- package/package/components/text-field/search-bar.svelte.d.ts +42 -87
- package/package/components/text-field/text-area.svelte +38 -54
- package/package/components/text-field/text-area.svelte.d.ts +116 -50
- package/package/components/text-field/text-input.svelte +30 -86
- package/package/components/text-field/text-input.svelte.d.ts +20 -105
- package/package/components/toast/toast.svelte +36 -30
- package/package/components/toast/toast.svelte.d.ts +65 -33
- package/package/components/toolbar/toolbar.svelte +25 -25
- package/package/components/toolbar/toolbar.svelte.d.ts +72 -34
- package/package/components/util/app-shell.svelte +22 -10
- package/package/components/util/app-shell.svelte.d.ts +40 -34
- package/package/components/util/group.svelte +20 -15
- package/package/components/util/group.svelte.d.ts +55 -31
- package/package/components/util/modal.svelte +89 -105
- package/package/components/util/modal.svelte.d.ts +24 -82
- package/package/components/util/placeholder.svelte +21 -0
- package/package/components/util/placeholder.svelte.d.ts +34 -0
- package/package/components/util/popup.svelte +65 -62
- package/package/components/util/popup.svelte.d.ts +104 -82
- package/package/services/{group.js → group.svelte.js} +11 -12
- package/package/services/{popup.js → popup.svelte.js} +6 -5
- package/package/typedefs.d.ts +545 -0
- package/package/typedefs.js +202 -0
- package/package.json +16 -23
- package/package/components/util/portal.svelte +0 -36
- package/package/components/util/portal.svelte.d.ts +0 -32
- /package/package/services/{events.d.ts → events.svelte.d.ts} +0 -0
- /package/package/services/{events.js → events.svelte.js} +0 -0
- /package/package/services/{group.d.ts → group.svelte.d.ts} +0 -0
- /package/package/services/{popup.d.ts → popup.svelte.d.ts} +0 -0
|
@@ -4,90 +4,38 @@
|
|
|
4
4
|
@see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
|
|
5
5
|
@see https://w3c.github.io/aria/#textbox
|
|
6
6
|
-->
|
|
7
|
-
<svelte:options accessors={true} />
|
|
8
|
-
|
|
9
7
|
<script>
|
|
10
8
|
import { generateElementId } from '@sveltia/utils/element';
|
|
11
|
-
import { activateKeyShortcuts } from '../../services/events';
|
|
9
|
+
import { activateKeyShortcuts } from '../../services/events.svelte';
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export let element = undefined;
|
|
18
|
-
/**
|
|
19
|
-
* The `class` attribute on the wrapper element.
|
|
20
|
-
* @type {string}
|
|
21
|
-
*/
|
|
22
|
-
let className = '';
|
|
23
|
-
export { className as class };
|
|
24
|
-
/**
|
|
25
|
-
* Make the text input container flexible.
|
|
26
|
-
* @type {boolean}
|
|
27
|
-
*/
|
|
28
|
-
export let flex = false;
|
|
29
|
-
/**
|
|
30
|
-
* The `role` attribute on the `<input>` element.
|
|
31
|
-
* @type {'textbox' | 'searchbox' | 'combobox' | 'spinbutton'}
|
|
32
|
-
*/
|
|
33
|
-
export let role = 'textbox';
|
|
34
|
-
/**
|
|
35
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
36
|
-
* @type {boolean | undefined}
|
|
37
|
-
*/
|
|
38
|
-
export let hidden = undefined;
|
|
39
|
-
/**
|
|
40
|
-
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
41
|
-
* @type {boolean}
|
|
42
|
-
*/
|
|
43
|
-
export let disabled = false;
|
|
44
|
-
/**
|
|
45
|
-
* Whether to disable the widget. An alias of `aria-readonly` attribute.
|
|
46
|
-
* @type {boolean}
|
|
47
|
-
*/
|
|
48
|
-
export let readonly = false;
|
|
49
|
-
/**
|
|
50
|
-
* Whether to mark the widget required. An alias of the `aria-required` attribute.
|
|
51
|
-
* @type {boolean}
|
|
52
|
-
*/
|
|
53
|
-
export let required = false;
|
|
54
|
-
/**
|
|
55
|
-
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
56
|
-
* @type {boolean}
|
|
57
|
-
*/
|
|
58
|
-
export let invalid = false;
|
|
59
|
-
/**
|
|
60
|
-
* Keyboard shortcuts. An alias of the `aria-keyshortcuts` attribute. Accepts the special `Accel`
|
|
61
|
-
* key, which will be replaced with `Control` or `Meta` depending on the user’s operating system.
|
|
62
|
-
* @type {string | undefined}
|
|
63
|
-
*/
|
|
64
|
-
export let keyShortcuts = undefined;
|
|
65
|
-
/**
|
|
66
|
-
* The `name` attribute on the `<input>` element.
|
|
67
|
-
* @type {string | undefined}
|
|
68
|
-
*/
|
|
69
|
-
export let name = undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Input value.
|
|
72
|
-
* @type {string | number | undefined}
|
|
73
|
-
*/
|
|
74
|
-
export let value = undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Whether to display `aria-label` over the `<input>` element if it’s empty, just like how the
|
|
77
|
-
* HTML `placeholder` attribute works.
|
|
78
|
-
* @type {boolean}
|
|
79
|
-
*/
|
|
80
|
-
export let showInlineLabel = false;
|
|
81
|
-
/**
|
|
82
|
-
* The `inputmode` attribute on the `<input>`.
|
|
83
|
-
* @type {'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'}
|
|
84
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode
|
|
12
|
+
* @type {import('../../typedefs').TextInputProps & import('../../typedefs').CommonEventHandlers &
|
|
13
|
+
* import('../../typedefs').InputEventHandlers & Record<string, any>}
|
|
85
14
|
*/
|
|
86
|
-
|
|
15
|
+
let {
|
|
16
|
+
/* eslint-disable prefer-const */
|
|
17
|
+
value = $bindable(),
|
|
18
|
+
element = $bindable(),
|
|
19
|
+
role = 'textbox',
|
|
20
|
+
keyShortcuts = undefined,
|
|
21
|
+
name = undefined,
|
|
22
|
+
showInlineLabel = false,
|
|
23
|
+
inputmode = 'text',
|
|
24
|
+
flex = false,
|
|
25
|
+
class: className,
|
|
26
|
+
hidden = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
readonly = false,
|
|
29
|
+
required = false,
|
|
30
|
+
invalid = false,
|
|
31
|
+
'aria-label': ariaLabel,
|
|
32
|
+
children,
|
|
33
|
+
onChange,
|
|
34
|
+
...restProps
|
|
35
|
+
/* eslint-enable prefer-const */
|
|
36
|
+
} = $props();
|
|
87
37
|
|
|
88
38
|
const id = generateElementId('input');
|
|
89
|
-
|
|
90
|
-
$: ariaLabel = $$restProps['aria-label'];
|
|
91
39
|
</script>
|
|
92
40
|
|
|
93
41
|
<div
|
|
@@ -96,9 +44,12 @@
|
|
|
96
44
|
class:flex
|
|
97
45
|
class:disabled
|
|
98
46
|
class:readonly
|
|
99
|
-
|
|
47
|
+
{hidden}
|
|
100
48
|
>
|
|
101
49
|
<input
|
|
50
|
+
bind:this={element}
|
|
51
|
+
{...restProps}
|
|
52
|
+
bind:value
|
|
102
53
|
type="text"
|
|
103
54
|
{role}
|
|
104
55
|
name={name || undefined}
|
|
@@ -111,14 +62,7 @@
|
|
|
111
62
|
aria-readonly={readonly}
|
|
112
63
|
aria-required={required}
|
|
113
64
|
aria-invalid={invalid}
|
|
114
|
-
{
|
|
115
|
-
bind:this={element}
|
|
116
|
-
bind:value
|
|
117
|
-
on:keydown
|
|
118
|
-
on:keyup
|
|
119
|
-
on:keypress
|
|
120
|
-
on:input
|
|
121
|
-
on:change
|
|
65
|
+
{onChange}
|
|
122
66
|
use:activateKeyShortcuts={keyShortcuts}
|
|
123
67
|
/>
|
|
124
68
|
{#if ariaLabel && showInlineLabel}
|
|
@@ -1,112 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default TextInput;
|
|
2
|
+
type TextInput = SvelteComponent<TextInputProps & KeyboardEventHandlers & MouseEventHandlers & FocusEventHandlers & DragEventHandlers & InputEventHandlers & Record<string, any>, {
|
|
3
|
+
[evt: string]: CustomEvent<any>;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "value" | "element" | undefined;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* A generic, single-line text field. The equivalent of the HTML `<input type="text">` element.
|
|
6
9
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
|
|
7
10
|
* @see https://w3c.github.io/aria/#textbox
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
[x: string]: any;
|
|
11
|
-
class?: string | undefined;
|
|
12
|
-
name?: string | undefined;
|
|
13
|
-
disabled?: boolean | undefined;
|
|
14
|
-
invalid?: boolean | undefined;
|
|
15
|
-
required?: boolean | undefined;
|
|
16
|
-
value?: string | number | undefined;
|
|
17
|
-
role?: "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined;
|
|
18
|
-
hidden?: boolean | undefined;
|
|
19
|
-
element?: HTMLInputElement | undefined;
|
|
20
|
-
readonly?: boolean | undefined;
|
|
21
|
-
keyShortcuts?: string | undefined;
|
|
22
|
-
flex?: boolean | undefined;
|
|
23
|
-
showInlineLabel?: boolean | undefined;
|
|
24
|
-
inputmode?: "search" | "text" | "email" | "tel" | "numeric" | "decimal" | "url" | undefined;
|
|
25
|
-
}, {
|
|
26
|
-
keydown: KeyboardEvent;
|
|
27
|
-
keyup: KeyboardEvent;
|
|
28
|
-
keypress: KeyboardEvent;
|
|
29
|
-
input: Event;
|
|
30
|
-
change: Event;
|
|
31
|
-
} & {
|
|
12
|
+
declare const TextInput: $$__sveltets_2_IsomorphicComponent<import("../../typedefs").TextInputProps & import("../../typedefs").KeyboardEventHandlers & import("../../typedefs").MouseEventHandlers & import("../../typedefs").FocusEventHandlers & import("../../typedefs").DragEventHandlers & import("../../typedefs").InputEventHandlers & Record<string, any>, {
|
|
32
13
|
[evt: string]: CustomEvent<any>;
|
|
33
|
-
}, {}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
set role(_: "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined);
|
|
45
|
-
get role(): "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined;
|
|
46
|
-
/**accessor*/
|
|
47
|
-
set hidden(_: boolean | undefined);
|
|
48
|
-
get hidden(): boolean | undefined;
|
|
49
|
-
/**accessor*/
|
|
50
|
-
set disabled(_: boolean | undefined);
|
|
51
|
-
get disabled(): boolean | undefined;
|
|
52
|
-
/**accessor*/
|
|
53
|
-
set readonly(_: boolean | undefined);
|
|
54
|
-
get readonly(): boolean | undefined;
|
|
55
|
-
/**accessor*/
|
|
56
|
-
set required(_: boolean | undefined);
|
|
57
|
-
get required(): boolean | undefined;
|
|
58
|
-
/**accessor*/
|
|
59
|
-
set invalid(_: boolean | undefined);
|
|
60
|
-
get invalid(): boolean | undefined;
|
|
61
|
-
/**accessor*/
|
|
62
|
-
set keyShortcuts(_: string | undefined);
|
|
63
|
-
get keyShortcuts(): string | undefined;
|
|
64
|
-
/**accessor*/
|
|
65
|
-
set name(_: string | undefined);
|
|
66
|
-
get name(): string | undefined;
|
|
67
|
-
/**accessor*/
|
|
68
|
-
set value(_: string | number | undefined);
|
|
69
|
-
get value(): string | number | undefined;
|
|
70
|
-
/**accessor*/
|
|
71
|
-
set showInlineLabel(_: boolean | undefined);
|
|
72
|
-
get showInlineLabel(): boolean | undefined;
|
|
73
|
-
/**accessor*/
|
|
74
|
-
set inputmode(_: "search" | "text" | "email" | "tel" | "numeric" | "decimal" | "url" | undefined);
|
|
75
|
-
get inputmode(): "search" | "text" | "email" | "tel" | "numeric" | "decimal" | "url" | undefined;
|
|
76
|
-
}
|
|
77
|
-
export type TextInputProps = typeof __propDef.props;
|
|
78
|
-
export type TextInputEvents = typeof __propDef.events;
|
|
79
|
-
export type TextInputSlots = typeof __propDef.slots;
|
|
80
|
-
import { SvelteComponent } from "svelte";
|
|
81
|
-
declare const __propDef: {
|
|
82
|
-
props: {
|
|
83
|
-
[x: string]: any;
|
|
84
|
-
class?: string | undefined;
|
|
85
|
-
name?: string | undefined;
|
|
86
|
-
disabled?: boolean | undefined;
|
|
87
|
-
invalid?: boolean | undefined;
|
|
88
|
-
required?: boolean | undefined;
|
|
89
|
-
value?: string | number | undefined;
|
|
90
|
-
role?: "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined;
|
|
91
|
-
hidden?: boolean | undefined;
|
|
92
|
-
element?: HTMLInputElement | undefined;
|
|
93
|
-
readonly?: boolean | undefined;
|
|
94
|
-
keyShortcuts?: string | undefined;
|
|
95
|
-
flex?: boolean | undefined;
|
|
96
|
-
showInlineLabel?: boolean | undefined;
|
|
97
|
-
inputmode?: "search" | "text" | "email" | "tel" | "numeric" | "decimal" | "url" | undefined;
|
|
14
|
+
}, {}, {}, "value" | "element">;
|
|
15
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
16
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
17
|
+
$$bindings?: Bindings;
|
|
18
|
+
} & Exports;
|
|
19
|
+
(internal: unknown, props: Props & {
|
|
20
|
+
$$events?: Events;
|
|
21
|
+
$$slots?: Slots;
|
|
22
|
+
}): Exports & {
|
|
23
|
+
$set?: any;
|
|
24
|
+
$on?: any;
|
|
98
25
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
keyup: KeyboardEvent;
|
|
102
|
-
keypress: KeyboardEvent;
|
|
103
|
-
input: Event;
|
|
104
|
-
change: Event;
|
|
105
|
-
} & {
|
|
106
|
-
[evt: string]: CustomEvent<any>;
|
|
107
|
-
};
|
|
108
|
-
slots: {};
|
|
109
|
-
exports?: undefined;
|
|
110
|
-
bindings?: undefined;
|
|
111
|
-
};
|
|
112
|
-
export {};
|
|
26
|
+
z_$$bindings?: Bindings;
|
|
27
|
+
}
|
|
@@ -5,46 +5,49 @@
|
|
|
5
5
|
@see https://developer.chrome.com/blog/introducing-popover-api/
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
|
-
import { onMount } from 'svelte';
|
|
8
|
+
import { onMount, untrack } from 'svelte';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* @typedef {object} Props
|
|
12
|
+
* @property {string | number | undefined} [id] - The toast ID. If updated, the timer that hides
|
|
13
|
+
* the toast will be reset, meaning the same toast can be displayed for a longer period of time.
|
|
14
|
+
* @property {boolean} [show] - Whether to show the toast.
|
|
15
|
+
* @property {number} [duration] - Duration to automatically hide the toast. Use `0` to hide it
|
|
16
|
+
* manually from the consumer.
|
|
17
|
+
* @property {import('../../typedefs').ToastPosition} [position] - Position of the toast.
|
|
18
|
+
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
14
19
|
*/
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Whether to show the toast.
|
|
18
|
-
* @type {boolean}
|
|
19
|
-
*/
|
|
20
|
-
export let show = false;
|
|
21
|
-
/**
|
|
22
|
-
* Duration to automatically hide the toast. Use `0` to hide it manually from the consumer.
|
|
23
|
-
* @type {number}
|
|
24
|
-
*/
|
|
25
|
-
export let duration = 5000;
|
|
20
|
+
|
|
26
21
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @type {import('../../typedefs').ToastPosition}
|
|
22
|
+
* @type {Props & Record<string, any>}
|
|
29
23
|
*/
|
|
30
|
-
|
|
24
|
+
let {
|
|
25
|
+
/* eslint-disable prefer-const */
|
|
26
|
+
show = $bindable(false),
|
|
27
|
+
id = undefined,
|
|
28
|
+
duration = 5000,
|
|
29
|
+
position = 'bottom-right',
|
|
30
|
+
children,
|
|
31
|
+
...restProps
|
|
32
|
+
/* eslint-enable prefer-const */
|
|
33
|
+
} = $props();
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* @type {HTMLElement | undefined}
|
|
34
37
|
*/
|
|
35
|
-
let popoverBase;
|
|
38
|
+
let popoverBase = $state();
|
|
36
39
|
/**
|
|
37
40
|
* @type {HTMLElement | undefined}
|
|
38
41
|
*/
|
|
39
|
-
let popover;
|
|
42
|
+
let popover = $state();
|
|
40
43
|
/**
|
|
41
44
|
* @type {HTMLElement | undefined}
|
|
42
45
|
*/
|
|
43
|
-
let toast;
|
|
46
|
+
let toast = $state();
|
|
44
47
|
/**
|
|
45
48
|
* @type {number}
|
|
46
49
|
*/
|
|
47
|
-
let timerId = 0;
|
|
50
|
+
let timerId = $state(0);
|
|
48
51
|
|
|
49
52
|
onMount(() => {
|
|
50
53
|
popover =
|
|
@@ -72,30 +75,33 @@
|
|
|
72
75
|
};
|
|
73
76
|
});
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
$effect(() => {
|
|
76
79
|
if (popover && toast) {
|
|
77
80
|
popover.appendChild(toast);
|
|
78
81
|
}
|
|
79
|
-
}
|
|
82
|
+
});
|
|
80
83
|
|
|
81
|
-
|
|
84
|
+
$effect(() => {
|
|
82
85
|
void id;
|
|
83
86
|
void show;
|
|
84
87
|
void duration;
|
|
85
|
-
|
|
88
|
+
|
|
89
|
+
untrack(() => {
|
|
90
|
+
globalThis.clearTimeout(timerId);
|
|
91
|
+
});
|
|
86
92
|
|
|
87
93
|
if (show && duration) {
|
|
88
94
|
timerId = globalThis.setTimeout(() => {
|
|
89
95
|
show = false;
|
|
90
96
|
}, duration);
|
|
91
97
|
}
|
|
92
|
-
}
|
|
98
|
+
});
|
|
93
99
|
</script>
|
|
94
100
|
|
|
95
|
-
<div role="none" class="sui toast-base"
|
|
101
|
+
<div bind:this={popoverBase} role="none" class="sui toast-base"></div>
|
|
96
102
|
|
|
97
|
-
<div class="sui toast {position}" aria-hidden={!show}
|
|
98
|
-
|
|
103
|
+
<div {...restProps} bind:this={toast} class="sui toast {position}" aria-hidden={!show}>
|
|
104
|
+
{@render children?.()}
|
|
99
105
|
</div>
|
|
100
106
|
|
|
101
107
|
<style>.toast-base {
|
|
@@ -1,42 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default Toast;
|
|
2
|
+
type Toast = SvelteComponent<Props & Record<string, any>, {
|
|
3
|
+
[evt: string]: CustomEvent<any>;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "show" | undefined;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Toast/snackbar notification. Use the Popover API if possible to acquire a non-modal top layer.
|
|
6
9
|
* @see https://w3c.github.io/aria/#alert
|
|
7
10
|
* @see https://developer.chrome.com/blog/introducing-popover-api/
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
declare const Toast: $$__sveltets_2_IsomorphicComponent<{
|
|
13
|
+
/**
|
|
14
|
+
* - The toast ID. If updated, the timer that hides
|
|
15
|
+
* the toast will be reset, meaning the same toast can be displayed for a longer period of time.
|
|
16
|
+
*/
|
|
17
|
+
id?: string | number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* - Whether to show the toast.
|
|
20
|
+
*/
|
|
13
21
|
show?: boolean | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* - Duration to automatically hide the toast. Use `0` to hide it
|
|
24
|
+
* manually from the consumer.
|
|
25
|
+
*/
|
|
14
26
|
duration?: number | undefined;
|
|
15
|
-
|
|
27
|
+
/**
|
|
28
|
+
* - Position of the toast.
|
|
29
|
+
*/
|
|
30
|
+
position?: import("../../typedefs").ToastPosition | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* - Primary slot content.
|
|
33
|
+
*/
|
|
34
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
35
|
+
} & Record<string, any>, {
|
|
16
36
|
[evt: string]: CustomEvent<any>;
|
|
17
|
-
}, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
}, {}, {}, "show">;
|
|
38
|
+
type Props = {
|
|
39
|
+
/**
|
|
40
|
+
* - The toast ID. If updated, the timer that hides
|
|
41
|
+
* the toast will be reset, meaning the same toast can be displayed for a longer period of time.
|
|
42
|
+
*/
|
|
43
|
+
id?: string | number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* - Whether to show the toast.
|
|
46
|
+
*/
|
|
47
|
+
show?: boolean | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* - Duration to automatically hide the toast. Use `0` to hide it
|
|
50
|
+
* manually from the consumer.
|
|
51
|
+
*/
|
|
52
|
+
duration?: number | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* - Position of the toast.
|
|
55
|
+
*/
|
|
56
|
+
position?: import("../../typedefs").ToastPosition | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* - Primary slot content.
|
|
59
|
+
*/
|
|
60
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
41
61
|
};
|
|
42
|
-
|
|
62
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
63
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
64
|
+
$$bindings?: Bindings;
|
|
65
|
+
} & Exports;
|
|
66
|
+
(internal: unknown, props: Props & {
|
|
67
|
+
$$events?: Events;
|
|
68
|
+
$$slots?: Slots;
|
|
69
|
+
}): Exports & {
|
|
70
|
+
$set?: any;
|
|
71
|
+
$on?: any;
|
|
72
|
+
};
|
|
73
|
+
z_$$bindings?: Bindings;
|
|
74
|
+
}
|
|
@@ -6,44 +6,44 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
9
|
+
* @typedef {object} Props
|
|
10
|
+
* @property {string} [class] - The `class` attribute on the wrapper element.
|
|
11
|
+
* @property {boolean} [hidden] - Whether to hide the widget.
|
|
12
|
+
* @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
|
|
13
|
+
* attribute.
|
|
14
|
+
* @property {'horizontal' | 'vertical'} [orientation] - Orientation of the widget. An alias of
|
|
15
|
+
* the `aria-orientation` attribute.
|
|
16
|
+
* @property {'primary' | 'secondary' | undefined} [variant] - The style variant of the toolbar.
|
|
17
|
+
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
11
18
|
*/
|
|
12
|
-
|
|
13
|
-
export { className as class };
|
|
14
|
-
/**
|
|
15
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
16
|
-
* @type {boolean | undefined}
|
|
17
|
-
*/
|
|
18
|
-
export let hidden = undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
21
|
-
* @type {boolean}
|
|
22
|
-
*/
|
|
23
|
-
export let disabled = false;
|
|
24
|
-
/**
|
|
25
|
-
* Orientation of the widget. An alias of the `aria-orientation` attribute.
|
|
26
|
-
* @type {'horizontal' | 'vertical'}
|
|
27
|
-
*/
|
|
28
|
-
export let orientation = 'horizontal';
|
|
19
|
+
|
|
29
20
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @type {'primary' | 'secondary' | undefined}
|
|
21
|
+
* @type {Props & Record<string, any>}
|
|
32
22
|
*/
|
|
33
|
-
|
|
23
|
+
let {
|
|
24
|
+
/* eslint-disable prefer-const */
|
|
25
|
+
class: className,
|
|
26
|
+
hidden = false,
|
|
27
|
+
disabled = false,
|
|
28
|
+
orientation = 'horizontal',
|
|
29
|
+
variant = undefined,
|
|
30
|
+
children,
|
|
31
|
+
...restProps
|
|
32
|
+
/* eslint-enable prefer-const */
|
|
33
|
+
} = $props();
|
|
34
34
|
</script>
|
|
35
35
|
|
|
36
36
|
<div
|
|
37
|
+
{...restProps}
|
|
37
38
|
role="toolbar"
|
|
38
39
|
class="sui toolbar {orientation} {variant ?? ''} {className}"
|
|
39
|
-
|
|
40
|
+
{hidden}
|
|
40
41
|
aria-hidden={hidden}
|
|
41
42
|
aria-disabled={disabled}
|
|
42
43
|
aria-orientation={orientation}
|
|
43
|
-
{...$$restProps}
|
|
44
44
|
>
|
|
45
45
|
<div role="none" class="inner" inert={disabled}>
|
|
46
|
-
|
|
46
|
+
{@render children?.()}
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
49
49
|
|