@sveltia/ui 0.6.6 → 0.7.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.svelte +109 -75
- package/package/components/button/button.svelte.d.ts +45 -18
- package/package/components/button/select-button-group.svelte +51 -30
- package/package/components/button/select-button-group.svelte.d.ts +12 -8
- package/package/components/button/select-button.svelte +50 -2
- package/package/components/button/select-button.svelte.d.ts +16 -0
- package/package/components/calendar/calendar.svelte +5 -3
- package/package/components/checkbox/checkbox-group.svelte +28 -10
- package/package/components/checkbox/checkbox-group.svelte.d.ts +4 -2
- package/package/components/checkbox/checkbox.svelte +114 -71
- package/package/components/checkbox/checkbox.svelte.d.ts +13 -7
- package/package/components/dialog/dialog.svelte +36 -16
- package/package/components/dialog/dialog.svelte.d.ts +0 -4
- package/package/components/disclosure/disclosure.svelte +48 -21
- package/package/components/disclosure/disclosure.svelte.d.ts +19 -0
- package/package/components/divider/divider.svelte +14 -6
- package/package/components/divider/divider.svelte.d.ts +3 -1
- package/package/components/divider/spacer.svelte +17 -5
- package/package/components/divider/spacer.svelte.d.ts +2 -0
- package/package/components/drawer/drawer.svelte +12 -5
- package/package/components/listbox/listbox.svelte +55 -20
- package/package/components/listbox/listbox.svelte.d.ts +12 -13
- package/package/components/listbox/option-group.svelte +22 -5
- package/package/components/listbox/option-group.svelte.d.ts +4 -0
- package/package/components/listbox/option.svelte +41 -14
- package/package/components/listbox/option.svelte.d.ts +9 -3
- package/package/components/menu/menu-button.svelte +51 -5
- package/package/components/menu/menu-button.svelte.d.ts +15 -0
- package/package/components/menu/menu-item-checkbox.svelte +41 -2
- package/package/components/menu/menu-item-checkbox.svelte.d.ts +14 -0
- package/package/components/menu/menu-item-group.svelte +26 -9
- package/package/components/menu/menu-item-group.svelte.d.ts +4 -2
- package/package/components/menu/menu-item-radio.svelte +47 -3
- package/package/components/menu/menu-item-radio.svelte.d.ts +14 -0
- package/package/components/menu/menu-item.svelte +48 -21
- package/package/components/menu/menu-item.svelte.d.ts +10 -4
- package/package/components/menu/menu.svelte +17 -9
- package/package/components/menu/menu.svelte.d.ts +8 -8
- package/package/components/radio/radio-group.svelte +50 -11
- package/package/components/radio/radio-group.svelte.d.ts +13 -5
- package/package/components/radio/radio.svelte +76 -45
- package/package/components/radio/radio.svelte.d.ts +11 -5
- package/package/components/select/combobox.svelte +58 -28
- package/package/components/select/combobox.svelte.d.ts +8 -2
- package/package/components/select/select.svelte +31 -6
- package/package/components/select/select.svelte.d.ts +10 -2
- package/package/components/slider/slider.svelte +158 -70
- package/package/components/slider/slider.svelte.d.ts +12 -4
- package/package/components/switch/switch.svelte +71 -29
- package/package/components/switch/switch.svelte.d.ts +11 -3
- package/package/components/table/table-row-header.svelte +1 -0
- package/package/components/table/table-row.svelte +16 -3
- package/package/components/table/table-row.svelte.d.ts +4 -0
- package/package/components/table/table.svelte +2 -1
- package/package/components/table/table.svelte.d.ts +4 -0
- package/package/components/tabs/tab-list.svelte +33 -16
- package/package/components/tabs/tab-list.svelte.d.ts +8 -18
- package/package/components/tabs/tab-panel.svelte +1 -2
- package/package/components/tabs/tab.svelte +25 -3
- package/package/components/tabs/tab.svelte.d.ts +10 -0
- package/package/components/text-field/markdown-editor.svelte +54 -22
- package/package/components/text-field/markdown-editor.svelte.d.ts +11 -1
- package/package/components/text-field/number-input.svelte +66 -15
- package/package/components/text-field/number-input.svelte.d.ts +13 -5
- package/package/components/text-field/password-input.svelte +42 -9
- package/package/components/text-field/password-input.svelte.d.ts +11 -1
- package/package/components/text-field/search-bar.svelte +67 -17
- package/package/components/text-field/search-bar.svelte.d.ts +26 -1
- package/package/components/text-field/text-area.svelte +55 -21
- package/package/components/text-field/text-area.svelte.d.ts +12 -19
- package/package/components/text-field/text-input.svelte +71 -46
- package/package/components/text-field/text-input.svelte.d.ts +34 -14
- package/package/components/toast/toast.svelte +119 -0
- package/package/components/toast/toast.svelte.d.ts +36 -0
- package/package/components/toolbar/toolbar.svelte +33 -10
- package/package/components/toolbar/toolbar.svelte.d.ts +7 -1
- package/package/components/util/app-shell.svelte +133 -69
- package/package/components/util/group.svelte +21 -6
- package/package/components/util/group.svelte.d.ts +4 -2
- package/package/components/util/popup.svelte +62 -10
- package/package/components/util/popup.svelte.d.ts +13 -3
- package/package/components/util/portal.svelte +1 -1
- package/package/components/util/portal.svelte.d.ts +2 -0
- package/package/index.d.ts +2 -0
- package/package/index.js +4 -3
- package/package/{components/util → services}/events.d.ts +1 -1
- package/package/{components/util → services}/events.js +3 -2
- package/package/services/group.d.ts +1 -0
- package/package/{components/util → services}/group.js +15 -13
- package/package/{components/util → services}/util.d.ts +1 -1
- package/package/{components/util → services}/util.js +2 -2
- package/package/styles/core.scss +36 -7
- package/package/styles/variables.scss +98 -62
- package/package.json +37 -29
- package/package/components/util/group.d.ts +0 -1
- /package/package/{components/util → services}/popup.d.ts +0 -0
- /package/package/{components/util → services}/popup.js +0 -0
|
@@ -14,33 +14,78 @@
|
|
|
14
14
|
import TextInput from './text-input.svelte';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The `class` attribute on the wrapper element.
|
|
18
18
|
* @type {string}
|
|
19
19
|
*/
|
|
20
20
|
let className = '';
|
|
21
|
-
|
|
22
21
|
export { className as class };
|
|
22
|
+
/**
|
|
23
|
+
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
24
|
+
* @type {boolean | undefined}
|
|
25
|
+
*/
|
|
26
|
+
export let hidden = undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
29
|
+
* @type {boolean}
|
|
30
|
+
*/
|
|
31
|
+
export let disabled = false;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to disable the widget. An alias of `aria-readonly` attribute.
|
|
34
|
+
* @type {boolean}
|
|
35
|
+
*/
|
|
36
|
+
export let readonly = false;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to disable the widget. An alias of the `aria-required` attribute.
|
|
39
|
+
* @type {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export let required = false;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to disable the widget. An alias of the `aria-invalid` attribute.
|
|
44
|
+
* @type {boolean}
|
|
45
|
+
*/
|
|
46
|
+
export let invalid = false;
|
|
47
|
+
/**
|
|
48
|
+
* Input value.
|
|
49
|
+
* @type {string | undefined}
|
|
50
|
+
*/
|
|
51
|
+
export let value = undefined;
|
|
23
52
|
|
|
24
|
-
/**
|
|
25
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Reference to the `TextInput` component.
|
|
55
|
+
* @type {TextInput | undefined}
|
|
56
|
+
*/
|
|
57
|
+
let inputComponent;
|
|
26
58
|
|
|
27
|
-
|
|
59
|
+
$: input = inputComponent?.element;
|
|
28
60
|
|
|
29
61
|
/**
|
|
30
62
|
* Move focus to the `<input>` element.
|
|
31
63
|
*/
|
|
32
64
|
export const focus = () => {
|
|
33
|
-
input?.
|
|
65
|
+
input?.focus();
|
|
34
66
|
};
|
|
35
67
|
</script>
|
|
36
68
|
|
|
37
|
-
<div
|
|
38
|
-
|
|
69
|
+
<div
|
|
70
|
+
class="sui search-bar {className}"
|
|
71
|
+
class:disabled
|
|
72
|
+
role="search"
|
|
73
|
+
hidden={hidden || undefined}
|
|
74
|
+
aria-hidden={hidden}
|
|
75
|
+
>
|
|
76
|
+
<span>
|
|
77
|
+
<Icon name="search" />
|
|
78
|
+
</span>
|
|
39
79
|
<TextInput
|
|
40
|
-
bind:this={input}
|
|
41
80
|
bind:value
|
|
42
81
|
role="searchbox"
|
|
82
|
+
{hidden}
|
|
83
|
+
{disabled}
|
|
84
|
+
{readonly}
|
|
85
|
+
{required}
|
|
86
|
+
{invalid}
|
|
43
87
|
{...$$restProps}
|
|
88
|
+
bind:this={inputComponent}
|
|
44
89
|
on:input
|
|
45
90
|
on:keydown
|
|
46
91
|
on:keyup
|
|
@@ -49,14 +94,14 @@
|
|
|
49
94
|
/>
|
|
50
95
|
{#if value}
|
|
51
96
|
<Button
|
|
52
|
-
|
|
97
|
+
iconic
|
|
53
98
|
on:click={() => {
|
|
54
99
|
value = '';
|
|
55
|
-
input
|
|
100
|
+
input?.focus();
|
|
56
101
|
window.requestIdleCallback(() => {
|
|
57
|
-
input
|
|
58
|
-
input
|
|
59
|
-
input
|
|
102
|
+
input?.dispatchEvent(new KeyboardEvent('input'));
|
|
103
|
+
input?.dispatchEvent(new KeyboardEvent('keypress'));
|
|
104
|
+
input?.dispatchEvent(new KeyboardEvent('change'));
|
|
60
105
|
});
|
|
61
106
|
}}
|
|
62
107
|
>
|
|
@@ -74,10 +119,15 @@
|
|
|
74
119
|
font-size: var(--sui-font-size-xx-large);
|
|
75
120
|
opacity: 0.5;
|
|
76
121
|
}
|
|
77
|
-
[role=search] >
|
|
122
|
+
[role=search] > span {
|
|
78
123
|
position: absolute;
|
|
79
|
-
inset:
|
|
124
|
+
inset: 0 auto 0 0;
|
|
80
125
|
z-index: 2;
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: center;
|
|
129
|
+
width: var(--sui-button-medium-height);
|
|
130
|
+
height: var(--sui-button-medium-height);
|
|
81
131
|
}
|
|
82
132
|
[role=search] > :global(button) {
|
|
83
133
|
position: absolute;
|
|
@@ -89,6 +139,6 @@
|
|
|
89
139
|
inset: 0 36px;
|
|
90
140
|
}
|
|
91
141
|
[role=search] :global(input) {
|
|
92
|
-
padding: 0
|
|
142
|
+
padding: 0 var(--sui-button-medium-height) !important;
|
|
93
143
|
width: 100%;
|
|
94
144
|
}</style>
|
|
@@ -11,7 +11,12 @@ export default class SearchBar extends SvelteComponent<{
|
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string;
|
|
13
13
|
focus?: () => void;
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
required?: boolean;
|
|
14
17
|
value?: string;
|
|
18
|
+
hidden?: boolean;
|
|
19
|
+
readonly?: boolean;
|
|
15
20
|
}, {
|
|
16
21
|
input: Event;
|
|
17
22
|
keydown: KeyboardEvent;
|
|
@@ -26,6 +31,21 @@ export default class SearchBar extends SvelteComponent<{
|
|
|
26
31
|
set class(arg: string);
|
|
27
32
|
get class(): string;
|
|
28
33
|
/**accessor*/
|
|
34
|
+
set hidden(arg: boolean);
|
|
35
|
+
get hidden(): boolean;
|
|
36
|
+
/**accessor*/
|
|
37
|
+
set disabled(arg: boolean);
|
|
38
|
+
get disabled(): boolean;
|
|
39
|
+
/**accessor*/
|
|
40
|
+
set readonly(arg: boolean);
|
|
41
|
+
get readonly(): boolean;
|
|
42
|
+
/**accessor*/
|
|
43
|
+
set required(arg: boolean);
|
|
44
|
+
get required(): boolean;
|
|
45
|
+
/**accessor*/
|
|
46
|
+
set invalid(arg: boolean);
|
|
47
|
+
get invalid(): boolean;
|
|
48
|
+
/**accessor*/
|
|
29
49
|
set value(arg: string);
|
|
30
50
|
get value(): string;
|
|
31
51
|
}
|
|
@@ -38,7 +58,12 @@ declare const __propDef: {
|
|
|
38
58
|
[x: string]: any;
|
|
39
59
|
class?: string;
|
|
40
60
|
focus?: () => void;
|
|
41
|
-
|
|
61
|
+
invalid?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
required?: boolean;
|
|
64
|
+
value?: string | undefined;
|
|
65
|
+
hidden?: boolean | undefined;
|
|
66
|
+
readonly?: boolean;
|
|
42
67
|
};
|
|
43
68
|
events: {
|
|
44
69
|
input: Event;
|
|
@@ -5,41 +5,74 @@
|
|
|
5
5
|
@see https://w3c.github.io/aria/#textbox
|
|
6
6
|
@see https://css-tricks.com/the-cleanest-trick-for-autogrowing-textareas/
|
|
7
7
|
-->
|
|
8
|
-
<svelte:options accessors={true} />
|
|
9
|
-
|
|
10
8
|
<script>
|
|
11
9
|
/**
|
|
12
|
-
*
|
|
10
|
+
* The `class` attribute on the wrapper element.
|
|
13
11
|
* @type {string}
|
|
14
12
|
*/
|
|
15
13
|
let className = '';
|
|
16
|
-
|
|
17
14
|
export { className as class };
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export let
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
17
|
+
* @type {boolean | undefined}
|
|
18
|
+
*/
|
|
19
|
+
export let hidden = undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
22
|
+
* @type {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export let disabled = false;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to disable the widget. An alias of `aria-readonly` attribute.
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
*/
|
|
29
|
+
export let readonly = false;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to disable the widget. An alias of the `aria-required` attribute.
|
|
32
|
+
* @type {boolean}
|
|
33
|
+
*/
|
|
34
|
+
export let required = false;
|
|
35
|
+
/**
|
|
36
|
+
* Whether to disable the widget. An alias of the `aria-invalid` attribute.
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
export let invalid = false;
|
|
40
|
+
/**
|
|
41
|
+
* The `name` attribute on the `<textarea>` element.
|
|
42
|
+
* @type {string | undefined}
|
|
43
|
+
*/
|
|
44
|
+
export let name = undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Input value.
|
|
47
|
+
* @type {string | undefined}
|
|
48
|
+
*/
|
|
25
49
|
export let value = undefined;
|
|
26
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Whether to automatically resize the `<textarea>` based on the content.
|
|
52
|
+
* @type {boolean}
|
|
53
|
+
*/
|
|
27
54
|
export let autoResize = false;
|
|
28
55
|
</script>
|
|
29
56
|
|
|
30
|
-
<div class="sui text-area {className}">
|
|
57
|
+
<div class="sui text-area {className}" class:disabled hidden={hidden || undefined}>
|
|
31
58
|
<textarea
|
|
32
|
-
|
|
59
|
+
{name}
|
|
60
|
+
bind:value
|
|
61
|
+
disabled={disabled || undefined}
|
|
62
|
+
readonly={readonly || undefined}
|
|
63
|
+
aria-hidden={hidden}
|
|
64
|
+
aria-disabled={disabled}
|
|
65
|
+
aria-readonly={readonly}
|
|
66
|
+
aria-required={required}
|
|
67
|
+
aria-invalid={invalid}
|
|
33
68
|
{...$$restProps}
|
|
34
69
|
class:auto-resize={autoResize}
|
|
35
|
-
bind:this={element}
|
|
36
|
-
bind:value
|
|
37
70
|
on:click
|
|
38
71
|
on:input
|
|
39
72
|
on:keypress
|
|
40
73
|
/>
|
|
41
74
|
{#if autoResize}
|
|
42
|
-
<div class="clone" aria-hidden="true">{value}</div>
|
|
75
|
+
<div class="clone" aria-hidden="true">{value ?? ''}</div>
|
|
43
76
|
{/if}
|
|
44
77
|
</div>
|
|
45
78
|
|
|
@@ -54,8 +87,8 @@ textarea,
|
|
|
54
87
|
display: block;
|
|
55
88
|
margin: 0;
|
|
56
89
|
border-width: 1px;
|
|
57
|
-
border-color: var(--sui-
|
|
58
|
-
border-radius: var(--sui-textbox-
|
|
90
|
+
border-color: var(--sui-textbox-border-color);
|
|
91
|
+
border-radius: var(--sui-textbox-border-radius);
|
|
59
92
|
padding: 8px;
|
|
60
93
|
width: 100%;
|
|
61
94
|
min-height: 8em;
|
|
@@ -77,8 +110,6 @@ textarea:focus,
|
|
|
77
110
|
textarea:disabled,
|
|
78
111
|
.clone:disabled {
|
|
79
112
|
background-color: var(--sui-disabled-background-color);
|
|
80
|
-
opacity: 0.4;
|
|
81
|
-
cursor: default;
|
|
82
113
|
}
|
|
83
114
|
|
|
84
115
|
textarea {
|
|
@@ -88,6 +119,9 @@ textarea.auto-resize {
|
|
|
88
119
|
overflow: hidden;
|
|
89
120
|
resize: none;
|
|
90
121
|
}
|
|
122
|
+
textarea[aria-invalid=true] {
|
|
123
|
+
border-color: var(--sui-error-foreground-color);
|
|
124
|
+
}
|
|
91
125
|
|
|
92
126
|
.clone {
|
|
93
127
|
visibility: hidden;
|
|
@@ -11,8 +11,12 @@ export default class TextArea extends SvelteComponent<{
|
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
class?: string;
|
|
13
13
|
name?: string;
|
|
14
|
+
invalid?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
required?: boolean;
|
|
14
17
|
value?: string;
|
|
15
|
-
|
|
18
|
+
hidden?: boolean;
|
|
19
|
+
readonly?: boolean;
|
|
16
20
|
autoResize?: boolean;
|
|
17
21
|
}, {
|
|
18
22
|
click: MouseEvent;
|
|
@@ -21,21 +25,6 @@ export default class TextArea extends SvelteComponent<{
|
|
|
21
25
|
} & {
|
|
22
26
|
[evt: string]: CustomEvent<any>;
|
|
23
27
|
}, {}> {
|
|
24
|
-
/**accessor*/
|
|
25
|
-
set class(arg: string);
|
|
26
|
-
get class(): string;
|
|
27
|
-
/**accessor*/
|
|
28
|
-
set element(arg: HTMLTextAreaElement);
|
|
29
|
-
get element(): HTMLTextAreaElement;
|
|
30
|
-
/**accessor*/
|
|
31
|
-
set name(arg: string);
|
|
32
|
-
get name(): string;
|
|
33
|
-
/**accessor*/
|
|
34
|
-
set value(arg: string);
|
|
35
|
-
get value(): string;
|
|
36
|
-
/**accessor*/
|
|
37
|
-
set autoResize(arg: boolean);
|
|
38
|
-
get autoResize(): boolean;
|
|
39
28
|
}
|
|
40
29
|
export type TextAreaProps = typeof __propDef.props;
|
|
41
30
|
export type TextAreaEvents = typeof __propDef.events;
|
|
@@ -45,9 +34,13 @@ declare const __propDef: {
|
|
|
45
34
|
props: {
|
|
46
35
|
[x: string]: any;
|
|
47
36
|
class?: string;
|
|
48
|
-
name?: string;
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
name?: string | undefined;
|
|
38
|
+
invalid?: boolean;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
value?: string | undefined;
|
|
42
|
+
hidden?: boolean | undefined;
|
|
43
|
+
readonly?: boolean;
|
|
51
44
|
autoResize?: boolean;
|
|
52
45
|
};
|
|
53
46
|
events: {
|
|
@@ -7,64 +7,91 @@
|
|
|
7
7
|
<svelte:options accessors={true} />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
10
|
-
import { activateKeyShortcuts } from '
|
|
11
|
-
import { getRandomId } from '
|
|
10
|
+
import { activateKeyShortcuts } from '../../services/events';
|
|
11
|
+
import { getRandomId } from '../../services/util';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Reference to the `<input>` element.
|
|
15
|
+
* @type {HTMLInputElement | undefined}
|
|
16
|
+
*/
|
|
17
|
+
export let element = undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The `class` attribute on the wrapper element.
|
|
15
20
|
* @type {string}
|
|
16
21
|
*/
|
|
17
22
|
let className = '';
|
|
18
|
-
|
|
19
23
|
export { className as class };
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/** @type {('textbox'|'searchbox'|'combobox'|'spinbutton')} */
|
|
24
|
+
/**
|
|
25
|
+
* The `role` attribute on the `<input>` element.
|
|
26
|
+
* @type {'textbox' | 'searchbox' | 'combobox' | 'spinbutton'}
|
|
27
|
+
*/
|
|
25
28
|
export let role = 'textbox';
|
|
26
|
-
|
|
27
29
|
/**
|
|
28
|
-
* Whether the
|
|
30
|
+
* Whether to hide the widget. An alias of the `aria-hidden` attribute.
|
|
31
|
+
* @type {boolean | undefined}
|
|
32
|
+
*/
|
|
33
|
+
export let hidden = undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to disable the widget. An alias of the `aria-disabled` attribute.
|
|
36
|
+
* @type {boolean}
|
|
29
37
|
*/
|
|
30
|
-
export let readOnly = false;
|
|
31
|
-
|
|
32
38
|
export let disabled = false;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Whether to disable the widget. An alias of `aria-readonly` attribute.
|
|
41
|
+
* @type {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export let readonly = false;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to disable the widget. An alias of the `aria-required` attribute.
|
|
46
|
+
* @type {boolean}
|
|
47
|
+
*/
|
|
48
|
+
export let required = false;
|
|
49
|
+
/**
|
|
50
|
+
* Whether to disable the widget. An alias of the `aria-invalid` attribute.
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
*/
|
|
53
|
+
export let invalid = false;
|
|
54
|
+
/**
|
|
55
|
+
* Keyboard shortcuts. An alias of the `aria-keyshortcuts` attribute. Accepts the special `Accel`
|
|
56
|
+
* key, which will be replaced with `Control` or `Meta` depending on the user’s operating system.
|
|
57
|
+
* @type {string | undefined}
|
|
58
|
+
*/
|
|
59
|
+
export let keyShortcuts = undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The `name` attribute on the `<input>` element.
|
|
62
|
+
* @type {string | undefined}
|
|
63
|
+
*/
|
|
64
|
+
export let name = undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Input value.
|
|
67
|
+
* @type {string | number | undefined}
|
|
68
|
+
*/
|
|
37
69
|
export let value = undefined;
|
|
38
|
-
|
|
39
70
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
71
|
+
* Whether to display `aria-label` over the `<input>` element if it’s empty, just like how the
|
|
72
|
+
* HTML `placeholder` attribute works.
|
|
73
|
+
* @type {boolean}
|
|
42
74
|
*/
|
|
43
|
-
export let
|
|
75
|
+
export let showInlineLabel = false;
|
|
44
76
|
|
|
45
77
|
const id = getRandomId('input');
|
|
46
|
-
let ariaLabel = '';
|
|
47
78
|
|
|
48
|
-
$:
|
|
49
|
-
// Replace `aria-label` with a visible label if `<input placeholder>` is not defined
|
|
50
|
-
if ('aria-label' in $$restProps && !('placeholder' in $$restProps)) {
|
|
51
|
-
ariaLabel = $$restProps['aria-label'];
|
|
52
|
-
delete $$restProps['aria-label'];
|
|
53
|
-
$$restProps['aria-labelledby'] = `${id}-label`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
79
|
+
$: ariaLabel = $$restProps['aria-label'];
|
|
56
80
|
</script>
|
|
57
81
|
|
|
58
|
-
<div class="sui text-input {className}">
|
|
82
|
+
<div class="sui text-input {className}" class:disabled hidden={hidden || undefined}>
|
|
59
83
|
<input
|
|
60
84
|
type="text"
|
|
61
85
|
{role}
|
|
62
86
|
name={name || undefined}
|
|
63
87
|
tabindex={disabled ? -1 : 0}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
aria-disabled={disabled
|
|
88
|
+
disabled={disabled || undefined}
|
|
89
|
+
readonly={readonly || undefined}
|
|
90
|
+
aria-hidden={hidden}
|
|
91
|
+
aria-disabled={disabled}
|
|
92
|
+
aria-readonly={readonly}
|
|
93
|
+
aria-required={required}
|
|
94
|
+
aria-invalid={invalid}
|
|
68
95
|
{...$$restProps}
|
|
69
96
|
bind:this={element}
|
|
70
97
|
bind:value
|
|
@@ -75,8 +102,8 @@
|
|
|
75
102
|
on:change
|
|
76
103
|
use:activateKeyShortcuts={keyShortcuts}
|
|
77
104
|
/>
|
|
78
|
-
{#if ariaLabel}
|
|
79
|
-
<span id="{id}-label" class="label" class:hidden={!!value}>
|
|
105
|
+
{#if ariaLabel && showInlineLabel}
|
|
106
|
+
<span id="{id}-label" class="label" class:hidden={!!value} aria-hidden="true">
|
|
80
107
|
{ariaLabel}
|
|
81
108
|
</span>
|
|
82
109
|
{/if}
|
|
@@ -94,11 +121,11 @@ input {
|
|
|
94
121
|
display: inline-block;
|
|
95
122
|
flex: auto;
|
|
96
123
|
border-width: 1px;
|
|
97
|
-
border-color: var(--sui-
|
|
98
|
-
border-radius: var(--sui-textbox-
|
|
124
|
+
border-color: var(--sui-textbox-border-color);
|
|
125
|
+
border-radius: var(--sui-textbox-border-radius);
|
|
99
126
|
padding: 0 8px;
|
|
100
127
|
min-width: 0;
|
|
101
|
-
height: var(--sui-textbox-
|
|
128
|
+
height: var(--sui-textbox-height);
|
|
102
129
|
color: var(--sui-textbox-foreground-color);
|
|
103
130
|
background-color: var(--sui-textbox-background-color);
|
|
104
131
|
font-family: var(--sui-textbox-font-family);
|
|
@@ -111,22 +138,20 @@ input:focus {
|
|
|
111
138
|
}
|
|
112
139
|
input:read-only {
|
|
113
140
|
color: var(--sui-tertiary-foreground-color);
|
|
114
|
-
border-color: var(--sui-
|
|
141
|
+
border-color: var(--sui-textbox-border-color) !important;
|
|
115
142
|
}
|
|
116
143
|
input:disabled {
|
|
117
144
|
background-color: var(--sui-disabled-background-color);
|
|
118
|
-
opacity: 0.4;
|
|
119
|
-
cursor: default;
|
|
120
145
|
}
|
|
121
146
|
input[aria-invalid=true] {
|
|
122
|
-
border-color:
|
|
147
|
+
border-color: var(--sui-error-foreground-color);
|
|
123
148
|
}
|
|
124
149
|
input ~ :global(button) {
|
|
125
150
|
flex: none;
|
|
126
151
|
margin-left: -1px;
|
|
127
152
|
border-width: 1px;
|
|
128
|
-
border-color: var(--sui-
|
|
129
|
-
height: var(--sui-textbox-
|
|
153
|
+
border-color: var(--sui-textbox-border-color);
|
|
154
|
+
height: var(--sui-textbox-height);
|
|
130
155
|
aspect-ratio: 1/1;
|
|
131
156
|
}
|
|
132
157
|
input ~ :global(button):last-child {
|
|
@@ -10,12 +10,16 @@ export default class TextInput extends SvelteComponent<{
|
|
|
10
10
|
[x: string]: any;
|
|
11
11
|
class?: string;
|
|
12
12
|
name?: string;
|
|
13
|
+
invalid?: boolean;
|
|
13
14
|
disabled?: boolean;
|
|
14
|
-
|
|
15
|
+
required?: boolean;
|
|
15
16
|
value?: string | number;
|
|
17
|
+
hidden?: boolean;
|
|
16
18
|
element?: HTMLInputElement;
|
|
17
19
|
role?: "textbox" | "searchbox" | "combobox" | "spinbutton";
|
|
18
20
|
keyShortcuts?: string;
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
showInlineLabel?: boolean;
|
|
19
23
|
}, {
|
|
20
24
|
input: Event;
|
|
21
25
|
keydown: KeyboardEvent;
|
|
@@ -25,30 +29,42 @@ export default class TextInput extends SvelteComponent<{
|
|
|
25
29
|
} & {
|
|
26
30
|
[evt: string]: CustomEvent<any>;
|
|
27
31
|
}, {}> {
|
|
28
|
-
/**accessor*/
|
|
29
|
-
set class(arg: string);
|
|
30
|
-
get class(): string;
|
|
31
32
|
/**accessor*/
|
|
32
33
|
set element(arg: HTMLInputElement);
|
|
33
34
|
get element(): HTMLInputElement;
|
|
34
35
|
/**accessor*/
|
|
36
|
+
set class(arg: string);
|
|
37
|
+
get class(): string;
|
|
38
|
+
/**accessor*/
|
|
35
39
|
set role(arg: "textbox" | "searchbox" | "combobox" | "spinbutton");
|
|
36
40
|
get role(): "textbox" | "searchbox" | "combobox" | "spinbutton";
|
|
37
41
|
/**accessor*/
|
|
38
|
-
set
|
|
39
|
-
get
|
|
42
|
+
set hidden(arg: boolean);
|
|
43
|
+
get hidden(): boolean;
|
|
40
44
|
/**accessor*/
|
|
41
45
|
set disabled(arg: boolean);
|
|
42
46
|
get disabled(): boolean;
|
|
43
47
|
/**accessor*/
|
|
48
|
+
set readonly(arg: boolean);
|
|
49
|
+
get readonly(): boolean;
|
|
50
|
+
/**accessor*/
|
|
51
|
+
set required(arg: boolean);
|
|
52
|
+
get required(): boolean;
|
|
53
|
+
/**accessor*/
|
|
54
|
+
set invalid(arg: boolean);
|
|
55
|
+
get invalid(): boolean;
|
|
56
|
+
/**accessor*/
|
|
57
|
+
set keyShortcuts(arg: string);
|
|
58
|
+
get keyShortcuts(): string;
|
|
59
|
+
/**accessor*/
|
|
44
60
|
set name(arg: string);
|
|
45
61
|
get name(): string;
|
|
46
62
|
/**accessor*/
|
|
47
63
|
set value(arg: string | number);
|
|
48
64
|
get value(): string | number;
|
|
49
65
|
/**accessor*/
|
|
50
|
-
set
|
|
51
|
-
get
|
|
66
|
+
set showInlineLabel(arg: boolean);
|
|
67
|
+
get showInlineLabel(): boolean;
|
|
52
68
|
}
|
|
53
69
|
export type TextInputProps = typeof __propDef.props;
|
|
54
70
|
export type TextInputEvents = typeof __propDef.events;
|
|
@@ -58,13 +74,17 @@ declare const __propDef: {
|
|
|
58
74
|
props: {
|
|
59
75
|
[x: string]: any;
|
|
60
76
|
class?: string;
|
|
61
|
-
name?: string;
|
|
77
|
+
name?: string | undefined;
|
|
78
|
+
invalid?: boolean;
|
|
62
79
|
disabled?: boolean;
|
|
63
|
-
|
|
64
|
-
value?:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
required?: boolean;
|
|
81
|
+
value?: string | number | undefined;
|
|
82
|
+
hidden?: boolean | undefined;
|
|
83
|
+
element?: HTMLInputElement | undefined;
|
|
84
|
+
role?: 'textbox' | 'searchbox' | 'combobox' | 'spinbutton';
|
|
85
|
+
keyShortcuts?: string | undefined;
|
|
86
|
+
readonly?: boolean;
|
|
87
|
+
showInlineLabel?: boolean;
|
|
68
88
|
};
|
|
69
89
|
events: {
|
|
70
90
|
input: Event;
|