@luxalgo/vela-ui 0.2.0 → 0.4.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.
Files changed (217) hide show
  1. package/CHANGELOG.md +153 -91
  2. package/LICENSE +201 -201
  3. package/NOTICE +28 -28
  4. package/README.md +86 -86
  5. package/cli/engine.mjs +282 -282
  6. package/cli/index.mjs +154 -154
  7. package/dist/badge.js +1 -1
  8. package/dist/bar-chart.d.ts +1 -1
  9. package/dist/bar-chart.js +1 -1
  10. package/dist/button.d.ts +1 -1
  11. package/dist/button.js +4 -4
  12. package/dist/callout-bubble.d.ts +1 -1
  13. package/dist/callout-bubble.js +4 -4
  14. package/dist/card.d.ts +52 -0
  15. package/dist/card.js +179 -0
  16. package/dist/checkbox.js +5 -5
  17. package/dist/{chunk-B5ZSRUDQ.js → chunk-BWSOMG3G.js} +2 -2
  18. package/dist/{chunk-G7IQLY3A.js → chunk-C3PXY2SW.js} +5 -0
  19. package/dist/{chunk-CC3DDNFC.js → chunk-DXDCKZ2M.js} +4 -4
  20. package/dist/chunk-GUIYFQ27.js +30 -0
  21. package/dist/{chunk-WGULXRWD.js → chunk-KUWTI2PE.js} +4 -4
  22. package/dist/{chunk-Z5PINFQO.js → chunk-QGWAN3EP.js} +5 -5
  23. package/dist/{chunk-V2Q4MRMS.js → chunk-RH53NQGE.js} +30 -4
  24. package/dist/{chunk-WBGSYCV2.js → chunk-SKFAYTDK.js} +4 -4
  25. package/dist/{chunk-MJ4RUGX7.js → chunk-TGJNHUYV.js} +3 -3
  26. package/dist/{chunk-WXH3EFV5.js → chunk-VC7SVSDK.js} +4 -4
  27. package/dist/{chunk-7VMN7NKJ.js → chunk-YT2BSP7O.js} +3 -3
  28. package/dist/collapsible.d.ts +1 -1
  29. package/dist/collapsible.js +3 -3
  30. package/dist/color-picker.js +5 -5
  31. package/dist/context-menu.js +5 -5
  32. package/dist/data-table.d.ts +1 -1
  33. package/dist/data-table.js +1 -1
  34. package/dist/date-picker.d.ts +1 -1
  35. package/dist/date-picker.js +2 -2
  36. package/dist/dialog.d.ts +9 -1
  37. package/dist/dialog.js +15 -5
  38. package/dist/donut.d.ts +1 -1
  39. package/dist/donut.js +1 -1
  40. package/dist/drawer.d.ts +1 -1
  41. package/dist/drawer.js +2 -2
  42. package/dist/dropdown-menu.d.ts +1 -1
  43. package/dist/dropdown-menu.js +5 -5
  44. package/dist/empty.d.ts +1 -1
  45. package/dist/empty.js +2 -2
  46. package/dist/field.js +13 -13
  47. package/dist/{stat.d.ts → figure.d.ts} +9 -9
  48. package/dist/figure.js +41 -0
  49. package/dist/glyph-select.js +5 -5
  50. package/dist/hover-card.d.ts +1 -1
  51. package/dist/hover-card.js +3 -3
  52. package/dist/icons.js +1 -1
  53. package/dist/index.d.ts +4 -2
  54. package/dist/index.js +3 -3
  55. package/dist/input-group.d.ts +1 -1
  56. package/dist/input-group.js +4 -4
  57. package/dist/input.js +2 -2
  58. package/dist/item.d.ts +1 -1
  59. package/dist/item.js +2 -2
  60. package/dist/kbd.d.ts +1 -1
  61. package/dist/kbd.js +2 -2
  62. package/dist/line-chart.d.ts +1 -1
  63. package/dist/line-chart.js +1 -1
  64. package/dist/manifest.json +691 -74
  65. package/dist/month-grid.js +1 -1
  66. package/dist/number-input.d.ts +1 -1
  67. package/dist/number-input.js +5 -5
  68. package/dist/popover.js +3 -3
  69. package/dist/scatter-chart.d.ts +1 -1
  70. package/dist/scatter-chart.js +1 -1
  71. package/dist/select.d.ts +1 -1
  72. package/dist/select.js +7 -7
  73. package/dist/slider.d.ts +1 -1
  74. package/dist/slider.js +2 -2
  75. package/dist/sort-button.js +4 -4
  76. package/dist/sparkline.d.ts +1 -1
  77. package/dist/sparkline.js +1 -1
  78. package/dist/switch.d.ts +1 -1
  79. package/dist/switch.js +3 -3
  80. package/dist/tabs.d.ts +1 -1
  81. package/dist/tabs.js +4 -4
  82. package/dist/text-area.d.ts +1 -1
  83. package/dist/text-area.js +2 -2
  84. package/dist/theme-TefB8vtl.d.ts +341 -0
  85. package/dist/theme.d.ts +42 -192
  86. package/dist/theme.js +1 -1
  87. package/dist/theme.schema.json +321 -30
  88. package/dist/toast.d.ts +49 -0
  89. package/dist/toast.js +463 -0
  90. package/dist/toggle-group.d.ts +1 -1
  91. package/dist/toggle-group.js +4 -4
  92. package/dist/tooltip.js +2 -2
  93. package/dist/treemap.d.ts +80 -0
  94. package/dist/treemap.js +470 -0
  95. package/dist/zag.d.ts +11 -2
  96. package/dist/zag.js +1 -1
  97. package/docs/theming.md +217 -217
  98. package/docs/what-to-change.md +20 -20
  99. package/docs/writing-a-component.md +250 -250
  100. package/llms.txt +6 -3
  101. package/package.json +90 -90
  102. package/registry/badge.ts +119 -119
  103. package/registry/bar-chart.ts +215 -215
  104. package/registry/button.ts +387 -379
  105. package/registry/callout-bubble.ts +347 -347
  106. package/registry/card.ts +379 -0
  107. package/registry/checkbox.ts +234 -234
  108. package/registry/collapsible.ts +271 -271
  109. package/registry/color-picker.ts +582 -582
  110. package/registry/context-menu.ts +208 -208
  111. package/registry/data-table.ts +215 -215
  112. package/registry/date-picker.ts +483 -483
  113. package/registry/dialog.ts +551 -535
  114. package/registry/donut.ts +145 -145
  115. package/registry/drawer.ts +636 -636
  116. package/registry/dropdown-menu.ts +762 -762
  117. package/registry/empty.ts +91 -91
  118. package/registry/field.ts +584 -584
  119. package/registry/{stat.ts → figure.ts} +96 -96
  120. package/registry/glyph-select.ts +268 -268
  121. package/registry/hover-card.ts +222 -222
  122. package/registry/input-group.ts +229 -229
  123. package/registry/input.ts +181 -181
  124. package/registry/item.ts +376 -376
  125. package/registry/kbd.ts +64 -64
  126. package/registry/line-chart.ts +218 -218
  127. package/registry/month-grid.ts +328 -328
  128. package/registry/number-input.ts +443 -443
  129. package/registry/popover.ts +368 -368
  130. package/registry/scatter-chart.ts +221 -221
  131. package/registry/select.ts +620 -620
  132. package/registry/slider.ts +259 -259
  133. package/registry/sort-button.ts +189 -189
  134. package/registry/sparkline.ts +114 -114
  135. package/registry/switch.ts +205 -205
  136. package/registry/tabs.ts +426 -426
  137. package/registry/text-area.ts +186 -186
  138. package/registry/toast.ts +965 -0
  139. package/registry/toggle-group.ts +295 -295
  140. package/registry/tooltip.ts +156 -156
  141. package/registry/treemap.ts +847 -0
  142. package/skills/theming-vela-ui/SKILL.md +137 -137
  143. package/skills/using-vela-ui-components/SKILL.md +139 -137
  144. package/skills/writing-vela-ui-components/SKILL.md +163 -163
  145. package/src/components/badge.ts +119 -119
  146. package/src/components/bar-chart.ts +215 -215
  147. package/src/components/button.ts +387 -379
  148. package/src/components/callout-bubble.ts +347 -347
  149. package/src/components/card.ts +379 -0
  150. package/src/components/checkbox.ts +234 -234
  151. package/src/components/collapsible.ts +271 -271
  152. package/src/components/color-picker.ts +582 -582
  153. package/src/components/context-menu.ts +208 -208
  154. package/src/components/data-table.ts +215 -215
  155. package/src/components/date-picker.ts +483 -483
  156. package/src/components/dialog.ts +551 -535
  157. package/src/components/donut.ts +145 -145
  158. package/src/components/drawer.ts +636 -636
  159. package/src/components/dropdown-menu.ts +762 -762
  160. package/src/components/empty.ts +91 -91
  161. package/src/components/field.ts +584 -584
  162. package/src/components/{stat.ts → figure.ts} +96 -96
  163. package/src/components/glyph-select.ts +268 -268
  164. package/src/components/hover-card.ts +222 -222
  165. package/src/components/input-group.ts +229 -229
  166. package/src/components/input.ts +181 -181
  167. package/src/components/item.ts +376 -376
  168. package/src/components/kbd.ts +64 -64
  169. package/src/components/line-chart.ts +218 -218
  170. package/src/components/month-grid.ts +328 -328
  171. package/src/components/number-input.ts +443 -443
  172. package/src/components/popover.ts +368 -368
  173. package/src/components/scatter-chart.ts +221 -221
  174. package/src/components/select.ts +620 -620
  175. package/src/components/slider.ts +259 -259
  176. package/src/components/sort-button.ts +189 -189
  177. package/src/components/sparkline.ts +114 -114
  178. package/src/components/switch.ts +205 -205
  179. package/src/components/tabs.ts +426 -426
  180. package/src/components/text-area.ts +186 -186
  181. package/src/components/toast.ts +965 -0
  182. package/src/components/toggle-group.ts +295 -295
  183. package/src/components/tooltip.ts +156 -156
  184. package/src/components/treemap.ts +847 -0
  185. package/src/index.ts +24 -24
  186. package/src/lib/calendar.ts +117 -117
  187. package/src/lib/chart.ts +72 -72
  188. package/src/lib/color.ts +89 -89
  189. package/src/lib/component-index.ts +163 -151
  190. package/src/lib/css.ts +48 -48
  191. package/src/lib/define.ts +45 -45
  192. package/src/lib/dispose.ts +36 -36
  193. package/src/lib/h.ts +55 -55
  194. package/src/lib/headless.ts +16 -16
  195. package/src/lib/i18n.ts +30 -30
  196. package/src/lib/icons.ts +244 -237
  197. package/src/lib/kit-text.ts +26 -26
  198. package/src/lib/page.ts +24 -24
  199. package/src/lib/palette.ts +81 -81
  200. package/src/lib/placement.ts +188 -188
  201. package/src/lib/scope.ts +135 -135
  202. package/src/lib/styles.ts +53 -53
  203. package/src/lib/surface-events.ts +31 -31
  204. package/src/lib/surface-exit.ts +87 -87
  205. package/src/lib/t.ts +68 -68
  206. package/src/lib/theme.ts +684 -664
  207. package/src/lib/tokens.ts +110 -110
  208. package/src/lib/variants.ts +32 -32
  209. package/src/lib/zag.ts +61 -46
  210. package/stylelint/index.mjs +60 -60
  211. package/stylelint/lint.mjs +81 -81
  212. package/stylelint/plugin.mjs +115 -115
  213. package/dist/chunk-P4MTEMT7.js +0 -23
  214. package/dist/stat.js +0 -41
  215. package/dist/{chunk-U3EH42YY.js → chunk-5BJV5FY5.js} +1 -1
  216. package/dist/{chunk-E2FE6V2N.js → chunk-ALAHGSLC.js} +1 -1
  217. package/dist/{chunk-C3ICYMI3.js → chunk-FYVQO5TN.js} +1 -1
@@ -1,151 +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
- checkbox: {
24
- parts: ['root', 'icon'],
25
- settings: ['radius'],
26
- },
27
- collapsible: {
28
- parts: ['root', 'trigger', 'icon', 'title', 'count', 'chevron', 'content'],
29
- settings: ['trigger-height', 'radius'],
30
- },
31
- 'color-picker': {
32
- parts: ['root', 'trigger', 'swatch', 'content'],
33
- settings: ['swatch-ring', 'circle-swatch-radius', 'content-radius'],
34
- },
35
- 'data-table': {
36
- parts: ['root', 'table', 'head', 'sort', 'row', 'cell', 'actions', 'empty'],
37
- settings: ['row-height', 'head-height', 'head-z'],
38
- },
39
- 'date-picker': {
40
- parts: ['root', 'head', 'title', 'switch', 'nav', 'week', 'grid', 'cells', 'blank', 'day', 'cell'],
41
- settings: ['radius', 'today-ring'],
42
- },
43
- dialog: {
44
- parts: ['backdrop', 'positioner', 'content', 'header', 'title', 'close', 'body', 'footer'],
45
- settings: ['radius'],
46
- },
47
- donut: {
48
- parts: ['root', 'ring', 'track', 'segment', 'figure', 'caption', 'legend', 'item', 'swatch', 'label', 'value'],
49
- settings: ['swatch-radius'],
50
- },
51
- drawer: {
52
- parts: ['backdrop', 'positioner', 'content', 'grab', 'title', 'body'],
53
- settings: ['radius', 'edge-radius', 'side-width', 'grab-radius'],
54
- },
55
- 'dropdown-menu': {
56
- parts: ['content', 'item', 'icon', 'label', 'hint', 'mark', 'badge', 'star', 'switch', 'arrow', 'separator'],
57
- settings: ['radius', 'switch-radius'],
58
- },
59
- empty: {
60
- parts: ['root', 'icon', 'title', 'description'],
61
- settings: ['icon-radius'],
62
- },
63
- field: {
64
- parts: ['grid', 'row', 'span', 'label', 'cell', 'bool', 'stacked', 'stacked-head', 'inline', 'inline-item', 'toggle-label', 'section', 'sep'],
65
- settings: [],
66
- },
67
- 'glyph-select': {
68
- parts: ['root', 'value', 'icon', 'content', 'item'],
69
- settings: ['radius', 'content-radius', 'focus-ring'],
70
- },
71
- 'hover-card': {
72
- parts: ['root', 'heading', 'icon', 'title', 'description', 'body', 'hint'],
73
- settings: ['radius', 'width', 'wide-width', 'icon-radius', 'shadow'],
74
- },
75
- input: {
76
- parts: ['root', 'control'],
77
- settings: ['radius', 'focus-ring'],
78
- },
79
- 'input-group': {
80
- parts: ['root', 'control', 'addon', 'text'],
81
- settings: ['radius', 'height', 'height-sm', 'focus-ring'],
82
- },
83
- item: {
84
- parts: ['root', 'media', 'content', 'title', 'description', 'meta', 'actions', 'group'],
85
- settings: ['radius', 'gap'],
86
- },
87
- kbd: {
88
- parts: ['root'],
89
- settings: ['radius', 'shadow'],
90
- },
91
- 'line-chart': {
92
- parts: ['root', 'label', 'area', 'line', 'dot', 'tip'],
93
- settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg', 'stroke-width'],
94
- },
95
- 'month-grid': {
96
- parts: ['root', 'weekday', 'day', 'date', 'value', 'detail', 'blank'],
97
- settings: ['radius', 'day-height', 'gap', 'selected-ring'],
98
- },
99
- 'number-input': {
100
- parts: ['root', 'input', 'steps', 'step'],
101
- settings: ['radius', 'step-radius', 'focus-ring'],
102
- },
103
- popover: {
104
- parts: ['content'],
105
- settings: [],
106
- },
107
- 'scatter-chart': {
108
- parts: ['root', 'grid', 'label', 'point', 'trend', 'focus', 'tip'],
109
- settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
110
- },
111
- select: {
112
- parts: ['root', 'trigger', 'value', 'icon', 'sizer', 'native', 'content', 'viewport', 'item', 'rail', 'thumb'],
113
- settings: ['radius', 'content-radius', 'thumb-radius', 'focus-ring'],
114
- },
115
- slider: {
116
- parts: ['root', 'control', 'track', 'range', 'thumb'],
117
- settings: ['track-height', 'thumb-size', 'radius', 'focus-ring'],
118
- },
119
- 'sort-button': {
120
- parts: ['root', 'icon', 'state'],
121
- settings: ['radius'],
122
- },
123
- sparkline: {
124
- parts: ['root', 'area', 'baseline', 'line'],
125
- settings: ['stroke-width'],
126
- },
127
- stat: {
128
- parts: ['root', 'label', 'value', 'sub'],
129
- settings: [],
130
- },
131
- switch: {
132
- parts: ['root', 'control', 'thumb'],
133
- settings: ['width', 'height', 'thumb-size', 'width-sm', 'height-sm', 'thumb-size-sm'],
134
- },
135
- tabs: {
136
- parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
137
- settings: ['track-radius', 'trigger-radius', 'filled-radius', 'soft-radius', 'count-radius'],
138
- },
139
- 'text-area': {
140
- parts: ['root', 'input'],
141
- settings: ['radius', 'focus-ring'],
142
- },
143
- 'toggle-group': {
144
- parts: ['root', 'item', 'icon'],
145
- settings: ['radius', 'radius-sm', 'item-radius', 'item-radius-sm'],
146
- },
147
- tooltip: {
148
- parts: ['positioner', 'content'],
149
- settings: ['radius'],
150
- },
151
- };
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
+ }
@@ -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
+ }