@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
|
@@ -1,44 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default Toolbar;
|
|
2
|
+
type Toolbar = SvelteComponent<Props & Record<string, any>, {
|
|
3
|
+
[evt: string]: CustomEvent<any>;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "" | undefined;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* A toolbar layout that can contain `<Button>`, `<Select>` and other widgets.
|
|
6
9
|
* @see https://w3c.github.io/aria/#toolbar
|
|
7
10
|
* @see https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
declare const Toolbar: $$__sveltets_2_IsomorphicComponent<{
|
|
13
|
+
/**
|
|
14
|
+
* - The `class` attribute on the wrapper element.
|
|
15
|
+
*/
|
|
11
16
|
class?: string | undefined;
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* - Whether to hide the widget.
|
|
19
|
+
*/
|
|
13
20
|
hidden?: boolean | undefined;
|
|
14
|
-
|
|
21
|
+
/**
|
|
22
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
23
|
+
* attribute.
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* - Orientation of the widget. An alias of
|
|
28
|
+
* the `aria-orientation` attribute.
|
|
29
|
+
*/
|
|
15
30
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
16
|
-
|
|
31
|
+
/**
|
|
32
|
+
* - The style variant of the toolbar.
|
|
33
|
+
*/
|
|
34
|
+
variant?: "primary" | "secondary" | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* - Primary slot content.
|
|
37
|
+
*/
|
|
38
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
39
|
+
} & Record<string, any>, {
|
|
17
40
|
[evt: string]: CustomEvent<any>;
|
|
18
|
-
}, {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
}, {}, {}, "">;
|
|
42
|
+
type Props = {
|
|
43
|
+
/**
|
|
44
|
+
* - The `class` attribute on the wrapper element.
|
|
45
|
+
*/
|
|
46
|
+
class?: string | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* - Whether to hide the widget.
|
|
49
|
+
*/
|
|
50
|
+
hidden?: boolean | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
53
|
+
* attribute.
|
|
54
|
+
*/
|
|
55
|
+
disabled?: boolean | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* - Orientation of the widget. An alias of
|
|
58
|
+
* the `aria-orientation` attribute.
|
|
59
|
+
*/
|
|
60
|
+
orientation?: "vertical" | "horizontal" | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* - The style variant of the toolbar.
|
|
63
|
+
*/
|
|
64
|
+
variant?: "primary" | "secondary" | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* - Primary slot content.
|
|
67
|
+
*/
|
|
68
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
43
69
|
};
|
|
44
|
-
|
|
70
|
+
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> {
|
|
71
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
72
|
+
$$bindings?: Bindings;
|
|
73
|
+
} & Exports;
|
|
74
|
+
(internal: unknown, props: Props & {
|
|
75
|
+
$$events?: Events;
|
|
76
|
+
$$slots?: Slots;
|
|
77
|
+
}): Exports & {
|
|
78
|
+
$set?: any;
|
|
79
|
+
$on?: any;
|
|
80
|
+
};
|
|
81
|
+
z_$$bindings?: Bindings;
|
|
82
|
+
}
|
|
@@ -8,10 +8,22 @@
|
|
|
8
8
|
import { onMount } from 'svelte';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
11
|
+
* @typedef {object} Props
|
|
12
|
+
* @property {'horizontal' | 'vertical' | undefined} [orientation] - Orientation of the app
|
|
13
|
+
* shell’s children..
|
|
14
|
+
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
13
15
|
*/
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {Props & Record<string, any>}
|
|
19
|
+
*/
|
|
20
|
+
let {
|
|
21
|
+
/* eslint-disable prefer-const */
|
|
22
|
+
orientation = 'horizontal',
|
|
23
|
+
children,
|
|
24
|
+
...restProps
|
|
25
|
+
/* eslint-enable prefer-const */
|
|
26
|
+
} = $props();
|
|
15
27
|
|
|
16
28
|
const stylesheets = [
|
|
17
29
|
// https://fonts.google.com/share?selection.family=Merriweather%20Sans:ital,wght@0,300;0,600;1,300%7CNoto%20Sans%20Mono
|
|
@@ -22,7 +34,7 @@
|
|
|
22
34
|
];
|
|
23
35
|
|
|
24
36
|
/** @type {HTMLElement | undefined} */
|
|
25
|
-
let fontLoader;
|
|
37
|
+
let fontLoader = $state();
|
|
26
38
|
|
|
27
39
|
onMount(() => {
|
|
28
40
|
const mediaQuery = globalThis.matchMedia('(prefers-color-scheme: dark)');
|
|
@@ -62,18 +74,18 @@
|
|
|
62
74
|
</svelte:head>
|
|
63
75
|
|
|
64
76
|
<!-- Preload fonts, including the icons -->
|
|
65
|
-
<div class="font-loader" aria-hidden="true"
|
|
77
|
+
<div bind:this={fontLoader} class="font-loader" aria-hidden="true" style:opacity="0">
|
|
66
78
|
Loading <strong>Sveltia</strong> <em>UI</em>
|
|
67
79
|
<span role="none" class="material-symbols-outlined">favorite</span>
|
|
68
80
|
</div>
|
|
69
81
|
|
|
70
82
|
<div
|
|
83
|
+
{...restProps}
|
|
71
84
|
role="none"
|
|
72
85
|
class="sui app-shell {orientation ?? ''}"
|
|
73
|
-
{
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
on:contextmenu={(event) => {
|
|
86
|
+
ondragover={(event) => event.preventDefault()}
|
|
87
|
+
ondrop={(event) => event.preventDefault()}
|
|
88
|
+
oncontextmenu={(event) => {
|
|
77
89
|
// Enable the native context menu only in the developer mode or on text fields
|
|
78
90
|
if (
|
|
79
91
|
!document.documentElement.matches('[data-env="dev"]') &&
|
|
@@ -83,7 +95,7 @@
|
|
|
83
95
|
}
|
|
84
96
|
}}
|
|
85
97
|
>
|
|
86
|
-
|
|
98
|
+
{@render children?.()}
|
|
87
99
|
</div>
|
|
88
100
|
|
|
89
101
|
<style global>@import url("https://fonts.googleapis.com/css2?family=Merriweather+Sans:ital,wght@0,300;0,600;1,300;1,600&family=Noto+Sans+Mono&display=swap");
|
|
@@ -1,42 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default AppShell;
|
|
2
|
+
type AppShell = SvelteComponent<Props & Record<string, any>, {
|
|
3
|
+
[evt: string]: CustomEvent<any>;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "" | undefined;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* Provide an application’s shell that makes the web app more like a native app. It also handles the
|
|
6
9
|
* dark/light mode switching. This component has to be placed directly under `<body>` (or
|
|
7
10
|
* `<div style="display:contents">` in a SvelteKit app).
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
declare const AppShell: $$__sveltets_2_IsomorphicComponent<{
|
|
13
|
+
/**
|
|
14
|
+
* - Orientation of the app
|
|
15
|
+
* shell’s children..
|
|
16
|
+
*/
|
|
11
17
|
orientation?: "horizontal" | "vertical" | undefined;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
/**
|
|
19
|
+
* - Primary slot content.
|
|
20
|
+
*/
|
|
21
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
22
|
+
} & Record<string, any>, {
|
|
16
23
|
[evt: string]: CustomEvent<any>;
|
|
17
|
-
}, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
orientation?: "horizontal" | "vertical" | undefined;
|
|
29
|
-
};
|
|
30
|
-
events: {
|
|
31
|
-
dragover: DragEvent;
|
|
32
|
-
drop: DragEvent;
|
|
33
|
-
} & {
|
|
34
|
-
[evt: string]: CustomEvent<any>;
|
|
35
|
-
};
|
|
36
|
-
slots: {
|
|
37
|
-
default: {};
|
|
38
|
-
};
|
|
39
|
-
exports?: undefined;
|
|
40
|
-
bindings?: undefined;
|
|
24
|
+
}, {}, {}, "">;
|
|
25
|
+
type Props = {
|
|
26
|
+
/**
|
|
27
|
+
* - Orientation of the app
|
|
28
|
+
* shell’s children..
|
|
29
|
+
*/
|
|
30
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* - Primary slot content.
|
|
33
|
+
*/
|
|
34
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
41
35
|
};
|
|
42
|
-
|
|
36
|
+
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> {
|
|
37
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
38
|
+
$$bindings?: Bindings;
|
|
39
|
+
} & Exports;
|
|
40
|
+
(internal: unknown, props: Props & {
|
|
41
|
+
$$events?: Events;
|
|
42
|
+
$$slots?: Slots;
|
|
43
|
+
}): Exports & {
|
|
44
|
+
$set?: any;
|
|
45
|
+
$on?: any;
|
|
46
|
+
};
|
|
47
|
+
z_$$bindings?: Bindings;
|
|
48
|
+
}
|
|
@@ -5,33 +5,38 @@
|
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
8
|
+
* @typedef {object} Props
|
|
9
|
+
* @property {string} [class] - The `class` attribute on the wrapper element.
|
|
10
|
+
* @property {boolean} [hidden] - Whether to hide the widget.
|
|
11
|
+
* @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
|
|
12
|
+
* attribute.
|
|
13
|
+
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
10
14
|
*/
|
|
11
|
-
|
|
12
|
-
export { className as class };
|
|
13
|
-
/**
|
|
14
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
15
|
-
* @type {boolean | undefined}
|
|
16
|
-
*/
|
|
17
|
-
export let hidden = undefined;
|
|
15
|
+
|
|
18
16
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @type {boolean}
|
|
17
|
+
* @type {Props & Record<string, any>}
|
|
21
18
|
*/
|
|
22
|
-
|
|
19
|
+
let {
|
|
20
|
+
/* eslint-disable prefer-const */
|
|
21
|
+
class: className,
|
|
22
|
+
hidden = false,
|
|
23
|
+
disabled = false,
|
|
24
|
+
children,
|
|
25
|
+
...restProps
|
|
26
|
+
/* eslint-enable prefer-const */
|
|
27
|
+
} = $props();
|
|
23
28
|
</script>
|
|
24
29
|
|
|
25
30
|
<div
|
|
31
|
+
{...restProps}
|
|
26
32
|
role="group"
|
|
27
33
|
class="sui group {className}"
|
|
28
|
-
|
|
34
|
+
{hidden}
|
|
29
35
|
aria-hidden={hidden}
|
|
30
36
|
aria-disabled={disabled}
|
|
31
|
-
{...$$restProps}
|
|
32
37
|
>
|
|
33
38
|
<div role="none" class="inner" inert={disabled}>
|
|
34
|
-
|
|
39
|
+
{@render children?.()}
|
|
35
40
|
</div>
|
|
36
41
|
</div>
|
|
37
42
|
|
|
@@ -1,39 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export default Group;
|
|
2
|
+
type Group = SvelteComponent<Props & Record<string, any>, {
|
|
3
|
+
[evt: string]: CustomEvent<any>;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "" | undefined;
|
|
6
|
+
};
|
|
4
7
|
/**
|
|
5
8
|
* A generic group layout.
|
|
6
9
|
* @see https://w3c.github.io/aria/#group
|
|
7
10
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
declare const Group: $$__sveltets_2_IsomorphicComponent<{
|
|
12
|
+
/**
|
|
13
|
+
* - The `class` attribute on the wrapper element.
|
|
14
|
+
*/
|
|
10
15
|
class?: string | undefined;
|
|
11
|
-
|
|
16
|
+
/**
|
|
17
|
+
* - Whether to hide the widget.
|
|
18
|
+
*/
|
|
12
19
|
hidden?: boolean | undefined;
|
|
13
|
-
|
|
20
|
+
/**
|
|
21
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
22
|
+
* attribute.
|
|
23
|
+
*/
|
|
24
|
+
disabled?: boolean | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* - Primary slot content.
|
|
27
|
+
*/
|
|
28
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
29
|
+
} & Record<string, any>, {
|
|
14
30
|
[evt: string]: CustomEvent<any>;
|
|
15
|
-
}, {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
default: {};
|
|
35
|
-
};
|
|
36
|
-
exports?: undefined;
|
|
37
|
-
bindings?: undefined;
|
|
31
|
+
}, {}, {}, "">;
|
|
32
|
+
type Props = {
|
|
33
|
+
/**
|
|
34
|
+
* - The `class` attribute on the wrapper element.
|
|
35
|
+
*/
|
|
36
|
+
class?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* - Whether to hide the widget.
|
|
39
|
+
*/
|
|
40
|
+
hidden?: boolean | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
43
|
+
* attribute.
|
|
44
|
+
*/
|
|
45
|
+
disabled?: boolean | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* - Primary slot content.
|
|
48
|
+
*/
|
|
49
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
38
50
|
};
|
|
39
|
-
|
|
51
|
+
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> {
|
|
52
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
53
|
+
$$bindings?: Bindings;
|
|
54
|
+
} & Exports;
|
|
55
|
+
(internal: unknown, props: Props & {
|
|
56
|
+
$$events?: Events;
|
|
57
|
+
$$slots?: Slots;
|
|
58
|
+
}): Exports & {
|
|
59
|
+
$set?: any;
|
|
60
|
+
$on?: any;
|
|
61
|
+
};
|
|
62
|
+
z_$$bindings?: Bindings;
|
|
63
|
+
}
|
|
@@ -2,53 +2,36 @@
|
|
|
2
2
|
@component
|
|
3
3
|
A generic modal top-layer helper based on the HTML `<dialog>` element.
|
|
4
4
|
-->
|
|
5
|
-
<svelte:options accessors={true} />
|
|
6
|
-
|
|
7
5
|
<script>
|
|
8
6
|
import { sleep } from '@sveltia/utils/misc';
|
|
9
|
-
import {
|
|
7
|
+
import { mount, onMount, unmount } from 'svelte';
|
|
8
|
+
import Placeholder from './placeholder.svelte';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
* @type {string}
|
|
14
|
-
*/
|
|
15
|
-
let className = '';
|
|
16
|
-
export { className as class };
|
|
17
|
-
/**
|
|
18
|
-
* The `role` attribute on the `<dialog>` element.
|
|
19
|
-
* @type {'dialog' | 'alertdialog' | 'none'}
|
|
20
|
-
*/
|
|
21
|
-
export let role = 'dialog';
|
|
22
|
-
/**
|
|
23
|
-
* Whether to show the modal.
|
|
24
|
-
* @type {boolean}
|
|
25
|
-
*/
|
|
26
|
-
export let open = false;
|
|
27
|
-
/**
|
|
28
|
-
* Whether to show the backdrop.
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
*/
|
|
31
|
-
export let showBackdrop = false;
|
|
32
|
-
/**
|
|
33
|
-
* Whether to close the modal when the backdrop (outside of the modal) is clicked.
|
|
34
|
-
* @type {boolean}
|
|
35
|
-
*/
|
|
36
|
-
export let lightDismiss = false;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to close the modal when the Escape key is pressed.
|
|
39
|
-
* @type {boolean}
|
|
40
|
-
*/
|
|
41
|
-
export let escapeDismiss = true;
|
|
42
|
-
/**
|
|
43
|
-
* Whether to keep the content in the DOM tree when the modal is not displayed.
|
|
44
|
-
* @type {boolean}
|
|
45
|
-
*/
|
|
46
|
-
export let keepContent = false;
|
|
47
|
-
/**
|
|
48
|
-
* A reference to the `<dialog>` element.
|
|
49
|
-
* @type {HTMLDialogElement | undefined}
|
|
11
|
+
* @type {import('../../typedefs').ModalProps & Record<string, any>}
|
|
50
12
|
*/
|
|
51
|
-
|
|
13
|
+
let {
|
|
14
|
+
/* eslint-disable prefer-const */
|
|
15
|
+
open = $bindable(false),
|
|
16
|
+
dialog = $bindable(),
|
|
17
|
+
class: className,
|
|
18
|
+
role = 'dialog',
|
|
19
|
+
showBackdrop = false,
|
|
20
|
+
lightDismiss = false,
|
|
21
|
+
escapeDismiss = true,
|
|
22
|
+
keepContent = false,
|
|
23
|
+
children,
|
|
24
|
+
extraContent,
|
|
25
|
+
onOpening,
|
|
26
|
+
onOpen,
|
|
27
|
+
onClosing,
|
|
28
|
+
onOk,
|
|
29
|
+
onCancel,
|
|
30
|
+
onClose,
|
|
31
|
+
...restProps
|
|
32
|
+
/* eslint-enable prefer-const */
|
|
33
|
+
} = $props();
|
|
34
|
+
|
|
52
35
|
/**
|
|
53
36
|
* Close the modal.
|
|
54
37
|
* @param {string} returnValue - Return value to be used for `<dialog>`.
|
|
@@ -62,10 +45,9 @@
|
|
|
62
45
|
open = false;
|
|
63
46
|
};
|
|
64
47
|
|
|
65
|
-
|
|
66
|
-
let
|
|
67
|
-
let
|
|
68
|
-
let showContent = false;
|
|
48
|
+
let setOpenClass = $state(false);
|
|
49
|
+
let setActiveClass = $state(false);
|
|
50
|
+
let showContent = $state(false);
|
|
69
51
|
|
|
70
52
|
/**
|
|
71
53
|
* Resolve once the transition is complete.
|
|
@@ -91,15 +73,14 @@
|
|
|
91
73
|
* Show the modal.
|
|
92
74
|
*/
|
|
93
75
|
const openDialog = async () => {
|
|
94
|
-
if (!dialog) {
|
|
76
|
+
if (!dialog || dialog?.open) {
|
|
95
77
|
return;
|
|
96
78
|
}
|
|
97
79
|
|
|
98
|
-
|
|
99
|
-
(document.querySelector('.sui.app-shell') ?? document.body).appendChild(dialog);
|
|
80
|
+
onOpening?.(new CustomEvent('Opening'));
|
|
100
81
|
showContent = true;
|
|
101
82
|
dialog.showModal();
|
|
102
|
-
|
|
83
|
+
onOpen?.(new CustomEvent('Open'));
|
|
103
84
|
await sleep(100);
|
|
104
85
|
setOpenClass = true;
|
|
105
86
|
await waitForTransition();
|
|
@@ -110,90 +91,93 @@
|
|
|
110
91
|
* Hide the modal.
|
|
111
92
|
*/
|
|
112
93
|
const closeDialog = async () => {
|
|
113
|
-
if (!dialog) {
|
|
94
|
+
if (!dialog || !dialog.open) {
|
|
114
95
|
return;
|
|
115
96
|
}
|
|
116
97
|
|
|
117
|
-
|
|
98
|
+
onClosing?.(new CustomEvent('Closing'));
|
|
118
99
|
setActiveClass = false;
|
|
119
100
|
setOpenClass = false;
|
|
120
101
|
await waitForTransition();
|
|
121
102
|
showContent = false;
|
|
122
103
|
dialog.close();
|
|
123
|
-
dialog.remove();
|
|
124
104
|
|
|
125
|
-
if (
|
|
126
|
-
|
|
105
|
+
if (dialog.returnValue === 'ok') {
|
|
106
|
+
onOk?.(new CustomEvent('Ok'));
|
|
107
|
+
onClose?.(new CustomEvent('Close', { detail: { returnValue: 'ok' } }));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (dialog.returnValue === 'cancel') {
|
|
111
|
+
onCancel?.(new CustomEvent('Cancel'));
|
|
112
|
+
onClose?.(new CustomEvent('Close', { detail: { returnValue: 'cancel' } }));
|
|
127
113
|
}
|
|
128
114
|
|
|
129
|
-
dispatch('close', dialog.returnValue);
|
|
130
115
|
dialog.returnValue = '';
|
|
131
116
|
};
|
|
132
117
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (open) {
|
|
139
|
-
openDialog();
|
|
140
|
-
} else {
|
|
141
|
-
closeDialog();
|
|
142
|
-
}
|
|
118
|
+
$effect(() => {
|
|
119
|
+
if (open) {
|
|
120
|
+
openDialog();
|
|
121
|
+
} else {
|
|
122
|
+
closeDialog();
|
|
143
123
|
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
$: {
|
|
147
|
-
void open;
|
|
148
|
-
toggleDialog();
|
|
149
|
-
}
|
|
124
|
+
});
|
|
150
125
|
|
|
151
126
|
onMount(() => {
|
|
152
|
-
|
|
127
|
+
const placeholder = mount(Placeholder, {
|
|
128
|
+
target: document.querySelector('.sui.app-shell') ?? document.body,
|
|
129
|
+
// eslint-disable-next-line no-use-before-define
|
|
130
|
+
props: { children: dialogSnippet },
|
|
131
|
+
});
|
|
153
132
|
|
|
154
133
|
// onUnmount
|
|
155
134
|
return () => {
|
|
156
135
|
dialog?.close();
|
|
157
|
-
|
|
136
|
+
unmount(placeholder);
|
|
158
137
|
};
|
|
159
138
|
});
|
|
160
139
|
</script>
|
|
161
140
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
141
|
+
{#snippet dialogSnippet()}
|
|
142
|
+
<dialog
|
|
143
|
+
bind:this={dialog}
|
|
144
|
+
{...restProps}
|
|
145
|
+
{role}
|
|
146
|
+
class="sui modal {className}"
|
|
147
|
+
class:backdrop={showBackdrop}
|
|
148
|
+
class:open={setOpenClass}
|
|
149
|
+
class:active={setActiveClass}
|
|
150
|
+
onclick={({ target }) => {
|
|
151
|
+
if (
|
|
152
|
+
dialog &&
|
|
153
|
+
lightDismiss &&
|
|
154
|
+
/** @type {HTMLElement | undefined} */ (target)?.matches('dialog')
|
|
155
|
+
) {
|
|
156
|
+
dialog.returnValue = 'cancel';
|
|
157
|
+
open = false;
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
oncancel={(event) => {
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
|
|
163
|
+
// Escape key is pressed
|
|
164
|
+
if (dialog && escapeDismiss) {
|
|
165
|
+
dialog.returnValue = 'cancel';
|
|
166
|
+
open = false;
|
|
167
|
+
}
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
{@render extraContent?.()}
|
|
171
|
+
{#if showContent || keepContent}
|
|
172
|
+
{@render children?.()}
|
|
173
|
+
{/if}
|
|
174
|
+
</dialog>
|
|
175
|
+
{/snippet}
|
|
193
176
|
|
|
194
177
|
<style>dialog {
|
|
195
178
|
position: fixed;
|
|
196
179
|
inset: 0;
|
|
180
|
+
z-index: 9999999;
|
|
197
181
|
display: flex;
|
|
198
182
|
justify-content: center;
|
|
199
183
|
align-items: center;
|