@luxalgo/vela-ui 0.1.0 → 0.3.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 (124) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +5 -2
  3. package/dist/badge.js +1 -1
  4. package/dist/bar-chart.js +1 -1
  5. package/dist/button.d.ts +18 -4
  6. package/dist/button.js +4 -3
  7. package/dist/calendar.d.ts +3 -1
  8. package/dist/calendar.js +1 -1
  9. package/dist/callout-bubble.d.ts +6 -1
  10. package/dist/callout-bubble.js +12 -8
  11. package/dist/card.d.ts +52 -0
  12. package/dist/card.js +179 -0
  13. package/dist/checkbox.js +5 -5
  14. package/dist/{chunk-X4YPSIW6.js → chunk-5BJV5FY5.js} +1 -1
  15. package/dist/{chunk-FCO3YZLT.js → chunk-ALAHGSLC.js} +1 -1
  16. package/dist/{chunk-5QHXOAZA.js → chunk-B2EZB5ZG.js} +4 -4
  17. package/dist/{chunk-G7IQLY3A.js → chunk-C3PXY2SW.js} +5 -0
  18. package/dist/chunk-DXDCKZ2M.js +117 -0
  19. package/dist/{chunk-6NXY62JS.js → chunk-FYVQO5TN.js} +1 -1
  20. package/dist/{chunk-V6TTTMTE.js → chunk-GVRX3UAV.js} +4 -1
  21. package/dist/{chunk-XJAPCCOJ.js → chunk-IOOYDSSK.js} +4 -4
  22. package/dist/{chunk-OBLIX3VN.js → chunk-KKS6NEGI.js} +2 -2
  23. package/dist/{chunk-SAPURP46.js → chunk-OJ2SEMN6.js} +3 -3
  24. package/dist/{chunk-2Q4JRINP.js → chunk-OQXFQMZM.js} +3 -3
  25. package/dist/{chunk-AJ2IYSOI.js → chunk-TBXUF5YX.js} +35 -3
  26. package/dist/{chunk-ZB3BZHSN.js → chunk-UEO6W37Z.js} +4 -4
  27. package/dist/{chunk-CH3DV6FD.js → chunk-WWHNUKSZ.js} +5 -5
  28. package/dist/chunk-XBEL4K33.js +142 -0
  29. package/dist/collapsible.d.ts +49 -0
  30. package/dist/collapsible.js +106 -0
  31. package/dist/color-picker.js +5 -5
  32. package/dist/context-menu.js +5 -5
  33. package/dist/css.d.ts +3 -1
  34. package/dist/css.js +1 -1
  35. package/dist/data-table.d.ts +39 -2
  36. package/dist/data-table.js +1 -1
  37. package/dist/date-picker.js +3 -3
  38. package/dist/dialog.d.ts +8 -0
  39. package/dist/dialog.js +15 -5
  40. package/dist/donut.js +1 -1
  41. package/dist/drawer.js +2 -2
  42. package/dist/dropdown-menu.js +4 -4
  43. package/dist/empty.js +2 -2
  44. package/dist/field.js +13 -13
  45. package/dist/glyph-select.js +5 -5
  46. package/dist/h-Bl37qUis.d.ts +24 -0
  47. package/dist/hover-card.d.ts +1 -1
  48. package/dist/hover-card.js +3 -3
  49. package/dist/icons.js +1 -1
  50. package/dist/index.d.ts +10 -2
  51. package/dist/index.js +3 -3
  52. package/dist/input-group.js +4 -3
  53. package/dist/input.js +2 -2
  54. package/dist/item.d.ts +72 -0
  55. package/dist/item.js +131 -0
  56. package/dist/kbd.js +2 -2
  57. package/dist/line-chart.js +1 -1
  58. package/dist/manifest.json +1336 -65
  59. package/dist/month-grid.d.ts +45 -0
  60. package/dist/month-grid.js +157 -0
  61. package/dist/number-input.js +5 -5
  62. package/dist/popover.js +3 -3
  63. package/dist/scatter-chart.js +1 -1
  64. package/dist/select.js +7 -7
  65. package/dist/slider.d.ts +46 -0
  66. package/dist/slider.js +111 -0
  67. package/dist/sort-button.d.ts +41 -0
  68. package/dist/sort-button.js +88 -0
  69. package/dist/sparkline.js +1 -1
  70. package/dist/stat.js +1 -1
  71. package/dist/switch.js +3 -3
  72. package/dist/tabs.d.ts +3 -1
  73. package/dist/tabs.js +13 -8
  74. package/dist/text-area.js +2 -2
  75. package/dist/theme-Ct-q58xz.d.ts +341 -0
  76. package/dist/theme.d.ts +42 -181
  77. package/dist/theme.js +2 -2
  78. package/dist/theme.schema.json +541 -1
  79. package/dist/toast.d.ts +49 -0
  80. package/dist/toast.js +463 -0
  81. package/dist/toggle-group.js +4 -4
  82. package/dist/tooltip.js +2 -2
  83. package/dist/treemap.d.ts +80 -0
  84. package/dist/treemap.js +470 -0
  85. package/docs/theming.md +6 -0
  86. package/docs/writing-a-component.md +4 -1
  87. package/llms.txt +11 -3
  88. package/package.json +1 -1
  89. package/registry/button.ts +105 -21
  90. package/registry/callout-bubble.ts +14 -3
  91. package/registry/card.ts +379 -0
  92. package/registry/collapsible.ts +271 -0
  93. package/registry/dialog.ts +16 -0
  94. package/registry/dropdown-menu.ts +3 -3
  95. package/registry/item.ts +376 -0
  96. package/registry/month-grid.ts +328 -0
  97. package/registry/slider.ts +259 -0
  98. package/registry/sort-button.ts +189 -0
  99. package/registry/tabs.ts +38 -4
  100. package/registry/toast.ts +965 -0
  101. package/registry/treemap.ts +847 -0
  102. package/skills/using-vela-ui-components/SKILL.md +14 -9
  103. package/src/components/button.ts +105 -21
  104. package/src/components/callout-bubble.ts +14 -3
  105. package/src/components/card.ts +379 -0
  106. package/src/components/collapsible.ts +271 -0
  107. package/src/components/dialog.ts +16 -0
  108. package/src/components/dropdown-menu.ts +3 -3
  109. package/src/components/item.ts +376 -0
  110. package/src/components/month-grid.ts +328 -0
  111. package/src/components/slider.ts +259 -0
  112. package/src/components/sort-button.ts +189 -0
  113. package/src/components/tabs.ts +38 -4
  114. package/src/components/toast.ts +965 -0
  115. package/src/components/treemap.ts +847 -0
  116. package/src/lib/calendar.ts +5 -0
  117. package/src/lib/component-index.ts +34 -2
  118. package/src/lib/css.ts +6 -2
  119. package/src/lib/icons.ts +7 -0
  120. package/src/lib/scope.ts +135 -0
  121. package/src/lib/theme.ts +21 -5
  122. package/dist/chunk-EZQXTO6K.js +0 -89
  123. package/dist/chunk-IDA2BT7D.js +0 -29
  124. package/dist/data-table-DtU3FX9j.d.ts +0 -61
@@ -83,6 +83,11 @@ export function weekdayNames(settings: CalendarSettings): string[] {
83
83
  return Array.from({ length: 7 }, (_, d) => stripBidiMarks(dtf.format(Date.UTC(2000, 0, 2 + d))));
84
84
  }
85
85
 
86
+ /** A day in words, for a screen reader (`Friday, November 6, 2026`). `month` counts from 0. */
87
+ export function longDate(settings: CalendarSettings, year: number, month: number, day: number): string {
88
+ return stripBidiMarks(dateFormat(settings, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(Date.UTC(year, month, day)));
89
+ }
90
+
86
91
  /** A year as a header label (`2026`, `2026年`). */
87
92
  export function yearLabel(settings: CalendarSettings, year: number): string {
88
93
  if (settings.english) return localizeDigits(String(year), settings);
@@ -13,17 +13,25 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
13
13
  settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg'],
14
14
  },
15
15
  button: {
16
- parts: ['root', 'icon'],
16
+ parts: ['root', 'icon', 'keys'],
17
17
  settings: ['radius', 'height', 'height-xs', 'height-sm', 'height-lg', 'font-size', 'font-size-xs', 'font-size-sm'],
18
18
  },
19
19
  'callout-bubble': {
20
20
  parts: ['root', 'panel', 'title', 'text', 'actions', 'button'],
21
21
  settings: ['panel-radius', 'button-radius'],
22
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
+ },
23
27
  checkbox: {
24
28
  parts: ['root', 'icon'],
25
29
  settings: ['radius'],
26
30
  },
31
+ collapsible: {
32
+ parts: ['root', 'trigger', 'icon', 'title', 'count', 'chevron', 'content'],
33
+ settings: ['trigger-height', 'radius'],
34
+ },
27
35
  'color-picker': {
28
36
  parts: ['root', 'trigger', 'swatch', 'content'],
29
37
  settings: ['swatch-ring', 'circle-swatch-radius', 'content-radius'],
@@ -76,6 +84,10 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
76
84
  parts: ['root', 'control', 'addon', 'text'],
77
85
  settings: ['radius', 'height', 'height-sm', 'focus-ring'],
78
86
  },
87
+ item: {
88
+ parts: ['root', 'media', 'content', 'title', 'description', 'meta', 'actions', 'group'],
89
+ settings: ['radius', 'gap'],
90
+ },
79
91
  kbd: {
80
92
  parts: ['root'],
81
93
  settings: ['radius', 'shadow'],
@@ -84,6 +96,10 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
84
96
  parts: ['root', 'label', 'area', 'line', 'dot', 'tip'],
85
97
  settings: ['tip-radius', 'tip-shadow', 'tip-z', 'tip-bg', 'stroke-width'],
86
98
  },
99
+ 'month-grid': {
100
+ parts: ['root', 'weekday', 'day', 'date', 'value', 'detail', 'blank'],
101
+ settings: ['radius', 'day-height', 'gap', 'selected-ring'],
102
+ },
87
103
  'number-input': {
88
104
  parts: ['root', 'input', 'steps', 'step'],
89
105
  settings: ['radius', 'step-radius', 'focus-ring'],
@@ -100,6 +116,14 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
100
116
  parts: ['root', 'trigger', 'value', 'icon', 'sizer', 'native', 'content', 'viewport', 'item', 'rail', 'thumb'],
101
117
  settings: ['radius', 'content-radius', 'thumb-radius', 'focus-ring'],
102
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
+ },
103
127
  sparkline: {
104
128
  parts: ['root', 'area', 'baseline', 'line'],
105
129
  settings: ['stroke-width'],
@@ -113,13 +137,17 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
113
137
  settings: ['width', 'height', 'thumb-size', 'width-sm', 'height-sm', 'thumb-size-sm'],
114
138
  },
115
139
  tabs: {
116
- parts: ['list', 'trigger', 'icon', 'count', 'content'],
140
+ parts: ['list', 'trigger', 'icon', 'count', 'label', 'description', 'content'],
117
141
  settings: ['track-radius', 'trigger-radius', 'filled-radius', 'soft-radius', 'count-radius'],
118
142
  },
119
143
  'text-area': {
120
144
  parts: ['root', 'input'],
121
145
  settings: ['radius', 'focus-ring'],
122
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
+ },
123
151
  'toggle-group': {
124
152
  parts: ['root', 'item', 'icon'],
125
153
  settings: ['radius', 'radius-sm', 'item-radius', 'item-radius-sm'],
@@ -128,4 +156,8 @@ export const KIT_COMPONENTS: Readonly<Record<string, { readonly parts: readonly
128
156
  parts: ['positioner', 'content'],
129
157
  settings: ['radius'],
130
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
+ },
131
163
  };
package/src/lib/css.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Component CSS: written in `css` templates (editors highlight them, stylelint checks them
2
2
  // through the postcss-lit syntax) and injected once per document or shadow root.
3
3
  import { pageState } from './page';
4
+ import { scopeToKit } from './scope';
4
5
  import { injectLayerOrder, injectStyles } from './styles';
5
6
 
6
7
  export { injectLayerOrder, LAYER_ORDER } from './styles';
@@ -30,14 +31,17 @@ export function acceptCss(text: string): void {
30
31
  }
31
32
 
32
33
  /** A component's stylesheet: call the result with the root it renders in, at creation, never
33
- * at import (a component nobody creates injects nothing). */
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. */
34
37
  export function defineStyles(id: string, text: string): (root?: Document | ShadowRoot) => void {
35
38
  // The sheet each root got, so later creations skip the lookup while it stays in place.
36
39
  const injected = new WeakMap<Document | ShadowRoot, Element>();
40
+ let scoped: string | undefined;
37
41
  return (root = document) => {
38
42
  if (injected.get(root)?.isConnected) return;
39
43
  injectLayerOrder(root);
40
- injectStyles(id, text, root);
44
+ injectStyles(id, (scoped ??= scopeToKit(text)), root);
41
45
  const sheet = root.getElementById?.(id) ?? (root instanceof Document ? null : root.querySelector(`#${CSS.escape(id)}`));
42
46
  if (sheet) injected.set(root, sheet);
43
47
  };
package/src/lib/icons.ts CHANGED
@@ -178,6 +178,13 @@ registerIcon('burger', S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
178
178
  registerIcon('info', S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
179
179
  registerIcon('reset', S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
180
180
 
181
+ // ── status glyphs (toasts, notices) ──
182
+ registerIcon('circle-check', S('<circle cx="8" cy="8" r="6.2"/><path d="m5.4 8.2 1.8 1.8 3.4-3.7"/>'));
183
+ registerIcon('circle-info', S('<circle cx="8" cy="8" r="6.2"/><path d="M8 7.4v3.6"/><circle cx="8" cy="5.1" r="0.8" fill="currentColor" stroke="none"/>'));
184
+ registerIcon('triangle-alert', S('<path d="M7.1 2.6a1 1 0 0 1 1.8 0l5.3 9.6a1 1 0 0 1-.9 1.5H2.7a1 1 0 0 1-.9-1.5z"/><path d="M8 6.3v3.2"/><circle cx="8" cy="11.4" r="0.8" fill="currentColor" stroke="none"/>'));
185
+ registerIcon('circle-x', S('<circle cx="8" cy="8" r="6.2"/><path d="m5.9 5.9 4.2 4.2M10.1 5.9l-4.2 4.2"/>'));
186
+ registerIcon('loader', S('<path d="M8 1.8a6.2 6.2 0 1 0 6.2 6.2"/>'));
187
+
181
188
  // ── pane chrome (stack order, collapse, maximize) ──
182
189
  registerIcon('pane-collapse', S('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));
183
190
  registerIcon('pane-expand', S('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));
@@ -0,0 +1,135 @@
1
+ // Component CSS keys on `data-slot`, and a page's own components often carry the same part
2
+ // names (`select-trigger`, `popover-content`, `switch`, `button`). Each rule of a component's
3
+ // stylesheet is kept to where kit components live, so the page's elements never match it.
4
+
5
+ /** Kit hosts (`ensureUIHost`), the floating layers they portal (`vela-ui-layer`) and themed
6
+ * hosts (`applyTheme`), each with everything inside it. `:where()` adds no weight. */
7
+ export const KIT_SCOPE = ':where(.vela-ui, .vela-ui *, .vela-ui-layer, .vela-ui-layer *, [data-vela-theme], [data-vela-theme] *)';
8
+
9
+ // At-rules whose block holds style rules, scoped like the top level. Any other block holds
10
+ // no selectors (`@keyframes` steps, `@font-face` descriptors).
11
+ const GROUPING = /^@(?:layer|media|supports|container|scope|starting-style)\b/i;
12
+ // Pseudo-elements written with one colon: like `::x`, they close a compound.
13
+ const LEGACY_PSEUDO_ELEMENT = /^:(?:before|after|first-line|first-letter)(?![\w-])/i;
14
+ const SPACE = /\s/;
15
+
16
+ /** The index after the string, comment or escape at `i`, or `i` when none starts there. */
17
+ function skipOpaque(text: string, i: number): number {
18
+ const c = text[i];
19
+ if (c === '\\') return i + 2;
20
+ if (c === '"' || c === "'") {
21
+ let j = i + 1;
22
+ while (j < text.length && text[j] !== c) j += text[j] === '\\' ? 2 : 1;
23
+ return j + 1;
24
+ }
25
+ if (c === '/' && text[i + 1] === '*') {
26
+ const end = text.indexOf('*/', i + 2);
27
+ return end < 0 ? text.length : end + 2;
28
+ }
29
+ return i;
30
+ }
31
+
32
+ function withoutComments(text: string): string {
33
+ let out = '';
34
+ for (let i = 0; i < text.length; ) {
35
+ const next = skipOpaque(text, i);
36
+ if (next === i) out += text[i++];
37
+ else {
38
+ if (text[i] !== '/') out += text.slice(i, next);
39
+ i = next;
40
+ }
41
+ }
42
+ return out;
43
+ }
44
+
45
+ /** A selector list's selectors: its commas outside brackets, parentheses and strings. */
46
+ function selectorsOf(list: string): string[] {
47
+ const out: string[] = [];
48
+ let depth = 0;
49
+ let start = 0;
50
+ for (let i = 0; i < list.length; ) {
51
+ const next = skipOpaque(list, i);
52
+ if (next !== i) {
53
+ i = next;
54
+ continue;
55
+ }
56
+ const c = list[i];
57
+ if (c === '(' || c === '[') depth += 1;
58
+ else if (c === ')' || c === ']') depth -= 1;
59
+ else if (c === ',' && depth === 0) {
60
+ out.push(list.slice(start, i).trim());
61
+ start = i + 1;
62
+ }
63
+ i += 1;
64
+ }
65
+ out.push(list.slice(start).trim());
66
+ return out;
67
+ }
68
+
69
+ /** The selector with the scope joined to its first compound, ahead of any pseudo-element. A
70
+ * selector the page drops (empty, or opening on a combinator) stays as it is. */
71
+ function scopeSelector(selector: string): string {
72
+ if (!selector || /^[>+~]/.test(selector)) return selector;
73
+ let depth = 0;
74
+ let i = 0;
75
+ while (i < selector.length) {
76
+ const next = skipOpaque(selector, i);
77
+ if (next !== i) {
78
+ i = next;
79
+ continue;
80
+ }
81
+ const c = selector[i]!;
82
+ if (c === '(' || c === '[') depth += 1;
83
+ else if (c === ')' || c === ']') depth -= 1;
84
+ else if (depth === 0 && (SPACE.test(c) || c === '>' || c === '+' || c === '~')) break;
85
+ else if (depth === 0 && c === ':' && (selector[i + 1] === ':' || LEGACY_PSEUDO_ELEMENT.test(selector.slice(i)))) break;
86
+ i += 1;
87
+ }
88
+ return selector.slice(0, i) + KIT_SCOPE + selector.slice(i);
89
+ }
90
+
91
+ /**
92
+ * A stylesheet whose top-level rules apply only where kit components live: {@link KIT_SCOPE}
93
+ * joins the first compound of each of their selectors, so a rule weighs the same and matches
94
+ * the same elements inside a kit host, and none outside. Rules nested in a rule follow their
95
+ * parent; those in `@layer`, `@media`, `@supports` and `@container` blocks are scoped too.
96
+ */
97
+ export function scopeToKit(text: string): string {
98
+ let out = '';
99
+ let copied = 0;
100
+ let start = 0;
101
+ let scoping = true;
102
+ const outer: boolean[] = [];
103
+ for (let i = 0; i < text.length; ) {
104
+ const next = skipOpaque(text, i);
105
+ if (next !== i) {
106
+ i = next;
107
+ continue;
108
+ }
109
+ const c = text[i];
110
+ if (c === ';') {
111
+ start = i + 1;
112
+ } else if (c === '{') {
113
+ const prelude = text.slice(start, i);
114
+ const head = withoutComments(prelude).trim();
115
+ outer.push(scoping);
116
+ if (head.startsWith('@')) {
117
+ scoping &&= GROUPING.test(head);
118
+ } else {
119
+ if (scoping && head) {
120
+ const lead = /^\s*/.exec(prelude)![0];
121
+ const trail = /\s*$/.exec(prelude)![0];
122
+ out += text.slice(copied, start) + lead + selectorsOf(head).map(scopeSelector).join(', ') + trail;
123
+ copied = i;
124
+ }
125
+ scoping = false;
126
+ }
127
+ start = i + 1;
128
+ } else if (c === '}') {
129
+ scoping = outer.pop() ?? true;
130
+ start = i + 1;
131
+ }
132
+ i += 1;
133
+ }
134
+ return out + text.slice(copied);
135
+ }
package/src/lib/theme.ts CHANGED
@@ -8,6 +8,7 @@ import type { badgeDef } from '../components/badge';
8
8
  import type { barChartDef } from '../components/bar-chart';
9
9
  import type { buttonDef } from '../components/button';
10
10
  import type { calloutBubbleDef } from '../components/callout-bubble';
11
+ import type { cardDef } from '../components/card';
11
12
  import type { colorPickerDef } from '../components/color-picker';
12
13
  import type { dataTableDef } from '../components/data-table';
13
14
  import type { datePickerDef } from '../components/date-picker';
@@ -28,13 +29,20 @@ import type { selectDef } from '../components/select';
28
29
  import type { sparklineDef } from '../components/sparkline';
29
30
  import type { statDef } from '../components/stat';
30
31
  import type { checkboxDef } from '../components/checkbox';
32
+ import type { collapsibleDef } from '../components/collapsible';
31
33
  import type { tabsDef } from '../components/tabs';
32
34
  import type { textAreaDef } from '../components/text-area';
33
35
  import type { inputDef } from '../components/input';
34
36
  import type { inputGroupDef } from '../components/input-group';
37
+ import type { itemDef } from '../components/item';
38
+ import type { monthGridDef } from '../components/month-grid';
39
+ import type { sliderDef } from '../components/slider';
40
+ import type { sortButtonDef } from '../components/sort-button';
35
41
  import type { switchDef } from '../components/switch';
42
+ import type { toastDef } from '../components/toast';
36
43
  import type { toggleGroupDef } from '../components/toggle-group';
37
44
  import type { tooltipDef } from '../components/tooltip';
45
+ import type { treemapDef } from '../components/treemap';
38
46
  import { contrastRatio, isDarkColor, mix, parseRgb } from './color';
39
47
  import { KIT_COMPONENTS } from './component-index';
40
48
  import { acceptCss, injectLayerOrder, isWrittenCss } from './css';
@@ -136,33 +144,41 @@ export interface ComponentDefs {
136
144
  'bar-chart': typeof barChartDef;
137
145
  button: typeof buttonDef;
138
146
  'callout-bubble': typeof calloutBubbleDef;
147
+ card: typeof cardDef;
148
+ checkbox: typeof checkboxDef;
149
+ collapsible: typeof collapsibleDef;
139
150
  'color-picker': typeof colorPickerDef;
140
151
  'data-table': typeof dataTableDef;
141
152
  'date-picker': typeof datePickerDef;
142
153
  dialog: typeof dialogDef;
143
154
  donut: typeof donutDef;
144
155
  drawer: typeof drawerDef;
156
+ 'dropdown-menu': typeof dropdownMenuDef;
145
157
  empty: typeof emptyDef;
146
158
  field: typeof fieldDef;
147
159
  'glyph-select': typeof glyphSelectDef;
148
160
  'hover-card': typeof hoverCardDef;
161
+ 'input-group': typeof inputGroupDef;
162
+ input: typeof inputDef;
163
+ item: typeof itemDef;
149
164
  kbd: typeof kbdDef;
150
165
  'line-chart': typeof lineChartDef;
151
- 'dropdown-menu': typeof dropdownMenuDef;
166
+ 'month-grid': typeof monthGridDef;
152
167
  'number-input': typeof numberInputDef;
153
168
  popover: typeof popoverDef;
154
169
  'scatter-chart': typeof scatterChartDef;
155
170
  select: typeof selectDef;
171
+ slider: typeof sliderDef;
172
+ 'sort-button': typeof sortButtonDef;
156
173
  sparkline: typeof sparklineDef;
157
174
  stat: typeof statDef;
158
- checkbox: typeof checkboxDef;
175
+ switch: typeof switchDef;
159
176
  tabs: typeof tabsDef;
160
177
  'text-area': typeof textAreaDef;
161
- input: typeof inputDef;
162
- 'input-group': typeof inputGroupDef;
163
- switch: typeof switchDef;
178
+ toast: typeof toastDef;
164
179
  'toggle-group': typeof toggleGroupDef;
165
180
  tooltip: typeof tooltipDef;
181
+ treemap: typeof treemapDef;
166
182
  }
167
183
 
168
184
  type SettingsOf<D> = D extends ComponentDef<string, string, infer S> ? S : never;
@@ -1,89 +0,0 @@
1
- import { variants } from './chunk-LZWZV2ZS.js';
2
- import { iconEl } from './chunk-G7IQLY3A.js';
3
- import { h } from './chunk-Q6WTDVH6.js';
4
- import { t } from './chunk-6QCILIT2.js';
5
- import { defineComponent } from './chunk-VMCR3S2A.js';
6
- import { css, defineStyles } from './chunk-IDA2BT7D.js';
7
-
8
- // src/components/button.ts
9
- var buttonDef = defineComponent({
10
- name: "button",
11
- parts: ["root", "icon"],
12
- settings: {
13
- radius: t.radius.md,
14
- height: "34px",
15
- "height-xs": "26px",
16
- "height-sm": "30px",
17
- "height-lg": "40px",
18
- "font-size": "14px",
19
- "font-size-xs": "12px",
20
- "font-size-sm": "13px"
21
- }
22
- });
23
- var buttonVariants = variants({
24
- variant: ["default", "outline", "secondary", "ghost", "destructive", "link", "up", "down"],
25
- size: ["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"]
26
- });
27
- var BUTTON_STYLE_ID = "vela-ui-button";
28
- var BUTTON_CSS = css`@layer vela.ui{[data-slot=button]{cursor:pointer;height:${buttonDef.vars.height};border-radius:${buttonDef.vars.radius};border:1px solid ${t.border.strong};color:${t.fg};font-weight:400;font-size:${buttonDef.vars["font-size"]};white-space:nowrap;transition:background ${t.dur.fast} ease, color ${t.dur.fast} ease, opacity ${t.dur.fast} ease, border-color ${t.dur.fast} ease;background:0 0;padding:0 11px;font-family:inherit}[data-slot=button]:where(:not([hidden])){justify-content:center;align-items:center;gap:6px;display:inline-flex}[data-slot=button]>[data-icon]{flex:none;width:1em;height:1em;font-size:16px}[data-slot=button]>[data-icon]>svg{width:100%;height:100%}[data-slot=button][data-size=xs]>[data-icon],[data-slot=button][data-size=icon-xs]>[data-icon]{font-size:12px}[data-slot=button][data-size=sm],[data-slot=button][data-size=icon-sm]{height:${buttonDef.vars["height-sm"]};font-size:${buttonDef.vars["font-size-sm"]}}[data-slot=button][data-size=xs],[data-slot=button][data-size=icon-xs]{height:${buttonDef.vars["height-xs"]};font-size:${buttonDef.vars["font-size-xs"]};border-radius:${t.radius.sm};padding:0 8px}[data-slot=button][data-size=lg],[data-slot=button][data-size=icon-lg]{height:${buttonDef.vars["height-lg"]};padding:0 14px}[data-slot=button][data-size=icon]{width:${buttonDef.vars.height};padding:0}[data-slot=button][data-size=icon-sm]{width:${buttonDef.vars["height-sm"]};padding:0}[data-slot=button][data-size=icon-xs]{width:${buttonDef.vars["height-xs"]};padding:0}[data-slot=button][data-size=icon-lg]{width:${buttonDef.vars["height-lg"]};padding:0}[data-slot=button]:disabled{cursor:default;opacity:.5}[data-slot=button]:focus-visible{outline:2px solid ${t.focus};outline-offset:1px}[data-slot=button]:not(:disabled):hover,[data-slot=button][aria-expanded=true]{background:${t.hover};color:${t.fg.bright};border-color:${t.fg.muted}}[data-slot=button][data-variant=default]{border-color:${t.selected.bg};background:${t.selected.bg};color:${t.selected.fg}}[data-slot=button][data-variant=default]:not(:disabled):hover,[data-slot=button][data-variant=default][aria-expanded=true]{background:${t.selected.bg};color:${t.selected.fg};opacity:.85;border-color:${t.selected.bg}}[data-slot=button][data-variant=secondary]{background:${t.surface.sunken};border-color:${t.border}}[data-slot=button][data-variant=secondary]:not(:disabled):hover,[data-slot=button][data-variant=secondary][aria-expanded=true]{border-color:${t.border.strong}}[data-slot=button][data-variant=ghost]{color:${t.fg.muted};border-color:#0000}[data-slot=button][data-variant=ghost]:not(:disabled):hover,[data-slot=button][data-variant=ghost][aria-expanded=true]{border-color:#0000}[data-slot=button][data-variant=destructive]{background:color-mix(in srgb, ${t.danger} 14%, transparent);color:${t.danger};border-color:#0000}[data-slot=button][data-variant=destructive]:not(:disabled):hover{background:color-mix(in srgb, ${t.danger} 24%, transparent);color:${t.danger};border-color:#0000}[data-slot=button][data-variant=link]{color:${t.accent};text-underline-offset:4px;background:0 0;border-color:#0000;padding-inline:0}[data-slot=button][data-variant=link]:not(:disabled):hover{color:${t.accent};background:0 0;border-color:#0000;text-decoration:underline}[data-slot=button][data-variant=up],[data-slot=button][data-variant=up]:not(:disabled):hover{background:${t.up};color:${t.fg.onFill};border-color:#0000}[data-slot=button][data-variant=down],[data-slot=button][data-variant=down]:not(:disabled):hover{background:${t.down};color:${t.fg.onFill};border-color:#0000}[data-slot=button][data-variant=up]:not(:disabled):hover,[data-slot=button][data-variant=down]:not(:disabled):hover{opacity:.88}[data-slot=button][data-pressed]{background:${t.active};color:${t.fg.bright}}}`;
29
- var injectStyles = defineStyles(BUTTON_STYLE_ID, BUTTON_CSS);
30
- var ButtonImpl = class {
31
- constructor(props) {
32
- injectStyles(document);
33
- const { variant, size } = buttonVariants.resolve(props);
34
- this.iconOnly = size.startsWith("icon");
35
- this.label = props.label ?? props.text;
36
- this.pressedState = props.pressed;
37
- const icon = (id, side) => {
38
- const el = iconEl(id, document);
39
- el.dataset.slot = buttonDef.slot("icon");
40
- el.dataset.icon = side;
41
- return el;
42
- };
43
- this.textNode = !this.iconOnly && props.text !== void 0 ? document.createTextNode(props.text) : null;
44
- this.el = h(
45
- "button",
46
- {
47
- className: props.className ? `vela-btn ${props.className}` : "vela-btn",
48
- slot: buttonDef.slot("root"),
49
- attrs: { type: "button", ...buttonVariants({ variant, size }) },
50
- on: props.onClick ? { click: props.onClick } : void 0
51
- },
52
- props.icon ? icon(props.icon, "inline-start") : null,
53
- this.textNode,
54
- props.iconEnd && !this.iconOnly ? icon(props.iconEnd, "inline-end") : null
55
- );
56
- this.el.disabled = props.disabled ?? false;
57
- this.paint();
58
- }
59
- get pressed() {
60
- return this.pressedState;
61
- }
62
- setPressed(pressed) {
63
- this.pressedState = pressed;
64
- this.paint();
65
- }
66
- setDisabled(disabled) {
67
- this.el.disabled = disabled;
68
- }
69
- setText(text) {
70
- this.label = text;
71
- if (this.textNode) this.textNode.data = text;
72
- this.paint();
73
- }
74
- destroy() {
75
- }
76
- paint() {
77
- const el = this.el;
78
- el.toggleAttribute("data-pressed", this.pressedState === true);
79
- if (this.pressedState === void 0) el.removeAttribute("aria-pressed");
80
- else el.setAttribute("aria-pressed", String(this.pressedState));
81
- if (this.iconOnly && this.label !== void 0) el.setAttribute("aria-label", this.label);
82
- else el.removeAttribute("aria-label");
83
- }
84
- };
85
- function createButton(props = {}) {
86
- return new ButtonImpl(props);
87
- }
88
-
89
- export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton };
@@ -1,29 +0,0 @@
1
- import { injectLayerOrder, injectStyles } from './chunk-2GQIZM5Z.js';
2
- import { pageState } from './chunk-X66RJAIS.js';
3
-
4
- // src/lib/css.ts
5
- var written = pageState("written-css@1", () => /* @__PURE__ */ new Set());
6
- function css(strings, ...values) {
7
- let out = strings[0] ?? "";
8
- for (let i = 0; i < values.length; i += 1) out += String(values[i]) + (strings[i + 1] ?? "");
9
- written.add(out);
10
- return out;
11
- }
12
- function isWrittenCss(text) {
13
- return written.has(text);
14
- }
15
- function acceptCss(text) {
16
- written.add(text);
17
- }
18
- function defineStyles(id, text) {
19
- const injected = /* @__PURE__ */ new WeakMap();
20
- return (root = document) => {
21
- if (injected.get(root)?.isConnected) return;
22
- injectLayerOrder(root);
23
- injectStyles(id, text, root);
24
- const sheet = root.getElementById?.(id) ?? (root instanceof Document ? null : root.querySelector(`#${CSS.escape(id)}`));
25
- if (sheet) injected.set(root, sheet);
26
- };
27
- }
28
-
29
- export { acceptCss, css, defineStyles, isWrittenCss };
@@ -1,61 +0,0 @@
1
- import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
-
3
- type Child = Node | string | number | null | undefined | false | readonly Child[];
4
- type AttrValue = string | number | boolean | null | undefined;
5
- interface ElementProps {
6
- className?: string;
7
- /** The part's `data-slot` (take it from the component's `defineComponent`). */
8
- slot?: string;
9
- /** `data-*` attributes (`{ icon: 'inline-start' }` → `data-icon="inline-start"`). `true`
10
- * writes an empty value; `false`, `null` and `undefined` write nothing. */
11
- data?: Record<string, AttrValue>;
12
- /** Plain attributes, with the same value rules as `data`. */
13
- attrs?: Record<string, AttrValue>;
14
- style?: string;
15
- text?: string;
16
- on?: {
17
- [K in keyof HTMLElementEventMap]?: (e: HTMLElementEventMap[K]) => void;
18
- };
19
- }
20
- declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, props?: ElementProps, ...children: Child[]): HTMLElementTagNameMap[K];
21
- declare function append(el: Node, children: readonly Child[]): void;
22
- /** Add a part to an element's slot, keeping the ones it has: a shell one component owns and
23
- * another builds on carries both (`data-slot="popover-content select-content"`). */
24
- declare function addSlot(el: Element, slot: string): void;
25
-
26
- declare const dataTableDef: ComponentDef<"data-table", "head" | "table" | "sort" | "root" | "actions" | "row" | "cell" | "empty", "row-height" | "head-height" | "head-z">;
27
- interface DataTableColumn<T> {
28
- id: string;
29
- header: string;
30
- /** What the header stands for, on hover (`MFE`: maximum favorable excursion). */
31
- title?: string;
32
- align?: 'start' | 'end' | 'center';
33
- width?: string;
34
- /** The cell's content; a string or a number renders as text. */
35
- cell(row: T): Child;
36
- /** The value the column sorts by; without it the column does not sort. */
37
- sort?(row: T): number | string;
38
- tone?(row: T): 'profit' | 'loss' | 'muted' | null;
39
- }
40
- interface DataTableProps<T> {
41
- columns: readonly DataTableColumn<T>[];
42
- rowKey(row: T): string;
43
- onRowClick?(row: T, e: MouseEvent): void;
44
- /** What shows when there are no rows. */
45
- empty?: () => HTMLElement;
46
- /** The initial sort. */
47
- sort?: {
48
- column: string;
49
- dir: 'asc' | 'desc';
50
- };
51
- /** Extra class names (layout hooks). */
52
- className?: string;
53
- }
54
- interface DataTableHandle<T> {
55
- readonly el: HTMLElement;
56
- setRows(rows: readonly T[]): void;
57
- destroy(): void;
58
- }
59
- declare function createDataTable<T>(props: DataTableProps<T>): DataTableHandle<T>;
60
-
61
- export { type Child as C, type DataTableColumn as D, type ElementProps as E, addSlot as a, append as b, type DataTableHandle as c, dataTableDef as d, type DataTableProps as e, createDataTable as f, h };