@luxalgo/vela-ui 0.3.0 → 0.4.1
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/CHANGELOG.md +165 -132
- package/LICENSE +201 -201
- package/NOTICE +28 -28
- package/README.md +86 -86
- package/cli/engine.mjs +282 -282
- package/cli/index.mjs +154 -154
- package/dist/button.js +2 -2
- package/dist/callout-bubble.js +3 -3
- package/dist/checkbox.js +3 -3
- package/dist/{chunk-OJ2SEMN6.js → chunk-5A54GODF.js} +2 -2
- package/dist/{chunk-UEO6W37Z.js → chunk-7LYWI32I.js} +2 -2
- package/dist/{chunk-IOOYDSSK.js → chunk-BIU66EHS.js} +2 -2
- package/dist/{chunk-KKS6NEGI.js → chunk-BWSOMG3G.js} +1 -1
- package/dist/{chunk-DXDCKZ2M.js → chunk-CZRHHVSB.js} +1 -1
- package/dist/{chunk-C3PXY2SW.js → chunk-EDYD5XKJ.js} +9 -0
- package/dist/chunk-GUIYFQ27.js +30 -0
- package/dist/{chunk-WWHNUKSZ.js → chunk-JEGB72M4.js} +8 -8
- package/dist/{chunk-B2EZB5ZG.js → chunk-ODPGOUQT.js} +4 -3
- package/dist/{chunk-TBXUF5YX.js → chunk-RH53NQGE.js} +18 -4
- package/dist/{chunk-OQXFQMZM.js → chunk-TGJNHUYV.js} +2 -2
- package/dist/collapsible.js +2 -2
- package/dist/color-picker.js +4 -4
- package/dist/context-menu.js +4 -4
- package/dist/date-picker.js +1 -1
- package/dist/dialog.js +4 -4
- package/dist/donut.d.ts +1 -1
- package/dist/drawer.js +1 -1
- package/dist/dropdown-menu.d.ts +2 -0
- package/dist/dropdown-menu.js +4 -4
- package/dist/empty.js +1 -1
- package/dist/field.js +9 -9
- package/dist/{stat.d.ts → figure.d.ts} +9 -9
- package/dist/figure.js +41 -0
- package/dist/glyph-select.js +4 -4
- package/dist/hover-card.js +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/input-group.js +2 -2
- package/dist/item.js +1 -1
- package/dist/manifest.json +75 -74
- package/dist/number-input.js +3 -3
- package/dist/popover.js +2 -2
- package/dist/select.d.ts +5 -1
- package/dist/select.js +5 -5
- package/dist/slider.js +1 -1
- package/dist/sort-button.js +2 -2
- package/dist/switch.js +1 -1
- package/dist/tabs.js +2 -2
- package/dist/{theme-Ct-q58xz.d.ts → theme-TefB8vtl.d.ts} +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +1 -1
- package/dist/theme.schema.json +30 -30
- package/dist/toast.d.ts +2 -2
- package/dist/toast.js +2 -2
- package/dist/toggle-group.js +2 -2
- package/dist/tooltip.js +1 -1
- package/dist/zag.d.ts +11 -2
- package/dist/zag.js +1 -1
- package/docs/theming.md +217 -217
- package/docs/what-to-change.md +20 -20
- package/docs/writing-a-component.md +250 -250
- package/llms.txt +3 -3
- package/package.json +90 -90
- package/registry/badge.ts +119 -119
- package/registry/bar-chart.ts +215 -215
- package/registry/button.ts +387 -387
- package/registry/callout-bubble.ts +347 -347
- package/registry/card.ts +379 -379
- package/registry/checkbox.ts +234 -234
- package/registry/collapsible.ts +271 -271
- package/registry/color-picker.ts +582 -582
- package/registry/context-menu.ts +208 -208
- package/registry/data-table.ts +215 -215
- package/registry/date-picker.ts +483 -483
- package/registry/dialog.ts +551 -551
- package/registry/donut.ts +145 -145
- package/registry/drawer.ts +636 -636
- package/registry/dropdown-menu.ts +765 -762
- package/registry/empty.ts +91 -91
- package/registry/field.ts +584 -584
- package/registry/{stat.ts → figure.ts} +96 -96
- package/registry/glyph-select.ts +268 -268
- package/registry/hover-card.ts +222 -222
- package/registry/input-group.ts +229 -229
- package/registry/input.ts +181 -181
- package/registry/item.ts +376 -376
- package/registry/kbd.ts +64 -64
- package/registry/line-chart.ts +218 -218
- package/registry/month-grid.ts +328 -328
- package/registry/number-input.ts +443 -443
- package/registry/popover.ts +368 -368
- package/registry/scatter-chart.ts +221 -221
- package/registry/select.ts +629 -620
- package/registry/slider.ts +259 -259
- package/registry/sort-button.ts +189 -189
- package/registry/sparkline.ts +114 -114
- package/registry/switch.ts +205 -205
- package/registry/tabs.ts +426 -426
- package/registry/text-area.ts +186 -186
- package/registry/toast.ts +965 -965
- package/registry/toggle-group.ts +295 -295
- package/registry/tooltip.ts +156 -156
- package/registry/treemap.ts +847 -847
- package/skills/theming-vela-ui/SKILL.md +137 -137
- package/skills/using-vela-ui-components/SKILL.md +141 -139
- package/skills/writing-vela-ui-components/SKILL.md +163 -163
- package/src/components/badge.ts +119 -119
- package/src/components/bar-chart.ts +215 -215
- package/src/components/button.ts +387 -387
- package/src/components/callout-bubble.ts +347 -347
- package/src/components/card.ts +379 -379
- package/src/components/checkbox.ts +234 -234
- package/src/components/collapsible.ts +271 -271
- package/src/components/color-picker.ts +582 -582
- package/src/components/context-menu.ts +208 -208
- package/src/components/data-table.ts +215 -215
- package/src/components/date-picker.ts +483 -483
- package/src/components/dialog.ts +551 -551
- package/src/components/donut.ts +145 -145
- package/src/components/drawer.ts +636 -636
- package/src/components/dropdown-menu.ts +765 -762
- package/src/components/empty.ts +91 -91
- package/src/components/field.ts +584 -584
- package/src/components/{stat.ts → figure.ts} +96 -96
- package/src/components/glyph-select.ts +268 -268
- package/src/components/hover-card.ts +222 -222
- package/src/components/input-group.ts +229 -229
- package/src/components/input.ts +181 -181
- package/src/components/item.ts +376 -376
- package/src/components/kbd.ts +64 -64
- package/src/components/line-chart.ts +218 -218
- package/src/components/month-grid.ts +328 -328
- package/src/components/number-input.ts +443 -443
- package/src/components/popover.ts +368 -368
- package/src/components/scatter-chart.ts +221 -221
- package/src/components/select.ts +629 -620
- package/src/components/slider.ts +259 -259
- package/src/components/sort-button.ts +189 -189
- package/src/components/sparkline.ts +114 -114
- package/src/components/switch.ts +205 -205
- package/src/components/tabs.ts +426 -426
- package/src/components/text-area.ts +186 -186
- package/src/components/toast.ts +965 -965
- package/src/components/toggle-group.ts +295 -295
- package/src/components/tooltip.ts +156 -156
- package/src/components/treemap.ts +847 -847
- package/src/index.ts +24 -24
- package/src/lib/calendar.ts +117 -117
- package/src/lib/chart.ts +72 -72
- package/src/lib/color.ts +89 -89
- package/src/lib/component-index.ts +163 -163
- package/src/lib/css.ts +48 -48
- package/src/lib/define.ts +45 -45
- package/src/lib/dispose.ts +36 -36
- package/src/lib/h.ts +55 -55
- package/src/lib/headless.ts +16 -16
- package/src/lib/i18n.ts +30 -30
- package/src/lib/icons.ts +253 -244
- package/src/lib/kit-text.ts +26 -26
- package/src/lib/page.ts +24 -24
- package/src/lib/palette.ts +81 -81
- package/src/lib/placement.ts +188 -188
- package/src/lib/scope.ts +135 -135
- package/src/lib/styles.ts +53 -53
- package/src/lib/surface-events.ts +31 -31
- package/src/lib/surface-exit.ts +87 -87
- package/src/lib/t.ts +68 -68
- package/src/lib/theme.ts +684 -670
- package/src/lib/tokens.ts +110 -110
- package/src/lib/variants.ts +32 -32
- package/src/lib/zag.ts +61 -46
- package/stylelint/index.mjs +60 -60
- package/stylelint/lint.mjs +81 -81
- package/stylelint/plugin.mjs +115 -115
- package/dist/chunk-P4MTEMT7.js +0 -23
- package/dist/stat.js +0 -41
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
// Generated from each component's declaration by scripts/component-index.mjs, which the build
|
|
2
|
-
// and `new-component` run: do not edit.
|
|
3
|
-
|
|
4
|
-
/** Every kit component's parts and settings, by name: what `checkTheme` checks a theme's
|
|
5
|
-
* `components` against. */
|
|
6
|
-
export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly string[]; readonly settings: readonly string[] }>> = {
|
|
7
|
-
badge: {
|
|
8
|
-
parts: ['root'],
|
|
9
|
-
settings: ['radius'],
|
|
10
|
-
},
|
|
11
|
-
'bar-chart': {
|
|
12
|
-
parts: ['root', 'grid', 'label', 'bar', 'marker', 'tip'],
|
|
13
|
-
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
|
|
14
|
-
},
|
|
15
|
-
button: {
|
|
16
|
-
parts: ['root', 'icon', 'keys'],
|
|
17
|
-
settings: ['radius', 'height', 'height-xs', 'height-sm', 'height-lg', 'font-size', 'font-size-xs', 'font-size-sm'],
|
|
18
|
-
},
|
|
19
|
-
'callout-bubble': {
|
|
20
|
-
parts: ['root', 'panel', 'title', 'text', 'actions', 'button'],
|
|
21
|
-
settings: ['panel-radius', 'button-radius'],
|
|
22
|
-
},
|
|
23
|
-
card: {
|
|
24
|
-
parts: ['root', 'header', 'heading', 'eyebrow', 'title', 'trigger', 'description', 'action', 'content', 'footer'],
|
|
25
|
-
settings: ['radius', 'padding', 'padding-sm', 'gap', 'gap-sm', 'background', 'border', 'inset-background'],
|
|
26
|
-
},
|
|
27
|
-
checkbox: {
|
|
28
|
-
parts: ['root', 'icon'],
|
|
29
|
-
settings: ['radius'],
|
|
30
|
-
},
|
|
31
|
-
collapsible: {
|
|
32
|
-
parts: ['root', 'trigger', 'icon', 'title', 'count', 'chevron', 'content'],
|
|
33
|
-
settings: ['trigger-height', 'radius'],
|
|
34
|
-
},
|
|
35
|
-
'color-picker': {
|
|
36
|
-
parts: ['root', 'trigger', 'swatch', 'content'],
|
|
37
|
-
settings: ['swatch-ring', 'circle-swatch-radius', 'content-radius'],
|
|
38
|
-
},
|
|
39
|
-
'data-table': {
|
|
40
|
-
parts: ['root', 'table', 'head', 'sort', 'row', 'cell', 'actions', 'empty'],
|
|
41
|
-
settings: ['row-height', 'head-height', 'head-z'],
|
|
42
|
-
},
|
|
43
|
-
'date-picker': {
|
|
44
|
-
parts: ['root', 'head', 'title', 'switch', 'nav', 'week', 'grid', 'cells', 'blank', 'day', 'cell'],
|
|
45
|
-
settings: ['radius', 'today-ring'],
|
|
46
|
-
},
|
|
47
|
-
dialog: {
|
|
48
|
-
parts: ['backdrop', 'positioner', 'content', 'header', 'title', 'close', 'body', 'footer'],
|
|
49
|
-
settings: ['radius'],
|
|
50
|
-
},
|
|
51
|
-
donut: {
|
|
52
|
-
parts: ['root', 'ring', 'track', 'segment', 'figure', 'caption', 'legend', 'item', 'swatch', 'label', 'value'],
|
|
53
|
-
settings: ['swatch-radius'],
|
|
54
|
-
},
|
|
55
|
-
drawer: {
|
|
56
|
-
parts: ['backdrop', 'positioner', 'content', 'grab', 'title', 'body'],
|
|
57
|
-
settings: ['radius', 'edge-radius', 'side-width', 'grab-radius'],
|
|
58
|
-
},
|
|
59
|
-
'dropdown-menu': {
|
|
60
|
-
parts: ['content', 'item', 'icon', 'label', 'hint', 'mark', 'badge', 'star', 'switch', 'arrow', 'separator'],
|
|
61
|
-
settings: ['radius', 'switch-radius'],
|
|
62
|
-
},
|
|
63
|
-
empty: {
|
|
64
|
-
parts: ['root', 'icon', 'title', 'description'],
|
|
65
|
-
settings: ['icon-radius'],
|
|
66
|
-
},
|
|
67
|
-
field: {
|
|
68
|
-
parts: ['grid', 'row', 'span', 'label', 'cell', 'bool', 'stacked', 'stacked-head', 'inline', 'inline-item', 'toggle-label', 'section', 'sep'],
|
|
69
|
-
settings: [],
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
parts: ['root', '
|
|
73
|
-
settings: [
|
|
74
|
-
},
|
|
75
|
-
'
|
|
76
|
-
parts: ['root', '
|
|
77
|
-
settings: ['radius', '
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
parts: ['root', '
|
|
81
|
-
settings: ['radius', '
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
parts: ['root', 'control'
|
|
85
|
-
settings: ['radius', '
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
parts: ['root', '
|
|
89
|
-
settings: ['radius', '
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
parts: ['root'],
|
|
93
|
-
settings: ['radius', '
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
parts: ['root'
|
|
97
|
-
settings: ['
|
|
98
|
-
},
|
|
99
|
-
'
|
|
100
|
-
parts: ['root', '
|
|
101
|
-
settings: ['radius', '
|
|
102
|
-
},
|
|
103
|
-
'
|
|
104
|
-
parts: ['root', '
|
|
105
|
-
settings: ['radius', '
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
parts: ['
|
|
109
|
-
settings: [],
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
parts: ['
|
|
113
|
-
settings: [
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
parts: ['root', '
|
|
117
|
-
settings: ['radius', '
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
parts: ['root', '
|
|
121
|
-
settings: ['
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
parts: ['root', '
|
|
125
|
-
settings: ['radius'],
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
parts: ['root', '
|
|
129
|
-
settings: ['
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
parts: ['root', '
|
|
133
|
-
settings: [],
|
|
134
|
-
},
|
|
135
|
-
switch: {
|
|
136
|
-
parts: ['root', 'control', 'thumb'],
|
|
137
|
-
settings: ['width', 'height', 'thumb-size', 'width-sm', 'height-sm', 'thumb-size-sm'],
|
|
138
|
-
},
|
|
139
|
-
tabs: {
|
|
140
|
-
parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
|
|
141
|
-
settings: ['track-radius', 'trigger-radius', 'filled-radius', 'soft-radius', 'count-radius'],
|
|
142
|
-
},
|
|
143
|
-
'text-area': {
|
|
144
|
-
parts: ['root', 'input'],
|
|
145
|
-
settings: ['radius', 'focus-ring'],
|
|
146
|
-
},
|
|
147
|
-
toast: {
|
|
148
|
-
parts: ['root', 'list', 'item', 'close', 'icon', 'content', 'title', 'description', 'cancel', 'action'],
|
|
149
|
-
settings: ['width', 'radius', 'background', 'border', 'foreground', 'description-color', 'shadow', 'success', 'info', 'warning', 'error'],
|
|
150
|
-
},
|
|
151
|
-
'toggle-group': {
|
|
152
|
-
parts: ['root', 'item', 'icon'],
|
|
153
|
-
settings: ['radius', 'radius-sm', 'item-radius', 'item-radius-sm'],
|
|
154
|
-
},
|
|
155
|
-
tooltip: {
|
|
156
|
-
parts: ['positioner', 'content'],
|
|
157
|
-
settings: ['radius'],
|
|
158
|
-
},
|
|
159
|
-
treemap: {
|
|
160
|
-
parts: ['root', 'crumbs', 'crumb', 'map', 'group', 'group-name', 'group-value', 'tile', 'tile-label', 'tile-value', 'legend', 'legend-bar', 'tip'],
|
|
161
|
-
settings: ['radius', 'up', 'down', 'tile-bg', 'tint-min', 'tint-max', 'hover-z', 'tip-radius', 'tip-bg', 'tip-shadow', 'tip-z'],
|
|
162
|
-
},
|
|
163
|
-
};
|
|
1
|
+
// Generated from each component's declaration by scripts/component-index.mjs, which the build
|
|
2
|
+
// and `new-component` run: do not edit.
|
|
3
|
+
|
|
4
|
+
/** Every kit component's parts and settings, by name: what `checkTheme` checks a theme's
|
|
5
|
+
* `components` against. */
|
|
6
|
+
export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly string[]; readonly settings: readonly string[] }>> = {
|
|
7
|
+
badge: {
|
|
8
|
+
parts: ['root'],
|
|
9
|
+
settings: ['radius'],
|
|
10
|
+
},
|
|
11
|
+
'bar-chart': {
|
|
12
|
+
parts: ['root', 'grid', 'label', 'bar', 'marker', 'tip'],
|
|
13
|
+
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
|
|
14
|
+
},
|
|
15
|
+
button: {
|
|
16
|
+
parts: ['root', 'icon', 'keys'],
|
|
17
|
+
settings: ['radius', 'height', 'height-xs', 'height-sm', 'height-lg', 'font-size', 'font-size-xs', 'font-size-sm'],
|
|
18
|
+
},
|
|
19
|
+
'callout-bubble': {
|
|
20
|
+
parts: ['root', 'panel', 'title', 'text', 'actions', 'button'],
|
|
21
|
+
settings: ['panel-radius', 'button-radius'],
|
|
22
|
+
},
|
|
23
|
+
card: {
|
|
24
|
+
parts: ['root', 'header', 'heading', 'eyebrow', 'title', 'trigger', 'description', 'action', 'content', 'footer'],
|
|
25
|
+
settings: ['radius', 'padding', 'padding-sm', 'gap', 'gap-sm', 'background', 'border', 'inset-background'],
|
|
26
|
+
},
|
|
27
|
+
checkbox: {
|
|
28
|
+
parts: ['root', 'icon'],
|
|
29
|
+
settings: ['radius'],
|
|
30
|
+
},
|
|
31
|
+
collapsible: {
|
|
32
|
+
parts: ['root', 'trigger', 'icon', 'title', 'count', 'chevron', 'content'],
|
|
33
|
+
settings: ['trigger-height', 'radius'],
|
|
34
|
+
},
|
|
35
|
+
'color-picker': {
|
|
36
|
+
parts: ['root', 'trigger', 'swatch', 'content'],
|
|
37
|
+
settings: ['swatch-ring', 'circle-swatch-radius', 'content-radius'],
|
|
38
|
+
},
|
|
39
|
+
'data-table': {
|
|
40
|
+
parts: ['root', 'table', 'head', 'sort', 'row', 'cell', 'actions', 'empty'],
|
|
41
|
+
settings: ['row-height', 'head-height', 'head-z'],
|
|
42
|
+
},
|
|
43
|
+
'date-picker': {
|
|
44
|
+
parts: ['root', 'head', 'title', 'switch', 'nav', 'week', 'grid', 'cells', 'blank', 'day', 'cell'],
|
|
45
|
+
settings: ['radius', 'today-ring'],
|
|
46
|
+
},
|
|
47
|
+
dialog: {
|
|
48
|
+
parts: ['backdrop', 'positioner', 'content', 'header', 'title', 'close', 'body', 'footer'],
|
|
49
|
+
settings: ['radius'],
|
|
50
|
+
},
|
|
51
|
+
donut: {
|
|
52
|
+
parts: ['root', 'ring', 'track', 'segment', 'figure', 'caption', 'legend', 'item', 'swatch', 'label', 'value'],
|
|
53
|
+
settings: ['swatch-radius'],
|
|
54
|
+
},
|
|
55
|
+
drawer: {
|
|
56
|
+
parts: ['backdrop', 'positioner', 'content', 'grab', 'title', 'body'],
|
|
57
|
+
settings: ['radius', 'edge-radius', 'side-width', 'grab-radius'],
|
|
58
|
+
},
|
|
59
|
+
'dropdown-menu': {
|
|
60
|
+
parts: ['content', 'item', 'icon', 'label', 'hint', 'mark', 'badge', 'star', 'switch', 'arrow', 'separator'],
|
|
61
|
+
settings: ['radius', 'switch-radius'],
|
|
62
|
+
},
|
|
63
|
+
empty: {
|
|
64
|
+
parts: ['root', 'icon', 'title', 'description'],
|
|
65
|
+
settings: ['icon-radius'],
|
|
66
|
+
},
|
|
67
|
+
field: {
|
|
68
|
+
parts: ['grid', 'row', 'span', 'label', 'cell', 'bool', 'stacked', 'stacked-head', 'inline', 'inline-item', 'toggle-label', 'section', 'sep'],
|
|
69
|
+
settings: [],
|
|
70
|
+
},
|
|
71
|
+
figure: {
|
|
72
|
+
parts: ['root', 'label', 'value', 'sub'],
|
|
73
|
+
settings: [],
|
|
74
|
+
},
|
|
75
|
+
'glyph-select': {
|
|
76
|
+
parts: ['root', 'value', 'icon', 'content', 'item'],
|
|
77
|
+
settings: ['radius', 'content-radius', 'focus-ring'],
|
|
78
|
+
},
|
|
79
|
+
'hover-card': {
|
|
80
|
+
parts: ['root', 'heading', 'icon', 'title', 'description', 'body', 'hint'],
|
|
81
|
+
settings: ['radius', 'width', 'wide-width', 'icon-radius', 'shadow'],
|
|
82
|
+
},
|
|
83
|
+
input: {
|
|
84
|
+
parts: ['root', 'control'],
|
|
85
|
+
settings: ['radius', 'focus-ring'],
|
|
86
|
+
},
|
|
87
|
+
'input-group': {
|
|
88
|
+
parts: ['root', 'control', 'addon', 'text'],
|
|
89
|
+
settings: ['radius', 'height', 'height-sm', 'focus-ring'],
|
|
90
|
+
},
|
|
91
|
+
item: {
|
|
92
|
+
parts: ['root', 'media', 'content', 'title', 'description', 'meta', 'actions', 'group'],
|
|
93
|
+
settings: ['radius', 'gap'],
|
|
94
|
+
},
|
|
95
|
+
kbd: {
|
|
96
|
+
parts: ['root'],
|
|
97
|
+
settings: ['radius', 'shadow'],
|
|
98
|
+
},
|
|
99
|
+
'line-chart': {
|
|
100
|
+
parts: ['root', 'label', 'area', 'line', 'dot', 'tip'],
|
|
101
|
+
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg', 'stroke-width'],
|
|
102
|
+
},
|
|
103
|
+
'month-grid': {
|
|
104
|
+
parts: ['root', 'weekday', 'day', 'date', 'value', 'detail', 'blank'],
|
|
105
|
+
settings: ['radius', 'day-height', 'gap', 'selected-ring'],
|
|
106
|
+
},
|
|
107
|
+
'number-input': {
|
|
108
|
+
parts: ['root', 'input', 'steps', 'step'],
|
|
109
|
+
settings: ['radius', 'step-radius', 'focus-ring'],
|
|
110
|
+
},
|
|
111
|
+
popover: {
|
|
112
|
+
parts: ['content'],
|
|
113
|
+
settings: [],
|
|
114
|
+
},
|
|
115
|
+
'scatter-chart': {
|
|
116
|
+
parts: ['root', 'grid', 'label', 'point', 'trend', 'focus', 'tip'],
|
|
117
|
+
settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
|
|
118
|
+
},
|
|
119
|
+
select: {
|
|
120
|
+
parts: ['root', 'trigger', 'value', 'icon', 'sizer', 'native', 'content', 'viewport', 'item', 'rail', 'thumb'],
|
|
121
|
+
settings: ['radius', 'content-radius', 'thumb-radius', 'focus-ring'],
|
|
122
|
+
},
|
|
123
|
+
slider: {
|
|
124
|
+
parts: ['root', 'control', 'track', 'range', 'thumb'],
|
|
125
|
+
settings: ['track-height', 'thumb-size', 'radius', 'focus-ring'],
|
|
126
|
+
},
|
|
127
|
+
'sort-button': {
|
|
128
|
+
parts: ['root', 'icon', 'state'],
|
|
129
|
+
settings: ['radius'],
|
|
130
|
+
},
|
|
131
|
+
sparkline: {
|
|
132
|
+
parts: ['root', 'area', 'baseline', 'line'],
|
|
133
|
+
settings: ['stroke-width'],
|
|
134
|
+
},
|
|
135
|
+
switch: {
|
|
136
|
+
parts: ['root', 'control', 'thumb'],
|
|
137
|
+
settings: ['width', 'height', 'thumb-size', 'width-sm', 'height-sm', 'thumb-size-sm'],
|
|
138
|
+
},
|
|
139
|
+
tabs: {
|
|
140
|
+
parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
|
|
141
|
+
settings: ['track-radius', 'trigger-radius', 'filled-radius', 'soft-radius', 'count-radius'],
|
|
142
|
+
},
|
|
143
|
+
'text-area': {
|
|
144
|
+
parts: ['root', 'input'],
|
|
145
|
+
settings: ['radius', 'focus-ring'],
|
|
146
|
+
},
|
|
147
|
+
toast: {
|
|
148
|
+
parts: ['root', 'list', 'item', 'close', 'icon', 'content', 'title', 'description', 'cancel', 'action'],
|
|
149
|
+
settings: ['width', 'radius', 'background', 'border', 'foreground', 'description-color', 'shadow', 'success', 'info', 'warning', 'error'],
|
|
150
|
+
},
|
|
151
|
+
'toggle-group': {
|
|
152
|
+
parts: ['root', 'item', 'icon'],
|
|
153
|
+
settings: ['radius', 'radius-sm', 'item-radius', 'item-radius-sm'],
|
|
154
|
+
},
|
|
155
|
+
tooltip: {
|
|
156
|
+
parts: ['positioner', 'content'],
|
|
157
|
+
settings: ['radius'],
|
|
158
|
+
},
|
|
159
|
+
treemap: {
|
|
160
|
+
parts: ['root', 'crumbs', 'crumb', 'map', 'group', 'group-name', 'group-value', 'tile', 'tile-label', 'tile-value', 'legend', 'legend-bar', 'tip'],
|
|
161
|
+
settings: ['radius', 'up', 'down', 'tile-bg', 'tint-min', 'tint-max', 'hover-z', 'tip-radius', 'tip-bg', 'tip-shadow', 'tip-z'],
|
|
162
|
+
},
|
|
163
|
+
};
|
package/src/lib/css.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// Component CSS: written in `css` templates (editors highlight them, stylelint checks them
|
|
2
|
-
// through the postcss-lit syntax) and injected once per document or shadow root.
|
|
3
|
-
import { pageState } from './page';
|
|
4
|
-
import { scopeToKit } from './scope';
|
|
5
|
-
import { injectLayerOrder, injectStyles } from './styles';
|
|
6
|
-
|
|
7
|
-
export { injectLayerOrder, LAYER_ORDER } from './styles';
|
|
8
|
-
|
|
9
|
-
// The texts the tag produced: CSS written in code. A theme loaded from data (a saved JSON, a
|
|
10
|
-
// shared file) holds strings no code wrote, so its CSS is told apart and left out by default.
|
|
11
|
-
// Page-wide: a theme written with one copy of the kit is applied by another.
|
|
12
|
-
const written = pageState('written-css@1', () => new Set<string>());
|
|
13
|
-
|
|
14
|
-
/** Joins a template into its CSS text. Interpolations are tokens (`t.*`) and component
|
|
15
|
-
* settings, which print as `var(--vela-…)`. */
|
|
16
|
-
export function css(strings: TemplateStringsArray, ...values: unknown[]): string {
|
|
17
|
-
let out = strings[0] ?? '';
|
|
18
|
-
for (let i = 0; i < values.length; i += 1) out += String(values[i]) + (strings[i + 1] ?? '');
|
|
19
|
-
written.add(out);
|
|
20
|
-
return out;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Whether a CSS text was written with the {@link css} tag, or accepted as if it were. */
|
|
24
|
-
export function isWrittenCss(text: string): boolean {
|
|
25
|
-
return written.has(text);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** Accept a CSS text from data as if code wrote it (a host's explicit `allowCss`). */
|
|
29
|
-
export function acceptCss(text: string): void {
|
|
30
|
-
written.add(text);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** A component's stylesheet: call the result with the root it renders in, at creation, never
|
|
34
|
-
* at import (a component nobody creates injects nothing). Its rules apply inside kit hosts,
|
|
35
|
-
* their floating layers and themed hosts only: the page's own elements may carry the same
|
|
36
|
-
* part names. */
|
|
37
|
-
export function defineStyles(id: string, text: string): (root?: Document | ShadowRoot) => void {
|
|
38
|
-
// The sheet each root got, so later creations skip the lookup while it stays in place.
|
|
39
|
-
const injected = new WeakMap<Document | ShadowRoot, Element>();
|
|
40
|
-
let scoped: string | undefined;
|
|
41
|
-
return (root = document) => {
|
|
42
|
-
if (injected.get(root)?.isConnected) return;
|
|
43
|
-
injectLayerOrder(root);
|
|
44
|
-
injectStyles(id, (scoped ??= scopeToKit(text)), root);
|
|
45
|
-
const sheet = root.getElementById?.(id) ?? (root instanceof Document ? null : root.querySelector(`#${CSS.escape(id)}`));
|
|
46
|
-
if (sheet) injected.set(root, sheet);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
1
|
+
// Component CSS: written in `css` templates (editors highlight them, stylelint checks them
|
|
2
|
+
// through the postcss-lit syntax) and injected once per document or shadow root.
|
|
3
|
+
import { pageState } from './page';
|
|
4
|
+
import { scopeToKit } from './scope';
|
|
5
|
+
import { injectLayerOrder, injectStyles } from './styles';
|
|
6
|
+
|
|
7
|
+
export { injectLayerOrder, LAYER_ORDER } from './styles';
|
|
8
|
+
|
|
9
|
+
// The texts the tag produced: CSS written in code. A theme loaded from data (a saved JSON, a
|
|
10
|
+
// shared file) holds strings no code wrote, so its CSS is told apart and left out by default.
|
|
11
|
+
// Page-wide: a theme written with one copy of the kit is applied by another.
|
|
12
|
+
const written = pageState('written-css@1', () => new Set<string>());
|
|
13
|
+
|
|
14
|
+
/** Joins a template into its CSS text. Interpolations are tokens (`t.*`) and component
|
|
15
|
+
* settings, which print as `var(--vela-…)`. */
|
|
16
|
+
export function css(strings: TemplateStringsArray, ...values: unknown[]): string {
|
|
17
|
+
let out = strings[0] ?? '';
|
|
18
|
+
for (let i = 0; i < values.length; i += 1) out += String(values[i]) + (strings[i + 1] ?? '');
|
|
19
|
+
written.add(out);
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Whether a CSS text was written with the {@link css} tag, or accepted as if it were. */
|
|
24
|
+
export function isWrittenCss(text: string): boolean {
|
|
25
|
+
return written.has(text);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Accept a CSS text from data as if code wrote it (a host's explicit `allowCss`). */
|
|
29
|
+
export function acceptCss(text: string): void {
|
|
30
|
+
written.add(text);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A component's stylesheet: call the result with the root it renders in, at creation, never
|
|
34
|
+
* at import (a component nobody creates injects nothing). Its rules apply inside kit hosts,
|
|
35
|
+
* their floating layers and themed hosts only: the page's own elements may carry the same
|
|
36
|
+
* part names. */
|
|
37
|
+
export function defineStyles(id: string, text: string): (root?: Document | ShadowRoot) => void {
|
|
38
|
+
// The sheet each root got, so later creations skip the lookup while it stays in place.
|
|
39
|
+
const injected = new WeakMap<Document | ShadowRoot, Element>();
|
|
40
|
+
let scoped: string | undefined;
|
|
41
|
+
return (root = document) => {
|
|
42
|
+
if (injected.get(root)?.isConnected) return;
|
|
43
|
+
injectLayerOrder(root);
|
|
44
|
+
injectStyles(id, (scoped ??= scopeToKit(text)), root);
|
|
45
|
+
const sheet = root.getElementById?.(id) ?? (root instanceof Document ? null : root.querySelector(`#${CSS.escape(id)}`));
|
|
46
|
+
if (sheet) injected.set(root, sheet);
|
|
47
|
+
};
|
|
48
|
+
}
|
package/src/lib/define.ts
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
// A component's declaration: its name, its parts and its settings. Every link between the
|
|
2
|
-
// name and the component's CSS comes from it: the parts' `data-slot` values, and the settings'
|
|
3
|
-
// custom properties, which a theme or a host's CSS can set.
|
|
4
|
-
import { pageState } from './page';
|
|
5
|
-
import type { Token } from './t';
|
|
6
|
-
|
|
7
|
-
export interface ComponentDef<N extends string, P extends string, S extends string> {
|
|
8
|
-
readonly name: N;
|
|
9
|
-
readonly parts: readonly P[];
|
|
10
|
-
/** A part's `data-slot`: the bare name for `root`, `name-part` otherwise. */
|
|
11
|
-
slot(part: P): string;
|
|
12
|
-
/** Each setting as `var(--vela-<name>-<setting>, <default>)`, for the component's CSS. */
|
|
13
|
-
readonly vars: { readonly [K in S]: string };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** A declared component's parts and settings, as a theme can name them. */
|
|
17
|
-
export interface DeclaredComponent {
|
|
18
|
-
readonly parts: readonly string[];
|
|
19
|
-
readonly settings: readonly string[];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const declared = (): Map<string, DeclaredComponent> => pageState('component-defs@1', () => new Map());
|
|
23
|
-
|
|
24
|
-
/** Every component declared on the page so far, the kit's and a page's own, by name. */
|
|
25
|
-
export function declaredComponents(): ReadonlyMap<string, DeclaredComponent> {
|
|
26
|
-
return declared();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function defineComponent<const N extends string, const P extends string, const S extends string = never>(def: {
|
|
30
|
-
name: N;
|
|
31
|
-
parts: readonly P[];
|
|
32
|
-
settings?: { readonly [K in S]: Token | string };
|
|
33
|
-
}): ComponentDef<N, P, S> {
|
|
34
|
-
const vars = {} as Record<string, string>;
|
|
35
|
-
for (const [key, fallback] of Object.entries(def.settings ?? {}) as Array<[string, Token | string]>) {
|
|
36
|
-
vars[key] = `var(--vela-${def.name}-${key}, ${String(fallback)})`;
|
|
37
|
-
}
|
|
38
|
-
declared().set(def.name, { parts: def.parts, settings: Object.keys(vars) });
|
|
39
|
-
return {
|
|
40
|
-
name: def.name,
|
|
41
|
-
parts: def.parts,
|
|
42
|
-
slot: (part) => (part === 'root' ? def.name : `${def.name}-${part}`),
|
|
43
|
-
vars: vars as { readonly [K in S]: string },
|
|
44
|
-
};
|
|
45
|
-
}
|
|
1
|
+
// A component's declaration: its name, its parts and its settings. Every link between the
|
|
2
|
+
// name and the component's CSS comes from it: the parts' `data-slot` values, and the settings'
|
|
3
|
+
// custom properties, which a theme or a host's CSS can set.
|
|
4
|
+
import { pageState } from './page';
|
|
5
|
+
import type { Token } from './t';
|
|
6
|
+
|
|
7
|
+
export interface ComponentDef<N extends string, P extends string, S extends string> {
|
|
8
|
+
readonly name: N;
|
|
9
|
+
readonly parts: readonly P[];
|
|
10
|
+
/** A part's `data-slot`: the bare name for `root`, `name-part` otherwise. */
|
|
11
|
+
slot(part: P): string;
|
|
12
|
+
/** Each setting as `var(--vela-<name>-<setting>, <default>)`, for the component's CSS. */
|
|
13
|
+
readonly vars: { readonly [K in S]: string };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A declared component's parts and settings, as a theme can name them. */
|
|
17
|
+
export interface DeclaredComponent {
|
|
18
|
+
readonly parts: readonly string[];
|
|
19
|
+
readonly settings: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const declared = (): Map<string, DeclaredComponent> => pageState('component-defs@1', () => new Map());
|
|
23
|
+
|
|
24
|
+
/** Every component declared on the page so far, the kit's and a page's own, by name. */
|
|
25
|
+
export function declaredComponents(): ReadonlyMap<string, DeclaredComponent> {
|
|
26
|
+
return declared();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function defineComponent<const N extends string, const P extends string, const S extends string = never>(def: {
|
|
30
|
+
name: N;
|
|
31
|
+
parts: readonly P[];
|
|
32
|
+
settings?: { readonly [K in S]: Token | string };
|
|
33
|
+
}): ComponentDef<N, P, S> {
|
|
34
|
+
const vars = {} as Record<string, string>;
|
|
35
|
+
for (const [key, fallback] of Object.entries(def.settings ?? {}) as Array<[string, Token | string]>) {
|
|
36
|
+
vars[key] = `var(--vela-${def.name}-${key}, ${String(fallback)})`;
|
|
37
|
+
}
|
|
38
|
+
declared().set(def.name, { parts: def.parts, settings: Object.keys(vars) });
|
|
39
|
+
return {
|
|
40
|
+
name: def.name,
|
|
41
|
+
parts: def.parts,
|
|
42
|
+
slot: (part) => (part === 'root' ? def.name : `${def.name}-${part}`),
|
|
43
|
+
vars: vars as { readonly [K in S]: string },
|
|
44
|
+
};
|
|
45
|
+
}
|
package/src/lib/dispose.ts
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// Teardown that outlives an element. A control with a running state machine must be stopped,
|
|
2
|
-
// not only detached: some machines register page-wide listeners that keep running, and keep
|
|
3
|
-
// their memory, after the element is gone. Each such control ties its teardown to its root
|
|
4
|
-
// element, so whoever discards a subtree releases every control in it with one call, whether
|
|
5
|
-
// or not it kept the handles. The kit's dialog, drawer and popover do it when destroyed.
|
|
6
|
-
import { pageState } from './page';
|
|
7
|
-
|
|
8
|
-
const owned = pageState('teardowns@1', () => new WeakMap<Element, Set<() => void>>());
|
|
9
|
-
|
|
10
|
-
/** Tie `teardown` to `el` and return its release, which runs it once: a control's `destroy()`
|
|
11
|
-
* calls the release, and so does {@link disposeWithin} on any of its ancestors. */
|
|
12
|
-
export function ownTeardown(el: Element, teardown: () => void): () => void {
|
|
13
|
-
let set = owned.get(el);
|
|
14
|
-
if (!set) owned.set(el, (set = new Set()));
|
|
15
|
-
const own = set;
|
|
16
|
-
const release = (): void => {
|
|
17
|
-
if (!own.delete(release)) return;
|
|
18
|
-
teardown();
|
|
19
|
-
};
|
|
20
|
-
own.add(release);
|
|
21
|
-
return release;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const releaseAt = (el: Element): void => {
|
|
25
|
-
const set = owned.get(el);
|
|
26
|
-
if (set) for (const release of [...set]) release();
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/** Release every kit control inside `root`, `root` included. Call it on a subtree you are
|
|
30
|
-
* discarding: a dialog body you rebuild, a row you remove. A released control no longer
|
|
31
|
-
* responds, so never call it on content you will show again. */
|
|
32
|
-
export function disposeWithin(root: Element | DocumentFragment | null | undefined): void {
|
|
33
|
-
if (!root) return;
|
|
34
|
-
if (root.nodeType === 1) releaseAt(root as Element);
|
|
35
|
-
for (const el of root.querySelectorAll('*')) releaseAt(el);
|
|
36
|
-
}
|
|
1
|
+
// Teardown that outlives an element. A control with a running state machine must be stopped,
|
|
2
|
+
// not only detached: some machines register page-wide listeners that keep running, and keep
|
|
3
|
+
// their memory, after the element is gone. Each such control ties its teardown to its root
|
|
4
|
+
// element, so whoever discards a subtree releases every control in it with one call, whether
|
|
5
|
+
// or not it kept the handles. The kit's dialog, drawer and popover do it when destroyed.
|
|
6
|
+
import { pageState } from './page';
|
|
7
|
+
|
|
8
|
+
const owned = pageState('teardowns@1', () => new WeakMap<Element, Set<() => void>>());
|
|
9
|
+
|
|
10
|
+
/** Tie `teardown` to `el` and return its release, which runs it once: a control's `destroy()`
|
|
11
|
+
* calls the release, and so does {@link disposeWithin} on any of its ancestors. */
|
|
12
|
+
export function ownTeardown(el: Element, teardown: () => void): () => void {
|
|
13
|
+
let set = owned.get(el);
|
|
14
|
+
if (!set) owned.set(el, (set = new Set()));
|
|
15
|
+
const own = set;
|
|
16
|
+
const release = (): void => {
|
|
17
|
+
if (!own.delete(release)) return;
|
|
18
|
+
teardown();
|
|
19
|
+
};
|
|
20
|
+
own.add(release);
|
|
21
|
+
return release;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const releaseAt = (el: Element): void => {
|
|
25
|
+
const set = owned.get(el);
|
|
26
|
+
if (set) for (const release of [...set]) release();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Release every kit control inside `root`, `root` included. Call it on a subtree you are
|
|
30
|
+
* discarding: a dialog body you rebuild, a row you remove. A released control no longer
|
|
31
|
+
* responds, so never call it on content you will show again. */
|
|
32
|
+
export function disposeWithin(root: Element | DocumentFragment | null | undefined): void {
|
|
33
|
+
if (!root) return;
|
|
34
|
+
if (root.nodeType === 1) releaseAt(root as Element);
|
|
35
|
+
for (const el of root.querySelectorAll('*')) releaseAt(el);
|
|
36
|
+
}
|