svelte-multistyle-ui 0.0.4-alpha → 0.0.6-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 +47 -12
- 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 +0 -1
- package/dist/components/MultiSelect.svelte +0 -1
- package/dist/components/Select.svelte +0 -1
- package/dist/components/Stepper.svelte +91 -33
- package/dist/components/Textarea.svelte +0 -1
- 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 -1027
- 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 +5 -37
- package/dist/components/modal-styles.css +0 -8
- package/dist/components/multiselect-styles.css +5 -32
- 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 +5 -18
- 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 +5 -18
- 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 +18 -4
package/cli/registry.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Component registry for the YAML -> Svelte page generator.
|
|
2
|
+
// Keyed by the export name from src/lib/index.js. Every shipped component has
|
|
3
|
+
// exactly one entry. If a new component is exported from index.js, add a matching
|
|
4
|
+
// entry here and run `pnpm gen:sample` to verify the registry-completeness check.
|
|
5
|
+
//
|
|
6
|
+
// Entry shape:
|
|
7
|
+
// importName JS identifier emitted in the import statement (= key)
|
|
8
|
+
// kind "leaf" (no children) | "children" (implicit children snippet)
|
|
9
|
+
// | "container" (layout box wrapping children) | "multi-snippet"
|
|
10
|
+
// bindable prop names that are $bindable(...) in the component
|
|
11
|
+
// primaryBindable the prop used by the `bind: varName` shorthand
|
|
12
|
+
// listProps props whose YAML value is a sequence (documentation/validation)
|
|
13
|
+
// objectProps props whose YAML value is a map (documentation/validation)
|
|
14
|
+
// snippets named snippet props for multi-snippet kind
|
|
15
|
+
// chart forwards chart data/series/labels/options to the Chart base
|
|
16
|
+
//
|
|
17
|
+
// Note: emit.js treats ANY array prop as an inline JS array literal and ANY object
|
|
18
|
+
// prop as an inline JS object literal, so listProps/objectProps are advisory unless
|
|
19
|
+
// future validation needs them. They are kept for clarity and future strict checks.
|
|
20
|
+
|
|
21
|
+
/** @type {Record<string, any>} */
|
|
22
|
+
const registry = {
|
|
23
|
+
// ---------------- Form ----------------
|
|
24
|
+
Input: { importName: "Input", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
25
|
+
Textarea: { importName: "Textarea", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
26
|
+
Select: { importName: "Select", kind: "leaf", bindable: ["value"], primaryBindable: "value", listProps: ["options"] },
|
|
27
|
+
MultiSelect: { importName: "MultiSelect", kind: "leaf", bindable: ["selected"], primaryBindable: "selected", listProps: ["options"] },
|
|
28
|
+
Checkbox: { importName: "Checkbox", kind: "leaf", bindable: ["checked"], primaryBindable: "checked" },
|
|
29
|
+
Radio: { importName: "Radio", kind: "leaf", bindable: ["group"], primaryBindable: "group" },
|
|
30
|
+
Toggle: { importName: "Toggle", kind: "leaf", bindable: ["checked"], primaryBindable: "checked" },
|
|
31
|
+
Slider: { importName: "Slider", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
32
|
+
FileUpload: { importName: "FileUpload", kind: "leaf" },
|
|
33
|
+
DatePicker: { importName: "DatePicker", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
34
|
+
ButtonGroup: { importName: "ButtonGroup", kind: "leaf", bindable: ["value"], primaryBindable: "value", listProps: ["items"] },
|
|
35
|
+
SortableList: { importName: "SortableList", kind: "children", bindable: ["items"], primaryBindable: "items", listProps: ["items"] },
|
|
36
|
+
|
|
37
|
+
// ---------------- Buttons ----------------
|
|
38
|
+
Button: { importName: "Button", kind: "children" }, // onclick is a passthrough scalar prop, NOT bindable
|
|
39
|
+
IconButton: { importName: "IconButton", kind: "children" },
|
|
40
|
+
FAB: { importName: "FAB", kind: "children" },
|
|
41
|
+
|
|
42
|
+
// ---------------- Layout ----------------
|
|
43
|
+
Card: { importName: "Card", kind: "container" },
|
|
44
|
+
Row: { importName: "Row", kind: "container" },
|
|
45
|
+
Column: { importName: "Column", kind: "container" },
|
|
46
|
+
Grid: { importName: "Grid", kind: "container" },
|
|
47
|
+
Divider: { importName: "Divider", kind: "leaf" },
|
|
48
|
+
Accordion: { importName: "Accordion", kind: "leaf", listProps: ["items"] },
|
|
49
|
+
DropdownMenu: { importName: "DropdownMenu", kind: "children", listProps: ["items"] },
|
|
50
|
+
|
|
51
|
+
// ---------------- Navigation ----------------
|
|
52
|
+
Tabs: { importName: "Tabs", kind: "leaf", bindable: ["active"], primaryBindable: "active", listProps: ["tabs"] },
|
|
53
|
+
Breadcrumb: { importName: "Breadcrumb", kind: "leaf", listProps: ["items"] },
|
|
54
|
+
Pagination: { importName: "Pagination", kind: "leaf", bindable: ["current"], primaryBindable: "current" },
|
|
55
|
+
Stepper: { importName: "Stepper", kind: "leaf", listProps: ["steps"] },
|
|
56
|
+
|
|
57
|
+
// ---------------- Data Display ----------------
|
|
58
|
+
Avatar: { importName: "Avatar", kind: "leaf" },
|
|
59
|
+
Chip: { importName: "Chip", kind: "children" },
|
|
60
|
+
Tooltip: { importName: "Tooltip", kind: "children" },
|
|
61
|
+
ProgressBar: { importName: "ProgressBar", kind: "leaf" },
|
|
62
|
+
Table: { importName: "Table", kind: "leaf", listProps: ["data"] }, // columns derived at runtime from data[0]
|
|
63
|
+
Spinner: { importName: "Spinner", kind: "leaf" },
|
|
64
|
+
Skeleton: { importName: "Skeleton", kind: "leaf" },
|
|
65
|
+
|
|
66
|
+
// ---------------- Feedback ----------------
|
|
67
|
+
Alert: { importName: "Alert", kind: "children" },
|
|
68
|
+
Rating: { importName: "Rating", kind: "leaf", bindable: ["value"], primaryBindable: "value" },
|
|
69
|
+
Toast: { importName: "Toast", kind: "leaf", bindable: ["toasts"], primaryBindable: "toasts", listProps: ["toasts"] },
|
|
70
|
+
|
|
71
|
+
// ---------------- Overlays ----------------
|
|
72
|
+
Modal: { importName: "Modal", kind: "children", bindable: ["open"], primaryBindable: "open" },
|
|
73
|
+
Drawer: { importName: "Drawer", kind: "children", bindable: ["open"], primaryBindable: "open" },
|
|
74
|
+
CommandPalette:{ importName: "CommandPalette",kind: "leaf", bindable: ["open"], primaryBindable: "open", listProps: ["groups"] },
|
|
75
|
+
Popover: { importName: "Popover", kind: "multi-snippet", snippets: ["children", "content"], bindable: ["open"], primaryBindable: "open" },
|
|
76
|
+
|
|
77
|
+
// ---------------- Charts (all forward to Chart base) ----------------
|
|
78
|
+
BarChart: { importName: "BarChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
79
|
+
LineChart: { importName: "LineChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
80
|
+
PieChart: { importName: "PieChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
81
|
+
DoughnutChart: { importName: "DoughnutChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
82
|
+
RadarChart: { importName: "RadarChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
83
|
+
PolarAreaChart: { importName: "PolarAreaChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
84
|
+
ScatterChart: { importName: "ScatterChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
85
|
+
BubbleChart: { importName: "BubbleChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
86
|
+
StackedBarChart: { importName: "StackedBarChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
87
|
+
StackedLineChart:{ importName: "StackedLineChart",kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
88
|
+
ComboChart: { importName: "ComboChart", kind: "leaf", chart: true, listProps: ["data", "series", "labels"], objectProps: ["options"] },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Exported component names — used by the registry-completeness check to diff
|
|
92
|
+
// against src/lib/index.js. Keep in sync with index.js when adding components.
|
|
93
|
+
export const registryKeys = Object.keys(registry);
|
|
94
|
+
|
|
95
|
+
export { registry };
|
package/cli/schema.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// Lightweight YAML page-schema validation. Plain asserts, no zod.
|
|
2
|
+
// Returns { errors, warnings }. Errors stop generation; warnings go to stderr.
|
|
3
|
+
import { registry } from "./registry.js";
|
|
4
|
+
|
|
5
|
+
const TOP_KEYS = new Set(["style", "theme", "mode", "state", "body", "onMount", "imports"]);
|
|
6
|
+
const VALID_MODES = new Set(["system", "light", "dark"]);
|
|
7
|
+
const VALID_TYPES = new Set(["string", "number", "bool", "boolean", "array", "object"]);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {any} doc parsed YAML
|
|
11
|
+
* @returns {{errors:string[], warnings:string[], stateNames:Set<string>}}
|
|
12
|
+
*/
|
|
13
|
+
export function validate(doc) {
|
|
14
|
+
const errors = [];
|
|
15
|
+
const warnings = [];
|
|
16
|
+
const stateNames = new Set();
|
|
17
|
+
|
|
18
|
+
if (doc == null || typeof doc !== "object" || Array.isArray(doc)) {
|
|
19
|
+
errors.push("Top-level YAML must be a mapping (object).");
|
|
20
|
+
return { errors, warnings, stateNames };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
for (const k of Object.keys(doc)) {
|
|
24
|
+
if (!TOP_KEYS.has(k)) warnings.push(`Unknown top-level key "${k}" (ignored).`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (doc.mode != null && !VALID_MODES.has(doc.mode)) {
|
|
28
|
+
errors.push(`mode must be one of system | light | dark, got "${doc.mode}".`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// state ---------------------------------------------------------------
|
|
32
|
+
if (doc.state != null) {
|
|
33
|
+
if (!Array.isArray(doc.state)) {
|
|
34
|
+
errors.push("state must be a list of { name, type, default? }.");
|
|
35
|
+
} else {
|
|
36
|
+
for (const entry of doc.state) {
|
|
37
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
38
|
+
errors.push("state entry must be a mapping.");
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!entry.name || typeof entry.name !== "string") {
|
|
42
|
+
errors.push('state entry missing string "name".');
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(entry.name)) {
|
|
46
|
+
errors.push(`state name "${entry.name}" is not a valid JS identifier.`);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (stateNames.has(entry.name)) errors.push(`Duplicate state name "${entry.name}".`);
|
|
50
|
+
stateNames.add(entry.name);
|
|
51
|
+
if (entry.type != null && !VALID_TYPES.has(entry.type)) {
|
|
52
|
+
warnings.push(`state "${entry.name}" has unknown type "${entry.type}"; defaulting to string.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// body ----------------------------------------------------------------
|
|
59
|
+
if (doc.body == null) {
|
|
60
|
+
warnings.push("No body key — generated page will have an empty markup tree.");
|
|
61
|
+
} else if (!Array.isArray(doc.body)) {
|
|
62
|
+
errors.push("body must be a list of component nodes.");
|
|
63
|
+
} else {
|
|
64
|
+
walkBody(doc.body, stateNames, errors, warnings, 0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { errors, warnings, stateNames };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function walkBody(nodes, stateNames, errors, warnings, depth) {
|
|
71
|
+
if (depth > 10) {
|
|
72
|
+
warnings.push("Body nesting deeper than 10 levels (likely a schema mistake); skipping deeper checks.");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
for (const node of nodes) walkNode(node, stateNames, errors, warnings, depth);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function walkNode(node, stateNames, errors, warnings, depth) {
|
|
79
|
+
if (node == null) return;
|
|
80
|
+
if (typeof node === "string") return; // literal text
|
|
81
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
82
|
+
errors.push("Body node must be a mapping or string.");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (typeof node.text === "string") return; // { text: "..." }
|
|
86
|
+
|
|
87
|
+
if (!node.component) {
|
|
88
|
+
errors.push('Body node missing required "component" key.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (typeof node.component !== "string") {
|
|
92
|
+
errors.push(`Component name must be a string, got ${typeof node.component}.`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const entry = registry[node.component];
|
|
96
|
+
if (!entry) {
|
|
97
|
+
errors.push(`Unknown component "${node.component}". Available: ${Object.keys(registry).join(", ")}.`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
validateBind(node, entry, stateNames, errors);
|
|
102
|
+
|
|
103
|
+
if ((node.children != null || node.text != null) && entry.kind === "leaf") {
|
|
104
|
+
warnings.push(`Component "${node.component}" takes no children; ignoring.`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (entry.kind === "multi-snippet") {
|
|
108
|
+
const provided = node.snippets && typeof node.snippets === "object" ? Object.keys(node.snippets) : [];
|
|
109
|
+
for (const sn of provided) {
|
|
110
|
+
if (!(entry.snippets || []).includes(sn)) {
|
|
111
|
+
warnings.push(`Component "${node.component}" has no snippet "${sn}".`);
|
|
112
|
+
} else if (Array.isArray(node.snippets[sn])) {
|
|
113
|
+
walkBody(node.snippets[sn], stateNames, errors, warnings, depth + 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (Array.isArray(node.children)) walkBody(node.children, stateNames, errors, warnings, depth + 1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function validateBind(node, entry, stateNames, errors) {
|
|
122
|
+
const bind = node.bind;
|
|
123
|
+
if (bind == null) return;
|
|
124
|
+
if (typeof bind === "string") {
|
|
125
|
+
if (!entry.primaryBindable) {
|
|
126
|
+
errors.push(`Component "${node.component}" has no primary bindable prop; use "bind: { prop: var }" explicitly or remove bind.`);
|
|
127
|
+
} else if (!stateNames.has(bind)) {
|
|
128
|
+
errors.push(`Bind target "${bind}" is not declared in state:. Add it under state: first.`);
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (typeof bind === "object" && !Array.isArray(bind)) {
|
|
133
|
+
for (const [prop, refName] of Object.entries(bind)) {
|
|
134
|
+
if (typeof refName !== "string") {
|
|
135
|
+
errors.push(`bind.${prop} must be a variable name string.`);
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
if (!stateNames.has(refName)) {
|
|
139
|
+
errors.push(`Bind target "${refName}" (for prop "${prop}") is not declared in state:.`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
errors.push(`bind must be a variable name string or a mapping of { prop: var }, got ${typeof bind}.`);
|
|
145
|
+
}
|
|
@@ -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,
|
|
@@ -20,11 +21,12 @@
|
|
|
20
21
|
const styleClass = $derived(`s-button-${style}`);
|
|
21
22
|
const themeClass = $derived(`theme-${theme}`);
|
|
22
23
|
const variantClass = $derived(`btn-${variant}`);
|
|
24
|
+
const presetClass = $derived(`btn-${preset}`);
|
|
23
25
|
const sizeClass = $derived(`btn-${size}`);
|
|
24
26
|
</script>
|
|
25
27
|
|
|
26
28
|
<button
|
|
27
|
-
class="s-button {styleClass} {themeClass} {variantClass} {sizeClass}"
|
|
29
|
+
class="s-button {styleClass} {themeClass} {variantClass} {presetClass} {sizeClass}"
|
|
28
30
|
{disabled}
|
|
29
31
|
{onclick}
|
|
30
32
|
{...rest}
|
|
@@ -7,6 +7,7 @@ declare const Button: 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;
|
|
@@ -17,6 +18,7 @@ type $$ComponentProps = {
|
|
|
17
18
|
style: any;
|
|
18
19
|
theme: any;
|
|
19
20
|
variant?: string;
|
|
21
|
+
preset?: string;
|
|
20
22
|
size?: string;
|
|
21
23
|
disabled?: boolean;
|
|
22
24
|
icon: any;
|
|
@@ -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);
|
|
@@ -64,7 +65,6 @@
|
|
|
64
65
|
"fluent",
|
|
65
66
|
"carbon",
|
|
66
67
|
"bootstrap",
|
|
67
|
-
"legacy-ios",
|
|
68
68
|
];
|
|
69
69
|
const hasFloatingLabel = $derived(floatingStyles.includes(style) && !!label);
|
|
70
70
|
const hasValue = $derived(!!value);
|
|
@@ -190,23 +190,56 @@
|
|
|
190
190
|
|
|
191
191
|
// Click outside
|
|
192
192
|
let wrapperEl;
|
|
193
|
+
let overlayEl;
|
|
193
194
|
|
|
194
195
|
function docClick(e) {
|
|
195
|
-
|
|
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))) {
|
|
196
200
|
open = false;
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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;
|
|
209
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
|
+
};
|
|
210
243
|
});
|
|
211
244
|
|
|
212
245
|
// Init from value
|
|
@@ -288,8 +321,10 @@
|
|
|
288
321
|
|
|
289
322
|
{#if open}
|
|
290
323
|
<div
|
|
291
|
-
class="s-datepicker-overlay"
|
|
324
|
+
class="s-datepicker-overlay {styleClass} {themeClass}"
|
|
292
325
|
class:s-datepicker-mobile={isMobile}
|
|
326
|
+
bind:this={overlayEl}
|
|
327
|
+
use:portal
|
|
293
328
|
role="dialog"
|
|
294
329
|
aria-modal="true"
|
|
295
330
|
aria-label="Date picker"
|
|
@@ -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;
|
|
@@ -1,34 +1,92 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import "./stepper-styles.css";
|
|
3
|
-
import { defaults } from "../config.js";
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
style: styleProp,
|
|
7
|
-
theme: themeProp,
|
|
8
|
-
steps = [],
|
|
9
|
-
current = 0,
|
|
10
|
-
...rest
|
|
11
|
-
} = $props();
|
|
12
|
-
|
|
13
|
-
const style = $derived(styleProp ?? defaults.style);
|
|
14
|
-
const theme = $derived(themeProp ?? defaults.theme);
|
|
15
|
-
|
|
16
|
-
const styleClass = $derived(`s-stepper-${style}`);
|
|
17
|
-
const themeClass = $derived(`theme-${theme}`);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
<script>
|
|
2
|
+
import "./stepper-styles.css";
|
|
3
|
+
import { defaults } from "../config.js";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
style: styleProp,
|
|
7
|
+
theme: themeProp,
|
|
8
|
+
steps = [],
|
|
9
|
+
current = 0,
|
|
10
|
+
...rest
|
|
11
|
+
} = $props();
|
|
12
|
+
|
|
13
|
+
const style = $derived(styleProp ?? defaults.style);
|
|
14
|
+
const theme = $derived(themeProp ?? defaults.theme);
|
|
15
|
+
|
|
16
|
+
const styleClass = $derived(`s-stepper-${style}`);
|
|
17
|
+
const themeClass = $derived(`theme-${theme}`);
|
|
18
|
+
|
|
19
|
+
let el;
|
|
20
|
+
let canLeft = $state(false);
|
|
21
|
+
let canRight = $state(false);
|
|
22
|
+
|
|
23
|
+
// Recompute arrow visibility from the scroll position.
|
|
24
|
+
function update() {
|
|
25
|
+
if (!el) return;
|
|
26
|
+
canLeft = el.scrollLeft > 1;
|
|
27
|
+
canRight = el.scrollLeft + el.clientWidth < el.scrollWidth - 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Translate by one step's pitch (the offset between two adjacent steps,
|
|
31
|
+
// i.e. one step + its trailing connector) — "1 width of the component".
|
|
32
|
+
function scrollBy1(dir) {
|
|
33
|
+
if (!el) return;
|
|
34
|
+
const stepEls = el.querySelectorAll(".s-stepper-step");
|
|
35
|
+
let amount = el.clientWidth;
|
|
36
|
+
if (stepEls.length >= 2) {
|
|
37
|
+
const pitch = stepEls[1].offsetLeft - stepEls[0].offsetLeft;
|
|
38
|
+
if (pitch > 0) amount = pitch;
|
|
39
|
+
}
|
|
40
|
+
el.scrollBy({ left: dir * amount, behavior: "smooth" });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Track scroll + resize + content changes (steps/current) -> arrow state.
|
|
44
|
+
$effect(() => {
|
|
45
|
+
void steps;
|
|
46
|
+
void current;
|
|
47
|
+
if (!el) return;
|
|
48
|
+
update();
|
|
49
|
+
const onScroll = () => update();
|
|
50
|
+
el.addEventListener("scroll", onScroll, { passive: true });
|
|
51
|
+
const ro = new ResizeObserver(() => update());
|
|
52
|
+
ro.observe(el);
|
|
53
|
+
return () => {
|
|
54
|
+
el.removeEventListener("scroll", onScroll);
|
|
55
|
+
ro.disconnect();
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<div class="s-stepper-wrap">
|
|
61
|
+
<div class="s-stepper {styleClass} {themeClass}" bind:this={el} {...rest}>
|
|
62
|
+
{#each steps as step, i}
|
|
63
|
+
<div
|
|
64
|
+
class="s-stepper-step"
|
|
65
|
+
class:completed={i < current}
|
|
66
|
+
class:active={i === current}
|
|
67
|
+
>
|
|
68
|
+
<div class="s-stepper-circle">{i + 1}</div>
|
|
69
|
+
<span class="s-stepper-label">{step.label}</span>
|
|
70
|
+
</div>
|
|
71
|
+
{#if i < steps.length - 1}
|
|
72
|
+
<div class="s-stepper-connector" class:completed={i < current - 1}></div>
|
|
73
|
+
{/if}
|
|
74
|
+
{/each}
|
|
75
|
+
</div>
|
|
76
|
+
{#if canLeft}
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
class="s-stepper-arrow left"
|
|
80
|
+
aria-label="Scroll steps backward"
|
|
81
|
+
onclick={() => scrollBy1(-1)}>‹</button
|
|
82
|
+
>
|
|
83
|
+
{/if}
|
|
84
|
+
{#if canRight}
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
class="s-stepper-arrow right"
|
|
88
|
+
aria-label="Scroll steps forward"
|
|
89
|
+
onclick={() => scrollBy1(1)}>›</button
|
|
90
|
+
>
|
|
91
|
+
{/if}
|
|
34
92
|
</div>
|
|
@@ -78,12 +78,4 @@
|
|
|
78
78
|
border: 1px solid rgba(255,255,255,0.2);
|
|
79
79
|
box-shadow: var(--t-shadow-md), inset 0 1px 0 rgba(255,255,255,0.3);
|
|
80
80
|
}
|
|
81
|
-
.s-accordion-liquid-glass .s-accordion-header { background: transparent; }
|
|
82
|
-
|
|
83
|
-
/* Legacy iOS */
|
|
84
|
-
.s-accordion-legacy-ios {
|
|
85
|
-
border-radius: 10px;
|
|
86
|
-
border: var(--t-border-width) solid var(--t-border);
|
|
87
|
-
background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%);
|
|
88
|
-
box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--t-shadow-xs);
|
|
89
|
-
}
|
|
81
|
+
.s-accordion-liquid-glass .s-accordion-header { background: transparent; }
|
|
@@ -60,7 +60,4 @@
|
|
|
60
60
|
.s-alert-carbon { border-radius: 0; border: var(--t-border-width) solid var(--t-border); border-left-width: 3px; border-left-color: var(--t-primary); font-family: 'IBM Plex Sans', sans-serif; }
|
|
61
61
|
|
|
62
62
|
/* Liquid Glass */
|
|
63
|
-
.s-alert-liquid-glass { border-radius: 16px; backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); box-shadow: var(--t-shadow-md), inset 0 1px 0 rgba(255,255,255,0.3); }
|
|
64
|
-
|
|
65
|
-
/* Legacy iOS */
|
|
66
|
-
.s-alert-legacy-ios { border-radius: 10px; border: var(--t-border-width) solid var(--t-border); background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--t-shadow-xs); }
|
|
63
|
+
.s-alert-liquid-glass { border-radius: 16px; backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); box-shadow: var(--t-shadow-md), inset 0 1px 0 rgba(255,255,255,0.3); }
|
|
@@ -44,7 +44,4 @@
|
|
|
44
44
|
.s-avatar-carbon { border-radius: 50%; border: var(--t-border-width) solid var(--t-border); }
|
|
45
45
|
|
|
46
46
|
/* Liquid Glass */
|
|
47
|
-
.s-avatar-liquid-glass { backdrop-filter: blur(16px); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }
|
|
48
|
-
|
|
49
|
-
/* Legacy iOS */
|
|
50
|
-
.s-avatar-legacy-ios { border: var(--t-border-width) solid var(--t-border); background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8); }
|
|
47
|
+
.s-avatar-liquid-glass { backdrop-filter: blur(16px); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }
|