@sveltia/ui 0.7.4 → 0.8.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 +4 -4
- package/package/components/alert/alert.svelte.d.ts +2 -2
- package/package/components/button/button.svelte +13 -3
- package/package/components/button/button.svelte.d.ts +11 -4
- package/package/components/button/select-button-group.svelte +12 -8
- package/package/components/button/select-button.svelte +5 -4
- package/package/components/button/select-button.svelte.d.ts +2 -0
- package/package/components/calendar/calendar.svelte +20 -14
- package/package/components/checkbox/checkbox-group.svelte +6 -5
- package/package/components/checkbox/checkbox.svelte +16 -9
- package/package/components/checkbox/checkbox.svelte.d.ts +2 -2
- package/package/components/dialog/alert-dialog.svelte +50 -0
- package/package/components/dialog/alert-dialog.svelte.d.ts +55 -0
- package/package/components/dialog/confirmation-dialog.svelte +55 -0
- package/package/components/dialog/confirmation-dialog.svelte.d.ts +57 -0
- package/package/components/dialog/dialog.svelte +164 -220
- package/package/components/dialog/dialog.svelte.d.ts +20 -12
- package/package/components/dialog/prompt-dialog.svelte +78 -0
- package/package/components/dialog/prompt-dialog.svelte.d.ts +72 -0
- package/package/components/disclosure/disclosure.svelte +3 -3
- package/package/components/divider/divider.svelte +1 -1
- package/package/components/divider/spacer.svelte +1 -12
- package/package/components/divider/spacer.svelte.d.ts +0 -2
- package/package/components/drawer/drawer.svelte +118 -208
- package/package/components/drawer/drawer.svelte.d.ts +12 -8
- package/package/components/grid/grid-body.svelte +51 -0
- package/package/components/grid/grid-body.svelte.d.ts +36 -0
- package/package/components/grid/grid-cell.svelte +22 -0
- package/package/components/grid/grid-cell.svelte.d.ts +34 -0
- package/package/components/grid/grid-col-header.svelte +22 -0
- package/package/components/grid/grid-col-header.svelte.d.ts +34 -0
- package/package/components/grid/grid-foot.svelte +27 -0
- package/package/components/grid/grid-foot.svelte.d.ts +34 -0
- package/package/components/grid/grid-head.svelte +27 -0
- package/package/components/grid/grid-head.svelte.d.ts +34 -0
- package/package/components/grid/grid-row-header.svelte +23 -0
- package/package/components/grid/grid-row-header.svelte.d.ts +34 -0
- package/package/components/grid/grid-row.svelte +37 -0
- package/package/components/grid/grid-row.svelte.d.ts +44 -0
- package/package/components/grid/grid.svelte +52 -0
- package/package/components/grid/grid.svelte.d.ts +42 -0
- package/package/components/icon/icon.svelte +6 -7
- package/package/components/icon/icon.svelte.d.ts +0 -2
- package/package/components/listbox/listbox.svelte +6 -6
- package/package/components/listbox/option-group.svelte +6 -5
- package/package/components/listbox/option.svelte +7 -28
- package/package/components/listbox/option.svelte.d.ts +2 -0
- package/package/components/menu/menu-button.svelte +26 -16
- package/package/components/menu/menu-button.svelte.d.ts +2 -2
- package/package/components/menu/menu-item-checkbox.svelte +5 -4
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +2 -0
- package/package/components/menu/menu-item-group.svelte +4 -3
- package/package/components/menu/menu-item-radio.svelte +5 -4
- package/package/components/menu/menu-item-radio.svelte.d.ts +2 -0
- package/package/components/menu/menu-item.svelte +7 -5
- package/package/components/menu/menu-item.svelte.d.ts +4 -2
- package/package/components/menu/menu.svelte +1 -1
- package/package/components/radio/radio-group.svelte +8 -8
- package/package/components/radio/radio-group.svelte.d.ts +2 -2
- package/package/components/radio/radio.svelte +5 -2
- package/package/components/radio/radio.svelte.d.ts +2 -0
- package/package/components/select/combobox.svelte +55 -35
- package/package/components/select/combobox.svelte.d.ts +3 -2
- package/package/components/select/select.svelte +10 -9
- package/package/components/select/select.svelte.d.ts +4 -3
- package/package/components/slider/slider.svelte +15 -7
- package/package/components/switch/switch.svelte +9 -6
- package/package/components/switch/switch.svelte.d.ts +2 -2
- package/package/components/table/table-body.svelte +31 -3
- package/package/components/table/table-body.svelte.d.ts +2 -0
- package/package/components/table/table-cell.svelte +3 -4
- package/package/components/table/table-cell.svelte.d.ts +1 -1
- package/package/components/table/table-col-header.svelte +1 -2
- package/package/components/table/table-foot.svelte +7 -3
- package/package/components/table/table-head.svelte +7 -3
- package/package/components/table/table-row-header.svelte +1 -2
- package/package/components/table/table-row.svelte +1 -14
- package/package/components/table/table-row.svelte.d.ts +0 -8
- package/package/components/table/table.svelte +5 -17
- package/package/components/table/table.svelte.d.ts +1 -7
- package/package/components/tabs/tab-list.svelte +7 -5
- package/package/components/tabs/tab-panel.svelte +1 -1
- package/package/components/tabs/tab.svelte +2 -1
- package/package/components/tabs/tab.svelte.d.ts +2 -0
- package/package/components/text-field/markdown-editor.svelte +36 -9
- package/package/components/text-field/markdown-editor.svelte.d.ts +2 -0
- package/package/components/text-field/number-input.svelte +107 -43
- package/package/components/text-field/number-input.svelte.d.ts +2 -0
- package/package/components/text-field/password-input.svelte +43 -12
- package/package/components/text-field/password-input.svelte.d.ts +2 -0
- package/package/components/text-field/search-bar.svelte +43 -13
- package/package/components/text-field/search-bar.svelte.d.ts +5 -0
- package/package/components/text-field/text-area.svelte +26 -6
- package/package/components/text-field/text-area.svelte.d.ts +2 -0
- package/package/components/text-field/text-input.svelte +37 -7
- package/package/components/text-field/text-input.svelte.d.ts +14 -4
- package/package/components/toast/toast.svelte +6 -16
- package/package/components/toast/toast.svelte.d.ts +2 -2
- package/package/components/toolbar/toolbar.svelte +3 -4
- package/package/components/util/app-shell.svelte +34 -29
- package/package/components/util/group.svelte +2 -2
- package/package/components/util/modal.svelte +220 -0
- package/package/components/util/modal.svelte.d.ts +83 -0
- package/package/components/util/popup.svelte +80 -121
- package/package/components/util/popup.svelte.d.ts +22 -13
- package/package/components/util/portal.svelte +1 -1
- package/package/index.d.ts +12 -0
- package/package/index.js +12 -0
- package/package/locales/en.d.ts +1 -0
- package/package/locales/en.js +1 -0
- package/package/locales/ja.d.ts +1 -0
- package/package/locales/ja.js +1 -0
- package/package/services/group.js +67 -13
- package/package/services/popup.d.ts +5 -1
- package/package/services/popup.js +22 -19
- package/package/styles/core.scss +13 -26
- package/package/styles/variables.scss +14 -2
- package/package.json +107 -11
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
A variant of the `<Select>` widget with an auto-complete text input field.
|
|
4
4
|
@see https://w3c.github.io/aria/#combobox
|
|
5
5
|
@see https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
|
|
6
|
+
@todo Add DOM API compatibility.
|
|
6
7
|
-->
|
|
7
8
|
<script>
|
|
8
9
|
import { createEventDispatcher } from 'svelte';
|
|
@@ -32,30 +33,29 @@
|
|
|
32
33
|
*/
|
|
33
34
|
export let disabled = false;
|
|
34
35
|
/**
|
|
35
|
-
* Whether to
|
|
36
|
+
* Whether to make the widget read-only. An alias of the `aria-readonly` attribute.
|
|
36
37
|
* @type {boolean}
|
|
37
38
|
*/
|
|
38
39
|
export let readonly = false;
|
|
39
40
|
/**
|
|
40
|
-
* Whether to
|
|
41
|
+
* Whether to mark the widget required. An alias of the `aria-required` attribute.
|
|
41
42
|
* @type {boolean}
|
|
42
43
|
*/
|
|
43
44
|
export let required = false;
|
|
44
45
|
/**
|
|
45
|
-
* Whether to
|
|
46
|
+
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
46
47
|
* @type {boolean}
|
|
47
48
|
*/
|
|
48
49
|
export let invalid = false;
|
|
49
|
-
/**
|
|
50
|
-
* Text label displayed on the readonly item.
|
|
51
|
-
* @type {string}
|
|
52
|
-
*/
|
|
53
|
-
export let label = '';
|
|
54
50
|
/**
|
|
55
51
|
* Selected option’s value.
|
|
56
52
|
* @type {(string | number | undefined)}
|
|
57
53
|
*/
|
|
58
54
|
export let value = undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Whether to make the `combobox` editable.
|
|
57
|
+
*/
|
|
58
|
+
export let editable = true;
|
|
59
59
|
/**
|
|
60
60
|
* Where to show the dropdown menu.
|
|
61
61
|
* @type {PopupPosition}
|
|
@@ -71,27 +71,54 @@
|
|
|
71
71
|
/** @type {Popup?} */
|
|
72
72
|
let popupComponent;
|
|
73
73
|
let isPopupOpen = writable(false);
|
|
74
|
+
/** @type {string} */
|
|
75
|
+
let label = '';
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Update the `value` and `label` whenever an option is selected
|
|
79
|
+
* @param {HTMLButtonElement} target Selected option.
|
|
80
|
+
*/
|
|
81
|
+
const onSelect = (target) => {
|
|
82
|
+
// @todo support more types
|
|
83
|
+
value = target.dataset.type === 'number' ? Number(target.value) : target.value;
|
|
84
|
+
label = target.querySelector('.label')?.textContent || target.value;
|
|
85
|
+
dispatch('change', { target: inputComponent?.element, value });
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
$: {
|
|
89
|
+
if (popupComponent?.content) {
|
|
90
|
+
window.requestAnimationFrame(() => {
|
|
91
|
+
const selected = popupComponent.content.querySelector(
|
|
92
|
+
'[role="option"][aria-selected="true"]',
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (selected) {
|
|
96
|
+
onSelect(/** @type {HTMLButtonElement?} */ (selected));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
74
101
|
</script>
|
|
75
102
|
|
|
76
|
-
<div class="sui combobox {className}"
|
|
77
|
-
{#if
|
|
103
|
+
<div role="none" class="sui combobox {className}" hidden={hidden || undefined} {...$$restProps}>
|
|
104
|
+
{#if !editable}
|
|
78
105
|
<div
|
|
106
|
+
role="combobox"
|
|
79
107
|
{id}
|
|
80
108
|
class:selected={value !== undefined}
|
|
81
109
|
tabindex={disabled ? -1 : 0}
|
|
82
|
-
role="combobox"
|
|
83
110
|
aria-controls="{id}-popup"
|
|
84
111
|
aria-expanded={$isPopupOpen}
|
|
85
112
|
aria-hidden={hidden}
|
|
86
113
|
aria-disabled={disabled}
|
|
87
|
-
aria-readonly=
|
|
114
|
+
aria-readonly={readonly}
|
|
88
115
|
aria-haspopup="listbox"
|
|
89
116
|
aria-activedescendant="selected-option"
|
|
90
117
|
{...$$restProps}
|
|
91
118
|
bind:this={comboboxElement}
|
|
92
119
|
>
|
|
93
|
-
<div class="label">
|
|
94
|
-
{value !== undefined ? label
|
|
120
|
+
<div role="none" class="label">
|
|
121
|
+
{value !== undefined ? label : $_('_sui.combobox.select_an_option')}
|
|
95
122
|
</div>
|
|
96
123
|
</div>
|
|
97
124
|
{:else}
|
|
@@ -118,21 +145,19 @@
|
|
|
118
145
|
{hidden}
|
|
119
146
|
{disabled}
|
|
120
147
|
tabindex={readonly || disabled ? -1 : 0}
|
|
148
|
+
aria-label={$isPopupOpen ? $_('_sui.collapse') : $_('_sui.expand')}
|
|
121
149
|
aria-controls="{id}-popup"
|
|
122
150
|
aria-expanded={$isPopupOpen}
|
|
123
151
|
on:click={(event) => {
|
|
152
|
+
event.preventDefault();
|
|
124
153
|
event.stopPropagation();
|
|
125
154
|
|
|
126
|
-
if (!disabled) {
|
|
155
|
+
if (!disabled && !readonly) {
|
|
127
156
|
$isPopupOpen = !$isPopupOpen;
|
|
128
157
|
}
|
|
129
158
|
}}
|
|
130
159
|
>
|
|
131
|
-
<Icon
|
|
132
|
-
slot="start-icon"
|
|
133
|
-
name="expand_more"
|
|
134
|
-
label={$isPopupOpen ? $_('_sui.collapse') : $_('_sui.expand')}
|
|
135
|
-
/>
|
|
160
|
+
<Icon slot="start-icon" name="expand_more" />
|
|
136
161
|
</Button>
|
|
137
162
|
</div>
|
|
138
163
|
<Popup
|
|
@@ -147,13 +172,7 @@
|
|
|
147
172
|
<Listbox
|
|
148
173
|
on:click={(event) => {
|
|
149
174
|
if (/** @type {HTMLElement} */ (event.target).matches('[role="option"]')) {
|
|
150
|
-
|
|
151
|
-
const target = /** @type {HTMLButtonElement?} */ (event.target);
|
|
152
|
-
|
|
153
|
-
// @todo support more types
|
|
154
|
-
value = target.dataset.type === 'number' ? Number(target.value) : target.value;
|
|
155
|
-
label = target.querySelector('.label')?.textContent || target.value;
|
|
156
|
-
dispatch('change', { target: inputComponent?.element, value });
|
|
175
|
+
onSelect(/** @type {HTMLButtonElement?} */ (event.target));
|
|
157
176
|
}
|
|
158
177
|
}}
|
|
159
178
|
>
|
|
@@ -162,6 +181,7 @@
|
|
|
162
181
|
</Popup>
|
|
163
182
|
|
|
164
183
|
<style>.combobox {
|
|
184
|
+
margin: var(--sui-focus-ring-width);
|
|
165
185
|
display: flex;
|
|
166
186
|
align-items: center;
|
|
167
187
|
position: relative;
|
|
@@ -180,6 +200,7 @@
|
|
|
180
200
|
position: absolute;
|
|
181
201
|
inset: 0 0 auto auto;
|
|
182
202
|
z-index: 1;
|
|
203
|
+
margin: 0 !important;
|
|
183
204
|
border-top-left-radius: 0;
|
|
184
205
|
border-bottom-left-radius: 0;
|
|
185
206
|
}
|
|
@@ -214,11 +235,6 @@
|
|
|
214
235
|
.combobox div[role=combobox]:hover, .combobox div[role=combobox]:focus {
|
|
215
236
|
background-color: var(--sui-hover-background-color);
|
|
216
237
|
}
|
|
217
|
-
.combobox div[role=combobox][aria-disabled=true] {
|
|
218
|
-
background-color: var(--sui-disabled-background-color);
|
|
219
|
-
opacity: 0.4;
|
|
220
|
-
cursor: default;
|
|
221
|
-
}
|
|
222
238
|
.combobox div[role=combobox] .label {
|
|
223
239
|
display: block;
|
|
224
240
|
overflow: hidden;
|
|
@@ -226,9 +242,13 @@
|
|
|
226
242
|
white-space: nowrap;
|
|
227
243
|
text-overflow: ellipsis;
|
|
228
244
|
}
|
|
245
|
+
.combobox :global(.text-input) {
|
|
246
|
+
margin: 0 !important;
|
|
247
|
+
width: 100% !important;
|
|
248
|
+
}
|
|
229
249
|
.combobox :global(input) {
|
|
230
250
|
padding: 0 32px 0 8px;
|
|
231
|
-
width:
|
|
251
|
+
width: 0;
|
|
232
252
|
}
|
|
233
253
|
.combobox + :global([role="listbox"]) {
|
|
234
254
|
position: fixed;
|
|
@@ -237,8 +257,8 @@
|
|
|
237
257
|
box-shadow: 0 8px 16px var(--sui-popup-shadow-color);
|
|
238
258
|
overflow: auto;
|
|
239
259
|
background-color: var(--sui-secondary-background-color);
|
|
240
|
-
-webkit-backdrop-filter: blur(
|
|
241
|
-
backdrop-filter: blur(
|
|
260
|
+
-webkit-backdrop-filter: blur(32px);
|
|
261
|
+
backdrop-filter: blur(32px);
|
|
242
262
|
/* Add .1s delay before the position can be determined */
|
|
243
263
|
transition: opacity 100ms 100ms;
|
|
244
264
|
}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* A variant of the `<Select>` widget with an auto-complete text input field.
|
|
6
6
|
* @see https://w3c.github.io/aria/#combobox
|
|
7
7
|
* @see https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
|
|
8
|
+
* @todo Add DOM API compatibility.
|
|
8
9
|
*/
|
|
9
10
|
export default class Combobox extends SvelteComponent<{
|
|
10
11
|
[x: string]: any;
|
|
11
12
|
class?: string;
|
|
12
|
-
label?: string;
|
|
13
13
|
invalid?: boolean;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
required?: boolean;
|
|
@@ -17,6 +17,7 @@ export default class Combobox extends SvelteComponent<{
|
|
|
17
17
|
position?: PopupPosition;
|
|
18
18
|
hidden?: boolean;
|
|
19
19
|
readonly?: boolean;
|
|
20
|
+
editable?: boolean;
|
|
20
21
|
}, {
|
|
21
22
|
change: CustomEvent<any>;
|
|
22
23
|
} & {
|
|
@@ -33,7 +34,6 @@ declare const __propDef: {
|
|
|
33
34
|
props: {
|
|
34
35
|
[x: string]: any;
|
|
35
36
|
class?: string;
|
|
36
|
-
label?: string;
|
|
37
37
|
invalid?: boolean;
|
|
38
38
|
disabled?: boolean;
|
|
39
39
|
required?: boolean;
|
|
@@ -41,6 +41,7 @@ declare const __propDef: {
|
|
|
41
41
|
position?: PopupPosition;
|
|
42
42
|
hidden?: boolean | undefined;
|
|
43
43
|
readonly?: boolean;
|
|
44
|
+
editable?: boolean;
|
|
44
45
|
};
|
|
45
46
|
events: {
|
|
46
47
|
change: CustomEvent<any>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
A
|
|
3
|
+
A select-only variant of `<Combobox>`. The equivalent of the HTML `<select>` element.
|
|
4
4
|
@see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
|
|
5
5
|
@see https://w3c.github.io/aria/#combobox
|
|
6
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
|
|
6
7
|
-->
|
|
7
8
|
<script>
|
|
8
9
|
import Combobox from './combobox.svelte';
|
|
@@ -23,21 +24,21 @@
|
|
|
23
24
|
* @type {boolean}
|
|
24
25
|
*/
|
|
25
26
|
export let disabled = false;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to make the widget read-only. An alias of the `aria-readonly` attribute.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export let readonly = false;
|
|
26
32
|
/**
|
|
27
33
|
* Whether to disable the widget. An alias of the `aria-required` attribute.
|
|
28
34
|
* @type {boolean}
|
|
29
35
|
*/
|
|
30
36
|
export let required = false;
|
|
31
37
|
/**
|
|
32
|
-
* Whether to
|
|
38
|
+
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
33
39
|
* @type {boolean}
|
|
34
40
|
*/
|
|
35
41
|
export let invalid = false;
|
|
36
|
-
/**
|
|
37
|
-
* Text label displayed on the readonly item.
|
|
38
|
-
* @type {string}
|
|
39
|
-
*/
|
|
40
|
-
export let label = '';
|
|
41
42
|
/**
|
|
42
43
|
* Selected option’s value.
|
|
43
44
|
* @type {(string | number | undefined)}
|
|
@@ -50,11 +51,11 @@
|
|
|
50
51
|
class="sui select {className}"
|
|
51
52
|
{hidden}
|
|
52
53
|
{disabled}
|
|
53
|
-
readonly
|
|
54
|
+
{readonly}
|
|
54
55
|
{required}
|
|
55
56
|
{invalid}
|
|
56
|
-
{label}
|
|
57
57
|
{...$$restProps}
|
|
58
|
+
editable={false}
|
|
58
59
|
on:change
|
|
59
60
|
>
|
|
60
61
|
<slot />
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} SelectEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} SelectSlots */
|
|
4
4
|
/**
|
|
5
|
-
* A
|
|
5
|
+
* A select-only variant of `<Combobox>`. The equivalent of the HTML `<select>` element.
|
|
6
6
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
|
|
7
7
|
* @see https://w3c.github.io/aria/#combobox
|
|
8
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/
|
|
8
9
|
*/
|
|
9
10
|
export default class Select extends SvelteComponent<{
|
|
10
11
|
[x: string]: any;
|
|
11
12
|
class?: string;
|
|
12
|
-
label?: string;
|
|
13
13
|
invalid?: boolean;
|
|
14
14
|
disabled?: boolean;
|
|
15
15
|
required?: boolean;
|
|
16
16
|
value?: string | number;
|
|
17
17
|
hidden?: boolean;
|
|
18
|
+
readonly?: boolean;
|
|
18
19
|
}, {
|
|
19
20
|
change: CustomEvent<any>;
|
|
20
21
|
} & {
|
|
@@ -31,12 +32,12 @@ declare const __propDef: {
|
|
|
31
32
|
props: {
|
|
32
33
|
[x: string]: any;
|
|
33
34
|
class?: string;
|
|
34
|
-
label?: string;
|
|
35
35
|
invalid?: boolean;
|
|
36
36
|
disabled?: boolean;
|
|
37
37
|
required?: boolean;
|
|
38
38
|
value?: (string | number | undefined);
|
|
39
39
|
hidden?: boolean | undefined;
|
|
40
|
+
readonly?: boolean;
|
|
40
41
|
};
|
|
41
42
|
events: {
|
|
42
43
|
change: CustomEvent<any>;
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
*/
|
|
28
28
|
export let disabled = false;
|
|
29
29
|
/**
|
|
30
|
-
* Whether to
|
|
30
|
+
* Whether to make the widget read-only. An alias of the `aria-readonly` attribute.
|
|
31
31
|
* @type {boolean}
|
|
32
32
|
*/
|
|
33
33
|
export let readonly = false;
|
|
34
34
|
/**
|
|
35
|
-
* Whether to
|
|
35
|
+
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
36
36
|
* @type {boolean}
|
|
37
37
|
*/
|
|
38
38
|
export let invalid = false;
|
|
@@ -250,6 +250,10 @@
|
|
|
250
250
|
* Initialize the variables.
|
|
251
251
|
*/
|
|
252
252
|
const init = () => {
|
|
253
|
+
if (!base) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
|
|
253
257
|
barWidth = base.clientWidth;
|
|
254
258
|
|
|
255
259
|
const stepCount = (max - min) / step + 1;
|
|
@@ -262,13 +266,15 @@
|
|
|
262
266
|
};
|
|
263
267
|
|
|
264
268
|
onMount(() => {
|
|
269
|
+
const observer = new ResizeObserver(() => init());
|
|
265
270
|
const query = window.matchMedia('(pointer: coarse)');
|
|
266
271
|
|
|
267
|
-
|
|
272
|
+
observer.observe(base);
|
|
268
273
|
query.addEventListener('change', init);
|
|
269
274
|
init();
|
|
270
275
|
|
|
271
276
|
return () => {
|
|
277
|
+
observer.disconnect();
|
|
272
278
|
query.removeEventListener('change', init);
|
|
273
279
|
};
|
|
274
280
|
});
|
|
@@ -287,20 +293,21 @@
|
|
|
287
293
|
/>
|
|
288
294
|
|
|
289
295
|
<div
|
|
296
|
+
role="none"
|
|
290
297
|
class="sui slider {className}"
|
|
291
298
|
class:disabled
|
|
292
|
-
|
|
299
|
+
class:readonly
|
|
293
300
|
hidden={hidden || undefined}
|
|
294
301
|
{...$$restProps}
|
|
295
302
|
on:click|preventDefault|stopPropagation
|
|
296
303
|
>
|
|
297
304
|
<div
|
|
298
|
-
class="base"
|
|
299
305
|
role="none"
|
|
306
|
+
class="base"
|
|
300
307
|
bind:this={base}
|
|
301
308
|
on:click|preventDefault|stopPropagation={(event) => onClick(event)}
|
|
302
309
|
>
|
|
303
|
-
<div class="base-bar" />
|
|
310
|
+
<div role="none" class="base-bar" />
|
|
304
311
|
<div
|
|
305
312
|
class="slider-bar"
|
|
306
313
|
style:left="{multiThumb ? sliderPositions[0] : 0}px"
|
|
@@ -341,8 +348,8 @@
|
|
|
341
348
|
{#if optionLabels.length}
|
|
342
349
|
{#each optionLabels as label, index}
|
|
343
350
|
<span
|
|
351
|
+
role="none"
|
|
344
352
|
class="label"
|
|
345
|
-
role="presentation"
|
|
346
353
|
style:left="{(barWidth / (optionLabels.length - 1)) * index}px"
|
|
347
354
|
>
|
|
348
355
|
{label}
|
|
@@ -355,6 +362,7 @@
|
|
|
355
362
|
<style>.slider {
|
|
356
363
|
position: relative;
|
|
357
364
|
display: inline-block;
|
|
365
|
+
margin: var(--sui-focus-ring-width);
|
|
358
366
|
padding: var(--sui-checkbox-height) calc(var(--sui-checkbox-height) / 2);
|
|
359
367
|
touch-action: none;
|
|
360
368
|
}
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
*/
|
|
23
23
|
export let disabled = false;
|
|
24
24
|
/**
|
|
25
|
-
* Whether to
|
|
25
|
+
* Whether to make the widget read-only. An alias of the `aria-readonly` attribute.
|
|
26
26
|
* @type {boolean}
|
|
27
27
|
*/
|
|
28
28
|
export let readonly = false;
|
|
29
29
|
/**
|
|
30
|
-
* Whether to
|
|
30
|
+
* Whether to mark the widget required. An alias of the `aria-required` attribute.
|
|
31
31
|
* @type {boolean}
|
|
32
32
|
*/
|
|
33
33
|
export let required = false;
|
|
34
34
|
/**
|
|
35
|
-
* Whether to
|
|
35
|
+
* Whether to mark the widget invalid. An alias of the `aria-invalid` attribute.
|
|
36
36
|
* @type {boolean}
|
|
37
37
|
*/
|
|
38
38
|
export let invalid = false;
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
</script>
|
|
50
50
|
|
|
51
51
|
<button
|
|
52
|
+
role="switch"
|
|
52
53
|
class="sui switch {className}"
|
|
53
54
|
type="button"
|
|
54
|
-
role="switch"
|
|
55
55
|
hidden={hidden || undefined}
|
|
56
56
|
disabled={disabled || undefined}
|
|
57
57
|
aria-checked={checked}
|
|
@@ -62,10 +62,12 @@
|
|
|
62
62
|
aria-invalid={invalid}
|
|
63
63
|
{...$$restProps}
|
|
64
64
|
on:click={() => {
|
|
65
|
-
|
|
65
|
+
if (!disabled && !readonly) {
|
|
66
|
+
checked = !checked;
|
|
67
|
+
}
|
|
66
68
|
}}
|
|
67
69
|
>
|
|
68
|
-
<span />
|
|
70
|
+
<span role="none" />
|
|
69
71
|
{#if label}
|
|
70
72
|
{label}
|
|
71
73
|
{:else}
|
|
@@ -77,6 +79,7 @@
|
|
|
77
79
|
display: inline-flex;
|
|
78
80
|
align-items: center;
|
|
79
81
|
gap: 8px;
|
|
82
|
+
margin: var(--sui-focus-ring-width);
|
|
80
83
|
border-width: 0;
|
|
81
84
|
border-style: solid;
|
|
82
85
|
border-color: transparent;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
export default class Switch extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string;
|
|
12
|
-
label?: string;
|
|
13
12
|
invalid?: boolean;
|
|
13
|
+
label?: string;
|
|
14
14
|
checked?: boolean | "mixed";
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
required?: boolean;
|
|
@@ -30,8 +30,8 @@ declare const __propDef: {
|
|
|
30
30
|
props: {
|
|
31
31
|
[x: string]: any;
|
|
32
32
|
class?: string;
|
|
33
|
-
label?: string | undefined;
|
|
34
33
|
invalid?: boolean;
|
|
34
|
+
label?: string | undefined;
|
|
35
35
|
checked?: boolean | 'mixed';
|
|
36
36
|
disabled?: boolean;
|
|
37
37
|
required?: boolean;
|
|
@@ -5,19 +5,47 @@
|
|
|
5
5
|
@see https://w3c.github.io/aria/#rowgroup
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
|
+
import { getRandomId } from '../../services/util';
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
|
-
*
|
|
11
|
+
* The `class` attribute on the wrapper element.
|
|
10
12
|
* @type {string}
|
|
11
13
|
*/
|
|
12
14
|
let className = '';
|
|
13
|
-
|
|
14
15
|
export { className as class };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Display label for the row group.
|
|
19
|
+
* @type {string}
|
|
20
|
+
*/
|
|
21
|
+
export let label = '';
|
|
22
|
+
|
|
23
|
+
const id = getRandomId('tbody');
|
|
15
24
|
</script>
|
|
16
25
|
|
|
17
|
-
<div
|
|
26
|
+
<div
|
|
27
|
+
role="rowgroup"
|
|
28
|
+
class="sui table-body row-group {className}"
|
|
29
|
+
aria-labelledby={label ? `${id}-label` : undefined}
|
|
30
|
+
aria-roledescription="table body"
|
|
31
|
+
{...$$restProps}
|
|
32
|
+
>
|
|
33
|
+
{#if label}
|
|
34
|
+
<tr class="row-group-caption">
|
|
35
|
+
<th id="{id}-label" colspan="9999" scope="rowgroup">{label}</th>
|
|
36
|
+
</tr>
|
|
37
|
+
{/if}
|
|
18
38
|
<slot />
|
|
19
39
|
</div>
|
|
20
40
|
|
|
21
41
|
<style>.table-body {
|
|
22
42
|
display: table-row-group;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
th {
|
|
46
|
+
padding: 8px;
|
|
47
|
+
color: var(--sui-secondary-foreground-color);
|
|
48
|
+
background-color: var(--sui-secondary-background-color);
|
|
49
|
+
font-size: var(--sui-font-size-default);
|
|
50
|
+
text-align: left;
|
|
23
51
|
}</style>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export default class TableBody extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string;
|
|
12
|
+
label?: string;
|
|
12
13
|
}, {
|
|
13
14
|
[evt: string]: CustomEvent<any>;
|
|
14
15
|
}, {
|
|
@@ -23,6 +24,7 @@ declare const __propDef: {
|
|
|
23
24
|
props: {
|
|
24
25
|
[x: string]: any;
|
|
25
26
|
class?: string;
|
|
27
|
+
label?: string;
|
|
26
28
|
};
|
|
27
29
|
events: {
|
|
28
30
|
[evt: string]: CustomEvent<any>;
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
@component
|
|
3
3
|
The equivalent of the HTML `<td>` element.
|
|
4
4
|
@see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td
|
|
5
|
-
@see https://w3c.github.io/aria/#
|
|
5
|
+
@see https://w3c.github.io/aria/#cell
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The `class` attribute on the wrapper element.
|
|
10
10
|
* @type {string}
|
|
11
11
|
*/
|
|
12
12
|
let className = '';
|
|
13
|
-
|
|
14
13
|
export { className as class };
|
|
15
14
|
</script>
|
|
16
15
|
|
|
17
|
-
<div role="
|
|
16
|
+
<div role="cell" class="sui table-cell {className}" {...$$restProps}>
|
|
18
17
|
<slot />
|
|
19
18
|
</div>
|
|
20
19
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* The equivalent of the HTML `<td>` element.
|
|
6
6
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td
|
|
7
|
-
* @see https://w3c.github.io/aria/#
|
|
7
|
+
* @see https://w3c.github.io/aria/#cell
|
|
8
8
|
*/
|
|
9
9
|
export default class TableCell extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
@@ -6,15 +6,19 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The `class` attribute on the wrapper element.
|
|
10
10
|
* @type {string}
|
|
11
11
|
*/
|
|
12
12
|
let className = '';
|
|
13
|
-
|
|
14
13
|
export { className as class };
|
|
15
14
|
</script>
|
|
16
15
|
|
|
17
|
-
<div
|
|
16
|
+
<div
|
|
17
|
+
role="rowgroup"
|
|
18
|
+
class="sui table-foot {className}"
|
|
19
|
+
aria-roledescription="table foot"
|
|
20
|
+
{...$$restProps}
|
|
21
|
+
>
|
|
18
22
|
<slot />
|
|
19
23
|
</div>
|
|
20
24
|
|
|
@@ -6,15 +6,19 @@
|
|
|
6
6
|
-->
|
|
7
7
|
<script>
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* The `class` attribute on the wrapper element.
|
|
10
10
|
* @type {string}
|
|
11
11
|
*/
|
|
12
12
|
let className = '';
|
|
13
|
-
|
|
14
13
|
export { className as class };
|
|
15
14
|
</script>
|
|
16
15
|
|
|
17
|
-
<div
|
|
16
|
+
<div
|
|
17
|
+
role="rowgroup"
|
|
18
|
+
class="sui table-head {className}"
|
|
19
|
+
aria-roledescription="table head"
|
|
20
|
+
{...$$restProps}
|
|
21
|
+
>
|
|
18
22
|
<slot />
|
|
19
23
|
</div>
|
|
20
24
|
|
|
@@ -11,22 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
let className = '';
|
|
13
13
|
export { className as class };
|
|
14
|
-
/**
|
|
15
|
-
* Whether to select the widget. An alias of the `aria-selected` attribute.
|
|
16
|
-
* @type {boolean}
|
|
17
|
-
*/
|
|
18
|
-
export let selected = false;
|
|
19
14
|
</script>
|
|
20
15
|
|
|
21
|
-
<div
|
|
22
|
-
class="sui table-row {className}"
|
|
23
|
-
role="row"
|
|
24
|
-
tabindex="0"
|
|
25
|
-
aria-selected={selected}
|
|
26
|
-
{...$$restProps}
|
|
27
|
-
on:click
|
|
28
|
-
on:select
|
|
29
|
-
>
|
|
16
|
+
<div role="row" class="sui table-row {className}" {...$$restProps}>
|
|
30
17
|
<slot />
|
|
31
18
|
</div>
|
|
32
19
|
|