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
package/dist/themes/generator.js
CHANGED
|
@@ -1,174 +1,176 @@
|
|
|
1
|
-
/* ===== Theme CSS generator =====
|
|
2
|
-
* Pure JS (no Svelte). Produces `.theme-<name>` (light) and
|
|
3
|
-
* `html.dark .theme-<name>` (dark) CSS rule bodies from a structured config.
|
|
4
|
-
*
|
|
5
|
-
* Config shape (only these fields are configurable; everything else is derived):
|
|
6
|
-
* common: { primary, secondary, info, success, warning, error, textOnPrimary,
|
|
7
|
-
* buttonRadius, cardRadius, inputRadius, borderWidth }
|
|
8
|
-
* light: { text, surface, cardSurface } // all required hex
|
|
9
|
-
* dark: { text, surface, cardSurface } // null = HSL-invert from light
|
|
10
|
-
*
|
|
11
|
-
* Derived (NOT configurable):
|
|
12
|
-
* --t-text-hint / --t-text-muted / --t-text-disabled = 50% transparency of --t-text
|
|
13
|
-
* --t-text-primary = primary, --t-text-secondary = secondary,
|
|
14
|
-
* --t-text-info/success/warning/error = info/success/warning/error
|
|
15
|
-
* --t-card-bg = surface, --t-card-border-color = mix(text 14%, surface),
|
|
16
|
-
* --t-surface-bg = mix(surface 85%, #000), --t-btn-bg = primary
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { invertHex } from "./color.js";
|
|
20
|
-
|
|
21
|
-
/** Stable output order so generated theme.css is byte-stable across runs. */
|
|
22
|
-
const TOKEN_ORDER = [
|
|
23
|
-
"--t-primary", "--t-secondary", "--t-info", "--t-success", "--t-warning", "--t-error",
|
|
24
|
-
"--t-text-on-primary",
|
|
25
|
-
"--t-surface", "--t-card-bg", "--t-card-surface", "--t-card-border-color", "--t-surface-bg",
|
|
26
|
-
"--t-text", "--t-text-hint", "--t-text-muted", "--t-text-disabled",
|
|
27
|
-
"--t-text-primary", "--t-text-secondary",
|
|
28
|
-
"--t-text-info", "--t-text-success", "--t-text-warning", "--t-text-error",
|
|
29
|
-
"--t-btn-bg", "--t-btn-border-color", "--t-btn-radius", "--t-card-radius", "--t-input-radius",
|
|
30
|
-
"--t-border-width",
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
/** 50% transparency of a text color css string. */
|
|
34
|
-
function hintOf(textCss) {
|
|
35
|
-
return `color-mix(in srgb, ${textCss} 50%, transparent)`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Resolve the light-mode token map for a config.
|
|
40
|
-
* @param {object} c theme config
|
|
41
|
-
* @returns {Record<string, string>}
|
|
42
|
-
*/
|
|
43
|
-
export function resolveLight(c) {
|
|
44
|
-
const { common: cm, light: l } = c;
|
|
45
|
-
return {
|
|
46
|
-
"--t-primary": cm.primary,
|
|
47
|
-
"--t-secondary": cm.secondary,
|
|
48
|
-
"--t-info": cm.info,
|
|
49
|
-
"--t-success": cm.success,
|
|
50
|
-
"--t-warning": cm.warning,
|
|
51
|
-
"--t-error": cm.error,
|
|
52
|
-
"--t-text-on-primary": cm.textOnPrimary,
|
|
53
|
-
"--t-btn-radius": cm.buttonRadius,
|
|
54
|
-
"--t-card-radius": cm.cardRadius,
|
|
55
|
-
"--t-input-radius": cm.inputRadius,
|
|
56
|
-
"--t-border-width": cm.borderWidth,
|
|
57
|
-
"--t-btn-bg": cm.primary,
|
|
58
|
-
"--t-btn-border-color": "transparent",
|
|
59
|
-
"--t-text": l.text,
|
|
60
|
-
"--t-surface": l.surface,
|
|
61
|
-
"--t-card-surface": l.cardSurface,
|
|
62
|
-
"--t-card-bg": l.surface,
|
|
63
|
-
"--t-card-border-color": `color-mix(in srgb, ${l.text} 14%, ${l.surface})`,
|
|
64
|
-
"--t-surface-bg": `color-mix(in srgb, ${l.surface} 85%, #000)`,
|
|
65
|
-
"--t-text-primary": cm.primary,
|
|
66
|
-
"--t-text-secondary": cm.secondary,
|
|
67
|
-
"--t-text-info": cm.info,
|
|
68
|
-
"--t-text-success": cm.success,
|
|
69
|
-
"--t-text-warning": cm.warning,
|
|
70
|
-
"--t-text-error": cm.error,
|
|
71
|
-
// --t-text-hint / --t-text-muted / --t-text-disabled MUST be emitted here,
|
|
72
|
-
// not left to theme-base.css. A color-mix() custom property bakes at the
|
|
73
|
-
// declaring element using THAT element's --t-text; the :root derivation
|
|
74
|
-
// bakes with :root's (light) text and is inherited as a fixed dark color,
|
|
75
|
-
// so it never follows --t-text when a theme/style/dark block changes it.
|
|
76
|
-
// Emitting per mode re-bakes with the correct (light or dark) text.
|
|
77
|
-
"--t-text-hint": hintOf(l.text),
|
|
78
|
-
"--t-text-muted": hintOf(l.text),
|
|
79
|
-
"--t-text-disabled": hintOf(l.text),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Resolve the dark-mode token map. null dark fields are HSL-inverted from
|
|
85
|
-
* their light counterpart; explicit (non-null) values win.
|
|
86
|
-
*
|
|
87
|
-
* Only dark-specific tokens are emitted (text, surface, cardSurface + their
|
|
88
|
-
* derivations). Common tokens (primary, status colors, radii, border-width,
|
|
89
|
-
* text-on-primary, btn-bg, brand/status text) are NOT re-emitted — they
|
|
90
|
-
* inherit from the `.theme-<name>` light block on the same element. This keeps
|
|
91
|
-
* the dark block small and avoids restating values that do not change.
|
|
92
|
-
* @param {object} c theme config
|
|
93
|
-
* @returns {Record<string, string>}
|
|
94
|
-
*/
|
|
95
|
-
export function resolveDark(c) {
|
|
96
|
-
const { light: l, dark: d } = c;
|
|
97
|
-
// Text lifts high (stays light); surfaces lift low (stay darker than text).
|
|
98
|
-
const darkText = d.text ?? invertHex(l.text, 20);
|
|
99
|
-
const darkSurface = d.surface ?? invertHex(l.surface, 10);
|
|
100
|
-
const darkCard = d.cardSurface ?? invertHex(l.cardSurface, 14);
|
|
101
|
-
return {
|
|
102
|
-
"--t-text": darkText,
|
|
103
|
-
"--t-surface": darkSurface,
|
|
104
|
-
"--t-card-surface": darkCard,
|
|
105
|
-
"--t-card-bg": darkSurface,
|
|
106
|
-
"--t-card-border-color": `color-mix(in srgb, ${darkText} 14%, ${darkSurface})`,
|
|
107
|
-
"--t-surface-bg": `color-mix(in srgb, ${darkSurface} 85%, #000)`,
|
|
108
|
-
// Re-bake the hint/muted/disabled derivations with the DARK text so they
|
|
109
|
-
// stay light in dark mode (see resolveLight comment for the baking rule).
|
|
110
|
-
"--t-text-hint": hintOf(darkText),
|
|
111
|
-
"--t-text-muted": hintOf(darkText),
|
|
112
|
-
"--t-text-disabled": hintOf(darkText),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** Emit a token map as indented `--t-*: value;` lines, in TOKEN_ORDER, skipping null. */
|
|
117
|
-
function emit(map) {
|
|
118
|
-
return TOKEN_ORDER
|
|
119
|
-
.filter((k) => map[k] != null)
|
|
120
|
-
.map((k) => ` ${k}: ${map[k]};`)
|
|
121
|
-
.join("\n");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Merge a style-override layer onto a base token map.
|
|
126
|
-
* override value === null -> drop that token (preserve the style's own value);
|
|
127
|
-
* non-null -> overwrite. Used for per-style null opt-outs (e.g. liquid-glass).
|
|
128
|
-
* @param {Record<string,string>} base
|
|
129
|
-
* @param {Record<string, string|null>|null} override
|
|
130
|
-
* @returns {Record<string,string>}
|
|
131
|
-
*/
|
|
132
|
-
function mergeLayer(base, override) {
|
|
133
|
-
if (!override) return base;
|
|
134
|
-
const out = { ...base };
|
|
135
|
-
for (const [k, v] of Object.entries(override)) {
|
|
136
|
-
if (v == null) delete out[k];
|
|
137
|
-
else out[k] = v;
|
|
138
|
-
}
|
|
139
|
-
return out;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Generate the `.theme-<name>` and `html.dark .theme-<name>` CSS rules.
|
|
144
|
-
* @param {string} name theme name
|
|
145
|
-
* @param {object} config { common, light, dark }
|
|
146
|
-
* @param {{ light?: object, dark?: object }|null} [override] style-override layer
|
|
147
|
-
* @returns {{ light: string, dark: string }}
|
|
148
|
-
*/
|
|
149
|
-
export function generateThemeCss(name, config, override = null) {
|
|
150
|
-
const lightMap = mergeLayer(resolveLight(config), override?.light);
|
|
151
|
-
const darkMap = mergeLayer(resolveDark(config), override?.dark);
|
|
152
|
-
const light = `.theme-${name} {\n${emit(lightMap)}\n}`;
|
|
153
|
-
const dark = `html.dark .theme-${name} {\n${emit(darkMap)}\n}`;
|
|
154
|
-
return { light, dark };
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Apply a theme config's CSS vars directly to a DOM element (live preview).
|
|
159
|
-
* Sets every resolved token; clears any previously-set --t-* var not in the new map.
|
|
160
|
-
* @param {HTMLElement} el
|
|
161
|
-
* @param {object} config { common, light, dark }
|
|
162
|
-
* @param {boolean} isDark
|
|
163
|
-
*/
|
|
164
|
-
export function applyThemeToElement(el, config, isDark) {
|
|
165
|
-
const map = isDark
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
1
|
+
/* ===== Theme CSS generator =====
|
|
2
|
+
* Pure JS (no Svelte). Produces `.theme-<name>` (light) and
|
|
3
|
+
* `html.dark .theme-<name>` (dark) CSS rule bodies from a structured config.
|
|
4
|
+
*
|
|
5
|
+
* Config shape (only these fields are configurable; everything else is derived):
|
|
6
|
+
* common: { primary, secondary, info, success, warning, error, textOnPrimary,
|
|
7
|
+
* buttonRadius, cardRadius, inputRadius, borderWidth }
|
|
8
|
+
* light: { text, surface, cardSurface } // all required hex
|
|
9
|
+
* dark: { text, surface, cardSurface } // null = HSL-invert from light
|
|
10
|
+
*
|
|
11
|
+
* Derived (NOT configurable):
|
|
12
|
+
* --t-text-hint / --t-text-muted / --t-text-disabled = 50% transparency of --t-text
|
|
13
|
+
* --t-text-primary = primary, --t-text-secondary = secondary,
|
|
14
|
+
* --t-text-info/success/warning/error = info/success/warning/error
|
|
15
|
+
* --t-card-bg = surface, --t-card-border-color = mix(text 14%, surface),
|
|
16
|
+
* --t-surface-bg = mix(surface 85%, #000), --t-btn-bg = primary
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { invertHex } from "./color.js";
|
|
20
|
+
|
|
21
|
+
/** Stable output order so generated theme.css is byte-stable across runs. */
|
|
22
|
+
const TOKEN_ORDER = [
|
|
23
|
+
"--t-primary", "--t-secondary", "--t-info", "--t-success", "--t-warning", "--t-error",
|
|
24
|
+
"--t-text-on-primary",
|
|
25
|
+
"--t-surface", "--t-card-bg", "--t-card-surface", "--t-card-border-color", "--t-surface-bg",
|
|
26
|
+
"--t-text", "--t-text-hint", "--t-text-muted", "--t-text-disabled",
|
|
27
|
+
"--t-text-primary", "--t-text-secondary",
|
|
28
|
+
"--t-text-info", "--t-text-success", "--t-text-warning", "--t-text-error",
|
|
29
|
+
"--t-btn-bg", "--t-btn-border-color", "--t-btn-radius", "--t-card-radius", "--t-input-radius",
|
|
30
|
+
"--t-border-width",
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** 50% transparency of a text color css string. */
|
|
34
|
+
function hintOf(textCss) {
|
|
35
|
+
return `color-mix(in srgb, ${textCss} 50%, transparent)`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the light-mode token map for a config.
|
|
40
|
+
* @param {object} c theme config
|
|
41
|
+
* @returns {Record<string, string>}
|
|
42
|
+
*/
|
|
43
|
+
export function resolveLight(c) {
|
|
44
|
+
const { common: cm, light: l } = c;
|
|
45
|
+
return {
|
|
46
|
+
"--t-primary": cm.primary,
|
|
47
|
+
"--t-secondary": cm.secondary,
|
|
48
|
+
"--t-info": cm.info,
|
|
49
|
+
"--t-success": cm.success,
|
|
50
|
+
"--t-warning": cm.warning,
|
|
51
|
+
"--t-error": cm.error,
|
|
52
|
+
"--t-text-on-primary": cm.textOnPrimary,
|
|
53
|
+
"--t-btn-radius": cm.buttonRadius,
|
|
54
|
+
"--t-card-radius": cm.cardRadius,
|
|
55
|
+
"--t-input-radius": cm.inputRadius,
|
|
56
|
+
"--t-border-width": cm.borderWidth,
|
|
57
|
+
"--t-btn-bg": cm.primary,
|
|
58
|
+
"--t-btn-border-color": "transparent",
|
|
59
|
+
"--t-text": l.text,
|
|
60
|
+
"--t-surface": l.surface,
|
|
61
|
+
"--t-card-surface": l.cardSurface,
|
|
62
|
+
"--t-card-bg": l.surface,
|
|
63
|
+
"--t-card-border-color": `color-mix(in srgb, ${l.text} 14%, ${l.surface})`,
|
|
64
|
+
"--t-surface-bg": `color-mix(in srgb, ${l.surface} 85%, #000)`,
|
|
65
|
+
"--t-text-primary": cm.primary,
|
|
66
|
+
"--t-text-secondary": cm.secondary,
|
|
67
|
+
"--t-text-info": cm.info,
|
|
68
|
+
"--t-text-success": cm.success,
|
|
69
|
+
"--t-text-warning": cm.warning,
|
|
70
|
+
"--t-text-error": cm.error,
|
|
71
|
+
// --t-text-hint / --t-text-muted / --t-text-disabled MUST be emitted here,
|
|
72
|
+
// not left to theme-base.css. A color-mix() custom property bakes at the
|
|
73
|
+
// declaring element using THAT element's --t-text; the :root derivation
|
|
74
|
+
// bakes with :root's (light) text and is inherited as a fixed dark color,
|
|
75
|
+
// so it never follows --t-text when a theme/style/dark block changes it.
|
|
76
|
+
// Emitting per mode re-bakes with the correct (light or dark) text.
|
|
77
|
+
"--t-text-hint": hintOf(l.text),
|
|
78
|
+
"--t-text-muted": hintOf(l.text),
|
|
79
|
+
"--t-text-disabled": hintOf(l.text),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Resolve the dark-mode token map. null dark fields are HSL-inverted from
|
|
85
|
+
* their light counterpart; explicit (non-null) values win.
|
|
86
|
+
*
|
|
87
|
+
* Only dark-specific tokens are emitted (text, surface, cardSurface + their
|
|
88
|
+
* derivations). Common tokens (primary, status colors, radii, border-width,
|
|
89
|
+
* text-on-primary, btn-bg, brand/status text) are NOT re-emitted — they
|
|
90
|
+
* inherit from the `.theme-<name>` light block on the same element. This keeps
|
|
91
|
+
* the dark block small and avoids restating values that do not change.
|
|
92
|
+
* @param {object} c theme config
|
|
93
|
+
* @returns {Record<string, string>}
|
|
94
|
+
*/
|
|
95
|
+
export function resolveDark(c) {
|
|
96
|
+
const { light: l, dark: d } = c;
|
|
97
|
+
// Text lifts high (stays light); surfaces lift low (stay darker than text).
|
|
98
|
+
const darkText = d.text ?? invertHex(l.text, 20);
|
|
99
|
+
const darkSurface = d.surface ?? invertHex(l.surface, 10);
|
|
100
|
+
const darkCard = d.cardSurface ?? invertHex(l.cardSurface, 14);
|
|
101
|
+
return {
|
|
102
|
+
"--t-text": darkText,
|
|
103
|
+
"--t-surface": darkSurface,
|
|
104
|
+
"--t-card-surface": darkCard,
|
|
105
|
+
"--t-card-bg": darkSurface,
|
|
106
|
+
"--t-card-border-color": `color-mix(in srgb, ${darkText} 14%, ${darkSurface})`,
|
|
107
|
+
"--t-surface-bg": `color-mix(in srgb, ${darkSurface} 85%, #000)`,
|
|
108
|
+
// Re-bake the hint/muted/disabled derivations with the DARK text so they
|
|
109
|
+
// stay light in dark mode (see resolveLight comment for the baking rule).
|
|
110
|
+
"--t-text-hint": hintOf(darkText),
|
|
111
|
+
"--t-text-muted": hintOf(darkText),
|
|
112
|
+
"--t-text-disabled": hintOf(darkText),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Emit a token map as indented `--t-*: value;` lines, in TOKEN_ORDER, skipping null. */
|
|
117
|
+
function emit(map) {
|
|
118
|
+
return TOKEN_ORDER
|
|
119
|
+
.filter((k) => map[k] != null)
|
|
120
|
+
.map((k) => ` ${k}: ${map[k]};`)
|
|
121
|
+
.join("\n");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Merge a style-override layer onto a base token map.
|
|
126
|
+
* override value === null -> drop that token (preserve the style's own value);
|
|
127
|
+
* non-null -> overwrite. Used for per-style null opt-outs (e.g. liquid-glass).
|
|
128
|
+
* @param {Record<string,string>} base
|
|
129
|
+
* @param {Record<string, string|null>|null} override
|
|
130
|
+
* @returns {Record<string,string>}
|
|
131
|
+
*/
|
|
132
|
+
function mergeLayer(base, override) {
|
|
133
|
+
if (!override) return base;
|
|
134
|
+
const out = { ...base };
|
|
135
|
+
for (const [k, v] of Object.entries(override)) {
|
|
136
|
+
if (v == null) delete out[k];
|
|
137
|
+
else out[k] = v;
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Generate the `.theme-<name>` and `html.dark .theme-<name>` CSS rules.
|
|
144
|
+
* @param {string} name theme name
|
|
145
|
+
* @param {object} config { common, light, dark }
|
|
146
|
+
* @param {{ light?: object, dark?: object }|null} [override] style-override layer
|
|
147
|
+
* @returns {{ light: string, dark: string }}
|
|
148
|
+
*/
|
|
149
|
+
export function generateThemeCss(name, config, override = null) {
|
|
150
|
+
const lightMap = mergeLayer(resolveLight(config), override?.light);
|
|
151
|
+
const darkMap = mergeLayer(resolveDark(config), override?.dark);
|
|
152
|
+
const light = `.theme-${name} {\n${emit(lightMap)}\n}`;
|
|
153
|
+
const dark = `html.dark .theme-${name},\nhtml.dark.theme-${name} {\n${emit(darkMap)}\n}`;
|
|
154
|
+
return { light, dark };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Apply a theme config's CSS vars directly to a DOM element (live preview).
|
|
159
|
+
* Sets every resolved token; clears any previously-set --t-* var not in the new map.
|
|
160
|
+
* @param {HTMLElement} el
|
|
161
|
+
* @param {object} config { common, light, dark }
|
|
162
|
+
* @param {boolean} isDark
|
|
163
|
+
*/
|
|
164
|
+
export function applyThemeToElement(el, config, isDark) {
|
|
165
|
+
const map = isDark
|
|
166
|
+
? { ...resolveLight(config), ...resolveDark(config) }
|
|
167
|
+
: resolveLight(config);
|
|
168
|
+
// clear stale --t-* vars set by a previous apply
|
|
169
|
+
for (let i = el.style.length - 1; i >= 0; i--) {
|
|
170
|
+
const prop = el.style[i];
|
|
171
|
+
if (prop.startsWith("--t-")) el.style.removeProperty(prop);
|
|
172
|
+
}
|
|
173
|
+
for (const [k, v] of Object.entries(map)) {
|
|
174
|
+
if (v != null) el.style.setProperty(k, v);
|
|
175
|
+
}
|
|
174
176
|
}
|
package/dist/themes/presets.d.ts
CHANGED
|
@@ -18,11 +18,11 @@ export namespace DEFAULT {
|
|
|
18
18
|
let cardSurface: string;
|
|
19
19
|
}
|
|
20
20
|
namespace dark {
|
|
21
|
-
let text_1:
|
|
21
|
+
let text_1: any;
|
|
22
22
|
export { text_1 as text };
|
|
23
|
-
let surface_1:
|
|
23
|
+
let surface_1: any;
|
|
24
24
|
export { surface_1 as surface };
|
|
25
|
-
let cardSurface_1:
|
|
25
|
+
let cardSurface_1: any;
|
|
26
26
|
export { cardSurface_1 as cardSurface };
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -62,11 +62,11 @@ export namespace ocean {
|
|
|
62
62
|
}
|
|
63
63
|
export { light_1 as light };
|
|
64
64
|
export namespace dark_1 {
|
|
65
|
-
let text_3:
|
|
65
|
+
let text_3: any;
|
|
66
66
|
export { text_3 as text };
|
|
67
|
-
let surface_3:
|
|
67
|
+
let surface_3: any;
|
|
68
68
|
export { surface_3 as surface };
|
|
69
|
-
let cardSurface_3:
|
|
69
|
+
let cardSurface_3: any;
|
|
70
70
|
export { cardSurface_3 as cardSurface };
|
|
71
71
|
}
|
|
72
72
|
export { dark_1 as dark };
|
|
@@ -107,11 +107,11 @@ export namespace forest {
|
|
|
107
107
|
}
|
|
108
108
|
export { light_2 as light };
|
|
109
109
|
export namespace dark_2 {
|
|
110
|
-
let text_5:
|
|
110
|
+
let text_5: any;
|
|
111
111
|
export { text_5 as text };
|
|
112
|
-
let surface_5:
|
|
112
|
+
let surface_5: any;
|
|
113
113
|
export { surface_5 as surface };
|
|
114
|
-
let cardSurface_5:
|
|
114
|
+
let cardSurface_5: any;
|
|
115
115
|
export { cardSurface_5 as cardSurface };
|
|
116
116
|
}
|
|
117
117
|
export { dark_2 as dark };
|
|
@@ -152,11 +152,11 @@ export namespace rose {
|
|
|
152
152
|
}
|
|
153
153
|
export { light_3 as light };
|
|
154
154
|
export namespace dark_3 {
|
|
155
|
-
let text_7:
|
|
155
|
+
let text_7: any;
|
|
156
156
|
export { text_7 as text };
|
|
157
|
-
let surface_7:
|
|
157
|
+
let surface_7: any;
|
|
158
158
|
export { surface_7 as surface };
|
|
159
|
-
let cardSurface_7:
|
|
159
|
+
let cardSurface_7: any;
|
|
160
160
|
export { cardSurface_7 as cardSurface };
|
|
161
161
|
}
|
|
162
162
|
export { dark_3 as dark };
|
|
@@ -242,11 +242,11 @@ export namespace gold {
|
|
|
242
242
|
}
|
|
243
243
|
export { light_5 as light };
|
|
244
244
|
export namespace dark_5 {
|
|
245
|
-
let text_11:
|
|
245
|
+
let text_11: any;
|
|
246
246
|
export { text_11 as text };
|
|
247
|
-
let surface_11:
|
|
247
|
+
let surface_11: any;
|
|
248
248
|
export { surface_11 as surface };
|
|
249
|
-
let cardSurface_11:
|
|
249
|
+
let cardSurface_11: any;
|
|
250
250
|
export { cardSurface_11 as cardSurface };
|
|
251
251
|
}
|
|
252
252
|
export { dark_5 as dark };
|
|
@@ -287,11 +287,11 @@ export namespace slate {
|
|
|
287
287
|
}
|
|
288
288
|
export { light_6 as light };
|
|
289
289
|
export namespace dark_6 {
|
|
290
|
-
let text_13:
|
|
290
|
+
let text_13: any;
|
|
291
291
|
export { text_13 as text };
|
|
292
|
-
let surface_13:
|
|
292
|
+
let surface_13: any;
|
|
293
293
|
export { surface_13 as surface };
|
|
294
|
-
let cardSurface_13:
|
|
294
|
+
let cardSurface_13: any;
|
|
295
295
|
export { cardSurface_13 as cardSurface };
|
|
296
296
|
}
|
|
297
297
|
export { dark_6 as dark };
|
|
@@ -332,11 +332,11 @@ export namespace candy {
|
|
|
332
332
|
}
|
|
333
333
|
export { light_7 as light };
|
|
334
334
|
export namespace dark_7 {
|
|
335
|
-
let text_15:
|
|
335
|
+
let text_15: any;
|
|
336
336
|
export { text_15 as text };
|
|
337
|
-
let surface_15:
|
|
337
|
+
let surface_15: any;
|
|
338
338
|
export { surface_15 as surface };
|
|
339
|
-
let cardSurface_15:
|
|
339
|
+
let cardSurface_15: any;
|
|
340
340
|
export { cardSurface_15 as cardSurface };
|
|
341
341
|
}
|
|
342
342
|
export { dark_7 as dark };
|
package/dist/themes/presets.js
CHANGED
|
@@ -29,8 +29,8 @@ export const DEFAULT = {
|
|
|
29
29
|
|
|
30
30
|
export const ocean = {
|
|
31
31
|
common: {
|
|
32
|
-
primary: "#
|
|
33
|
-
info: "#
|
|
32
|
+
primary: "#0369a1", secondary: "#0e7490",
|
|
33
|
+
info: "#0369a1", success: "#15803d", warning: "#a16207", error: "#be123c",
|
|
34
34
|
textOnPrimary: "#ffffff",
|
|
35
35
|
buttonRadius: "10px", cardRadius: "12px", inputRadius: "8px", borderWidth: "1.5px",
|
|
36
36
|
},
|
|
@@ -40,8 +40,8 @@ export const ocean = {
|
|
|
40
40
|
|
|
41
41
|
export const forest = {
|
|
42
42
|
common: {
|
|
43
|
-
primary: "#
|
|
44
|
-
info: "#
|
|
43
|
+
primary: "#15803d", secondary: "#166534",
|
|
44
|
+
info: "#0e7490", success: "#15803d", warning: "#a16207", error: "#b91c1c",
|
|
45
45
|
textOnPrimary: "#ffffff",
|
|
46
46
|
buttonRadius: "8px", cardRadius: "12px", inputRadius: "8px", borderWidth: "1.5px",
|
|
47
47
|
},
|
|
@@ -51,8 +51,8 @@ export const forest = {
|
|
|
51
51
|
|
|
52
52
|
export const rose = {
|
|
53
53
|
common: {
|
|
54
|
-
primary: "#
|
|
55
|
-
info: "#
|
|
54
|
+
primary: "#be123c", secondary: "#9f1239",
|
|
55
|
+
info: "#be123c", success: "#15803d", warning: "#a16207", error: "#be123c",
|
|
56
56
|
textOnPrimary: "#ffffff",
|
|
57
57
|
buttonRadius: "12px", cardRadius: "14px", inputRadius: "8px", borderWidth: "1.5px",
|
|
58
58
|
},
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes discovery metadata from either a `dbmr` `DISCOVER` response
|
|
3
|
+
* (`{ columns: [...] }`) or a custom/non-dbmr structure (`Array` or `{ fields: [...] }`)
|
|
4
|
+
* into `FilterBar` / `CrudView` field definitions.
|
|
5
|
+
*
|
|
6
|
+
* @param {Object|Array|null} discovery
|
|
7
|
+
* @returns {Array<Object>} Normalized field definitions
|
|
8
|
+
*/
|
|
9
|
+
export function normalizeDiscovery(discovery: any | any[] | null): Array<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Maps a `dbmr` `OPTIONS /resources` response (`{ resource, methods: [...] }`)
|
|
12
|
+
* or an array of HTTP methods into `CrudView` permission props.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object|Array<string>} optionsResponse
|
|
15
|
+
* @returns {Object} `{ allowCreate, allowView, allowEdit, allowDelete, allowExport }`
|
|
16
|
+
*/
|
|
17
|
+
export function mapOptionsToCrudProps(optionsResponse: any | Array<string>): any;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a lightweight `dbmr` v0.0.3 HTTP client that pairs directly with `CrudView`.
|
|
20
|
+
* Supports `GET`/`QUERY` listing, `DISCOVER` column & autocomplete lookup, `OPTIONS`,
|
|
21
|
+
* `POST`/`PATCH`/`PUT`/`DELETE`, bulk delete, and optimistic locking (`ETag` / `version`).
|
|
22
|
+
*
|
|
23
|
+
* @param {string} baseUrl - Base resource URL (e.g. "/api/posts")
|
|
24
|
+
* @param {Object} [config]
|
|
25
|
+
* @returns {Object} dbmr client & `crudProps()` helper
|
|
26
|
+
*/
|
|
27
|
+
export function createDbmrClient(baseUrl: string, config?: any): any;
|