@sveltia/ui 0.2.3 → 0.2.5
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/composite/calendar.svelte +4 -1
- package/package/components/composite/calendar.svelte.d.ts +1 -1
- package/package/components/composite/checkbox-group.svelte +4 -4
- package/package/components/composite/combobox.svelte +11 -8
- package/package/components/composite/combobox.svelte.d.ts +5 -5
- package/package/components/composite/disclosure.svelte +3 -3
- package/package/components/composite/disclosure.svelte.d.ts +1 -1
- package/package/components/composite/grid.svelte +2 -2
- package/package/components/composite/grid.svelte.d.ts +1 -1
- package/package/components/composite/listbox.svelte +4 -4
- package/package/components/composite/listbox.svelte.d.ts +2 -2
- package/package/components/composite/menu-item-group.svelte +1 -1
- package/package/components/composite/menu.svelte +3 -3
- package/package/components/composite/menu.svelte.d.ts +2 -2
- package/package/components/composite/{radio-button-group.svelte → radio-group.svelte} +11 -10
- package/package/components/composite/radio-group.svelte.d.ts +40 -0
- package/package/components/composite/select-button-group.svelte +4 -4
- package/package/components/composite/select-button-group.svelte.d.ts +3 -3
- package/package/components/composite/select.svelte +2 -2
- package/package/components/composite/select.svelte.d.ts +1 -1
- package/package/components/composite/tab-list.svelte +4 -4
- package/package/components/composite/tab-list.svelte.d.ts +2 -2
- package/package/components/core/button.svelte +12 -13
- package/package/components/core/button.svelte.d.ts +10 -10
- package/package/components/core/checkbox.svelte +40 -21
- package/package/components/core/checkbox.svelte.d.ts +4 -2
- package/package/components/core/dialog.svelte +14 -4
- package/package/components/core/dialog.svelte.d.ts +3 -3
- package/package/components/core/drawer.svelte +13 -3
- package/package/components/core/drawer.svelte.d.ts +1 -1
- package/package/components/core/grid-cell.svelte +1 -2
- package/package/components/core/group.svelte +1 -1
- package/package/components/core/icon.svelte +1 -1
- package/package/components/core/menu-button.svelte +3 -3
- package/package/components/core/menu-button.svelte.d.ts +3 -3
- package/package/components/core/menu-item-checkbox.svelte +1 -1
- package/package/components/core/menu-item-radio.svelte +1 -1
- package/package/components/core/number-input.svelte +19 -9
- package/package/components/core/number-input.svelte.d.ts +1 -1
- package/package/components/core/option.svelte +1 -1
- package/package/components/core/password-input.svelte +3 -3
- package/package/components/core/password-input.svelte.d.ts +1 -1
- package/package/components/core/{radio-button.svelte → radio.svelte} +45 -20
- package/package/components/core/radio.svelte.d.ts +41 -0
- package/package/components/core/row-group.svelte +1 -2
- package/package/components/core/row.svelte +1 -2
- package/package/components/core/search-bar.svelte +2 -2
- package/package/components/core/select-button.svelte +3 -3
- package/package/components/core/select-button.svelte.d.ts +2 -2
- package/package/components/core/separator.svelte +2 -1
- package/package/components/core/separator.svelte.d.ts +2 -2
- package/package/components/core/slider.svelte +54 -18
- package/package/components/core/spacer.svelte +2 -2
- package/package/components/core/switch.svelte +3 -3
- package/package/components/core/switch.svelte.d.ts +1 -1
- package/package/components/core/tab-panel.svelte +2 -3
- package/package/components/core/tab-panel.svelte.d.ts +1 -1
- package/package/components/core/tab.svelte +2 -2
- package/package/components/core/tab.svelte.d.ts +1 -1
- package/package/components/core/text-area.svelte +7 -7
- package/package/components/core/text-area.svelte.d.ts +2 -2
- package/package/components/core/text-input.svelte +7 -7
- package/package/components/core/text-input.svelte.d.ts +5 -5
- package/package/components/core/toolbar.svelte +2 -3
- package/package/components/core/toolbar.svelte.d.ts +1 -1
- package/package/components/editor/markdown.svelte +1 -1
- package/package/components/editor/markdown.svelte.d.ts +1 -1
- package/package/components/helpers/group.d.ts +1 -37
- package/package/components/helpers/group.js +26 -19
- package/package/components/helpers/popup.d.ts +1 -2
- package/package/components/helpers/popup.js +18 -8
- package/package/components/helpers/util.js +6 -0
- package/package/components/util/app-shell.svelte +15 -6
- package/package/components/util/misc.js +0 -2
- package/package/components/util/popup.svelte +14 -4
- package/package/components/util/popup.svelte.d.ts +10 -10
- package/package/components/util/portal.svelte +1 -1
- package/package/index.d.ts +6 -3
- package/package/index.js +47 -2
- package/package/styles/variables.scss +8 -5
- package/package/typedef.d.ts +1 -0
- package/package/typedef.js +4 -0
- package/package.json +30 -32
- package/package/components/composite/radio-button-group.svelte.d.ts +0 -36
- package/package/components/core/radio-button.svelte.d.ts +0 -37
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} ButtonSlots */
|
|
4
4
|
/**
|
|
5
5
|
* @see https://w3c.github.io/aria/#button
|
|
6
|
-
* @see https://
|
|
6
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/button/
|
|
7
7
|
*/
|
|
8
8
|
export default class Button extends SvelteComponentTyped<{
|
|
9
9
|
[x: string]: any;
|
|
@@ -15,8 +15,8 @@ export default class Button extends SvelteComponentTyped<{
|
|
|
15
15
|
size?: "small" | "medium" | "large";
|
|
16
16
|
hidden?: boolean;
|
|
17
17
|
disabled?: boolean;
|
|
18
|
-
pressed?:
|
|
19
|
-
popupPosition?:
|
|
18
|
+
pressed?: boolean | "true" | "false" | "mixed";
|
|
19
|
+
popupPosition?: PopupPosition;
|
|
20
20
|
}, {
|
|
21
21
|
mouseenter: MouseEvent;
|
|
22
22
|
mouseleave: MouseEvent;
|
|
@@ -58,14 +58,14 @@ export default class Button extends SvelteComponentTyped<{
|
|
|
58
58
|
set disabled(arg: boolean);
|
|
59
59
|
get disabled(): boolean;
|
|
60
60
|
/**accessor*/
|
|
61
|
-
set pressed(arg:
|
|
62
|
-
get pressed():
|
|
61
|
+
set pressed(arg: boolean | "true" | "false" | "mixed");
|
|
62
|
+
get pressed(): boolean | "true" | "false" | "mixed";
|
|
63
63
|
/**accessor*/
|
|
64
64
|
set label(arg: string);
|
|
65
65
|
get label(): string;
|
|
66
66
|
/**accessor*/
|
|
67
|
-
set popupPosition(arg:
|
|
68
|
-
get popupPosition():
|
|
67
|
+
set popupPosition(arg: PopupPosition);
|
|
68
|
+
get popupPosition(): PopupPosition;
|
|
69
69
|
}
|
|
70
70
|
export type ButtonProps = typeof __propDef.props;
|
|
71
71
|
export type ButtonEvents = typeof __propDef.events;
|
|
@@ -76,14 +76,14 @@ declare const __propDef: {
|
|
|
76
76
|
[x: string]: any;
|
|
77
77
|
label?: string;
|
|
78
78
|
class?: string;
|
|
79
|
-
element?:
|
|
79
|
+
element?: HTMLButtonElement | null;
|
|
80
80
|
type?: ('button' | 'submit' | 'reset');
|
|
81
81
|
role?: string;
|
|
82
82
|
size?: ('small' | 'medium' | 'large');
|
|
83
83
|
hidden?: boolean;
|
|
84
84
|
disabled?: boolean;
|
|
85
|
-
pressed?: (boolean |
|
|
86
|
-
popupPosition?:
|
|
85
|
+
pressed?: (boolean | 'false' | 'mixed' | 'true' | undefined);
|
|
86
|
+
popupPosition?: PopupPosition;
|
|
87
87
|
};
|
|
88
88
|
events: {
|
|
89
89
|
mouseenter: MouseEvent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
@see https://w3c.github.io/aria/#checkbox
|
|
4
|
-
@see https://
|
|
4
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
7
|
import { createEventDispatcher } from 'svelte';
|
|
@@ -11,31 +11,34 @@
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* CSS class name on the button.
|
|
14
|
-
* @type {
|
|
14
|
+
* @type {string}
|
|
15
15
|
*/
|
|
16
16
|
let className = '';
|
|
17
17
|
|
|
18
18
|
export { className as class };
|
|
19
19
|
|
|
20
|
-
/** @type {
|
|
20
|
+
/** @type {string} */
|
|
21
21
|
export let name = '';
|
|
22
22
|
|
|
23
|
-
/** @type {
|
|
23
|
+
/** @type {string?} */
|
|
24
|
+
export let label = undefined;
|
|
25
|
+
|
|
26
|
+
/** @type {string?} */
|
|
24
27
|
export let value = undefined;
|
|
25
28
|
|
|
26
|
-
/** @type {(
|
|
29
|
+
/** @type {(boolean | string | undefined)} */
|
|
27
30
|
export let checked = false;
|
|
28
31
|
|
|
29
|
-
/** @type {
|
|
32
|
+
/** @type {boolean} */
|
|
30
33
|
export let indeterminate = false;
|
|
31
34
|
|
|
32
|
-
/** @type {
|
|
35
|
+
/** @type {boolean} */
|
|
33
36
|
export let disabled = false;
|
|
34
37
|
|
|
35
38
|
const dispatch = createEventDispatcher();
|
|
36
39
|
const id = getRandomId('checkbox');
|
|
37
40
|
/** @type {Button} */
|
|
38
|
-
let
|
|
41
|
+
let buttonComponent;
|
|
39
42
|
</script>
|
|
40
43
|
|
|
41
44
|
{#if name && value && checked && !indeterminate}
|
|
@@ -43,24 +46,26 @@
|
|
|
43
46
|
{/if}
|
|
44
47
|
|
|
45
48
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
46
|
-
<
|
|
49
|
+
<span
|
|
47
50
|
class="sui checkbox {className}"
|
|
48
51
|
class:checked
|
|
49
52
|
class:indeterminate
|
|
50
53
|
class:disabled
|
|
51
54
|
on:click|preventDefault|stopPropagation={(event) => {
|
|
52
|
-
if (!event.target.matches('button')) {
|
|
53
|
-
|
|
55
|
+
if (!(/** @type {HTMLElement} */ (event.target).matches('button'))) {
|
|
56
|
+
buttonComponent.element.click();
|
|
54
57
|
}
|
|
55
58
|
}}
|
|
56
59
|
>
|
|
57
60
|
<Button
|
|
58
61
|
{id}
|
|
59
62
|
{disabled}
|
|
63
|
+
{name}
|
|
64
|
+
{value}
|
|
60
65
|
role="checkbox"
|
|
61
66
|
aria-checked={indeterminate ? 'mixed' : checked}
|
|
62
67
|
aria-labelledby="{id}-label"
|
|
63
|
-
bind:this={
|
|
68
|
+
bind:this={buttonComponent}
|
|
64
69
|
on:click={(event) => {
|
|
65
70
|
event.preventDefault();
|
|
66
71
|
event.stopPropagation();
|
|
@@ -71,12 +76,16 @@
|
|
|
71
76
|
>
|
|
72
77
|
<Icon slot="start-icon" name={indeterminate ? 'remove' : 'check'} />
|
|
73
78
|
</Button>
|
|
74
|
-
{#if $$slots.default}
|
|
79
|
+
{#if $$slots.default || label}
|
|
75
80
|
<label id="{id}-label">
|
|
76
|
-
|
|
81
|
+
{#if $$slots.default}
|
|
82
|
+
<slot />
|
|
83
|
+
{:else}
|
|
84
|
+
{label}
|
|
85
|
+
{/if}
|
|
77
86
|
</label>
|
|
78
87
|
{/if}
|
|
79
|
-
</
|
|
88
|
+
</span>
|
|
80
89
|
|
|
81
90
|
<style>.checkbox {
|
|
82
91
|
display: inline-flex;
|
|
@@ -90,25 +99,35 @@
|
|
|
90
99
|
.checkbox.disabled {
|
|
91
100
|
cursor: default;
|
|
92
101
|
}
|
|
102
|
+
.checkbox.disabled label {
|
|
103
|
+
color: var(--disabled-foreground-color);
|
|
104
|
+
}
|
|
93
105
|
.checkbox :global(button) {
|
|
94
106
|
align-items: center;
|
|
95
107
|
justify-content: center;
|
|
96
108
|
overflow: hidden;
|
|
97
109
|
border-width: 2px;
|
|
98
|
-
border-color: var(--control-border-color);
|
|
110
|
+
border-color: var(--primary-control-border-color);
|
|
99
111
|
border-radius: 4px;
|
|
100
|
-
width:
|
|
101
|
-
height:
|
|
112
|
+
width: 20px;
|
|
113
|
+
height: 20px;
|
|
102
114
|
color: var(--primary-accent-color-lighter);
|
|
103
115
|
transition: all 200ms;
|
|
104
116
|
}
|
|
105
117
|
.checkbox :global(button) :global(.icon) {
|
|
106
|
-
font-size:
|
|
118
|
+
font-size: 20px;
|
|
119
|
+
}
|
|
120
|
+
.checkbox :global(button[aria-checked="true"]) {
|
|
121
|
+
border-color: var(--primary-accent-color-lighter);
|
|
122
|
+
color: var(--control-background-color);
|
|
123
|
+
background-color: var(--primary-accent-color-lighter);
|
|
107
124
|
}
|
|
108
|
-
.checkbox :global(button[aria-checked="true"]),
|
|
109
125
|
.checkbox :global(button[aria-checked="mixed"]) {
|
|
110
|
-
color: var(--primary-
|
|
126
|
+
color: var(--primary-control-border-color);
|
|
111
127
|
}
|
|
112
128
|
.checkbox :global(button[aria-checked="false"]) {
|
|
113
129
|
color: transparent;
|
|
130
|
+
}
|
|
131
|
+
.checkbox label {
|
|
132
|
+
cursor: inherit;
|
|
114
133
|
}</style>
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} CheckboxSlots */
|
|
4
4
|
/**
|
|
5
5
|
* @see https://w3c.github.io/aria/#checkbox
|
|
6
|
-
* @see https://
|
|
6
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/
|
|
7
7
|
*/
|
|
8
8
|
export default class Checkbox extends SvelteComponentTyped<{
|
|
9
|
+
label?: string;
|
|
9
10
|
class?: string;
|
|
10
11
|
disabled?: boolean;
|
|
11
12
|
name?: string;
|
|
@@ -26,10 +27,11 @@ export type CheckboxSlots = typeof __propDef.slots;
|
|
|
26
27
|
import { SvelteComponentTyped } from "svelte";
|
|
27
28
|
declare const __propDef: {
|
|
28
29
|
props: {
|
|
30
|
+
label?: string | null;
|
|
29
31
|
class?: string;
|
|
30
32
|
disabled?: boolean;
|
|
31
33
|
name?: string;
|
|
32
|
-
value?:
|
|
34
|
+
value?: string | null;
|
|
33
35
|
checked?: (boolean | string | undefined);
|
|
34
36
|
indeterminate?: boolean;
|
|
35
37
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
@see https://w3c.github.io/aria/#dialog
|
|
4
|
-
@see https://
|
|
4
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
7
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* CSS class name on the button.
|
|
15
|
-
* @type {
|
|
15
|
+
* @type {string}
|
|
16
16
|
*/
|
|
17
17
|
let className = '';
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Width of the dialog.
|
|
27
|
-
* @type {('small'|'medium'|'large')}
|
|
27
|
+
* @type {('small' | 'medium' | 'large' | 'x-large')}
|
|
28
28
|
*/
|
|
29
29
|
export let size = 'medium';
|
|
30
30
|
|
|
@@ -54,6 +54,9 @@
|
|
|
54
54
|
let showDialog = false;
|
|
55
55
|
let showContent = false;
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
57
60
|
const openDialog = async () => {
|
|
58
61
|
(document.querySelector('.sui.app-shell') || document.body).appendChild(dialog);
|
|
59
62
|
showContent = true;
|
|
@@ -69,6 +72,9 @@
|
|
|
69
72
|
});
|
|
70
73
|
};
|
|
71
74
|
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
72
78
|
const closeDialog = async () => {
|
|
73
79
|
showDialog = false;
|
|
74
80
|
|
|
@@ -91,6 +97,9 @@
|
|
|
91
97
|
dialog?.remove();
|
|
92
98
|
};
|
|
93
99
|
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
94
103
|
const toggleDialog = () => {
|
|
95
104
|
if (dialog) {
|
|
96
105
|
if (open) {
|
|
@@ -102,6 +111,7 @@
|
|
|
102
111
|
};
|
|
103
112
|
|
|
104
113
|
// Call the function only when the `open` prop is changed
|
|
114
|
+
// @ts-ignore
|
|
105
115
|
$: toggleDialog(open);
|
|
106
116
|
|
|
107
117
|
onMount(() => {
|
|
@@ -121,7 +131,7 @@
|
|
|
121
131
|
class="sui dialog {className} {size}"
|
|
122
132
|
class:open={showDialog}
|
|
123
133
|
on:click={({ target }) => {
|
|
124
|
-
if (closeOnBackdropClick && target?.matches('dialog')) {
|
|
134
|
+
if (closeOnBackdropClick && /** @type {HTMLElement?} */ (target)?.matches('dialog')) {
|
|
125
135
|
dialog.returnValue = 'cancel';
|
|
126
136
|
open = false;
|
|
127
137
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} DialogSlots */
|
|
4
4
|
/**
|
|
5
5
|
* @see https://w3c.github.io/aria/#dialog
|
|
6
|
-
* @see https://
|
|
6
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
7
7
|
*/
|
|
8
8
|
export default class Dialog extends SvelteComponentTyped<{
|
|
9
9
|
title?: string;
|
|
10
10
|
open?: boolean;
|
|
11
11
|
class?: string;
|
|
12
|
-
size?: "small" | "medium" | "large";
|
|
12
|
+
size?: "small" | "medium" | "large" | "x-large";
|
|
13
13
|
modal?: boolean;
|
|
14
14
|
showCancel?: boolean;
|
|
15
15
|
showOk?: boolean;
|
|
@@ -43,7 +43,7 @@ declare const __propDef: {
|
|
|
43
43
|
title?: string;
|
|
44
44
|
open?: boolean;
|
|
45
45
|
class?: string;
|
|
46
|
-
size?: ('small' | 'medium' | 'large');
|
|
46
|
+
size?: ('small' | 'medium' | 'large' | 'x-large');
|
|
47
47
|
modal?: boolean;
|
|
48
48
|
showCancel?: boolean;
|
|
49
49
|
showOk?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
3
|
@see https://w3c.github.io/aria/#dialog
|
|
4
|
-
@see https://
|
|
4
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
5
5
|
-->
|
|
6
6
|
<script>
|
|
7
7
|
import { createEventDispatcher, onMount } from 'svelte';
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* CSS class name on the button.
|
|
15
|
-
* @type {
|
|
15
|
+
* @type {string}
|
|
16
16
|
*/
|
|
17
17
|
let className = '';
|
|
18
18
|
|
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
|
|
62
62
|
$: orientation = position === 'right' || position === 'left' ? 'vertical' : 'horizontal';
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
64
67
|
const openDialog = async () => {
|
|
65
68
|
(document.querySelector('.sui.app-shell') || document.body).appendChild(dialog);
|
|
66
69
|
showContent = true;
|
|
@@ -71,6 +74,9 @@
|
|
|
71
74
|
});
|
|
72
75
|
};
|
|
73
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
74
80
|
const closeDialog = async () => {
|
|
75
81
|
showDialog = false;
|
|
76
82
|
|
|
@@ -93,6 +99,9 @@
|
|
|
93
99
|
dialog?.remove();
|
|
94
100
|
};
|
|
95
101
|
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
96
105
|
const toggleDialog = () => {
|
|
97
106
|
if (dialog) {
|
|
98
107
|
if (open) {
|
|
@@ -104,6 +113,7 @@
|
|
|
104
113
|
};
|
|
105
114
|
|
|
106
115
|
// Call the function only when the `open` prop is changed
|
|
116
|
+
// @ts-ignore
|
|
107
117
|
$: toggleDialog(open);
|
|
108
118
|
|
|
109
119
|
onMount(() => {
|
|
@@ -123,7 +133,7 @@
|
|
|
123
133
|
class="sui dialog {className} {size} {position} {orientation}"
|
|
124
134
|
class:open={showDialog}
|
|
125
135
|
on:click={({ target }) => {
|
|
126
|
-
if (closeOnBackdropClick && target?.matches('dialog')) {
|
|
136
|
+
if (closeOnBackdropClick && /** @type {HTMLElement?} */ (target)?.matches('dialog')) {
|
|
127
137
|
dialog.returnValue = 'cancel';
|
|
128
138
|
open = false;
|
|
129
139
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/** @typedef {typeof __propDef.slots} DrawerSlots */
|
|
4
4
|
/**
|
|
5
5
|
* @see https://w3c.github.io/aria/#dialog
|
|
6
|
-
* @see https://
|
|
6
|
+
* @see https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/
|
|
7
7
|
*/
|
|
8
8
|
export default class Drawer extends SvelteComponentTyped<{
|
|
9
9
|
title?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
@component
|
|
3
|
-
@see https://
|
|
3
|
+
@see https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/
|
|
4
4
|
-->
|
|
5
5
|
<script>
|
|
6
6
|
import Popup from '../util/popup.svelte';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* CSS class name on the button.
|
|
11
|
-
* @type {
|
|
11
|
+
* @type {string}
|
|
12
12
|
*/
|
|
13
13
|
let className = '';
|
|
14
14
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
if (members.length) {
|
|
45
|
-
(key === 'ArrowUp' ? members.pop() : members.shift()).focus();
|
|
45
|
+
/** @type {HTMLElement} */ (key === 'ArrowUp' ? members.pop() : members.shift()).focus();
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/** @typedef {typeof __propDef.props} MenuButtonProps */
|
|
2
2
|
/** @typedef {typeof __propDef.events} MenuButtonEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} MenuButtonSlots */
|
|
4
|
-
/** @see https://
|
|
4
|
+
/** @see https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/ */
|
|
5
5
|
export default class MenuButton extends SvelteComponentTyped<{
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
class?: string;
|
|
8
|
-
popupPosition?:
|
|
8
|
+
popupPosition?: PopupPosition;
|
|
9
9
|
}, {
|
|
10
10
|
[evt: string]: CustomEvent<any>;
|
|
11
11
|
}, {
|
|
@@ -27,7 +27,7 @@ declare const __propDef: {
|
|
|
27
27
|
props: {
|
|
28
28
|
[x: string]: any;
|
|
29
29
|
class?: string;
|
|
30
|
-
popupPosition?:
|
|
30
|
+
popupPosition?: PopupPosition;
|
|
31
31
|
};
|
|
32
32
|
events: {
|
|
33
33
|
[evt: string]: CustomEvent<any>;
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* CSS class name on the button.
|
|
13
|
-
* @type {
|
|
13
|
+
* @type {string}
|
|
14
14
|
*/
|
|
15
15
|
let className = '';
|
|
16
16
|
|
|
17
17
|
export { className as class };
|
|
18
18
|
|
|
19
|
-
/** @type {
|
|
19
|
+
/** @type {string?} */
|
|
20
20
|
export let value = undefined;
|
|
21
21
|
|
|
22
22
|
export let disabled = false;
|
|
@@ -24,22 +24,32 @@
|
|
|
24
24
|
export let max = undefined;
|
|
25
25
|
export let step = 1;
|
|
26
26
|
|
|
27
|
+
$: maximumFractionDigits = String(step).split('.')[1]?.length || 0;
|
|
28
|
+
$: isMin = typeof min === 'number' && Number(value || 0) <= min;
|
|
29
|
+
$: isMax = typeof max === 'number' && Number(value || 0) >= max;
|
|
30
|
+
|
|
27
31
|
let component;
|
|
28
32
|
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
29
36
|
const decrease = () => {
|
|
30
|
-
if (
|
|
37
|
+
if (isMin) {
|
|
31
38
|
return;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
value =
|
|
41
|
+
value = Number(Number(value || 0) - step).toFixed(maximumFractionDigits);
|
|
35
42
|
};
|
|
36
43
|
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
37
47
|
const increase = () => {
|
|
38
|
-
if (
|
|
48
|
+
if (isMax) {
|
|
39
49
|
return;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
value =
|
|
52
|
+
value = Number(Number(value || 0) + step).toFixed(maximumFractionDigits);
|
|
43
53
|
};
|
|
44
54
|
</script>
|
|
45
55
|
|
|
@@ -70,7 +80,7 @@
|
|
|
70
80
|
/>
|
|
71
81
|
<Button
|
|
72
82
|
class="iconic"
|
|
73
|
-
disabled={disabled || Number.isNaN(Number(value))}
|
|
83
|
+
disabled={disabled || Number.isNaN(Number(value)) || isMin}
|
|
74
84
|
on:click={() => {
|
|
75
85
|
decrease();
|
|
76
86
|
}}
|
|
@@ -79,7 +89,7 @@
|
|
|
79
89
|
</Button>
|
|
80
90
|
<Button
|
|
81
91
|
class="iconic"
|
|
82
|
-
disabled={disabled || Number.isNaN(Number(value))}
|
|
92
|
+
disabled={disabled || Number.isNaN(Number(value)) || isMax}
|
|
83
93
|
on:click={() => {
|
|
84
94
|
increase();
|
|
85
95
|
}}
|
|
@@ -100,7 +110,7 @@
|
|
|
100
110
|
flex: none;
|
|
101
111
|
margin-left: -1px;
|
|
102
112
|
border-width: 1px;
|
|
103
|
-
border-color: var(--control-border-color);
|
|
113
|
+
border-color: var(--secondary-control-border-color);
|
|
104
114
|
width: 32px;
|
|
105
115
|
height: var(--input--medium--height);
|
|
106
116
|
}
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* CSS class name on the button.
|
|
13
|
-
* @type {
|
|
13
|
+
* @type {string}
|
|
14
14
|
*/
|
|
15
15
|
let className = '';
|
|
16
16
|
|
|
17
17
|
export { className as class };
|
|
18
18
|
|
|
19
|
-
/** @type {
|
|
19
|
+
/** @type {string?} */
|
|
20
20
|
export let value = undefined;
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
flex: none;
|
|
70
70
|
margin-left: -1px;
|
|
71
71
|
border-width: 1px;
|
|
72
|
-
border-color: var(--control-border-color);
|
|
72
|
+
border-color: var(--secondary-control-border-color);
|
|
73
73
|
height: var(--input--medium--height);
|
|
74
74
|
aspect-ratio: 1/1;
|
|
75
75
|
}
|