@sveltia/ui 0.16.0 → 0.17.1
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 +28 -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 +27 -22
- package/package/components/menu/menu.svelte.d.ts +50 -30
- package/package/components/radio/radio-group.svelte +38 -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 +28 -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 +12 -19
- 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
|
@@ -9,8 +9,19 @@
|
|
|
9
9
|
import Spacer from '../divider/spacer.svelte';
|
|
10
10
|
import Icon from '../icon/icon.svelte';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} Props
|
|
14
|
+
* @property {string | undefined} [value] - Date.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {Props & Record<string, any>}
|
|
19
|
+
*/
|
|
20
|
+
let {
|
|
21
|
+
/* eslint-disable prefer-const */
|
|
22
|
+
value = $bindable(undefined),
|
|
23
|
+
/* eslint-enable prefer-const */
|
|
24
|
+
} = $props();
|
|
14
25
|
|
|
15
26
|
/** @type {{ day: Date }[]} */
|
|
16
27
|
const dayList = [];
|
|
@@ -18,9 +29,13 @@
|
|
|
18
29
|
const weeks = [];
|
|
19
30
|
const now = new Date();
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
const date = $derived(value ? new Date(value) : now);
|
|
33
|
+
const firstDayOfMonth = $derived(new Date(date.getUTCFullYear(), date.getUTCMonth(), 1));
|
|
34
|
+
let firstDay = $state();
|
|
35
|
+
|
|
36
|
+
$effect(() => {
|
|
37
|
+
firstDay = new Date(firstDayOfMonth);
|
|
38
|
+
});
|
|
24
39
|
|
|
25
40
|
/**
|
|
26
41
|
* Populate {@link weeks} as per the current {@link firstDay}.
|
|
@@ -41,11 +56,11 @@
|
|
|
41
56
|
}
|
|
42
57
|
};
|
|
43
58
|
|
|
44
|
-
|
|
59
|
+
$effect(() => {
|
|
45
60
|
if (firstDay) {
|
|
46
61
|
getWeeks();
|
|
47
62
|
}
|
|
48
|
-
}
|
|
63
|
+
});
|
|
49
64
|
</script>
|
|
50
65
|
|
|
51
66
|
<div role="group">
|
|
@@ -53,57 +68,67 @@
|
|
|
53
68
|
<div role="none" class="header">
|
|
54
69
|
<Button
|
|
55
70
|
variant="ghost"
|
|
56
|
-
label={firstDay
|
|
71
|
+
label={firstDay?.toLocaleDateString('en', { year: 'numeric', month: 'short' })}
|
|
57
72
|
aria-haspopup="dialog"
|
|
58
73
|
>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
{#snippet endIcon()}
|
|
75
|
+
<Icon name="arrow_drop_down" class="small-arrow" />
|
|
76
|
+
{/snippet}
|
|
77
|
+
{#snippet popup()}
|
|
78
|
+
<div
|
|
79
|
+
role="none"
|
|
80
|
+
class="popup-inner"
|
|
81
|
+
onclick={(event) => {
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<div role="group" aria-label={$_('_sui.calendar.year')}>
|
|
86
|
+
<div role="none" class="header">
|
|
87
|
+
<Button
|
|
88
|
+
aria-label={$_('_sui.calendar.previous_decade')}
|
|
89
|
+
onclick={() => {
|
|
90
|
+
//
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
<Icon name="chevron_left" />
|
|
94
|
+
</Button>
|
|
95
|
+
<Button
|
|
96
|
+
aria-label={$_('_sui.calendar.next_decade')}
|
|
97
|
+
onclick={() => {
|
|
98
|
+
//
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
<Icon name="chevron_right" />
|
|
102
|
+
</Button>
|
|
103
|
+
</div>
|
|
104
|
+
<div role="none" class="grid">
|
|
105
|
+
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as year}
|
|
106
|
+
<div role="none">
|
|
107
|
+
<Button>202{year}</Button>
|
|
108
|
+
</div>
|
|
109
|
+
{/each}
|
|
110
|
+
</div>
|
|
79
111
|
</div>
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
112
|
+
<Divider orientation="vertical" />
|
|
113
|
+
<div role="group" aria-label={$_('_sui.calendar.month')}>
|
|
114
|
+
<div role="none" class="grid">
|
|
115
|
+
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as month}
|
|
116
|
+
<div role="none">
|
|
117
|
+
<Button>
|
|
118
|
+
{new Date(date.getUTCFullYear(), month, 10).toLocaleDateString('en', {
|
|
119
|
+
month: 'short',
|
|
120
|
+
})}
|
|
121
|
+
</Button>
|
|
122
|
+
</div>
|
|
123
|
+
{/each}
|
|
124
|
+
</div>
|
|
86
125
|
</div>
|
|
87
126
|
</div>
|
|
88
|
-
|
|
89
|
-
<div role="group" aria-label={$_('_sui.calendar.month')}>
|
|
90
|
-
<div role="none" class="grid">
|
|
91
|
-
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as month}
|
|
92
|
-
<div role="none">
|
|
93
|
-
<Button>
|
|
94
|
-
{new Date(date.getUTCFullYear(), month, 10).toLocaleDateString('en', {
|
|
95
|
-
month: 'short',
|
|
96
|
-
})}
|
|
97
|
-
</Button>
|
|
98
|
-
</div>
|
|
99
|
-
{/each}
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
127
|
+
{/snippet}
|
|
103
128
|
</Button>
|
|
104
129
|
<Button
|
|
105
130
|
aria-label={$_('_sui.calendar.previous_month')}
|
|
106
|
-
|
|
131
|
+
onclick={() => {
|
|
107
132
|
firstDay.setUTCMonth(firstDay.getUTCMonth() - 1);
|
|
108
133
|
firstDay = firstDay;
|
|
109
134
|
}}
|
|
@@ -112,7 +137,7 @@
|
|
|
112
137
|
</Button>
|
|
113
138
|
<Button
|
|
114
139
|
aria-label={$_('_sui.calendar.next_month')}
|
|
115
|
-
|
|
140
|
+
onclick={() => {
|
|
116
141
|
firstDay.setUTCMonth(firstDay.getUTCMonth() + 1);
|
|
117
142
|
firstDay = firstDay;
|
|
118
143
|
}}
|
|
@@ -129,7 +154,7 @@
|
|
|
129
154
|
{#each dayList as { day }}
|
|
130
155
|
<div
|
|
131
156
|
role="none"
|
|
132
|
-
class:other-month={day.getUTCMonth() !== firstDay
|
|
157
|
+
class:other-month={day.getUTCMonth() !== firstDay?.getUTCMonth()}
|
|
133
158
|
class:today={day.getFullYear() === now.getFullYear() &&
|
|
134
159
|
day.getMonth() === now.getMonth() &&
|
|
135
160
|
day.getDate() === now.getDate()}
|
|
@@ -137,7 +162,7 @@
|
|
|
137
162
|
<Button
|
|
138
163
|
role="option"
|
|
139
164
|
aria-selected={false}
|
|
140
|
-
|
|
165
|
+
onclick={() => {
|
|
141
166
|
[value] = day.toJSON().split('T');
|
|
142
167
|
}}
|
|
143
168
|
>
|
|
@@ -148,7 +173,7 @@
|
|
|
148
173
|
</div>
|
|
149
174
|
<div role="none" class="footer">
|
|
150
175
|
<Button
|
|
151
|
-
|
|
176
|
+
onclick={() => {
|
|
152
177
|
value = '';
|
|
153
178
|
}}
|
|
154
179
|
>
|
|
@@ -156,7 +181,7 @@
|
|
|
156
181
|
</Button>
|
|
157
182
|
<Spacer flex={true} />
|
|
158
183
|
<Button
|
|
159
|
-
|
|
184
|
+
onclick={() => {
|
|
160
185
|
[value] = now.toJSON().split('T');
|
|
161
186
|
}}
|
|
162
187
|
>
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
export default Calendar;
|
|
2
|
-
type Calendar = SvelteComponent<{
|
|
3
|
-
value?: string | undefined;
|
|
4
|
-
}, {
|
|
5
|
-
click: MouseEvent;
|
|
6
|
-
} & {
|
|
2
|
+
type Calendar = SvelteComponent<Props & Record<string, any>, {
|
|
7
3
|
[evt: string]: CustomEvent<any>;
|
|
8
4
|
}, {}> & {
|
|
9
|
-
$$bindings?:
|
|
5
|
+
$$bindings?: "value" | undefined;
|
|
10
6
|
};
|
|
11
7
|
/** A calendar (date picker) widget. */
|
|
12
8
|
declare const Calendar: $$__sveltets_2_IsomorphicComponent<{
|
|
9
|
+
/**
|
|
10
|
+
* - Date.
|
|
11
|
+
*/
|
|
13
12
|
value?: string | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
click: MouseEvent;
|
|
16
|
-
} & {
|
|
13
|
+
} & Record<string, any>, {
|
|
17
14
|
[evt: string]: CustomEvent<any>;
|
|
18
|
-
}, {}, {},
|
|
15
|
+
}, {}, {}, "value">;
|
|
16
|
+
type Props = {
|
|
17
|
+
/**
|
|
18
|
+
* - Date.
|
|
19
|
+
*/
|
|
20
|
+
value?: string | undefined;
|
|
21
|
+
};
|
|
19
22
|
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> {
|
|
20
23
|
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
21
24
|
$$bindings?: Bindings;
|
|
@@ -4,39 +4,42 @@
|
|
|
4
4
|
-->
|
|
5
5
|
<script>
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
7
|
+
* @typedef {object} Props
|
|
8
|
+
* @property {string} [class] - The `class` attribute on the wrapper element.
|
|
9
|
+
* @property {boolean} [hidden] - Whether to hide the widget. An alias of the `aria-hidden`
|
|
10
|
+
* attribute.
|
|
11
|
+
* @property {boolean} [disabled] - Whether to disable the widget. An alias of the `aria-disabled`
|
|
12
|
+
* attribute.
|
|
13
|
+
* @property {'horizontal'|'vertical'} [orientation] - Orientation of the widget.
|
|
14
|
+
* @property {import('svelte').Snippet} [children] - Primary slot content.
|
|
9
15
|
*/
|
|
10
|
-
|
|
11
|
-
export { className as class };
|
|
12
|
-
/**
|
|
13
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
14
|
-
* @type {boolean | undefined}
|
|
15
|
-
*/
|
|
16
|
-
export let hidden = undefined;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
19
|
-
* @type {boolean}
|
|
20
|
-
*/
|
|
21
|
-
export let disabled = false;
|
|
16
|
+
|
|
22
17
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @type {('horizontal'|'vertical')}
|
|
18
|
+
* @type {Props & Record<string, any>}
|
|
25
19
|
*/
|
|
26
|
-
|
|
20
|
+
let {
|
|
21
|
+
/* eslint-disable prefer-const */
|
|
22
|
+
class: className,
|
|
23
|
+
hidden = false,
|
|
24
|
+
disabled = false,
|
|
25
|
+
orientation = 'horizontal',
|
|
26
|
+
children,
|
|
27
|
+
...restProps
|
|
28
|
+
/* eslint-enable prefer-const */
|
|
29
|
+
} = $props();
|
|
27
30
|
</script>
|
|
28
31
|
|
|
29
32
|
<div
|
|
33
|
+
{...restProps}
|
|
30
34
|
role="group"
|
|
31
35
|
class="sui checkbox-group {className} {orientation}"
|
|
32
|
-
|
|
36
|
+
{hidden}
|
|
33
37
|
aria-hidden={hidden}
|
|
34
38
|
aria-disabled={disabled}
|
|
35
39
|
aria-roledescription="checkbox group"
|
|
36
|
-
{...$$restProps}
|
|
37
40
|
>
|
|
38
41
|
<div role="none" class="inner" inert={disabled}>
|
|
39
|
-
|
|
42
|
+
{@render children?.()}
|
|
40
43
|
</div>
|
|
41
44
|
</div>
|
|
42
45
|
|
|
@@ -1,38 +1,60 @@
|
|
|
1
1
|
export default CheckboxGroup;
|
|
2
|
-
type CheckboxGroup = SvelteComponent
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
class?: string | undefined;
|
|
5
|
-
disabled?: boolean | undefined;
|
|
6
|
-
hidden?: boolean | undefined;
|
|
7
|
-
orientation?: "vertical" | "horizontal" | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
default: {};
|
|
10
|
-
}>, {
|
|
2
|
+
type CheckboxGroup = SvelteComponent<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
|
/** The layout container of `<Checkbox>`es. */
|
|
18
|
-
declare const CheckboxGroup: $$__sveltets_2_IsomorphicComponent
|
|
19
|
-
|
|
8
|
+
declare const CheckboxGroup: $$__sveltets_2_IsomorphicComponent<{
|
|
9
|
+
/**
|
|
10
|
+
* - The `class` attribute on the wrapper element.
|
|
11
|
+
*/
|
|
20
12
|
class?: string | undefined;
|
|
21
|
-
|
|
13
|
+
/**
|
|
14
|
+
* - Whether to hide the widget. An alias of the `aria-hidden`
|
|
15
|
+
* attribute.
|
|
16
|
+
*/
|
|
22
17
|
hidden?: boolean | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
20
|
+
* attribute.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* - Orientation of the widget.
|
|
25
|
+
*/
|
|
23
26
|
orientation?: "vertical" | "horizontal" | undefined;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* - Primary slot content.
|
|
29
|
+
*/
|
|
30
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
31
|
+
} & Record<string, any>, {
|
|
27
32
|
[evt: string]: CustomEvent<any>;
|
|
28
|
-
}, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
}, {}, {}, "">;
|
|
34
|
+
type Props = {
|
|
35
|
+
/**
|
|
36
|
+
* - The `class` attribute on the wrapper element.
|
|
37
|
+
*/
|
|
38
|
+
class?: string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* - Whether to hide the widget. An alias of the `aria-hidden`
|
|
41
|
+
* attribute.
|
|
42
|
+
*/
|
|
43
|
+
hidden?: boolean | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* - Whether to disable the widget. An alias of the `aria-disabled`
|
|
46
|
+
* attribute.
|
|
47
|
+
*/
|
|
48
|
+
disabled?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* - Orientation of the widget.
|
|
51
|
+
*/
|
|
52
|
+
orientation?: "vertical" | "horizontal" | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* - Primary slot content.
|
|
55
|
+
*/
|
|
56
|
+
children?: import("svelte").Snippet<[]> | undefined;
|
|
57
|
+
};
|
|
36
58
|
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
59
|
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
38
60
|
$$bindings?: Bindings;
|
|
@@ -7,73 +7,56 @@
|
|
|
7
7
|
-->
|
|
8
8
|
<script>
|
|
9
9
|
import { generateElementId } from '@sveltia/utils/element';
|
|
10
|
-
import { createEventDispatcher } from 'svelte';
|
|
11
10
|
import Button from '../button/button.svelte';
|
|
12
11
|
import Icon from '../icon/icon.svelte';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @
|
|
14
|
+
* @typedef {object} Props
|
|
15
|
+
* @property {string} [class] - The `class` attribute on the wrapper element.
|
|
16
|
+
* @property {boolean} [required] - Whether to mark the widget required. An alias of the
|
|
17
|
+
* `aria-required` attribute.
|
|
18
|
+
* @property {boolean} [invalid] - Whether to mark the widget invalid. An alias of the
|
|
19
|
+
* `aria-invalid` attribute.
|
|
20
|
+
* @property {boolean | 'mixed'} [checked] - Whether to check the widget. An alias of the
|
|
21
|
+
* `aria-checked` attribute.
|
|
22
|
+
* @property {string | undefined} [label] - Text label displayed next to the checkbox.
|
|
23
|
+
* @property {string} [aria-label] - `aria-label` attribute.
|
|
24
|
+
* @property {import('svelte').Snippet} [checkIcon] - Check icon slot content.
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
export { className as class };
|
|
20
|
-
/**
|
|
21
|
-
* The `name` attribute on the `<button>` element.
|
|
22
|
-
* @type {string | undefined}
|
|
23
|
-
*/
|
|
24
|
-
export let name = undefined;
|
|
25
|
-
/**
|
|
26
|
-
* The `value` attribute on the `<button>` element.
|
|
27
|
-
* @type {string | undefined}
|
|
28
|
-
*/
|
|
29
|
-
export let value = undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
32
|
-
* @type {boolean | undefined}
|
|
33
|
-
*/
|
|
34
|
-
export let hidden = undefined;
|
|
35
|
-
/**
|
|
36
|
-
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
37
|
-
* @type {boolean}
|
|
38
|
-
*/
|
|
39
|
-
export let disabled = false;
|
|
40
|
-
/**
|
|
41
|
-
* Whether to make the widget read-only. An alias of the `aria-readonly` attribute.
|
|
42
|
-
* @type {boolean}
|
|
43
|
-
*/
|
|
44
|
-
export let readonly = false;
|
|
45
|
-
/**
|
|
46
|
-
* Whether to mark the widget required. An alias of the `aria-required` attribute.
|
|
47
|
-
* @type {boolean}
|
|
48
|
-
*/
|
|
49
|
-
export let required = false;
|
|
50
|
-
/**
|
|
51
|
-
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
52
|
-
* @type {boolean}
|
|
53
|
-
*/
|
|
54
|
-
export let invalid = false;
|
|
55
|
-
/**
|
|
56
|
-
* Whether to check the widget. An alias of the `aria-checked` attribute.
|
|
57
|
-
* @type {boolean | 'mixed'}
|
|
58
|
-
*/
|
|
59
|
-
export let checked = false;
|
|
26
|
+
|
|
60
27
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
28
|
+
* @type {import('../../typedefs').ButtonProps & import('../../typedefs').CommonEventHandlers &
|
|
29
|
+
* Props & Record<string, any>}
|
|
63
30
|
*/
|
|
64
|
-
|
|
31
|
+
let {
|
|
32
|
+
/* eslint-disable prefer-const */
|
|
33
|
+
checked = $bindable(false),
|
|
34
|
+
class: className,
|
|
35
|
+
name = undefined,
|
|
36
|
+
value = undefined,
|
|
37
|
+
hidden = false,
|
|
38
|
+
disabled = false,
|
|
39
|
+
readonly = false,
|
|
40
|
+
required = false,
|
|
41
|
+
invalid = false,
|
|
42
|
+
label = undefined,
|
|
43
|
+
'aria-label': ariaLabel,
|
|
44
|
+
onChange,
|
|
45
|
+
children,
|
|
46
|
+
checkIcon,
|
|
47
|
+
...restProps
|
|
48
|
+
/* eslint-enable prefer-const */
|
|
49
|
+
} = $props();
|
|
65
50
|
|
|
66
|
-
const dispatch = createEventDispatcher();
|
|
67
51
|
const id = generateElementId('checkbox');
|
|
68
52
|
|
|
69
53
|
/**
|
|
70
|
-
* Reference to the
|
|
71
|
-
* @type {
|
|
54
|
+
* Reference to the `<button>` element.
|
|
55
|
+
* @type {HTMLButtonElement | undefined}
|
|
72
56
|
*/
|
|
73
|
-
let
|
|
57
|
+
let buttonElement = $state();
|
|
74
58
|
|
|
75
|
-
|
|
76
|
-
$: indeterminate = checked === 'mixed';
|
|
59
|
+
const indeterminate = $derived(checked === 'mixed');
|
|
77
60
|
</script>
|
|
78
61
|
|
|
79
62
|
<div
|
|
@@ -83,15 +66,20 @@
|
|
|
83
66
|
class:indeterminate
|
|
84
67
|
class:disabled
|
|
85
68
|
class:readonly
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
{hidden}
|
|
70
|
+
onclick={(event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
|
|
88
74
|
if (!(/** @type {HTMLElement} */ (event.target).matches('button'))) {
|
|
89
|
-
|
|
75
|
+
buttonElement?.click();
|
|
90
76
|
}
|
|
91
77
|
}}
|
|
92
78
|
>
|
|
93
79
|
<div role="none" class="inner" inert={disabled}>
|
|
94
80
|
<Button
|
|
81
|
+
{...restProps}
|
|
82
|
+
bind:element={buttonElement}
|
|
95
83
|
role="checkbox"
|
|
96
84
|
{id}
|
|
97
85
|
{name}
|
|
@@ -104,26 +92,28 @@
|
|
|
104
92
|
aria-checked={checked}
|
|
105
93
|
aria-label={ariaLabel || undefined}
|
|
106
94
|
aria-labelledby={ariaLabel ? undefined : `${id}-label`}
|
|
107
|
-
{
|
|
108
|
-
bind:this={buttonComponent}
|
|
109
|
-
on:click={(event) => {
|
|
95
|
+
onclick={(event) => {
|
|
110
96
|
event.preventDefault();
|
|
111
97
|
event.stopPropagation();
|
|
112
98
|
|
|
113
99
|
if (!disabled && !readonly) {
|
|
114
100
|
checked = indeterminate ? true : !checked;
|
|
115
|
-
|
|
101
|
+
onChange?.(new CustomEvent('Change', { detail: { checked } }));
|
|
116
102
|
}
|
|
117
103
|
}}
|
|
118
104
|
>
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
{#snippet startIcon()}
|
|
106
|
+
{#if checkIcon}
|
|
107
|
+
{@render checkIcon()}
|
|
108
|
+
{:else}
|
|
109
|
+
<Icon name={indeterminate ? 'remove' : 'check'} />
|
|
110
|
+
{/if}
|
|
111
|
+
{/snippet}
|
|
122
112
|
</Button>
|
|
123
|
-
{#if
|
|
113
|
+
{#if children || label}
|
|
124
114
|
<label id="{id}-label">
|
|
125
|
-
{#if
|
|
126
|
-
|
|
115
|
+
{#if children}
|
|
116
|
+
{@render children()}
|
|
127
117
|
{:else}
|
|
128
118
|
{label}
|
|
129
119
|
{/if}
|