@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,351 @@
1
+ import { iconEl } from './chunk-G7IQLY3A.js';
2
+ import { kitTranslator } from './chunk-FVH6L7FM.js';
3
+ import { msg, textOf } from './chunk-FN2BUFNM.js';
4
+ import { announceSurface } from './chunk-J2QJATCD.js';
5
+ import { holdForExit } from './chunk-S7USVSYP.js';
6
+ import { floatingLayerHost } from './chunk-AJ2IYSOI.js';
7
+ import { zagPositioning, splitPlacement } from './chunk-3Q32K4PE.js';
8
+ import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-P4MTEMT7.js';
9
+ import { addSlot } from './chunk-Q6WTDVH6.js';
10
+ import { t } from './chunk-6QCILIT2.js';
11
+ import { defineComponent } from './chunk-VMCR3S2A.js';
12
+ import { defineStyles, css } from './chunk-IDA2BT7D.js';
13
+ import * as zagMenu from '@zag-js/menu';
14
+
15
+ function dropdownMenuController(opts) {
16
+ return {
17
+ machine: zagMenu.machine,
18
+ props: {
19
+ id: opts.id ?? nextUid("vela-menu"),
20
+ ids: opts.triggerId ? { trigger: opts.triggerId } : void 0,
21
+ positioning: {
22
+ ...zagPositioning(opts, opts.placement ? splitPlacement(opts.placement) : { side: "bottom", align: "start" }),
23
+ ...opts.getAnchorRect ? { getAnchorRect: () => opts.getAnchorRect() } : {}
24
+ },
25
+ onSelect: (d) => opts.onSelect?.(d.value),
26
+ onOpenChange: (d) => opts.onOpenChange?.(d.open)
27
+ },
28
+ connect: (service) => zagMenu.connect(service, normalizeProps)
29
+ };
30
+ }
31
+ var dropdownMenuDef = defineComponent({
32
+ name: "dropdown-menu",
33
+ parts: ["content", "item", "icon", "label", "hint", "mark", "badge", "star", "switch", "arrow", "separator"],
34
+ settings: { radius: t.radius.md, "switch-radius": "9px" }
35
+ });
36
+ var injectStyles = defineStyles(
37
+ "vela-ui-menu",
38
+ css`@layer vela.ui{[data-slot~=dropdown-menu-content]{background:${t.surface};color:${t.fg};border:1px solid ${t.border.strong};border-radius:${dropdownMenuDef.vars.radius};box-shadow:${t.shadow};min-width:180px;max-height:min(60vh, var(--available-height,60vh));z-index:${t.z.menu};outline:2px solid #0000;margin:0;padding:6px;font-size:13px;list-style:none;overflow-y:auto}[data-slot~=dropdown-menu-content][data-state=open]{animation:vela-menu-in ${t.dur.fast} ${t.ease}}@keyframes vela-menu-in{0%{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:translateY(0)}}[data-slot~=dropdown-menu-item]{border-radius:${t.radius.sm};cursor:pointer;-webkit-user-select:none;user-select:none;white-space:nowrap;align-items:center;gap:10px;padding:7px 10px;display:flex}[data-slot~=dropdown-menu-item][data-highlighted]{background:${t.hover}}[data-slot~=dropdown-menu-item][data-disabled]{opacity:.4;cursor:default}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-icon]{width:16px;height:16px;color:${t.fg.muted};justify-content:center;font-size:16px}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-label]{flex:auto}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-hint]{color:${t.fg.faint};font-size:${t.fontSize.sm}}[data-slot~=dropdown-menu-item][data-checked]{background:${t.hover.strong};color:${t.fg.bright}}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-mark]{flex:none;justify-content:center;align-items:center;width:14px;display:inline-flex}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-mark] [data-slot~=dropdown-menu-icon]{width:14px;height:14px;color:${t.fg.bright};font-size:14px}[data-slot~=dropdown-menu-item][data-checkmark]{color:${t.fg.bright}}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-badge]{box-sizing:border-box;border-radius:${t.radius.md};background:${t.hover};border:1px solid ${t.border};width:24px;height:24px;color:${t.fg.muted};transition:background ${t.dur.fast} ${t.ease}, border-color ${t.dur.fast} ${t.ease}, color ${t.dur.fast} ${t.ease};flex:none;justify-content:center;align-items:center;padding:3px;display:inline-flex}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-badge]:empty{background:0 0;border-color:#0000}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-badge] [data-slot~=dropdown-menu-icon]{color:inherit}[data-slot~=dropdown-menu-item][data-highlighted] [data-slot~=dropdown-menu-badge]:not(:empty){color:${t.fg.bright}}[data-slot~=dropdown-menu-item][data-checked] [data-slot~=dropdown-menu-badge]:not(:empty),[data-slot~=dropdown-menu-item][data-checkmark] [data-slot~=dropdown-menu-badge]:not(:empty){background:color-mix(in srgb, ${t.fg.bright} 83%, ${t.surface});border-color:color-mix(in srgb, ${t.fg.bright} 40%, transparent);color:${t.surface}}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-star]{border-radius:${t.radius.sm};opacity:0;width:26px;height:22px;transition:opacity ${t.dur.fast} ease, background ${t.dur.fast} ease;order:98;margin-block:-3px;margin-inline:0 -5px;padding:3px 5px}[data-slot~=dropdown-menu-item][data-highlighted] [data-slot~=dropdown-menu-star]{opacity:.55}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-star]:hover{opacity:1;background:${t.hover.strong}}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-star][data-fav]{opacity:.95;color:${t.highlight}}[data-slot~=dropdown-menu-item] [data-slot~=dropdown-menu-arrow]{width:12px;color:${t.fg.faint};flex:none;order:99;margin-inline-start:auto;font-size:11px}[data-slot~=dropdown-menu-item][data-state=open]{background:${t.hover}}[data-slot~=dropdown-menu-content][data-badges]>[data-slot~=dropdown-menu-item]{padding-block:5px;padding-inline:6px 10px}[data-slot~=dropdown-menu-switch]{border-radius:${dropdownMenuDef.vars["switch-radius"]};background:${t.surface.overlay};border:1px solid ${t.border.soft};width:34px;height:18px;transition:background ${t.dur.med} ease, border-color ${t.dur.med} ease;flex:none;order:99;margin-inline-start:auto;position:relative}[data-slot~=dropdown-menu-switch]:after{content:"";top:2px;background:${t.fg.muted};width:12px;height:12px;transition:transform ${t.dur.med} ease, background ${t.dur.med} ease;border-radius:50%;position:absolute;inset-inline-start:2px}[data-slot~=dropdown-menu-switch][data-on]{background:var(${t.accent.bright.name},${t.accent});border-color:var(${t.accent.bright.name},${t.accent})}[data-slot~=dropdown-menu-switch][data-on]:after{background:${t.bg};transform:translate(16px)}[data-slot~=dropdown-menu-separator]{background:${t.border};height:1px;margin:4px 6px}}`
39
+ );
40
+ function menuIcon(id, doc) {
41
+ const el = iconEl(id, doc);
42
+ el.dataset.slot = dropdownMenuDef.slot("icon");
43
+ return el;
44
+ }
45
+ var TEXT = {
46
+ addFavorite: msg("ui.menu.addFavorite", "Add to favorites"),
47
+ removeFavorite: msg("ui.menu.removeFavorite", "Remove from favorites")
48
+ };
49
+ var ROW_INSET_PX = 7;
50
+ var SUBMENU_GAP_PX = 4;
51
+ var Surface = class _Surface {
52
+ constructor(doc, opts) {
53
+ this.items = [];
54
+ /** Branch item id → the surface it opens. */
55
+ this.subs = /* @__PURE__ */ new Map();
56
+ /** Trigger rect captured when this level opened — the list stays put if the
57
+ * trigger then moves (favorite chips shifting the caret). */
58
+ this.pinnedAnchor = null;
59
+ /** The open state last announced — see {@link announce}. */
60
+ this.shown = false;
61
+ /** The list's exit animation after a close; a reopen cancels it. */
62
+ this.exit = null;
63
+ this.doc = doc;
64
+ this.host = opts.host;
65
+ this.onSelect = opts.onSelect;
66
+ this.onFavorite = opts.onFavorite;
67
+ this.i18n = opts.i18n;
68
+ this.checkmarks = opts.checkmarks === true;
69
+ this.iconBadges = opts.iconBadges === true;
70
+ this.positioner = doc.createElement("div");
71
+ this.positioner.className = "vela-ui-layer";
72
+ this.list = doc.createElement("ul");
73
+ this.list.className = "vela-menu";
74
+ this.list.dataset.slot = dropdownMenuDef.slot("content");
75
+ if (opts.minWidth) this.list.style.minWidth = opts.minWidth;
76
+ this.positioner.appendChild(this.list);
77
+ this.host.appendChild(this.positioner);
78
+ const trigger = opts.trigger;
79
+ this.opener = trigger ?? opts.opener ?? null;
80
+ this.ctrl = dropdownMenuController({
81
+ items: [],
82
+ id: opts.id,
83
+ ...opts.placement,
84
+ onSelect: (id) => this.onSelect(id),
85
+ getAnchorRect: () => this.pinnedAnchor,
86
+ onOpenChange: (open) => {
87
+ if (open && trigger) {
88
+ const r = trigger.getBoundingClientRect();
89
+ this.pinnedAnchor = { x: r.x, y: r.y, width: r.width, height: r.height };
90
+ } else {
91
+ this.pinnedAnchor = null;
92
+ }
93
+ opts.onOpenChange?.(open);
94
+ },
95
+ triggerId: opts.triggerId
96
+ });
97
+ if (opts.submenu) {
98
+ this.ctrl.props.positioning = {
99
+ ...this.ctrl.props.positioning,
100
+ offset: { mainAxis: ROW_INSET_PX + SUBMENU_GAP_PX },
101
+ shift: -ROW_INSET_PX
102
+ };
103
+ }
104
+ this.mid = String(this.ctrl.props.id);
105
+ if (opts.triggerId && trigger) trigger.id = opts.triggerId;
106
+ this.handle = runMachine(this.ctrl.machine, this.ctrl.props, (service) => {
107
+ const api = this.ctrl.connect(service);
108
+ const closing = this.shown && !api.open;
109
+ if (closing) this.announce(false);
110
+ if (api.open && this.exit) {
111
+ this.exit.cancel();
112
+ this.exit = null;
113
+ }
114
+ if (trigger) spreadProps(trigger, api.getTriggerProps(), this.mid);
115
+ spreadProps(this.positioner, api.getPositionerProps(), this.mid);
116
+ spreadProps(this.list, api.getContentProps(), this.mid);
117
+ this.project(api);
118
+ if (closing) this.holdExit();
119
+ if (api.open && !this.shown) this.announce(true);
120
+ });
121
+ }
122
+ /** Keep the just-closed list up through its exit animation. `spreadProps` re-applies
123
+ * `hidden` only when the machine's value for it changes, so the list stays shown until
124
+ * the exit ends — or until a reopen, which projects `hidden: false` itself. */
125
+ holdExit() {
126
+ this.list.hidden = false;
127
+ this.exit = holdForExit(this.list, () => {
128
+ this.exit = null;
129
+ if (!this.shown) this.list.hidden = true;
130
+ });
131
+ }
132
+ get api() {
133
+ return this.ctrl.connect(this.handle.service);
134
+ }
135
+ announce(open) {
136
+ this.shown = open;
137
+ announceSurface(this.list, open, "menu", this.opener);
138
+ }
139
+ setItems(items) {
140
+ this.items = items;
141
+ for (const sub of this.subs.values()) sub.destroy();
142
+ this.subs.clear();
143
+ this.build();
144
+ const api = this.api;
145
+ for (const sub of this.subs.values()) {
146
+ api.setChild(sub.handle.service);
147
+ sub.api.setParent(this.handle.service);
148
+ }
149
+ this.handle.flush();
150
+ if (this.subs.size > 0) queueMicrotask(() => this.handle.flush());
151
+ }
152
+ destroy() {
153
+ for (const sub of this.subs.values()) sub.destroy();
154
+ this.subs.clear();
155
+ this.exit?.finish();
156
+ this.handle.stop();
157
+ if (this.shown) this.announce(false);
158
+ this.positioner.remove();
159
+ }
160
+ byId(id) {
161
+ return this.items.find((i) => i.id === id);
162
+ }
163
+ /** Push the machine's item props onto the rendered rows. A branch takes the submenu
164
+ * trigger props, which carry the child's ids and hover handlers; a leaf takes plain ones. */
165
+ project(api) {
166
+ for (const li of this.list.children) {
167
+ const id = li.dataset.veiId;
168
+ if (!id) continue;
169
+ const sub = this.subs.get(id);
170
+ if (sub) {
171
+ spreadProps(li, api.getTriggerItemProps(sub.api), this.mid);
172
+ continue;
173
+ }
174
+ const item = this.byId(id);
175
+ spreadProps(li, api.getItemProps({ value: id, disabled: item?.disabled, closeOnSelect: item?.toggle ? false : void 0 }), this.mid);
176
+ }
177
+ }
178
+ build() {
179
+ const doc = this.doc;
180
+ this.list.replaceChildren();
181
+ const markable = this.checkmarks && this.items.some((i) => !(i.submenu && i.submenu.length > 0) && !i.toggle && i.checked !== void 0);
182
+ const iconic = this.items.some((i) => !!i.icon);
183
+ const badged = this.iconBadges && iconic;
184
+ if (badged) this.list.dataset.badges = "1";
185
+ else delete this.list.dataset.badges;
186
+ for (const item of this.items) {
187
+ if (item.separatorBefore) {
188
+ const sep = doc.createElement("li");
189
+ sep.className = "vela-menu-sep";
190
+ sep.dataset.slot = dropdownMenuDef.slot("separator");
191
+ sep.setAttribute("role", "separator");
192
+ this.list.appendChild(sep);
193
+ }
194
+ const branch = item.submenu !== void 0 && item.submenu.length > 0;
195
+ const li = doc.createElement("li");
196
+ li.className = "vela-menu-item";
197
+ li.dataset.slot = dropdownMenuDef.slot("item");
198
+ li.dataset.veiId = item.id;
199
+ if (item.toggle) {
200
+ li.dataset.toggle = "1";
201
+ }
202
+ if (markable) {
203
+ const mark = doc.createElement("span");
204
+ mark.className = "vela-menu-mark";
205
+ mark.dataset.slot = dropdownMenuDef.slot("mark");
206
+ if (!branch && !item.toggle && item.checked) {
207
+ mark.appendChild(menuIcon("check", doc));
208
+ li.dataset.checkmark = "1";
209
+ }
210
+ li.appendChild(mark);
211
+ } else if (!branch && !item.toggle && item.checked) {
212
+ li.dataset.checked = "1";
213
+ }
214
+ if (badged) {
215
+ const badge = doc.createElement("span");
216
+ badge.className = "vela-menu-badge";
217
+ badge.dataset.slot = dropdownMenuDef.slot("badge");
218
+ if (item.icon) badge.appendChild(menuIcon(item.icon, doc));
219
+ li.appendChild(badge);
220
+ } else if (item.icon) {
221
+ li.appendChild(menuIcon(item.icon, doc));
222
+ } else if (iconic) {
223
+ li.appendChild(menuIcon("", doc));
224
+ }
225
+ const label = doc.createElement("span");
226
+ label.className = "vela-menu-label";
227
+ label.dataset.slot = dropdownMenuDef.slot("label");
228
+ label.textContent = item.label;
229
+ li.appendChild(label);
230
+ if (item.hint) {
231
+ const hint = doc.createElement("span");
232
+ hint.className = "vela-menu-hint";
233
+ hint.dataset.slot = dropdownMenuDef.slot("hint");
234
+ hint.textContent = item.hint;
235
+ li.appendChild(hint);
236
+ }
237
+ if (item.favorite !== void 0 && this.onFavorite) {
238
+ const on = item.favorite;
239
+ const star = menuIcon(on ? "star-filled" : "star", doc);
240
+ star.classList.add("vela-menu-star");
241
+ addSlot(star, dropdownMenuDef.slot("star"));
242
+ if (on) {
243
+ star.classList.add("vela-fav");
244
+ star.dataset.fav = "";
245
+ }
246
+ star.removeAttribute("aria-hidden");
247
+ star.setAttribute("role", "button");
248
+ star.setAttribute("aria-label", textOf(this.i18n, on ? TEXT.removeFavorite : TEXT.addFavorite));
249
+ star.setAttribute("aria-pressed", on ? "true" : "false");
250
+ for (const ev of ["pointerdown", "pointerup", "mousedown", "mouseup"]) {
251
+ star.addEventListener(ev, (e) => e.stopPropagation());
252
+ }
253
+ star.addEventListener("click", (e) => {
254
+ e.stopPropagation();
255
+ e.preventDefault();
256
+ this.onFavorite?.(item.id, !on);
257
+ });
258
+ li.appendChild(star);
259
+ }
260
+ if (item.toggle) {
261
+ const sw = doc.createElement("span");
262
+ sw.className = "vela-menu-switch" + (item.checked ? " on" : "");
263
+ sw.dataset.slot = dropdownMenuDef.slot("switch");
264
+ if (item.checked) sw.dataset.on = "";
265
+ sw.setAttribute("aria-hidden", "true");
266
+ li.appendChild(sw);
267
+ }
268
+ if (branch) {
269
+ li.dataset.branch = "1";
270
+ const arrow = menuIcon("chevron-right", doc);
271
+ arrow.classList.add("vela-menu-arrow");
272
+ addSlot(arrow, dropdownMenuDef.slot("arrow"));
273
+ li.appendChild(arrow);
274
+ const sub = new _Surface(doc, {
275
+ host: this.host,
276
+ placement: { placement: "right-start" },
277
+ submenu: true,
278
+ opener: li,
279
+ onSelect: this.onSelect,
280
+ onFavorite: this.onFavorite,
281
+ i18n: this.i18n,
282
+ checkmarks: this.checkmarks,
283
+ iconBadges: this.iconBadges,
284
+ id: `${this.mid}--${item.id}`
285
+ });
286
+ sub.setItems(item.submenu ?? []);
287
+ this.subs.set(item.id, sub);
288
+ }
289
+ this.list.appendChild(li);
290
+ }
291
+ }
292
+ };
293
+ var DropdownMenu = class {
294
+ constructor(opts) {
295
+ const anchor = opts.trigger ?? opts.host ?? document.body;
296
+ const doc = anchor.ownerDocument;
297
+ injectStyles(doc);
298
+ const host = floatingLayerHost(opts.host ?? anchor, doc.body);
299
+ this.root = new Surface(doc, {
300
+ host,
301
+ placement: {
302
+ placement: opts.placement,
303
+ side: opts.side,
304
+ align: opts.align,
305
+ sideOffset: opts.sideOffset,
306
+ alignOffset: opts.alignOffset,
307
+ avoidCollisions: opts.avoidCollisions,
308
+ collisionPadding: opts.collisionPadding,
309
+ collisionBoundary: opts.collisionBoundary
310
+ },
311
+ onSelect: (id) => opts.onSelect?.(id),
312
+ onOpenChange: opts.onOpenChange,
313
+ trigger: opts.trigger,
314
+ triggerId: opts.triggerId,
315
+ id: opts.id,
316
+ minWidth: opts.minWidth,
317
+ onFavorite: opts.onFavorite,
318
+ i18n: opts.i18n ?? kitTranslator(),
319
+ checkmarks: opts.checkmarks,
320
+ iconBadges: opts.iconBadges
321
+ });
322
+ this.root.setItems(opts.items);
323
+ }
324
+ get api() {
325
+ return this.root.api;
326
+ }
327
+ open() {
328
+ this.api.setOpen(true);
329
+ }
330
+ /** Open anchored to a viewport point (context menus). */
331
+ openAt(clientX, clientY) {
332
+ const api = this.api;
333
+ api.setOpen(true);
334
+ api.reposition({ getAnchorRect: () => ({ x: clientX, y: clientY, width: 0, height: 0 }) });
335
+ }
336
+ close() {
337
+ this.api.setOpen(false);
338
+ }
339
+ /** Swap the item descriptors (e.g. checked states) and re-project. */
340
+ setItems(items) {
341
+ this.root.setItems(items);
342
+ }
343
+ destroy() {
344
+ this.root.destroy();
345
+ }
346
+ };
347
+ function createDropdownMenu(props) {
348
+ return new DropdownMenu(props);
349
+ }
350
+
351
+ export { DropdownMenu, createDropdownMenu, dropdownMenuController, dropdownMenuDef };
@@ -0,0 +1,25 @@
1
+ import { h } from './chunk-Q6WTDVH6.js';
2
+ import { t } from './chunk-6QCILIT2.js';
3
+ import { defineComponent } from './chunk-VMCR3S2A.js';
4
+ import { defineStyles, css } from './chunk-IDA2BT7D.js';
5
+
6
+ // src/components/kbd.ts
7
+ var kbdDef = defineComponent({
8
+ name: "kbd",
9
+ parts: ["root"],
10
+ settings: { radius: "5px", shadow: `inset 0 -1px 0 ${t.border}` }
11
+ });
12
+ var injectStyles = defineStyles(
13
+ "vela-ui-kbd",
14
+ css`@layer vela.ui{[data-slot=kbd]{border-radius:${kbdDef.vars.radius};border:1px solid ${t.border};border-bottom-color:color-mix(in srgb, ${t.fg.muted} 35%, transparent);background:${t.hover};min-width:18px;height:18px;color:${t.fg.bright};font:inherit;box-shadow:${kbdDef.vars.shadow};padding:0 4px;font-size:10px;font-weight:500;line-height:1}[data-slot=kbd]:where(:not([hidden])){justify-content:center;align-items:center;display:inline-flex}}`
15
+ );
16
+ function createKbd(props) {
17
+ injectStyles(document);
18
+ const el = h("kbd", { className: props.className, slot: kbdDef.slot("root"), text: props.text });
19
+ return { el, destroy: () => el.remove() };
20
+ }
21
+ function shortcutKeys(shortcut) {
22
+ return shortcut.split("+").map((key) => createKbd({ text: key }).el);
23
+ }
24
+
25
+ export { createKbd, kbdDef, shortcutKeys };
@@ -0,0 +1,52 @@
1
+ // src/lib/t.ts
2
+ function tok(name) {
3
+ const prop = `--vela-${name}`;
4
+ const ref = `var(${prop})`;
5
+ return { name: prop, var: ref, toString: () => ref };
6
+ }
7
+ function group(base, subs) {
8
+ const out = base ? tok(base) : {};
9
+ for (const [key, name] of Object.entries(subs)) out[key] = tok(name);
10
+ return out;
11
+ }
12
+ var t = {
13
+ space: group(null, { 1: "space-1", 2: "space-2", 3: "space-3", 4: "space-4" }),
14
+ radius: group(null, { sm: "radius-sm", md: "radius-md", lg: "radius-lg" }),
15
+ z: group(null, { tooltip: "z-tooltip", menu: "z-menu", dialog: "z-dialog", popover: "z-popover" }),
16
+ ease: tok("ease"),
17
+ dur: group(null, { fast: "dur-fast", med: "dur-med" }),
18
+ fontSize: group(null, { sm: "font-size-sm", md: "font-size-md", lg: "font-size-lg" }),
19
+ font: tok("font"),
20
+ bg: tok("bg"),
21
+ fg: group("fg", { muted: "fg-muted", faint: "fg-faint", bright: "fg-bright", onFill: "fg-on-fill" }),
22
+ surface: group("surface", { elev: "surface-elev", overlay: "surface-overlay", sunken: "surface-sunken" }),
23
+ border: group("border", { strong: "border-strong", soft: "border-soft", faint: "border-faint" }),
24
+ hover: group("hover", { strong: "hover-strong" }),
25
+ active: tok("active"),
26
+ focus: group("focus", { soft: "focus-soft" }),
27
+ separatorHover: group(null, { band: "separator-hover-band", line: "separator-hover-line" }),
28
+ scroll: group("scroll", { size: "scroll-size" }),
29
+ accent: group("accent", { bright: "accent-bright" }),
30
+ highlight: tok("highlight"),
31
+ selected: group(null, { bg: "selected-bg", fg: "selected-fg" }),
32
+ up: tok("up"),
33
+ down: tok("down"),
34
+ profit: tok("profit"),
35
+ loss: tok("loss"),
36
+ danger: tok("danger"),
37
+ shadow: group("shadow", { dialog: "shadow-dialog" }),
38
+ backdrop: tok("backdrop")
39
+ };
40
+ function tokenNames() {
41
+ const names = [];
42
+ const walk = (v) => {
43
+ if (!v || typeof v !== "object") return;
44
+ const name = v.name;
45
+ if (typeof name === "string") names.push(name);
46
+ for (const [k, sub] of Object.entries(v)) if (k !== "name" && k !== "var") walk(sub);
47
+ };
48
+ walk(t);
49
+ return names;
50
+ }
51
+
52
+ export { t, tokenNames };
@@ -0,0 +1,55 @@
1
+ // src/lib/chart.ts
2
+ function niceStep(range, ticks) {
3
+ const raw = range / Math.max(1, ticks);
4
+ const mag = 10 ** Math.floor(Math.log10(raw || 1));
5
+ const n = raw / mag;
6
+ return (n <= 1 ? 1 : n <= 2 ? 2 : n <= 5 ? 5 : 10) * mag;
7
+ }
8
+ function valueAxis(lo, hi, count) {
9
+ const step = niceStep(hi - lo || 1, count);
10
+ const min = Math.floor(lo / step) * step;
11
+ const max = Math.ceil(hi / step) * step || step;
12
+ const n = Math.round((max - min) / step);
13
+ const digits = Math.max(0, -Math.floor(Math.log10(step)) + 2);
14
+ const ticks = Array.from({ length: n + 1 }, (_, i) => Number((min + i * step).toFixed(digits)) || 0);
15
+ return { min, max, step, ticks };
16
+ }
17
+ function compactNumber(v) {
18
+ const a = Math.abs(v);
19
+ const sign = v < 0 ? "-" : "";
20
+ if (a >= 1e6) return `${sign}${+(a / 1e6).toFixed(1)}M`;
21
+ if (a >= 1e3) return `${sign}${+(a / 1e3).toFixed(1)}k`;
22
+ return `${sign}${+a.toFixed(2)}`;
23
+ }
24
+ function escapeXml(s) {
25
+ return s.replace(/[<>&"]/g, (c) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", '"': "&quot;" })[c]);
26
+ }
27
+ function showTip(tip, content, box, x, y) {
28
+ const wasHidden = tip.hidden;
29
+ if (typeof content === "string") tip.textContent = content;
30
+ else tip.replaceChildren(content);
31
+ tip.hidden = false;
32
+ tip.toggleAttribute("data-instant", wasHidden);
33
+ const tw = tip.offsetWidth;
34
+ const th = tip.offsetHeight;
35
+ const GAP = 16;
36
+ const left = x + GAP + tw <= box.w ? x + GAP : Math.max(0, x - GAP - tw);
37
+ tip.style.left = `${Math.round(left)}px`;
38
+ tip.style.top = `${Math.round(Math.max(0, Math.min(box.h - th, y - th / 2)))}px`;
39
+ }
40
+ var SVG_NS = "http://www.w3.org/2000/svg";
41
+ function chartFrame(rootSlot, tipSlot, className, draw) {
42
+ const svg = document.createElementNS(SVG_NS, "svg");
43
+ const tip = document.createElement("div");
44
+ tip.dataset.slot = tipSlot;
45
+ tip.hidden = true;
46
+ const el = document.createElement("div");
47
+ el.dataset.slot = rootSlot;
48
+ if (className) el.className = className;
49
+ el.append(svg, tip);
50
+ const ro = typeof ResizeObserver === "function" ? new ResizeObserver(draw) : null;
51
+ ro?.observe(el);
52
+ return { el, svg, tip, disconnect: () => ro?.disconnect() };
53
+ }
54
+
55
+ export { chartFrame, compactNumber, escapeXml, niceStep, showTip, valueAxis };
@@ -0,0 +1,26 @@
1
+ import { pageState } from './chunk-X66RJAIS.js';
2
+
3
+ // src/lib/dispose.ts
4
+ var owned = pageState("teardowns@1", () => /* @__PURE__ */ new WeakMap());
5
+ function ownTeardown(el, teardown) {
6
+ let set = owned.get(el);
7
+ if (!set) owned.set(el, set = /* @__PURE__ */ new Set());
8
+ const own = set;
9
+ const release = () => {
10
+ if (!own.delete(release)) return;
11
+ teardown();
12
+ };
13
+ own.add(release);
14
+ return release;
15
+ }
16
+ var releaseAt = (el) => {
17
+ const set = owned.get(el);
18
+ if (set) for (const release of [...set]) release();
19
+ };
20
+ function disposeWithin(root) {
21
+ if (!root) return;
22
+ if (root.nodeType === 1) releaseAt(root);
23
+ for (const el of root.querySelectorAll("*")) releaseAt(el);
24
+ }
25
+
26
+ export { disposeWithin, ownTeardown };