@sveltia/ui 0.1.4 → 0.2.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.json +23 -12
- package/package/components/composite/calendar.svelte +0 -240
- package/package/components/composite/calendar.svelte.d.ts +0 -20
- package/package/components/composite/checkbox-group.svelte +0 -43
- package/package/components/composite/checkbox-group.svelte.d.ts +0 -24
- package/package/components/composite/combobox.svelte +0 -197
- package/package/components/composite/combobox.svelte.d.ts +0 -32
- package/package/components/composite/disclosure.svelte +0 -60
- package/package/components/composite/disclosure.svelte.d.ts +0 -26
- package/package/components/composite/grid.svelte +0 -24
- package/package/components/composite/grid.svelte.d.ts +0 -22
- package/package/components/composite/listbox.svelte +0 -63
- package/package/components/composite/listbox.svelte.d.ts +0 -39
- package/package/components/composite/menu-item-group.svelte +0 -31
- package/package/components/composite/menu-item-group.svelte.d.ts +0 -23
- package/package/components/composite/menu.svelte +0 -44
- package/package/components/composite/menu.svelte.d.ts +0 -32
- package/package/components/composite/radio-button-group.svelte +0 -45
- package/package/components/composite/radio-button-group.svelte.d.ts +0 -27
- package/package/components/composite/select-button-group.svelte +0 -70
- package/package/components/composite/select-button-group.svelte.d.ts +0 -31
- package/package/components/composite/select.svelte +0 -34
- package/package/components/composite/select.svelte.d.ts +0 -26
- package/package/components/composite/tab-list.svelte +0 -76
- package/package/components/composite/tab-list.svelte.d.ts +0 -42
- package/package/components/core/button.svelte +0 -205
- package/package/components/core/button.svelte.d.ts +0 -78
- package/package/components/core/checkbox.svelte +0 -107
- package/package/components/core/checkbox.svelte.d.ts +0 -30
- package/package/components/core/dialog.svelte +0 -274
- package/package/components/core/dialog.svelte.d.ts +0 -45
- package/package/components/core/grid-cell.svelte +0 -14
- package/package/components/core/grid-cell.svelte.d.ts +0 -21
- package/package/components/core/group.svelte +0 -31
- package/package/components/core/group.svelte.d.ts +0 -23
- package/package/components/core/icon.svelte +0 -21
- package/package/components/core/icon.svelte.d.ts +0 -20
- package/package/components/core/menu-button.svelte +0 -57
- package/package/components/core/menu-button.svelte.d.ts +0 -30
- package/package/components/core/menu-item-checkbox.svelte +0 -24
- package/package/components/core/menu-item-checkbox.svelte.d.ts +0 -24
- package/package/components/core/menu-item-radio.svelte +0 -19
- package/package/components/core/menu-item-radio.svelte.d.ts +0 -24
- package/package/components/core/menu-item.svelte +0 -113
- package/package/components/core/menu-item.svelte.d.ts +0 -29
- package/package/components/core/number-input.svelte +0 -112
- package/package/components/core/number-input.svelte.d.ts +0 -28
- package/package/components/core/option.svelte +0 -59
- package/package/components/core/option.svelte.d.ts +0 -35
- package/package/components/core/password-input.svelte +0 -81
- package/package/components/core/password-input.svelte.d.ts +0 -25
- package/package/components/core/radio-button.svelte +0 -93
- package/package/components/core/radio-button.svelte.d.ts +0 -27
- package/package/components/core/row-group.svelte +0 -14
- package/package/components/core/row-group.svelte.d.ts +0 -21
- package/package/components/core/row.svelte +0 -14
- package/package/components/core/row.svelte.d.ts +0 -23
- package/package/components/core/search-bar.svelte +0 -90
- package/package/components/core/search-bar.svelte.d.ts +0 -35
- package/package/components/core/select-button.svelte +0 -31
- package/package/components/core/select-button.svelte.d.ts +0 -35
- package/package/components/core/separator.svelte +0 -28
- package/package/components/core/separator.svelte.d.ts +0 -20
- package/package/components/core/slider.svelte +0 -270
- package/package/components/core/slider.svelte.d.ts +0 -35
- package/package/components/core/spacer.svelte +0 -22
- package/package/components/core/spacer.svelte.d.ts +0 -19
- package/package/components/core/switch.svelte +0 -80
- package/package/components/core/switch.svelte.d.ts +0 -27
- package/package/components/core/tab-panel.svelte +0 -23
- package/package/components/core/tab-panel.svelte.d.ts +0 -25
- package/package/components/core/tab.svelte +0 -22
- package/package/components/core/tab.svelte.d.ts +0 -31
- package/package/components/core/text-area.svelte +0 -90
- package/package/components/core/text-area.svelte.d.ts +0 -43
- package/package/components/core/text-input.svelte +0 -145
- package/package/components/core/text-input.svelte.d.ts +0 -53
- package/package/components/core/toolbar.svelte +0 -74
- package/package/components/core/toolbar.svelte.d.ts +0 -26
- package/package/components/editor/markdown.svelte +0 -78
- package/package/components/editor/markdown.svelte.d.ts +0 -19
- package/package/components/helpers/group.d.ts +0 -37
- package/package/components/helpers/group.js +0 -246
- package/package/components/helpers/popup.d.ts +0 -26
- package/package/components/helpers/popup.js +0 -146
- package/package/components/helpers/util.d.ts +0 -1
- package/package/components/helpers/util.js +0 -8
- package/package/components/util/app-shell.svelte +0 -284
- package/package/components/util/app-shell.svelte.d.ts +0 -28
- package/package/components/util/misc.d.ts +0 -2
- package/package/components/util/misc.js +0 -22
- package/package/components/util/popup.svelte +0 -131
- package/package/components/util/popup.svelte.d.ts +0 -37
- package/package/components/util/portal.svelte +0 -34
- package/package/components/util/portal.svelte.d.ts +0 -21
- package/package/index.d.ts +0 -41
- package/package/index.js +0 -66
- package/package/locales/en.d.ts +0 -42
- package/package/locales/en.js +0 -41
- package/package/locales/ja.d.ts +0 -42
- package/package/locales/ja.js +0 -41
- package/package/styles/core.scss +0 -134
- package/package/styles/variables.scss +0 -114
- package/package/typedef.d.ts +0 -0
- package/package/typedef.js +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
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(.ternary) {
|
|
145
|
-
justify-content: center;
|
|
146
|
-
border-radius: var(--button--medium--border-radius);
|
|
147
|
-
padding: var(--button--medium--padding, 0 8px);
|
|
148
|
-
height: var(--button--medium--height);
|
|
149
|
-
}
|
|
150
|
-
button:global(.primary) :global(.label:only-child), button:global(.secondary) :global(.label:only-child), button:global(.ternary) :global(.label:only-child) {
|
|
151
|
-
padding: 0 4px;
|
|
152
|
-
}
|
|
153
|
-
button:global(.primary) {
|
|
154
|
-
border-width: 1px;
|
|
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 {
|
|
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-width: 1px;
|
|
167
|
-
border-color: var(--control-border-color);
|
|
168
|
-
color: var(--highlight-foreground-color);
|
|
169
|
-
background-color: var(--ternary-background-color);
|
|
170
|
-
}
|
|
171
|
-
button:global(.secondary)[aria-pressed=true] {
|
|
172
|
-
background-color: var(--primary-accent-color);
|
|
173
|
-
}
|
|
174
|
-
button:global(.ternary) {
|
|
175
|
-
color: var(--primary-foreground-color);
|
|
176
|
-
padding: var(--button--medium--padding, 0 8px);
|
|
177
|
-
}
|
|
178
|
-
button:global(.ternary)[aria-pressed=true] {
|
|
179
|
-
background-color: var(--highlight-background-color);
|
|
180
|
-
}
|
|
181
|
-
button:global(.danger) {
|
|
182
|
-
background-color: var(--danger-background-color);
|
|
183
|
-
}
|
|
184
|
-
button:global(.large) {
|
|
185
|
-
height: var(--button--large--height);
|
|
186
|
-
}
|
|
187
|
-
button:global(.small) {
|
|
188
|
-
padding: var(--button--small--padding, 0 8px);
|
|
189
|
-
height: var(--button--small--height);
|
|
190
|
-
font-size: 12px;
|
|
191
|
-
}
|
|
192
|
-
button:global(.small) :global(.icon) {
|
|
193
|
-
font-size: 16px;
|
|
194
|
-
}
|
|
195
|
-
button:global(.link) {
|
|
196
|
-
color: var(--primary-accent-color-lighter);
|
|
197
|
-
}
|
|
198
|
-
button:global(.iconic) {
|
|
199
|
-
justify-content: center;
|
|
200
|
-
border-radius: 4px;
|
|
201
|
-
aspect-ratio: 1/1;
|
|
202
|
-
}
|
|
203
|
-
button :global(.label) {
|
|
204
|
-
padding: 0 4px;
|
|
205
|
-
}</style>
|
|
@@ -1,78 +0,0 @@
|
|
|
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 {
|
|
9
|
-
/**accessor*/
|
|
10
|
-
set class(arg: any);
|
|
11
|
-
get class(): any;
|
|
12
|
-
/**accessor*/
|
|
13
|
-
set element(arg: any);
|
|
14
|
-
get element(): any;
|
|
15
|
-
/**accessor*/
|
|
16
|
-
set type(arg: any);
|
|
17
|
-
get type(): any;
|
|
18
|
-
/**accessor*/
|
|
19
|
-
set role(arg: any);
|
|
20
|
-
get role(): any;
|
|
21
|
-
/**accessor*/
|
|
22
|
-
set size(arg: any);
|
|
23
|
-
get size(): any;
|
|
24
|
-
/**accessor*/
|
|
25
|
-
set hidden(arg: any);
|
|
26
|
-
get hidden(): any;
|
|
27
|
-
/**accessor*/
|
|
28
|
-
set disabled(arg: any);
|
|
29
|
-
get disabled(): any;
|
|
30
|
-
/**accessor*/
|
|
31
|
-
set pressed(arg: any);
|
|
32
|
-
get pressed(): any;
|
|
33
|
-
/**accessor*/
|
|
34
|
-
set label(arg: any);
|
|
35
|
-
get label(): any;
|
|
36
|
-
/**accessor*/
|
|
37
|
-
set popupPosition(arg: any);
|
|
38
|
-
get popupPosition(): any;
|
|
39
|
-
}
|
|
40
|
-
export type ButtonProps = typeof __propDef.props;
|
|
41
|
-
export type ButtonEvents = typeof __propDef.events;
|
|
42
|
-
export type ButtonSlots = typeof __propDef.slots;
|
|
43
|
-
declare const __propDef: {
|
|
44
|
-
props: {
|
|
45
|
-
[x: string]: any;
|
|
46
|
-
label?: string;
|
|
47
|
-
class?: string;
|
|
48
|
-
element?: (HTMLButtonElement | undefined);
|
|
49
|
-
type?: ('button' | 'submit' | 'reset');
|
|
50
|
-
role?: string;
|
|
51
|
-
size?: ('small' | 'medium' | 'large');
|
|
52
|
-
hidden?: boolean;
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
pressed?: (boolean | string | undefined);
|
|
55
|
-
popupPosition?: any;
|
|
56
|
-
};
|
|
57
|
-
events: {
|
|
58
|
-
mouseenter: MouseEvent;
|
|
59
|
-
mouseleave: MouseEvent;
|
|
60
|
-
click: MouseEvent;
|
|
61
|
-
dragover: DragEvent;
|
|
62
|
-
dragleave: DragEvent;
|
|
63
|
-
dragend: DragEvent;
|
|
64
|
-
drop: DragEvent;
|
|
65
|
-
keydown: KeyboardEvent;
|
|
66
|
-
keyup: KeyboardEvent;
|
|
67
|
-
keypress: KeyboardEvent;
|
|
68
|
-
} & {
|
|
69
|
-
[evt: string]: CustomEvent<any>;
|
|
70
|
-
};
|
|
71
|
-
slots: {
|
|
72
|
-
'start-icon': {};
|
|
73
|
-
default: {};
|
|
74
|
-
'end-icon': {};
|
|
75
|
-
popup: {};
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
const dispatch = createEventDispatcher();
|
|
33
|
-
const id = getRandomId('checkbox');
|
|
34
|
-
/** @type {Button} */
|
|
35
|
-
let button;
|
|
36
|
-
|
|
37
|
-
$: {
|
|
38
|
-
dispatch('change', { checked });
|
|
39
|
-
}
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
{#if name && value && checked && !indeterminate}
|
|
43
|
-
<input type="hidden" {name} {value} />
|
|
44
|
-
{/if}
|
|
45
|
-
|
|
46
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
47
|
-
<label
|
|
48
|
-
class="sui checkbox {className}"
|
|
49
|
-
on:click|preventDefault|stopPropagation={(event) => {
|
|
50
|
-
if (!event.target.matches('button')) {
|
|
51
|
-
button.element.click();
|
|
52
|
-
}
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
<Button
|
|
56
|
-
{id}
|
|
57
|
-
role="checkbox"
|
|
58
|
-
aria-checked={indeterminate ? 'mixed' : checked}
|
|
59
|
-
aria-labelledby="{id}-label"
|
|
60
|
-
bind:this={button}
|
|
61
|
-
on:click={(event) => {
|
|
62
|
-
event.preventDefault();
|
|
63
|
-
event.stopPropagation();
|
|
64
|
-
checked = indeterminate ? true : !checked;
|
|
65
|
-
indeterminate = false;
|
|
66
|
-
}}
|
|
67
|
-
>
|
|
68
|
-
<Icon slot="start-icon" name={indeterminate ? 'remove' : 'check'} />
|
|
69
|
-
</Button>
|
|
70
|
-
{#if $$slots.default}
|
|
71
|
-
<label id="{id}-label">
|
|
72
|
-
<slot />
|
|
73
|
-
</label>
|
|
74
|
-
{/if}
|
|
75
|
-
</label>
|
|
76
|
-
|
|
77
|
-
<style>.checkbox {
|
|
78
|
-
display: inline-flex;
|
|
79
|
-
align-items: center;
|
|
80
|
-
gap: 8px;
|
|
81
|
-
color: inherit;
|
|
82
|
-
cursor: pointer;
|
|
83
|
-
-webkit-user-select: none;
|
|
84
|
-
user-select: none;
|
|
85
|
-
}
|
|
86
|
-
.checkbox :global(button) {
|
|
87
|
-
align-items: center;
|
|
88
|
-
justify-content: center;
|
|
89
|
-
overflow: hidden;
|
|
90
|
-
border-width: 2px;
|
|
91
|
-
border-color: var(--control-border-color);
|
|
92
|
-
border-radius: 4px;
|
|
93
|
-
width: 24px;
|
|
94
|
-
height: 24px;
|
|
95
|
-
color: var(--primary-accent-color-lighter);
|
|
96
|
-
transition: all 200ms;
|
|
97
|
-
}
|
|
98
|
-
.checkbox :global(button) :global(.icon) {
|
|
99
|
-
font-size: 20px;
|
|
100
|
-
}
|
|
101
|
-
.checkbox :global(button[aria-checked="true"]),
|
|
102
|
-
.checkbox :global(button[aria-checked="mixed"]) {
|
|
103
|
-
color: var(--primary-accent-color-lighter);
|
|
104
|
-
}
|
|
105
|
-
.checkbox :global(button[aria-checked="false"]) {
|
|
106
|
-
color: transparent;
|
|
107
|
-
}</style>
|
|
@@ -1,30 +0,0 @@
|
|
|
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 {
|
|
9
|
-
}
|
|
10
|
-
export type CheckboxProps = typeof __propDef.props;
|
|
11
|
-
export type CheckboxEvents = typeof __propDef.events;
|
|
12
|
-
export type CheckboxSlots = typeof __propDef.slots;
|
|
13
|
-
declare const __propDef: {
|
|
14
|
-
props: {
|
|
15
|
-
class?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
value?: (string | undefined);
|
|
18
|
-
checked?: (boolean | string | undefined);
|
|
19
|
-
indeterminate?: boolean;
|
|
20
|
-
};
|
|
21
|
-
events: {
|
|
22
|
-
change: CustomEvent<any>;
|
|
23
|
-
} & {
|
|
24
|
-
[evt: string]: CustomEvent<any>;
|
|
25
|
-
};
|
|
26
|
-
slots: {
|
|
27
|
-
default: {};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
@see https://w3c.github.io/aria/#dialog
|
|
4
|
-
@see https://w3c.github.io/aria-practices/#dialog_modal
|
|
5
|
-
-->
|
|
6
|
-
<script>
|
|
7
|
-
import { createEventDispatcher, onMount } from 'svelte';
|
|
8
|
-
import { _ } from 'svelte-i18n';
|
|
9
|
-
import Button from './button.svelte';
|
|
10
|
-
import Icon from './icon.svelte';
|
|
11
|
-
import Spacer from './spacer.svelte';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* CSS class name on the button.
|
|
15
|
-
* @type {String}
|
|
16
|
-
*/
|
|
17
|
-
let className = '';
|
|
18
|
-
|
|
19
|
-
export { className as class };
|
|
20
|
-
|
|
21
|
-
export let open = false;
|
|
22
|
-
|
|
23
|
-
export let title = '';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Width of the dialog.
|
|
27
|
-
* @type {('small'|'medium'|'large')}
|
|
28
|
-
*/
|
|
29
|
-
export let size = 'medium';
|
|
30
|
-
|
|
31
|
-
export let modal = true;
|
|
32
|
-
|
|
33
|
-
export let showCancel = true;
|
|
34
|
-
|
|
35
|
-
export let showOk = true;
|
|
36
|
-
|
|
37
|
-
export let showClose = false;
|
|
38
|
-
|
|
39
|
-
export let okLabel = '';
|
|
40
|
-
|
|
41
|
-
export let okDisabled = false;
|
|
42
|
-
|
|
43
|
-
export let cancelLabel = '';
|
|
44
|
-
|
|
45
|
-
export let cancelDisabled = false;
|
|
46
|
-
|
|
47
|
-
export let closeOnBackdropClick = false;
|
|
48
|
-
|
|
49
|
-
const dispatch = createEventDispatcher();
|
|
50
|
-
/** @type {?HTMLDialogElement} */
|
|
51
|
-
let dialog;
|
|
52
|
-
let showDialog = false;
|
|
53
|
-
let showContent = false;
|
|
54
|
-
let closeDialogTimer = 0;
|
|
55
|
-
|
|
56
|
-
$: {
|
|
57
|
-
if (dialog) {
|
|
58
|
-
if (open) {
|
|
59
|
-
window.clearTimeout(closeDialogTimer);
|
|
60
|
-
(document.querySelector('.sui.app-shell') || document.body).appendChild(dialog);
|
|
61
|
-
showContent = true;
|
|
62
|
-
|
|
63
|
-
if (modal) {
|
|
64
|
-
dialog.showModal();
|
|
65
|
-
} else {
|
|
66
|
-
dialog.show();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
window.requestAnimationFrame(() => {
|
|
70
|
-
showDialog = true;
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
showDialog = false;
|
|
74
|
-
|
|
75
|
-
closeDialogTimer = window.setTimeout(() => {
|
|
76
|
-
showContent = false;
|
|
77
|
-
dialog?.close();
|
|
78
|
-
dialog?.remove();
|
|
79
|
-
}, 500);
|
|
80
|
-
|
|
81
|
-
if (dialog.returnValue === 'ok') {
|
|
82
|
-
dispatch('ok');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (dialog.returnValue === 'cancel') {
|
|
86
|
-
dispatch('cancel');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
dispatch('close', dialog.returnValue);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
onMount(() => {
|
|
95
|
-
dialog.remove();
|
|
96
|
-
|
|
97
|
-
// onUnmount
|
|
98
|
-
return () => {
|
|
99
|
-
dialog?.close();
|
|
100
|
-
dialog?.remove();
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
</script>
|
|
104
|
-
|
|
105
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
106
|
-
<dialog
|
|
107
|
-
bind:this={dialog}
|
|
108
|
-
class="sui dialog {className} {size}"
|
|
109
|
-
class:open={showDialog}
|
|
110
|
-
on:click={({ target }) => {
|
|
111
|
-
if (closeOnBackdropClick && target?.matches('dialog')) {
|
|
112
|
-
dialog.returnValue = 'cancel';
|
|
113
|
-
open = false;
|
|
114
|
-
}
|
|
115
|
-
}}
|
|
116
|
-
on:cancel={() => {
|
|
117
|
-
// Cancelled with the Escape key
|
|
118
|
-
open = false;
|
|
119
|
-
}}
|
|
120
|
-
>
|
|
121
|
-
<form method="dialog" on:submit|preventDefault>
|
|
122
|
-
{#if showContent}
|
|
123
|
-
{#if title || showClose || $$slots.header || $$slots['header-extra']}
|
|
124
|
-
<div class="header">
|
|
125
|
-
{#if $$slots.header}
|
|
126
|
-
<slot name="header" />
|
|
127
|
-
{:else}
|
|
128
|
-
<div class="title">
|
|
129
|
-
{title}
|
|
130
|
-
</div>
|
|
131
|
-
<Spacer flex={true} />
|
|
132
|
-
{#if $$slots['header-extra']}
|
|
133
|
-
<slot name="header-extra" />
|
|
134
|
-
{/if}
|
|
135
|
-
{#if showClose}
|
|
136
|
-
<Button
|
|
137
|
-
class="ternary iconic"
|
|
138
|
-
on:click={() => {
|
|
139
|
-
dialog.returnValue = 'close';
|
|
140
|
-
open = false;
|
|
141
|
-
}}
|
|
142
|
-
>
|
|
143
|
-
<Icon slot="start-icon" name="close" label={$_('sui._.close')} />
|
|
144
|
-
</Button>
|
|
145
|
-
{/if}
|
|
146
|
-
{/if}
|
|
147
|
-
</div>
|
|
148
|
-
{/if}
|
|
149
|
-
<div class="main">
|
|
150
|
-
<slot />
|
|
151
|
-
</div>
|
|
152
|
-
{#if showOk || showCancel || $$slots.footer || $$slots['footer-extra']}
|
|
153
|
-
<div class="footer">
|
|
154
|
-
{#if $$slots.footer}
|
|
155
|
-
<slot name="footer" />
|
|
156
|
-
{:else}
|
|
157
|
-
{#if $$slots['footer-extra']}
|
|
158
|
-
<slot name="footer-extra" />
|
|
159
|
-
{/if}
|
|
160
|
-
<Spacer flex={true} />
|
|
161
|
-
{#if showOk}
|
|
162
|
-
<Button
|
|
163
|
-
class="primary"
|
|
164
|
-
label={okLabel || $_('sui._.ok')}
|
|
165
|
-
disabled={okDisabled}
|
|
166
|
-
on:click={() => {
|
|
167
|
-
dialog.returnValue = 'ok';
|
|
168
|
-
open = false;
|
|
169
|
-
}}
|
|
170
|
-
/>
|
|
171
|
-
{/if}
|
|
172
|
-
{#if showCancel}
|
|
173
|
-
<Button
|
|
174
|
-
class="secondary"
|
|
175
|
-
label={cancelLabel || $_('sui._.cancel')}
|
|
176
|
-
disabled={cancelDisabled}
|
|
177
|
-
on:click={() => {
|
|
178
|
-
dialog.returnValue = 'cancel';
|
|
179
|
-
open = false;
|
|
180
|
-
}}
|
|
181
|
-
/>
|
|
182
|
-
{/if}
|
|
183
|
-
{/if}
|
|
184
|
-
</div>
|
|
185
|
-
{/if}
|
|
186
|
-
{/if}
|
|
187
|
-
</form>
|
|
188
|
-
</dialog>
|
|
189
|
-
|
|
190
|
-
<style>dialog {
|
|
191
|
-
display: flex;
|
|
192
|
-
justify-content: center;
|
|
193
|
-
align-items: center;
|
|
194
|
-
background-color: var(--popup-backdrop-color);
|
|
195
|
-
}
|
|
196
|
-
dialog.open form {
|
|
197
|
-
opacity: 1;
|
|
198
|
-
transform: scale(100%);
|
|
199
|
-
transition-duration: 100ms;
|
|
200
|
-
}
|
|
201
|
-
dialog:not(.open) {
|
|
202
|
-
pointer-events: none !important;
|
|
203
|
-
}
|
|
204
|
-
dialog:not(.open) form {
|
|
205
|
-
opacity: 0;
|
|
206
|
-
transform: scale(90%);
|
|
207
|
-
pointer-events: none;
|
|
208
|
-
transition-duration: 200ms;
|
|
209
|
-
}
|
|
210
|
-
dialog:not(.open) :global(*) {
|
|
211
|
-
pointer-events: none !important;
|
|
212
|
-
}
|
|
213
|
-
dialog :global(a),
|
|
214
|
-
dialog :global(input),
|
|
215
|
-
dialog :global(textarea),
|
|
216
|
-
dialog :global(button),
|
|
217
|
-
dialog :global([tabindex="0"]) {
|
|
218
|
-
pointer-events: all;
|
|
219
|
-
}
|
|
220
|
-
dialog form {
|
|
221
|
-
display: flex;
|
|
222
|
-
flex-direction: column;
|
|
223
|
-
border-radius: 4px;
|
|
224
|
-
background-color: var(--secondary-background-color-translucent);
|
|
225
|
-
backdrop-filter: blur(16px);
|
|
226
|
-
box-shadow: 0 8px 16px var(--popup-shadow-color);
|
|
227
|
-
will-change: opacity, transform;
|
|
228
|
-
transition-property: opacity, transform;
|
|
229
|
-
}
|
|
230
|
-
dialog.small form {
|
|
231
|
-
width: 400px;
|
|
232
|
-
max-height: 400px;
|
|
233
|
-
}
|
|
234
|
-
dialog.medium form {
|
|
235
|
-
width: 600px;
|
|
236
|
-
max-height: 600px;
|
|
237
|
-
}
|
|
238
|
-
dialog.large form {
|
|
239
|
-
width: 800px;
|
|
240
|
-
max-height: 800px;
|
|
241
|
-
}
|
|
242
|
-
dialog.x-large form {
|
|
243
|
-
width: 1000px;
|
|
244
|
-
max-height: 1000px;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.header,
|
|
248
|
-
.footer {
|
|
249
|
-
display: flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: 8px;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
.header {
|
|
255
|
-
box-sizing: content-box;
|
|
256
|
-
margin: 0 16px;
|
|
257
|
-
border-width: 0 0 1px;
|
|
258
|
-
border-color: var(--secondary-border-color);
|
|
259
|
-
padding: 16px 8px;
|
|
260
|
-
height: 32px;
|
|
261
|
-
}
|
|
262
|
-
.header .title {
|
|
263
|
-
font-size: 16px;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.footer {
|
|
267
|
-
margin: 0 24px 24px;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.main {
|
|
271
|
-
overflow: auto;
|
|
272
|
-
margin: 24px 24px;
|
|
273
|
-
white-space: normal;
|
|
274
|
-
}</style>
|