@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,61 @@
1
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
+
3
+ type Child = Node | string | number | null | undefined | false | readonly Child[];
4
+ type AttrValue = string | number | boolean | null | undefined;
5
+ interface ElementProps {
6
+ className?: string;
7
+ /** The part's `data-slot` (take it from the component's `defineComponent`). */
8
+ slot?: string;
9
+ /** `data-*` attributes (`{ icon: 'inline-start' }` → `data-icon="inline-start"`). `true`
10
+ * writes an empty value; `false`, `null` and `undefined` write nothing. */
11
+ data?: Record<string, AttrValue>;
12
+ /** Plain attributes, with the same value rules as `data`. */
13
+ attrs?: Record<string, AttrValue>;
14
+ style?: string;
15
+ text?: string;
16
+ on?: {
17
+ [K in keyof HTMLElementEventMap]?: (e: HTMLElementEventMap[K]) => void;
18
+ };
19
+ }
20
+ declare function h<K extends keyof HTMLElementTagNameMap>(tag: K, props?: ElementProps, ...children: Child[]): HTMLElementTagNameMap[K];
21
+ declare function append(el: Node, children: readonly Child[]): void;
22
+ /** Add a part to an element's slot, keeping the ones it has: a shell one component owns and
23
+ * another builds on carries both (`data-slot="popover-content select-content"`). */
24
+ declare function addSlot(el: Element, slot: string): void;
25
+
26
+ declare const dataTableDef: ComponentDef<"data-table", "head" | "table" | "sort" | "root" | "actions" | "row" | "cell" | "empty", "row-height" | "head-height" | "head-z">;
27
+ interface DataTableColumn<T> {
28
+ id: string;
29
+ header: string;
30
+ /** What the header stands for, on hover (`MFE`: maximum favorable excursion). */
31
+ title?: string;
32
+ align?: 'start' | 'end' | 'center';
33
+ width?: string;
34
+ /** The cell's content; a string or a number renders as text. */
35
+ cell(row: T): Child;
36
+ /** The value the column sorts by; without it the column does not sort. */
37
+ sort?(row: T): number | string;
38
+ tone?(row: T): 'profit' | 'loss' | 'muted' | null;
39
+ }
40
+ interface DataTableProps<T> {
41
+ columns: readonly DataTableColumn<T>[];
42
+ rowKey(row: T): string;
43
+ onRowClick?(row: T, e: MouseEvent): void;
44
+ /** What shows when there are no rows. */
45
+ empty?: () => HTMLElement;
46
+ /** The initial sort. */
47
+ sort?: {
48
+ column: string;
49
+ dir: 'asc' | 'desc';
50
+ };
51
+ /** Extra class names (layout hooks). */
52
+ className?: string;
53
+ }
54
+ interface DataTableHandle<T> {
55
+ readonly el: HTMLElement;
56
+ setRows(rows: readonly T[]): void;
57
+ destroy(): void;
58
+ }
59
+ declare function createDataTable<T>(props: DataTableProps<T>): DataTableHandle<T>;
60
+
61
+ export { type Child as C, type DataTableColumn as D, type ElementProps as E, addSlot as a, append as b, type DataTableHandle as c, dataTableDef as d, type DataTableProps as e, createDataTable as f, h };
@@ -0,0 +1,3 @@
1
+ export { D as DataTableColumn, c as DataTableHandle, e as DataTableProps, f as createDataTable, d as dataTableDef } from './data-table-DtU3FX9j.js';
2
+ import './define-D5u3F5Dj.js';
3
+ import './t.js';
@@ -0,0 +1,88 @@
1
+ import { h, append } 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
+ import './chunk-2GQIZM5Z.js';
6
+ import './chunk-BXMWQIBO.js';
7
+ import './chunk-X66RJAIS.js';
8
+
9
+ // src/components/data-table.ts
10
+ var dataTableDef = defineComponent({
11
+ name: "data-table",
12
+ parts: ["root", "table", "head", "sort", "row", "cell", "actions", "empty"],
13
+ settings: { "row-height": "28px", "head-height": "28px", "head-z": "1" }
14
+ });
15
+ var injectStyles = defineStyles(
16
+ "vela-ui-data-table",
17
+ css`@layer vela.ui{[data-slot=data-table]{height:100%;min-height:0;overflow:auto}[data-slot=data-table-table]{border-collapse:separate;border-spacing:0;width:100%;font-size:12px}[data-slot=data-table-head]{z-index:${dataTableDef.vars["head-z"]};height:${dataTableDef.vars["head-height"]};text-align:start;color:${t.fg.muted};background:${t.surface};border-bottom:1px solid ${t.border.faint};white-space:nowrap;-webkit-user-select:none;user-select:none;padding:0 10px;font-size:11px;font-weight:500;position:sticky;top:0}[data-slot=data-table-head][data-sortable]{cursor:pointer}[data-slot=data-table-head][data-sortable]:hover{color:${t.fg}}[data-slot=data-table-sort]{opacity:.8;margin-inline-start:4px;font-size:9px;display:inline-block}[data-slot=data-table-row]{transition:background ${t.dur.fast} ease}[data-slot=data-table-row]:hover{background:${t.hover}}[data-slot=data-table-row][data-clickable]{cursor:pointer}[data-slot=data-table-cell]{height:${dataTableDef.vars["row-height"]};border-bottom:1px solid ${t.border.faint};white-space:nowrap;color:${t.fg};padding:0 10px}[data-slot=data-table-cell][data-tone=profit]{color:${t.profit}}[data-slot=data-table-cell][data-tone=loss]{color:${t.loss}}[data-slot=data-table-cell][data-tone=muted]{color:${t.fg.muted}}:is([data-slot~=data-table-head],[data-slot~=data-table-cell])[data-align=end]{text-align:end;font-variant-numeric:tabular-nums}:is([data-slot~=data-table-head],[data-slot~=data-table-cell])[data-align=center]{text-align:center}[data-slot=data-table-actions]{opacity:0;transition:opacity ${t.dur.fast} ease;gap:2px}[data-slot=data-table-actions]:where(:not([hidden])){display:inline-flex}[data-slot=data-table-actions]:focus-within,[data-slot=data-table-actions]:is([data-slot=data-table-row]:hover *){opacity:1}}`
18
+ );
19
+ function createDataTable(props) {
20
+ injectStyles(document);
21
+ let rows = [];
22
+ let sort = props.sort ?? null;
23
+ const table = h("table", { slot: dataTableDef.slot("table") });
24
+ const thead = table.createTHead();
25
+ const tbody = h("tbody");
26
+ const emptyHost = h("div", { slot: dataTableDef.slot("empty") });
27
+ const el = h("div", { className: props.className, slot: dataTableDef.slot("root") }, table, emptyHost);
28
+ table.appendChild(tbody);
29
+ const renderHead = () => {
30
+ const tr = h("tr");
31
+ for (const col of props.columns) {
32
+ const th = h("th", {
33
+ slot: dataTableDef.slot("head"),
34
+ data: { align: col.align ?? null, sortable: !!col.sort, col: col.id },
35
+ attrs: { title: col.title ?? null, scope: "col", "aria-sort": sort?.column === col.id ? sort.dir === "asc" ? "ascending" : "descending" : null },
36
+ text: col.header
37
+ });
38
+ if (col.width) th.style.width = col.width;
39
+ if (col.sort) {
40
+ if (sort?.column === col.id) th.appendChild(h("span", { slot: dataTableDef.slot("sort"), attrs: { "aria-hidden": "true" }, text: sort.dir === "asc" ? "\u25B2" : "\u25BC" }));
41
+ th.addEventListener("click", () => {
42
+ sort = { column: col.id, dir: sort?.column === col.id && sort.dir === "desc" ? "asc" : "desc" };
43
+ renderHead();
44
+ renderBody();
45
+ });
46
+ }
47
+ tr.appendChild(th);
48
+ }
49
+ thead.replaceChildren(tr);
50
+ };
51
+ const renderBody = () => {
52
+ let shown = rows;
53
+ const col = sort ? props.columns.find((c) => c.id === sort.column) : void 0;
54
+ if (sort && col?.sort) {
55
+ const dir = sort.dir === "asc" ? 1 : -1;
56
+ shown = [...rows].sort((a, b) => {
57
+ const va = col.sort(a);
58
+ const vb = col.sort(b);
59
+ return dir * (typeof va === "number" && typeof vb === "number" ? va - vb : String(va).localeCompare(String(vb)));
60
+ });
61
+ }
62
+ const frag = document.createDocumentFragment();
63
+ for (const row of shown) {
64
+ const tr = h("tr", { slot: dataTableDef.slot("row"), data: { key: props.rowKey(row), clickable: !!props.onRowClick } });
65
+ if (props.onRowClick) tr.addEventListener("click", (e) => props.onRowClick(row, e));
66
+ for (const c of props.columns) {
67
+ const td = h("td", { slot: dataTableDef.slot("cell"), data: { align: c.align ?? null, tone: c.tone?.(row) ?? null, col: c.id } });
68
+ append(td, [c.cell(row)]);
69
+ tr.appendChild(td);
70
+ }
71
+ frag.appendChild(tr);
72
+ }
73
+ tbody.replaceChildren(frag);
74
+ const empty = shown.length === 0 && props.empty ? props.empty() : null;
75
+ emptyHost.replaceChildren(...empty ? [empty] : []);
76
+ };
77
+ renderHead();
78
+ return {
79
+ el,
80
+ setRows(next) {
81
+ rows = next;
82
+ renderBody();
83
+ },
84
+ destroy: () => el.remove()
85
+ };
86
+ }
87
+
88
+ export { createDataTable, dataTableDef };
@@ -0,0 +1,90 @@
1
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
+ import { Translator } from './i18n.js';
3
+ import './t.js';
4
+
5
+ type DatePickerPanel = 'date' | 'month' | 'year';
6
+ interface DatePickerControllerOptions {
7
+ /** The selected date (`YYYY-MM-DD`); the calendar opens on its month. */
8
+ value?: string;
9
+ /** "Today" for the today ring and the initial month when nothing is selected. */
10
+ today?: Date;
11
+ /** The translator whose locale names the months and weekdays, picks the first day of
12
+ * the week and the digits: `chart.i18n` inside a chart, `createTranslator(...)`
13
+ * elsewhere. Default: English, weeks starting on Sunday. */
14
+ i18n?: Translator;
15
+ }
16
+ /** One cell of the current panel. `blank` cells pad the first week of a month. */
17
+ interface DatePickerCell {
18
+ label: string;
19
+ /** The day (`YYYY-MM-DD`) on the date panel; the month index or the year otherwise. */
20
+ value: string | number;
21
+ checked: boolean;
22
+ today: boolean;
23
+ /** A padding year outside the decade on the year panel. */
24
+ outside?: boolean;
25
+ blank?: boolean;
26
+ }
27
+ interface DatePickerController {
28
+ readonly panel: DatePickerPanel;
29
+ readonly year: number;
30
+ readonly month: number;
31
+ readonly value: string | null;
32
+ /** Whether the locale writes the year before the month (the header's switch order). */
33
+ readonly yearFirst: boolean;
34
+ /** The weekday column labels, starting on the locale's first day of the week. */
35
+ weekdays(): string[];
36
+ /** Header text: the month switch (hidden off the date panel) and the year switch. */
37
+ header(): {
38
+ month: string;
39
+ monthVisible: boolean;
40
+ year: string;
41
+ yearDisabled: boolean;
42
+ };
43
+ /** What the arrows step on the current panel. */
44
+ navLabels(): {
45
+ prev: string;
46
+ next: string;
47
+ };
48
+ cells(): DatePickerCell[];
49
+ /** One month, one year or ten, depending on the panel. */
50
+ step(dir: 1 | -1): void;
51
+ showMonths(): void;
52
+ showYears(): void;
53
+ /** Activate a cell: a day returns its date (the pick); a month or year only navigates. */
54
+ choose(cell: DatePickerCell): string | null;
55
+ /** Rewrite the selection without emitting (and open on its month). */
56
+ setValue(value: string | null): void;
57
+ }
58
+ /** `YYYY-MM-DD` for a local date. */
59
+ declare function isoDate(d: Date): string;
60
+ /** Accept `YYYY-MM-DD` or `YYYY-M-D` and return a padded ISO date, or null if unusable. */
61
+ declare function normalizeDateInput(raw: string): string | null;
62
+ /** The calendar's panels, navigation and selection, without DOM. */
63
+ declare function datePickerController(opts?: DatePickerControllerOptions): DatePickerController;
64
+ declare const datePickerDef: ComponentDef<"date-picker", "head" | "nav" | "title" | "switch" | "root" | "grid" | "cell" | "day" | "week" | "cells" | "blank", "radius" | "today-ring">;
65
+ interface DatePickerOptions extends DatePickerControllerOptions {
66
+ /** A day was picked (`YYYY-MM-DD`). */
67
+ onPick?: (value: string) => void;
68
+ }
69
+ type DatePickerProps = DatePickerOptions;
70
+ declare class DatePicker {
71
+ private readonly opts;
72
+ readonly el: HTMLDivElement;
73
+ private readonly ctrl;
74
+ private readonly prev;
75
+ private readonly next;
76
+ private readonly monthBtn;
77
+ private readonly yearBtn;
78
+ private readonly week;
79
+ private readonly grid;
80
+ constructor(opts?: DatePickerOptions);
81
+ get value(): string | null;
82
+ /** Rewrite the selection without emitting (the calendar opens on its month). */
83
+ setValue(value: string | null): void;
84
+ destroy(): void;
85
+ private paint;
86
+ private cellEl;
87
+ }
88
+ declare function createDatePicker(props?: DatePickerProps): DatePicker;
89
+
90
+ export { DatePicker, type DatePickerCell, type DatePickerController, type DatePickerControllerOptions, type DatePickerOptions, type DatePickerPanel, type DatePickerProps, createDatePicker, datePickerController, datePickerDef, isoDate, normalizeDateInput };
@@ -0,0 +1,257 @@
1
+ import { calendarSettings, monthNames, yearLabel, weekdayNames, yearBeforeMonth, plainInteger } from './chunk-V6TTTMTE.js';
2
+ import { iconEl } from './chunk-G7IQLY3A.js';
3
+ import { msg, textOf } from './chunk-FN2BUFNM.js';
4
+ import { h } from './chunk-Q6WTDVH6.js';
5
+ import { t } from './chunk-6QCILIT2.js';
6
+ import { defineComponent } from './chunk-VMCR3S2A.js';
7
+ import { defineStyles, css } from './chunk-IDA2BT7D.js';
8
+ import './chunk-2GQIZM5Z.js';
9
+ import './chunk-BXMWQIBO.js';
10
+ import './chunk-X66RJAIS.js';
11
+
12
+ // src/components/date-picker.ts
13
+ var NAV = {
14
+ prevMonth: msg("ui.datePicker.previousMonth", "Previous month"),
15
+ nextMonth: msg("ui.datePicker.nextMonth", "Next month"),
16
+ prevYear: msg("ui.datePicker.previousYear", "Previous year"),
17
+ nextYear: msg("ui.datePicker.nextYear", "Next year"),
18
+ prevDecade: msg("ui.datePicker.previousDecade", "Previous decade"),
19
+ nextDecade: msg("ui.datePicker.nextDecade", "Next decade")
20
+ };
21
+ function isoDate(d) {
22
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
23
+ }
24
+ function normalizeDateInput(raw) {
25
+ const m = /^(\d{4})-(\d{1,2})-(\d{1,2})$/.exec(raw.trim());
26
+ if (!m) return null;
27
+ const y = Number(m[1]);
28
+ const mo = Number(m[2]);
29
+ const d = Number(m[3]);
30
+ const dt = new Date(y, mo - 1, d);
31
+ if (dt.getFullYear() !== y || dt.getMonth() !== mo - 1 || dt.getDate() !== d) return null;
32
+ return isoDate(dt);
33
+ }
34
+ function parseIsoDate(raw) {
35
+ const iso = raw ? normalizeDateInput(raw) : null;
36
+ if (!iso) return null;
37
+ const [y, mo, d] = iso.split("-").map(Number);
38
+ return new Date(y, mo - 1, d);
39
+ }
40
+ function datePickerController(opts = {}) {
41
+ const today = opts.today ?? /* @__PURE__ */ new Date();
42
+ let selected = parseIsoDate(opts.value);
43
+ let year = selected?.getFullYear() ?? today.getFullYear();
44
+ let month = selected?.getMonth() ?? today.getMonth();
45
+ let panel = "date";
46
+ const i18n = opts.i18n ?? null;
47
+ const settings = calendarSettings(i18n);
48
+ const weekStart = opts.i18n?.weekStart ?? 0;
49
+ const monthsLong = monthNames(settings, "long");
50
+ const monthsShort = monthNames(settings, "short");
51
+ const num = (n) => plainInteger(settings, n);
52
+ const decade = () => Math.floor(year / 10) * 10;
53
+ return {
54
+ get panel() {
55
+ return panel;
56
+ },
57
+ get year() {
58
+ return year;
59
+ },
60
+ get month() {
61
+ return month;
62
+ },
63
+ get value() {
64
+ return selected ? isoDate(selected) : null;
65
+ },
66
+ yearFirst: yearBeforeMonth(settings),
67
+ weekdays() {
68
+ const names = weekdayNames(settings);
69
+ return Array.from({ length: 7 }, (_, i) => names[(weekStart + i) % 7]);
70
+ },
71
+ header() {
72
+ return {
73
+ month: monthsLong[month] ?? "",
74
+ monthVisible: panel === "date",
75
+ year: panel === "year" ? `${num(decade())}-${num(decade() + 9)}` : yearLabel(settings, year),
76
+ yearDisabled: panel === "year"
77
+ // in the decade panel the year reads as its title
78
+ };
79
+ },
80
+ navLabels() {
81
+ if (panel === "date") return { prev: textOf(i18n, NAV.prevMonth), next: textOf(i18n, NAV.nextMonth) };
82
+ if (panel === "month") return { prev: textOf(i18n, NAV.prevYear), next: textOf(i18n, NAV.nextYear) };
83
+ return { prev: textOf(i18n, NAV.prevDecade), next: textOf(i18n, NAV.nextDecade) };
84
+ },
85
+ cells() {
86
+ const out = [];
87
+ if (panel === "date") {
88
+ const startPad = (new Date(year, month, 1).getDay() - weekStart + 7) % 7;
89
+ const days = new Date(year, month + 1, 0).getDate();
90
+ const todayIso = isoDate(today);
91
+ const selectedIso = selected ? isoDate(selected) : "";
92
+ for (let i = 0; i < startPad; i++) out.push({ label: "", value: "", checked: false, today: false, blank: true });
93
+ for (let day = 1; day <= days; day++) {
94
+ const iso = `${year}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
95
+ out.push({ label: num(day), value: iso, checked: iso === selectedIso, today: iso === todayIso });
96
+ }
97
+ return out;
98
+ }
99
+ if (panel === "month") {
100
+ for (let m = 0; m < 12; m++) {
101
+ out.push({
102
+ label: monthsShort[m] ?? "",
103
+ value: m,
104
+ checked: selected?.getFullYear() === year && selected.getMonth() === m,
105
+ today: today.getFullYear() === year && today.getMonth() === m
106
+ });
107
+ }
108
+ return out;
109
+ }
110
+ const d = decade();
111
+ for (let y = d - 1; y <= d + 10; y++) {
112
+ out.push({ label: num(y), value: y, checked: selected?.getFullYear() === y, today: today.getFullYear() === y, outside: y < d || y > d + 9 });
113
+ }
114
+ return out;
115
+ },
116
+ step(dir) {
117
+ if (panel === "date") {
118
+ month += dir;
119
+ if (month < 0) {
120
+ month = 11;
121
+ year -= 1;
122
+ }
123
+ if (month > 11) {
124
+ month = 0;
125
+ year += 1;
126
+ }
127
+ } else {
128
+ year += panel === "month" ? dir : dir * 10;
129
+ }
130
+ },
131
+ showMonths() {
132
+ panel = "month";
133
+ },
134
+ showYears() {
135
+ panel = "year";
136
+ },
137
+ choose(cell) {
138
+ if (cell.blank) return null;
139
+ if (panel === "date") {
140
+ selected = parseIsoDate(String(cell.value));
141
+ return selected ? isoDate(selected) : null;
142
+ }
143
+ if (panel === "month") {
144
+ month = Number(cell.value);
145
+ panel = "date";
146
+ return null;
147
+ }
148
+ year = Number(cell.value);
149
+ panel = "month";
150
+ return null;
151
+ },
152
+ setValue(value) {
153
+ selected = parseIsoDate(value);
154
+ if (selected) {
155
+ year = selected.getFullYear();
156
+ month = selected.getMonth();
157
+ }
158
+ panel = "date";
159
+ }
160
+ };
161
+ }
162
+ var datePickerDef = defineComponent({
163
+ name: "date-picker",
164
+ parts: ["root", "head", "title", "switch", "nav", "week", "grid", "cells", "blank", "day", "cell"],
165
+ settings: { radius: t.radius.sm, "today-ring": `inset 0 0 0 1px ${t.border.strong}` }
166
+ });
167
+ var CHOOSE_MONTH = msg("ui.datePicker.chooseMonth", "Choose month");
168
+ var CHOOSE_YEAR = msg("ui.datePicker.chooseYear", "Choose year");
169
+ var injectStyles = defineStyles(
170
+ "vela-date-picker-styles",
171
+ css`@layer vela.ui{[data-slot=date-picker]{color:${t.fg};font:14px ${t.font};-webkit-user-select:none;user-select:none}[data-slot=date-picker-head]{justify-content:space-between;align-items:center;gap:8px;margin-bottom:8px;display:flex}[data-slot=date-picker-title]{flex:1;justify-content:center;align-items:center;gap:2px;min-width:0;display:flex}[data-slot=date-picker-switch]{color:${t.fg.bright};font:inherit;border-radius:${datePickerDef.vars.radius};cursor:pointer;background:0 0;border:none;padding:2px 6px;font-size:14px;font-weight:600}[data-slot=date-picker-switch]:disabled{cursor:default}[data-slot=date-picker-switch]:not(:disabled):hover{background:${t.hover}}[data-slot=date-picker-nav]{width:24px;height:24px;color:${t.fg.muted};border-radius:${datePickerDef.vars.radius};cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:0;font-size:14px;display:inline-flex}[data-slot=date-picker-nav]:hover{background:${t.hover};color:${t.fg.bright}}[data-slot=date-picker-week],[data-slot=date-picker-grid]{grid-template-columns:repeat(7,28px);gap:2px}[data-slot=date-picker-week]:where(:not([hidden])),[data-slot=date-picker-grid]{display:grid}[data-slot=date-picker-week]{color:${t.fg.muted};text-align:center;margin-bottom:4px;font-size:11px}[data-slot=date-picker-week]>span{line-height:20px}[data-slot=date-picker-blank]{width:28px;height:28px}[data-slot=date-picker-day]{width:28px;height:28px;color:inherit;border-radius:${datePickerDef.vars.radius};cursor:pointer;font:inherit;background:0 0;border:none;padding:0;font-size:14px}[data-slot=date-picker-day]:hover{background:${t.hover}}[data-slot=date-picker-day][data-checked]{background:${t.hover.strong};color:${t.fg.bright}}[data-slot=date-picker-day][data-today]:not([data-checked]){box-shadow:${datePickerDef.vars["today-ring"]}}[data-slot=date-picker-cells]{grid-template-columns:repeat(3,1fr);gap:4px;width:208px;display:grid}[data-slot=date-picker-cell]{height:36px;color:inherit;border-radius:${datePickerDef.vars.radius};cursor:pointer;font:inherit;background:0 0;border:none;padding:0 4px;font-size:14px}[data-slot=date-picker-cell]:hover{background:${t.hover}}[data-slot=date-picker-cell][data-checked]{background:${t.hover.strong};color:${t.fg.bright}}[data-slot=date-picker-cell][data-today]:not([data-checked]){box-shadow:${datePickerDef.vars["today-ring"]}}[data-slot=date-picker-cell][data-outside]{opacity:.45}}`
172
+ );
173
+ var DatePicker = class {
174
+ constructor(opts = {}) {
175
+ this.opts = opts;
176
+ const doc = document;
177
+ injectStyles(doc);
178
+ this.ctrl = datePickerController(opts);
179
+ const button = (className, part) => h("button", { className, slot: part, attrs: { type: "button" } });
180
+ this.prev = button("vela-date-picker-nav", datePickerDef.slot("nav"));
181
+ this.prev.append(iconEl("chevron-left", doc));
182
+ this.next = button("vela-date-picker-nav", datePickerDef.slot("nav"));
183
+ this.next.append(iconEl("chevron-right", doc));
184
+ const i18n = opts.i18n ?? null;
185
+ this.monthBtn = button("vela-date-picker-switch", datePickerDef.slot("switch"));
186
+ this.monthBtn.setAttribute("aria-label", textOf(i18n, CHOOSE_MONTH));
187
+ this.yearBtn = button("vela-date-picker-switch", datePickerDef.slot("switch"));
188
+ this.yearBtn.setAttribute("aria-label", textOf(i18n, CHOOSE_YEAR));
189
+ const title = h("div", { className: "vela-date-picker-title", slot: datePickerDef.slot("title") }, this.ctrl.yearFirst ? [this.yearBtn, this.monthBtn] : [this.monthBtn, this.yearBtn]);
190
+ const head = h("div", { className: "vela-date-picker-head", slot: datePickerDef.slot("head") }, this.prev, title, this.next);
191
+ this.week = h(
192
+ "div",
193
+ { className: "vela-date-picker-week", slot: datePickerDef.slot("week") },
194
+ this.ctrl.weekdays().map((d) => h("span", { text: d }))
195
+ );
196
+ this.grid = h("div");
197
+ const on = (el, run) => el.addEventListener("click", (e) => {
198
+ e.stopPropagation();
199
+ run();
200
+ this.paint();
201
+ });
202
+ on(this.prev, () => this.ctrl.step(-1));
203
+ on(this.next, () => this.ctrl.step(1));
204
+ on(this.monthBtn, () => this.ctrl.showMonths());
205
+ on(this.yearBtn, () => this.ctrl.showYears());
206
+ this.el = h("div", { className: "vela-date-picker", slot: datePickerDef.slot("root") }, head, this.week, this.grid);
207
+ this.paint();
208
+ }
209
+ get value() {
210
+ return this.ctrl.value;
211
+ }
212
+ /** Rewrite the selection without emitting (the calendar opens on its month). */
213
+ setValue(value) {
214
+ this.ctrl.setValue(value);
215
+ this.paint();
216
+ }
217
+ destroy() {
218
+ }
219
+ paint() {
220
+ const doc = this.el.ownerDocument;
221
+ const head = this.ctrl.header();
222
+ this.monthBtn.hidden = !head.monthVisible;
223
+ this.monthBtn.textContent = head.month;
224
+ this.yearBtn.textContent = head.year;
225
+ this.yearBtn.disabled = head.yearDisabled;
226
+ const nav = this.ctrl.navLabels();
227
+ this.prev.setAttribute("aria-label", nav.prev);
228
+ this.next.setAttribute("aria-label", nav.next);
229
+ const dates = this.ctrl.panel === "date";
230
+ this.week.hidden = !dates;
231
+ this.grid.className = dates ? "vela-date-picker-grid" : "vela-date-picker-cells";
232
+ this.grid.setAttribute("data-slot", datePickerDef.slot(dates ? "grid" : "cells"));
233
+ this.grid.replaceChildren(...this.ctrl.cells().map((cell) => this.cellEl(doc, cell, dates)));
234
+ }
235
+ cellEl(doc, cell, dates) {
236
+ if (cell.blank) return h("span", { className: "vela-date-picker-blank", slot: datePickerDef.slot("blank") });
237
+ const b = h("button", {
238
+ className: dates ? "vela-date-picker-day" : "vela-date-picker-cell",
239
+ slot: datePickerDef.slot(dates ? "day" : "cell"),
240
+ attrs: { type: "button" },
241
+ data: { checked: cell.checked ? "1" : null, today: cell.today ? "1" : null, outside: cell.outside ? "1" : null },
242
+ text: cell.label
243
+ });
244
+ b.addEventListener("click", (e) => {
245
+ e.stopPropagation();
246
+ const picked = this.ctrl.choose(cell);
247
+ if (picked) this.opts.onPick?.(picked);
248
+ else this.paint();
249
+ });
250
+ return b;
251
+ }
252
+ };
253
+ function createDatePicker(props = {}) {
254
+ return new DatePicker(props);
255
+ }
256
+
257
+ export { DatePicker, createDatePicker, datePickerController, datePickerDef, isoDate, normalizeDateInput };
@@ -0,0 +1,21 @@
1
+ import { Token } from './t.js';
2
+
3
+ interface ComponentDef<N extends string, P extends string, S extends string> {
4
+ readonly name: N;
5
+ readonly parts: readonly P[];
6
+ /** A part's `data-slot`: the bare name for `root`, `name-part` otherwise. */
7
+ slot(part: P): string;
8
+ /** Each setting as `var(--vela-<name>-<setting>, <default>)`, for the component's CSS. */
9
+ readonly vars: {
10
+ readonly [K in S]: string;
11
+ };
12
+ }
13
+ declare function defineComponent<const N extends string, const P extends string, const S extends string = never>(def: {
14
+ name: N;
15
+ parts: readonly P[];
16
+ settings?: {
17
+ readonly [K in S]: Token | string;
18
+ };
19
+ }): ComponentDef<N, P, S>;
20
+
21
+ export { type ComponentDef as C, defineComponent as d };
@@ -0,0 +1,89 @@
1
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
+ import * as dialog from '@zag-js/dialog';
3
+ import './t.js';
4
+
5
+ interface DialogControllerOptions {
6
+ /** Trap focus + backdrop (default true). Non-modal = floating panel. */
7
+ modal?: boolean;
8
+ closeOnEscape?: boolean;
9
+ closeOnInteractOutside?: boolean;
10
+ /** Element to focus on open (default: the machine's first-tabbable pick). */
11
+ initialFocusEl?: () => HTMLElement | null;
12
+ onOpenChange?: (open: boolean) => void;
13
+ }
14
+ type DialogService = dialog.Service;
15
+ type DialogApi = dialog.Api;
16
+ interface DialogController {
17
+ machine: typeof dialog.machine;
18
+ props: Partial<dialog.Props>;
19
+ connect(service: DialogService): DialogApi;
20
+ }
21
+ /** Zag's dialog machine with the options mapped onto it, for any view layer. */
22
+ declare function dialogController(opts?: DialogControllerOptions): DialogController;
23
+ declare const dialogDef: ComponentDef<"dialog", "close" | "body" | "footer" | "header" | "title" | "backdrop" | "content" | "positioner", "radius">;
24
+ type DialogVariant = 'default' | 'settings' | 'form';
25
+ interface DialogOptions extends DialogControllerOptions {
26
+ title?: string;
27
+ content?: Node | ((body: HTMLElement) => void);
28
+ host?: HTMLElement;
29
+ /** Drag the dialog by its header (the reference dialogs move; search stays fixed). */
30
+ draggable?: boolean;
31
+ /** Darken the page behind the dialog (default false — the chart stays readable while
32
+ * dialogs edit live content). Pass true for a dimming scrim; the backdrop still
33
+ * catches interact-outside dismissal either way. */
34
+ dimBackdrop?: boolean;
35
+ /** Vertical placement of the card. Default `top` (current 10vh pad). */
36
+ align?: 'top' | 'center';
37
+ /** Pin the overlay to `host` (absolute) instead of the viewport (fixed). */
38
+ contained?: boolean;
39
+ /** Footer pinned below the scrollable body. */
40
+ footer?: Node | ((el: HTMLElement) => void);
41
+ /** Extra nodes before the title (e.g. a mobile section burger). */
42
+ headerStart?: Node;
43
+ /** Skip default body padding — the caller owns the body layout. */
44
+ flush?: boolean;
45
+ /** `settings`: the chart settings card; `form`: the indicator and drawing settings card. */
46
+ variant?: DialogVariant;
47
+ /** Extra class on the panel. */
48
+ className?: string;
49
+ /** Close when the backdrop itself is pressed (not when a portaled popover is). */
50
+ closeOnBackdrop?: boolean;
51
+ }
52
+ type DialogProps = DialogOptions;
53
+ declare class Dialog {
54
+ /** Caller-owned content area — append your form/panel here. */
55
+ readonly body: HTMLElement;
56
+ readonly panel: HTMLElement;
57
+ readonly titleEl: HTMLElement;
58
+ readonly positioner: HTMLElement;
59
+ readonly backdrop: HTMLElement;
60
+ readonly footer: HTMLElement | null;
61
+ private readonly handle;
62
+ private readonly ctrl;
63
+ constructor(opts?: DialogOptions);
64
+ private opener;
65
+ private wasOpen;
66
+ /** The panel and scrim's exit animation after a close; a reopen cancels it. */
67
+ private exit;
68
+ private destroyed;
69
+ private setShown;
70
+ /** Keep the just-closed dialog up through its exit animation, then hide it — or
71
+ * remove it, when it was destroyed meanwhile. `spreadProps` re-applies the close
72
+ * props' `hidden` only when its value changes, so lifting it keeps the panel and
73
+ * scrim up until the exit ends. The positioner spans the viewport: inert, it lets
74
+ * clicks through to the page while the panel animates out. */
75
+ private holdExit;
76
+ private detach;
77
+ /** Closing hands focus back to whatever opened it (Escape, the ✕, hide(), or a
78
+ * teardown that outruns the machine's close notification). */
79
+ private restoreOpener;
80
+ private announce;
81
+ get open(): boolean;
82
+ show(): void;
83
+ hide(): void;
84
+ contains(node: Node | null): boolean;
85
+ destroy(): void;
86
+ }
87
+ declare function createDialog(props?: DialogProps): Dialog;
88
+
89
+ export { Dialog, type DialogApi, type DialogController, type DialogControllerOptions, type DialogOptions, type DialogProps, type DialogService, type DialogVariant, createDialog, dialogController, dialogDef };