svelte-multistyle-ui 0.0.15-alpha → 0.1.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/README.md +55 -3
- package/cli/bin.js +94 -92
- package/cli/emit.js +242 -225
- package/cli/fixtures/sample.expected.svelte +2 -1
- package/cli/generate.js +507 -499
- package/cli/registry.js +105 -100
- package/cli/schema.js +16 -0
- package/dist/actions/dialog.d.ts +11 -0
- package/dist/actions/dialog.js +118 -0
- package/dist/components/Accordion.svelte +11 -5
- package/dist/components/Accordion.svelte.d.ts +8 -12
- package/dist/components/Alert.svelte +11 -5
- package/dist/components/Alert.svelte.d.ts +8 -16
- package/dist/components/Avatar.svelte +13 -3
- package/dist/components/Avatar.svelte.d.ts +8 -14
- package/dist/components/Breadcrumb.svelte +9 -3
- package/dist/components/Breadcrumb.svelte.d.ts +8 -8
- package/dist/components/Button.svelte +11 -3
- package/dist/components/Button.svelte.d.ts +8 -20
- package/dist/components/ButtonGroup.svelte +10 -4
- package/dist/components/ButtonGroup.svelte.d.ts +8 -16
- package/dist/components/Card.svelte +9 -3
- package/dist/components/Card.svelte.d.ts +8 -12
- package/dist/components/Carousel.svelte +17 -9
- package/dist/components/Carousel.svelte.d.ts +8 -16
- package/dist/components/Checkbox.svelte +10 -4
- package/dist/components/Checkbox.svelte.d.ts +8 -14
- package/dist/components/Chip.svelte +10 -4
- package/dist/components/Chip.svelte.d.ts +8 -20
- package/dist/components/CodeEditor.svelte +139 -129
- package/dist/components/CodeEditor.svelte.d.ts +8 -16
- package/dist/components/Column.svelte +48 -38
- package/dist/components/Column.svelte.d.ts +8 -12
- package/dist/components/CommandPalette.svelte +14 -5
- package/dist/components/CommandPalette.svelte.d.ts +8 -12
- package/dist/components/CrudView.svelte +1604 -0
- package/dist/components/CrudView.svelte.d.ts +17 -0
- package/dist/components/DatePicker.svelte +42 -10
- package/dist/components/DatePicker.svelte.d.ts +8 -24
- package/dist/components/Divider.svelte +9 -3
- package/dist/components/Divider.svelte.d.ts +8 -10
- package/dist/components/Drawer.svelte +19 -3
- package/dist/components/Drawer.svelte.d.ts +8 -14
- package/dist/components/DropdownMenu.svelte +32 -5
- package/dist/components/DropdownMenu.svelte.d.ts +8 -18
- package/dist/components/FAB.svelte +10 -4
- package/dist/components/FAB.svelte.d.ts +8 -14
- package/dist/components/FileUpload.svelte +47 -8
- package/dist/components/FileUpload.svelte.d.ts +8 -14
- package/dist/components/FilterBar.svelte +768 -0
- package/dist/components/FilterBar.svelte.d.ts +17 -0
- package/dist/components/GraphEditor.svelte +725 -723
- package/dist/components/GraphEditor.svelte.d.ts +8 -8
- package/dist/components/Grid.svelte +61 -51
- package/dist/components/Grid.svelte.d.ts +8 -18
- package/dist/components/IconButton.svelte +12 -4
- package/dist/components/IconButton.svelte.d.ts +8 -22
- package/dist/components/InlineEdit.svelte +6 -3
- package/dist/components/InlineEdit.svelte.d.ts +10 -10
- package/dist/components/Input.svelte +18 -4
- package/dist/components/Input.svelte.d.ts +8 -62
- package/dist/components/Modal.svelte +14 -5
- package/dist/components/Modal.svelte.d.ts +8 -16
- package/dist/components/MultiSelect.svelte +22 -204
- package/dist/components/MultiSelect.svelte.d.ts +8 -16
- package/dist/components/Pagination.svelte +19 -4
- package/dist/components/Pagination.svelte.d.ts +8 -12
- package/dist/components/Popover.svelte +15 -4
- package/dist/components/Popover.svelte.d.ts +8 -16
- package/dist/components/ProgressBar.svelte +79 -73
- package/dist/components/ProgressBar.svelte.d.ts +8 -14
- package/dist/components/Radio.svelte +10 -4
- package/dist/components/Radio.svelte.d.ts +8 -14
- package/dist/components/Rating.svelte +30 -6
- package/dist/components/Rating.svelte.d.ts +8 -18
- package/dist/components/Row.svelte +49 -39
- package/dist/components/Row.svelte.d.ts +8 -14
- package/dist/components/Select.svelte +252 -32
- package/dist/components/Select.svelte.d.ts +8 -16
- package/dist/components/Skeleton.svelte +9 -3
- package/dist/components/Skeleton.svelte.d.ts +8 -12
- package/dist/components/Slider.svelte +14 -6
- package/dist/components/Slider.svelte.d.ts +8 -18
- package/dist/components/SortableList.svelte +136 -130
- package/dist/components/SortableList.svelte.d.ts +6 -14
- package/dist/components/Spinner.svelte +9 -3
- package/dist/components/Spinner.svelte.d.ts +8 -8
- package/dist/components/Stepper.svelte +101 -93
- package/dist/components/Stepper.svelte.d.ts +8 -10
- package/dist/components/Table.svelte +9 -3
- package/dist/components/Table.svelte.d.ts +8 -12
- package/dist/components/Tabs.svelte +29 -5
- package/dist/components/Tabs.svelte.d.ts +8 -10
- package/dist/components/TextEditor.svelte +191 -182
- package/dist/components/TextEditor.svelte.d.ts +8 -18
- package/dist/components/Textarea.svelte +24 -7
- package/dist/components/Textarea.svelte.d.ts +8 -24
- package/dist/components/Toast.svelte +52 -16
- package/dist/components/Toast.svelte.d.ts +8 -12
- package/dist/components/Toggle.svelte +10 -4
- package/dist/components/Toggle.svelte.d.ts +8 -14
- package/dist/components/Tooltip.svelte +14 -4
- package/dist/components/Tooltip.svelte.d.ts +8 -12
- package/dist/components/charts/BarChart.svelte +7 -5
- package/dist/components/charts/BarChart.svelte.d.ts +8 -22
- package/dist/components/charts/BubbleChart.svelte +7 -5
- package/dist/components/charts/BubbleChart.svelte.d.ts +8 -22
- package/dist/components/charts/Chart.svelte +273 -248
- package/dist/components/charts/Chart.svelte.d.ts +8 -30
- package/dist/components/charts/ComboChart.svelte +7 -5
- package/dist/components/charts/ComboChart.svelte.d.ts +8 -22
- package/dist/components/charts/DoughnutChart.svelte +7 -5
- package/dist/components/charts/DoughnutChart.svelte.d.ts +8 -22
- package/dist/components/charts/LineChart.svelte +7 -5
- package/dist/components/charts/LineChart.svelte.d.ts +8 -22
- package/dist/components/charts/MermaidChart.svelte +106 -0
- package/dist/components/charts/MermaidChart.svelte.d.ts +20 -0
- package/dist/components/charts/PieChart.svelte +7 -5
- package/dist/components/charts/PieChart.svelte.d.ts +8 -22
- package/dist/components/charts/PolarAreaChart.svelte +7 -5
- package/dist/components/charts/PolarAreaChart.svelte.d.ts +8 -22
- package/dist/components/charts/RadarChart.svelte +7 -5
- package/dist/components/charts/RadarChart.svelte.d.ts +8 -22
- package/dist/components/charts/ScatterChart.svelte +7 -5
- package/dist/components/charts/ScatterChart.svelte.d.ts +8 -22
- package/dist/components/charts/StackedBarChart.svelte +20 -18
- package/dist/components/charts/StackedBarChart.svelte.d.ts +8 -22
- package/dist/components/charts/StackedLineChart.svelte +23 -21
- package/dist/components/charts/StackedLineChart.svelte.d.ts +8 -22
- package/dist/components/charts/chart-config.d.ts +5 -5
- package/dist/components/charts/chart-config.js +722 -733
- package/dist/components/charts/index.d.ts +12 -0
- package/dist/components/charts/index.js +12 -0
- package/dist/components/charts/mermaid-chart-styles.css +27 -0
- package/dist/components/checkbox-styles.css +122 -117
- package/dist/components/crudview-styles.css +1057 -0
- package/dist/components/fileupload-styles.css +121 -117
- package/dist/components/filterbar-styles.css +655 -0
- package/dist/components/graph/FlowNode.svelte +82 -79
- package/dist/components/graph/FlowNode.svelte.d.ts +8 -28
- package/dist/components/graph/GraphNode.svelte +72 -69
- package/dist/components/graph/GraphNode.svelte.d.ts +8 -22
- package/dist/components/prism-manual.d.ts +0 -0
- package/dist/components/prism-manual.js +4 -0
- package/dist/components/radio-styles.css +118 -113
- package/dist/components/rating-styles.css +70 -65
- package/dist/components/select-styles.css +239 -11
- package/dist/components/slider-styles.css +85 -81
- package/dist/components/text-editor-core/dom-utils.d.ts +1 -1
- package/dist/components/text-editor-core/editor-core.d.ts +9 -9
- package/dist/components/text-editor-core/editor-core.js +854 -808
- package/dist/components/text-editor-core/sanitizer.d.ts +4 -1
- package/dist/components/text-editor-core/sanitizer.js +236 -161
- package/dist/components/text-editor-core/selection-engine.d.ts +3 -3
- package/dist/components/theme.css +59 -49
- package/dist/components/toast-styles.css +8 -8
- package/dist/components/toggle-styles.css +126 -121
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/config.svelte.d.ts +5 -4
- package/dist/config.svelte.js +124 -81
- package/dist/graph/geometry.d.ts +1 -1
- package/dist/graph/node-types.d.ts +1 -1
- package/dist/index.d.ts +4 -11
- package/dist/index.js +9 -12
- package/dist/themes/generator.js +175 -173
- package/dist/themes/presets.d.ts +21 -21
- package/dist/themes/presets.js +6 -6
- package/dist/utils/dbmr.d.ts +27 -0
- package/dist/utils/dbmr.js +381 -0
- package/dist/utils/filter.d.ts +103 -0
- package/dist/utils/filter.js +621 -0
- package/package.json +114 -85
- package/dist/components/multiselect-styles.css +0 -364
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default CrudView;
|
|
2
|
+
type CrudView = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const CrudView: import("svelte").Component<{
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
}, {}, "mode" | "items" | "data" | "search" | "selected" | "conjunction" | "filters" | "views" | "activeView" | "perPage" | "currentPage" | "sortKey" | "sortDirection" | "activeItem" | "breadcrumbs" | "activeTab">;
|
|
12
|
+
type $$ComponentProps = {
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
15
|
+
class?: string;
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./datepicker-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults, iconClass } from "../config.js";
|
|
4
4
|
import { portal } from "../actions/portal.js";
|
|
5
|
+
import { dialog } from "../actions/dialog.js";
|
|
5
6
|
import { cn } from "../utils/cn.js";
|
|
6
7
|
import dayjs from "dayjs";
|
|
7
8
|
import customParseFormat from "dayjs/plugin/customParseFormat";
|
|
8
9
|
dayjs.extend(customParseFormat);
|
|
9
10
|
|
|
11
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
12
|
+
|
|
13
|
+
|
|
10
14
|
let {
|
|
11
15
|
style: styleProp,
|
|
12
16
|
theme: themeProp,
|
|
@@ -23,11 +27,14 @@
|
|
|
23
27
|
...rest
|
|
24
28
|
} = $props();
|
|
25
29
|
|
|
26
|
-
const
|
|
27
|
-
|
|
30
|
+
const _cfg = getMultistyleDefaults();
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
34
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
28
35
|
const styleClass = $derived(`s-datepicker-${style}`);
|
|
29
36
|
const themeClass = $derived(`theme-${theme}`);
|
|
30
|
-
const uid =
|
|
37
|
+
const uid = $props.id();
|
|
31
38
|
const internalId = `dp-${uid}`;
|
|
32
39
|
const dispFormat = $derived(displayFormat ?? format);
|
|
33
40
|
|
|
@@ -37,6 +44,16 @@
|
|
|
37
44
|
let viewDate = $state(new Date());
|
|
38
45
|
let selectedDate = $state(null);
|
|
39
46
|
let isMobile = $state(false);
|
|
47
|
+
let skipNextFocus = false;
|
|
48
|
+
function closePicker() {
|
|
49
|
+
skipNextFocus = true;
|
|
50
|
+
open = false;
|
|
51
|
+
if (typeof requestAnimationFrame !== "undefined") {
|
|
52
|
+
requestAnimationFrame(() => { skipNextFocus = false; });
|
|
53
|
+
} else {
|
|
54
|
+
skipNextFocus = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
40
57
|
|
|
41
58
|
// Format helpers — uses dayjs for full format support (MMM, MMMM, etc.)
|
|
42
59
|
function toDayjsFmt(f) {
|
|
@@ -48,14 +65,28 @@
|
|
|
48
65
|
}
|
|
49
66
|
|
|
50
67
|
function parseDate(str, f) {
|
|
51
|
-
|
|
52
|
-
|
|
68
|
+
if (!str) return null;
|
|
69
|
+
const d = dayjs(str, toDayjsFmt(f), true);
|
|
70
|
+
if (d.isValid()) return d.toDate();
|
|
71
|
+
const loose = dayjs(str, toDayjsFmt(f));
|
|
72
|
+
return loose.isValid() ? loose.toDate() : null;
|
|
53
73
|
}
|
|
54
74
|
|
|
75
|
+
// Sync internal selectedDate / viewDate when parent updates or clears `value`
|
|
76
|
+
$effect(() => {
|
|
77
|
+
const parsed = value ? parseDate(value, format) : null;
|
|
78
|
+
selectedDate = parsed;
|
|
79
|
+
if (parsed) {
|
|
80
|
+
viewDate = new Date(parsed);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
55
84
|
// Derived
|
|
56
|
-
const displayValue = $derived(
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
const displayValue = $derived.by(() => {
|
|
86
|
+
if (!value) return "";
|
|
87
|
+
const parsed = parseDate(value, format);
|
|
88
|
+
return parsed ? fmt(parsed, dispFormat) : "";
|
|
89
|
+
});
|
|
59
90
|
const inputPlaceholder = $derived(placeholder || dispFormat.toLowerCase());
|
|
60
91
|
|
|
61
92
|
// Floating-label support — mirrors Input.svelte. Material / Material 3 float
|
|
@@ -312,7 +343,7 @@
|
|
|
312
343
|
placeholder={useFloatingLabel ? "" : inputPlaceholder}
|
|
313
344
|
{disabled}
|
|
314
345
|
onfocus={() => {
|
|
315
|
-
if (!disabled) open = true;
|
|
346
|
+
if (!disabled && !skipNextFocus) open = true;
|
|
316
347
|
}}
|
|
317
348
|
onclick={() => {
|
|
318
349
|
if (!disabled) open = true;
|
|
@@ -332,6 +363,7 @@
|
|
|
332
363
|
class:s-datepicker-mobile={isMobile}
|
|
333
364
|
bind:this={overlayEl}
|
|
334
365
|
use:portal
|
|
366
|
+
use:dialog={{ onclose: closePicker, lockScroll: isMobile }}
|
|
335
367
|
role="dialog"
|
|
336
368
|
aria-modal="true"
|
|
337
369
|
aria-label="Date picker"
|
|
@@ -4,30 +4,14 @@ type DatePicker = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const DatePicker: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
format?: string;
|
|
11
|
-
displayFormat?: any;
|
|
12
|
-
label?: string;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
min?: any;
|
|
16
|
-
max?: any;
|
|
17
|
-
locale?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
18
10
|
class?: string;
|
|
19
|
-
}
|
|
11
|
+
}, {}, "value">;
|
|
20
12
|
type $$ComponentProps = {
|
|
21
|
-
style
|
|
22
|
-
theme
|
|
23
|
-
value?: string;
|
|
24
|
-
format?: string;
|
|
25
|
-
displayFormat?: any;
|
|
26
|
-
label?: string;
|
|
27
|
-
placeholder?: string;
|
|
28
|
-
disabled?: boolean;
|
|
29
|
-
min?: any;
|
|
30
|
-
max?: any;
|
|
31
|
-
locale?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
32
15
|
class?: string;
|
|
33
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./divider-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults } from "../config.js";
|
|
4
4
|
import { cn } from "../utils/cn.js";
|
|
5
5
|
|
|
6
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
let {
|
|
7
10
|
style: styleProp,
|
|
8
11
|
theme: themeProp,
|
|
@@ -12,8 +15,11 @@
|
|
|
12
15
|
...rest
|
|
13
16
|
} = $props();
|
|
14
17
|
|
|
15
|
-
const
|
|
16
|
-
|
|
18
|
+
const _cfg = getMultistyleDefaults();
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
22
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
17
23
|
|
|
18
24
|
const styleClass = $derived(`s-divider-${style}`);
|
|
19
25
|
const themeClass = $derived(`theme-${theme}`);
|
|
@@ -4,16 +4,14 @@ type Divider = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const Divider: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
label?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
11
10
|
class?: string;
|
|
12
|
-
}
|
|
11
|
+
}, {}, "">;
|
|
13
12
|
type $$ComponentProps = {
|
|
14
|
-
style
|
|
15
|
-
theme
|
|
16
|
-
orientation?: string;
|
|
17
|
-
label?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
18
15
|
class?: string;
|
|
19
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,23 +1,32 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./drawer-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults } from "../config.js";
|
|
4
4
|
import { fade } from "svelte/transition";
|
|
5
5
|
import { portal } from "../actions/portal.js";
|
|
6
|
+
import { dialog } from "../actions/dialog.js";
|
|
6
7
|
import { cn } from "../utils/cn.js";
|
|
7
8
|
|
|
9
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
10
|
+
|
|
11
|
+
|
|
8
12
|
let {
|
|
9
13
|
style: styleProp,
|
|
10
14
|
theme: themeProp,
|
|
11
15
|
position = "left",
|
|
12
16
|
open = $bindable(false),
|
|
17
|
+
title = "",
|
|
18
|
+
showClose = true,
|
|
13
19
|
children,
|
|
14
20
|
onclose,
|
|
15
21
|
class: className = "",
|
|
16
22
|
...rest
|
|
17
23
|
} = $props();
|
|
18
24
|
|
|
19
|
-
const
|
|
20
|
-
|
|
25
|
+
const _cfg = getMultistyleDefaults();
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
29
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
21
30
|
const styleClass = $derived(`s-drawer-${style}`);
|
|
22
31
|
const themeClass = $derived(`theme-${theme}`);
|
|
23
32
|
|
|
@@ -53,6 +62,7 @@
|
|
|
53
62
|
{#if open}
|
|
54
63
|
<div
|
|
55
64
|
use:portal
|
|
65
|
+
use:dialog={{ onclose: handleClose }}
|
|
56
66
|
class={cn("s-drawer-overlay", className)}
|
|
57
67
|
transition:fade={{ duration: 200 }}
|
|
58
68
|
onclick={handleBackdrop}
|
|
@@ -65,6 +75,12 @@
|
|
|
65
75
|
role="dialog"
|
|
66
76
|
aria-modal="true"
|
|
67
77
|
>
|
|
78
|
+
{#if title || showClose}
|
|
79
|
+
<div class="s-drawer-header" style="display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;">
|
|
80
|
+
{#if title}<h3 class="s-drawer-title" style="margin:0;font-size:16px;font-weight:600;">{title}</h3>{:else}<span></span>{/if}
|
|
81
|
+
{#if showClose}<button type="button" class="s-drawer-close" onclick={handleClose} aria-label="Close" style="background:none;border:none;font-size:20px;line-height:1;cursor:pointer;color:inherit;">×</button>{/if}
|
|
82
|
+
</div>
|
|
83
|
+
{/if}
|
|
68
84
|
{@render children?.()}
|
|
69
85
|
</div>
|
|
70
86
|
</div>
|
|
@@ -4,20 +4,14 @@ type Drawer = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const Drawer: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
open?: boolean;
|
|
11
|
-
children: any;
|
|
12
|
-
onclose: any;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
13
10
|
class?: string;
|
|
14
|
-
}
|
|
11
|
+
}, {}, "open">;
|
|
15
12
|
type $$ComponentProps = {
|
|
16
|
-
style
|
|
17
|
-
theme
|
|
18
|
-
position?: string;
|
|
19
|
-
open?: boolean;
|
|
20
|
-
children: any;
|
|
21
|
-
onclose: any;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
22
15
|
class?: string;
|
|
23
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./dropdown-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults } from "../config.js";
|
|
4
4
|
import { fly } from "svelte/transition";
|
|
5
5
|
import { cn } from "../utils/cn.js";
|
|
6
6
|
|
|
7
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
8
|
+
|
|
9
|
+
|
|
7
10
|
let {
|
|
8
11
|
style: styleProp,
|
|
9
12
|
theme: themeProp,
|
|
@@ -17,8 +20,11 @@
|
|
|
17
20
|
...rest
|
|
18
21
|
} = $props();
|
|
19
22
|
|
|
20
|
-
const
|
|
21
|
-
|
|
23
|
+
const _cfg = getMultistyleDefaults();
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
27
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
22
28
|
const styleClass = $derived(`s-dropdown-${style}`);
|
|
23
29
|
const themeClass = $derived(`theme-${theme}`);
|
|
24
30
|
const variantClass = $derived(`dropdown-${color}`);
|
|
@@ -40,6 +46,26 @@
|
|
|
40
46
|
close();
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
function handleMenuKeydown(e) {
|
|
50
|
+
if (!menuEl) return;
|
|
51
|
+
const btns = Array.from(menuEl.querySelectorAll('[role="menuitem"]:not([disabled])'));
|
|
52
|
+
if (btns.length === 0) return;
|
|
53
|
+
const idx = btns.indexOf(document.activeElement);
|
|
54
|
+
if (e.key === "ArrowDown") {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
btns[(idx + 1) % btns.length].focus();
|
|
57
|
+
} else if (e.key === "ArrowUp") {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
btns[(idx - 1 + btns.length) % btns.length].focus();
|
|
60
|
+
} else if (e.key === "Home") {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
btns[0].focus();
|
|
63
|
+
} else if (e.key === "End") {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
btns[btns.length - 1].focus();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
43
69
|
// Click outside to close
|
|
44
70
|
$effect(() => {
|
|
45
71
|
if (!open) return;
|
|
@@ -73,7 +99,7 @@
|
|
|
73
99
|
role="button"
|
|
74
100
|
tabindex="0"
|
|
75
101
|
aria-expanded={open}
|
|
76
|
-
onkeydown={(e) => { if (e.key === "Enter" || e.key === " ")
|
|
102
|
+
onkeydown={(e) => { if (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") { e.preventDefault(); open = true; requestAnimationFrame(() => menuEl?.querySelector('[role="menuitem"]:not([disabled])')?.focus()); } }}
|
|
77
103
|
>
|
|
78
104
|
{@render children?.()}
|
|
79
105
|
</div>
|
|
@@ -88,12 +114,13 @@
|
|
|
88
114
|
opacity: 0
|
|
89
115
|
}}
|
|
90
116
|
role="menu"
|
|
117
|
+
onkeydown={handleMenuKeydown}
|
|
91
118
|
>
|
|
92
119
|
{#each items as item}
|
|
93
120
|
{#if item.divider}
|
|
94
121
|
<div class="s-dropdown-divider"></div>
|
|
95
122
|
{:else}
|
|
96
|
-
<button
|
|
123
|
+
<button type="button"
|
|
97
124
|
class="s-dropdown-item"
|
|
98
125
|
class:active={item.active}
|
|
99
126
|
disabled={item.disabled}
|
|
@@ -4,24 +4,14 @@ type DropdownMenu = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const DropdownMenu: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
color?: string;
|
|
11
|
-
children: any;
|
|
12
|
-
items?: any[];
|
|
13
|
-
position?: string;
|
|
14
|
-
align?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
15
10
|
class?: string;
|
|
16
|
-
}
|
|
11
|
+
}, {}, "">;
|
|
17
12
|
type $$ComponentProps = {
|
|
18
|
-
style
|
|
19
|
-
theme
|
|
20
|
-
variant?: string;
|
|
21
|
-
color?: string;
|
|
22
|
-
children: any;
|
|
23
|
-
items?: any[];
|
|
24
|
-
position?: string;
|
|
25
|
-
align?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
26
15
|
class?: string;
|
|
27
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./fab-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults } from "../config.js";
|
|
4
4
|
import { cn } from "../utils/cn.js";
|
|
5
5
|
|
|
6
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
let {
|
|
7
10
|
style: styleProp,
|
|
8
11
|
theme: themeProp,
|
|
@@ -14,15 +17,18 @@
|
|
|
14
17
|
...rest
|
|
15
18
|
} = $props();
|
|
16
19
|
|
|
17
|
-
const
|
|
18
|
-
|
|
20
|
+
const _cfg = getMultistyleDefaults();
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
24
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
19
25
|
|
|
20
26
|
const styleClass = $derived(`s-fab-${style}`);
|
|
21
27
|
const themeClass = $derived(`theme-${theme}`);
|
|
22
28
|
const presetClass = $derived(`fab-${preset}`);
|
|
23
29
|
</script>
|
|
24
30
|
|
|
25
|
-
<button
|
|
31
|
+
<button type="button"
|
|
26
32
|
class={cn("s-fab", styleClass, themeClass, presetClass, `fab-${position}`, className)}
|
|
27
33
|
{onclick}
|
|
28
34
|
{...rest}
|
|
@@ -4,20 +4,14 @@ type FAB = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const FAB: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
children: any;
|
|
11
|
-
position?: string;
|
|
12
|
-
onclick: any;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
13
10
|
class?: string;
|
|
14
|
-
}
|
|
11
|
+
}, {}, "">;
|
|
15
12
|
type $$ComponentProps = {
|
|
16
|
-
style
|
|
17
|
-
theme
|
|
18
|
-
preset?: string;
|
|
19
|
-
children: any;
|
|
20
|
-
position?: string;
|
|
21
|
-
onclick: any;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
22
15
|
class?: string;
|
|
23
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|
|
@@ -1,36 +1,74 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import "./fileupload-styles.css";
|
|
3
|
-
import {
|
|
3
|
+
import { getMultistyleDefaults } from "../config.js";
|
|
4
4
|
import { cn } from "../utils/cn.js";
|
|
5
5
|
|
|
6
|
+
/** @type {{ style?: string, theme?: string, class?: string, [key: string]: any }} */
|
|
7
|
+
|
|
8
|
+
|
|
6
9
|
let {
|
|
7
10
|
style: styleProp,
|
|
8
11
|
theme: themeProp,
|
|
12
|
+
files = $bindable([]),
|
|
9
13
|
accept = "",
|
|
10
14
|
multiple = false,
|
|
11
15
|
disabled = false,
|
|
12
16
|
label = "Drop files or click to upload",
|
|
17
|
+
onfiles,
|
|
18
|
+
onchange,
|
|
13
19
|
class: className = "",
|
|
14
20
|
...rest
|
|
15
21
|
} = $props();
|
|
16
22
|
|
|
17
|
-
const
|
|
18
|
-
|
|
23
|
+
const _cfg = getMultistyleDefaults();
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
const style = $derived(styleProp ?? _cfg.style);
|
|
27
|
+
const theme = $derived(themeProp ?? _cfg.theme);
|
|
19
28
|
|
|
20
29
|
const styleClass = $derived(`s-fileupload-${style}`);
|
|
21
30
|
const themeClass = $derived(`theme-${theme}`);
|
|
22
31
|
|
|
23
|
-
let files = $state([]);
|
|
24
32
|
let dragging = $state(false);
|
|
33
|
+
let inputEl = $state(null);
|
|
34
|
+
|
|
35
|
+
$effect(() => {
|
|
36
|
+
if (inputEl && (!files || files.length === 0)) {
|
|
37
|
+
inputEl.value = "";
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function matchesAccept(file) {
|
|
42
|
+
if (!accept) return true;
|
|
43
|
+
const tokens = accept.split(",").map((s) => s.trim().toLowerCase()).filter(Boolean);
|
|
44
|
+
if (tokens.length === 0) return true;
|
|
45
|
+
const name = (file.name || "").toLowerCase();
|
|
46
|
+
const mime = (file.type || "").toLowerCase();
|
|
47
|
+
return tokens.some((t) => {
|
|
48
|
+
if (t.startsWith(".")) return name.endsWith(t);
|
|
49
|
+
if (t.endsWith("/*")) return mime.startsWith(t.slice(0, -1));
|
|
50
|
+
return mime === t;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function applyFiles(rawList) {
|
|
55
|
+
if (disabled) return;
|
|
56
|
+
let next = Array.from(rawList || []).filter(matchesAccept);
|
|
57
|
+
if (!multiple && next.length > 1) next = [next[0]];
|
|
58
|
+
files = next;
|
|
59
|
+
onfiles?.(files);
|
|
60
|
+
onchange?.(files);
|
|
61
|
+
}
|
|
25
62
|
|
|
26
63
|
function handleChange(e) {
|
|
27
|
-
|
|
64
|
+
applyFiles(e.target.files);
|
|
28
65
|
}
|
|
29
66
|
|
|
30
67
|
function handleDrop(e) {
|
|
31
68
|
e.preventDefault();
|
|
32
69
|
dragging = false;
|
|
33
|
-
|
|
70
|
+
if (disabled) return;
|
|
71
|
+
applyFiles(e.dataTransfer?.files);
|
|
34
72
|
}
|
|
35
73
|
</script>
|
|
36
74
|
|
|
@@ -40,13 +78,14 @@
|
|
|
40
78
|
class:disabled
|
|
41
79
|
ondragover={(e) => {
|
|
42
80
|
e.preventDefault();
|
|
43
|
-
dragging = true;
|
|
81
|
+
if (!disabled) dragging = true;
|
|
44
82
|
}}
|
|
45
83
|
ondragleave={() => (dragging = false)}
|
|
46
84
|
ondrop={handleDrop}
|
|
47
85
|
{...rest}
|
|
48
86
|
>
|
|
49
87
|
<input
|
|
88
|
+
bind:this={inputEl}
|
|
50
89
|
type="file"
|
|
51
90
|
{accept}
|
|
52
91
|
{multiple}
|
|
@@ -61,7 +100,7 @@
|
|
|
61
100
|
height="32"
|
|
62
101
|
viewBox="0 0 24 24"
|
|
63
102
|
fill="none"
|
|
64
|
-
stroke="
|
|
103
|
+
stroke="currentColor"
|
|
65
104
|
stroke-width="2"
|
|
66
105
|
>
|
|
67
106
|
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline
|
|
@@ -4,20 +4,14 @@ type FileUpload = {
|
|
|
4
4
|
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
5
|
};
|
|
6
6
|
declare const FileUpload: import("svelte").Component<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
multiple?: boolean;
|
|
11
|
-
disabled?: boolean;
|
|
12
|
-
label?: string;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
style?: string;
|
|
9
|
+
theme?: string;
|
|
13
10
|
class?: string;
|
|
14
|
-
}
|
|
11
|
+
}, {}, "files">;
|
|
15
12
|
type $$ComponentProps = {
|
|
16
|
-
style
|
|
17
|
-
theme
|
|
18
|
-
accept?: string;
|
|
19
|
-
multiple?: boolean;
|
|
20
|
-
disabled?: boolean;
|
|
21
|
-
label?: string;
|
|
13
|
+
style?: string;
|
|
14
|
+
theme?: string;
|
|
22
15
|
class?: string;
|
|
23
|
-
|
|
16
|
+
[key: string]: any;
|
|
17
|
+
};
|