@luxalgo/vela-ui 0.3.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 (167) hide show
  1. package/CHANGELOG.md +153 -132
  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/callout-bubble.js +2 -2
  8. package/dist/checkbox.js +2 -2
  9. package/dist/{chunk-KKS6NEGI.js → chunk-BWSOMG3G.js} +1 -1
  10. package/dist/chunk-GUIYFQ27.js +30 -0
  11. package/dist/{chunk-B2EZB5ZG.js → chunk-KUWTI2PE.js} +2 -2
  12. package/dist/{chunk-WWHNUKSZ.js → chunk-QGWAN3EP.js} +2 -2
  13. package/dist/{chunk-TBXUF5YX.js → chunk-RH53NQGE.js} +18 -4
  14. package/dist/{chunk-IOOYDSSK.js → chunk-SKFAYTDK.js} +1 -1
  15. package/dist/{chunk-OQXFQMZM.js → chunk-TGJNHUYV.js} +2 -2
  16. package/dist/{chunk-UEO6W37Z.js → chunk-VC7SVSDK.js} +1 -1
  17. package/dist/{chunk-OJ2SEMN6.js → chunk-YT2BSP7O.js} +1 -1
  18. package/dist/collapsible.js +1 -1
  19. package/dist/color-picker.js +4 -4
  20. package/dist/context-menu.js +3 -3
  21. package/dist/dialog.js +3 -3
  22. package/dist/donut.d.ts +1 -1
  23. package/dist/drawer.js +1 -1
  24. package/dist/dropdown-menu.js +3 -3
  25. package/dist/field.js +8 -8
  26. package/dist/{stat.d.ts → figure.d.ts} +9 -9
  27. package/dist/figure.js +41 -0
  28. package/dist/glyph-select.js +3 -3
  29. package/dist/index.d.ts +2 -2
  30. package/dist/index.js +1 -1
  31. package/dist/manifest.json +74 -74
  32. package/dist/number-input.js +2 -2
  33. package/dist/popover.js +2 -2
  34. package/dist/select.d.ts +1 -1
  35. package/dist/select.js +4 -4
  36. package/dist/slider.js +1 -1
  37. package/dist/sort-button.js +1 -1
  38. package/dist/switch.js +1 -1
  39. package/dist/tabs.js +1 -1
  40. package/dist/{theme-Ct-q58xz.d.ts → theme-TefB8vtl.d.ts} +2 -2
  41. package/dist/theme.d.ts +2 -2
  42. package/dist/theme.js +1 -1
  43. package/dist/theme.schema.json +30 -30
  44. package/dist/toast.d.ts +2 -2
  45. package/dist/toast.js +1 -1
  46. package/dist/toggle-group.js +1 -1
  47. package/dist/tooltip.js +1 -1
  48. package/dist/zag.d.ts +11 -2
  49. package/dist/zag.js +1 -1
  50. package/docs/theming.md +217 -217
  51. package/docs/what-to-change.md +20 -20
  52. package/docs/writing-a-component.md +250 -250
  53. package/llms.txt +3 -3
  54. package/package.json +90 -90
  55. package/registry/badge.ts +119 -119
  56. package/registry/bar-chart.ts +215 -215
  57. package/registry/button.ts +387 -387
  58. package/registry/callout-bubble.ts +347 -347
  59. package/registry/card.ts +379 -379
  60. package/registry/checkbox.ts +234 -234
  61. package/registry/collapsible.ts +271 -271
  62. package/registry/color-picker.ts +582 -582
  63. package/registry/context-menu.ts +208 -208
  64. package/registry/data-table.ts +215 -215
  65. package/registry/date-picker.ts +483 -483
  66. package/registry/dialog.ts +551 -551
  67. package/registry/donut.ts +145 -145
  68. package/registry/drawer.ts +636 -636
  69. package/registry/dropdown-menu.ts +762 -762
  70. package/registry/empty.ts +91 -91
  71. package/registry/field.ts +584 -584
  72. package/registry/{stat.ts → figure.ts} +96 -96
  73. package/registry/glyph-select.ts +268 -268
  74. package/registry/hover-card.ts +222 -222
  75. package/registry/input-group.ts +229 -229
  76. package/registry/input.ts +181 -181
  77. package/registry/item.ts +376 -376
  78. package/registry/kbd.ts +64 -64
  79. package/registry/line-chart.ts +218 -218
  80. package/registry/month-grid.ts +328 -328
  81. package/registry/number-input.ts +443 -443
  82. package/registry/popover.ts +368 -368
  83. package/registry/scatter-chart.ts +221 -221
  84. package/registry/select.ts +620 -620
  85. package/registry/slider.ts +259 -259
  86. package/registry/sort-button.ts +189 -189
  87. package/registry/sparkline.ts +114 -114
  88. package/registry/switch.ts +205 -205
  89. package/registry/tabs.ts +426 -426
  90. package/registry/text-area.ts +186 -186
  91. package/registry/toast.ts +965 -965
  92. package/registry/toggle-group.ts +295 -295
  93. package/registry/tooltip.ts +156 -156
  94. package/registry/treemap.ts +847 -847
  95. package/skills/theming-vela-ui/SKILL.md +137 -137
  96. package/skills/using-vela-ui-components/SKILL.md +139 -139
  97. package/skills/writing-vela-ui-components/SKILL.md +163 -163
  98. package/src/components/badge.ts +119 -119
  99. package/src/components/bar-chart.ts +215 -215
  100. package/src/components/button.ts +387 -387
  101. package/src/components/callout-bubble.ts +347 -347
  102. package/src/components/card.ts +379 -379
  103. package/src/components/checkbox.ts +234 -234
  104. package/src/components/collapsible.ts +271 -271
  105. package/src/components/color-picker.ts +582 -582
  106. package/src/components/context-menu.ts +208 -208
  107. package/src/components/data-table.ts +215 -215
  108. package/src/components/date-picker.ts +483 -483
  109. package/src/components/dialog.ts +551 -551
  110. package/src/components/donut.ts +145 -145
  111. package/src/components/drawer.ts +636 -636
  112. package/src/components/dropdown-menu.ts +762 -762
  113. package/src/components/empty.ts +91 -91
  114. package/src/components/field.ts +584 -584
  115. package/src/components/{stat.ts → figure.ts} +96 -96
  116. package/src/components/glyph-select.ts +268 -268
  117. package/src/components/hover-card.ts +222 -222
  118. package/src/components/input-group.ts +229 -229
  119. package/src/components/input.ts +181 -181
  120. package/src/components/item.ts +376 -376
  121. package/src/components/kbd.ts +64 -64
  122. package/src/components/line-chart.ts +218 -218
  123. package/src/components/month-grid.ts +328 -328
  124. package/src/components/number-input.ts +443 -443
  125. package/src/components/popover.ts +368 -368
  126. package/src/components/scatter-chart.ts +221 -221
  127. package/src/components/select.ts +620 -620
  128. package/src/components/slider.ts +259 -259
  129. package/src/components/sort-button.ts +189 -189
  130. package/src/components/sparkline.ts +114 -114
  131. package/src/components/switch.ts +205 -205
  132. package/src/components/tabs.ts +426 -426
  133. package/src/components/text-area.ts +186 -186
  134. package/src/components/toast.ts +965 -965
  135. package/src/components/toggle-group.ts +295 -295
  136. package/src/components/tooltip.ts +156 -156
  137. package/src/components/treemap.ts +847 -847
  138. package/src/index.ts +24 -24
  139. package/src/lib/calendar.ts +117 -117
  140. package/src/lib/chart.ts +72 -72
  141. package/src/lib/color.ts +89 -89
  142. package/src/lib/component-index.ts +163 -163
  143. package/src/lib/css.ts +48 -48
  144. package/src/lib/define.ts +45 -45
  145. package/src/lib/dispose.ts +36 -36
  146. package/src/lib/h.ts +55 -55
  147. package/src/lib/headless.ts +16 -16
  148. package/src/lib/i18n.ts +30 -30
  149. package/src/lib/icons.ts +244 -244
  150. package/src/lib/kit-text.ts +26 -26
  151. package/src/lib/page.ts +24 -24
  152. package/src/lib/palette.ts +81 -81
  153. package/src/lib/placement.ts +188 -188
  154. package/src/lib/scope.ts +135 -135
  155. package/src/lib/styles.ts +53 -53
  156. package/src/lib/surface-events.ts +31 -31
  157. package/src/lib/surface-exit.ts +87 -87
  158. package/src/lib/t.ts +68 -68
  159. package/src/lib/theme.ts +684 -670
  160. package/src/lib/tokens.ts +110 -110
  161. package/src/lib/variants.ts +32 -32
  162. package/src/lib/zag.ts +61 -46
  163. package/stylelint/index.mjs +60 -60
  164. package/stylelint/lint.mjs +81 -81
  165. package/stylelint/plugin.mjs +115 -115
  166. package/dist/chunk-P4MTEMT7.js +0 -23
  167. 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
- 'glyph-select': {
72
- parts: ['root', 'value', 'icon', 'content', 'item'],
73
- settings: ['radius', 'content-radius', 'focus-ring'],
74
- },
75
- 'hover-card': {
76
- parts: ['root', 'heading', 'icon', 'title', 'description', 'body', 'hint'],
77
- settings: ['radius', 'width', 'wide-width', 'icon-radius', 'shadow'],
78
- },
79
- input: {
80
- parts: ['root', 'control'],
81
- settings: ['radius', 'focus-ring'],
82
- },
83
- 'input-group': {
84
- parts: ['root', 'control', 'addon', 'text'],
85
- settings: ['radius', 'height', 'height-sm', 'focus-ring'],
86
- },
87
- item: {
88
- parts: ['root', 'media', 'content', 'title', 'description', 'meta', 'actions', 'group'],
89
- settings: ['radius', 'gap'],
90
- },
91
- kbd: {
92
- parts: ['root'],
93
- settings: ['radius', 'shadow'],
94
- },
95
- 'line-chart': {
96
- parts: ['root', 'label', 'area', 'line', 'dot', 'tip'],
97
- settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg', 'stroke-width'],
98
- },
99
- 'month-grid': {
100
- parts: ['root', 'weekday', 'day', 'date', 'value', 'detail', 'blank'],
101
- settings: ['radius', 'day-height', 'gap', 'selected-ring'],
102
- },
103
- 'number-input': {
104
- parts: ['root', 'input', 'steps', 'step'],
105
- settings: ['radius', 'step-radius', 'focus-ring'],
106
- },
107
- popover: {
108
- parts: ['content'],
109
- settings: [],
110
- },
111
- 'scatter-chart': {
112
- parts: ['root', 'grid', 'label', 'point', 'trend', 'focus', 'tip'],
113
- settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
114
- },
115
- select: {
116
- parts: ['root', 'trigger', 'value', 'icon', 'sizer', 'native', 'content', 'viewport', 'item', 'rail', 'thumb'],
117
- settings: ['radius', 'content-radius', 'thumb-radius', 'focus-ring'],
118
- },
119
- slider: {
120
- parts: ['root', 'control', 'track', 'range', 'thumb'],
121
- settings: ['track-height', 'thumb-size', 'radius', 'focus-ring'],
122
- },
123
- 'sort-button': {
124
- parts: ['root', 'icon', 'state'],
125
- settings: ['radius'],
126
- },
127
- sparkline: {
128
- parts: ['root', 'area', 'baseline', 'line'],
129
- settings: ['stroke-width'],
130
- },
131
- stat: {
132
- parts: ['root', 'label', 'value', 'sub'],
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
+ }
@@ -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
+ }