@luxalgo/vela-ui 0.0.0-stage → 0.2.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 (269) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +28 -0
  4. package/README.md +86 -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 +55 -0
  12. package/dist/button.js +11 -0
  13. package/dist/calendar.d.ts +24 -0
  14. package/dist/calendar.js +1 -0
  15. package/dist/callout-bubble.d.ts +103 -0
  16. package/dist/callout-bubble.js +177 -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-3Q32K4PE.js +85 -0
  23. package/dist/chunk-6QCILIT2.js +52 -0
  24. package/dist/chunk-7VMN7NKJ.js +133 -0
  25. package/dist/chunk-A2FJ7Y7D.js +55 -0
  26. package/dist/chunk-A72NWYNP.js +26 -0
  27. package/dist/chunk-B5ZSRUDQ.js +227 -0
  28. package/dist/chunk-BXMWQIBO.js +66 -0
  29. package/dist/chunk-C3ICYMI3.js +25 -0
  30. package/dist/chunk-CC3DDNFC.js +117 -0
  31. package/dist/chunk-E2FE6V2N.js +81 -0
  32. package/dist/chunk-FN2BUFNM.js +10 -0
  33. package/dist/chunk-FVH6L7FM.js +18 -0
  34. package/dist/chunk-G7IQLY3A.js +183 -0
  35. package/dist/chunk-GVRX3UAV.js +82 -0
  36. package/dist/chunk-J2QJATCD.js +12 -0
  37. package/dist/chunk-LZWZV2ZS.js +18 -0
  38. package/dist/chunk-MJ4RUGX7.js +403 -0
  39. package/dist/chunk-MMTMOV6R.js +31 -0
  40. package/dist/chunk-P4MTEMT7.js +23 -0
  41. package/dist/chunk-Q6WTDVH6.js +31 -0
  42. package/dist/chunk-S7USVSYP.js +50 -0
  43. package/dist/chunk-TAKSIV57.js +90 -0
  44. package/dist/chunk-U3EH42YY.js +72 -0
  45. package/dist/chunk-V2Q4MRMS.js +573 -0
  46. package/dist/chunk-VMCR3S2A.js +22 -0
  47. package/dist/chunk-WBGSYCV2.js +101 -0
  48. package/dist/chunk-WGULXRWD.js +351 -0
  49. package/dist/chunk-WXH3EFV5.js +219 -0
  50. package/dist/chunk-X66RJAIS.js +14 -0
  51. package/dist/chunk-XBEL4K33.js +142 -0
  52. package/dist/chunk-Z5PINFQO.js +280 -0
  53. package/dist/collapsible.d.ts +49 -0
  54. package/dist/collapsible.js +106 -0
  55. package/dist/color-picker.d.ts +103 -0
  56. package/dist/color-picker.js +19 -0
  57. package/dist/color.d.ts +24 -0
  58. package/dist/color.js +1 -0
  59. package/dist/context-menu.d.ts +72 -0
  60. package/dist/context-menu.js +161 -0
  61. package/dist/css.d.ts +17 -0
  62. package/dist/css.js +4 -0
  63. package/dist/data-table.d.ts +40 -0
  64. package/dist/data-table.js +88 -0
  65. package/dist/date-picker.d.ts +90 -0
  66. package/dist/date-picker.js +257 -0
  67. package/dist/define-D5u3F5Dj.d.ts +21 -0
  68. package/dist/dialog.d.ts +89 -0
  69. package/dist/dialog.js +258 -0
  70. package/dist/dispose.d.ts +9 -0
  71. package/dist/dispose.js +2 -0
  72. package/dist/donut.d.ts +27 -0
  73. package/dist/donut.js +67 -0
  74. package/dist/drawer.d.ts +119 -0
  75. package/dist/drawer.js +326 -0
  76. package/dist/dropdown-menu.d.ts +114 -0
  77. package/dist/dropdown-menu.js +18 -0
  78. package/dist/empty.d.ts +21 -0
  79. package/dist/empty.js +38 -0
  80. package/dist/field.d.ts +147 -0
  81. package/dist/field.js +328 -0
  82. package/dist/glyph-select.d.ts +57 -0
  83. package/dist/glyph-select.js +17 -0
  84. package/dist/h-Bl37qUis.d.ts +24 -0
  85. package/dist/headless.d.ts +6 -0
  86. package/dist/headless.js +9 -0
  87. package/dist/hover-card.d.ts +43 -0
  88. package/dist/hover-card.js +97 -0
  89. package/dist/i18n.d.ts +20 -0
  90. package/dist/i18n.js +1 -0
  91. package/dist/icons.d.ts +20 -0
  92. package/dist/icons.js +2 -0
  93. package/dist/index.d.ts +51 -0
  94. package/dist/index.js +13 -0
  95. package/dist/input-group.d.ts +57 -0
  96. package/dist/input-group.js +87 -0
  97. package/dist/input.d.ts +54 -0
  98. package/dist/input.js +9 -0
  99. package/dist/item.d.ts +72 -0
  100. package/dist/item.js +131 -0
  101. package/dist/kbd.d.ts +19 -0
  102. package/dist/kbd.js +8 -0
  103. package/dist/kit-text.d.ts +8 -0
  104. package/dist/kit-text.js +2 -0
  105. package/dist/line-chart.d.ts +32 -0
  106. package/dist/line-chart.js +120 -0
  107. package/dist/manifest.json +4508 -0
  108. package/dist/month-grid.d.ts +45 -0
  109. package/dist/month-grid.js +157 -0
  110. package/dist/number-input.d.ts +99 -0
  111. package/dist/number-input.js +14 -0
  112. package/dist/page.d.ts +7 -0
  113. package/dist/page.js +1 -0
  114. package/dist/palette.d.ts +55 -0
  115. package/dist/palette.js +1 -0
  116. package/dist/placement.d.ts +98 -0
  117. package/dist/placement.js +1 -0
  118. package/dist/popover.d.ts +107 -0
  119. package/dist/popover.js +15 -0
  120. package/dist/scatter-chart.d.ts +32 -0
  121. package/dist/scatter-chart.js +121 -0
  122. package/dist/select.d.ts +112 -0
  123. package/dist/select.js +19 -0
  124. package/dist/slider.d.ts +46 -0
  125. package/dist/slider.js +111 -0
  126. package/dist/sort-button.d.ts +41 -0
  127. package/dist/sort-button.js +88 -0
  128. package/dist/sparkline.d.ts +22 -0
  129. package/dist/sparkline.js +72 -0
  130. package/dist/stat.d.ts +29 -0
  131. package/dist/stat.js +41 -0
  132. package/dist/styles.d.ts +22 -0
  133. package/dist/styles.js +2 -0
  134. package/dist/surface-events.d.ts +17 -0
  135. package/dist/surface-events.js +1 -0
  136. package/dist/surface-exit.d.ts +25 -0
  137. package/dist/surface-exit.js +1 -0
  138. package/dist/switch.d.ts +54 -0
  139. package/dist/switch.js +92 -0
  140. package/dist/t.d.ts +89 -0
  141. package/dist/t.js +1 -0
  142. package/dist/tabs.d.ts +65 -0
  143. package/dist/tabs.js +155 -0
  144. package/dist/text-area.d.ts +54 -0
  145. package/dist/text-area.js +9 -0
  146. package/dist/theme.d.ts +199 -0
  147. package/dist/theme.js +8 -0
  148. package/dist/theme.schema.json +1994 -0
  149. package/dist/themes/dark.css +3 -0
  150. package/dist/themes/light.css +3 -0
  151. package/dist/toggle-group.d.ts +56 -0
  152. package/dist/toggle-group.js +130 -0
  153. package/dist/tokens.d.ts +16 -0
  154. package/dist/tokens.js +3 -0
  155. package/dist/tooltip.d.ts +47 -0
  156. package/dist/tooltip.js +74 -0
  157. package/dist/variants-B4stUBnY.d.ts +16 -0
  158. package/dist/zag.d.ts +19 -0
  159. package/dist/zag.js +2 -0
  160. package/docs/theming.md +217 -0
  161. package/docs/what-to-change.md +20 -0
  162. package/docs/writing-a-component.md +250 -0
  163. package/llms.txt +71 -0
  164. package/package.json +90 -6
  165. package/registry/badge.ts +119 -0
  166. package/registry/bar-chart.ts +215 -0
  167. package/registry/button.ts +379 -0
  168. package/registry/callout-bubble.ts +347 -0
  169. package/registry/checkbox.ts +234 -0
  170. package/registry/collapsible.ts +271 -0
  171. package/registry/color-picker.ts +582 -0
  172. package/registry/context-menu.ts +208 -0
  173. package/registry/data-table.ts +215 -0
  174. package/registry/date-picker.ts +483 -0
  175. package/registry/dialog.ts +535 -0
  176. package/registry/donut.ts +145 -0
  177. package/registry/drawer.ts +636 -0
  178. package/registry/dropdown-menu.ts +762 -0
  179. package/registry/empty.ts +91 -0
  180. package/registry/field.ts +585 -0
  181. package/registry/glyph-select.ts +268 -0
  182. package/registry/hover-card.ts +222 -0
  183. package/registry/input-group.ts +229 -0
  184. package/registry/input.ts +181 -0
  185. package/registry/item.ts +376 -0
  186. package/registry/kbd.ts +64 -0
  187. package/registry/line-chart.ts +218 -0
  188. package/registry/month-grid.ts +328 -0
  189. package/registry/number-input.ts +443 -0
  190. package/registry/popover.ts +368 -0
  191. package/registry/scatter-chart.ts +221 -0
  192. package/registry/select.ts +620 -0
  193. package/registry/slider.ts +259 -0
  194. package/registry/sort-button.ts +189 -0
  195. package/registry/sparkline.ts +114 -0
  196. package/registry/stat.ts +96 -0
  197. package/registry/switch.ts +205 -0
  198. package/registry/tabs.ts +426 -0
  199. package/registry/text-area.ts +186 -0
  200. package/registry/toggle-group.ts +295 -0
  201. package/registry/tooltip.ts +156 -0
  202. package/skills/theming-vela-ui/SKILL.md +137 -0
  203. package/skills/using-vela-ui-components/SKILL.md +137 -0
  204. package/skills/writing-vela-ui-components/SKILL.md +163 -0
  205. package/src/components/badge.ts +119 -0
  206. package/src/components/bar-chart.ts +215 -0
  207. package/src/components/button.ts +379 -0
  208. package/src/components/callout-bubble.ts +347 -0
  209. package/src/components/checkbox.ts +234 -0
  210. package/src/components/collapsible.ts +271 -0
  211. package/src/components/color-picker.ts +582 -0
  212. package/src/components/context-menu.ts +208 -0
  213. package/src/components/data-table.ts +215 -0
  214. package/src/components/date-picker.ts +483 -0
  215. package/src/components/dialog.ts +535 -0
  216. package/src/components/donut.ts +145 -0
  217. package/src/components/drawer.ts +636 -0
  218. package/src/components/dropdown-menu.ts +762 -0
  219. package/src/components/empty.ts +91 -0
  220. package/src/components/field.ts +585 -0
  221. package/src/components/glyph-select.ts +268 -0
  222. package/src/components/hover-card.ts +222 -0
  223. package/src/components/input-group.ts +229 -0
  224. package/src/components/input.ts +181 -0
  225. package/src/components/item.ts +376 -0
  226. package/src/components/kbd.ts +64 -0
  227. package/src/components/line-chart.ts +218 -0
  228. package/src/components/month-grid.ts +328 -0
  229. package/src/components/number-input.ts +443 -0
  230. package/src/components/popover.ts +368 -0
  231. package/src/components/scatter-chart.ts +221 -0
  232. package/src/components/select.ts +620 -0
  233. package/src/components/slider.ts +259 -0
  234. package/src/components/sort-button.ts +189 -0
  235. package/src/components/sparkline.ts +114 -0
  236. package/src/components/stat.ts +96 -0
  237. package/src/components/switch.ts +205 -0
  238. package/src/components/tabs.ts +426 -0
  239. package/src/components/text-area.ts +186 -0
  240. package/src/components/toggle-group.ts +295 -0
  241. package/src/components/tooltip.ts +156 -0
  242. package/src/index.ts +24 -0
  243. package/src/lib/calendar.ts +117 -0
  244. package/src/lib/chart.ts +72 -0
  245. package/src/lib/color.ts +89 -0
  246. package/src/lib/component-index.ts +151 -0
  247. package/src/lib/css.ts +48 -0
  248. package/src/lib/define.ts +45 -0
  249. package/src/lib/dispose.ts +36 -0
  250. package/src/lib/h.ts +55 -0
  251. package/src/lib/headless.ts +16 -0
  252. package/src/lib/i18n.ts +30 -0
  253. package/src/lib/icons.ts +237 -0
  254. package/src/lib/kit-text.ts +26 -0
  255. package/src/lib/page.ts +24 -0
  256. package/src/lib/palette.ts +81 -0
  257. package/src/lib/placement.ts +188 -0
  258. package/src/lib/scope.ts +135 -0
  259. package/src/lib/styles.ts +53 -0
  260. package/src/lib/surface-events.ts +31 -0
  261. package/src/lib/surface-exit.ts +87 -0
  262. package/src/lib/t.ts +68 -0
  263. package/src/lib/theme.ts +664 -0
  264. package/src/lib/tokens.ts +111 -0
  265. package/src/lib/variants.ts +32 -0
  266. package/src/lib/zag.ts +46 -0
  267. package/stylelint/index.mjs +60 -0
  268. package/stylelint/lint.mjs +81 -0
  269. package/stylelint/plugin.mjs +115 -0
@@ -0,0 +1,403 @@
1
+ import { kitTranslator } from './chunk-FVH6L7FM.js';
2
+ import { msg, textOf } from './chunk-FN2BUFNM.js';
3
+ import { openPopoverTrigger, closeOpenPopovers, Popover } from './chunk-B5ZSRUDQ.js';
4
+ import { ACCENT_BRIGHT, ACCENT, BULLISH, BEARISH, WARNING, NEUTRAL } from './chunk-MMTMOV6R.js';
5
+ import { ownTeardown, disposeWithin } from './chunk-A72NWYNP.js';
6
+ import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-P4MTEMT7.js';
7
+ import { h } from './chunk-Q6WTDVH6.js';
8
+ import { defineComponent } from './chunk-VMCR3S2A.js';
9
+ import { defineStyles, css } from './chunk-XBEL4K33.js';
10
+ import { t } from './chunk-6QCILIT2.js';
11
+ import * as zagSlider from '@zag-js/slider';
12
+
13
+ function splitColor(color) {
14
+ const s = String(color ?? "").trim();
15
+ let m = /^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(s);
16
+ if (m) return { hex6: `#${m[1].toLowerCase()}`, alpha: m[2] ? parseInt(m[2], 16) / 255 : 1 };
17
+ m = /^#([0-9a-f]{3})$/i.exec(s);
18
+ if (m) {
19
+ const x = m[1].toLowerCase();
20
+ return { hex6: `#${x[0]}${x[0]}${x[1]}${x[1]}${x[2]}${x[2]}`, alpha: 1 };
21
+ }
22
+ const rgba = /^rgba?\(([^)]+)\)/i.exec(s);
23
+ if (rgba) {
24
+ const p = rgba[1].split(",").map((v) => v.trim());
25
+ const hx = (n) => Math.max(0, Math.min(255, Math.round(n))).toString(16).padStart(2, "0");
26
+ const a = p[3] != null ? Math.max(0, Math.min(1, parseFloat(p[3]))) : 1;
27
+ return { hex6: `#${hx(parseInt(p[0] ?? "0", 10))}${hx(parseInt(p[1] ?? "0", 10))}${hx(parseInt(p[2] ?? "0", 10))}`, alpha: a };
28
+ }
29
+ return { hex6: ACCENT_BRIGHT, alpha: 1 };
30
+ }
31
+ function combineColor(hex6, alpha) {
32
+ const a = Math.max(0, Math.min(1, alpha));
33
+ if (a >= 0.999) return hex6;
34
+ return `${hex6}${Math.round(a * 255).toString(16).padStart(2, "0")}`;
35
+ }
36
+ function blendOver(fg, bg, alpha) {
37
+ const rgb = (c) => {
38
+ const n = parseInt(splitColor(c).hex6.slice(1), 16);
39
+ return [n >> 16 & 255, n >> 8 & 255, n & 255];
40
+ };
41
+ const [fr, fgc, fb] = rgb(fg);
42
+ const [br, bgc, bb] = rgb(bg);
43
+ const a = Math.max(0, Math.min(1, alpha));
44
+ const hx = (n) => Math.round(n).toString(16).padStart(2, "0");
45
+ return `#${hx(fr * a + br * (1 - a))}${hx(fgc * a + bgc * (1 - a))}${hx(fb * a + bb * (1 - a))}`;
46
+ }
47
+ function hslHex(hue, s, l) {
48
+ const sn = s / 100;
49
+ const ln = l / 100;
50
+ const k = (n) => (n + hue / 30) % 12;
51
+ const a = sn * Math.min(ln, 1 - ln);
52
+ const f = (n) => ln - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
53
+ const to = (x) => Math.round(x * 255).toString(16).padStart(2, "0");
54
+ return `#${to(f(0))}${to(f(8))}${to(f(4))}`;
55
+ }
56
+ function buildPalette() {
57
+ const grays = [100, 90, 80, 68, 56, 45, 35, 25, 14, 0].map((l) => hslHex(0, 0, l));
58
+ const hues = [4, 28, 50, 96, 140, 174, 200, 224, 270, 322];
59
+ const levels = [
60
+ [82, 56],
61
+ [58, 84],
62
+ [62, 74],
63
+ [66, 62],
64
+ [70, 50],
65
+ [64, 39],
66
+ [54, 29]
67
+ ];
68
+ return [grays, ...levels.map(([s, l]) => hues.map((hue) => hslHex(hue, s, l)))];
69
+ }
70
+ function transparencyChecker(size) {
71
+ return `repeating-conic-gradient(#9aa0a6 0% 25%, #d3d6da 0% 50%) 0 0 / ${size}px ${size}px`;
72
+ }
73
+ function colorPickerController(opts = {}) {
74
+ const parsed = splitColor(opts.color ?? ACCENT_BRIGHT);
75
+ let hex6 = parsed.hex6;
76
+ let alpha = parsed.alpha;
77
+ return {
78
+ get hex6() {
79
+ return hex6;
80
+ },
81
+ get alpha() {
82
+ return alpha;
83
+ },
84
+ combined() {
85
+ return combineColor(hex6, alpha);
86
+ },
87
+ setHex(hex) {
88
+ hex6 = splitColor(hex).hex6;
89
+ },
90
+ setAlpha(a) {
91
+ alpha = Math.max(0, Math.min(1, a));
92
+ }
93
+ };
94
+ }
95
+ var colorPickerDef = defineComponent({
96
+ name: "color-picker",
97
+ parts: ["root", "trigger", "swatch", "content"],
98
+ settings: {
99
+ "swatch-ring": "inset 0 0 0 1px rgba(0, 0, 0, 0.25)",
100
+ "circle-swatch-radius": "2px",
101
+ "content-radius": t.radius.lg
102
+ }
103
+ });
104
+ var TEXT = {
105
+ opacity: msg("ui.colorPicker.opacity", "Opacity"),
106
+ opacityPercent: msg("ui.colorPicker.opacityPercent", "Opacity (%)")
107
+ };
108
+ var PALETTE = buildPalette();
109
+ var CHECKER = transparencyChecker(10);
110
+ var FIELD_CHECKER = transparencyChecker(8);
111
+ var recents = [ACCENT, BULLISH, BEARISH, WARNING, NEUTRAL];
112
+ function addRecent(hex6) {
113
+ const i = recents.findIndex((c) => c.toLowerCase() === hex6.toLowerCase());
114
+ if (i >= 0) recents.splice(i, 1);
115
+ recents.unshift(hex6);
116
+ if (recents.length > 10) recents.length = 10;
117
+ }
118
+ var injectStyles = defineStyles(
119
+ "vela-ui-color",
120
+ css`@layer vela.ui{[data-slot=color-picker-swatch]{width:100%;height:100%;box-shadow:${colorPickerDef.vars["swatch-ring"]};border-radius:0;display:block}[data-slot=color-picker-trigger]{border:1px solid ${t.border};background:${t.surface.sunken};cursor:pointer;border-radius:0;flex:none;width:24px;height:24px;padding:2px}[data-slot=color-picker-trigger]:where(:not([hidden])){display:inline-flex}[data-slot=color-picker-trigger]:where([data-shape=circle]){border:1px solid ${t.border.strong};border-radius:${t.radius.sm};background:0 0;width:26px;height:26px;padding:3px;overflow:hidden}[data-slot=color-picker-trigger]:hover{border-color:${t.fg.muted}}[data-slot=color-picker-trigger]:where([data-shape=circle]) [data-slot=color-picker-swatch]{border-radius:${colorPickerDef.vars["circle-swatch-radius"]};box-shadow:none}[data-slot~=color-picker-content]{background:${t.surface.overlay};border:1px solid ${t.border};border-radius:${colorPickerDef.vars["content-radius"]};box-shadow:${t.shadow};padding:10px}}`
121
+ );
122
+ function buildColorPicker(color, theme, onChange, options = {}) {
123
+ const commit = options.commit ?? "live";
124
+ const i18n = options.i18n ?? kitTranslator();
125
+ const parsed = splitColor(color);
126
+ let curHex = parsed.hex6;
127
+ let curAlpha = parsed.alpha;
128
+ const root = document.createElement("div");
129
+ root.dataset.slot = colorPickerDef.slot("root");
130
+ root.style.cssText = "display:flex;flex-direction:column;gap:9px;width:236px;";
131
+ const grid = document.createElement("div");
132
+ grid.style.cssText = "display:grid;grid-template-columns:repeat(10,1fr);gap:4px;";
133
+ const swatches = [];
134
+ for (const row of PALETTE) {
135
+ for (const c of row) {
136
+ const sw = document.createElement("button");
137
+ sw.type = "button";
138
+ sw.dataset.c = c;
139
+ sw.setAttribute("aria-label", c);
140
+ sw.style.cssText = `width:100%;aspect-ratio:1;border-radius:4px;border:none;cursor:pointer;background:${c};padding:0;`;
141
+ sw.addEventListener("click", (e) => {
142
+ e.stopPropagation();
143
+ pickHex(c);
144
+ });
145
+ grid.appendChild(sw);
146
+ swatches.push(sw);
147
+ }
148
+ }
149
+ const paintSelection = () => {
150
+ for (const sw of swatches) {
151
+ const on = (sw.dataset.c ?? "").toLowerCase() === curHex.toLowerCase();
152
+ sw.setAttribute("aria-pressed", String(on));
153
+ sw.style.outline = on ? `2px solid ${theme.textColor}` : "none";
154
+ sw.style.outlineOffset = "2px";
155
+ sw.style.zIndex = on ? "1" : "";
156
+ sw.style.position = on ? "relative" : "";
157
+ }
158
+ };
159
+ const recentRow = document.createElement("div");
160
+ recentRow.style.cssText = "display:flex;align-items:center;gap:5px;flex-wrap:wrap;border-top:1px solid var(--vela-border);padding-top:9px;";
161
+ const recentSwatches = document.createElement("div");
162
+ recentSwatches.style.cssText = "display:contents;";
163
+ const add = document.createElement("label");
164
+ add.style.cssText = `width:17px;height:17px;border-radius:var(--vela-radius-sm);border:1px dashed var(--vela-border-strong);cursor:pointer;display:flex;align-items:center;justify-content:center;color:${theme.textColor};font:14px ${theme.fontFamily};position:relative;`;
165
+ add.textContent = "+";
166
+ const customInput = document.createElement("input");
167
+ customInput.type = "color";
168
+ customInput.value = curHex;
169
+ customInput.style.cssText = "position:absolute;inset:0;opacity:0;cursor:pointer;";
170
+ customInput.addEventListener("input", () => previewHex(customInput.value));
171
+ customInput.addEventListener("change", () => pickHex(customInput.value, true));
172
+ add.appendChild(customInput);
173
+ recentRow.append(recentSwatches, add);
174
+ const renderRecents = () => {
175
+ recentSwatches.replaceChildren();
176
+ for (const c of recents) {
177
+ const sw = document.createElement("button");
178
+ sw.type = "button";
179
+ sw.setAttribute("aria-label", c);
180
+ sw.style.cssText = `width:17px;height:17px;border-radius:var(--vela-radius-sm);border:1px solid var(--vela-border);cursor:pointer;background:${c};padding:0;`;
181
+ sw.addEventListener("click", (e) => {
182
+ e.stopPropagation();
183
+ pickHex(c);
184
+ });
185
+ recentSwatches.appendChild(sw);
186
+ }
187
+ };
188
+ const opLabel = document.createElement("div");
189
+ opLabel.textContent = textOf(i18n, TEXT.opacity);
190
+ opLabel.style.cssText = `font:11px ${theme.fontFamily};color:var(--vela-fg-muted);`;
191
+ const opRow = document.createElement("div");
192
+ opRow.style.cssText = "display:flex;align-items:center;gap:10px;";
193
+ const track = document.createElement("div");
194
+ track.style.cssText = "flex:1;position:relative;height:13px;border-radius:7px;cursor:pointer;";
195
+ const knob = document.createElement("div");
196
+ knob.style.cssText = "position:absolute;top:50%;width:15px;height:15px;border-radius:50%;background:var(--vela-selected-bg);box-shadow:0 1px 3px rgba(0,0,0,0.55);transform:translate(-50%,-50%);pointer-events:none;";
197
+ track.appendChild(knob);
198
+ const pctBox = document.createElement("input");
199
+ pctBox.type = "text";
200
+ pctBox.inputMode = "numeric";
201
+ pctBox.title = textOf(i18n, TEXT.opacityPercent);
202
+ pctBox.style.cssText = `width:46px;box-sizing:border-box;text-align:center;font:var(--vela-font-size-md) ${theme.fontFamily};color:var(--vela-fg);background:transparent;border:1px solid var(--vela-border);border-radius:5px;padding:3px 4px;outline:none;`;
203
+ pctBox.addEventListener("focus", () => {
204
+ pctBox.style.borderColor = "var(--vela-border-strong)";
205
+ pctBox.select();
206
+ });
207
+ opRow.append(track, pctBox);
208
+ const paintOpacity = () => {
209
+ track.style.background = `linear-gradient(to right, ${curHex}00, ${curHex}ff), ${CHECKER}`;
210
+ knob.style.left = `${curAlpha * 100}%`;
211
+ pctBox.value = `${Math.round(curAlpha * 100)}%`;
212
+ };
213
+ const commitTyped = () => {
214
+ pctBox.style.borderColor = "var(--vela-border)";
215
+ const n = parseFloat(pctBox.value.replace("%", ""));
216
+ if (Number.isFinite(n)) {
217
+ const next = Math.max(0, Math.min(100, n)) / 100;
218
+ if (Math.round(next * 100) !== Math.round(curAlpha * 100)) {
219
+ curAlpha = next;
220
+ paintOpacity();
221
+ emit();
222
+ zagSlider.connect(slider.service, normalizeProps).setValue([next]);
223
+ return;
224
+ }
225
+ }
226
+ paintOpacity();
227
+ };
228
+ pctBox.addEventListener("change", commitTyped);
229
+ pctBox.addEventListener("blur", () => {
230
+ pctBox.style.borderColor = "var(--vela-border)";
231
+ paintOpacity();
232
+ });
233
+ pctBox.addEventListener("keydown", (e) => {
234
+ if (e.key === "Escape") return;
235
+ e.stopPropagation();
236
+ if (e.key === "Enter") {
237
+ e.preventDefault();
238
+ commitTyped();
239
+ pctBox.blur();
240
+ }
241
+ });
242
+ const pct = (a) => Math.round(a * 100);
243
+ const sliderId = nextUid("vela-color-opacity");
244
+ let pressed = false;
245
+ const slider = runMachine(
246
+ zagSlider.machine,
247
+ {
248
+ id: sliderId,
249
+ min: 0,
250
+ max: 1,
251
+ step: 0.01,
252
+ defaultValue: [curAlpha],
253
+ thumbAlignment: "center",
254
+ "aria-label": [textOf(i18n, TEXT.opacity)],
255
+ getAriaValueText: ({ value }) => `${pct(value)}%`,
256
+ onValueChange: ({ value: [a] }) => {
257
+ if (a === void 0 || pct(a) === pct(curAlpha)) return;
258
+ curAlpha = a;
259
+ paintOpacity();
260
+ if (commit === "live") emit();
261
+ },
262
+ onValueChangeEnd: ({ value: [a] }) => {
263
+ if (commit !== "release" || !pressed) return;
264
+ pressed = false;
265
+ if (a !== void 0 && pct(a) !== pct(curAlpha)) {
266
+ curAlpha = a;
267
+ paintOpacity();
268
+ }
269
+ emit();
270
+ }
271
+ },
272
+ (service) => {
273
+ const api = zagSlider.connect(service, normalizeProps);
274
+ const own = (props) => {
275
+ const { style: _style, ...rest } = props;
276
+ return rest;
277
+ };
278
+ spreadProps(opRow, own(api.getRootProps()), sliderId);
279
+ spreadProps(track, own(api.getControlProps()), sliderId);
280
+ spreadProps(knob, own(api.getThumbProps({ index: 0 })), sliderId);
281
+ }
282
+ );
283
+ ownTeardown(root, () => slider.stop());
284
+ track.addEventListener("pointerdown", (e) => {
285
+ e.stopPropagation();
286
+ pressed = true;
287
+ });
288
+ knob.addEventListener("keydown", () => {
289
+ pressed = true;
290
+ });
291
+ function emit() {
292
+ onChange(combineColor(curHex, curAlpha));
293
+ }
294
+ function previewHex(hex) {
295
+ curHex = splitColor(hex).hex6;
296
+ paintSelection();
297
+ paintOpacity();
298
+ emit();
299
+ }
300
+ function pickHex(hex, custom = false) {
301
+ previewHex(hex);
302
+ addRecent(curHex);
303
+ customInput.value = curHex;
304
+ if (custom) renderRecents();
305
+ }
306
+ renderRecents();
307
+ paintSelection();
308
+ paintOpacity();
309
+ root.append(grid, recentRow, opLabel, opRow);
310
+ return root;
311
+ }
312
+ function colorField(theme, getVal, onVal, opts) {
313
+ return new ColorField({ ...opts, theme, getVal, onVal }).el;
314
+ }
315
+ var ColorField = class {
316
+ constructor(opts) {
317
+ injectStyles(document);
318
+ this.theme = opts.theme;
319
+ this.getVal = opts.getVal;
320
+ this.onVal = opts.onVal;
321
+ this.popoverOpts = opts.popover;
322
+ this.placement = opts;
323
+ this.commit = opts.commit;
324
+ this.i18n = opts.i18n ?? kitTranslator();
325
+ const circle = opts.shape === "circle";
326
+ const swatch = h("span", { className: "vela-color-field-swatch", slot: colorPickerDef.slot("swatch") });
327
+ const trigger = h(
328
+ "button",
329
+ {
330
+ className: circle ? "vela-color-field vela-color-field-circle" : "vela-color-field",
331
+ slot: colorPickerDef.slot("trigger"),
332
+ attrs: { type: "button", id: opts.id },
333
+ data: { shape: opts.shape ?? "square" }
334
+ },
335
+ swatch
336
+ );
337
+ this.el = trigger;
338
+ this.swatch = swatch;
339
+ this.paint();
340
+ trigger.addEventListener("vela-sync", () => this.paint());
341
+ trigger.addEventListener("pointerdown", (e) => {
342
+ e.preventDefault();
343
+ trigger.focus({ preventScroll: true });
344
+ });
345
+ trigger.addEventListener("click", (e) => {
346
+ e.stopPropagation();
347
+ this.toggle();
348
+ });
349
+ this.release = ownTeardown(trigger, () => {
350
+ if (openPopoverTrigger() === trigger) closeOpenPopovers();
351
+ });
352
+ }
353
+ destroy() {
354
+ this.release();
355
+ }
356
+ paint() {
357
+ const v = this.getVal();
358
+ this.swatch.style.background = `linear-gradient(${v}, ${v}), ${FIELD_CHECKER}`;
359
+ }
360
+ toggle() {
361
+ if (openPopoverTrigger() === this.el) {
362
+ closeOpenPopovers();
363
+ return;
364
+ }
365
+ const content = buildColorPicker(
366
+ this.getVal(),
367
+ this.theme,
368
+ (val) => {
369
+ this.onVal(val);
370
+ this.paint();
371
+ },
372
+ { commit: this.commit, i18n: this.i18n }
373
+ );
374
+ const pop = new Popover({
375
+ trigger: this.el,
376
+ theme: this.theme,
377
+ side: this.placement.side,
378
+ align: this.placement.align ?? this.popoverOpts?.align ?? "end",
379
+ sideOffset: this.placement.sideOffset ?? this.popoverOpts?.gap ?? 6,
380
+ alignOffset: this.placement.alignOffset,
381
+ avoidCollisions: this.placement.avoidCollisions,
382
+ collisionPadding: this.placement.collisionPadding,
383
+ host: this.popoverOpts?.host,
384
+ position: this.popoverOpts?.position,
385
+ collisionBoundary: this.placement.collisionBoundary ?? this.popoverOpts?.boundary,
386
+ zIndex: this.popoverOpts?.zIndex,
387
+ className: "vela-color-field-pop",
388
+ slot: colorPickerDef.slot("content"),
389
+ content,
390
+ // A fresh popover per open: closing discards it.
391
+ onClose: () => disposeWithin(content)
392
+ });
393
+ pop.show();
394
+ }
395
+ };
396
+ function createColorField(props) {
397
+ return new ColorField(props);
398
+ }
399
+ function closeColorPopover() {
400
+ closeOpenPopovers();
401
+ }
402
+
403
+ export { ColorField, blendOver, buildColorPicker, buildPalette, closeColorPopover, colorField, colorPickerController, colorPickerDef, combineColor, createColorField, hslHex, splitColor, transparencyChecker };
@@ -0,0 +1,31 @@
1
+ // src/lib/palette.ts
2
+ var ACCENT = "#2962ff";
3
+ var ACCENT_BRIGHT = "#38c0fd";
4
+ var BULLISH = "#089981";
5
+ var BEARISH = "#f23645";
6
+ var NEUTRAL = "#787b86";
7
+ var HIGHLIGHT = "#e0b400";
8
+ var WARNING = "#ff9800";
9
+ var INFO = "#5b9cf6";
10
+ var MARKER = "#ff5d00";
11
+ var VALID = "#0ecb81";
12
+ var INVALID = "#f6465d";
13
+ var SESSION_PRE = "#f97316";
14
+ var SESSION_POST = "#0ea5e9";
15
+ var SESSION_OFF = "#9ca3af";
16
+ var SERIES_LINE = "#3b82f6";
17
+ var CROSSHAIR = "#9aa0ad";
18
+ var SLATE_DEEP = "#1e293b";
19
+ var SLATE = "#475569";
20
+ var CHIP_PLATE = "#595959";
21
+ var TRADE_LONG = ACCENT;
22
+ var TRADE_SHORT = BEARISH;
23
+ var TRADE_EXIT = "#d500f9";
24
+ var CATEGORICAL = [ACCENT, BULLISH, BEARISH, WARNING, "#7e57c2", "#26a69a", INFO, "#e573b5"];
25
+ function categoricalColor(key) {
26
+ let h = 0;
27
+ for (let i = 0; i < key.length; i++) h = h * 31 + key.charCodeAt(i) >>> 0;
28
+ return CATEGORICAL[h % CATEGORICAL.length];
29
+ }
30
+
31
+ export { ACCENT, ACCENT_BRIGHT, BEARISH, BULLISH, CATEGORICAL, CHIP_PLATE, CROSSHAIR, HIGHLIGHT, INFO, INVALID, MARKER, NEUTRAL, SERIES_LINE, SESSION_OFF, SESSION_POST, SESSION_PRE, SLATE, SLATE_DEEP, TRADE_EXIT, TRADE_LONG, TRADE_SHORT, VALID, WARNING, categoricalColor };
@@ -0,0 +1,23 @@
1
+ import { pageUid } from './chunk-X66RJAIS.js';
2
+ import { VanillaMachine } from '@zag-js/vanilla';
3
+ export { normalizeProps, spreadProps } from '@zag-js/vanilla';
4
+
5
+ function runMachine(machine, props, render) {
6
+ const m = new VanillaMachine(machine, props);
7
+ const unsub = m.subscribe(render);
8
+ m.start();
9
+ render(m.service);
10
+ return {
11
+ service: m.service,
12
+ flush: () => render(m.service),
13
+ stop: () => {
14
+ unsub();
15
+ m.stop();
16
+ }
17
+ };
18
+ }
19
+ function nextUid(prefix) {
20
+ return pageUid(prefix);
21
+ }
22
+
23
+ export { nextUid, runMachine };
@@ -0,0 +1,31 @@
1
+ // src/lib/h.ts
2
+ function h(tag, props = {}, ...children) {
3
+ const el = document.createElement(tag);
4
+ if (props.className) el.className = props.className;
5
+ if (props.slot) el.setAttribute("data-slot", props.slot);
6
+ if (props.data) for (const [k, v] of Object.entries(props.data)) setAttr(el, `data-${k}`, v);
7
+ if (props.attrs) for (const [k, v] of Object.entries(props.attrs)) setAttr(el, k, v);
8
+ if (props.style) el.style.cssText = props.style;
9
+ if (props.text !== void 0) el.textContent = props.text;
10
+ if (props.on) for (const [type, fn] of Object.entries(props.on)) el.addEventListener(type, fn);
11
+ append(el, children);
12
+ return el;
13
+ }
14
+ function append(el, children) {
15
+ for (const c of children) {
16
+ if (c == null || c === false) continue;
17
+ if (Array.isArray(c)) append(el, c);
18
+ else if (typeof c === "string" || typeof c === "number") el.appendChild(document.createTextNode(String(c)));
19
+ else el.appendChild(c);
20
+ }
21
+ }
22
+ function addSlot(el, slot) {
23
+ const slots = (el.getAttribute("data-slot") ?? "").split(" ").filter(Boolean);
24
+ if (!slots.includes(slot)) el.setAttribute("data-slot", [...slots, slot].join(" "));
25
+ }
26
+ function setAttr(el, name, v) {
27
+ if (v == null || v === false) el.removeAttribute(name);
28
+ else el.setAttribute(name, v === true ? "" : String(v));
29
+ }
30
+
31
+ export { addSlot, append, h };
@@ -0,0 +1,50 @@
1
+ // src/lib/surface-exit.ts
2
+ var CLOSING_ATTR = "data-closing";
3
+ var SURFACE_EXIT_CAP_MS = 1e3;
4
+ function animationsOf(els) {
5
+ return els.flatMap((el) => el.getAnimations({ subtree: true }));
6
+ }
7
+ function ends(a) {
8
+ return Number.isFinite(a.effect?.getComputedTiming().endTime ?? Number.POSITIVE_INFINITY);
9
+ }
10
+ function holdForExit(els, done, opts = {}) {
11
+ const list = Array.isArray(els) ? els : [els];
12
+ if (list.length === 0 || !list.every((el) => typeof el.getAnimations === "function")) {
13
+ done();
14
+ return null;
15
+ }
16
+ const before = new Set(animationsOf(list));
17
+ for (const el of list) el.setAttribute(CLOSING_ATTR, "");
18
+ const exit = animationsOf(list).filter((a) => !before.has(a) && ends(a));
19
+ if (exit.length === 0) {
20
+ for (const el of list) el.removeAttribute(CLOSING_ATTR);
21
+ done();
22
+ return null;
23
+ }
24
+ const frozen = [...list, ...opts.inert ?? []];
25
+ const wasInert = frozen.map((el) => el.inert);
26
+ for (const el of frozen) el.inert = true;
27
+ let settled = false;
28
+ const settle = (complete) => {
29
+ if (settled) return;
30
+ settled = true;
31
+ clearTimeout(cap);
32
+ for (const el of list) el.removeAttribute(CLOSING_ATTR);
33
+ frozen.forEach((el, i) => {
34
+ el.inert = wasInert[i];
35
+ });
36
+ if (complete) done();
37
+ };
38
+ const cap = setTimeout(() => settle(true), SURFACE_EXIT_CAP_MS);
39
+ let pending = exit.length;
40
+ const one = () => {
41
+ if (--pending === 0) settle(true);
42
+ };
43
+ for (const a of exit) a.finished.then(one, one);
44
+ return {
45
+ cancel: () => settle(false),
46
+ finish: () => settle(true)
47
+ };
48
+ }
49
+
50
+ export { SURFACE_EXIT_CAP_MS, holdForExit };
@@ -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 };