@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
package/cli/index.mjs ADDED
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/env node
2
+ // vela-ui: add a component to a project, copy its source for a variant of your own, see what
3
+ // changed upstream since, and check the project.
4
+ import { spawnSync } from 'node:child_process';
5
+ import { join, relative, resolve } from 'node:path';
6
+ import { createInterface } from 'node:readline/promises';
7
+ import { pathToFileURL } from 'node:url';
8
+ import { parseArgs } from 'node:util';
9
+ import * as engine from './engine.mjs';
10
+
11
+ const USAGE = `Usage: vela-ui <command> [options]
12
+
13
+ list the components
14
+ add <component> make ${engine.PACKAGE} a direct dependency and print the import
15
+ add <component> --source copy the component's source, for a variant of your own
16
+ --as <name> the copy's component name (default: app-<component>)
17
+ --force overwrite an existing copy
18
+ diff <copy> what changed upstream since the copy was made
19
+ --accept record that the copy has taken those changes in
20
+ check one copy of the package, no copy behind it, the theme file valid
21
+
22
+ --cwd <path> the project (default: the current folder)
23
+ --from <path> read the catalog from a checkout instead of this package
24
+ --agents add the note for coding agents to AGENTS.md without asking
25
+ --no-install print the install command instead of running it`;
26
+
27
+ const say = (text = '') => process.stdout.write(`${text}\n`);
28
+ const fail = (text) => {
29
+ process.stderr.write(`vela-ui: ${text}\n`);
30
+ process.exit(1);
31
+ };
32
+
33
+ let parsed;
34
+ try {
35
+ parsed = parseArgs({
36
+ allowPositionals: true,
37
+ options: {
38
+ source: { type: 'boolean' },
39
+ as: { type: 'string' },
40
+ force: { type: 'boolean' },
41
+ accept: { type: 'boolean' },
42
+ from: { type: 'string' },
43
+ cwd: { type: 'string' },
44
+ agents: { type: 'boolean' },
45
+ 'no-install': { type: 'boolean' },
46
+ help: { type: 'boolean', short: 'h' },
47
+ },
48
+ });
49
+ } catch (e) {
50
+ fail(`${e.message}\n\n${USAGE}`);
51
+ }
52
+ const { values, positionals } = parsed;
53
+ const [command, name] = positionals;
54
+ if (!command || values.help) {
55
+ say(USAGE);
56
+ process.exit(command || values.help ? 0 : 1);
57
+ }
58
+
59
+ const cwd = resolve(values.cwd ?? process.cwd());
60
+ let catalog;
61
+ try {
62
+ catalog = engine.readCatalog(values.from);
63
+ } catch (e) {
64
+ fail(e.message);
65
+ }
66
+
67
+ async function offerAgentsNote() {
68
+ if (engine.hasAgentsBlock(cwd)) return;
69
+ let yes = values.agents === true;
70
+ if (!yes && process.stdin.isTTY) {
71
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
72
+ const answer = await rl.question('Add a note to AGENTS.md pointing coding agents at the kit\'s reference? [Y/n] ');
73
+ rl.close();
74
+ yes = !/^n/i.test(answer.trim());
75
+ }
76
+ if (yes) {
77
+ engine.writeAgentsBlock(cwd);
78
+ say('Added the note to AGENTS.md.');
79
+ } else if (!process.stdin.isTTY) say('Tip: `vela-ui add <component> --agents` adds a note to AGENTS.md pointing coding agents at the kit\'s reference.');
80
+ }
81
+
82
+ function ensureDependency() {
83
+ if (engine.isDirectDependency(cwd)) return;
84
+ const cmd = engine.installCommand(engine.detectPackageManager(cwd), `${engine.PACKAGE}@^${catalog.version}`);
85
+ if (values['no-install']) {
86
+ say(`${engine.PACKAGE} is not a dependency of this project yet: ${cmd}`);
87
+ return;
88
+ }
89
+ say(`$ ${cmd}`);
90
+ const run = spawnSync(cmd, { cwd, stdio: 'inherit', shell: true });
91
+ if (run.status !== 0) fail(`the install failed (${cmd}).`);
92
+ }
93
+
94
+ switch (command) {
95
+ case 'list': {
96
+ for (const c of catalog.manifest.components) say(`${c.name.padEnd(16)} ${c.factory ?? ''}`.trimEnd());
97
+ break;
98
+ }
99
+ case 'add': {
100
+ if (!name) fail('add needs a component: `vela-ui list` shows them.');
101
+ const item = engine.findItem(catalog, name);
102
+ if (!item) fail(`no component "${name}" in ${engine.PACKAGE} ${catalog.version}: \`vela-ui list\` shows them.`);
103
+ ensureDependency();
104
+ const factory = item.factory ?? item.exports[0];
105
+ if (values.source) {
106
+ const as = values.as ?? `app-${item.component ?? item.name}`;
107
+ if (!/^[a-z][a-z0-9-]*$/.test(as)) fail(`--as takes a lowercase name with dashes ("${as}").`);
108
+ let file;
109
+ try {
110
+ ({ file } = engine.copyItem({ cwd, catalog, item, as, force: values.force }));
111
+ } catch (e) {
112
+ fail(e.message);
113
+ }
114
+ const alias = engine.readConfig(cwd).aliases?.ui;
115
+ const from = alias?.startsWith('#') ? `${alias}/${as}` : `./${relative(cwd, file).split('\\').join('/').replace(/\.ts$/, '')}`;
116
+ say(`Copied ${item.name} to ${relative(cwd, file)}, as the component "${as}" (its parts are data-slot="${as}…").`);
117
+ say(`Vela and the plugins keep rendering the package's ${item.name}.`);
118
+ say();
119
+ say(`import { ${factory} } from '${from}';`);
120
+ } else {
121
+ say(item.example ?? `import { ${factory} } from '${item.import}';`);
122
+ }
123
+ await offerAgentsNote();
124
+ break;
125
+ }
126
+ case 'diff': {
127
+ if (!name) fail('diff needs a copy: the names are in vela-ui.lock.json.');
128
+ try {
129
+ const { entry, diff } = engine.upstreamDiff({ cwd, catalog, as: name });
130
+ if (!diff) say(`${name}: no change upstream since ${entry.version}.`);
131
+ else {
132
+ say(`${name}: ${entry.item}, ${entry.version} -> ${catalog.version} (- upstream when copied, + upstream now)\n`);
133
+ say(diff);
134
+ }
135
+ if (values.accept) {
136
+ engine.acceptUpstream({ cwd, catalog, as: name });
137
+ say(`\nRecorded ${name} as up to date with ${catalog.version}.`);
138
+ }
139
+ } catch (e) {
140
+ fail(e.message);
141
+ }
142
+ break;
143
+ }
144
+ case 'check': {
145
+ const { checkTheme } = await import(pathToFileURL(join(catalog.root, 'dist/theme.js')).href);
146
+ const findings = engine.checkProject({ cwd, catalog, checkTheme });
147
+ if (!findings.length) say('vela-ui check: all good.');
148
+ for (const f of findings) say(`${f.level === 'error' ? 'error' : 'warn '} ${f.text}`);
149
+ process.exit(findings.some((f) => f.level === 'error') ? 1 : 0);
150
+ break;
151
+ }
152
+ default:
153
+ fail(`unknown command "${command}".\n\n${USAGE}`);
154
+ }
@@ -0,0 +1,26 @@
1
+ import { V as VariantFn, a as VariantProps } from './variants-B4stUBnY.js';
2
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
3
+ import './t.js';
4
+
5
+ declare const badgeDef: ComponentDef<"badge", "root", "radius">;
6
+ declare const badgeVariants: VariantFn<{
7
+ readonly variant: readonly ["default", "secondary", "outline", "destructive", "up", "down"];
8
+ }>;
9
+ type BadgeVariant = (typeof badgeVariants.spec.variant)[number];
10
+ interface BadgeProps extends VariantProps<typeof badgeVariants> {
11
+ text: string;
12
+ /** A round count pill (`3`, `9+`) rather than a label. */
13
+ count?: boolean;
14
+ className?: string;
15
+ }
16
+ interface BadgeHandle {
17
+ readonly el: HTMLSpanElement;
18
+ setText(text: string): void;
19
+ setVariant(variant: BadgeVariant): void;
20
+ destroy(): void;
21
+ }
22
+ declare const BADGE_STYLE_ID = "vela-ui-badge";
23
+ declare const BADGE_CSS: string;
24
+ declare function createBadge(props: BadgeProps): BadgeHandle;
25
+
26
+ export { BADGE_CSS, BADGE_STYLE_ID, type BadgeHandle, type BadgeProps, type BadgeVariant, badgeDef, badgeVariants, createBadge };
package/dist/badge.js ADDED
@@ -0,0 +1,44 @@
1
+ import { variants } from './chunk-LZWZV2ZS.js';
2
+ import { h } from './chunk-Q6WTDVH6.js';
3
+ import { t } from './chunk-6QCILIT2.js';
4
+ import { defineComponent } from './chunk-VMCR3S2A.js';
5
+ import { css, defineStyles } from './chunk-IDA2BT7D.js';
6
+ import './chunk-2GQIZM5Z.js';
7
+ import './chunk-BXMWQIBO.js';
8
+ import './chunk-X66RJAIS.js';
9
+
10
+ // src/components/badge.ts
11
+ var badgeDef = defineComponent({
12
+ name: "badge",
13
+ parts: ["root"],
14
+ settings: { radius: "5px" }
15
+ });
16
+ var badgeVariants = variants({ variant: ["default", "secondary", "outline", "destructive", "up", "down"] });
17
+ var BADGE_STYLE_ID = "vela-ui-badge";
18
+ var BADGE_CSS = css`@layer vela.ui{[data-slot=badge]{box-sizing:border-box;border-radius:${badgeDef.vars.radius};white-space:nowrap;font-variant-numeric:tabular-nums;background:${t.selected.bg};height:20px;color:${t.selected.fg};border:1px solid #0000;align-items:center;gap:4px;padding:0 6px;font-size:12px;font-weight:500;line-height:1}[data-slot=badge]:where(:not([hidden])){display:inline-flex}[data-slot=badge][data-count]{border-radius:999px;justify-content:center;min-width:18px;height:18px;padding:0 5px;font-size:11px}[data-slot=badge][data-variant=secondary]{background:${t.hover};color:${t.fg.muted}}[data-slot=badge][data-variant=outline]{border-color:${t.border.strong};color:${t.fg};background:0 0}[data-slot=badge][data-variant=destructive]{background:color-mix(in srgb, ${t.danger} 18%, transparent);color:${t.danger}}[data-slot=badge][data-variant=up]{background:color-mix(in srgb, ${t.up} 18%, transparent);color:${t.up}}[data-slot=badge][data-variant=down]{background:color-mix(in srgb, ${t.down} 18%, transparent);color:${t.down}}}`;
19
+ var injectStyles = defineStyles(BADGE_STYLE_ID, BADGE_CSS);
20
+ var BadgeImpl = class {
21
+ constructor(props) {
22
+ injectStyles(document);
23
+ this.el = h("span", {
24
+ className: props.className ? `vela-badge ${props.className}` : "vela-badge",
25
+ slot: badgeDef.slot("root"),
26
+ attrs: badgeVariants(props),
27
+ data: { count: props.count === true },
28
+ text: props.text
29
+ });
30
+ }
31
+ setText(text) {
32
+ this.el.textContent = text;
33
+ }
34
+ setVariant(variant) {
35
+ this.el.setAttribute("data-variant", variant);
36
+ }
37
+ destroy() {
38
+ }
39
+ };
40
+ function createBadge(props) {
41
+ return new BadgeImpl(props);
42
+ }
43
+
44
+ export { BADGE_CSS, BADGE_STYLE_ID, badgeDef, badgeVariants, createBadge };
@@ -0,0 +1,40 @@
1
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
+ import './t.js';
3
+
4
+ declare const barChartDef: ComponentDef<"bar-chart", "label" | "marker" | "root" | "grid" | "bar" | "tip", "tip-radius" | "tip-shadow" | "tip-z" | "tip-bg">;
5
+ interface BarDatum {
6
+ label: string;
7
+ value: number;
8
+ /** The bar's tone (default: by its sign). */
9
+ tone?: 'profit' | 'loss' | 'muted';
10
+ }
11
+ interface BarChartProps {
12
+ /** The hover readout of a bar. */
13
+ format?: (d: BarDatum) => string | Node;
14
+ /** Label every Nth bar under the axis (default: as many as fit). */
15
+ labelEvery?: number;
16
+ /** A value axis on the start side, with gridlines. */
17
+ axes?: boolean;
18
+ /** The value axis's title, written up its side. */
19
+ axisTitle?: string;
20
+ /** Slant the bar labels (long labels on many bars). */
21
+ slantLabels?: boolean;
22
+ yFormat?: (v: number) => string;
23
+ /** What a bar's label reads under the axis (default: the label itself). */
24
+ labelFormat?: (label: string) => string;
25
+ /** Extra class names (layout hooks). */
26
+ className?: string;
27
+ }
28
+ interface BarChartHandle {
29
+ readonly el: HTMLElement;
30
+ /** `markers` are dashed vertical lines at fractional bar positions (0: the first bar's
31
+ * start edge), each in its own ink. */
32
+ setData(data: readonly BarDatum[], markers?: ReadonlyArray<{
33
+ at: number;
34
+ color: string;
35
+ }>): void;
36
+ destroy(): void;
37
+ }
38
+ declare function createBarChart(props?: BarChartProps): BarChartHandle;
39
+
40
+ export { type BarChartHandle, type BarChartProps, type BarDatum, barChartDef, createBarChart };
@@ -0,0 +1,105 @@
1
+ import { chartFrame, showTip, valueAxis, compactNumber, escapeXml } from './chunk-A2FJ7Y7D.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/bar-chart.ts
10
+ var barChartDef = defineComponent({
11
+ name: "bar-chart",
12
+ parts: ["root", "grid", "label", "bar", "marker", "tip"],
13
+ settings: { "tip-radius": "3px", "tip-shadow": t.shadow, "tip-z": "2", "tip-bg": t.surface.elev }
14
+ });
15
+ var injectStyles = defineStyles(
16
+ "vela-ui-bar-chart",
17
+ css`@layer vela.ui{[data-slot=bar-chart]{width:100%;height:100%;position:relative}[data-slot=bar-chart]>svg{width:100%;height:100%;display:block;overflow:visible}[data-slot=bar-chart-grid]{stroke:color-mix(in srgb, ${t.fg.bright} 5%, transparent)}[data-slot=bar-chart-grid][data-zero]{stroke:color-mix(in srgb, ${t.fg.bright} 20%, transparent)}[data-slot=bar-chart-grid][data-base]{stroke:${t.border}}[data-slot=bar-chart-label]{fill:${t.fg.muted};font-size:10px}[data-slot=bar-chart-label][data-title]{font-size:11px}[data-slot=bar-chart-bar]{fill:${t.profit}}[data-slot=bar-chart-bar][data-tone=loss]{fill:${t.loss}}[data-slot=bar-chart-bar][data-tone=muted]{fill:${t.fg.faint}}[data-slot=bar-chart-bar][data-thin]{opacity:.85}[data-slot=bar-chart-marker]{stroke-width:2px;stroke-dasharray:4 3}[data-slot=bar-chart-tip]{z-index:${barChartDef.vars["tip-z"]};pointer-events:none;border-radius:${barChartDef.vars["tip-radius"]};border:1px solid ${t.border};background:${barChartDef.vars["tip-bg"]};color:${t.fg.bright};box-shadow:${barChartDef.vars["tip-shadow"]};white-space:nowrap;font-variant-numeric:tabular-nums;transition:left ${t.dur.fast} ease-out, top ${t.dur.fast} ease-out;padding:8px;font-size:12px;line-height:1.35;position:absolute;top:0}[data-slot=bar-chart-tip][data-instant]{transition:none}}`
18
+ );
19
+ function createBarChart(props = {}) {
20
+ injectStyles(document);
21
+ let data = [];
22
+ let markers = [];
23
+ const slot = (part) => `data-slot="${barChartDef.slot(part)}"`;
24
+ const geometry = () => {
25
+ const w = frame.el.clientWidth;
26
+ const ht = frame.el.clientHeight;
27
+ if (w < 4 || ht < 24 || data.length === 0) return null;
28
+ const left = props.axes ? props.axisTitle ? 54 : 40 : 0;
29
+ const top = props.axes ? 6 : 0;
30
+ const plotH = ht - top - (props.slantLabels ? 46 : 16);
31
+ const lo = Math.min(0, ...data.map((d) => d.value));
32
+ const hi = Math.max(0, ...data.map((d) => d.value));
33
+ const axis = props.axes ? valueAxis(lo, hi, 4) : { min: lo, max: hi, ticks: [] };
34
+ const range = axis.max - axis.min || 1;
35
+ return { w, h: ht, left, top, plotH, bw: (w - left) / data.length, zero: top + axis.max / range * plotH, scale: plotH / range, ticks: axis.ticks };
36
+ };
37
+ const draw = () => {
38
+ const g = geometry();
39
+ if (!g) {
40
+ frame.svg.replaceChildren();
41
+ return;
42
+ }
43
+ const every = props.labelEvery ?? Math.max(1, Math.ceil(data.length / Math.max(1, Math.floor((g.w - g.left) / (props.slantLabels ? 32 : 56)))));
44
+ const label = (x, y, text, anchor, extra = "") => `<text ${slot("label")} x="${x.toFixed(1)}" y="${y.toFixed(1)}" text-anchor="${anchor}"${extra}>${escapeXml(text)}</text>`;
45
+ let body = "";
46
+ if (props.axes) {
47
+ const fmt = props.yFormat ?? compactNumber;
48
+ for (const v of g.ticks) {
49
+ const y = g.zero - v * g.scale;
50
+ body += `<line ${slot("grid")}${v === 0 ? ' data-zero=""' : ""} x1="${g.left}" x2="${g.w}" y1="${y.toFixed(1)}" y2="${y.toFixed(1)}"/>`;
51
+ body += label(g.left - 6, y + 3, fmt(v), "end");
52
+ }
53
+ if (props.axisTitle) {
54
+ const cy = g.top + g.plotH / 2;
55
+ body += label(10, cy, props.axisTitle, "middle", ` data-title="" transform="rotate(-90 10 ${cy.toFixed(1)})"`);
56
+ }
57
+ } else body += `<line ${slot("grid")} data-base="" x1="0" x2="${g.w}" y1="${g.zero}" y2="${g.zero}"/>`;
58
+ const barW = props.axes ? Math.max(1, Math.min(g.bw * 0.62, 48)) : Math.max(1, g.bw - Math.min(4, g.bw * 0.2));
59
+ data.forEach((d, i) => {
60
+ const cx = g.left + i * g.bw + g.bw / 2;
61
+ const ht = Math.max(1, Math.abs(d.value) * g.scale);
62
+ const y = d.value >= 0 ? g.zero - ht : g.zero;
63
+ const tone = d.tone ?? (d.value >= 0 ? "profit" : "loss");
64
+ body += `<rect ${slot("bar")} data-tone="${tone}"${props.axes ? "" : ' data-thin=""'} x="${(cx - barW / 2).toFixed(1)}" y="${y.toFixed(1)}" width="${barW.toFixed(1)}" height="${ht.toFixed(1)}" rx="${props.axes ? 2 : 1.5}"/>`;
65
+ if (i % every !== 0) return;
66
+ const ly = g.top + g.plotH + 12;
67
+ const text = props.labelFormat ? props.labelFormat(d.label) : d.label;
68
+ body += props.slantLabels ? label(cx, ly, text, "end", ` transform="rotate(-45 ${cx.toFixed(1)} ${ly.toFixed(1)})"`) : label(cx, g.h - 3, text, "middle");
69
+ });
70
+ for (const m of markers) {
71
+ const x = g.left + m.at * g.bw;
72
+ body += `<line ${slot("marker")} style="stroke: ${escapeXml(m.color)}" x1="${x.toFixed(1)}" x2="${x.toFixed(1)}" y1="${g.top}" y2="${(g.top + g.plotH).toFixed(1)}"/>`;
73
+ }
74
+ frame.svg.setAttribute("viewBox", `0 0 ${g.w} ${g.h}`);
75
+ frame.svg.innerHTML = body;
76
+ };
77
+ const frame = chartFrame(barChartDef.slot("root"), barChartDef.slot("tip"), props.className, draw);
78
+ frame.el.addEventListener("pointermove", (e) => {
79
+ const g = geometry();
80
+ if (!g) return;
81
+ const i = Math.floor((e.clientX - frame.el.getBoundingClientRect().left - g.left) / g.bw);
82
+ const d = data[i];
83
+ if (!d) {
84
+ frame.tip.hidden = true;
85
+ return;
86
+ }
87
+ const top = d.value >= 0 ? g.zero - Math.abs(d.value) * g.scale : g.zero + Math.abs(d.value) * g.scale;
88
+ showTip(frame.tip, props.format ? props.format(d) : `${d.label}: ${d.value}`, g, g.left + i * g.bw + g.bw / 2, top);
89
+ });
90
+ frame.el.addEventListener("pointerleave", () => frame.tip.hidden = true);
91
+ return {
92
+ el: frame.el,
93
+ setData(next, nextMarkers = []) {
94
+ data = next;
95
+ markers = nextMarkers;
96
+ draw();
97
+ },
98
+ destroy() {
99
+ frame.disconnect();
100
+ frame.el.remove();
101
+ }
102
+ };
103
+ }
104
+
105
+ export { barChartDef, createBarChart };
@@ -0,0 +1,41 @@
1
+ import { a as VariantProps, V as VariantFn } from './variants-B4stUBnY.js';
2
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
3
+ import './t.js';
4
+
5
+ declare const buttonDef: ComponentDef<"button", "root" | "icon", "height" | "font-size-sm" | "radius" | "height-xs" | "height-sm" | "height-lg" | "font-size" | "font-size-xs">;
6
+ declare const buttonVariants: VariantFn<{
7
+ readonly variant: readonly ["default", "outline", "secondary", "ghost", "destructive", "link", "up", "down"];
8
+ readonly size: readonly ["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"];
9
+ }>;
10
+ type ButtonVariant = (typeof buttonVariants.spec.variant)[number];
11
+ type ButtonSize = (typeof buttonVariants.spec.size)[number];
12
+ interface ButtonProps extends VariantProps<typeof buttonVariants> {
13
+ /** The visible text (the `icon*` sizes show none; `label` names them). */
14
+ text?: string;
15
+ /** Icon id from the kit's registry, before the text (the icon of an `icon*` size). */
16
+ icon?: string;
17
+ /** Icon id after the text (a menu trigger's chevron). */
18
+ iconEnd?: string;
19
+ /** Accessible name; required for the `icon*` sizes, defaults to `text`. */
20
+ label?: string;
21
+ /** A toggle button's state (`aria-pressed`). Omitted: not a toggle. */
22
+ pressed?: boolean;
23
+ disabled?: boolean;
24
+ onClick?: (e: MouseEvent) => void;
25
+ /** Extra class names (layout hooks). */
26
+ className?: string;
27
+ }
28
+ interface ButtonHandle {
29
+ readonly el: HTMLButtonElement;
30
+ readonly pressed: boolean | undefined;
31
+ setPressed(pressed: boolean): void;
32
+ setDisabled(disabled: boolean): void;
33
+ /** New text (or, for an `icon*` size, a new accessible name). */
34
+ setText(text: string): void;
35
+ destroy(): void;
36
+ }
37
+ declare const BUTTON_STYLE_ID = "vela-ui-button";
38
+ declare const BUTTON_CSS: string;
39
+ declare function createButton(props?: ButtonProps): ButtonHandle;
40
+
41
+ export { BUTTON_CSS, BUTTON_STYLE_ID, type ButtonHandle, type ButtonProps, type ButtonSize, type ButtonVariant, buttonDef, buttonVariants, createButton };
package/dist/button.js ADDED
@@ -0,0 +1,10 @@
1
+ export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton } from './chunk-EZQXTO6K.js';
2
+ import './chunk-LZWZV2ZS.js';
3
+ import './chunk-G7IQLY3A.js';
4
+ import './chunk-Q6WTDVH6.js';
5
+ import './chunk-6QCILIT2.js';
6
+ import './chunk-VMCR3S2A.js';
7
+ import './chunk-IDA2BT7D.js';
8
+ import './chunk-2GQIZM5Z.js';
9
+ import './chunk-BXMWQIBO.js';
10
+ import './chunk-X66RJAIS.js';
@@ -0,0 +1,22 @@
1
+ import { Translator } from './i18n.js';
2
+
3
+ interface CalendarSettings {
4
+ readonly locale: string;
5
+ readonly numberingSystem: string;
6
+ /** The locale's language is English: the picker's own tables apply. */
7
+ readonly english: boolean;
8
+ }
9
+ /** The calendar settings of a translator (English, Latin digits, without one). */
10
+ declare function calendarSettings(i18n: Translator | null | undefined): CalendarSettings;
11
+ /** Twelve month names, January first. */
12
+ declare function monthNames(settings: CalendarSettings, width: 'long' | 'short'): string[];
13
+ /** Seven short weekday names, Sunday first (index = `Date#getDay()`). */
14
+ declare function weekdayNames(settings: CalendarSettings): string[];
15
+ /** A year as a header label (`2026`, `2026年`). */
16
+ declare function yearLabel(settings: CalendarSettings, year: number): string;
17
+ /** An integer in the settings' digits, without grouping (`2026`, `٢٠٢٦`). */
18
+ declare function plainInteger(settings: CalendarSettings, n: number): string;
19
+ /** Whether the locale writes the year before the month (`2026年9月`, not `September 2026`). */
20
+ declare function yearBeforeMonth(settings: CalendarSettings): boolean;
21
+
22
+ export { type CalendarSettings, calendarSettings, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel };
@@ -0,0 +1 @@
1
+ export { calendarSettings, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel } from './chunk-V6TTTMTE.js';
@@ -0,0 +1,98 @@
1
+ import { C as ComponentDef } from './define-D5u3F5Dj.js';
2
+ import { PlacementProps } from './placement.js';
3
+ import { ChartTheme } from './tokens.js';
4
+ import { PopoverBoundary } from './popover.js';
5
+ import './t.js';
6
+
7
+ /** One block of a deployed callout panel — plain text, or a button running a caller action. */
8
+ type CalloutPanelItem = {
9
+ type: 'text';
10
+ text: string;
11
+ } | {
12
+ type: 'button';
13
+ label: string;
14
+ /** Emphasized (selection-colored) button — the panel's main action. */
15
+ primary?: boolean;
16
+ /** Close the panel after `run` (default true — an action answers the panel). */
17
+ close?: boolean;
18
+ run(): void;
19
+ };
20
+ /** The deployed panel: an optional heading over ordered text/button blocks. */
21
+ interface CalloutPanel {
22
+ title?: string;
23
+ items: CalloutPanelItem[];
24
+ }
25
+ /** What dresses the bubble itself (the panel is what the click deploys). */
26
+ interface CalloutBubbleSpec {
27
+ /** Icon id in the icon registry (`registerIcon`), centered in the bubble. */
28
+ icon: string;
29
+ /** Bubble fill — any CSS color, token expressions included. */
30
+ background: string;
31
+ /** Icon ink (default: `currentColor` inherited from the slot). */
32
+ color?: string;
33
+ /** Accessible name. Callers typically show the same text in their own tooltip. */
34
+ label: string;
35
+ /** Deployed panel — presence makes the bubble clickable. */
36
+ panel?: CalloutPanel;
37
+ }
38
+ /** Whether activating a panel button also closes the panel (defaults to yes). */
39
+ declare function closesPanel(item: Extract<CalloutPanelItem, {
40
+ type: 'button';
41
+ }>): boolean;
42
+ /** A panel row as the view lays it out: one text block, or a run of adjacent buttons. */
43
+ type CalloutPanelRow = {
44
+ type: 'text';
45
+ text: string;
46
+ } | {
47
+ type: 'buttons';
48
+ buttons: Array<Extract<CalloutPanelItem, {
49
+ type: 'button';
50
+ }>>;
51
+ };
52
+ /**
53
+ * Group a panel's ordered items into layout rows: consecutive buttons share one row
54
+ * (the common "text above, actions below" shape falls out naturally), text blocks
55
+ * stand alone. Pure — unit-tested apart from the DOM.
56
+ */
57
+ declare function calloutPanelRows(items: CalloutPanelItem[]): CalloutPanelRow[];
58
+ declare const calloutBubbleDef: ComponentDef<"callout-bubble", "button" | "title" | "text" | "root" | "panel" | "actions", "panel-radius" | "button-radius">;
59
+ /** The panel opens where the placement props say (default below and start-aligned, 6px away,
60
+ * flipping above near the bottom edge). */
61
+ interface CalloutBubbleOptions extends CalloutBubbleSpec, PlacementProps {
62
+ /** Bubble diameter in px (default 16; the icon renders 4px smaller). */
63
+ size?: number;
64
+ /** Where the deployed panel portals (default: the document body). Pass the chart
65
+ * or widget root so the panel lives inside the host's DOM. */
66
+ host?: HTMLElement;
67
+ /** Live theme, for a panel deployed OUTSIDE a `.vela-ui` token host (renderer
68
+ * chrome on a bare chart passes its theme getter; widget chrome may omit it). */
69
+ theme?: () => ChartTheme;
70
+ /** @deprecated Use `collisionBoundary`. */
71
+ boundary?: PopoverBoundary;
72
+ }
73
+ type CalloutBubbleProps = CalloutBubbleOptions;
74
+ declare const CALLOUT_STYLE_ID = "vela-ui-callout-bubble";
75
+ declare const CALLOUT_CSS: string;
76
+ declare class CalloutBubble {
77
+ readonly el: HTMLElement;
78
+ private spec;
79
+ private readonly size;
80
+ private readonly host;
81
+ private readonly theme;
82
+ private readonly placement;
83
+ private pop;
84
+ constructor(opts: CalloutBubbleOptions);
85
+ /** Re-dress the bubble (a status change: new icon, tint, label, panel). */
86
+ set(spec: Partial<CalloutBubbleSpec>): void;
87
+ /** Whether the deployed panel is currently open. */
88
+ get open(): boolean;
89
+ /** Close the deployed panel, if any. The bubble itself stays. */
90
+ hidePanel(): void;
91
+ destroy(): void;
92
+ private dress;
93
+ private toggle;
94
+ private buildPanel;
95
+ }
96
+ declare function createCalloutBubble(props: CalloutBubbleProps): CalloutBubble;
97
+
98
+ export { CALLOUT_CSS, CALLOUT_STYLE_ID, CalloutBubble, type CalloutBubbleOptions, type CalloutBubbleProps, type CalloutBubbleSpec, type CalloutPanel, type CalloutPanelItem, type CalloutPanelRow, calloutBubbleDef, calloutPanelRows, closesPanel, createCalloutBubble };