@sveltia/ui 0.25.7 → 0.25.9
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/dist/components/alert/alert.svelte +7 -3
- package/dist/components/alert/alert.svelte.d.ts +11 -10
- package/dist/components/alert/infobar.svelte +9 -5
- package/dist/components/alert/infobar.svelte.d.ts +15 -14
- package/dist/components/button/button-group.svelte +6 -2
- package/dist/components/button/button-group.svelte.d.ts +7 -6
- package/dist/components/button/button.svelte +5 -2
- package/dist/components/button/button.svelte.d.ts +2 -1
- package/dist/components/button/select-button-group.svelte +12 -8
- package/dist/components/button/select-button-group.svelte.d.ts +19 -18
- package/dist/components/button/select-button.svelte +6 -3
- package/dist/components/button/select-button.svelte.d.ts +4 -3
- package/dist/components/button/split-button.svelte +10 -7
- package/dist/components/button/split-button.svelte.d.ts +18 -17
- package/dist/components/calendar/calendar.svelte +1 -1
- package/dist/components/calendar/calendar.svelte.d.ts +2 -2
- package/dist/components/checkbox/checkbox-group.svelte +9 -5
- package/dist/components/checkbox/checkbox-group.svelte.d.ts +13 -12
- package/dist/components/checkbox/checkbox.svelte +13 -9
- package/dist/components/checkbox/checkbox.svelte.d.ts +19 -17
- package/dist/components/dialog/alert-dialog.svelte +5 -2
- package/dist/components/dialog/alert-dialog.svelte.d.ts +3 -1
- package/dist/components/dialog/confirmation-dialog.svelte +5 -2
- package/dist/components/dialog/confirmation-dialog.svelte.d.ts +3 -1
- package/dist/components/dialog/dialog.svelte +5 -2
- package/dist/components/dialog/dialog.svelte.d.ts +3 -1
- package/dist/components/dialog/prompt-dialog.svelte +16 -7
- package/dist/components/dialog/prompt-dialog.svelte.d.ts +17 -13
- package/dist/components/disclosure/disclosure.svelte +12 -8
- package/dist/components/disclosure/disclosure.svelte.d.ts +21 -20
- package/dist/components/divider/divider.svelte +3 -3
- package/dist/components/divider/divider.svelte.d.ts +6 -6
- package/dist/components/divider/spacer.svelte +2 -2
- package/dist/components/divider/spacer.svelte.d.ts +4 -4
- package/dist/components/drawer/drawer.svelte +18 -13
- package/dist/components/drawer/drawer.svelte.d.ts +39 -37
- package/dist/components/grid/grid-body.svelte +7 -3
- package/dist/components/grid/grid-body.svelte.d.ts +9 -8
- package/dist/components/grid/grid-cell.svelte +6 -2
- package/dist/components/grid/grid-cell.svelte.d.ts +7 -6
- package/dist/components/grid/grid-col-header.svelte +6 -2
- package/dist/components/grid/grid-col-header.svelte.d.ts +7 -6
- package/dist/components/grid/grid-foot.svelte +6 -2
- package/dist/components/grid/grid-foot.svelte.d.ts +7 -6
- package/dist/components/grid/grid-head.svelte +6 -2
- package/dist/components/grid/grid-head.svelte.d.ts +7 -6
- package/dist/components/grid/grid-row-header.svelte +6 -2
- package/dist/components/grid/grid-row-header.svelte.d.ts +7 -6
- package/dist/components/grid/grid-row.svelte +9 -5
- package/dist/components/grid/grid-row.svelte.d.ts +13 -12
- package/dist/components/grid/grid.svelte +10 -6
- package/dist/components/grid/grid.svelte.d.ts +15 -14
- package/dist/components/icon/icon.svelte +2 -2
- package/dist/components/icon/icon.svelte.d.ts +4 -4
- package/dist/components/listbox/listbox.svelte +18 -13
- package/dist/components/listbox/listbox.svelte.d.ts +27 -26
- package/dist/components/listbox/option-group.svelte +9 -5
- package/dist/components/listbox/option-group.svelte.d.ts +13 -12
- package/dist/components/listbox/option.svelte +12 -8
- package/dist/components/listbox/option.svelte.d.ts +17 -15
- package/dist/components/menu/menu-button.svelte +7 -4
- package/dist/components/menu/menu-button.svelte.d.ts +6 -5
- package/dist/components/menu/menu-item-checkbox.svelte +5 -2
- package/dist/components/menu/menu-item-checkbox.svelte.d.ts +3 -1
- package/dist/components/menu/menu-item-group.svelte +9 -5
- package/dist/components/menu/menu-item-group.svelte.d.ts +8 -8
- package/dist/components/menu/menu-item-radio.svelte +5 -2
- package/dist/components/menu/menu-item-radio.svelte.d.ts +3 -1
- package/dist/components/menu/menu-item.svelte +5 -2
- package/dist/components/menu/menu-item.svelte.d.ts +3 -1
- package/dist/components/menu/menu.svelte +9 -5
- package/dist/components/menu/menu.svelte.d.ts +13 -12
- package/dist/components/progressbar/progressbar.svelte +5 -5
- package/dist/components/progressbar/progressbar.svelte.d.ts +10 -10
- package/dist/components/radio/radio-group.svelte +13 -9
- package/dist/components/radio/radio-group.svelte.d.ts +21 -20
- package/dist/components/radio/radio.svelte +15 -11
- package/dist/components/radio/radio.svelte.d.ts +27 -26
- package/dist/components/select/combobox.svelte +6 -3
- package/dist/components/select/combobox.svelte.d.ts +3 -1
- package/dist/components/select/select-tags.svelte +16 -13
- package/dist/components/select/select-tags.svelte.d.ts +27 -28
- package/dist/components/select/select.svelte +5 -1
- package/dist/components/select/select.svelte.d.ts +2 -1
- package/dist/components/slider/slider.svelte +27 -25
- package/dist/components/slider/slider.svelte.d.ts +35 -34
- package/dist/components/switch/switch.svelte +13 -9
- package/dist/components/switch/switch.svelte.d.ts +21 -20
- package/dist/components/table/table-body.svelte +7 -3
- package/dist/components/table/table-body.svelte.d.ts +9 -8
- package/dist/components/table/table-cell.svelte +6 -2
- package/dist/components/table/table-cell.svelte.d.ts +7 -6
- package/dist/components/table/table-col-header.svelte +6 -2
- package/dist/components/table/table-col-header.svelte.d.ts +7 -6
- package/dist/components/table/table-foot.svelte +6 -2
- package/dist/components/table/table-foot.svelte.d.ts +7 -6
- package/dist/components/table/table-head.svelte +6 -2
- package/dist/components/table/table-head.svelte.d.ts +7 -6
- package/dist/components/table/table-row-header.svelte +6 -2
- package/dist/components/table/table-row-header.svelte.d.ts +7 -6
- package/dist/components/table/table-row.svelte +6 -2
- package/dist/components/table/table-row.svelte.d.ts +7 -6
- package/dist/components/table/table.svelte +6 -2
- package/dist/components/table/table.svelte.d.ts +7 -6
- package/dist/components/tabs/tab-box.svelte +7 -3
- package/dist/components/tabs/tab-box.svelte.d.ts +9 -8
- package/dist/components/tabs/tab-list.svelte +12 -8
- package/dist/components/tabs/tab-list.svelte.d.ts +19 -18
- package/dist/components/tabs/tab-panel.svelte +6 -2
- package/dist/components/tabs/tab-panel.svelte.d.ts +7 -6
- package/dist/components/tabs/tab-panels.svelte +6 -2
- package/dist/components/tabs/tab-panels.svelte.d.ts +7 -6
- package/dist/components/tabs/tab.svelte +6 -3
- package/dist/components/tabs/tab.svelte.d.ts +4 -3
- package/dist/components/text-editor/code-editor.svelte +16 -18
- package/dist/components/text-editor/code-editor.svelte.d.ts +25 -24
- package/dist/components/text-editor/core.d.ts +5 -3
- package/dist/components/text-editor/core.js +26 -15
- package/dist/components/text-editor/index.d.ts +12 -6
- package/dist/components/text-editor/index.js +7 -3
- package/dist/components/text-editor/lexical-root.svelte +27 -30
- package/dist/components/text-editor/lexical-root.svelte.d.ts +17 -16
- package/dist/components/text-editor/store.svelte.d.ts +2 -1
- package/dist/components/text-editor/store.svelte.js +10 -5
- package/dist/components/text-editor/text-editor.svelte +22 -13
- package/dist/components/text-editor/text-editor.svelte.d.ts +37 -32
- package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte +3 -3
- package/dist/components/text-editor/toolbar/code-editor-toolbar.svelte.d.ts +6 -6
- package/dist/components/text-editor/toolbar/code-language-switcher.svelte +6 -2
- package/dist/components/text-editor/toolbar/code-language-switcher.svelte.d.ts +2 -2
- package/dist/components/text-editor/toolbar/format-text-button.svelte +6 -2
- package/dist/components/text-editor/toolbar/format-text-button.svelte.d.ts +5 -4
- package/dist/components/text-editor/toolbar/insert-image-button.svelte +6 -2
- package/dist/components/text-editor/toolbar/insert-image-button.svelte.d.ts +5 -4
- package/dist/components/text-editor/toolbar/insert-link-button.svelte +9 -4
- package/dist/components/text-editor/toolbar/insert-menu-button.svelte +6 -2
- package/dist/components/text-editor/toolbar/insert-menu-button.svelte.d.ts +5 -4
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte +10 -6
- package/dist/components/text-editor/toolbar/text-editor-toolbar.svelte.d.ts +6 -6
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte +8 -5
- package/dist/components/text-editor/toolbar/toggle-block-menu-item.svelte.d.ts +5 -4
- package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte +7 -3
- package/dist/components/text-editor/toolbar/toolbar-wrapper.svelte.d.ts +9 -8
- package/dist/components/text-editor/transformers/table.d.ts +3 -2
- package/dist/components/text-editor/transformers/table.js +5 -1
- package/dist/components/text-field/number-input.svelte +12 -8
- package/dist/components/text-field/number-input.svelte.d.ts +20 -17
- package/dist/components/text-field/password-input.svelte +8 -4
- package/dist/components/text-field/password-input.svelte.d.ts +10 -7
- package/dist/components/text-field/search-bar.svelte +9 -5
- package/dist/components/text-field/search-bar.svelte.d.ts +14 -11
- package/dist/components/text-field/text-area.svelte +18 -14
- package/dist/components/text-field/text-area.svelte.d.ts +29 -27
- package/dist/components/text-field/text-input.svelte +7 -3
- package/dist/components/text-field/text-input.svelte.d.ts +5 -3
- package/dist/components/toast/toast.svelte +10 -5
- package/dist/components/toast/toast.svelte.d.ts +16 -14
- package/dist/components/toolbar/toolbar.svelte +11 -7
- package/dist/components/toolbar/toolbar.svelte.d.ts +17 -16
- package/dist/components/util/app-shell.svelte +6 -3
- package/dist/components/util/app-shell.svelte.d.ts +7 -8
- package/dist/components/util/group.svelte +8 -4
- package/dist/components/util/group.svelte.d.ts +11 -10
- package/dist/components/util/modal.svelte +7 -3
- package/dist/components/util/modal.svelte.d.ts +2 -1
- package/dist/components/util/placeholder.svelte +5 -1
- package/dist/components/util/placeholder.svelte.d.ts +5 -4
- package/dist/components/util/popup.svelte +23 -17
- package/dist/components/util/popup.svelte.d.ts +36 -33
- package/dist/index.js +3 -3
- package/dist/services/events.svelte.d.ts +2 -1
- package/dist/services/events.svelte.js +12 -8
- package/dist/services/group.svelte.d.ts +2 -1
- package/dist/services/group.svelte.js +16 -12
- package/dist/services/popup.svelte.d.ts +16 -10
- package/dist/services/popup.svelte.js +14 -13
- package/dist/typedefs.d.ts +191 -189
- package/dist/typedefs.js +168 -164
- package/package.json +18 -18
|
@@ -10,57 +10,58 @@ type Toolbar = {
|
|
|
10
10
|
*/
|
|
11
11
|
declare const Toolbar: import("svelte").Component<{
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* The `class` attribute on the wrapper element.
|
|
14
14
|
*/
|
|
15
15
|
class?: string | undefined;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Whether to hide the widget.
|
|
18
18
|
*/
|
|
19
19
|
hidden?: boolean | undefined;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
22
22
|
* attribute.
|
|
23
23
|
*/
|
|
24
24
|
disabled?: boolean | undefined;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Orientation of the widget. An alias of the
|
|
27
|
+
* `aria-orientation` attribute.
|
|
28
28
|
*/
|
|
29
29
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* The style variant of the toolbar.
|
|
32
32
|
*/
|
|
33
33
|
variant?: "primary" | "secondary" | undefined;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Primary slot content.
|
|
36
36
|
*/
|
|
37
|
-
children?:
|
|
37
|
+
children?: Snippet<[]> | undefined;
|
|
38
38
|
} & Record<string, any>, {}, "">;
|
|
39
39
|
type Props = {
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* The `class` attribute on the wrapper element.
|
|
42
42
|
*/
|
|
43
43
|
class?: string | undefined;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Whether to hide the widget.
|
|
46
46
|
*/
|
|
47
47
|
hidden?: boolean | undefined;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
50
50
|
* attribute.
|
|
51
51
|
*/
|
|
52
52
|
disabled?: boolean | undefined;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
54
|
+
* Orientation of the widget. An alias of the
|
|
55
|
+
* `aria-orientation` attribute.
|
|
56
56
|
*/
|
|
57
57
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* The style variant of the toolbar.
|
|
60
60
|
*/
|
|
61
61
|
variant?: "primary" | "secondary" | undefined;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Primary slot content.
|
|
64
64
|
*/
|
|
65
|
-
children?:
|
|
65
|
+
children?: Snippet<[]> | undefined;
|
|
66
66
|
};
|
|
67
|
+
import type { Snippet } from 'svelte';
|
|
@@ -7,11 +7,14 @@
|
|
|
7
7
|
<script>
|
|
8
8
|
import { onMount } from 'svelte';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @import { Snippet } from 'svelte';
|
|
12
|
+
*/
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* @typedef {object} Props
|
|
12
|
-
* @property {'horizontal' | 'vertical'} [orientation]
|
|
13
|
-
*
|
|
14
|
-
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
16
|
+
* @property {'horizontal' | 'vertical'} [orientation] Orientation of the app shell’s children.
|
|
17
|
+
* @property {Snippet} [children] Primary slot content.
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -10,23 +10,22 @@ type AppShell = {
|
|
|
10
10
|
*/
|
|
11
11
|
declare const AppShell: import("svelte").Component<{
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* shell’s children..
|
|
13
|
+
* Orientation of the app shell’s children.
|
|
15
14
|
*/
|
|
16
15
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
17
16
|
/**
|
|
18
|
-
*
|
|
17
|
+
* Primary slot content.
|
|
19
18
|
*/
|
|
20
|
-
children?:
|
|
19
|
+
children?: Snippet<[]> | undefined;
|
|
21
20
|
} & Record<string, any>, {}, "">;
|
|
22
21
|
type Props = {
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
25
|
-
* shell’s children..
|
|
23
|
+
* Orientation of the app shell’s children.
|
|
26
24
|
*/
|
|
27
25
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
27
|
+
* Primary slot content.
|
|
30
28
|
*/
|
|
31
|
-
children?:
|
|
29
|
+
children?: Snippet<[]> | undefined;
|
|
32
30
|
};
|
|
31
|
+
import type { Snippet } from 'svelte';
|
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
@see https://w3c.github.io/aria/#group
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
|
+
/**
|
|
8
|
+
* @import { Snippet } from 'svelte';
|
|
9
|
+
*/
|
|
10
|
+
|
|
7
11
|
/**
|
|
8
12
|
* @typedef {object} Props
|
|
9
|
-
* @property {string} [class]
|
|
10
|
-
* @property {boolean} [hidden]
|
|
11
|
-
* @property {boolean} [disabled]
|
|
13
|
+
* @property {string} [class] The `class` attribute on the wrapper element.
|
|
14
|
+
* @property {boolean} [hidden] Whether to hide the widget.
|
|
15
|
+
* @property {boolean} [disabled] Whether to disable the widget. An alias of the `aria-disabled`
|
|
12
16
|
* attribute.
|
|
13
|
-
* @property {
|
|
17
|
+
* @property {Snippet} [children] Primary slot content.
|
|
14
18
|
*/
|
|
15
19
|
|
|
16
20
|
/**
|
|
@@ -9,39 +9,40 @@ type Group = {
|
|
|
9
9
|
*/
|
|
10
10
|
declare const Group: import("svelte").Component<{
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* The `class` attribute on the wrapper element.
|
|
13
13
|
*/
|
|
14
14
|
class?: string | undefined;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Whether to hide the widget.
|
|
17
17
|
*/
|
|
18
18
|
hidden?: boolean | undefined;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
21
21
|
* attribute.
|
|
22
22
|
*/
|
|
23
23
|
disabled?: boolean | undefined;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Primary slot content.
|
|
26
26
|
*/
|
|
27
|
-
children?:
|
|
27
|
+
children?: Snippet<[]> | undefined;
|
|
28
28
|
} & Record<string, any>, {}, "">;
|
|
29
29
|
type Props = {
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* The `class` attribute on the wrapper element.
|
|
32
32
|
*/
|
|
33
33
|
class?: string | undefined;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Whether to hide the widget.
|
|
36
36
|
*/
|
|
37
37
|
hidden?: boolean | undefined;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* Whether to disable the widget. An alias of the `aria-disabled`
|
|
40
40
|
* attribute.
|
|
41
41
|
*/
|
|
42
42
|
disabled?: boolean | undefined;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Primary slot content.
|
|
45
45
|
*/
|
|
46
|
-
children?:
|
|
46
|
+
children?: Snippet<[]> | undefined;
|
|
47
47
|
};
|
|
48
|
+
import type { Snippet } from 'svelte';
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
import Placeholder from './placeholder.svelte';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @
|
|
11
|
+
* @import { ModalProps } from '../../typedefs';
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {ModalProps & Record<string, any>}
|
|
12
16
|
*/
|
|
13
17
|
let {
|
|
14
18
|
/* eslint-disable prefer-const */
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
40
|
* Close the modal.
|
|
37
|
-
* @param {string} returnValue
|
|
41
|
+
* @param {string} returnValue Return value to be used for `<dialog>`.
|
|
38
42
|
*/
|
|
39
43
|
export const close = (returnValue) => {
|
|
40
44
|
if (!dialog) {
|
|
@@ -57,7 +61,7 @@
|
|
|
57
61
|
new Promise((resolve) => {
|
|
58
62
|
/**
|
|
59
63
|
* Transition event listener.
|
|
60
|
-
* @param {TransitionEvent} event
|
|
64
|
+
* @param {TransitionEvent} event `transition` event.
|
|
61
65
|
*/
|
|
62
66
|
const listener = (event) => {
|
|
63
67
|
if (event.target === dialog) {
|
|
@@ -6,6 +6,7 @@ type Modal = {
|
|
|
6
6
|
close: (returnValue: string) => void;
|
|
7
7
|
};
|
|
8
8
|
/** A generic modal top-layer helper based on the HTML `<dialog>` element. */
|
|
9
|
-
declare const Modal: import("svelte").Component<
|
|
9
|
+
declare const Modal: import("svelte").Component<ModalProps & Record<string, any>, {
|
|
10
10
|
close: (returnValue: string) => void;
|
|
11
11
|
}, "dialog" | "open">;
|
|
12
|
+
import type { ModalProps } from '../../typedefs';
|
|
@@ -3,9 +3,13 @@
|
|
|
3
3
|
@see https://github.com/sveltejs/svelte/issues/3088
|
|
4
4
|
-->
|
|
5
5
|
<script>
|
|
6
|
+
/**
|
|
7
|
+
* @import { Snippet } from 'svelte';
|
|
8
|
+
*/
|
|
9
|
+
|
|
6
10
|
/**
|
|
7
11
|
* @typedef {object} Props
|
|
8
|
-
* @property {
|
|
12
|
+
* @property {Snippet} [children] Primary slot content.
|
|
9
13
|
*/
|
|
10
14
|
|
|
11
15
|
/**
|
|
@@ -6,13 +6,14 @@ type Placeholder = {
|
|
|
6
6
|
/** @see https://github.com/sveltejs/svelte/issues/3088 */
|
|
7
7
|
declare const Placeholder: import("svelte").Component<{
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Primary slot content.
|
|
10
10
|
*/
|
|
11
|
-
children?:
|
|
11
|
+
children?: Snippet<[]> | undefined;
|
|
12
12
|
} & Record<string, any>, {}, "">;
|
|
13
13
|
type Props = {
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Primary slot content.
|
|
16
16
|
*/
|
|
17
|
-
children?:
|
|
17
|
+
children?: Snippet<[]> | undefined;
|
|
18
18
|
};
|
|
19
|
+
import type { Snippet } from 'svelte';
|
|
@@ -9,28 +9,34 @@
|
|
|
9
9
|
import { activatePopup } from '../../services/popup.svelte.js';
|
|
10
10
|
import Modal from './modal.svelte';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* @import { Snippet } from 'svelte';
|
|
14
|
+
* @import { Writable } from 'svelte/store';
|
|
15
|
+
* @import { ModalProps, PopupPosition } from '../../typedefs';
|
|
16
|
+
*/
|
|
17
|
+
|
|
12
18
|
/**
|
|
13
19
|
* @typedef {object} Props
|
|
14
|
-
* @property {string} [class]
|
|
15
|
-
* @property {boolean} [open]
|
|
16
|
-
* @property {boolean} [hovered]
|
|
17
|
-
* @property {HTMLElement} [anchor]
|
|
20
|
+
* @property {string} [class] The `class` attribute on the content element.
|
|
21
|
+
* @property {boolean} [open] Whether to open the popup.
|
|
22
|
+
* @property {boolean} [hovered] Whether the content is hovered.
|
|
23
|
+
* @property {HTMLElement} [anchor] A reference to the anchor element that opens the popup.
|
|
18
24
|
* Typically a `<button>`.
|
|
19
|
-
* @property {HTMLElement} [content]
|
|
20
|
-
* @property {
|
|
21
|
-
* @property {HTMLElement} [positionBaseElement]
|
|
22
|
-
*
|
|
23
|
-
* @property {HTMLDialogElement} [parentDialogElement]
|
|
25
|
+
* @property {HTMLElement} [content] A reference to the content element.
|
|
26
|
+
* @property {PopupPosition} [position] Where to show the popup.
|
|
27
|
+
* @property {HTMLElement} [positionBaseElement] The base element of {@link position}. If omitted,
|
|
28
|
+
* this will be {@link anchor}.
|
|
29
|
+
* @property {HTMLDialogElement} [parentDialogElement] A reference to a dialog element that is
|
|
24
30
|
* already displayed. This should be provided for a nested popup.
|
|
25
|
-
* @property {boolean} [touchOptimized]
|
|
31
|
+
* @property {boolean} [touchOptimized] Whether to show the popup at the center of the screen on
|
|
26
32
|
* mobile/tablet and ignore the defined dropdown `position`.
|
|
27
|
-
* @property {
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {(event: CustomEvent) => void} [onOpen]
|
|
33
|
+
* @property {Snippet} [children] Primary slot content.
|
|
34
|
+
* @property {Snippet} [extraContent] Extra slot content.
|
|
35
|
+
* @property {(event: CustomEvent) => void} [onOpen] Custom `Open` event handler.
|
|
30
36
|
*/
|
|
31
37
|
|
|
32
38
|
/**
|
|
33
|
-
* @type {
|
|
39
|
+
* @type {ModalProps & Props & Record<string, any>}
|
|
34
40
|
*/
|
|
35
41
|
let {
|
|
36
42
|
/* eslint-disable prefer-const */
|
|
@@ -73,7 +79,7 @@
|
|
|
73
79
|
let contentType = $state();
|
|
74
80
|
/**
|
|
75
81
|
* Style to be applied to the content.
|
|
76
|
-
* @type {
|
|
82
|
+
* @type {Writable<Record<string, any>>}
|
|
77
83
|
*/
|
|
78
84
|
let style = writable({
|
|
79
85
|
inset: undefined,
|
|
@@ -83,8 +89,8 @@
|
|
|
83
89
|
});
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
|
-
* @type {{ style:
|
|
87
|
-
*
|
|
92
|
+
* @type {{ style: Writable<Record<string, any>>, open: Writable<boolean>, checkPosition:
|
|
93
|
+
* () => void } | undefined}
|
|
88
94
|
*/
|
|
89
95
|
let popupInstance = undefined;
|
|
90
96
|
let hoveredTimeout = 0;
|
|
@@ -4,111 +4,114 @@ type Popup = {
|
|
|
4
4
|
$set?(props: Partial<ModalProps & Props & Record<string, any>>): void;
|
|
5
5
|
};
|
|
6
6
|
/** Generic popup helper. */
|
|
7
|
-
declare const Popup: import("svelte").Component<
|
|
7
|
+
declare const Popup: import("svelte").Component<ModalProps & {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The `class` attribute on the content element.
|
|
10
10
|
*/
|
|
11
11
|
class?: string | undefined;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Whether to open the popup.
|
|
14
14
|
*/
|
|
15
15
|
open?: boolean | undefined;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Whether the content is hovered.
|
|
18
18
|
*/
|
|
19
19
|
hovered?: boolean | undefined;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* A reference to the anchor element that opens the popup.
|
|
22
22
|
* Typically a `<button>`.
|
|
23
23
|
*/
|
|
24
24
|
anchor?: HTMLElement | undefined;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* A reference to the content element.
|
|
27
27
|
*/
|
|
28
28
|
content?: HTMLElement | undefined;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Where to show the popup.
|
|
31
31
|
*/
|
|
32
|
-
position?:
|
|
32
|
+
position?: PopupPosition | undefined;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
34
|
+
* The base element of {@link position}. If omitted,
|
|
35
|
+
* this will be {@link anchor}.
|
|
36
36
|
*/
|
|
37
37
|
positionBaseElement?: HTMLElement | undefined;
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* A reference to a dialog element that is
|
|
40
40
|
* already displayed. This should be provided for a nested popup.
|
|
41
41
|
*/
|
|
42
42
|
parentDialogElement?: HTMLDialogElement | undefined;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Whether to show the popup at the center of the screen on
|
|
45
45
|
* mobile/tablet and ignore the defined dropdown `position`.
|
|
46
46
|
*/
|
|
47
47
|
touchOptimized?: boolean | undefined;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Primary slot content.
|
|
50
50
|
*/
|
|
51
|
-
children?:
|
|
51
|
+
children?: Snippet<[]> | undefined;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Extra slot content.
|
|
54
54
|
*/
|
|
55
|
-
extraContent?:
|
|
55
|
+
extraContent?: Snippet<[]> | undefined;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Custom `Open` event handler.
|
|
58
58
|
*/
|
|
59
59
|
onOpen?: ((event: CustomEvent) => void) | undefined;
|
|
60
60
|
} & Record<string, any>, {}, "open" | "hovered" | "content">;
|
|
61
61
|
type Props = {
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* The `class` attribute on the content element.
|
|
64
64
|
*/
|
|
65
65
|
class?: string | undefined;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Whether to open the popup.
|
|
68
68
|
*/
|
|
69
69
|
open?: boolean | undefined;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Whether the content is hovered.
|
|
72
72
|
*/
|
|
73
73
|
hovered?: boolean | undefined;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* A reference to the anchor element that opens the popup.
|
|
76
76
|
* Typically a `<button>`.
|
|
77
77
|
*/
|
|
78
78
|
anchor?: HTMLElement | undefined;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* A reference to the content element.
|
|
81
81
|
*/
|
|
82
82
|
content?: HTMLElement | undefined;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Where to show the popup.
|
|
85
85
|
*/
|
|
86
|
-
position?:
|
|
86
|
+
position?: PopupPosition | undefined;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
88
|
+
* The base element of {@link position}. If omitted,
|
|
89
|
+
* this will be {@link anchor}.
|
|
90
90
|
*/
|
|
91
91
|
positionBaseElement?: HTMLElement | undefined;
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* A reference to a dialog element that is
|
|
94
94
|
* already displayed. This should be provided for a nested popup.
|
|
95
95
|
*/
|
|
96
96
|
parentDialogElement?: HTMLDialogElement | undefined;
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
98
|
+
* Whether to show the popup at the center of the screen on
|
|
99
99
|
* mobile/tablet and ignore the defined dropdown `position`.
|
|
100
100
|
*/
|
|
101
101
|
touchOptimized?: boolean | undefined;
|
|
102
102
|
/**
|
|
103
|
-
*
|
|
103
|
+
* Primary slot content.
|
|
104
104
|
*/
|
|
105
|
-
children?:
|
|
105
|
+
children?: Snippet<[]> | undefined;
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
107
|
+
* Extra slot content.
|
|
108
108
|
*/
|
|
109
|
-
extraContent?:
|
|
109
|
+
extraContent?: Snippet<[]> | undefined;
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
111
|
+
* Custom `Open` event handler.
|
|
112
112
|
*/
|
|
113
113
|
onOpen?: ((event: CustomEvent) => void) | undefined;
|
|
114
114
|
};
|
|
115
|
+
import type { ModalProps } from '../../typedefs';
|
|
116
|
+
import type { PopupPosition } from '../../typedefs';
|
|
117
|
+
import type { Snippet } from 'svelte';
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,9 @@ import { addMessages, init } from 'svelte-i18n';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Load strings and initialize the locales.
|
|
5
|
-
* @param {object} [init]
|
|
6
|
-
* @param {string} [init.fallbackLocale]
|
|
7
|
-
* @param {string} [init.initialLocale]
|
|
5
|
+
* @param {object} [init] Initialize options.
|
|
6
|
+
* @param {string} [init.fallbackLocale] Fallback locale.
|
|
7
|
+
* @param {string} [init.initialLocale] Initial locale.
|
|
8
8
|
* @see https://github.com/kaisermann/svelte-i18n/blob/main/docs/Getting%20Started.md
|
|
9
9
|
* @see https://vitejs.dev/guide/features.html#glob-import
|
|
10
10
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export function isMac(): boolean;
|
|
2
2
|
export function matchShortcuts(event: KeyboardEvent, shortcuts: string): boolean;
|
|
3
|
-
export function activateKeyShortcuts(element: (HTMLInputElement | HTMLButtonElement), shortcuts?: string | undefined):
|
|
3
|
+
export function activateKeyShortcuts(element: (HTMLInputElement | HTMLButtonElement), shortcuts?: string | undefined): ActionReturn;
|
|
4
|
+
import type { ActionReturn } from 'svelte/action';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { ActionReturn } from 'svelte/action';
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* Check if the user agent is macOS.
|
|
3
7
|
* @returns {boolean} Result.
|
|
@@ -8,8 +12,8 @@ export const isMac = () =>
|
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* Whether the event matches the given keyboard shortcuts.
|
|
11
|
-
* @param {KeyboardEvent} event
|
|
12
|
-
* @param {string} shortcuts
|
|
15
|
+
* @param {KeyboardEvent} event `keydown` or `keypress` event.
|
|
16
|
+
* @param {string} shortcuts Keyboard shortcuts like `A` or `Ctrl+S`.
|
|
13
17
|
* @returns {boolean} Result.
|
|
14
18
|
* @see https://w3c.github.io/aria/#aria-keyshortcuts
|
|
15
19
|
*/
|
|
@@ -48,11 +52,11 @@ export const matchShortcuts = (event, shortcuts) => {
|
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* Activate keyboard shortcuts.
|
|
51
|
-
* @param {(HTMLInputElement | HTMLButtonElement)} element
|
|
52
|
-
* @param {string} [shortcuts]
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* @returns {
|
|
55
|
+
* @param {(HTMLInputElement | HTMLButtonElement)} element Element.
|
|
56
|
+
* @param {string} [shortcuts] Keyboard shortcuts like `A` or `Accel+S` to focus and click the text
|
|
57
|
+
* field or button. Multiple shortcuts can be defined space-separated. The `Accel` modifier will be
|
|
58
|
+
* replaced with `Ctrl` on Windows/Linux and `Command` on macOS.
|
|
59
|
+
* @returns {ActionReturn} Actions.
|
|
56
60
|
*/
|
|
57
61
|
export const activateKeyShortcuts = (element, shortcuts = '') => {
|
|
58
62
|
/** @type {string | undefined} */
|
|
@@ -60,7 +64,7 @@ export const activateKeyShortcuts = (element, shortcuts = '') => {
|
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
66
|
* Handle the event.
|
|
63
|
-
* @param {KeyboardEvent} event
|
|
67
|
+
* @param {KeyboardEvent} event `keydown` event.
|
|
64
68
|
*/
|
|
65
69
|
const handler = (event) => {
|
|
66
70
|
const { disabled, offsetParent } = element;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export function activateGroup(parent: HTMLElement, params?: object | undefined):
|
|
1
|
+
export function activateGroup(parent: HTMLElement, params?: object | undefined): ActionReturn;
|
|
2
|
+
import type { ActionReturn } from 'svelte/action';
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @import { ActionReturn } from 'svelte/action';
|
|
3
|
+
*/
|
|
4
|
+
|
|
1
5
|
import { generateElementId } from '@sveltia/utils/element';
|
|
2
6
|
import { sleep } from '@sveltia/utils/misc';
|
|
3
7
|
|
|
@@ -61,9 +65,9 @@ const config = {
|
|
|
61
65
|
class Group {
|
|
62
66
|
/**
|
|
63
67
|
* Initialize a new `Group` instance.
|
|
64
|
-
* @param {HTMLElement} parent
|
|
65
|
-
* @param {object} [options]
|
|
66
|
-
* @param {boolean} [options.clickToSelect]
|
|
68
|
+
* @param {HTMLElement} parent Parent element.
|
|
69
|
+
* @param {object} [options] Options.
|
|
70
|
+
* @param {boolean} [options.clickToSelect] Whether to select an item by clicking on it.
|
|
67
71
|
* @todo Check for added elements probably with `MutationObserver`.
|
|
68
72
|
*/
|
|
69
73
|
constructor(parent, { clickToSelect = true } = {}) {
|
|
@@ -211,8 +215,8 @@ class Group {
|
|
|
211
215
|
|
|
212
216
|
/**
|
|
213
217
|
* Select (and move focus to) the given target.
|
|
214
|
-
* @param {(MouseEvent | KeyboardEvent)} event
|
|
215
|
-
* @param {HTMLElement} newTarget
|
|
218
|
+
* @param {(MouseEvent | KeyboardEvent)} event Triggered event.
|
|
219
|
+
* @param {HTMLElement} newTarget Target element.
|
|
216
220
|
*/
|
|
217
221
|
selectTarget(event, newTarget) {
|
|
218
222
|
if (this.isDisabled || this.isReadOnly) {
|
|
@@ -335,7 +339,7 @@ class Group {
|
|
|
335
339
|
|
|
336
340
|
/**
|
|
337
341
|
* Handle the `click` event on the widget.
|
|
338
|
-
* @param {MouseEvent} event
|
|
342
|
+
* @param {MouseEvent} event `click` event.
|
|
339
343
|
*/
|
|
340
344
|
onClick(event) {
|
|
341
345
|
// eslint-disable-next-line prefer-destructuring
|
|
@@ -354,7 +358,7 @@ class Group {
|
|
|
354
358
|
|
|
355
359
|
/**
|
|
356
360
|
* Handle the `keydown` event on the widget.
|
|
357
|
-
* @param {KeyboardEvent} event
|
|
361
|
+
* @param {KeyboardEvent} event `keydown` event.
|
|
358
362
|
*/
|
|
359
363
|
onKeyDown(event) {
|
|
360
364
|
const { key, ctrlKey, metaKey, shiftKey, altKey } = event;
|
|
@@ -461,7 +465,7 @@ class Group {
|
|
|
461
465
|
|
|
462
466
|
/**
|
|
463
467
|
* Called whenever the params are updated. Filter the items based on the search terms.
|
|
464
|
-
* @param {{ searchTerms: string }} params
|
|
468
|
+
* @param {{ searchTerms: string }} params Updated params.
|
|
465
469
|
*/
|
|
466
470
|
onUpdate({ searchTerms }) {
|
|
467
471
|
const terms = searchTerms.trim().toLocaleLowerCase();
|
|
@@ -493,9 +497,9 @@ class Group {
|
|
|
493
497
|
|
|
494
498
|
/**
|
|
495
499
|
* Activate a new group.
|
|
496
|
-
* @param {HTMLElement} parent
|
|
497
|
-
* @param {object} [params]
|
|
498
|
-
* @returns {
|
|
500
|
+
* @param {HTMLElement} parent Parent element.
|
|
501
|
+
* @param {object} [params] Action params.
|
|
502
|
+
* @returns {ActionReturn} Action.
|
|
499
503
|
*/
|
|
500
504
|
export const activateGroup = (parent, params) => {
|
|
501
505
|
const group = new Group(parent, params);
|
|
@@ -503,7 +507,7 @@ export const activateGroup = (parent, params) => {
|
|
|
503
507
|
return {
|
|
504
508
|
/**
|
|
505
509
|
* Called whenever the params are updated.
|
|
506
|
-
* @param {any} newParams
|
|
510
|
+
* @param {any} newParams Updated params.
|
|
507
511
|
*/
|
|
508
512
|
update(newParams) {
|
|
509
513
|
group.onUpdate(newParams);
|