@sveltia/ui 0.10.7 → 0.11.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/button/button-group.svelte +17 -0
- package/package/components/button/button-group.svelte.d.ts +29 -0
- package/package/components/button/button.svelte +1 -0
- package/package/components/button/button.svelte.d.ts +4 -2
- package/package/components/button/select-button-group.svelte.d.ts +2 -2
- package/package/components/button/select-button.svelte.d.ts +2 -2
- package/package/components/button/split-button.svelte.d.ts +2 -2
- package/package/components/checkbox/checkbox.svelte.d.ts +2 -2
- package/package/components/disclosure/disclosure.svelte.d.ts +2 -2
- package/package/components/divider/divider.svelte +4 -0
- package/package/components/drawer/drawer.svelte +0 -1
- package/package/components/listbox/listbox.svelte +22 -1
- package/package/components/listbox/listbox.svelte.d.ts +6 -2
- package/package/components/listbox/option-group.svelte.d.ts +2 -2
- package/package/components/listbox/option.svelte +15 -4
- package/package/components/listbox/option.svelte.d.ts +4 -2
- package/package/components/menu/menu-button.svelte.d.ts +2 -2
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +2 -2
- package/package/components/menu/menu-item-group.svelte.d.ts +2 -2
- package/package/components/menu/menu-item-radio.svelte.d.ts +2 -2
- package/package/components/menu/menu-item.svelte.d.ts +2 -2
- package/package/components/radio/radio-group.svelte.d.ts +2 -2
- package/package/components/radio/radio.svelte.d.ts +2 -2
- package/package/components/select/combobox.svelte +71 -10
- package/package/components/select/combobox.svelte.d.ts +2 -2
- package/package/components/select/select.svelte.d.ts +2 -2
- package/package/components/slider/slider.svelte.d.ts +2 -2
- package/package/components/switch/switch.svelte.d.ts +2 -2
- package/package/components/text-field/markdown-editor.svelte.d.ts +2 -2
- package/package/components/text-field/number-input.svelte.d.ts +2 -2
- package/package/components/text-field/password-input.svelte.d.ts +2 -2
- package/package/components/text-field/search-bar.svelte.d.ts +2 -2
- package/package/components/text-field/text-area.svelte.d.ts +2 -2
- package/package/components/text-field/text-input.svelte.d.ts +2 -2
- package/package/components/toolbar/toolbar.svelte +8 -0
- package/package/components/util/app-shell.svelte +10 -10
- package/package/components/util/modal.svelte +1 -1
- package/package/components/util/popup.svelte +1 -1
- package/package/index.d.ts +1 -0
- package/package/index.js +1 -0
- package/package/locales/en.d.ts +2 -0
- package/package/locales/en.js +2 -0
- package/package/locales/ja.d.ts +2 -0
- package/package/locales/ja.js +2 -0
- package/package/services/events.js +8 -6
- package/package/services/group.d.ts +1 -1
- package/package/services/group.js +67 -18
- package/package/styles/variables.scss +5 -5
- package/package.json +20 -12
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
export default class Combobox extends SvelteComponent<{
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string | undefined;
|
|
13
|
-
invalid?: boolean | undefined;
|
|
14
13
|
disabled?: boolean | undefined;
|
|
14
|
+
invalid?: boolean | undefined;
|
|
15
15
|
required?: boolean | undefined;
|
|
16
16
|
value?: string | number | undefined;
|
|
17
17
|
position?: PopupPosition | undefined;
|
|
@@ -37,8 +37,8 @@ declare const __propDef: {
|
|
|
37
37
|
props: {
|
|
38
38
|
[x: string]: any;
|
|
39
39
|
class?: string | undefined;
|
|
40
|
-
invalid?: boolean | undefined;
|
|
41
40
|
disabled?: boolean | undefined;
|
|
41
|
+
invalid?: boolean | undefined;
|
|
42
42
|
required?: boolean | undefined;
|
|
43
43
|
value?: (string | number | undefined);
|
|
44
44
|
position?: PopupPosition | undefined;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
export default class Select extends SvelteComponent<{
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string | undefined;
|
|
13
|
-
invalid?: boolean | undefined;
|
|
14
13
|
disabled?: boolean | undefined;
|
|
14
|
+
invalid?: boolean | undefined;
|
|
15
15
|
required?: boolean | undefined;
|
|
16
16
|
value?: string | number | undefined;
|
|
17
17
|
hidden?: boolean | undefined;
|
|
@@ -32,8 +32,8 @@ declare const __propDef: {
|
|
|
32
32
|
props: {
|
|
33
33
|
[x: string]: any;
|
|
34
34
|
class?: string | undefined;
|
|
35
|
-
invalid?: boolean | undefined;
|
|
36
35
|
disabled?: boolean | undefined;
|
|
36
|
+
invalid?: boolean | undefined;
|
|
37
37
|
required?: boolean | undefined;
|
|
38
38
|
value?: (string | number | undefined);
|
|
39
39
|
hidden?: boolean | undefined;
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
export default class Slider extends SvelteComponent<{
|
|
13
13
|
[x: string]: any;
|
|
14
14
|
class?: string | undefined;
|
|
15
|
-
invalid?: boolean | undefined;
|
|
16
15
|
disabled?: boolean | undefined;
|
|
16
|
+
invalid?: boolean | undefined;
|
|
17
17
|
max?: number | undefined;
|
|
18
18
|
min?: number | undefined;
|
|
19
19
|
step?: number | undefined;
|
|
@@ -39,8 +39,8 @@ declare const __propDef: {
|
|
|
39
39
|
props: {
|
|
40
40
|
[x: string]: any;
|
|
41
41
|
class?: string | undefined;
|
|
42
|
-
invalid?: boolean | undefined;
|
|
43
42
|
disabled?: boolean | undefined;
|
|
43
|
+
invalid?: boolean | undefined;
|
|
44
44
|
max?: number | undefined;
|
|
45
45
|
min?: number | undefined;
|
|
46
46
|
step?: number | undefined;
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
export default class Switch extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string | undefined;
|
|
12
|
+
disabled?: boolean | undefined;
|
|
12
13
|
invalid?: boolean | undefined;
|
|
13
14
|
label?: string | undefined;
|
|
14
15
|
checked?: boolean | "mixed" | undefined;
|
|
15
|
-
disabled?: boolean | undefined;
|
|
16
16
|
required?: boolean | undefined;
|
|
17
17
|
hidden?: boolean | undefined;
|
|
18
18
|
readonly?: boolean | undefined;
|
|
@@ -32,10 +32,10 @@ declare const __propDef: {
|
|
|
32
32
|
props: {
|
|
33
33
|
[x: string]: any;
|
|
34
34
|
class?: string | undefined;
|
|
35
|
+
disabled?: boolean | undefined;
|
|
35
36
|
invalid?: boolean | undefined;
|
|
36
37
|
label?: string | undefined;
|
|
37
38
|
checked?: boolean | "mixed" | undefined;
|
|
38
|
-
disabled?: boolean | undefined;
|
|
39
39
|
required?: boolean | undefined;
|
|
40
40
|
hidden?: boolean | undefined;
|
|
41
41
|
readonly?: boolean | undefined;
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
/** A Markdown text editor. */
|
|
5
5
|
export default class MarkdownEditor extends SvelteComponent<{
|
|
6
6
|
[x: string]: any;
|
|
7
|
-
invalid?: boolean | undefined;
|
|
8
7
|
disabled?: boolean | undefined;
|
|
8
|
+
invalid?: boolean | undefined;
|
|
9
9
|
required?: boolean | undefined;
|
|
10
10
|
value?: string | undefined;
|
|
11
11
|
hidden?: boolean | undefined;
|
|
@@ -22,8 +22,8 @@ import { SvelteComponent } from "svelte";
|
|
|
22
22
|
declare const __propDef: {
|
|
23
23
|
props: {
|
|
24
24
|
[x: string]: any;
|
|
25
|
-
invalid?: boolean | undefined;
|
|
26
25
|
disabled?: boolean | undefined;
|
|
26
|
+
invalid?: boolean | undefined;
|
|
27
27
|
required?: boolean | undefined;
|
|
28
28
|
value?: string | undefined;
|
|
29
29
|
hidden?: boolean | undefined;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
export default class NumberInput extends SvelteComponent<{
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string | undefined;
|
|
12
|
-
invalid?: boolean | undefined;
|
|
13
12
|
disabled?: boolean | undefined;
|
|
13
|
+
invalid?: boolean | undefined;
|
|
14
14
|
max?: number | undefined;
|
|
15
15
|
min?: number | undefined;
|
|
16
16
|
required?: boolean | undefined;
|
|
@@ -44,8 +44,8 @@ declare const __propDef: {
|
|
|
44
44
|
props: {
|
|
45
45
|
[x: string]: any;
|
|
46
46
|
class?: string | undefined;
|
|
47
|
-
invalid?: boolean | undefined;
|
|
48
47
|
disabled?: boolean | undefined;
|
|
48
|
+
invalid?: boolean | undefined;
|
|
49
49
|
max?: number | undefined;
|
|
50
50
|
min?: number | undefined;
|
|
51
51
|
required?: boolean | undefined;
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
export default class PasswordInput extends SvelteComponent<{
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string | undefined;
|
|
13
|
-
invalid?: boolean | undefined;
|
|
14
13
|
disabled?: boolean | undefined;
|
|
14
|
+
invalid?: boolean | undefined;
|
|
15
15
|
required?: boolean | undefined;
|
|
16
16
|
value?: string | undefined;
|
|
17
17
|
hidden?: boolean | undefined;
|
|
@@ -39,8 +39,8 @@ declare const __propDef: {
|
|
|
39
39
|
props: {
|
|
40
40
|
[x: string]: any;
|
|
41
41
|
class?: string | undefined;
|
|
42
|
-
invalid?: boolean | undefined;
|
|
43
42
|
disabled?: boolean | undefined;
|
|
43
|
+
invalid?: boolean | undefined;
|
|
44
44
|
required?: boolean | undefined;
|
|
45
45
|
value?: string | undefined;
|
|
46
46
|
hidden?: boolean | undefined;
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
export default class SearchBar extends SvelteComponent<{
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string | undefined;
|
|
13
|
+
disabled?: boolean | undefined;
|
|
13
14
|
focus?: (() => void) | undefined;
|
|
14
15
|
invalid?: boolean | undefined;
|
|
15
|
-
disabled?: boolean | undefined;
|
|
16
16
|
required?: boolean | undefined;
|
|
17
17
|
value?: string | undefined;
|
|
18
18
|
hidden?: boolean | undefined;
|
|
@@ -66,9 +66,9 @@ declare const __propDef: {
|
|
|
66
66
|
props: {
|
|
67
67
|
[x: string]: any;
|
|
68
68
|
class?: string | undefined;
|
|
69
|
+
disabled?: boolean | undefined;
|
|
69
70
|
focus?: (() => void) | undefined;
|
|
70
71
|
invalid?: boolean | undefined;
|
|
71
|
-
disabled?: boolean | undefined;
|
|
72
72
|
required?: boolean | undefined;
|
|
73
73
|
value?: string | undefined;
|
|
74
74
|
hidden?: boolean | undefined;
|
|
@@ -11,8 +11,8 @@ export default class TextArea extends SvelteComponent<{
|
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string | undefined;
|
|
13
13
|
name?: string | undefined;
|
|
14
|
-
invalid?: boolean | undefined;
|
|
15
14
|
disabled?: boolean | undefined;
|
|
15
|
+
invalid?: boolean | undefined;
|
|
16
16
|
required?: boolean | undefined;
|
|
17
17
|
value?: string | undefined;
|
|
18
18
|
hidden?: boolean | undefined;
|
|
@@ -38,8 +38,8 @@ declare const __propDef: {
|
|
|
38
38
|
[x: string]: any;
|
|
39
39
|
class?: string | undefined;
|
|
40
40
|
name?: string | undefined;
|
|
41
|
-
invalid?: boolean | undefined;
|
|
42
41
|
disabled?: boolean | undefined;
|
|
42
|
+
invalid?: boolean | undefined;
|
|
43
43
|
required?: boolean | undefined;
|
|
44
44
|
value?: string | undefined;
|
|
45
45
|
hidden?: boolean | undefined;
|
|
@@ -10,8 +10,8 @@ export default class TextInput extends SvelteComponent<{
|
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string | undefined;
|
|
12
12
|
name?: string | undefined;
|
|
13
|
-
invalid?: boolean | undefined;
|
|
14
13
|
disabled?: boolean | undefined;
|
|
14
|
+
invalid?: boolean | undefined;
|
|
15
15
|
required?: boolean | undefined;
|
|
16
16
|
value?: string | number | undefined;
|
|
17
17
|
role?: "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined;
|
|
@@ -83,8 +83,8 @@ declare const __propDef: {
|
|
|
83
83
|
[x: string]: any;
|
|
84
84
|
class?: string | undefined;
|
|
85
85
|
name?: string | undefined;
|
|
86
|
-
invalid?: boolean | undefined;
|
|
87
86
|
disabled?: boolean | undefined;
|
|
87
|
+
invalid?: boolean | undefined;
|
|
88
88
|
required?: boolean | undefined;
|
|
89
89
|
value?: string | number | undefined;
|
|
90
90
|
role?: "textbox" | "searchbox" | "combobox" | "spinbutton" | undefined;
|
|
@@ -98,6 +98,14 @@
|
|
|
98
98
|
font-weight: normal;
|
|
99
99
|
opacity: 0.8;
|
|
100
100
|
}
|
|
101
|
+
[role=toolbar] :global(.divider[aria-orientation="horizontal"]) {
|
|
102
|
+
margin: 0 4px;
|
|
103
|
+
width: calc(100% - 8px);
|
|
104
|
+
}
|
|
105
|
+
[role=toolbar] :global(.divider[aria-orientation="vertical"]) {
|
|
106
|
+
margin: 4px 0;
|
|
107
|
+
height: calc(100% - 8px);
|
|
108
|
+
}
|
|
101
109
|
|
|
102
110
|
.inner {
|
|
103
111
|
display: contents;
|
|
@@ -268,10 +268,10 @@
|
|
|
268
268
|
--sui-background-color-2-hsl: var(--sui-base-hue) 5% 98%;
|
|
269
269
|
--sui-background-color-3-hsl: var(--sui-base-hue) 5% 96%;
|
|
270
270
|
--sui-background-color-4-hsl: var(--sui-base-hue) 5% 94%;
|
|
271
|
-
--sui-background-color-5-hsl: var(--sui-base-hue) 5%
|
|
272
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 5%
|
|
273
|
-
--sui-border-color-2-hsl: var(--sui-base-hue) 5%
|
|
274
|
-
--sui-border-color-3-hsl: var(--sui-base-hue) 5%
|
|
271
|
+
--sui-background-color-5-hsl: var(--sui-base-hue) 5% 84%;
|
|
272
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 5% 65%;
|
|
273
|
+
--sui-border-color-2-hsl: var(--sui-base-hue) 5% 84%;
|
|
274
|
+
--sui-border-color-3-hsl: var(--sui-base-hue) 5% 88%;
|
|
275
275
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
|
276
276
|
--sui-primary-accent-color-text: hsl(var(--sui-base-hue) 80% 40%);
|
|
277
277
|
--sui-primary-accent-color-light: hsl(var(--sui-base-hue) 80% 45%);
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
--sui-background-color-3-hsl: var(--sui-base-hue) 10% 14%;
|
|
304
304
|
--sui-background-color-4-hsl: var(--sui-base-hue) 10% 16%;
|
|
305
305
|
--sui-background-color-5-hsl: var(--sui-base-hue) 10% 26%;
|
|
306
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 10%
|
|
306
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 10% 45%;
|
|
307
307
|
--sui-border-color-2-hsl: var(--sui-base-hue) 10% 26%;
|
|
308
308
|
--sui-border-color-3-hsl: var(--sui-base-hue) 10% 22%;
|
|
309
309
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
|
@@ -337,10 +337,10 @@
|
|
|
337
337
|
--sui-background-color-2-hsl: var(--sui-base-hue) 5% 98%;
|
|
338
338
|
--sui-background-color-3-hsl: var(--sui-base-hue) 5% 96%;
|
|
339
339
|
--sui-background-color-4-hsl: var(--sui-base-hue) 5% 94%;
|
|
340
|
-
--sui-background-color-5-hsl: var(--sui-base-hue) 5%
|
|
341
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 5%
|
|
342
|
-
--sui-border-color-2-hsl: var(--sui-base-hue) 5%
|
|
343
|
-
--sui-border-color-3-hsl: var(--sui-base-hue) 5%
|
|
340
|
+
--sui-background-color-5-hsl: var(--sui-base-hue) 5% 84%;
|
|
341
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 5% 65%;
|
|
342
|
+
--sui-border-color-2-hsl: var(--sui-base-hue) 5% 84%;
|
|
343
|
+
--sui-border-color-3-hsl: var(--sui-base-hue) 5% 88%;
|
|
344
344
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
|
345
345
|
--sui-primary-accent-color-text: hsl(var(--sui-base-hue) 80% 40%);
|
|
346
346
|
--sui-primary-accent-color-light: hsl(var(--sui-base-hue) 80% 45%);
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
--sui-background-color-3-hsl: var(--sui-base-hue) 10% 14%;
|
|
375
375
|
--sui-background-color-4-hsl: var(--sui-base-hue) 10% 16%;
|
|
376
376
|
--sui-background-color-5-hsl: var(--sui-base-hue) 10% 26%;
|
|
377
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 10%
|
|
377
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 10% 45%;
|
|
378
378
|
--sui-border-color-2-hsl: var(--sui-base-hue) 10% 26%;
|
|
379
379
|
--sui-border-color-3-hsl: var(--sui-base-hue) 10% 22%;
|
|
380
380
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
package/package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export function initLocales({ fallbackLocale, initialLocale }?: {
|
|
|
3
3
|
initialLocale?: string | undefined;
|
|
4
4
|
} | undefined): void;
|
|
5
5
|
export { default as Alert } from "./components/alert/alert.svelte";
|
|
6
|
+
export { default as ButtonGroup } from "./components/button/button-group.svelte";
|
|
6
7
|
export { default as Button } from "./components/button/button.svelte";
|
|
7
8
|
export { default as SelectButtonGroup } from "./components/button/select-button-group.svelte";
|
|
8
9
|
export { default as SelectButton } from "./components/button/select-button.svelte";
|
package/package/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export const initLocales = ({ fallbackLocale = 'en', initialLocale = 'en' } = {}
|
|
|
28
28
|
initLocales();
|
|
29
29
|
|
|
30
30
|
export { default as Alert } from './components/alert/alert.svelte';
|
|
31
|
+
export { default as ButtonGroup } from './components/button/button-group.svelte';
|
|
31
32
|
export { default as Button } from './components/button/button.svelte';
|
|
32
33
|
export { default as SelectButtonGroup } from './components/button/select-button-group.svelte';
|
|
33
34
|
export { default as SelectButton } from './components/button/select-button.svelte';
|
package/package/locales/en.d.ts
CHANGED
package/package/locales/en.js
CHANGED
package/package/locales/ja.d.ts
CHANGED
package/package/locales/ja.js
CHANGED
|
@@ -62,16 +62,18 @@ export const activateKeyShortcuts = (element, shortcuts = '') => {
|
|
|
62
62
|
* @param {KeyboardEvent} event - `keydown` event.
|
|
63
63
|
*/
|
|
64
64
|
const handler = (event) => {
|
|
65
|
+
const { disabled, offsetParent, offsetLeft, offsetTop } = element;
|
|
66
|
+
|
|
67
|
+
// Check if the element is enabled, visible and clickable (not behind a modal dialog)
|
|
65
68
|
if (
|
|
66
|
-
|
|
69
|
+
!disabled &&
|
|
70
|
+
!!offsetParent &&
|
|
71
|
+
document.elementsFromPoint(offsetLeft + 4, offsetTop + 4).includes(element) &&
|
|
67
72
|
matchShortcuts(event, /** @type {string} */ (platformKeyShortcuts))
|
|
68
73
|
) {
|
|
69
74
|
event.preventDefault();
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
element.focus();
|
|
73
|
-
element.click();
|
|
74
|
-
}
|
|
75
|
+
element.focus();
|
|
76
|
+
element.click();
|
|
75
77
|
}
|
|
76
78
|
};
|
|
77
79
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function activateGroup(parent: HTMLElement):
|
|
1
|
+
export function activateGroup(parent: HTMLElement, _params?: object | undefined): import('svelte/action').ActionReturn;
|
|
@@ -75,7 +75,18 @@ class Group {
|
|
|
75
75
|
this.childSelectedProp = childSelectedAttr.replace('aria-', '');
|
|
76
76
|
this.focusChild = focusChild;
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// Wait a bit before the relevant components, including the `aria-controls` target are mounted
|
|
79
|
+
(async () => {
|
|
80
|
+
await sleep(100);
|
|
81
|
+
this.activate();
|
|
82
|
+
})();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Activate the members.
|
|
87
|
+
*/
|
|
88
|
+
activate() {
|
|
89
|
+
const { parent, allMembers, selected: defaultSelected } = this;
|
|
79
90
|
|
|
80
91
|
allMembers.forEach((element, index) => {
|
|
81
92
|
// Select the first one if no member has the `selected` attribute
|
|
@@ -340,9 +351,10 @@ class Group {
|
|
|
340
351
|
const target = /** @type {HTMLElement} */ (event.target);
|
|
341
352
|
const { allMembers, activeMembers } = this;
|
|
342
353
|
|
|
354
|
+
/** @type {HTMLElement | undefined} */
|
|
343
355
|
const currentTarget = (() => {
|
|
344
356
|
if (!this.focusChild) {
|
|
345
|
-
return activeMembers.find((member) => member.matches('.focused'))
|
|
357
|
+
return activeMembers.find((member) => member.matches('.focused'));
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
if (target.matches(this.selector)) {
|
|
@@ -352,22 +364,20 @@ class Group {
|
|
|
352
364
|
return undefined;
|
|
353
365
|
})();
|
|
354
366
|
|
|
355
|
-
if (!currentTarget) {
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
367
|
if (['Enter', ' ', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(key)) {
|
|
360
368
|
event.preventDefault();
|
|
361
369
|
}
|
|
362
370
|
|
|
363
371
|
if (key === 'Enter') {
|
|
364
|
-
currentTarget
|
|
372
|
+
currentTarget?.click(); // Also close the popup if needed
|
|
365
373
|
|
|
366
374
|
return;
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
if (key === ' ') {
|
|
370
|
-
|
|
378
|
+
if (currentTarget) {
|
|
379
|
+
this.selectTarget(event, currentTarget);
|
|
380
|
+
}
|
|
371
381
|
|
|
372
382
|
return;
|
|
373
383
|
}
|
|
@@ -376,9 +386,9 @@ class Group {
|
|
|
376
386
|
let newTarget;
|
|
377
387
|
|
|
378
388
|
if (this.grid) {
|
|
379
|
-
const colCount = Math.floor(this.parent.clientWidth /
|
|
389
|
+
const colCount = Math.floor(this.parent.clientWidth / activeMembers[0].clientWidth);
|
|
380
390
|
|
|
381
|
-
index = allMembers.indexOf(currentTarget);
|
|
391
|
+
index = currentTarget ? allMembers.indexOf(currentTarget) : -1;
|
|
382
392
|
|
|
383
393
|
if (key === 'ArrowUp' && index > 0) {
|
|
384
394
|
newTarget = allMembers[index - colCount];
|
|
@@ -400,7 +410,7 @@ class Group {
|
|
|
400
410
|
newTarget = undefined;
|
|
401
411
|
}
|
|
402
412
|
} else {
|
|
403
|
-
index = activeMembers.indexOf(currentTarget);
|
|
413
|
+
index = currentTarget ? activeMembers.indexOf(currentTarget) : -1;
|
|
404
414
|
|
|
405
415
|
if (key === (this.orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp')) {
|
|
406
416
|
if (index > 0) {
|
|
@@ -431,17 +441,56 @@ class Group {
|
|
|
431
441
|
this.selectTarget(event, newTarget);
|
|
432
442
|
}
|
|
433
443
|
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Called whenever the params are updated. Filter the items based on the search terms.
|
|
447
|
+
* @param {{ searchTerms: string }} params - Updated params.
|
|
448
|
+
*/
|
|
449
|
+
onUpdate({ searchTerms }) {
|
|
450
|
+
const terms = searchTerms.trim().toLocaleLowerCase();
|
|
451
|
+
const _terms = terms ? terms.split(/\s+/) : [];
|
|
452
|
+
|
|
453
|
+
const matched = this.allMembers
|
|
454
|
+
.map((member) => {
|
|
455
|
+
const searchValue =
|
|
456
|
+
(
|
|
457
|
+
member.dataset.searchValue ??
|
|
458
|
+
member.dataset.label ??
|
|
459
|
+
member.querySelector('.label')?.textContent ??
|
|
460
|
+
member.textContent
|
|
461
|
+
)?.toLocaleLowerCase() ?? '';
|
|
462
|
+
|
|
463
|
+
const hidden = !_terms.every((term) => searchValue.includes(term));
|
|
464
|
+
|
|
465
|
+
member.dispatchEvent(new CustomEvent('toggle', { detail: { hidden } }));
|
|
466
|
+
|
|
467
|
+
return hidden;
|
|
468
|
+
})
|
|
469
|
+
.filter((hidden) => !hidden).length;
|
|
470
|
+
|
|
471
|
+
this.parent.dispatchEvent(
|
|
472
|
+
new CustomEvent('filter', { detail: { matched, total: this.allMembers.length } }),
|
|
473
|
+
);
|
|
474
|
+
}
|
|
434
475
|
}
|
|
435
476
|
|
|
436
477
|
/**
|
|
437
478
|
* Activate a new group.
|
|
438
479
|
* @param {HTMLElement} parent - Parent element.
|
|
480
|
+
* @param {object} [_params] - Action params.
|
|
481
|
+
* @returns {import('svelte/action').ActionReturn} Action.
|
|
439
482
|
*/
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
483
|
+
// eslint-disable-next-line no-unused-vars
|
|
484
|
+
export const activateGroup = (parent, _params) => {
|
|
485
|
+
const group = new Group(parent);
|
|
486
|
+
|
|
487
|
+
return {
|
|
488
|
+
/**
|
|
489
|
+
* Called whenever the params are updated.
|
|
490
|
+
* @param {any} params - Updated params.
|
|
491
|
+
*/
|
|
492
|
+
update(params) {
|
|
493
|
+
group.onUpdate(params);
|
|
494
|
+
},
|
|
495
|
+
};
|
|
447
496
|
};
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
--sui-background-color-2-hsl: var(--sui-base-hue) 5% 98%; // primary
|
|
10
10
|
--sui-background-color-3-hsl: var(--sui-base-hue) 5% 96%; // secondary
|
|
11
11
|
--sui-background-color-4-hsl: var(--sui-base-hue) 5% 94%; // tertiary/disabled
|
|
12
|
-
--sui-background-color-5-hsl: var(--sui-base-hue) 5%
|
|
13
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 5%
|
|
14
|
-
--sui-border-color-2-hsl: var(--sui-base-hue) 5%
|
|
15
|
-
--sui-border-color-3-hsl: var(--sui-base-hue) 5%
|
|
12
|
+
--sui-background-color-5-hsl: var(--sui-base-hue) 5% 84%; // highlight
|
|
13
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 5% 65%; // control
|
|
14
|
+
--sui-border-color-2-hsl: var(--sui-base-hue) 5% 84%; // primary
|
|
15
|
+
--sui-border-color-3-hsl: var(--sui-base-hue) 5% 88%; // secondary
|
|
16
16
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
|
17
17
|
// Accents
|
|
18
18
|
--sui-primary-accent-color-text: hsl(var(--sui-base-hue) 80% 40%);
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
--sui-background-color-3-hsl: var(--sui-base-hue) 10% 14%; // secondary
|
|
47
47
|
--sui-background-color-4-hsl: var(--sui-base-hue) 10% 16%; // tertiary/disabled
|
|
48
48
|
--sui-background-color-5-hsl: var(--sui-base-hue) 10% 26%; // highlight
|
|
49
|
-
--sui-border-color-1-hsl: var(--sui-base-hue) 10%
|
|
49
|
+
--sui-border-color-1-hsl: var(--sui-base-hue) 10% 45%; // control
|
|
50
50
|
--sui-border-color-2-hsl: var(--sui-base-hue) 10% 26%; // primary
|
|
51
51
|
--sui-border-color-3-hsl: var(--sui-base-hue) 10% 22%; // secondary
|
|
52
52
|
--sui-shadow-color: var(--sui-base-hue) 10% 0%;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -26,32 +26,32 @@
|
|
|
26
26
|
"svelte": "^4.2.12"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@playwright/test": "^1.
|
|
30
|
-
"@sveltejs/adapter-auto": "^3.
|
|
31
|
-
"@sveltejs/kit": "^2.5.
|
|
32
|
-
"@sveltejs/package": "^2.3.
|
|
29
|
+
"@playwright/test": "^1.43.0",
|
|
30
|
+
"@sveltejs/adapter-auto": "^3.2.0",
|
|
31
|
+
"@sveltejs/kit": "^2.5.5",
|
|
32
|
+
"@sveltejs/package": "^2.3.1",
|
|
33
33
|
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
|
34
|
-
"cspell": "^8.6.
|
|
34
|
+
"cspell": "^8.6.1",
|
|
35
35
|
"eslint": "^8.57.0",
|
|
36
36
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
37
37
|
"eslint-config-prettier": "^9.1.0",
|
|
38
38
|
"eslint-plugin-import": "^2.29.1",
|
|
39
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
39
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
40
40
|
"eslint-plugin-svelte": "^2.35.1",
|
|
41
41
|
"npm-run-all": "^4.1.5",
|
|
42
|
-
"postcss": "^8.4.
|
|
42
|
+
"postcss": "^8.4.38",
|
|
43
43
|
"postcss-html": "^1.6.0",
|
|
44
44
|
"prettier": "^3.2.5",
|
|
45
45
|
"prettier-plugin-svelte": "^3.2.2",
|
|
46
|
-
"sass": "^1.
|
|
47
|
-
"stylelint": "^16.
|
|
46
|
+
"sass": "^1.74.1",
|
|
47
|
+
"stylelint": "^16.3.1",
|
|
48
48
|
"stylelint-config-recommended-scss": "^14.0.0",
|
|
49
49
|
"stylelint-scss": "^6.2.1",
|
|
50
|
-
"svelte-check": "^3.6.
|
|
50
|
+
"svelte-check": "^3.6.9",
|
|
51
51
|
"svelte-i18n": "^4.0.0",
|
|
52
52
|
"svelte-preprocess": "^5.1.3",
|
|
53
53
|
"tslib": "^2.6.2",
|
|
54
|
-
"vite": "^5.
|
|
54
|
+
"vite": "^5.2.8",
|
|
55
55
|
"vitest": "^1.4.0"
|
|
56
56
|
},
|
|
57
57
|
"exports": {
|
|
@@ -61,6 +61,11 @@
|
|
|
61
61
|
"svelte": "./package/components/alert/alert.svelte",
|
|
62
62
|
"default": "./package/components/alert/alert.svelte"
|
|
63
63
|
},
|
|
64
|
+
"./components/button/button-group.svelte": {
|
|
65
|
+
"types": "./package/components/button/button-group.svelte.d.ts",
|
|
66
|
+
"svelte": "./package/components/button/button-group.svelte",
|
|
67
|
+
"default": "./package/components/button/button-group.svelte"
|
|
68
|
+
},
|
|
64
69
|
"./components/button/button.svelte": {
|
|
65
70
|
"types": "./package/components/button/button.svelte.d.ts",
|
|
66
71
|
"svelte": "./package/components/button/button.svelte",
|
|
@@ -431,6 +436,9 @@
|
|
|
431
436
|
"components/alert/alert.svelte": [
|
|
432
437
|
"./package/components/alert/alert.svelte.d.ts"
|
|
433
438
|
],
|
|
439
|
+
"components/button/button-group.svelte": [
|
|
440
|
+
"./package/components/button/button-group.svelte.d.ts"
|
|
441
|
+
],
|
|
434
442
|
"components/button/button.svelte": [
|
|
435
443
|
"./package/components/button/button.svelte.d.ts"
|
|
436
444
|
],
|