@sveltia/ui 0.16.0 → 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 +32 -28
- package/package/components/button/button-group.svelte +16 -6
- package/package/components/button/button-group.svelte.d.ts +23 -23
- package/package/components/button/button.svelte +41 -136
- package/package/components/button/button.svelte.d.ts +5 -146
- package/package/components/button/select-button-group.svelte +31 -37
- package/package/components/button/select-button-group.svelte.d.ts +76 -34
- package/package/components/button/select-button.svelte +19 -62
- package/package/components/button/select-button.svelte.d.ts +17 -73
- package/package/components/button/split-button.svelte +37 -47
- package/package/components/button/split-button.svelte.d.ts +40 -47
- package/package/components/calendar/calendar.svelte +80 -55
- package/package/components/calendar/calendar.svelte.d.ts +13 -10
- package/package/components/checkbox/checkbox-group.svelte +23 -20
- package/package/components/checkbox/checkbox-group.svelte.d.ts +49 -27
- package/package/components/checkbox/checkbox.svelte +57 -67
- package/package/components/checkbox/checkbox.svelte.d.ts +67 -55
- package/package/components/dialog/alert-dialog.svelte +9 -36
- package/package/components/dialog/alert-dialog.svelte.d.ts +5 -44
- package/package/components/dialog/confirmation-dialog.svelte +9 -41
- package/package/components/dialog/confirmation-dialog.svelte.d.ts +5 -46
- package/package/components/dialog/dialog.svelte +60 -105
- package/package/components/dialog/dialog.svelte.d.ts +5 -102
- package/package/components/dialog/prompt-dialog.svelte +32 -61
- package/package/components/dialog/prompt-dialog.svelte.d.ts +38 -62
- package/package/components/disclosure/disclosure.svelte +39 -34
- package/package/components/disclosure/disclosure.svelte.d.ts +74 -56
- package/package/components/divider/divider.svelte +18 -14
- package/package/components/divider/divider.svelte.d.ts +31 -10
- package/package/components/divider/spacer.svelte +13 -8
- package/package/components/divider/spacer.svelte.d.ts +20 -9
- package/package/components/drawer/drawer.svelte +63 -76
- package/package/components/drawer/drawer.svelte.d.ts +102 -84
- package/package/components/grid/grid-body.svelte +15 -10
- package/package/components/grid/grid-body.svelte.d.ts +30 -24
- package/package/components/grid/grid-cell.svelte +16 -6
- package/package/components/grid/grid-cell.svelte.d.ts +23 -23
- package/package/components/grid/grid-col-header.svelte +16 -6
- package/package/components/grid/grid-col-header.svelte.d.ts +23 -23
- package/package/components/grid/grid-foot.svelte +16 -6
- package/package/components/grid/grid-foot.svelte.d.ts +23 -23
- package/package/components/grid/grid-head.svelte +16 -6
- package/package/components/grid/grid-head.svelte.d.ts +23 -23
- package/package/components/grid/grid-row-header.svelte +16 -6
- package/package/components/grid/grid-row-header.svelte.d.ts +23 -23
- package/package/components/grid/grid-row.svelte +19 -23
- package/package/components/grid/grid-row.svelte.d.ts +48 -38
- package/package/components/grid/grid.svelte +26 -25
- package/package/components/grid/grid.svelte.d.ts +56 -32
- package/package/components/icon/icon.svelte +14 -9
- package/package/components/icon/icon.svelte.d.ts +20 -9
- package/package/components/listbox/listbox.svelte +46 -52
- package/package/components/listbox/listbox.svelte.d.ts +102 -40
- package/package/components/listbox/option-group.svelte +23 -19
- package/package/components/listbox/option-group.svelte.d.ts +49 -27
- package/package/components/listbox/option.svelte +44 -57
- package/package/components/listbox/option.svelte.d.ts +54 -84
- package/package/components/menu/menu-button.svelte +42 -63
- package/package/components/menu/menu-button.svelte.d.ts +18 -72
- package/package/components/menu/menu-item-checkbox.svelte +29 -41
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +5 -44
- package/package/components/menu/menu-item-group.svelte +22 -19
- package/package/components/menu/menu-item-group.svelte.d.ts +41 -27
- package/package/components/menu/menu-item-radio.svelte +29 -41
- package/package/components/menu/menu-item-radio.svelte.d.ts +5 -44
- package/package/components/menu/menu-item.svelte +66 -75
- package/package/components/menu/menu-item.svelte.d.ts +5 -80
- package/package/components/menu/menu.svelte +25 -22
- package/package/components/menu/menu.svelte.d.ts +50 -30
- package/package/components/radio/radio-group.svelte +36 -42
- package/package/components/radio/radio-group.svelte.d.ts +85 -35
- package/package/components/radio/radio.svelte +45 -48
- package/package/components/radio/radio.svelte.d.ts +96 -42
- package/package/components/select/combobox.svelte +76 -101
- package/package/components/select/combobox.svelte.d.ts +5 -56
- package/package/components/select/select-tags.svelte +48 -59
- package/package/components/select/select-tags.svelte.d.ts +109 -28
- package/package/components/select/select.svelte +18 -37
- package/package/components/select/select.svelte.d.ts +5 -40
- package/package/components/slider/slider.svelte +71 -68
- package/package/components/slider/slider.svelte.d.ts +142 -31
- package/package/components/switch/switch.svelte +36 -46
- package/package/components/switch/switch.svelte.d.ts +83 -37
- package/package/components/table/table-body.svelte +15 -11
- package/package/components/table/table-body.svelte.d.ts +30 -24
- package/package/components/table/table-cell.svelte +16 -6
- package/package/components/table/table-cell.svelte.d.ts +23 -23
- package/package/components/table/table-col-header.svelte +16 -6
- package/package/components/table/table-col-header.svelte.d.ts +23 -23
- package/package/components/table/table-foot.svelte +16 -6
- package/package/components/table/table-foot.svelte.d.ts +23 -23
- package/package/components/table/table-head.svelte +16 -6
- package/package/components/table/table-head.svelte.d.ts +23 -23
- package/package/components/table/table-row-header.svelte +16 -6
- package/package/components/table/table-row-header.svelte.d.ts +23 -23
- package/package/components/table/table-row.svelte +16 -6
- package/package/components/table/table-row.svelte.d.ts +23 -23
- package/package/components/table/table.svelte +16 -6
- package/package/components/table/table.svelte.d.ts +23 -23
- package/package/components/tabs/tab-box.svelte +16 -9
- package/package/components/tabs/tab-box.svelte.d.ts +32 -22
- package/package/components/tabs/tab-list.svelte +36 -35
- package/package/components/tabs/tab-list.svelte.d.ts +65 -33
- package/package/components/tabs/tab-panel.svelte +16 -6
- package/package/components/tabs/tab-panel.svelte.d.ts +23 -23
- package/package/components/tabs/tab-panels.svelte +16 -6
- package/package/components/tabs/tab-panels.svelte.d.ts +23 -21
- package/package/components/tabs/tab.svelte +28 -25
- package/package/components/tabs/tab.svelte.d.ts +17 -63
- package/package/components/text-editor/lexical-root.svelte +38 -32
- package/package/components/text-editor/lexical-root.svelte.d.ts +74 -13
- package/package/components/text-editor/text-editor.svelte +63 -79
- package/package/components/text-editor/text-editor.svelte.d.ts +97 -20
- package/package/components/text-editor/toolbar/editor-toolbar.svelte +41 -24
- package/package/components/text-editor/toolbar/editor-toolbar.svelte.d.ts +32 -7
- package/package/components/text-editor/toolbar/format-text-button.svelte +15 -5
- package/package/components/text-editor/toolbar/format-text-button.svelte.d.ts +13 -6
- package/package/components/text-editor/toolbar/insert-link-button.svelte +18 -16
- package/package/components/text-editor/toolbar/insert-link-button.svelte.d.ts +4 -8
- 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 +13 -6
- package/package/components/text-field/number-input.svelte +63 -81
- package/package/components/text-field/number-input.svelte.d.ts +48 -55
- package/package/components/text-field/password-input.svelte +38 -57
- package/package/components/text-field/password-input.svelte.d.ts +16 -45
- package/package/components/text-field/search-bar.svelte +45 -62
- package/package/components/text-field/search-bar.svelte.d.ts +25 -66
- package/package/components/text-field/text-area.svelte +38 -54
- package/package/components/text-field/text-area.svelte.d.ts +100 -35
- package/package/components/text-field/text-input.svelte +30 -86
- package/package/components/text-field/text-input.svelte.d.ts +4 -78
- package/package/components/toast/toast.svelte +36 -30
- package/package/components/toast/toast.svelte.d.ts +50 -28
- package/package/components/toolbar/toolbar.svelte +25 -25
- package/package/components/toolbar/toolbar.svelte.d.ts +57 -29
- package/package/components/util/app-shell.svelte +22 -10
- package/package/components/util/app-shell.svelte.d.ts +25 -29
- package/package/components/util/group.svelte +20 -15
- package/package/components/util/group.svelte.d.ts +40 -26
- package/package/components/util/modal.svelte +89 -105
- package/package/components/util/modal.svelte.d.ts +6 -71
- package/package/components/util/placeholder.svelte +21 -0
- package/package/components/util/{portal.svelte.d.ts → placeholder.svelte.d.ts} +17 -25
- package/package/components/util/popup.svelte +65 -62
- package/package/components/util/popup.svelte.d.ts +89 -77
- 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 +11 -18
- package/package/components/util/portal.svelte +0 -36
- /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
|
@@ -8,58 +8,46 @@
|
|
|
8
8
|
import MenuItem from './menu-item.svelte';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* @type {import('../../typedefs').ButtonProps & import('../../typedefs').MenuItemProps &
|
|
12
|
+
* import('../../typedefs').CommonEventHandlers & Record<string, any>}
|
|
13
13
|
*/
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* Whether to mark the widget checked.
|
|
28
|
-
* @type {boolean}
|
|
29
|
-
*/
|
|
30
|
-
export let checked = false;
|
|
31
|
-
/**
|
|
32
|
-
* Text label displayed on the item.
|
|
33
|
-
* @type {string | undefined}
|
|
34
|
-
*/
|
|
35
|
-
export let label = '';
|
|
36
|
-
/**
|
|
37
|
-
* Name of `<Icon>` displayed before the label.
|
|
38
|
-
*/
|
|
39
|
-
export let iconName = '';
|
|
40
|
-
/**
|
|
41
|
-
* ARIA label of `<Icon>` displayed before the label.
|
|
42
|
-
*/
|
|
43
|
-
export let iconLabel = '';
|
|
14
|
+
let {
|
|
15
|
+
/* eslint-disable prefer-const */
|
|
16
|
+
checked = $bindable(false),
|
|
17
|
+
class: className,
|
|
18
|
+
hidden = false,
|
|
19
|
+
disabled = false,
|
|
20
|
+
label = '',
|
|
21
|
+
children: _children,
|
|
22
|
+
startIcon: _startIcon,
|
|
23
|
+
onChange,
|
|
24
|
+
...restProps
|
|
25
|
+
/* eslint-enable prefer-const */
|
|
26
|
+
} = $props();
|
|
44
27
|
</script>
|
|
45
28
|
|
|
46
29
|
<MenuItem
|
|
30
|
+
{...restProps}
|
|
47
31
|
role="menuitemcheckbox"
|
|
48
32
|
class="sui menu-item-checkbox {className}"
|
|
49
33
|
{label}
|
|
50
34
|
{hidden}
|
|
51
35
|
{disabled}
|
|
52
36
|
aria-checked={checked}
|
|
53
|
-
{
|
|
54
|
-
|
|
55
|
-
{...$$restProps}
|
|
56
|
-
on:click
|
|
57
|
-
on:select
|
|
58
|
-
on:change
|
|
59
|
-
on:change={(event) => {
|
|
37
|
+
onChange={(event) => {
|
|
38
|
+
onChange?.(event);
|
|
60
39
|
checked = event.detail.checked;
|
|
61
40
|
}}
|
|
62
41
|
>
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
{#snippet startIcon()}
|
|
43
|
+
{@render _startIcon?.()}
|
|
44
|
+
{/snippet}
|
|
45
|
+
{#snippet children()}
|
|
46
|
+
{@render _children?.()}
|
|
47
|
+
{/snippet}
|
|
48
|
+
{#snippet endIcon()}
|
|
49
|
+
{#if checked}
|
|
50
|
+
<Icon name="check" />
|
|
51
|
+
{/if}
|
|
52
|
+
{/snippet}
|
|
65
53
|
</MenuItem>
|
|
@@ -1,55 +1,16 @@
|
|
|
1
1
|
export default MenuItemCheckbox;
|
|
2
|
-
type MenuItemCheckbox = SvelteComponent
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
class?: string | undefined;
|
|
5
|
-
disabled?: boolean | undefined;
|
|
6
|
-
label?: string | undefined;
|
|
7
|
-
checked?: boolean | undefined;
|
|
8
|
-
hidden?: boolean | undefined;
|
|
9
|
-
iconName?: string | undefined;
|
|
10
|
-
iconLabel?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
default: {};
|
|
13
|
-
}>, {
|
|
14
|
-
click: MouseEvent;
|
|
15
|
-
select: CustomEvent<any>;
|
|
16
|
-
change: CustomEvent<any>;
|
|
17
|
-
} & {
|
|
2
|
+
type MenuItemCheckbox = SvelteComponent<ButtonProps & MenuItemProps & KeyboardEventHandlers & MouseEventHandlers & FocusEventHandlers & DragEventHandlers & Record<string, any>, {
|
|
18
3
|
[evt: string]: CustomEvent<any>;
|
|
19
|
-
}, {
|
|
20
|
-
|
|
21
|
-
}> & {
|
|
22
|
-
$$bindings?: string | undefined;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "checked" | undefined;
|
|
23
6
|
};
|
|
24
7
|
/**
|
|
25
8
|
* A menu item widget with a checkbox.
|
|
26
9
|
* @see https://w3c.github.io/aria/#menuitemcheckbox
|
|
27
10
|
*/
|
|
28
|
-
declare const MenuItemCheckbox: $$__sveltets_2_IsomorphicComponent
|
|
29
|
-
[x: string]: any;
|
|
30
|
-
class?: string | undefined;
|
|
31
|
-
disabled?: boolean | undefined;
|
|
32
|
-
label?: string | undefined;
|
|
33
|
-
checked?: boolean | undefined;
|
|
34
|
-
hidden?: boolean | undefined;
|
|
35
|
-
iconName?: string | undefined;
|
|
36
|
-
iconLabel?: string | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
default: {};
|
|
39
|
-
}>, {
|
|
40
|
-
click: MouseEvent;
|
|
41
|
-
select: CustomEvent<any>;
|
|
42
|
-
change: CustomEvent<any>;
|
|
43
|
-
} & {
|
|
11
|
+
declare const MenuItemCheckbox: $$__sveltets_2_IsomorphicComponent<import("../../typedefs").ButtonProps & import("../../typedefs").MenuItemProps & import("../../typedefs").KeyboardEventHandlers & import("../../typedefs").MouseEventHandlers & import("../../typedefs").FocusEventHandlers & import("../../typedefs").DragEventHandlers & Record<string, any>, {
|
|
44
12
|
[evt: string]: CustomEvent<any>;
|
|
45
|
-
}, {
|
|
46
|
-
default: {};
|
|
47
|
-
}, {}, string>;
|
|
48
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
49
|
-
default: any;
|
|
50
|
-
} ? Props extends Record<string, never> ? any : {
|
|
51
|
-
children?: any;
|
|
52
|
-
} : {});
|
|
13
|
+
}, {}, {}, "checked">;
|
|
53
14
|
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> {
|
|
54
15
|
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
55
16
|
$$bindings?: Bindings;
|
|
@@ -6,45 +6,48 @@
|
|
|
6
6
|
import { generateElementId } from '@sveltia/utils/element';
|
|
7
7
|
|
|
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. An alias of the `aria-hidden`
|
|
12
|
+
* attribute.
|
|
13
|
+
* @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
|
|
14
|
+
* attribute.
|
|
15
|
+
* @property {string} [title] - Text label displayed above the group items.
|
|
11
16
|
*/
|
|
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;
|
|
17
|
+
|
|
24
18
|
/**
|
|
25
|
-
*
|
|
19
|
+
* @type {import('../../typedefs').CommonEventHandlers & Props & Record<string, any>}
|
|
26
20
|
*/
|
|
27
|
-
|
|
21
|
+
let {
|
|
22
|
+
/* eslint-disable prefer-const */
|
|
23
|
+
class: className,
|
|
24
|
+
hidden = false,
|
|
25
|
+
disabled = false,
|
|
26
|
+
title = '',
|
|
27
|
+
children,
|
|
28
|
+
...restProps
|
|
29
|
+
/* eslint-enable prefer-const */
|
|
30
|
+
} = $props();
|
|
28
31
|
|
|
29
32
|
const id = generateElementId('group');
|
|
30
33
|
</script>
|
|
31
34
|
|
|
32
35
|
<div
|
|
36
|
+
{...restProps}
|
|
33
37
|
role="group"
|
|
34
38
|
{id}
|
|
35
39
|
class="sui menu-item-group {className}"
|
|
36
|
-
|
|
40
|
+
{hidden}
|
|
37
41
|
aria-hidden={hidden}
|
|
38
42
|
aria-disabled={disabled}
|
|
39
43
|
aria-labelledby={title ? `${id}-title` : undefined}
|
|
40
44
|
aria-roledescription="menu item group"
|
|
41
|
-
{...$$restProps}
|
|
42
45
|
>
|
|
43
46
|
{#if title}
|
|
44
47
|
<div role="none" class="title" id="{id}-title">{title}</div>
|
|
45
48
|
{/if}
|
|
46
49
|
<div role="none" class="inner" inert={disabled}>
|
|
47
|
-
|
|
50
|
+
{@render children?.()}
|
|
48
51
|
</div>
|
|
49
52
|
</div>
|
|
50
53
|
|
|
@@ -1,38 +1,52 @@
|
|
|
1
1
|
export default MenuItemGroup;
|
|
2
|
-
type MenuItemGroup = SvelteComponent
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
class?: string | undefined;
|
|
5
|
-
disabled?: boolean | undefined;
|
|
6
|
-
title?: string | undefined;
|
|
7
|
-
hidden?: boolean | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}>, {
|
|
2
|
+
type MenuItemGroup = SvelteComponent<KeyboardEventHandlers & MouseEventHandlers & FocusEventHandlers & DragEventHandlers & Props & Record<string, any>, {
|
|
11
3
|
[evt: string]: CustomEvent<any>;
|
|
12
|
-
}, {
|
|
13
|
-
|
|
14
|
-
}> & {
|
|
15
|
-
$$bindings?: string | undefined;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "" | undefined;
|
|
16
6
|
};
|
|
17
7
|
/** A menu item group. */
|
|
18
|
-
declare const MenuItemGroup: $$__sveltets_2_IsomorphicComponent
|
|
19
|
-
|
|
8
|
+
declare const MenuItemGroup: $$__sveltets_2_IsomorphicComponent<import("../../typedefs").KeyboardEventHandlers & import("../../typedefs").MouseEventHandlers & import("../../typedefs").FocusEventHandlers & import("../../typedefs").DragEventHandlers & {
|
|
9
|
+
/**
|
|
10
|
+
* - The `class` attribute on the wrapper element.
|
|
11
|
+
*/
|
|
20
12
|
class?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* - Whether to hide the widget. An alias of the `aria-hidden`
|
|
15
|
+
* attribute.
|
|
16
|
+
*/
|
|
17
|
+
hidden?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
20
|
+
* attribute.
|
|
21
|
+
*/
|
|
21
22
|
disabled?: boolean | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* - Text label displayed above the group items.
|
|
25
|
+
*/
|
|
22
26
|
title?: string | undefined;
|
|
23
|
-
|
|
24
|
-
}, {
|
|
25
|
-
default: {};
|
|
26
|
-
}>, {
|
|
27
|
+
} & Record<string, any>, {
|
|
27
28
|
[evt: string]: CustomEvent<any>;
|
|
28
|
-
}, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
}, {}, {}, "">;
|
|
30
|
+
type Props = {
|
|
31
|
+
/**
|
|
32
|
+
* - The `class` attribute on the wrapper element.
|
|
33
|
+
*/
|
|
34
|
+
class?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* - Whether to hide the widget. An alias of the `aria-hidden`
|
|
37
|
+
* attribute.
|
|
38
|
+
*/
|
|
39
|
+
hidden?: boolean | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
42
|
+
* attribute.
|
|
43
|
+
*/
|
|
44
|
+
disabled?: boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* - Text label displayed above the group items.
|
|
47
|
+
*/
|
|
48
|
+
title?: string | undefined;
|
|
49
|
+
};
|
|
36
50
|
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
51
|
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
38
52
|
$$bindings?: Bindings;
|
|
@@ -9,58 +9,46 @@
|
|
|
9
9
|
import MenuItem from './menu-item.svelte';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* @type {import('../../typedefs').ButtonProps & import('../../typedefs').MenuItemProps &
|
|
13
|
+
* import('../../typedefs').CommonEventHandlers & Record<string, any>}
|
|
14
14
|
*/
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* Whether to check the widget. An alias of the `aria-checked` attribute.
|
|
29
|
-
* @type {boolean}
|
|
30
|
-
*/
|
|
31
|
-
export let checked = false;
|
|
32
|
-
/**
|
|
33
|
-
* Text label displayed on the item.
|
|
34
|
-
* @type {string | undefined}
|
|
35
|
-
*/
|
|
36
|
-
export let label = '';
|
|
37
|
-
/**
|
|
38
|
-
* Name of `<Icon>` displayed before the label.
|
|
39
|
-
*/
|
|
40
|
-
export let iconName = '';
|
|
41
|
-
/**
|
|
42
|
-
* ARIA label of `<Icon>` displayed before the label.
|
|
43
|
-
*/
|
|
44
|
-
export let iconLabel = '';
|
|
15
|
+
let {
|
|
16
|
+
/* eslint-disable prefer-const */
|
|
17
|
+
checked = $bindable(false),
|
|
18
|
+
class: className,
|
|
19
|
+
hidden = false,
|
|
20
|
+
disabled = false,
|
|
21
|
+
label = '',
|
|
22
|
+
children: _children,
|
|
23
|
+
startIcon: _startIcon,
|
|
24
|
+
onChange,
|
|
25
|
+
...restProps
|
|
26
|
+
/* eslint-enable prefer-const */
|
|
27
|
+
} = $props();
|
|
45
28
|
</script>
|
|
46
29
|
|
|
47
30
|
<MenuItem
|
|
31
|
+
{...restProps}
|
|
48
32
|
role="menuitemradio"
|
|
49
33
|
class="sui menu-item-radio {className}"
|
|
50
34
|
{label}
|
|
51
35
|
{hidden}
|
|
52
36
|
{disabled}
|
|
53
37
|
aria-checked={checked}
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
{...$$restProps}
|
|
57
|
-
on:click
|
|
58
|
-
on:select
|
|
59
|
-
on:change
|
|
60
|
-
on:change={(event) => {
|
|
38
|
+
onChange={(event) => {
|
|
39
|
+
onChange?.(event);
|
|
61
40
|
checked = event.detail.checked;
|
|
62
41
|
}}
|
|
63
42
|
>
|
|
64
|
-
|
|
65
|
-
|
|
43
|
+
{#snippet startIcon()}
|
|
44
|
+
{@render _startIcon?.()}
|
|
45
|
+
{/snippet}
|
|
46
|
+
{#snippet children()}
|
|
47
|
+
{@render _children?.()}
|
|
48
|
+
{/snippet}
|
|
49
|
+
{#snippet endIcon()}
|
|
50
|
+
{#if checked}
|
|
51
|
+
<Icon name="check" />
|
|
52
|
+
{/if}
|
|
53
|
+
{/snippet}
|
|
66
54
|
</MenuItem>
|
|
@@ -1,56 +1,17 @@
|
|
|
1
1
|
export default MenuItemRadio;
|
|
2
|
-
type MenuItemRadio = SvelteComponent
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
class?: string | undefined;
|
|
5
|
-
disabled?: boolean | undefined;
|
|
6
|
-
label?: string | undefined;
|
|
7
|
-
checked?: boolean | undefined;
|
|
8
|
-
hidden?: boolean | undefined;
|
|
9
|
-
iconName?: string | undefined;
|
|
10
|
-
iconLabel?: string | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
default: {};
|
|
13
|
-
}>, {
|
|
14
|
-
click: MouseEvent;
|
|
15
|
-
select: CustomEvent<any>;
|
|
16
|
-
change: CustomEvent<any>;
|
|
17
|
-
} & {
|
|
2
|
+
type MenuItemRadio = SvelteComponent<ButtonProps & MenuItemProps & KeyboardEventHandlers & MouseEventHandlers & FocusEventHandlers & DragEventHandlers & Record<string, any>, {
|
|
18
3
|
[evt: string]: CustomEvent<any>;
|
|
19
|
-
}, {
|
|
20
|
-
|
|
21
|
-
}> & {
|
|
22
|
-
$$bindings?: string | undefined;
|
|
4
|
+
}, {}> & {
|
|
5
|
+
$$bindings?: "checked" | undefined;
|
|
23
6
|
};
|
|
24
7
|
/**
|
|
25
8
|
* A menu item widget with a radio. Only one item can be selected within the parent `<Menu>` or
|
|
26
9
|
* `<MenuItemGroup>` component.
|
|
27
10
|
* @see https://w3c.github.io/aria/#menuitemradio
|
|
28
11
|
*/
|
|
29
|
-
declare const MenuItemRadio: $$__sveltets_2_IsomorphicComponent
|
|
30
|
-
[x: string]: any;
|
|
31
|
-
class?: string | undefined;
|
|
32
|
-
disabled?: boolean | undefined;
|
|
33
|
-
label?: string | undefined;
|
|
34
|
-
checked?: boolean | undefined;
|
|
35
|
-
hidden?: boolean | undefined;
|
|
36
|
-
iconName?: string | undefined;
|
|
37
|
-
iconLabel?: string | undefined;
|
|
38
|
-
}, {
|
|
39
|
-
default: {};
|
|
40
|
-
}>, {
|
|
41
|
-
click: MouseEvent;
|
|
42
|
-
select: CustomEvent<any>;
|
|
43
|
-
change: CustomEvent<any>;
|
|
44
|
-
} & {
|
|
12
|
+
declare const MenuItemRadio: $$__sveltets_2_IsomorphicComponent<import("../../typedefs").ButtonProps & import("../../typedefs").MenuItemProps & import("../../typedefs").KeyboardEventHandlers & import("../../typedefs").MouseEventHandlers & import("../../typedefs").FocusEventHandlers & import("../../typedefs").DragEventHandlers & Record<string, any>, {
|
|
45
13
|
[evt: string]: CustomEvent<any>;
|
|
46
|
-
}, {
|
|
47
|
-
default: {};
|
|
48
|
-
}, {}, string>;
|
|
49
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
50
|
-
default: any;
|
|
51
|
-
} ? Props extends Record<string, never> ? any : {
|
|
52
|
-
children?: any;
|
|
53
|
-
} : {});
|
|
14
|
+
}, {}, {}, "checked">;
|
|
54
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> {
|
|
55
16
|
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
56
17
|
$$bindings?: Bindings;
|
|
@@ -4,104 +4,95 @@
|
|
|
4
4
|
@see https://w3c.github.io/aria/#menuitem
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
|
-
import { writable } from 'svelte/store';
|
|
8
7
|
import Button from '../button/button.svelte';
|
|
9
8
|
import Icon from '../icon/icon.svelte';
|
|
10
|
-
import Menu from './menu.svelte';
|
|
11
9
|
import Popup from '../util/popup.svelte';
|
|
10
|
+
import Menu from './menu.svelte';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
let className = '';
|
|
18
|
-
export { className as class };
|
|
19
|
-
/**
|
|
20
|
-
* The `role` attribute on the `<button>` element.
|
|
21
|
-
* @type {'menuitem' | 'menuitemcheckbox' | 'menuitemradio'}
|
|
22
|
-
*/
|
|
23
|
-
export let role = 'menuitem';
|
|
24
|
-
/**
|
|
25
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
26
|
-
* @type {boolean | undefined}
|
|
27
|
-
*/
|
|
28
|
-
export let hidden = undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
31
|
-
* @type {boolean}
|
|
13
|
+
* @type {import('../../typedefs').ButtonProps & import('../../typedefs').MenuItemProps &
|
|
14
|
+
* import('../../typedefs').CommonEventHandlers & Record<string, any>}
|
|
32
15
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
16
|
+
let {
|
|
17
|
+
/* eslint-disable prefer-const */
|
|
18
|
+
class: className,
|
|
19
|
+
role = 'menuitem',
|
|
20
|
+
hidden = false,
|
|
21
|
+
disabled = false,
|
|
22
|
+
label = '',
|
|
23
|
+
children: _children,
|
|
24
|
+
startIcon: _startIcon,
|
|
25
|
+
endIcon: _endIcon,
|
|
26
|
+
chevronIcon,
|
|
27
|
+
items,
|
|
28
|
+
onChange,
|
|
29
|
+
onSelect,
|
|
30
|
+
...restProps
|
|
31
|
+
/* eslint-enable prefer-const */
|
|
32
|
+
} = $props();
|
|
33
|
+
|
|
34
|
+
let isPopupOpen = $state(false);
|
|
35
|
+
|
|
43
36
|
/**
|
|
44
|
-
*
|
|
37
|
+
* Reference to the `<button>` element.
|
|
38
|
+
* @type {HTMLButtonElement | undefined}
|
|
45
39
|
*/
|
|
46
|
-
|
|
40
|
+
let buttonElement = $state();
|
|
47
41
|
|
|
48
|
-
|
|
49
|
-
let buttonComponent;
|
|
50
|
-
let isPopupOpen = writable(false);
|
|
51
|
-
|
|
52
|
-
$: hasChildren = role === 'menuitem' && $$slots.children;
|
|
42
|
+
const hasItems = $derived(role === 'menuitem' && !!items);
|
|
53
43
|
</script>
|
|
54
44
|
|
|
55
|
-
<div role="none" class="sui menuitem {className}"
|
|
45
|
+
<div role="none" class="sui menuitem {className}" {hidden}>
|
|
56
46
|
<Button
|
|
47
|
+
bind:element={buttonElement}
|
|
48
|
+
{...restProps}
|
|
57
49
|
{role}
|
|
58
50
|
{hidden}
|
|
59
51
|
{disabled}
|
|
60
|
-
aria-haspopup={
|
|
61
|
-
aria-expanded={
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
on:mouseenter={() => {
|
|
66
|
-
if (hasChildren) {
|
|
67
|
-
$isPopupOpen = true;
|
|
52
|
+
aria-haspopup={hasItems ? 'menu' : undefined}
|
|
53
|
+
aria-expanded={hasItems ? isPopupOpen : undefined}
|
|
54
|
+
onmouseenter={() => {
|
|
55
|
+
if (hasItems) {
|
|
56
|
+
isPopupOpen = true;
|
|
68
57
|
}
|
|
69
58
|
}}
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
59
|
+
onmouseleave={() => {
|
|
60
|
+
if (hasItems) {
|
|
61
|
+
isPopupOpen = false;
|
|
73
62
|
}
|
|
74
63
|
}}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
on:select
|
|
78
|
-
on:change
|
|
64
|
+
{onChange}
|
|
65
|
+
{onSelect}
|
|
79
66
|
>
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
{
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
{#snippet startIcon()}
|
|
68
|
+
{@render _startIcon?.()}
|
|
69
|
+
{/snippet}
|
|
70
|
+
{#snippet children()}
|
|
71
|
+
<div role="none" class="content" class:label={!!label}>
|
|
72
|
+
{#if label}
|
|
73
|
+
{label}
|
|
74
|
+
{:else}
|
|
75
|
+
{@render _children?.()}
|
|
76
|
+
{/if}
|
|
77
|
+
</div>
|
|
78
|
+
{#if hasItems}
|
|
79
|
+
<span role="none" class="icon-outer">
|
|
80
|
+
{#if chevronIcon}
|
|
81
|
+
{@render chevronIcon()}
|
|
82
|
+
{:else}
|
|
83
|
+
<Icon name="chevron_right" />
|
|
84
|
+
{/if}
|
|
85
|
+
</span>
|
|
90
86
|
{/if}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<slot name="chevron-icon">
|
|
96
|
-
<Icon name="chevron_right" />
|
|
97
|
-
</slot>
|
|
98
|
-
</span>
|
|
99
|
-
{/if}
|
|
87
|
+
{/snippet}
|
|
88
|
+
{#snippet endIcon()}
|
|
89
|
+
{@render _endIcon?.()}
|
|
90
|
+
{/snippet}
|
|
100
91
|
</Button>
|
|
101
|
-
{#if
|
|
102
|
-
<Popup anchor={
|
|
92
|
+
{#if hasItems}
|
|
93
|
+
<Popup anchor={buttonElement} position="right-top" bind:open={isPopupOpen}>
|
|
103
94
|
<Menu>
|
|
104
|
-
|
|
95
|
+
{@render items?.()}
|
|
105
96
|
</Menu>
|
|
106
97
|
</Popup>
|
|
107
98
|
{/if}
|