@sveltia/ui 0.2.0 → 0.2.2
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 +239 -0
- package/package/components/composite/calendar.svelte.d.ts +27 -0
- package/package/components/composite/checkbox-group.svelte +43 -0
- package/package/components/composite/checkbox-group.svelte.d.ts +34 -0
- package/package/components/composite/combobox.svelte +208 -0
- package/package/components/composite/combobox.svelte.d.ts +47 -0
- package/package/components/composite/disclosure.svelte +60 -0
- package/package/components/composite/disclosure.svelte.d.ts +35 -0
- package/package/components/composite/grid.svelte +24 -0
- package/package/components/composite/grid.svelte.d.ts +31 -0
- package/package/components/composite/listbox.svelte +63 -0
- package/package/components/composite/listbox.svelte.d.ts +52 -0
- package/package/components/composite/menu-item-group.svelte +31 -0
- package/package/components/composite/menu-item-group.svelte.d.ts +33 -0
- package/package/components/composite/menu.svelte +44 -0
- package/package/components/composite/menu.svelte.d.ts +41 -0
- package/package/components/composite/radio-button-group.svelte +45 -0
- package/package/components/composite/radio-button-group.svelte.d.ts +36 -0
- package/package/components/composite/select-button-group.svelte +71 -0
- package/package/components/composite/select-button-group.svelte.d.ts +44 -0
- package/package/components/composite/select.svelte +34 -0
- package/package/components/composite/select.svelte.d.ts +38 -0
- package/package/components/composite/tab-list.svelte +76 -0
- package/package/components/composite/tab-list.svelte.d.ts +55 -0
- package/package/components/core/button.svelte +222 -0
- package/package/components/core/button.svelte.d.ts +109 -0
- package/package/components/core/checkbox.svelte +114 -0
- package/package/components/core/checkbox.svelte.d.ts +45 -0
- package/package/components/core/dialog.svelte +288 -0
- package/package/components/core/dialog.svelte.d.ts +73 -0
- package/package/components/core/drawer.svelte +338 -0
- package/package/components/core/drawer.svelte.d.ts +59 -0
- package/package/components/core/grid-cell.svelte +14 -0
- package/package/components/core/grid-cell.svelte.d.ts +29 -0
- package/package/components/core/group.svelte +31 -0
- package/package/components/core/group.svelte.d.ts +33 -0
- package/package/components/core/icon.svelte +21 -0
- package/package/components/core/icon.svelte.d.ts +27 -0
- package/package/components/core/menu-button.svelte +57 -0
- package/package/components/core/menu-button.svelte.d.ts +46 -0
- package/package/components/core/menu-item-checkbox.svelte +24 -0
- package/package/components/core/menu-item-checkbox.svelte.d.ts +34 -0
- package/package/components/core/menu-item-radio.svelte +19 -0
- package/package/components/core/menu-item-radio.svelte.d.ts +34 -0
- package/package/components/core/menu-item.svelte +113 -0
- package/package/components/core/menu-item.svelte.d.ts +44 -0
- package/package/components/core/number-input.svelte +112 -0
- package/package/components/core/number-input.svelte.d.ts +42 -0
- package/package/components/core/option.svelte +65 -0
- package/package/components/core/option.svelte.d.ts +60 -0
- package/package/components/core/password-input.svelte +81 -0
- package/package/components/core/password-input.svelte.d.ts +36 -0
- package/package/components/core/radio-button.svelte +93 -0
- package/package/components/core/radio-button.svelte.d.ts +37 -0
- package/package/components/core/row-group.svelte +14 -0
- package/package/components/core/row-group.svelte.d.ts +29 -0
- package/package/components/core/row.svelte +14 -0
- package/package/components/core/row.svelte.d.ts +33 -0
- package/package/components/core/search-bar.svelte +91 -0
- package/package/components/core/search-bar.svelte.d.ts +49 -0
- package/package/components/core/select-button.svelte +31 -0
- package/package/components/core/select-button.svelte.d.ts +52 -0
- package/package/components/core/separator.svelte +28 -0
- package/package/components/core/separator.svelte.d.ts +26 -0
- package/package/components/core/slider.svelte +271 -0
- package/package/components/core/slider.svelte.d.ts +51 -0
- package/package/components/core/spacer.svelte +22 -0
- package/package/components/core/spacer.svelte.d.ts +25 -0
- package/package/components/core/switch.svelte +86 -0
- package/package/components/core/switch.svelte.d.ts +37 -0
- package/package/components/core/tab-panel.svelte +23 -0
- package/package/components/core/tab-panel.svelte.d.ts +33 -0
- package/package/components/core/tab.svelte +22 -0
- package/package/components/core/tab.svelte.d.ts +45 -0
- package/package/components/core/text-area.svelte +90 -0
- package/package/components/core/text-area.svelte.d.ts +57 -0
- package/package/components/core/text-input.svelte +146 -0
- package/package/components/core/text-input.svelte.d.ts +71 -0
- package/package/components/core/toolbar.svelte +74 -0
- package/package/components/core/toolbar.svelte.d.ts +35 -0
- package/package/components/editor/markdown.svelte +78 -0
- package/package/components/editor/markdown.svelte.d.ts +25 -0
- package/package/components/helpers/group.d.ts +37 -0
- package/package/components/helpers/group.js +246 -0
- package/package/components/helpers/popup.d.ts +31 -0
- package/package/components/helpers/popup.js +165 -0
- package/package/components/helpers/util.d.ts +1 -0
- package/package/components/helpers/util.js +8 -0
- package/package/components/util/app-shell.svelte +354 -0
- package/package/components/util/app-shell.svelte.d.ts +38 -0
- package/package/components/util/misc.d.ts +2 -0
- package/package/components/util/misc.js +22 -0
- package/package/components/util/popup.svelte +155 -0
- package/package/components/util/popup.svelte.d.ts +53 -0
- package/package/components/util/portal.svelte +34 -0
- package/package/components/util/portal.svelte.d.ts +28 -0
- package/package/index.d.ts +43 -0
- package/package/index.js +68 -0
- package/package/locales/en.d.ts +42 -0
- package/package/locales/en.js +41 -0
- package/package/locales/ja.d.ts +42 -0
- package/package/locales/ja.js +41 -0
- package/package/styles/core.scss +134 -0
- package/package/styles/variables.scss +184 -0
- package/package/typedef.d.ts +0 -0
- package/package/typedef.js +0 -0
- package/package.json +2 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} TabListProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} TabListEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} TabListSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#tablist
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#tabpanel
|
|
7
|
+
*/
|
|
8
|
+
export default class TabList extends SvelteComponentTyped<{
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
class?: string;
|
|
11
|
+
element?: HTMLElement;
|
|
12
|
+
name?: string;
|
|
13
|
+
orientation?: "horizontal" | "vertical";
|
|
14
|
+
}, {
|
|
15
|
+
select: Event;
|
|
16
|
+
} & {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
}, {
|
|
19
|
+
default: {};
|
|
20
|
+
}> {
|
|
21
|
+
/**accessor*/
|
|
22
|
+
set class(arg: string);
|
|
23
|
+
get class(): string;
|
|
24
|
+
/**accessor*/
|
|
25
|
+
set element(arg: HTMLElement);
|
|
26
|
+
get element(): HTMLElement;
|
|
27
|
+
/**accessor*/
|
|
28
|
+
set orientation(arg: "horizontal" | "vertical");
|
|
29
|
+
get orientation(): "horizontal" | "vertical";
|
|
30
|
+
/**accessor*/
|
|
31
|
+
set name(arg: string);
|
|
32
|
+
get name(): string;
|
|
33
|
+
}
|
|
34
|
+
export type TabListProps = typeof __propDef.props;
|
|
35
|
+
export type TabListEvents = typeof __propDef.events;
|
|
36
|
+
export type TabListSlots = typeof __propDef.slots;
|
|
37
|
+
import { SvelteComponentTyped } from "svelte";
|
|
38
|
+
declare const __propDef: {
|
|
39
|
+
props: {
|
|
40
|
+
[x: string]: any;
|
|
41
|
+
class?: string;
|
|
42
|
+
element?: (HTMLElement | undefined);
|
|
43
|
+
name?: string;
|
|
44
|
+
orientation?: ('horizontal' | 'vertical');
|
|
45
|
+
};
|
|
46
|
+
events: {
|
|
47
|
+
select: Event;
|
|
48
|
+
} & {
|
|
49
|
+
[evt: string]: CustomEvent<any>;
|
|
50
|
+
};
|
|
51
|
+
slots: {
|
|
52
|
+
default: {};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#button
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#button
|
|
5
|
+
-->
|
|
6
|
+
<svelte:options accessors={true} />
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import Popup from '../util/popup.svelte';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* CSS class name on the button.
|
|
13
|
+
* @type {String}
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line padding-line-between-statements
|
|
16
|
+
let className = '';
|
|
17
|
+
|
|
18
|
+
export { className as class };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Reference to the button element.
|
|
22
|
+
* @type {(HTMLButtonElement|undefined)}
|
|
23
|
+
*/
|
|
24
|
+
export let element = undefined;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The `type` attribute on the button element.
|
|
28
|
+
* @type {('button'|'submit'|'reset')}
|
|
29
|
+
*/
|
|
30
|
+
export let type = 'button';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The `role` attribute on the button element.
|
|
34
|
+
* @type {String}
|
|
35
|
+
*/
|
|
36
|
+
export let role = 'button';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The height of the button.
|
|
40
|
+
* @type {('small'|'medium'|'large')}
|
|
41
|
+
*/
|
|
42
|
+
export let size = 'medium';
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether the button is hidden.
|
|
46
|
+
* @type {Boolean}
|
|
47
|
+
*/
|
|
48
|
+
export let hidden = false;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether the button is disabled.
|
|
52
|
+
* @type {Boolean}
|
|
53
|
+
*/
|
|
54
|
+
export let disabled = false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The `aria-pressed` attribute on the button element.
|
|
58
|
+
* @type {(Boolean|String|undefined)}
|
|
59
|
+
*/
|
|
60
|
+
export let pressed = undefined;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Text label displayed on the button.
|
|
64
|
+
* @type {String}
|
|
65
|
+
*/
|
|
66
|
+
export let label = '';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Where to show the dropdown menu.
|
|
70
|
+
* @type {PopupPosition}
|
|
71
|
+
*/
|
|
72
|
+
export let popupPosition = 'bottom-left';
|
|
73
|
+
|
|
74
|
+
/** @type {?Popup} */
|
|
75
|
+
let popupComponent;
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<button
|
|
79
|
+
{type}
|
|
80
|
+
{role}
|
|
81
|
+
hidden={hidden ? 'hidden' : undefined}
|
|
82
|
+
disabled={disabled ? 'disabled' : undefined}
|
|
83
|
+
class="sui button {size} {className}"
|
|
84
|
+
aria-hidden={hidden ? true : undefined}
|
|
85
|
+
aria-disabled={disabled ? true : undefined}
|
|
86
|
+
aria-pressed={pressed}
|
|
87
|
+
{...$$restProps}
|
|
88
|
+
on:mouseenter
|
|
89
|
+
on:mouseleave
|
|
90
|
+
on:click
|
|
91
|
+
on:dragover
|
|
92
|
+
on:dragleave
|
|
93
|
+
on:dragend
|
|
94
|
+
on:drop
|
|
95
|
+
on:keydown
|
|
96
|
+
on:keyup
|
|
97
|
+
on:keypress
|
|
98
|
+
bind:this={element}
|
|
99
|
+
>
|
|
100
|
+
<slot name="start-icon" />
|
|
101
|
+
{#if label}
|
|
102
|
+
<span class="label">{label}</span>
|
|
103
|
+
{/if}
|
|
104
|
+
<slot />
|
|
105
|
+
<slot name="end-icon" />
|
|
106
|
+
</button>
|
|
107
|
+
|
|
108
|
+
{#if $$slots.popup}
|
|
109
|
+
<Popup anchor={element} position={popupPosition} bind:this={popupComponent}>
|
|
110
|
+
<slot name="popup" />
|
|
111
|
+
</Popup>
|
|
112
|
+
{/if}
|
|
113
|
+
|
|
114
|
+
<style>button {
|
|
115
|
+
display: inline-flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
gap: 4px;
|
|
118
|
+
border-width: 0;
|
|
119
|
+
border-style: solid;
|
|
120
|
+
border-color: transparent;
|
|
121
|
+
padding: 0;
|
|
122
|
+
color: inherit;
|
|
123
|
+
background-color: transparent;
|
|
124
|
+
box-shadow: none;
|
|
125
|
+
font: inherit;
|
|
126
|
+
text-align: left;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
transition: all 200ms;
|
|
129
|
+
}
|
|
130
|
+
button > :global(*) {
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
}
|
|
133
|
+
button:global(:not(:disabled):focus-visible) {
|
|
134
|
+
z-index: 1;
|
|
135
|
+
}
|
|
136
|
+
button[hidden] {
|
|
137
|
+
display: none !important;
|
|
138
|
+
}
|
|
139
|
+
button[disabled] {
|
|
140
|
+
opacity: 0.4;
|
|
141
|
+
cursor: default;
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
}
|
|
144
|
+
button:global(.primary), button:global(.secondary), button:global(.tertiary), button:global(.ghost) {
|
|
145
|
+
justify-content: center;
|
|
146
|
+
border-width: 1px;
|
|
147
|
+
border-radius: var(--button--medium--border-radius);
|
|
148
|
+
padding: var(--button--medium--padding, 0 8px);
|
|
149
|
+
height: var(--button--medium--height);
|
|
150
|
+
}
|
|
151
|
+
button:global(.primary) :global(.label:only-child), button:global(.secondary) :global(.label:only-child), button:global(.tertiary) :global(.label:only-child), button:global(.ghost) :global(.label:only-child) {
|
|
152
|
+
padding: 0 4px;
|
|
153
|
+
}
|
|
154
|
+
button:global(.primary) {
|
|
155
|
+
border-color: var(--control-border-color);
|
|
156
|
+
color: var(--primary-accent-color-foreground);
|
|
157
|
+
background-color: var(--primary-accent-color);
|
|
158
|
+
}
|
|
159
|
+
button:global(.primary):hover, button:global(.primary):focus-visible {
|
|
160
|
+
background-color: var(--primary-accent-color-lighter);
|
|
161
|
+
}
|
|
162
|
+
button:global(.primary):active {
|
|
163
|
+
background-color: var(--primary-accent-color-darker);
|
|
164
|
+
}
|
|
165
|
+
button:global(.secondary) {
|
|
166
|
+
border-color: var(--primary-accent-color);
|
|
167
|
+
color: var(--primary-accent-color-lighter);
|
|
168
|
+
background-color: var(--tertiary-background-color);
|
|
169
|
+
}
|
|
170
|
+
button:global(.secondary):hover, button:global(.secondary):focus-visible {
|
|
171
|
+
background-color: var(--highlight-background-color);
|
|
172
|
+
}
|
|
173
|
+
button:global(.secondary)[aria-pressed=true] {
|
|
174
|
+
background-color: var(--primary-accent-color);
|
|
175
|
+
}
|
|
176
|
+
button:global(.tertiary) {
|
|
177
|
+
border-color: var(--control-border-color);
|
|
178
|
+
color: var(--highlight-foreground-color);
|
|
179
|
+
background-color: var(--tertiary-background-color);
|
|
180
|
+
}
|
|
181
|
+
button:global(.tertiary):hover, button:global(.tertiary):focus-visible {
|
|
182
|
+
background-color: var(--highlight-background-color);
|
|
183
|
+
}
|
|
184
|
+
button:global(.tertiary)[aria-pressed=true] {
|
|
185
|
+
background-color: var(--highlight-background-color);
|
|
186
|
+
}
|
|
187
|
+
button:global(.ghost):hover, button:global(.ghost):focus-visible {
|
|
188
|
+
background-color: var(--highlight-background-color);
|
|
189
|
+
}
|
|
190
|
+
button:global(.ghost)[aria-pressed=true] {
|
|
191
|
+
background-color: var(--highlight-background-color);
|
|
192
|
+
}
|
|
193
|
+
button:global(.danger) {
|
|
194
|
+
background-color: var(--danger-background-color);
|
|
195
|
+
}
|
|
196
|
+
button:global(.large) {
|
|
197
|
+
height: var(--button--large--height);
|
|
198
|
+
}
|
|
199
|
+
button:global(.small) {
|
|
200
|
+
padding: var(--button--small--padding, 0 8px);
|
|
201
|
+
height: var(--button--small--height);
|
|
202
|
+
font-size: var(--font-size--small);
|
|
203
|
+
}
|
|
204
|
+
button:global(.small) :global(.icon) {
|
|
205
|
+
font-size: var(--font-size--large);
|
|
206
|
+
}
|
|
207
|
+
button:global(.pill) {
|
|
208
|
+
border-radius: var(--button--medium--pill--height, 16px);
|
|
209
|
+
padding: var(--button--medium--pill--padding, 0 16px);
|
|
210
|
+
}
|
|
211
|
+
button:global(.link) {
|
|
212
|
+
color: var(--primary-accent-color-lighter);
|
|
213
|
+
}
|
|
214
|
+
button:global(.iconic) {
|
|
215
|
+
justify-content: center;
|
|
216
|
+
padding: 0;
|
|
217
|
+
border-radius: 4px;
|
|
218
|
+
aspect-ratio: 1/1;
|
|
219
|
+
}
|
|
220
|
+
button :global(.label) {
|
|
221
|
+
padding: 0 4px;
|
|
222
|
+
}</style>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} ButtonProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} ButtonEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} ButtonSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#button
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#button
|
|
7
|
+
*/
|
|
8
|
+
export default class Button extends SvelteComponentTyped<{
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
label?: string;
|
|
11
|
+
class?: string;
|
|
12
|
+
element?: HTMLButtonElement;
|
|
13
|
+
type?: "reset" | "submit" | "button";
|
|
14
|
+
role?: string;
|
|
15
|
+
size?: "small" | "medium" | "large";
|
|
16
|
+
hidden?: boolean;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
pressed?: string | boolean;
|
|
19
|
+
popupPosition?: any;
|
|
20
|
+
}, {
|
|
21
|
+
mouseenter: MouseEvent;
|
|
22
|
+
mouseleave: MouseEvent;
|
|
23
|
+
click: MouseEvent;
|
|
24
|
+
dragover: DragEvent;
|
|
25
|
+
dragleave: DragEvent;
|
|
26
|
+
dragend: DragEvent;
|
|
27
|
+
drop: DragEvent;
|
|
28
|
+
keydown: KeyboardEvent;
|
|
29
|
+
keyup: KeyboardEvent;
|
|
30
|
+
keypress: KeyboardEvent;
|
|
31
|
+
} & {
|
|
32
|
+
[evt: string]: CustomEvent<any>;
|
|
33
|
+
}, {
|
|
34
|
+
'start-icon': {};
|
|
35
|
+
default: {};
|
|
36
|
+
'end-icon': {};
|
|
37
|
+
popup: {};
|
|
38
|
+
}> {
|
|
39
|
+
/**accessor*/
|
|
40
|
+
set class(arg: string);
|
|
41
|
+
get class(): string;
|
|
42
|
+
/**accessor*/
|
|
43
|
+
set element(arg: HTMLButtonElement);
|
|
44
|
+
get element(): HTMLButtonElement;
|
|
45
|
+
/**accessor*/
|
|
46
|
+
set type(arg: "reset" | "submit" | "button");
|
|
47
|
+
get type(): "reset" | "submit" | "button";
|
|
48
|
+
/**accessor*/
|
|
49
|
+
set role(arg: string);
|
|
50
|
+
get role(): string;
|
|
51
|
+
/**accessor*/
|
|
52
|
+
set size(arg: "small" | "medium" | "large");
|
|
53
|
+
get size(): "small" | "medium" | "large";
|
|
54
|
+
/**accessor*/
|
|
55
|
+
set hidden(arg: boolean);
|
|
56
|
+
get hidden(): boolean;
|
|
57
|
+
/**accessor*/
|
|
58
|
+
set disabled(arg: boolean);
|
|
59
|
+
get disabled(): boolean;
|
|
60
|
+
/**accessor*/
|
|
61
|
+
set pressed(arg: string | boolean);
|
|
62
|
+
get pressed(): string | boolean;
|
|
63
|
+
/**accessor*/
|
|
64
|
+
set label(arg: string);
|
|
65
|
+
get label(): string;
|
|
66
|
+
/**accessor*/
|
|
67
|
+
set popupPosition(arg: any);
|
|
68
|
+
get popupPosition(): any;
|
|
69
|
+
}
|
|
70
|
+
export type ButtonProps = typeof __propDef.props;
|
|
71
|
+
export type ButtonEvents = typeof __propDef.events;
|
|
72
|
+
export type ButtonSlots = typeof __propDef.slots;
|
|
73
|
+
import { SvelteComponentTyped } from "svelte";
|
|
74
|
+
declare const __propDef: {
|
|
75
|
+
props: {
|
|
76
|
+
[x: string]: any;
|
|
77
|
+
label?: string;
|
|
78
|
+
class?: string;
|
|
79
|
+
element?: (HTMLButtonElement | undefined);
|
|
80
|
+
type?: ('button' | 'submit' | 'reset');
|
|
81
|
+
role?: string;
|
|
82
|
+
size?: ('small' | 'medium' | 'large');
|
|
83
|
+
hidden?: boolean;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
pressed?: (boolean | string | undefined);
|
|
86
|
+
popupPosition?: any;
|
|
87
|
+
};
|
|
88
|
+
events: {
|
|
89
|
+
mouseenter: MouseEvent;
|
|
90
|
+
mouseleave: MouseEvent;
|
|
91
|
+
click: MouseEvent;
|
|
92
|
+
dragover: DragEvent;
|
|
93
|
+
dragleave: DragEvent;
|
|
94
|
+
dragend: DragEvent;
|
|
95
|
+
drop: DragEvent;
|
|
96
|
+
keydown: KeyboardEvent;
|
|
97
|
+
keyup: KeyboardEvent;
|
|
98
|
+
keypress: KeyboardEvent;
|
|
99
|
+
} & {
|
|
100
|
+
[evt: string]: CustomEvent<any>;
|
|
101
|
+
};
|
|
102
|
+
slots: {
|
|
103
|
+
'start-icon': {};
|
|
104
|
+
default: {};
|
|
105
|
+
'end-icon': {};
|
|
106
|
+
popup: {};
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
@see https://w3c.github.io/aria/#checkbox
|
|
4
|
+
@see https://w3c.github.io/aria-practices/#checkbox
|
|
5
|
+
-->
|
|
6
|
+
<script>
|
|
7
|
+
import { createEventDispatcher } from 'svelte';
|
|
8
|
+
import { getRandomId } from '../helpers/util';
|
|
9
|
+
import Button from './button.svelte';
|
|
10
|
+
import Icon from './icon.svelte';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CSS class name on the button.
|
|
14
|
+
* @type {String}
|
|
15
|
+
*/
|
|
16
|
+
let className = '';
|
|
17
|
+
|
|
18
|
+
export { className as class };
|
|
19
|
+
|
|
20
|
+
/** @type {String} */
|
|
21
|
+
export let name = '';
|
|
22
|
+
|
|
23
|
+
/** @type {(String|undefined)} */
|
|
24
|
+
export let value = undefined;
|
|
25
|
+
|
|
26
|
+
/** @type {(Boolean|String|undefined)} */
|
|
27
|
+
export let checked = false;
|
|
28
|
+
|
|
29
|
+
/** @type {Boolean} */
|
|
30
|
+
export let indeterminate = false;
|
|
31
|
+
|
|
32
|
+
/** @type {Boolean} */
|
|
33
|
+
export let disabled = false;
|
|
34
|
+
|
|
35
|
+
const dispatch = createEventDispatcher();
|
|
36
|
+
const id = getRandomId('checkbox');
|
|
37
|
+
/** @type {Button} */
|
|
38
|
+
let button;
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
{#if name && value && checked && !indeterminate}
|
|
42
|
+
<input type="hidden" {name} {value} />
|
|
43
|
+
{/if}
|
|
44
|
+
|
|
45
|
+
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
46
|
+
<label
|
|
47
|
+
class="sui checkbox {className}"
|
|
48
|
+
class:checked
|
|
49
|
+
class:indeterminate
|
|
50
|
+
class:disabled
|
|
51
|
+
on:click|preventDefault|stopPropagation={(event) => {
|
|
52
|
+
if (!event.target.matches('button')) {
|
|
53
|
+
button.element.click();
|
|
54
|
+
}
|
|
55
|
+
}}
|
|
56
|
+
>
|
|
57
|
+
<Button
|
|
58
|
+
{id}
|
|
59
|
+
{disabled}
|
|
60
|
+
role="checkbox"
|
|
61
|
+
aria-checked={indeterminate ? 'mixed' : checked}
|
|
62
|
+
aria-labelledby="{id}-label"
|
|
63
|
+
bind:this={button}
|
|
64
|
+
on:click={(event) => {
|
|
65
|
+
event.preventDefault();
|
|
66
|
+
event.stopPropagation();
|
|
67
|
+
checked = indeterminate ? true : !checked;
|
|
68
|
+
indeterminate = false;
|
|
69
|
+
dispatch('change', { checked });
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<Icon slot="start-icon" name={indeterminate ? 'remove' : 'check'} />
|
|
73
|
+
</Button>
|
|
74
|
+
{#if $$slots.default}
|
|
75
|
+
<label id="{id}-label">
|
|
76
|
+
<slot />
|
|
77
|
+
</label>
|
|
78
|
+
{/if}
|
|
79
|
+
</label>
|
|
80
|
+
|
|
81
|
+
<style>.checkbox {
|
|
82
|
+
display: inline-flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 8px;
|
|
85
|
+
color: inherit;
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
-webkit-user-select: none;
|
|
88
|
+
user-select: none;
|
|
89
|
+
}
|
|
90
|
+
.checkbox.disabled {
|
|
91
|
+
cursor: default;
|
|
92
|
+
}
|
|
93
|
+
.checkbox :global(button) {
|
|
94
|
+
align-items: center;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
border-width: 2px;
|
|
98
|
+
border-color: var(--control-border-color);
|
|
99
|
+
border-radius: 4px;
|
|
100
|
+
width: 24px;
|
|
101
|
+
height: 24px;
|
|
102
|
+
color: var(--primary-accent-color-lighter);
|
|
103
|
+
transition: all 200ms;
|
|
104
|
+
}
|
|
105
|
+
.checkbox :global(button) :global(.icon) {
|
|
106
|
+
font-size: var(--font-size--xx-large);
|
|
107
|
+
}
|
|
108
|
+
.checkbox :global(button[aria-checked="true"]),
|
|
109
|
+
.checkbox :global(button[aria-checked="mixed"]) {
|
|
110
|
+
color: var(--primary-accent-color-lighter);
|
|
111
|
+
}
|
|
112
|
+
.checkbox :global(button[aria-checked="false"]) {
|
|
113
|
+
color: transparent;
|
|
114
|
+
}</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} CheckboxProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} CheckboxEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} CheckboxSlots */
|
|
4
|
+
/**
|
|
5
|
+
* @see https://w3c.github.io/aria/#checkbox
|
|
6
|
+
* @see https://w3c.github.io/aria-practices/#checkbox
|
|
7
|
+
*/
|
|
8
|
+
export default class Checkbox extends SvelteComponentTyped<{
|
|
9
|
+
class?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
name?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
checked?: string | boolean;
|
|
14
|
+
indeterminate?: boolean;
|
|
15
|
+
}, {
|
|
16
|
+
change: CustomEvent<any>;
|
|
17
|
+
} & {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {
|
|
20
|
+
default: {};
|
|
21
|
+
}> {
|
|
22
|
+
}
|
|
23
|
+
export type CheckboxProps = typeof __propDef.props;
|
|
24
|
+
export type CheckboxEvents = typeof __propDef.events;
|
|
25
|
+
export type CheckboxSlots = typeof __propDef.slots;
|
|
26
|
+
import { SvelteComponentTyped } from "svelte";
|
|
27
|
+
declare const __propDef: {
|
|
28
|
+
props: {
|
|
29
|
+
class?: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
name?: string;
|
|
32
|
+
value?: (string | undefined);
|
|
33
|
+
checked?: (boolean | string | undefined);
|
|
34
|
+
indeterminate?: boolean;
|
|
35
|
+
};
|
|
36
|
+
events: {
|
|
37
|
+
change: CustomEvent<any>;
|
|
38
|
+
} & {
|
|
39
|
+
[evt: string]: CustomEvent<any>;
|
|
40
|
+
};
|
|
41
|
+
slots: {
|
|
42
|
+
default: {};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export {};
|