@luxalgo/vela-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +28 -0
  4. package/README.md +83 -3
  5. package/cli/engine.mjs +282 -0
  6. package/cli/index.mjs +154 -0
  7. package/dist/badge.d.ts +26 -0
  8. package/dist/badge.js +44 -0
  9. package/dist/bar-chart.d.ts +40 -0
  10. package/dist/bar-chart.js +105 -0
  11. package/dist/button.d.ts +41 -0
  12. package/dist/button.js +10 -0
  13. package/dist/calendar.d.ts +22 -0
  14. package/dist/calendar.js +1 -0
  15. package/dist/callout-bubble.d.ts +98 -0
  16. package/dist/callout-bubble.js +173 -0
  17. package/dist/chart.d.ts +30 -0
  18. package/dist/chart.js +1 -0
  19. package/dist/checkbox.d.ts +60 -0
  20. package/dist/checkbox.js +12 -0
  21. package/dist/chunk-2GQIZM5Z.js +28 -0
  22. package/dist/chunk-2Q4JRINP.js +403 -0
  23. package/dist/chunk-3Q32K4PE.js +85 -0
  24. package/dist/chunk-5QHXOAZA.js +351 -0
  25. package/dist/chunk-6NXY62JS.js +25 -0
  26. package/dist/chunk-6QCILIT2.js +52 -0
  27. package/dist/chunk-A2FJ7Y7D.js +55 -0
  28. package/dist/chunk-A72NWYNP.js +26 -0
  29. package/dist/chunk-AJ2IYSOI.js +553 -0
  30. package/dist/chunk-BXMWQIBO.js +66 -0
  31. package/dist/chunk-CH3DV6FD.js +280 -0
  32. package/dist/chunk-EZQXTO6K.js +89 -0
  33. package/dist/chunk-FCO3YZLT.js +81 -0
  34. package/dist/chunk-FN2BUFNM.js +10 -0
  35. package/dist/chunk-FVH6L7FM.js +18 -0
  36. package/dist/chunk-G7IQLY3A.js +183 -0
  37. package/dist/chunk-IDA2BT7D.js +29 -0
  38. package/dist/chunk-J2QJATCD.js +12 -0
  39. package/dist/chunk-LZWZV2ZS.js +18 -0
  40. package/dist/chunk-MMTMOV6R.js +31 -0
  41. package/dist/chunk-OBLIX3VN.js +227 -0
  42. package/dist/chunk-P4MTEMT7.js +23 -0
  43. package/dist/chunk-Q6WTDVH6.js +31 -0
  44. package/dist/chunk-S7USVSYP.js +50 -0
  45. package/dist/chunk-SAPURP46.js +133 -0
  46. package/dist/chunk-TAKSIV57.js +90 -0
  47. package/dist/chunk-V6TTTMTE.js +79 -0
  48. package/dist/chunk-VMCR3S2A.js +22 -0
  49. package/dist/chunk-X4YPSIW6.js +72 -0
  50. package/dist/chunk-X66RJAIS.js +14 -0
  51. package/dist/chunk-XJAPCCOJ.js +101 -0
  52. package/dist/chunk-ZB3BZHSN.js +219 -0
  53. package/dist/color-picker.d.ts +103 -0
  54. package/dist/color-picker.js +19 -0
  55. package/dist/color.d.ts +24 -0
  56. package/dist/color.js +1 -0
  57. package/dist/context-menu.d.ts +72 -0
  58. package/dist/context-menu.js +161 -0
  59. package/dist/css.d.ts +15 -0
  60. package/dist/css.js +4 -0
  61. package/dist/data-table-DtU3FX9j.d.ts +61 -0
  62. package/dist/data-table.d.ts +3 -0
  63. package/dist/data-table.js +88 -0
  64. package/dist/date-picker.d.ts +90 -0
  65. package/dist/date-picker.js +257 -0
  66. package/dist/define-D5u3F5Dj.d.ts +21 -0
  67. package/dist/dialog.d.ts +89 -0
  68. package/dist/dialog.js +258 -0
  69. package/dist/dispose.d.ts +9 -0
  70. package/dist/dispose.js +2 -0
  71. package/dist/donut.d.ts +27 -0
  72. package/dist/donut.js +67 -0
  73. package/dist/drawer.d.ts +119 -0
  74. package/dist/drawer.js +326 -0
  75. package/dist/dropdown-menu.d.ts +114 -0
  76. package/dist/dropdown-menu.js +18 -0
  77. package/dist/empty.d.ts +21 -0
  78. package/dist/empty.js +38 -0
  79. package/dist/field.d.ts +147 -0
  80. package/dist/field.js +328 -0
  81. package/dist/glyph-select.d.ts +57 -0
  82. package/dist/glyph-select.js +17 -0
  83. package/dist/headless.d.ts +6 -0
  84. package/dist/headless.js +9 -0
  85. package/dist/hover-card.d.ts +43 -0
  86. package/dist/hover-card.js +97 -0
  87. package/dist/i18n.d.ts +20 -0
  88. package/dist/i18n.js +1 -0
  89. package/dist/icons.d.ts +20 -0
  90. package/dist/icons.js +2 -0
  91. package/dist/index.d.ts +45 -0
  92. package/dist/index.js +13 -0
  93. package/dist/input-group.d.ts +57 -0
  94. package/dist/input-group.js +86 -0
  95. package/dist/input.d.ts +54 -0
  96. package/dist/input.js +9 -0
  97. package/dist/kbd.d.ts +19 -0
  98. package/dist/kbd.js +8 -0
  99. package/dist/kit-text.d.ts +8 -0
  100. package/dist/kit-text.js +2 -0
  101. package/dist/line-chart.d.ts +32 -0
  102. package/dist/line-chart.js +120 -0
  103. package/dist/manifest.json +3854 -0
  104. package/dist/number-input.d.ts +99 -0
  105. package/dist/number-input.js +14 -0
  106. package/dist/page.d.ts +7 -0
  107. package/dist/page.js +1 -0
  108. package/dist/palette.d.ts +55 -0
  109. package/dist/palette.js +1 -0
  110. package/dist/placement.d.ts +98 -0
  111. package/dist/placement.js +1 -0
  112. package/dist/popover.d.ts +107 -0
  113. package/dist/popover.js +15 -0
  114. package/dist/scatter-chart.d.ts +32 -0
  115. package/dist/scatter-chart.js +121 -0
  116. package/dist/select.d.ts +112 -0
  117. package/dist/select.js +19 -0
  118. package/dist/sparkline.d.ts +22 -0
  119. package/dist/sparkline.js +72 -0
  120. package/dist/stat.d.ts +29 -0
  121. package/dist/stat.js +41 -0
  122. package/dist/styles.d.ts +22 -0
  123. package/dist/styles.js +2 -0
  124. package/dist/surface-events.d.ts +17 -0
  125. package/dist/surface-events.js +1 -0
  126. package/dist/surface-exit.d.ts +25 -0
  127. package/dist/surface-exit.js +1 -0
  128. package/dist/switch.d.ts +54 -0
  129. package/dist/switch.js +92 -0
  130. package/dist/t.d.ts +89 -0
  131. package/dist/t.js +1 -0
  132. package/dist/tabs.d.ts +63 -0
  133. package/dist/tabs.js +150 -0
  134. package/dist/text-area.d.ts +54 -0
  135. package/dist/text-area.js +9 -0
  136. package/dist/theme.d.ts +188 -0
  137. package/dist/theme.js +8 -0
  138. package/dist/theme.schema.json +1745 -0
  139. package/dist/themes/dark.css +3 -0
  140. package/dist/themes/light.css +3 -0
  141. package/dist/toggle-group.d.ts +56 -0
  142. package/dist/toggle-group.js +130 -0
  143. package/dist/tokens.d.ts +16 -0
  144. package/dist/tokens.js +3 -0
  145. package/dist/tooltip.d.ts +47 -0
  146. package/dist/tooltip.js +74 -0
  147. package/dist/variants-B4stUBnY.d.ts +16 -0
  148. package/dist/zag.d.ts +19 -0
  149. package/dist/zag.js +2 -0
  150. package/docs/theming.md +211 -0
  151. package/docs/what-to-change.md +20 -0
  152. package/docs/writing-a-component.md +247 -0
  153. package/llms.txt +66 -0
  154. package/package.json +90 -6
  155. package/registry/badge.ts +119 -0
  156. package/registry/bar-chart.ts +215 -0
  157. package/registry/button.ts +303 -0
  158. package/registry/callout-bubble.ts +336 -0
  159. package/registry/checkbox.ts +234 -0
  160. package/registry/color-picker.ts +582 -0
  161. package/registry/context-menu.ts +208 -0
  162. package/registry/data-table.ts +215 -0
  163. package/registry/date-picker.ts +483 -0
  164. package/registry/dialog.ts +535 -0
  165. package/registry/donut.ts +145 -0
  166. package/registry/drawer.ts +636 -0
  167. package/registry/dropdown-menu.ts +762 -0
  168. package/registry/empty.ts +91 -0
  169. package/registry/field.ts +585 -0
  170. package/registry/glyph-select.ts +268 -0
  171. package/registry/hover-card.ts +222 -0
  172. package/registry/input-group.ts +229 -0
  173. package/registry/input.ts +181 -0
  174. package/registry/kbd.ts +64 -0
  175. package/registry/line-chart.ts +218 -0
  176. package/registry/number-input.ts +443 -0
  177. package/registry/popover.ts +368 -0
  178. package/registry/scatter-chart.ts +221 -0
  179. package/registry/select.ts +620 -0
  180. package/registry/sparkline.ts +114 -0
  181. package/registry/stat.ts +96 -0
  182. package/registry/switch.ts +205 -0
  183. package/registry/tabs.ts +392 -0
  184. package/registry/text-area.ts +186 -0
  185. package/registry/toggle-group.ts +295 -0
  186. package/registry/tooltip.ts +156 -0
  187. package/skills/theming-vela-ui/SKILL.md +137 -0
  188. package/skills/using-vela-ui-components/SKILL.md +134 -0
  189. package/skills/writing-vela-ui-components/SKILL.md +163 -0
  190. package/src/components/badge.ts +119 -0
  191. package/src/components/bar-chart.ts +215 -0
  192. package/src/components/button.ts +303 -0
  193. package/src/components/callout-bubble.ts +336 -0
  194. package/src/components/checkbox.ts +234 -0
  195. package/src/components/color-picker.ts +582 -0
  196. package/src/components/context-menu.ts +208 -0
  197. package/src/components/data-table.ts +215 -0
  198. package/src/components/date-picker.ts +483 -0
  199. package/src/components/dialog.ts +535 -0
  200. package/src/components/donut.ts +145 -0
  201. package/src/components/drawer.ts +636 -0
  202. package/src/components/dropdown-menu.ts +762 -0
  203. package/src/components/empty.ts +91 -0
  204. package/src/components/field.ts +585 -0
  205. package/src/components/glyph-select.ts +268 -0
  206. package/src/components/hover-card.ts +222 -0
  207. package/src/components/input-group.ts +229 -0
  208. package/src/components/input.ts +181 -0
  209. package/src/components/kbd.ts +64 -0
  210. package/src/components/line-chart.ts +218 -0
  211. package/src/components/number-input.ts +443 -0
  212. package/src/components/popover.ts +368 -0
  213. package/src/components/scatter-chart.ts +221 -0
  214. package/src/components/select.ts +620 -0
  215. package/src/components/sparkline.ts +114 -0
  216. package/src/components/stat.ts +96 -0
  217. package/src/components/switch.ts +205 -0
  218. package/src/components/tabs.ts +392 -0
  219. package/src/components/text-area.ts +186 -0
  220. package/src/components/toggle-group.ts +295 -0
  221. package/src/components/tooltip.ts +156 -0
  222. package/src/index.ts +24 -0
  223. package/src/lib/calendar.ts +112 -0
  224. package/src/lib/chart.ts +72 -0
  225. package/src/lib/color.ts +89 -0
  226. package/src/lib/component-index.ts +131 -0
  227. package/src/lib/css.ts +44 -0
  228. package/src/lib/define.ts +45 -0
  229. package/src/lib/dispose.ts +36 -0
  230. package/src/lib/h.ts +55 -0
  231. package/src/lib/headless.ts +16 -0
  232. package/src/lib/i18n.ts +30 -0
  233. package/src/lib/icons.ts +237 -0
  234. package/src/lib/kit-text.ts +26 -0
  235. package/src/lib/page.ts +24 -0
  236. package/src/lib/palette.ts +81 -0
  237. package/src/lib/placement.ts +188 -0
  238. package/src/lib/styles.ts +53 -0
  239. package/src/lib/surface-events.ts +31 -0
  240. package/src/lib/surface-exit.ts +87 -0
  241. package/src/lib/t.ts +68 -0
  242. package/src/lib/theme.ts +654 -0
  243. package/src/lib/tokens.ts +111 -0
  244. package/src/lib/variants.ts +32 -0
  245. package/src/lib/zag.ts +46 -0
  246. package/stylelint/index.mjs +60 -0
  247. package/stylelint/lint.mjs +81 -0
  248. package/stylelint/plugin.mjs +115 -0
@@ -0,0 +1,133 @@
1
+ import { openPopoverTrigger, closeOpenPopovers, Popover } from './chunk-OBLIX3VN.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 { defineStyles, css } from './chunk-IDA2BT7D.js';
7
+
8
+ // src/components/glyph-select.ts
9
+ function glyphSelectController(opts) {
10
+ let value = opts.value;
11
+ return {
12
+ options: opts.options,
13
+ get value() {
14
+ return value;
15
+ },
16
+ setValue(v) {
17
+ value = v;
18
+ },
19
+ optionOf(v) {
20
+ return opts.options.find((o) => o.value === v);
21
+ },
22
+ pick(v) {
23
+ value = v;
24
+ opts.onChange?.(v);
25
+ return v;
26
+ }
27
+ };
28
+ }
29
+ var WIDTH_FIELD_OPTIONS = [1, 2, 3, 4, 5];
30
+ function lineWidthGlyph(width) {
31
+ return `<svg width="22" height="14" viewBox="0 0 22 14" fill="none"><line x1="2" y1="7" x2="20" y2="7" stroke="currentColor" stroke-width="${width}" stroke-linecap="round"/></svg>`;
32
+ }
33
+ function widthFieldOptions() {
34
+ return WIDTH_FIELD_OPTIONS.map((w) => ({ value: w, label: `${w}px`, glyph: lineWidthGlyph(w) }));
35
+ }
36
+ var glyphSelectDef = defineComponent({
37
+ name: "glyph-select",
38
+ parts: ["root", "value", "icon", "content", "item"],
39
+ settings: { radius: t.radius.md, "content-radius": t.radius.md, "focus-ring": `0 0 0 3px ${t.focus.soft}` }
40
+ });
41
+ var injectStyles = defineStyles(
42
+ "vela-ui-glyph-select",
43
+ css`@layer vela.ui{[data-slot=glyph-select]{border:1px solid ${t.border.strong};border-radius:${glyphSelectDef.vars.radius};cursor:pointer;height:34px;color:${t.fg.bright};transition:border-color ${t.dur.fast} ease, box-shadow ${t.dur.fast} ease;background:0 0;outline:2px solid #0000;flex:none;justify-self:start;align-items:center;gap:8px;padding-block:0;padding-inline:8px 26px;font-family:inherit;font-size:14px;position:relative}[data-slot=glyph-select]:where(:not([hidden])){display:inline-flex}[data-slot=glyph-select]:hover{border-color:${t.fg.muted}}[data-slot=glyph-select]:focus{border-color:${t.focus};box-shadow:${glyphSelectDef.vars["focus-ring"]}}[data-slot=glyph-select-icon]{inset-inline-end:8px;opacity:.55;color:inherit;pointer-events:none;line-height:0;display:flex;position:absolute;top:50%;transform:translateY(-50%)}[data-slot~=glyph-select-content]{background:${t.bg};border-radius:${glyphSelectDef.vars["content-radius"]};box-shadow:${t.shadow};color:${t.fg};font:14px ${t.font};border:none;flex-direction:column;gap:1px;padding:4px;display:flex}[data-slot=glyph-select-item]{border-radius:${t.radius.sm};min-width:96px;color:inherit;cursor:pointer;text-align:start;font:inherit;background:0 0;border:none;align-items:center;gap:8px;padding:7px 10px;display:flex}[data-slot=glyph-select-item]:hover{background:${t.hover}}[data-slot=glyph-select-item][data-active="1"]{background:${t.hover.strong};color:${t.fg.bright}}}`
44
+ );
45
+ var GlyphSelect = class {
46
+ constructor(opts) {
47
+ injectStyles(document);
48
+ this.placement = opts;
49
+ this.ctrl = glyphSelectController(opts);
50
+ this.theme = opts.theme;
51
+ this.get = opts.get ?? (() => this.ctrl.value);
52
+ const trigger = h("button", { className: "vela-glyph-select", slot: glyphSelectDef.slot("root"), attrs: { type: "button", title: opts.title } });
53
+ this.el = trigger;
54
+ this.paint();
55
+ trigger.addEventListener("pointerdown", (e) => {
56
+ e.preventDefault();
57
+ trigger.focus({ preventScroll: true });
58
+ });
59
+ trigger.addEventListener("click", (e) => {
60
+ e.stopPropagation();
61
+ this.toggle();
62
+ });
63
+ trigger.addEventListener("vela-sync", () => {
64
+ this.ctrl.setValue(this.get());
65
+ this.paint();
66
+ });
67
+ }
68
+ setValue(v) {
69
+ this.ctrl.setValue(v);
70
+ this.paint();
71
+ }
72
+ destroy() {
73
+ }
74
+ paint() {
75
+ const opt = this.ctrl.optionOf(this.get());
76
+ const glyph = h("span", { slot: glyphSelectDef.slot("value"), style: "display:flex" });
77
+ glyph.innerHTML = opt?.glyph ?? "";
78
+ const caret = h("span", { className: "vela-glyph-select-caret", slot: glyphSelectDef.slot("icon") }, iconEl("chevron-down", this.el.ownerDocument));
79
+ this.el.replaceChildren(glyph, caret);
80
+ }
81
+ toggle() {
82
+ if (openPopoverTrigger() === this.el) {
83
+ closeOpenPopovers();
84
+ return;
85
+ }
86
+ const current = this.get();
87
+ const pop = new Popover({
88
+ trigger: this.el,
89
+ theme: this.theme,
90
+ side: this.placement.side,
91
+ align: this.placement.align ?? "end",
92
+ sideOffset: this.placement.sideOffset ?? 6,
93
+ alignOffset: this.placement.alignOffset,
94
+ avoidCollisions: this.placement.avoidCollisions,
95
+ collisionPadding: this.placement.collisionPadding,
96
+ collisionBoundary: this.placement.collisionBoundary,
97
+ className: "vela-glyph-select-pop",
98
+ slot: glyphSelectDef.slot("content"),
99
+ content: (el) => {
100
+ el.style.font = `var(--vela-font-size-md) ${this.theme.fontFamily}`;
101
+ for (const o of this.ctrl.options) {
102
+ const item = h("button", { className: "vela-glyph-select-item", slot: glyphSelectDef.slot("item"), attrs: { type: "button" }, data: { active: o.value === current ? "1" : "0" } });
103
+ item.innerHTML = `<span style="display:flex;flex:none;">${o.glyph}</span><span style="flex:1;font-variant-numeric:tabular-nums;">${o.label}</span>`;
104
+ item.addEventListener("click", (ev) => {
105
+ ev.stopPropagation();
106
+ pop.hide();
107
+ this.ctrl.pick(o.value);
108
+ this.paint();
109
+ });
110
+ el.appendChild(item);
111
+ }
112
+ }
113
+ });
114
+ pop.show();
115
+ }
116
+ };
117
+ function createGlyphSelect(props) {
118
+ return new GlyphSelect(props);
119
+ }
120
+ function widthField(theme, getVal, onVal) {
121
+ return new GlyphSelect({
122
+ theme,
123
+ options: widthFieldOptions(),
124
+ value: getVal(),
125
+ get: getVal,
126
+ onChange: onVal
127
+ }).el;
128
+ }
129
+ function closeWidthPopover() {
130
+ closeOpenPopovers();
131
+ }
132
+
133
+ export { GlyphSelect, WIDTH_FIELD_OPTIONS, closeWidthPopover, createGlyphSelect, glyphSelectController, glyphSelectDef, lineWidthGlyph, widthField, widthFieldOptions };
@@ -0,0 +1,90 @@
1
+ import { HIGHLIGHT, ACCENT_BRIGHT, ACCENT } from './chunk-MMTMOV6R.js';
2
+ import { isDarkColor, mix, withAlpha } from './chunk-BXMWQIBO.js';
3
+
4
+ // src/lib/tokens.ts
5
+ var STATIC_TOKENS = {
6
+ "--vela-space-1": "4px",
7
+ "--vela-space-2": "8px",
8
+ "--vela-space-3": "12px",
9
+ "--vela-space-4": "16px",
10
+ "--vela-radius-sm": "4px",
11
+ "--vela-radius-md": "6px",
12
+ "--vela-radius-lg": "10px",
13
+ "--vela-z-tooltip": "60",
14
+ "--vela-z-menu": "50",
15
+ "--vela-z-dialog": "40",
16
+ // Form popovers portal to <body> (or a chart host) and must sit above a dialog
17
+ // whose own stacking context may be nested inside the chart container.
18
+ "--vela-z-popover": "6000",
19
+ "--vela-ease": "cubic-bezier(0.22, 1, 0.36, 1)",
20
+ "--vela-dur-fast": "90ms",
21
+ "--vela-dur-med": "160ms",
22
+ "--vela-font-size-sm": "11px",
23
+ "--vela-font-size-md": "12px",
24
+ "--vela-font-size-lg": "14px",
25
+ "--vela-scroll-size": "5px"
26
+ };
27
+ function themeTokens(t) {
28
+ const dark = isDarkColor(t.background);
29
+ const wash = (a) => dark ? `rgba(255,255,255,${a})` : withAlpha(t.textColor, a + 0.02);
30
+ const elevated = mix(t.background, dark ? "#ffffff" : t.textColor, dark ? 0.03 : 0.05);
31
+ return {
32
+ "--vela-font": t.fontFamily,
33
+ "--vela-bg": t.background,
34
+ // Chrome text is slightly brighter than the chart's own axis text, which is
35
+ // deliberately recessive; the chart keeps using `t.textColor` directly.
36
+ "--vela-fg": dark ? "#d1d4dc" : t.textColor,
37
+ "--vela-fg-muted": dark ? "#868a96" : withAlpha(t.textColor, 0.62),
38
+ "--vela-fg-faint": withAlpha(t.textColor, 0.35),
39
+ "--vela-fg-bright": dark ? "#f0f3fa" : "#000000",
40
+ "--vela-surface": t.background,
41
+ // Panels and menus float ABOVE the chart, so their surface is the wash flattened onto
42
+ // the chart background — opaque, or candles read through the panel.
43
+ "--vela-surface-elev": elevated,
44
+ "--vela-surface-overlay": elevated,
45
+ // Recessed fields (inputs, selects) read as cut INTO their panel, so they fall back
46
+ // to the chart surface and are separated from the panel by their border alone.
47
+ "--vela-surface-sunken": t.background,
48
+ "--vela-border": t.borderColor,
49
+ "--vela-border-strong": dark ? "#34353b" : withAlpha(t.textColor, 0.28),
50
+ "--vela-border-soft": t.borderColor,
51
+ // Barely-there rules INSIDE a panel (row separators), where a full border would
52
+ // chop the list into boxes.
53
+ "--vela-border-faint": withAlpha(t.textColor, 0.08),
54
+ "--vela-hover": wash(0.06),
55
+ "--vela-active": wash(0.1),
56
+ // A deliberately stronger hover for rows inside an already-tinted surface (menu
57
+ // items in an active flyout), where the normal wash would not separate from it.
58
+ "--vela-hover-strong": wash(0.16),
59
+ "--vela-focus": withAlpha(t.textColor, 0.5),
60
+ "--vela-focus-soft": withAlpha(t.textColor, 0.12),
61
+ // Separator hover — the SAME wash the chart's pane separators paint on hover
62
+ // (soft full-thickness band + solid 2px center line), so DOM-drawn dividers
63
+ // (the workspace grid) and canvas-drawn ones read as one family.
64
+ "--vela-separator-hover-band": withAlpha(t.textColor, 0.1),
65
+ "--vela-separator-hover-line": withAlpha(t.textColor, 0.55),
66
+ // A scrollbar thumb is a border-weight line: present, never louder than the content.
67
+ "--vela-scroll": t.borderColor,
68
+ "--vela-accent": ACCENT,
69
+ "--vela-accent-bright": ACCENT_BRIGHT,
70
+ "--vela-highlight": HIGHLIGHT,
71
+ // The inverse chip: a filled selected state (active tab, ticked checkbox). Its ink
72
+ // must contrast the fill, so the pair flips together with the theme.
73
+ "--vela-selected-bg": dark ? "#f0f3fa" : t.textColor,
74
+ "--vela-selected-fg": dark ? t.background : "#ffffff",
75
+ // Fixed ink for saturated fills (accent buttons, categorical avatars) — those fills
76
+ // are theme-independent, so their ink is too.
77
+ "--vela-fg-on-fill": "#ffffff",
78
+ "--vela-up": t.upColor,
79
+ "--vela-down": t.downColor,
80
+ // Gains and losses (P&L, win rates): the candles' inks unless a theme parts them.
81
+ "--vela-profit": t.upColor,
82
+ "--vela-loss": t.downColor,
83
+ "--vela-danger": t.downColor,
84
+ "--vela-shadow": "0 8px 30px rgba(0,0,0,0.5)",
85
+ "--vela-shadow-dialog": "0 20px 60px rgba(0,0,0,0.5)",
86
+ "--vela-backdrop": "rgba(0,0,0,0.45)"
87
+ };
88
+ }
89
+
90
+ export { STATIC_TOKENS, themeTokens };
@@ -0,0 +1,79 @@
1
+ // src/lib/calendar.ts
2
+ var EN_MONTHS_LONG = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
3
+ var EN_MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
4
+ var EN_WEEKDAYS_MIN = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
5
+ var BIDI_MARKS = /[\u200e\u200f\u061c]/g;
6
+ var stripBidiMarks = (text) => text.replace(BIDI_MARKS, "");
7
+ function calendarSettings(i18n) {
8
+ const locale = i18n?.locale ?? "en";
9
+ let language = locale.split(/[-_]/)[0] ?? locale;
10
+ try {
11
+ language = new Intl.Locale(locale).language;
12
+ } catch {
13
+ }
14
+ return { locale, numberingSystem: i18n?.numberingSystem ?? "latn", english: language.toLowerCase() === "en" };
15
+ }
16
+ var dateFormats = /* @__PURE__ */ new Map();
17
+ function dateFormat(settings, options) {
18
+ const key = `${settings.locale}|${settings.numberingSystem}|${JSON.stringify(options)}`;
19
+ let dtf = dateFormats.get(key);
20
+ if (!dtf) {
21
+ try {
22
+ dtf = new Intl.DateTimeFormat(settings.locale, { ...options, timeZone: "UTC", calendar: "gregory", numberingSystem: settings.numberingSystem });
23
+ } catch {
24
+ dtf = new Intl.DateTimeFormat("en", { ...options, timeZone: "UTC", calendar: "gregory" });
25
+ }
26
+ dateFormats.set(key, dtf);
27
+ }
28
+ return dtf;
29
+ }
30
+ var digitTables = /* @__PURE__ */ new Map();
31
+ function localizeDigits(text, settings) {
32
+ const key = `${settings.locale}|${settings.numberingSystem}`;
33
+ let digits = digitTables.get(key);
34
+ if (digits === void 0) {
35
+ let nf;
36
+ try {
37
+ nf = new Intl.NumberFormat(settings.locale, { numberingSystem: settings.numberingSystem, useGrouping: false, maximumFractionDigits: 0 });
38
+ } catch {
39
+ nf = new Intl.NumberFormat("en", { useGrouping: false, maximumFractionDigits: 0 });
40
+ }
41
+ const table = Array.from({ length: 10 }, (_, d) => stripBidiMarks(nf.format(d)));
42
+ digits = table.every((d, i) => d === String(i)) ? null : table;
43
+ digitTables.set(key, digits);
44
+ }
45
+ if (!digits) return text;
46
+ const map = digits;
47
+ return text.replace(/[0-9]/g, (d) => map[Number(d)]);
48
+ }
49
+ function monthNames(settings, width) {
50
+ if (settings.english) return [...width === "long" ? EN_MONTHS_LONG : EN_MONTHS_SHORT];
51
+ const dtf = dateFormat(settings, { month: width });
52
+ return Array.from({ length: 12 }, (_, m) => stripBidiMarks(dtf.format(Date.UTC(2e3, m, 15))));
53
+ }
54
+ function weekdayNames(settings) {
55
+ if (settings.english) return [...EN_WEEKDAYS_MIN];
56
+ const dtf = dateFormat(settings, { weekday: "short" });
57
+ return Array.from({ length: 7 }, (_, d) => stripBidiMarks(dtf.format(Date.UTC(2e3, 0, 2 + d))));
58
+ }
59
+ function yearLabel(settings, year) {
60
+ if (settings.english) return localizeDigits(String(year), settings);
61
+ return stripBidiMarks(dateFormat(settings, { year: "numeric" }).format(Date.UTC(year, 6, 1)));
62
+ }
63
+ function plainInteger(settings, n) {
64
+ return localizeDigits(String(Math.trunc(n)), settings);
65
+ }
66
+ var yearFirstCache = /* @__PURE__ */ new Map();
67
+ function yearBeforeMonth(settings) {
68
+ if (settings.english) return false;
69
+ const key = `${settings.locale}|${settings.numberingSystem}`;
70
+ let first = yearFirstCache.get(key);
71
+ if (first === void 0) {
72
+ const types = dateFormat(settings, { year: "numeric", month: "long" }).formatToParts(Date.UTC(2026, 8, 15)).map((p) => p.type);
73
+ first = types.indexOf("year") < types.indexOf("month");
74
+ yearFirstCache.set(key, first);
75
+ }
76
+ return first;
77
+ }
78
+
79
+ export { calendarSettings, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel };
@@ -0,0 +1,22 @@
1
+ import { pageState } from './chunk-X66RJAIS.js';
2
+
3
+ // src/lib/define.ts
4
+ var declared = () => pageState("component-defs@1", () => /* @__PURE__ */ new Map());
5
+ function declaredComponents() {
6
+ return declared();
7
+ }
8
+ function defineComponent(def) {
9
+ const vars = {};
10
+ for (const [key, fallback] of Object.entries(def.settings ?? {})) {
11
+ vars[key] = `var(--vela-${def.name}-${key}, ${String(fallback)})`;
12
+ }
13
+ declared().set(def.name, { parts: def.parts, settings: Object.keys(vars) });
14
+ return {
15
+ name: def.name,
16
+ parts: def.parts,
17
+ slot: (part) => part === "root" ? def.name : `${def.name}-${part}`,
18
+ vars
19
+ };
20
+ }
21
+
22
+ export { declaredComponents, defineComponent };
@@ -0,0 +1,72 @@
1
+ import { variants } from './chunk-LZWZV2ZS.js';
2
+ import { h } from './chunk-Q6WTDVH6.js';
3
+ import { t } from './chunk-6QCILIT2.js';
4
+ import { defineComponent } from './chunk-VMCR3S2A.js';
5
+ import { css, defineStyles } from './chunk-IDA2BT7D.js';
6
+
7
+ // src/components/input.ts
8
+ function inputController(opts = {}) {
9
+ let value = opts.value ?? opts.defaultValue ?? "";
10
+ const size = opts.size ?? "md";
11
+ return {
12
+ get value() {
13
+ return value;
14
+ },
15
+ size,
16
+ fill: opts.fill ?? size !== "sm",
17
+ disabled: opts.disabled ?? false,
18
+ commit(next) {
19
+ if (next === value) return null;
20
+ value = next;
21
+ opts.onChange?.(next);
22
+ return next;
23
+ },
24
+ sync(next) {
25
+ value = next;
26
+ }
27
+ };
28
+ }
29
+ var inputDef = defineComponent({
30
+ name: "input",
31
+ parts: ["root", "control"],
32
+ settings: { radius: t.radius.md, "focus-ring": `0 0 0 3px ${t.focus.soft}` }
33
+ });
34
+ var inputVariants = variants({ size: ["md", "sm"] });
35
+ var TEXT_STYLE_ID = "vela-ui-text-2";
36
+ var TEXT_CSS = css`@layer vela.ui{[data-slot=input-control]{box-sizing:border-box;border:1px solid ${t.border.strong};border-radius:${inputDef.vars.radius};width:100%;min-width:0;height:34px;color:${t.fg.bright};text-overflow:ellipsis;transition:border-color ${t.dur.fast} ease, box-shadow ${t.dur.fast} ease;-webkit-user-select:text;user-select:text;background:0 0;outline:2px solid #0000;padding:0 8px;font-family:inherit;font-size:14px;overflow:hidden}[data-slot=input-control]:hover{border-color:${t.fg.muted}}[data-slot=input-control]:focus{border-color:${t.focus};box-shadow:${inputDef.vars["focus-ring"]}}[data-slot=input-control]::placeholder{color:currentColor;opacity:.4}[data-slot=input]{min-width:0}[data-slot=input]:where(:not([hidden])){display:inline-block}[data-slot=input][data-fill]{width:100%}[data-slot=input]:not([data-fill]){flex:none;justify-self:start;width:100px}[data-slot=input][data-size=sm] [data-slot=input-control]{background:${t.surface.elev};border-radius:${t.radius.sm};height:28px;color:${t.fg};font-size:13px}}`;
37
+ var injectStyles = defineStyles(TEXT_STYLE_ID, TEXT_CSS);
38
+ var Input = class {
39
+ constructor(opts = {}) {
40
+ injectStyles(document);
41
+ this.ctrl = inputController(opts);
42
+ const ti = h("input", { className: "vela-text-field", slot: inputDef.slot("control"), attrs: { type: opts.type ?? "text", size: 1, id: opts.id, placeholder: opts.placeholder, name: opts.name } });
43
+ ti.required = opts.required === true;
44
+ ti.value = this.ctrl.value;
45
+ ti.disabled = this.ctrl.disabled;
46
+ ti.addEventListener("blur", () => {
47
+ this.ctrl.commit(ti.value);
48
+ });
49
+ ti.addEventListener("keydown", (e) => {
50
+ if (e.key === "Enter") {
51
+ e.preventDefault();
52
+ ti.blur();
53
+ }
54
+ });
55
+ this.el = h("div", { className: "vela-text", slot: inputDef.slot("root"), attrs: inputVariants({ size: this.ctrl.size }), data: { fill: this.ctrl.fill } }, ti);
56
+ this.input = ti;
57
+ }
58
+ get value() {
59
+ return this.ctrl.value;
60
+ }
61
+ setValue(v) {
62
+ this.ctrl.sync(v);
63
+ this.input.value = v;
64
+ }
65
+ destroy() {
66
+ }
67
+ };
68
+ function createInput(props = {}) {
69
+ return new Input(props);
70
+ }
71
+
72
+ export { Input, TEXT_CSS, TEXT_STYLE_ID, createInput, inputController, inputDef, inputVariants };
@@ -0,0 +1,14 @@
1
+ // src/lib/page.ts
2
+ var ROOT = /* @__PURE__ */ Symbol.for("@luxalgo/vela-ui");
3
+ function pageState(name, init) {
4
+ const holder = globalThis;
5
+ const bag = holder[ROOT] ?? (holder[ROOT] = /* @__PURE__ */ Object.create(null));
6
+ if (!(name in bag)) bag[name] = init();
7
+ return bag[name];
8
+ }
9
+ function pageUid(prefix) {
10
+ const counter = pageState("uid@1", () => ({ n: 0 }));
11
+ return `${prefix}-${++counter.n}`;
12
+ }
13
+
14
+ export { pageState, pageUid };
@@ -0,0 +1,101 @@
1
+ import { variants } from './chunk-LZWZV2ZS.js';
2
+ import { iconEl } from './chunk-G7IQLY3A.js';
3
+ import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-P4MTEMT7.js';
4
+ import { ownTeardown } from './chunk-A72NWYNP.js';
5
+ import { h } from './chunk-Q6WTDVH6.js';
6
+ import { t } from './chunk-6QCILIT2.js';
7
+ import { defineComponent } from './chunk-VMCR3S2A.js';
8
+ import { defineStyles, css } from './chunk-IDA2BT7D.js';
9
+ import * as zagSwitch from '@zag-js/switch';
10
+
11
+ function checkboxController(opts = {}) {
12
+ let checked = opts.checked ?? opts.defaultChecked ?? false;
13
+ const disabled = opts.disabled ?? false;
14
+ return {
15
+ get checked() {
16
+ return checked;
17
+ },
18
+ disabled,
19
+ size: opts.size ?? "md",
20
+ tone: opts.tone ?? "bright",
21
+ setChecked(v) {
22
+ checked = v;
23
+ },
24
+ toggle() {
25
+ if (disabled) return checked;
26
+ checked = !checked;
27
+ opts.onCheckedChange?.(checked);
28
+ opts.onChange?.(checked);
29
+ return checked;
30
+ }
31
+ };
32
+ }
33
+ var checkboxDef = defineComponent({
34
+ name: "checkbox",
35
+ parts: ["root", "icon"],
36
+ settings: { radius: "5px" }
37
+ });
38
+ var checkboxVariants = variants({ size: ["md", "sm"], tone: ["bright", "selected"] });
39
+ var injectStyles = defineStyles(
40
+ "vela-ui-checkbox",
41
+ css`@layer vela.ui{[data-slot=checkbox]{border:1px solid ${t.border};border-radius:${checkboxDef.vars.radius};color:#0000;cursor:pointer;width:20px;height:20px;transition:background ${t.dur.fast} ease, border-color ${t.dur.fast} ease, color ${t.dur.fast} ease;background:0 0;flex:none;justify-content:center;align-items:center;padding:0;line-height:0;position:relative}[data-slot=checkbox]:where(:not([hidden])){display:inline-flex}[data-slot=checkbox] [data-slot=checkbox-icon],[data-slot=checkbox] svg{width:12px;height:12px;display:block}[data-slot=checkbox][data-size=sm] [data-slot=checkbox-icon],[data-slot=checkbox][data-size=sm] svg{width:11px;height:11px}[data-slot=checkbox]:hover{border-color:${t.fg.muted}}[data-slot=checkbox][data-focus-visible]{outline:2px solid ${t.focus};outline-offset:1px}[data-slot=checkbox][data-state=checked]{background:${t.fg.bright};border-color:${t.fg.bright};color:${t.bg}}[data-slot=checkbox][data-size=sm]{border-color:${t.border.strong};width:18px;height:18px}[data-slot=checkbox][data-size=sm]:hover{border-color:${t.fg.muted}}[data-slot=checkbox][data-size=sm][data-state=checked]{background:${t.selected.bg};border-color:${t.selected.bg};color:${t.selected.fg}}[data-slot=checkbox][data-tone=selected][data-state=checked]{background:${t.selected.bg};border-color:${t.selected.bg};color:${t.selected.fg}}[data-slot=checkbox][data-disabled]{opacity:.4;cursor:default}}`
42
+ );
43
+ var Checkbox = class {
44
+ constructor(opts = {}) {
45
+ injectStyles(document);
46
+ this.mid = nextUid("vela-checkbox");
47
+ this.current = opts.checked ?? opts.defaultChecked ?? false;
48
+ const icon = iconEl("check", document);
49
+ icon.dataset.slot = checkboxDef.slot("icon");
50
+ this.input = h("input", {});
51
+ this.el = h("label", { className: "vela-switch", slot: checkboxDef.slot("root"), attrs: checkboxVariants({ size: opts.size ?? "md", tone: opts.tone ?? "bright" }) }, this.input, icon);
52
+ this.machine = runMachine(
53
+ zagSwitch.machine,
54
+ {
55
+ id: this.mid,
56
+ // The host's id names the focusable control, so its own `<label for>` reaches it.
57
+ ...opts.id ? { ids: { hiddenInput: opts.id } } : {},
58
+ defaultChecked: this.current,
59
+ disabled: opts.disabled ?? false,
60
+ ...opts.name !== void 0 ? { name: opts.name } : {},
61
+ ...opts.required !== void 0 ? { required: opts.required } : {}
62
+ },
63
+ (service) => this.render(service)
64
+ );
65
+ this.release = ownTeardown(this.el, () => this.machine.stop());
66
+ this.input.addEventListener("change", () => {
67
+ this.current = this.input.checked;
68
+ opts.onCheckedChange?.(this.current);
69
+ opts.onChange?.(this.current);
70
+ });
71
+ this.el.addEventListener("pointerdown", (e) => {
72
+ if (opts.disabled) return;
73
+ e.preventDefault();
74
+ this.input.focus({ preventScroll: true });
75
+ });
76
+ }
77
+ get checked() {
78
+ return this.current;
79
+ }
80
+ setChecked(v) {
81
+ if (v === this.current) return;
82
+ this.current = v;
83
+ this.api().setChecked(v);
84
+ }
85
+ destroy() {
86
+ this.release();
87
+ }
88
+ api() {
89
+ return zagSwitch.connect(this.machine.service, normalizeProps);
90
+ }
91
+ render(service) {
92
+ const api = zagSwitch.connect(service, normalizeProps);
93
+ spreadProps(this.el, api.getRootProps(), this.mid);
94
+ spreadProps(this.input, api.getHiddenInputProps(), this.mid);
95
+ }
96
+ };
97
+ function createCheckbox(props = {}) {
98
+ return new Checkbox(props);
99
+ }
100
+
101
+ export { Checkbox, checkboxController, checkboxDef, checkboxVariants, createCheckbox };