svelte-multistyle-ui 0.0.3-alpha → 0.0.5-alpha
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/README.md +1 -1
- package/cli/bin.js +90 -0
- package/cli/emit.js +228 -0
- package/cli/fixtures/sample.expected.svelte +69 -0
- package/cli/fixtures/sample.yaml +128 -0
- package/cli/generate.js +68 -0
- package/cli/registry.js +95 -0
- package/cli/schema.js +145 -0
- package/dist/components/Button.svelte +3 -1
- package/dist/components/Button.svelte.d.ts +2 -0
- package/dist/components/DatePicker.svelte +176 -55
- package/dist/components/FAB.svelte +3 -1
- package/dist/components/FAB.svelte.d.ts +2 -0
- package/dist/components/IconButton.svelte +3 -1
- package/dist/components/IconButton.svelte.d.ts +2 -0
- package/dist/components/Input.svelte +3 -3
- package/dist/components/MultiSelect.svelte +19 -2
- package/dist/components/Select.svelte +4 -3
- package/dist/components/Stepper.svelte +91 -33
- package/dist/components/Textarea.svelte +1 -2
- package/dist/components/accordion-styles.css +1 -9
- package/dist/components/alert-styles.css +1 -4
- package/dist/components/avatar-styles.css +1 -4
- package/dist/components/breadcrumb-styles.css +1 -7
- package/dist/components/button-styles.css +44 -52
- package/dist/components/buttongroup-styles.css +1 -5
- package/dist/components/card-styles.css +1 -9
- package/dist/components/carousel-styles.css +1 -5
- package/dist/components/charts/Chart.svelte +63 -3
- package/dist/components/charts/chart-config.d.ts +27 -2
- package/dist/components/charts/chart-config.js +180 -67
- package/dist/components/charts/chart-styles.css +32 -17
- package/dist/components/checkbox-styles.css +2 -10
- package/dist/components/chip-styles.css +1 -4
- package/dist/components/commandpalette-styles.css +0 -4
- package/dist/components/datepicker-styles.css +967 -1011
- package/dist/components/divider-styles.css +1 -4
- package/dist/components/drawer-styles.css +0 -4
- package/dist/components/dropdown-styles.css +0 -5
- package/dist/components/fab-styles.css +18 -12
- package/dist/components/fileupload-styles.css +2 -10
- package/dist/components/iconbutton-styles.css +33 -34
- package/dist/components/input-styles.css +17 -50
- package/dist/components/modal-styles.css +0 -8
- package/dist/components/multiselect-styles.css +167 -31
- package/dist/components/pagination-styles.css +2 -5
- package/dist/components/popover-styles.css +0 -4
- package/dist/components/progressbar-styles.css +1 -5
- package/dist/components/radio-styles.css +1 -8
- package/dist/components/rating-styles.css +1 -4
- package/dist/components/select-styles.css +50 -21
- package/dist/components/skeleton-styles.css +1 -4
- package/dist/components/slider-styles.css +1 -5
- package/dist/components/sortablelist-styles.css +0 -13
- package/dist/components/spinner-styles.css +1 -4
- package/dist/components/stepper-styles.css +59 -8
- package/dist/components/table-styles.css +1 -5
- package/dist/components/tabs-styles.css +3 -7
- package/dist/components/textarea-styles.css +6 -19
- package/dist/components/theme-base.css +19 -2
- package/dist/components/theme.css +329 -333
- package/dist/components/toast-styles.css +1 -4
- package/dist/components/toggle-styles.css +1 -11
- package/dist/components/tooltip-styles.css +1 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/themes/color.d.ts +52 -0
- package/dist/themes/color.js +91 -0
- package/dist/themes/generator.d.ts +41 -0
- package/dist/themes/generator.js +174 -0
- package/dist/themes/index.d.ts +3 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/presets.d.ts +445 -0
- package/dist/themes/presets.js +144 -0
- package/dist/themes/schema.d.ts +47 -0
- package/dist/themes/schema.js +34 -0
- package/package.json +19 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./datepicker-styles.css";
|
|
3
3
|
import { defaults, iconClass } from "../config.js";
|
|
4
|
+
import { portal } from "../actions/portal.js";
|
|
4
5
|
import dayjs from "dayjs";
|
|
5
6
|
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
6
7
|
dayjs.extend(customParseFormat);
|
|
@@ -28,8 +29,6 @@
|
|
|
28
29
|
const internalId = `dp-${uid}`;
|
|
29
30
|
const dispFormat = $derived(displayFormat ?? format);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
32
|
// State
|
|
34
33
|
let open = $state(false);
|
|
35
34
|
let view = $state("date");
|
|
@@ -37,7 +36,6 @@
|
|
|
37
36
|
let selectedDate = $state(null);
|
|
38
37
|
let isMobile = $state(false);
|
|
39
38
|
|
|
40
|
-
|
|
41
39
|
// Format helpers — uses dayjs for full format support (MMM, MMMM, etc.)
|
|
42
40
|
function toDayjsFmt(f) {
|
|
43
41
|
return f.replace(/hh/g, "HH");
|
|
@@ -54,14 +52,20 @@
|
|
|
54
52
|
|
|
55
53
|
// Derived
|
|
56
54
|
const displayValue = $derived(
|
|
57
|
-
value ? fmt(parseDate(value, format) || new Date(), dispFormat) : ""
|
|
55
|
+
value ? fmt(parseDate(value, format) || new Date(), dispFormat) : "",
|
|
58
56
|
);
|
|
59
57
|
const inputPlaceholder = $derived(placeholder || dispFormat.toLowerCase());
|
|
60
58
|
|
|
61
59
|
// Floating-label support — mirrors Input.svelte so the label sits inside the
|
|
62
60
|
// border (floats up on focus/value) for outlined styles, and renders no
|
|
63
61
|
// in-field label for the non-floating styles, exactly like Input.
|
|
64
|
-
const floatingStyles = [
|
|
62
|
+
const floatingStyles = [
|
|
63
|
+
"material",
|
|
64
|
+
"material3",
|
|
65
|
+
"fluent",
|
|
66
|
+
"carbon",
|
|
67
|
+
"bootstrap",
|
|
68
|
+
];
|
|
65
69
|
const hasFloatingLabel = $derived(floatingStyles.includes(style) && !!label);
|
|
66
70
|
const hasValue = $derived(!!value);
|
|
67
71
|
const floated = $derived(open || hasValue);
|
|
@@ -76,13 +80,13 @@
|
|
|
76
80
|
|
|
77
81
|
const months = $derived(
|
|
78
82
|
Array.from({ length: 12 }, (_, i) =>
|
|
79
|
-
new Date(2000, i, 1).toLocaleString(locale, { month: "short" })
|
|
80
|
-
)
|
|
83
|
+
new Date(2000, i, 1).toLocaleString(locale, { month: "short" }),
|
|
84
|
+
),
|
|
81
85
|
);
|
|
82
86
|
const weekdays = $derived(
|
|
83
87
|
Array.from({ length: 7 }, (_, i) =>
|
|
84
|
-
new Date(2000, 0, i + 2).toLocaleString(locale, { weekday: "short" })
|
|
85
|
-
)
|
|
88
|
+
new Date(2000, 0, i + 2).toLocaleString(locale, { weekday: "short" }),
|
|
89
|
+
),
|
|
86
90
|
);
|
|
87
91
|
|
|
88
92
|
function calendarDays(year, month) {
|
|
@@ -93,27 +97,41 @@
|
|
|
93
97
|
for (let i = fd - 1; i >= 0; i--) days.push({ d: pmd - i, o: true });
|
|
94
98
|
for (let i = 1; i <= dim; i++) days.push({ d: i, o: false });
|
|
95
99
|
let n = 1;
|
|
96
|
-
while (days.length < 42) {
|
|
100
|
+
while (days.length < 42) {
|
|
101
|
+
days.push({ d: n++, o: true });
|
|
102
|
+
}
|
|
97
103
|
return days;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
const calDays = $derived(calendarDays(viewYear, viewMonth));
|
|
101
107
|
const yearList = $derived(
|
|
102
|
-
Array.from({ length: 12 }, (_, i) => decadeStart + i)
|
|
108
|
+
Array.from({ length: 12 }, (_, i) => decadeStart + i),
|
|
103
109
|
);
|
|
104
110
|
|
|
105
111
|
function isToday(d, o) {
|
|
106
112
|
if (o) return false;
|
|
107
113
|
const t = new Date();
|
|
108
|
-
return
|
|
114
|
+
return (
|
|
115
|
+
d === t.getDate() &&
|
|
116
|
+
viewMonth === t.getMonth() &&
|
|
117
|
+
viewYear === t.getFullYear()
|
|
118
|
+
);
|
|
109
119
|
}
|
|
110
120
|
|
|
111
121
|
function isDisabled(d, o) {
|
|
112
122
|
if (o) return true;
|
|
113
123
|
const dt = new Date(viewYear, viewMonth, d);
|
|
114
124
|
const day = new Date(dt.getFullYear(), dt.getMonth(), dt.getDate());
|
|
115
|
-
const minDay = minDate
|
|
116
|
-
|
|
125
|
+
const minDay = minDate
|
|
126
|
+
? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())
|
|
127
|
+
: null;
|
|
128
|
+
const maxDay = maxDate
|
|
129
|
+
? new Date(
|
|
130
|
+
maxDate.getFullYear(),
|
|
131
|
+
maxDate.getMonth(),
|
|
132
|
+
maxDate.getDate() + 1,
|
|
133
|
+
)
|
|
134
|
+
: null;
|
|
117
135
|
if (minDay && day < minDay) return true;
|
|
118
136
|
if (maxDay && day >= maxDay) return true;
|
|
119
137
|
return false;
|
|
@@ -121,7 +139,11 @@
|
|
|
121
139
|
|
|
122
140
|
function isSelected(d, o) {
|
|
123
141
|
if (!selectedDate || o) return false;
|
|
124
|
-
return
|
|
142
|
+
return (
|
|
143
|
+
d === selectedDate.getDate() &&
|
|
144
|
+
viewMonth === selectedDate.getMonth() &&
|
|
145
|
+
viewYear === selectedDate.getFullYear()
|
|
146
|
+
);
|
|
125
147
|
}
|
|
126
148
|
|
|
127
149
|
// Navigation
|
|
@@ -141,7 +163,11 @@
|
|
|
141
163
|
if (o) return;
|
|
142
164
|
const dt = new Date(viewYear, viewMonth, d);
|
|
143
165
|
if (selectedDate) {
|
|
144
|
-
dt.setHours(
|
|
166
|
+
dt.setHours(
|
|
167
|
+
selectedDate.getHours(),
|
|
168
|
+
selectedDate.getMinutes(),
|
|
169
|
+
selectedDate.getSeconds(),
|
|
170
|
+
);
|
|
145
171
|
}
|
|
146
172
|
selectedDate = dt;
|
|
147
173
|
value = fmt(dt, format);
|
|
@@ -164,23 +190,56 @@
|
|
|
164
190
|
|
|
165
191
|
// Click outside
|
|
166
192
|
let wrapperEl;
|
|
193
|
+
let overlayEl;
|
|
167
194
|
|
|
168
195
|
function docClick(e) {
|
|
169
|
-
|
|
196
|
+
// overlay is portaled to <body>, so it is no longer inside wrapperEl —
|
|
197
|
+
// treat it as part of the picker for outside-click purposes.
|
|
198
|
+
if (open && wrapperEl && !wrapperEl.contains(e.target) &&
|
|
199
|
+
!(overlayEl && overlayEl.contains(e.target))) {
|
|
170
200
|
open = false;
|
|
171
201
|
}
|
|
172
202
|
}
|
|
173
203
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
204
|
+
// Position the portaled overlay (fixed) anchored to the input. On mobile it
|
|
205
|
+
// is a fullscreen sheet driven by CSS, so anchoring is skipped.
|
|
206
|
+
function positionOverlay() {
|
|
207
|
+
if (!overlayEl || !wrapperEl || isMobile) return;
|
|
208
|
+
const rect = wrapperEl.getBoundingClientRect();
|
|
209
|
+
const ovW = overlayEl.offsetWidth || 320;
|
|
210
|
+
const ovH = overlayEl.offsetHeight || 360;
|
|
211
|
+
let left = rect.left;
|
|
212
|
+
const maxLeft = window.innerWidth - ovW - 8;
|
|
213
|
+
if (left > maxLeft) left = maxLeft;
|
|
214
|
+
if (left < 8) left = 8;
|
|
215
|
+
let top = rect.bottom + 4;
|
|
216
|
+
// Flip above the field if it would overflow the bottom of the viewport.
|
|
217
|
+
if (top + ovH > window.innerHeight - 8 && rect.top - ovH - 4 > 8) {
|
|
218
|
+
top = rect.top - ovH - 4;
|
|
183
219
|
}
|
|
220
|
+
overlayEl.style.position = "fixed";
|
|
221
|
+
overlayEl.style.left = `${left}px`;
|
|
222
|
+
overlayEl.style.top = `${top}px`;
|
|
223
|
+
overlayEl.style.zIndex = "10000";
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
$effect(() => {
|
|
227
|
+
if (!open) return;
|
|
228
|
+
document.addEventListener("mousedown", docClick);
|
|
229
|
+
document.addEventListener("touchstart", docClick);
|
|
230
|
+
checkMobile();
|
|
231
|
+
// Re-anchor on any scroll (capture: catches scroll inside ancestor cards)
|
|
232
|
+
// and on resize; reposition once the portaled overlay is mounted.
|
|
233
|
+
const reposition = () => positionOverlay();
|
|
234
|
+
window.addEventListener("scroll", reposition, true);
|
|
235
|
+
window.addEventListener("resize", reposition);
|
|
236
|
+
queueMicrotask(reposition);
|
|
237
|
+
return () => {
|
|
238
|
+
document.removeEventListener("mousedown", docClick);
|
|
239
|
+
document.removeEventListener("touchstart", docClick);
|
|
240
|
+
window.removeEventListener("scroll", reposition, true);
|
|
241
|
+
window.removeEventListener("resize", reposition);
|
|
242
|
+
};
|
|
184
243
|
});
|
|
185
244
|
|
|
186
245
|
// Init from value
|
|
@@ -230,7 +289,7 @@
|
|
|
230
289
|
class="s-datepicker-wrapper {styleClass} {themeClass}"
|
|
231
290
|
class:s-datepicker-open={open}
|
|
232
291
|
class:focused={open}
|
|
233
|
-
class:floated
|
|
292
|
+
class:floated
|
|
234
293
|
class:has-value={hasValue}
|
|
235
294
|
class:disabled
|
|
236
295
|
bind:this={wrapperEl}
|
|
@@ -246,42 +305,76 @@
|
|
|
246
305
|
value={displayValue}
|
|
247
306
|
placeholder={hasFloatingLabel ? "" : inputPlaceholder}
|
|
248
307
|
{disabled}
|
|
249
|
-
onfocus={() => {
|
|
250
|
-
|
|
308
|
+
onfocus={() => {
|
|
309
|
+
if (!disabled) open = true;
|
|
310
|
+
}}
|
|
311
|
+
onclick={() => {
|
|
312
|
+
if (!disabled) open = true;
|
|
313
|
+
}}
|
|
251
314
|
role="combobox"
|
|
252
315
|
aria-expanded={open}
|
|
253
316
|
aria-haspopup="dialog"
|
|
254
317
|
/>
|
|
255
|
-
<span class="s-datepicker-trigger-icon {iconClass}" aria-hidden="true"
|
|
318
|
+
<span class="s-datepicker-trigger-icon {iconClass}" aria-hidden="true"
|
|
319
|
+
>calendar_today</span
|
|
320
|
+
>
|
|
256
321
|
|
|
257
322
|
{#if open}
|
|
258
323
|
<div
|
|
259
|
-
class="s-datepicker-overlay"
|
|
324
|
+
class="s-datepicker-overlay {styleClass} {themeClass}"
|
|
260
325
|
class:s-datepicker-mobile={isMobile}
|
|
326
|
+
bind:this={overlayEl}
|
|
327
|
+
use:portal
|
|
261
328
|
role="dialog"
|
|
262
329
|
aria-modal="true"
|
|
263
330
|
aria-label="Date picker"
|
|
264
331
|
>
|
|
265
332
|
<!-- Header -->
|
|
266
333
|
<div class="s-dp-header">
|
|
267
|
-
<button
|
|
334
|
+
<button
|
|
335
|
+
type="button"
|
|
336
|
+
class="s-dp-nav-btn"
|
|
337
|
+
onclick={prev}
|
|
338
|
+
aria-label="Previous">‹</button
|
|
339
|
+
>
|
|
268
340
|
<div class="s-dp-header-labels">
|
|
269
341
|
{#if view === "date"}
|
|
270
|
-
<button
|
|
271
|
-
|
|
342
|
+
<button
|
|
343
|
+
type="button"
|
|
344
|
+
class="s-dp-header-label"
|
|
345
|
+
onclick={() => (view = "month")}
|
|
346
|
+
>
|
|
347
|
+
{new Date(2000, viewMonth, 1).toLocaleString(locale, {
|
|
348
|
+
month: "long",
|
|
349
|
+
})}
|
|
272
350
|
</button>
|
|
273
|
-
<button
|
|
351
|
+
<button
|
|
352
|
+
type="button"
|
|
353
|
+
class="s-dp-header-label"
|
|
354
|
+
onclick={() => (view = "year")}
|
|
355
|
+
>
|
|
274
356
|
{viewYear}
|
|
275
357
|
</button>
|
|
276
358
|
{:else if view === "month"}
|
|
277
|
-
<button
|
|
359
|
+
<button
|
|
360
|
+
type="button"
|
|
361
|
+
class="s-dp-header-label s-dp-header-label-active"
|
|
362
|
+
onclick={() => (view = "year")}
|
|
363
|
+
>
|
|
278
364
|
{viewYear}
|
|
279
365
|
</button>
|
|
280
366
|
{:else}
|
|
281
|
-
<span class="s-dp-header-label s-dp-header-label-active"
|
|
367
|
+
<span class="s-dp-header-label s-dp-header-label-active"
|
|
368
|
+
>{decadeStart} – {decadeEnd}</span
|
|
369
|
+
>
|
|
282
370
|
{/if}
|
|
283
371
|
</div>
|
|
284
|
-
<button
|
|
372
|
+
<button
|
|
373
|
+
type="button"
|
|
374
|
+
class="s-dp-nav-btn"
|
|
375
|
+
onclick={next}
|
|
376
|
+
aria-label="Next">›</button
|
|
377
|
+
>
|
|
285
378
|
</div>
|
|
286
379
|
|
|
287
380
|
<!-- Date view -->
|
|
@@ -301,34 +394,37 @@
|
|
|
301
394
|
class:s-dp-selected={isSelected(cd.d, cd.o)}
|
|
302
395
|
class:s-dp-day-disabled={isDisabled(cd.d, cd.o)}
|
|
303
396
|
onclick={() => selectDay(cd.d, cd.o)}
|
|
304
|
-
disabled={cd.o || isDisabled(cd.d, cd.o)}
|
|
305
|
-
>
|
|
397
|
+
disabled={cd.o || isDisabled(cd.d, cd.o)}>{cd.d}</button
|
|
398
|
+
>
|
|
306
399
|
{/each}
|
|
307
400
|
</div>
|
|
308
401
|
|
|
309
|
-
|
|
402
|
+
<!-- Month view -->
|
|
310
403
|
{:else if view === "month"}
|
|
311
404
|
<div class="s-dp-months-grid">
|
|
312
405
|
{#each months as m, i}
|
|
313
406
|
<button
|
|
314
407
|
type="button"
|
|
315
408
|
class="s-dp-month"
|
|
316
|
-
class:s-dp-selected={selectedDate &&
|
|
317
|
-
|
|
318
|
-
|
|
409
|
+
class:s-dp-selected={selectedDate &&
|
|
410
|
+
i === selectedDate.getMonth() &&
|
|
411
|
+
viewYear === selectedDate.getFullYear()}
|
|
412
|
+
onclick={() => selectMonth(i)}>{m}</button
|
|
413
|
+
>
|
|
319
414
|
{/each}
|
|
320
415
|
</div>
|
|
321
416
|
|
|
322
|
-
|
|
417
|
+
<!-- Year view (decade) -->
|
|
323
418
|
{:else}
|
|
324
419
|
<div class="s-dp-years-grid">
|
|
325
420
|
{#each yearList as y (y)}
|
|
326
421
|
<button
|
|
327
422
|
type="button"
|
|
328
423
|
class="s-dp-year"
|
|
329
|
-
class:s-dp-selected={selectedDate &&
|
|
330
|
-
|
|
331
|
-
|
|
424
|
+
class:s-dp-selected={selectedDate &&
|
|
425
|
+
y === selectedDate.getFullYear()}
|
|
426
|
+
onclick={() => selectYear(y)}>{y}</button
|
|
427
|
+
>
|
|
332
428
|
{/each}
|
|
333
429
|
</div>
|
|
334
430
|
{/if}
|
|
@@ -339,18 +435,39 @@
|
|
|
339
435
|
<span class="s-dp-time-label">Time</span>
|
|
340
436
|
<div class="s-dp-time-inputs">
|
|
341
437
|
{#if showHours}
|
|
342
|
-
<input
|
|
343
|
-
|
|
438
|
+
<input
|
|
439
|
+
type="number"
|
|
440
|
+
class="s-dp-time-input"
|
|
441
|
+
min={0}
|
|
442
|
+
max={23}
|
|
443
|
+
value={currentHour}
|
|
444
|
+
oninput={(e) => setHour(parseInt(e.target.value) || 0)}
|
|
445
|
+
aria-label="Hour"
|
|
446
|
+
/>
|
|
344
447
|
<span class="s-dp-time-sep">:</span>
|
|
345
448
|
{/if}
|
|
346
449
|
{#if showMinutes}
|
|
347
|
-
<input
|
|
348
|
-
|
|
450
|
+
<input
|
|
451
|
+
type="number"
|
|
452
|
+
class="s-dp-time-input"
|
|
453
|
+
min={0}
|
|
454
|
+
max={59}
|
|
455
|
+
value={currentMinute}
|
|
456
|
+
oninput={(e) => setMinute(parseInt(e.target.value) || 0)}
|
|
457
|
+
aria-label="Minute"
|
|
458
|
+
/>
|
|
349
459
|
{/if}
|
|
350
460
|
{#if showSeconds}
|
|
351
461
|
<span class="s-dp-time-sep">:</span>
|
|
352
|
-
<input
|
|
353
|
-
|
|
462
|
+
<input
|
|
463
|
+
type="number"
|
|
464
|
+
class="s-dp-time-input"
|
|
465
|
+
min={0}
|
|
466
|
+
max={59}
|
|
467
|
+
value={currentSecond}
|
|
468
|
+
oninput={(e) => setSecond(parseInt(e.target.value) || 0)}
|
|
469
|
+
aria-label="Second"
|
|
470
|
+
/>
|
|
354
471
|
{/if}
|
|
355
472
|
</div>
|
|
356
473
|
</div>
|
|
@@ -358,7 +475,11 @@
|
|
|
358
475
|
|
|
359
476
|
<!-- Mobile done button -->
|
|
360
477
|
{#if isMobile}
|
|
361
|
-
<button
|
|
478
|
+
<button
|
|
479
|
+
type="button"
|
|
480
|
+
class="s-dp-done-btn"
|
|
481
|
+
onclick={() => (open = false)}>Done</button
|
|
482
|
+
>
|
|
362
483
|
{/if}
|
|
363
484
|
</div>
|
|
364
485
|
{/if}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
let {
|
|
6
6
|
style: styleProp,
|
|
7
7
|
theme: themeProp,
|
|
8
|
+
preset = "primary",
|
|
8
9
|
children,
|
|
9
10
|
position = "bottom-right",
|
|
10
11
|
onclick,
|
|
@@ -16,10 +17,11 @@
|
|
|
16
17
|
|
|
17
18
|
const styleClass = $derived(`s-fab-${style}`);
|
|
18
19
|
const themeClass = $derived(`theme-${theme}`);
|
|
20
|
+
const presetClass = $derived(`fab-${preset}`);
|
|
19
21
|
</script>
|
|
20
22
|
|
|
21
23
|
<button
|
|
22
|
-
class="s-fab {styleClass} {themeClass} fab-{position}"
|
|
24
|
+
class="s-fab {styleClass} {themeClass} {presetClass} fab-{position}"
|
|
23
25
|
{onclick}
|
|
24
26
|
{...rest}
|
|
25
27
|
>
|
|
@@ -6,6 +6,7 @@ type FAB = {
|
|
|
6
6
|
declare const FAB: import("svelte").Component<{
|
|
7
7
|
style: any;
|
|
8
8
|
theme: any;
|
|
9
|
+
preset?: string;
|
|
9
10
|
children: any;
|
|
10
11
|
position?: string;
|
|
11
12
|
onclick: any;
|
|
@@ -13,6 +14,7 @@ declare const FAB: import("svelte").Component<{
|
|
|
13
14
|
type $$ComponentProps = {
|
|
14
15
|
style: any;
|
|
15
16
|
theme: any;
|
|
17
|
+
preset?: string;
|
|
16
18
|
children: any;
|
|
17
19
|
position?: string;
|
|
18
20
|
onclick: any;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
style: styleProp,
|
|
7
7
|
theme: themeProp,
|
|
8
8
|
variant = "filled",
|
|
9
|
+
preset = "primary",
|
|
9
10
|
size = "md",
|
|
10
11
|
disabled = false,
|
|
11
12
|
icon,
|
|
@@ -21,11 +22,12 @@
|
|
|
21
22
|
const styleClass = $derived(`s-iconbtn-${style}`);
|
|
22
23
|
const themeClass = $derived(`theme-${theme}`);
|
|
23
24
|
const variantClass = $derived(`ibtn-${variant}`);
|
|
25
|
+
const presetClass = $derived(`ibtn-${preset}`);
|
|
24
26
|
const sizeClass = $derived(`ibtn-${size}`);
|
|
25
27
|
</script>
|
|
26
28
|
|
|
27
29
|
<button
|
|
28
|
-
class="s-iconbtn {styleClass} {themeClass} {variantClass} {sizeClass}"
|
|
30
|
+
class="s-iconbtn {styleClass} {themeClass} {variantClass} {presetClass} {sizeClass}"
|
|
29
31
|
{disabled}
|
|
30
32
|
{onclick}
|
|
31
33
|
aria-label={ariaLabel}
|
|
@@ -7,6 +7,7 @@ declare const IconButton: import("svelte").Component<{
|
|
|
7
7
|
style: any;
|
|
8
8
|
theme: any;
|
|
9
9
|
variant?: string;
|
|
10
|
+
preset?: string;
|
|
10
11
|
size?: string;
|
|
11
12
|
disabled?: boolean;
|
|
12
13
|
icon: any;
|
|
@@ -18,6 +19,7 @@ type $$ComponentProps = {
|
|
|
18
19
|
style: any;
|
|
19
20
|
theme: any;
|
|
20
21
|
variant?: string;
|
|
22
|
+
preset?: string;
|
|
21
23
|
size?: string;
|
|
22
24
|
disabled?: boolean;
|
|
23
25
|
icon: any;
|
|
@@ -59,7 +59,6 @@
|
|
|
59
59
|
"fluent",
|
|
60
60
|
"carbon",
|
|
61
61
|
"bootstrap",
|
|
62
|
-
"legacy-ios",
|
|
63
62
|
];
|
|
64
63
|
const hasFloatingLabel = $derived(
|
|
65
64
|
floatingStyles.includes(style) && (label || placeholder),
|
|
@@ -80,7 +79,8 @@
|
|
|
80
79
|
<span class="s-input-icon s-input-icon-start {iconClass}">{iconStart}</span>
|
|
81
80
|
{/if}
|
|
82
81
|
{#if hasFloatingLabel}
|
|
83
|
-
<label class="s-input-floating-label" for={internalId}>{displayLabel}</label
|
|
82
|
+
<label class="s-input-floating-label" for={internalId}>{displayLabel}</label
|
|
83
|
+
>
|
|
84
84
|
{/if}
|
|
85
85
|
<input
|
|
86
86
|
{type}
|
|
@@ -118,4 +118,4 @@
|
|
|
118
118
|
{#if style === "fluent"}
|
|
119
119
|
<span class="s-input-fluent-border-indicator"></span>
|
|
120
120
|
{/if}
|
|
121
|
-
</div>
|
|
121
|
+
</div>
|
|
@@ -19,10 +19,23 @@
|
|
|
19
19
|
let open = $state(false);
|
|
20
20
|
let focused = $state(false);
|
|
21
21
|
let hasValue = $derived(selected.length > 0);
|
|
22
|
+
let floated = $derived(focused || hasValue);
|
|
22
23
|
|
|
23
24
|
const styleClass = $derived(`s-mselect-${style}`);
|
|
24
25
|
const themeClass = $derived(`theme-${theme}`);
|
|
25
26
|
|
|
27
|
+
const floatingStyles = [
|
|
28
|
+
"material",
|
|
29
|
+
"material3",
|
|
30
|
+
"fluent",
|
|
31
|
+
"carbon",
|
|
32
|
+
"bootstrap",
|
|
33
|
+
];
|
|
34
|
+
const hasFloatingLabel = $derived(
|
|
35
|
+
floatingStyles.includes(style) && (label || placeholder),
|
|
36
|
+
);
|
|
37
|
+
const displayLabel = $derived(label || placeholder);
|
|
38
|
+
|
|
26
39
|
function toggle(val) {
|
|
27
40
|
if (selected.includes(val)) {
|
|
28
41
|
selected = selected.filter((v) => v !== val);
|
|
@@ -54,13 +67,17 @@
|
|
|
54
67
|
class:focused
|
|
55
68
|
class:open
|
|
56
69
|
class:has-value={hasValue}
|
|
70
|
+
class:floated
|
|
57
71
|
tabindex="-1"
|
|
58
72
|
role="listbox"
|
|
59
|
-
aria-label={
|
|
73
|
+
aria-label={displayLabel}
|
|
60
74
|
onfocusin={() => (focused = true)}
|
|
61
75
|
onfocusout={handleBlur}
|
|
62
76
|
{...rest}
|
|
63
77
|
>
|
|
78
|
+
{#if hasFloatingLabel}
|
|
79
|
+
<label class="s-mselect-floating-label">{displayLabel}</label>
|
|
80
|
+
{/if}
|
|
64
81
|
<div
|
|
65
82
|
class="mselect-control"
|
|
66
83
|
role="button"
|
|
@@ -90,7 +107,7 @@
|
|
|
90
107
|
</span>
|
|
91
108
|
{/each}
|
|
92
109
|
</div>
|
|
93
|
-
{:else}
|
|
110
|
+
{:else if !hasFloatingLabel}
|
|
94
111
|
<span class="mselect-placeholder">{placeholder}</span>
|
|
95
112
|
{/if}
|
|
96
113
|
<span class="mselect-arrow">
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"fluent",
|
|
34
34
|
"carbon",
|
|
35
35
|
"bootstrap",
|
|
36
|
-
"legacy-ios",
|
|
37
36
|
];
|
|
38
37
|
const hasFloatingLabel = $derived(
|
|
39
38
|
floatingStyles.includes(style) && (label || placeholder),
|
|
@@ -49,7 +48,9 @@
|
|
|
49
48
|
class:floated
|
|
50
49
|
>
|
|
51
50
|
{#if hasFloatingLabel}
|
|
52
|
-
<label class="s-select-floating-label" for={internalId}
|
|
51
|
+
<label class="s-select-floating-label" for={internalId}
|
|
52
|
+
>{displayLabel}</label
|
|
53
|
+
>
|
|
53
54
|
{/if}
|
|
54
55
|
<select
|
|
55
56
|
bind:value
|
|
@@ -77,4 +78,4 @@
|
|
|
77
78
|
/>
|
|
78
79
|
</svg>
|
|
79
80
|
</span>
|
|
80
|
-
</div>
|
|
81
|
+
</div>
|