@sveltia/ui 0.1.5 → 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 +22 -11
- 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 -206
- 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 -71
- 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 -104
- 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 -154
- 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 -145
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sveltia/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,32 +29,32 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.21.4",
|
|
31
31
|
"@babel/eslint-parser": "^7.21.3",
|
|
32
|
-
"@playwright/test": "^1.32.
|
|
32
|
+
"@playwright/test": "^1.32.3",
|
|
33
33
|
"@sveltejs/adapter-auto": "2.0.0",
|
|
34
|
-
"@sveltejs/kit": "1.15.
|
|
34
|
+
"@sveltejs/kit": "1.15.7",
|
|
35
35
|
"@sveltejs/package": "^2.0.2",
|
|
36
36
|
"cspell": "^6.31.1",
|
|
37
|
-
"eslint": "^8.
|
|
37
|
+
"eslint": "^8.39.0",
|
|
38
38
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
39
39
|
"eslint-config-prettier": "^8.8.0",
|
|
40
40
|
"eslint-plugin-import": "^2.27.5",
|
|
41
41
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
42
42
|
"npm-run-all": "^4.1.5",
|
|
43
|
-
"postcss": "^8.4.
|
|
43
|
+
"postcss": "^8.4.23",
|
|
44
44
|
"postcss-html": "^1.5.0",
|
|
45
|
-
"prettier": "^2.8.
|
|
45
|
+
"prettier": "^2.8.8",
|
|
46
46
|
"prettier-plugin-svelte": "^2.10.0",
|
|
47
|
-
"sass": "^1.
|
|
48
|
-
"stylelint": "^15.
|
|
49
|
-
"stylelint-config-recommended-scss": "^
|
|
47
|
+
"sass": "^1.62.0",
|
|
48
|
+
"stylelint": "^15.6.0",
|
|
49
|
+
"stylelint-config-recommended-scss": "^10.0.0",
|
|
50
50
|
"stylelint-scss": "^4.6.0",
|
|
51
51
|
"svelte-check": "^3.2.0",
|
|
52
52
|
"svelte-i18n": "^3.6.0",
|
|
53
53
|
"svelte-migrate": "^1.1.3",
|
|
54
54
|
"svelte-preprocess": "^5.0.3",
|
|
55
55
|
"tslib": "^2.5.0",
|
|
56
|
-
"vite": "^4.
|
|
57
|
-
"vitest": "^0.30.
|
|
56
|
+
"vite": "^4.3.1",
|
|
57
|
+
"vitest": "^0.30.1"
|
|
58
58
|
},
|
|
59
59
|
"exports": {
|
|
60
60
|
"./package.json": "./package.json",
|
|
@@ -133,6 +133,11 @@
|
|
|
133
133
|
"svelte": "./package/components/core/dialog.svelte",
|
|
134
134
|
"default": "./package/components/core/dialog.svelte"
|
|
135
135
|
},
|
|
136
|
+
"./components/core/drawer.svelte": {
|
|
137
|
+
"types": "./package/components/core/drawer.svelte.d.ts",
|
|
138
|
+
"svelte": "./package/components/core/drawer.svelte",
|
|
139
|
+
"default": "./package/components/core/drawer.svelte"
|
|
140
|
+
},
|
|
136
141
|
"./components/core/grid-cell.svelte": {
|
|
137
142
|
"types": "./package/components/core/grid-cell.svelte.d.ts",
|
|
138
143
|
"svelte": "./package/components/core/grid-cell.svelte",
|
|
@@ -360,6 +365,9 @@
|
|
|
360
365
|
"components/core/dialog.svelte": [
|
|
361
366
|
"./package/components/core/dialog.svelte.d.ts"
|
|
362
367
|
],
|
|
368
|
+
"components/core/drawer.svelte": [
|
|
369
|
+
"./package/components/core/drawer.svelte.d.ts"
|
|
370
|
+
],
|
|
363
371
|
"components/core/grid-cell.svelte": [
|
|
364
372
|
"./package/components/core/grid-cell.svelte.d.ts"
|
|
365
373
|
],
|
|
@@ -408,6 +416,9 @@
|
|
|
408
416
|
"components/core/separator.svelte": [
|
|
409
417
|
"./package/components/core/separator.svelte.d.ts"
|
|
410
418
|
],
|
|
419
|
+
"components/core/slider.svelte": [
|
|
420
|
+
"./package/components/core/slider.svelte.d.ts"
|
|
421
|
+
],
|
|
411
422
|
"components/core/spacer.svelte": [
|
|
412
423
|
"./package/components/core/spacer.svelte.d.ts"
|
|
413
424
|
],
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { _ } from 'svelte-i18n';
|
|
3
|
-
import Button from '../core/button.svelte';
|
|
4
|
-
import Icon from '../core/icon.svelte';
|
|
5
|
-
import Separator from '../core/separator.svelte';
|
|
6
|
-
import Spacer from '../core/spacer.svelte';
|
|
7
|
-
|
|
8
|
-
/** @type {(String|undefined)} */
|
|
9
|
-
export let value = undefined;
|
|
10
|
-
|
|
11
|
-
const dayList = [];
|
|
12
|
-
const weeks = [];
|
|
13
|
-
const now = new Date();
|
|
14
|
-
|
|
15
|
-
$: date = value ? new Date(value) : now;
|
|
16
|
-
$: firstDayOfMonth = new Date(date.getUTCFullYear(), date.getUTCMonth(), 1);
|
|
17
|
-
$: firstDay = new Date(firstDayOfMonth);
|
|
18
|
-
|
|
19
|
-
const getWeeks = () => {
|
|
20
|
-
const cursor = new Date(firstDay);
|
|
21
|
-
|
|
22
|
-
// Start from Sunday
|
|
23
|
-
cursor.setDate(1 - cursor.getUTCDay());
|
|
24
|
-
|
|
25
|
-
for (let i = 0; i < 42; i += 1) {
|
|
26
|
-
const week = Math.floor(i / 7);
|
|
27
|
-
|
|
28
|
-
dayList[i] = { day: new Date(cursor) };
|
|
29
|
-
weeks[week] ||= [];
|
|
30
|
-
weeks[week][cursor.getUTCDay() % 7] = { day: new Date(cursor) };
|
|
31
|
-
cursor.setUTCDate(cursor.getUTCDate() + 1);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
$: {
|
|
36
|
-
if (firstDay) {
|
|
37
|
-
getWeeks();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
</script>
|
|
41
|
-
|
|
42
|
-
<div role="group">
|
|
43
|
-
<input type="hidden" bind:value />
|
|
44
|
-
<div class="header">
|
|
45
|
-
<Button
|
|
46
|
-
class="ternary"
|
|
47
|
-
label={firstDay.toLocaleDateString('en', { year: 'numeric', month: 'short' })}
|
|
48
|
-
aria-haspopup="dialog"
|
|
49
|
-
>
|
|
50
|
-
<Icon slot="end-icon" name="arrow_drop_down" />
|
|
51
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
52
|
-
<div slot="popup" class="popup-inner" on:click|stopPropagation>
|
|
53
|
-
<div role="group" aria-label={$_('sui.calendar.year')}>
|
|
54
|
-
<div class="header">
|
|
55
|
-
<Button
|
|
56
|
-
on:click={() => {
|
|
57
|
-
//
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<Icon name="chevron_left" label={$_('sui.calendar.previous_decade')} />
|
|
61
|
-
</Button>
|
|
62
|
-
<Button
|
|
63
|
-
on:click={() => {
|
|
64
|
-
//
|
|
65
|
-
}}
|
|
66
|
-
>
|
|
67
|
-
<Icon name="chevron_right" label={$_('sui.calendar.next_decade')} />
|
|
68
|
-
</Button>
|
|
69
|
-
</div>
|
|
70
|
-
<div class="grid">
|
|
71
|
-
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] as year}
|
|
72
|
-
<div>
|
|
73
|
-
<Button>202{year}</Button>
|
|
74
|
-
</div>
|
|
75
|
-
{/each}
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
<Separator orientation="vertical" />
|
|
79
|
-
<div role="group" aria-label={$_('sui.calendar.month')}>
|
|
80
|
-
<div class="grid">
|
|
81
|
-
{#each [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] as month}
|
|
82
|
-
<div>
|
|
83
|
-
<Button>
|
|
84
|
-
{new Date(date.getUTCFullYear(), month, 10).toLocaleDateString('en', {
|
|
85
|
-
month: 'short',
|
|
86
|
-
})}
|
|
87
|
-
</Button>
|
|
88
|
-
</div>
|
|
89
|
-
{/each}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</Button>
|
|
94
|
-
<Button
|
|
95
|
-
on:click={() => {
|
|
96
|
-
firstDay.setUTCMonth(firstDay.getUTCMonth() - 1);
|
|
97
|
-
firstDay = firstDay;
|
|
98
|
-
}}
|
|
99
|
-
>
|
|
100
|
-
<Icon name="chevron_left" label={$_('sui.calendar.previous_month')} />
|
|
101
|
-
</Button>
|
|
102
|
-
<Button
|
|
103
|
-
on:click={() => {
|
|
104
|
-
firstDay.setUTCMonth(firstDay.getUTCMonth() + 1);
|
|
105
|
-
firstDay = firstDay;
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<Icon name="chevron_right" label={$_('sui.calendar.next_month')} />
|
|
109
|
-
</Button>
|
|
110
|
-
</div>
|
|
111
|
-
<div class="grid" role="listbox">
|
|
112
|
-
{#each dayList.slice(0, 7) as { day }}
|
|
113
|
-
<div class="weekday" role="presentation">
|
|
114
|
-
{day.toLocaleDateString('en', { weekday: 'narrow' })}
|
|
115
|
-
</div>
|
|
116
|
-
{/each}
|
|
117
|
-
{#each dayList as { day }}
|
|
118
|
-
<div
|
|
119
|
-
class:other-month={day.getUTCMonth() !== firstDay.getUTCMonth()}
|
|
120
|
-
class:today={day.getFullYear() === now.getFullYear() &&
|
|
121
|
-
day.getMonth() === now.getMonth() &&
|
|
122
|
-
day.getDate() === now.getDate()}
|
|
123
|
-
>
|
|
124
|
-
<Button
|
|
125
|
-
role="option"
|
|
126
|
-
aria-selected={false}
|
|
127
|
-
on:click={() => {
|
|
128
|
-
[value] = day.toJSON().split('T');
|
|
129
|
-
}}
|
|
130
|
-
>
|
|
131
|
-
{day.getUTCDate()}
|
|
132
|
-
</Button>
|
|
133
|
-
</div>
|
|
134
|
-
{/each}
|
|
135
|
-
</div>
|
|
136
|
-
<div class="footer">
|
|
137
|
-
<Button
|
|
138
|
-
on:click={() => {
|
|
139
|
-
value = '';
|
|
140
|
-
}}
|
|
141
|
-
>
|
|
142
|
-
{$_('sui.calendar.clear')}
|
|
143
|
-
</Button>
|
|
144
|
-
<Spacer flex={true} />
|
|
145
|
-
<Button
|
|
146
|
-
on:click={() => {
|
|
147
|
-
[value] = now.toJSON().split('T');
|
|
148
|
-
}}
|
|
149
|
-
>
|
|
150
|
-
{$_('sui.calendar.today')}
|
|
151
|
-
</Button>
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
<style>[role=group] {
|
|
156
|
-
display: inline-flex;
|
|
157
|
-
flex-direction: column;
|
|
158
|
-
gap: 8px;
|
|
159
|
-
-webkit-user-select: none;
|
|
160
|
-
user-select: none;
|
|
161
|
-
cursor: default;
|
|
162
|
-
font-size: 14px;
|
|
163
|
-
}
|
|
164
|
-
[role=group] > * {
|
|
165
|
-
flex: none;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.header,
|
|
169
|
-
.footer {
|
|
170
|
-
display: flex;
|
|
171
|
-
gap: 8px;
|
|
172
|
-
height: 24px;
|
|
173
|
-
align-items: center;
|
|
174
|
-
}
|
|
175
|
-
.header :global(button.secondary),
|
|
176
|
-
.footer :global(button.secondary) {
|
|
177
|
-
width: 100px;
|
|
178
|
-
flex: auto;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.grid {
|
|
182
|
-
display: grid !important;
|
|
183
|
-
grid-template-columns: repeat(auto-fill, 24px);
|
|
184
|
-
gap: 2px;
|
|
185
|
-
width: 180px;
|
|
186
|
-
}
|
|
187
|
-
.grid div {
|
|
188
|
-
display: flex;
|
|
189
|
-
justify-content: center;
|
|
190
|
-
align-items: center;
|
|
191
|
-
width: 24px;
|
|
192
|
-
height: 24px;
|
|
193
|
-
font-size: 12px;
|
|
194
|
-
}
|
|
195
|
-
.grid div.weekday {
|
|
196
|
-
color: var(--secondary-foreground-color);
|
|
197
|
-
}
|
|
198
|
-
.grid div.other-month {
|
|
199
|
-
color: var(--ternary-foreground-color);
|
|
200
|
-
}
|
|
201
|
-
.grid div.today :global(button) {
|
|
202
|
-
color: var(--highlight-foreground-color);
|
|
203
|
-
background-color: var(--primary-accent-color);
|
|
204
|
-
}
|
|
205
|
-
.grid div :global(button) {
|
|
206
|
-
justify-content: center;
|
|
207
|
-
width: 100%;
|
|
208
|
-
height: 24px;
|
|
209
|
-
border-radius: 50%;
|
|
210
|
-
}
|
|
211
|
-
.grid div :global(button):hover {
|
|
212
|
-
background-color: var(--highlight-background-color);
|
|
213
|
-
}
|
|
214
|
-
.grid div :global(button):focus {
|
|
215
|
-
border-width: 1px;
|
|
216
|
-
border-color: var(--primary-accent-color-lighter);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
.footer :global(button) {
|
|
220
|
-
font-size: 12px;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.popup-inner {
|
|
224
|
-
display: flex;
|
|
225
|
-
gap: 8px;
|
|
226
|
-
padding: 8px;
|
|
227
|
-
}
|
|
228
|
-
.popup-inner [role=group] {
|
|
229
|
-
gap: 0;
|
|
230
|
-
}
|
|
231
|
-
.popup-inner [role=group] .header {
|
|
232
|
-
justify-content: center;
|
|
233
|
-
}
|
|
234
|
-
.popup-inner .grid {
|
|
235
|
-
grid-template-columns: repeat(auto-fill, 48px);
|
|
236
|
-
width: 98px;
|
|
237
|
-
}
|
|
238
|
-
.popup-inner .grid > div {
|
|
239
|
-
width: 48px;
|
|
240
|
-
}</style>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} CalendarProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} CalendarEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} CalendarSlots */
|
|
4
|
-
export default class Calendar {
|
|
5
|
-
}
|
|
6
|
-
export type CalendarProps = typeof __propDef.props;
|
|
7
|
-
export type CalendarEvents = typeof __propDef.events;
|
|
8
|
-
export type CalendarSlots = typeof __propDef.slots;
|
|
9
|
-
declare const __propDef: {
|
|
10
|
-
props: {
|
|
11
|
-
value?: (string | undefined);
|
|
12
|
-
};
|
|
13
|
-
events: {
|
|
14
|
-
click: MouseEvent;
|
|
15
|
-
} & {
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
};
|
|
18
|
-
slots: {};
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
The container of `<Checkbox>`es.
|
|
4
|
-
-->
|
|
5
|
-
<script>
|
|
6
|
-
/**
|
|
7
|
-
* CSS class name on the button.
|
|
8
|
-
* @type {String}
|
|
9
|
-
*/
|
|
10
|
-
// eslint-disable-next-line padding-line-between-statements
|
|
11
|
-
let className = '';
|
|
12
|
-
|
|
13
|
-
export { className as class };
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The `aria-label` attribute on the button element.
|
|
17
|
-
* @type {String}
|
|
18
|
-
*/
|
|
19
|
-
export let ariaLabel = '';
|
|
20
|
-
|
|
21
|
-
/** @type {('horizontal'|'vertical')} */
|
|
22
|
-
export let orientation = 'horizontal';
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<div
|
|
26
|
-
class="sui checkbox-group {className} {orientation}"
|
|
27
|
-
role="group"
|
|
28
|
-
aria-label={ariaLabel}
|
|
29
|
-
{...$$restProps}
|
|
30
|
-
>
|
|
31
|
-
<slot />
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
<style>.checkbox-group {
|
|
35
|
-
display: inline-flex;
|
|
36
|
-
gap: 16px;
|
|
37
|
-
}
|
|
38
|
-
.checkbox-group.horizontal {
|
|
39
|
-
align-items: center;
|
|
40
|
-
}
|
|
41
|
-
.checkbox-group.vertical {
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
}</style>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} CheckboxGroupProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} CheckboxGroupEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} CheckboxGroupSlots */
|
|
4
|
-
/** The container of `<Checkbox>`es. */
|
|
5
|
-
export default class CheckboxGroup {
|
|
6
|
-
}
|
|
7
|
-
export type CheckboxGroupProps = typeof __propDef.props;
|
|
8
|
-
export type CheckboxGroupEvents = typeof __propDef.events;
|
|
9
|
-
export type CheckboxGroupSlots = typeof __propDef.slots;
|
|
10
|
-
declare const __propDef: {
|
|
11
|
-
props: {
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
class?: string;
|
|
14
|
-
orientation?: ('horizontal' | 'vertical');
|
|
15
|
-
ariaLabel?: string;
|
|
16
|
-
};
|
|
17
|
-
events: {
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
};
|
|
20
|
-
slots: {
|
|
21
|
-
default: {};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@component
|
|
3
|
-
@see https://w3c.github.io/aria/#combobox
|
|
4
|
-
@see https://w3c.github.io/aria-practices/#combobox
|
|
5
|
-
-->
|
|
6
|
-
<script>
|
|
7
|
-
import { createEventDispatcher } from 'svelte';
|
|
8
|
-
import { _ } from 'svelte-i18n';
|
|
9
|
-
import { writable } from 'svelte/store';
|
|
10
|
-
import Button from '../core/button.svelte';
|
|
11
|
-
import Icon from '../core/icon.svelte';
|
|
12
|
-
import TextInput from '../core/text-input.svelte';
|
|
13
|
-
import { getRandomId } from '../helpers/util';
|
|
14
|
-
import Popup from '../util/popup.svelte';
|
|
15
|
-
import Listbox from './listbox.svelte';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* CSS class name on the button.
|
|
19
|
-
* @type {String}
|
|
20
|
-
*/
|
|
21
|
-
let className = '';
|
|
22
|
-
|
|
23
|
-
export { className as class };
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Where to show the dropdown menu.
|
|
27
|
-
* @type {PopupPosition}
|
|
28
|
-
*/
|
|
29
|
-
export let position = 'bottom-left';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Whether the textbox is editable.
|
|
33
|
-
*/
|
|
34
|
-
export let readOnly = false;
|
|
35
|
-
|
|
36
|
-
export let disabled = false;
|
|
37
|
-
|
|
38
|
-
export let label = '';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Selected option’s value.
|
|
42
|
-
* @type {(String|undefined)}
|
|
43
|
-
*/
|
|
44
|
-
export let value = undefined;
|
|
45
|
-
|
|
46
|
-
const dispatch = createEventDispatcher();
|
|
47
|
-
const id = getRandomId('combobox');
|
|
48
|
-
let comboboxElement;
|
|
49
|
-
/** @type {(TextInput| undefined)} */
|
|
50
|
-
let inputComponent;
|
|
51
|
-
/** @type {(Popup| undefined)} */
|
|
52
|
-
let popupComponent;
|
|
53
|
-
let isPopupOpen = writable(false);
|
|
54
|
-
|
|
55
|
-
$: {
|
|
56
|
-
dispatch('change', { target: inputComponent?.element, value });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
$: {
|
|
60
|
-
if (readOnly && value && popupComponent?.element) {
|
|
61
|
-
window.requestAnimationFrame(() => {
|
|
62
|
-
label =
|
|
63
|
-
popupComponent?.element.querySelector('[aria-selected="true"] .label')?.textContent || '';
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<div class="sui combobox {className}">
|
|
70
|
-
{#if readOnly}
|
|
71
|
-
<div
|
|
72
|
-
class:selected={value !== undefined}
|
|
73
|
-
role="combobox"
|
|
74
|
-
{id}
|
|
75
|
-
tabindex="0"
|
|
76
|
-
aria-controls="{id}-popup"
|
|
77
|
-
aria-expanded={$isPopupOpen}
|
|
78
|
-
aria-disabled={disabled ? true : undefined}
|
|
79
|
-
aria-haspopup="listbox"
|
|
80
|
-
aria-activedescendant="selected-option"
|
|
81
|
-
{...$$restProps}
|
|
82
|
-
bind:this={comboboxElement}
|
|
83
|
-
>
|
|
84
|
-
<div class="label">
|
|
85
|
-
{value !== undefined ? label || value : $_('sui.combobox.select_an_option')}
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
{:else}
|
|
89
|
-
<TextInput
|
|
90
|
-
role="combobox"
|
|
91
|
-
{id}
|
|
92
|
-
{value}
|
|
93
|
-
{disabled}
|
|
94
|
-
aria-controls="{id}-popup"
|
|
95
|
-
aria-expanded={$isPopupOpen}
|
|
96
|
-
aria-disabled={disabled ? true : undefined}
|
|
97
|
-
aria-haspopup="listbox"
|
|
98
|
-
aria-activedescendant="selected-option"
|
|
99
|
-
{...$$restProps}
|
|
100
|
-
bind:this={inputComponent}
|
|
101
|
-
/>
|
|
102
|
-
{/if}
|
|
103
|
-
<Button
|
|
104
|
-
{disabled}
|
|
105
|
-
aria-controls="{id}-popup"
|
|
106
|
-
aria-expanded={$isPopupOpen}
|
|
107
|
-
aria-disabled={disabled ? true : undefined}
|
|
108
|
-
class="ternary iconic"
|
|
109
|
-
on:click={(event) => {
|
|
110
|
-
event.stopPropagation();
|
|
111
|
-
|
|
112
|
-
if (!disabled) {
|
|
113
|
-
$isPopupOpen = !$isPopupOpen;
|
|
114
|
-
}
|
|
115
|
-
}}
|
|
116
|
-
>
|
|
117
|
-
<Icon
|
|
118
|
-
slot="start-icon"
|
|
119
|
-
name="expand_more"
|
|
120
|
-
label={$isPopupOpen ? $_('sui._.collapse') : $_('sui._.expand')}
|
|
121
|
-
/>
|
|
122
|
-
</Button>
|
|
123
|
-
</div>
|
|
124
|
-
<Popup
|
|
125
|
-
id="{id}-popup"
|
|
126
|
-
anchor={comboboxElement || inputComponent?.element}
|
|
127
|
-
{position}
|
|
128
|
-
bind:open={isPopupOpen}
|
|
129
|
-
bind:this={popupComponent}
|
|
130
|
-
>
|
|
131
|
-
<Listbox
|
|
132
|
-
on:click={({ target }) => {
|
|
133
|
-
if (target.matches('[role="option"]')) {
|
|
134
|
-
value = target.value;
|
|
135
|
-
}
|
|
136
|
-
}}
|
|
137
|
-
>
|
|
138
|
-
<slot />
|
|
139
|
-
</Listbox>
|
|
140
|
-
</Popup>
|
|
141
|
-
|
|
142
|
-
<style>.combobox {
|
|
143
|
-
display: flex;
|
|
144
|
-
align-items: center;
|
|
145
|
-
position: relative;
|
|
146
|
-
}
|
|
147
|
-
.combobox :global(.icon) {
|
|
148
|
-
font-size: 20px;
|
|
149
|
-
opacity: 0.5;
|
|
150
|
-
}
|
|
151
|
-
.combobox > :global(.icon) {
|
|
152
|
-
position: absolute;
|
|
153
|
-
inset: 8px auto auto 8px;
|
|
154
|
-
z-index: 1;
|
|
155
|
-
}
|
|
156
|
-
.combobox > :global(button) {
|
|
157
|
-
position: absolute;
|
|
158
|
-
inset: 0 0 auto auto;
|
|
159
|
-
z-index: 1;
|
|
160
|
-
}
|
|
161
|
-
.combobox div[role=combobox] {
|
|
162
|
-
display: flex;
|
|
163
|
-
align-items: center;
|
|
164
|
-
border-width: 1px;
|
|
165
|
-
border-color: var(--control-border-color);
|
|
166
|
-
border-radius: 4px;
|
|
167
|
-
padding: 0 32px 0 8px;
|
|
168
|
-
width: 100%;
|
|
169
|
-
height: var(--input--medium--height);
|
|
170
|
-
-webkit-user-select: none;
|
|
171
|
-
user-select: none;
|
|
172
|
-
cursor: pointer;
|
|
173
|
-
}
|
|
174
|
-
.combobox div[role=combobox]:not(.selected) {
|
|
175
|
-
font-style: italic;
|
|
176
|
-
}
|
|
177
|
-
.combobox div[role=combobox][aria-disabled=true] {
|
|
178
|
-
background-color: var(--disabled-background-color);
|
|
179
|
-
opacity: 0.4;
|
|
180
|
-
cursor: default;
|
|
181
|
-
}
|
|
182
|
-
.combobox div[role=combobox] .label {
|
|
183
|
-
display: block;
|
|
184
|
-
overflow: hidden;
|
|
185
|
-
width: 100%;
|
|
186
|
-
white-space: nowrap;
|
|
187
|
-
text-overflow: ellipsis;
|
|
188
|
-
}
|
|
189
|
-
.combobox :global(input) {
|
|
190
|
-
padding: 0 32px 0 8px;
|
|
191
|
-
width: 100%;
|
|
192
|
-
}
|
|
193
|
-
.combobox + :global([role="listbox"]) {
|
|
194
|
-
position: fixed;
|
|
195
|
-
z-index: 100;
|
|
196
|
-
border-radius: 4px;
|
|
197
|
-
box-shadow: 0 8px 16px var(--popup-shadow-color);
|
|
198
|
-
overflow: auto;
|
|
199
|
-
background-color: var(--secondary-background-color);
|
|
200
|
-
backdrop-filter: blur(16px);
|
|
201
|
-
transition: opacity 100ms 100ms;
|
|
202
|
-
}
|
|
203
|
-
.combobox + :global([role="listbox"]:not(.open)) {
|
|
204
|
-
opacity: 0;
|
|
205
|
-
pointer-events: none;
|
|
206
|
-
}</style>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/** @typedef {typeof __propDef.props} ComboboxProps */
|
|
2
|
-
/** @typedef {typeof __propDef.events} ComboboxEvents */
|
|
3
|
-
/** @typedef {typeof __propDef.slots} ComboboxSlots */
|
|
4
|
-
/**
|
|
5
|
-
* @see https://w3c.github.io/aria/#combobox
|
|
6
|
-
* @see https://w3c.github.io/aria-practices/#combobox
|
|
7
|
-
*/
|
|
8
|
-
export default class Combobox {
|
|
9
|
-
}
|
|
10
|
-
export type ComboboxProps = typeof __propDef.props;
|
|
11
|
-
export type ComboboxEvents = typeof __propDef.events;
|
|
12
|
-
export type ComboboxSlots = typeof __propDef.slots;
|
|
13
|
-
declare const __propDef: {
|
|
14
|
-
props: {
|
|
15
|
-
[x: string]: any;
|
|
16
|
-
label?: string;
|
|
17
|
-
position?: any;
|
|
18
|
-
class?: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
value?: (string | undefined);
|
|
21
|
-
readOnly?: boolean;
|
|
22
|
-
};
|
|
23
|
-
events: {
|
|
24
|
-
change: CustomEvent<any>;
|
|
25
|
-
} & {
|
|
26
|
-
[evt: string]: CustomEvent<any>;
|
|
27
|
-
};
|
|
28
|
-
slots: {
|
|
29
|
-
default: {};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export {};
|