@luxalgo/vela-ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/LICENSE +201 -0
- package/NOTICE +28 -0
- package/README.md +86 -3
- package/cli/engine.mjs +282 -0
- package/cli/index.mjs +154 -0
- package/dist/badge.d.ts +26 -0
- package/dist/badge.js +44 -0
- package/dist/bar-chart.d.ts +40 -0
- package/dist/bar-chart.js +105 -0
- package/dist/button.d.ts +55 -0
- package/dist/button.js +11 -0
- package/dist/calendar.d.ts +24 -0
- package/dist/calendar.js +1 -0
- package/dist/callout-bubble.d.ts +103 -0
- package/dist/callout-bubble.js +177 -0
- package/dist/chart.d.ts +30 -0
- package/dist/chart.js +1 -0
- package/dist/checkbox.d.ts +60 -0
- package/dist/checkbox.js +12 -0
- package/dist/chunk-2GQIZM5Z.js +28 -0
- package/dist/chunk-3Q32K4PE.js +85 -0
- package/dist/chunk-6QCILIT2.js +52 -0
- package/dist/chunk-7VMN7NKJ.js +133 -0
- package/dist/chunk-A2FJ7Y7D.js +55 -0
- package/dist/chunk-A72NWYNP.js +26 -0
- package/dist/chunk-B5ZSRUDQ.js +227 -0
- package/dist/chunk-BXMWQIBO.js +66 -0
- package/dist/chunk-C3ICYMI3.js +25 -0
- package/dist/chunk-CC3DDNFC.js +117 -0
- package/dist/chunk-E2FE6V2N.js +81 -0
- package/dist/chunk-FN2BUFNM.js +10 -0
- package/dist/chunk-FVH6L7FM.js +18 -0
- package/dist/chunk-G7IQLY3A.js +183 -0
- package/dist/chunk-GVRX3UAV.js +82 -0
- package/dist/chunk-J2QJATCD.js +12 -0
- package/dist/chunk-LZWZV2ZS.js +18 -0
- package/dist/chunk-MJ4RUGX7.js +403 -0
- package/dist/chunk-MMTMOV6R.js +31 -0
- package/dist/chunk-P4MTEMT7.js +23 -0
- package/dist/chunk-Q6WTDVH6.js +31 -0
- package/dist/chunk-S7USVSYP.js +50 -0
- package/dist/chunk-TAKSIV57.js +90 -0
- package/dist/chunk-U3EH42YY.js +72 -0
- package/dist/chunk-V2Q4MRMS.js +573 -0
- package/dist/chunk-VMCR3S2A.js +22 -0
- package/dist/chunk-WBGSYCV2.js +101 -0
- package/dist/chunk-WGULXRWD.js +351 -0
- package/dist/chunk-WXH3EFV5.js +219 -0
- package/dist/chunk-X66RJAIS.js +14 -0
- package/dist/chunk-XBEL4K33.js +142 -0
- package/dist/chunk-Z5PINFQO.js +280 -0
- package/dist/collapsible.d.ts +49 -0
- package/dist/collapsible.js +106 -0
- package/dist/color-picker.d.ts +103 -0
- package/dist/color-picker.js +19 -0
- package/dist/color.d.ts +24 -0
- package/dist/color.js +1 -0
- package/dist/context-menu.d.ts +72 -0
- package/dist/context-menu.js +161 -0
- package/dist/css.d.ts +17 -0
- package/dist/css.js +4 -0
- package/dist/data-table.d.ts +40 -0
- package/dist/data-table.js +88 -0
- package/dist/date-picker.d.ts +90 -0
- package/dist/date-picker.js +257 -0
- package/dist/define-D5u3F5Dj.d.ts +21 -0
- package/dist/dialog.d.ts +89 -0
- package/dist/dialog.js +258 -0
- package/dist/dispose.d.ts +9 -0
- package/dist/dispose.js +2 -0
- package/dist/donut.d.ts +27 -0
- package/dist/donut.js +67 -0
- package/dist/drawer.d.ts +119 -0
- package/dist/drawer.js +326 -0
- package/dist/dropdown-menu.d.ts +114 -0
- package/dist/dropdown-menu.js +18 -0
- package/dist/empty.d.ts +21 -0
- package/dist/empty.js +38 -0
- package/dist/field.d.ts +147 -0
- package/dist/field.js +328 -0
- package/dist/glyph-select.d.ts +57 -0
- package/dist/glyph-select.js +17 -0
- package/dist/h-Bl37qUis.d.ts +24 -0
- package/dist/headless.d.ts +6 -0
- package/dist/headless.js +9 -0
- package/dist/hover-card.d.ts +43 -0
- package/dist/hover-card.js +97 -0
- package/dist/i18n.d.ts +20 -0
- package/dist/i18n.js +1 -0
- package/dist/icons.d.ts +20 -0
- package/dist/icons.js +2 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +13 -0
- package/dist/input-group.d.ts +57 -0
- package/dist/input-group.js +87 -0
- package/dist/input.d.ts +54 -0
- package/dist/input.js +9 -0
- package/dist/item.d.ts +72 -0
- package/dist/item.js +131 -0
- package/dist/kbd.d.ts +19 -0
- package/dist/kbd.js +8 -0
- package/dist/kit-text.d.ts +8 -0
- package/dist/kit-text.js +2 -0
- package/dist/line-chart.d.ts +32 -0
- package/dist/line-chart.js +120 -0
- package/dist/manifest.json +4508 -0
- package/dist/month-grid.d.ts +45 -0
- package/dist/month-grid.js +157 -0
- package/dist/number-input.d.ts +99 -0
- package/dist/number-input.js +14 -0
- package/dist/page.d.ts +7 -0
- package/dist/page.js +1 -0
- package/dist/palette.d.ts +55 -0
- package/dist/palette.js +1 -0
- package/dist/placement.d.ts +98 -0
- package/dist/placement.js +1 -0
- package/dist/popover.d.ts +107 -0
- package/dist/popover.js +15 -0
- package/dist/scatter-chart.d.ts +32 -0
- package/dist/scatter-chart.js +121 -0
- package/dist/select.d.ts +112 -0
- package/dist/select.js +19 -0
- package/dist/slider.d.ts +46 -0
- package/dist/slider.js +111 -0
- package/dist/sort-button.d.ts +41 -0
- package/dist/sort-button.js +88 -0
- package/dist/sparkline.d.ts +22 -0
- package/dist/sparkline.js +72 -0
- package/dist/stat.d.ts +29 -0
- package/dist/stat.js +41 -0
- package/dist/styles.d.ts +22 -0
- package/dist/styles.js +2 -0
- package/dist/surface-events.d.ts +17 -0
- package/dist/surface-events.js +1 -0
- package/dist/surface-exit.d.ts +25 -0
- package/dist/surface-exit.js +1 -0
- package/dist/switch.d.ts +54 -0
- package/dist/switch.js +92 -0
- package/dist/t.d.ts +89 -0
- package/dist/t.js +1 -0
- package/dist/tabs.d.ts +65 -0
- package/dist/tabs.js +155 -0
- package/dist/text-area.d.ts +54 -0
- package/dist/text-area.js +9 -0
- package/dist/theme.d.ts +199 -0
- package/dist/theme.js +8 -0
- package/dist/theme.schema.json +1994 -0
- package/dist/themes/dark.css +3 -0
- package/dist/themes/light.css +3 -0
- package/dist/toggle-group.d.ts +56 -0
- package/dist/toggle-group.js +130 -0
- package/dist/tokens.d.ts +16 -0
- package/dist/tokens.js +3 -0
- package/dist/tooltip.d.ts +47 -0
- package/dist/tooltip.js +74 -0
- package/dist/variants-B4stUBnY.d.ts +16 -0
- package/dist/zag.d.ts +19 -0
- package/dist/zag.js +2 -0
- package/docs/theming.md +217 -0
- package/docs/what-to-change.md +20 -0
- package/docs/writing-a-component.md +250 -0
- package/llms.txt +71 -0
- package/package.json +90 -6
- package/registry/badge.ts +119 -0
- package/registry/bar-chart.ts +215 -0
- package/registry/button.ts +379 -0
- package/registry/callout-bubble.ts +347 -0
- package/registry/checkbox.ts +234 -0
- package/registry/collapsible.ts +271 -0
- package/registry/color-picker.ts +582 -0
- package/registry/context-menu.ts +208 -0
- package/registry/data-table.ts +215 -0
- package/registry/date-picker.ts +483 -0
- package/registry/dialog.ts +535 -0
- package/registry/donut.ts +145 -0
- package/registry/drawer.ts +636 -0
- package/registry/dropdown-menu.ts +762 -0
- package/registry/empty.ts +91 -0
- package/registry/field.ts +585 -0
- package/registry/glyph-select.ts +268 -0
- package/registry/hover-card.ts +222 -0
- package/registry/input-group.ts +229 -0
- package/registry/input.ts +181 -0
- package/registry/item.ts +376 -0
- package/registry/kbd.ts +64 -0
- package/registry/line-chart.ts +218 -0
- package/registry/month-grid.ts +328 -0
- package/registry/number-input.ts +443 -0
- package/registry/popover.ts +368 -0
- package/registry/scatter-chart.ts +221 -0
- package/registry/select.ts +620 -0
- package/registry/slider.ts +259 -0
- package/registry/sort-button.ts +189 -0
- package/registry/sparkline.ts +114 -0
- package/registry/stat.ts +96 -0
- package/registry/switch.ts +205 -0
- package/registry/tabs.ts +426 -0
- package/registry/text-area.ts +186 -0
- package/registry/toggle-group.ts +295 -0
- package/registry/tooltip.ts +156 -0
- package/skills/theming-vela-ui/SKILL.md +137 -0
- package/skills/using-vela-ui-components/SKILL.md +137 -0
- package/skills/writing-vela-ui-components/SKILL.md +163 -0
- package/src/components/badge.ts +119 -0
- package/src/components/bar-chart.ts +215 -0
- package/src/components/button.ts +379 -0
- package/src/components/callout-bubble.ts +347 -0
- package/src/components/checkbox.ts +234 -0
- package/src/components/collapsible.ts +271 -0
- package/src/components/color-picker.ts +582 -0
- package/src/components/context-menu.ts +208 -0
- package/src/components/data-table.ts +215 -0
- package/src/components/date-picker.ts +483 -0
- package/src/components/dialog.ts +535 -0
- package/src/components/donut.ts +145 -0
- package/src/components/drawer.ts +636 -0
- package/src/components/dropdown-menu.ts +762 -0
- package/src/components/empty.ts +91 -0
- package/src/components/field.ts +585 -0
- package/src/components/glyph-select.ts +268 -0
- package/src/components/hover-card.ts +222 -0
- package/src/components/input-group.ts +229 -0
- package/src/components/input.ts +181 -0
- package/src/components/item.ts +376 -0
- package/src/components/kbd.ts +64 -0
- package/src/components/line-chart.ts +218 -0
- package/src/components/month-grid.ts +328 -0
- package/src/components/number-input.ts +443 -0
- package/src/components/popover.ts +368 -0
- package/src/components/scatter-chart.ts +221 -0
- package/src/components/select.ts +620 -0
- package/src/components/slider.ts +259 -0
- package/src/components/sort-button.ts +189 -0
- package/src/components/sparkline.ts +114 -0
- package/src/components/stat.ts +96 -0
- package/src/components/switch.ts +205 -0
- package/src/components/tabs.ts +426 -0
- package/src/components/text-area.ts +186 -0
- package/src/components/toggle-group.ts +295 -0
- package/src/components/tooltip.ts +156 -0
- package/src/index.ts +24 -0
- package/src/lib/calendar.ts +117 -0
- package/src/lib/chart.ts +72 -0
- package/src/lib/color.ts +89 -0
- package/src/lib/component-index.ts +151 -0
- package/src/lib/css.ts +48 -0
- package/src/lib/define.ts +45 -0
- package/src/lib/dispose.ts +36 -0
- package/src/lib/h.ts +55 -0
- package/src/lib/headless.ts +16 -0
- package/src/lib/i18n.ts +30 -0
- package/src/lib/icons.ts +237 -0
- package/src/lib/kit-text.ts +26 -0
- package/src/lib/page.ts +24 -0
- package/src/lib/palette.ts +81 -0
- package/src/lib/placement.ts +188 -0
- package/src/lib/scope.ts +135 -0
- package/src/lib/styles.ts +53 -0
- package/src/lib/surface-events.ts +31 -0
- package/src/lib/surface-exit.ts +87 -0
- package/src/lib/t.ts +68 -0
- package/src/lib/theme.ts +664 -0
- package/src/lib/tokens.ts +111 -0
- package/src/lib/variants.ts +32 -0
- package/src/lib/zag.ts +46 -0
- package/stylelint/index.mjs +60 -0
- package/stylelint/lint.mjs +81 -0
- package/stylelint/plugin.mjs +115 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
3
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
4
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
5
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
6
|
+
|
|
7
|
+
// src/components/text-area.ts
|
|
8
|
+
function textAreaController(opts = {}) {
|
|
9
|
+
let value = opts.value ?? opts.defaultValue ?? "";
|
|
10
|
+
return {
|
|
11
|
+
get value() {
|
|
12
|
+
return value;
|
|
13
|
+
},
|
|
14
|
+
size: opts.size ?? "md",
|
|
15
|
+
rows: opts.rows ?? 3,
|
|
16
|
+
disabled: opts.disabled ?? false,
|
|
17
|
+
commit(next) {
|
|
18
|
+
if (next === value) return null;
|
|
19
|
+
value = next;
|
|
20
|
+
opts.onChange?.(next);
|
|
21
|
+
return next;
|
|
22
|
+
},
|
|
23
|
+
sync(next) {
|
|
24
|
+
value = next;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var textAreaDef = defineComponent({
|
|
29
|
+
name: "text-area",
|
|
30
|
+
parts: ["root", "input"],
|
|
31
|
+
settings: { radius: t.radius.md, "focus-ring": `0 0 0 3px ${t.focus.soft}` }
|
|
32
|
+
});
|
|
33
|
+
var textAreaVariants = variants({ size: ["md", "sm"] });
|
|
34
|
+
var injectStyles = defineStyles(
|
|
35
|
+
"vela-ui-textarea",
|
|
36
|
+
css`@layer vela.ui{[data-slot=text-area-input]{box-sizing:border-box;border:1px solid ${t.border.strong};border-radius:${textAreaDef.vars.radius};width:100%;min-height:64px;color:${t.fg.bright};resize:vertical;transition:border-color ${t.dur.fast} ease, box-shadow ${t.dur.fast} ease;-webkit-user-select:text;user-select:text;background:0 0;outline:2px solid #0000;padding:8px;font-family:inherit;font-size:14px;line-height:1.4;display:block}[data-slot=text-area-input]:hover{border-color:${t.fg.muted}}[data-slot=text-area-input]:focus{border-color:${t.focus};box-shadow:${textAreaDef.vars["focus-ring"]}}[data-slot=text-area-input]::placeholder{color:currentColor;opacity:.4}[data-slot=text-area]{width:100%;min-width:0}[data-slot=text-area]:where(:not([hidden])){display:block}[data-slot=text-area][data-autogrow] [data-slot=text-area-input]{resize:none;min-height:46px;overflow-y:hidden}[data-slot=text-area][data-size=sm] [data-slot=text-area-input]{min-height:46px;padding:6px 9px;font-size:13px;line-height:18px}}`
|
|
37
|
+
);
|
|
38
|
+
var TextArea = class {
|
|
39
|
+
constructor(opts = {}) {
|
|
40
|
+
injectStyles(document);
|
|
41
|
+
this.ctrl = textAreaController(opts);
|
|
42
|
+
this.autoGrow = opts.autoGrow === true;
|
|
43
|
+
this.maxLines = opts.maxLines ?? 4;
|
|
44
|
+
const ta = h("textarea", { className: "vela-textarea-field", slot: textAreaDef.slot("input"), attrs: { id: opts.id, placeholder: opts.placeholder, name: opts.name } });
|
|
45
|
+
ta.required = opts.required === true;
|
|
46
|
+
ta.rows = this.ctrl.rows;
|
|
47
|
+
ta.value = this.ctrl.value;
|
|
48
|
+
ta.disabled = this.ctrl.disabled;
|
|
49
|
+
ta.addEventListener("blur", () => {
|
|
50
|
+
this.ctrl.commit(ta.value);
|
|
51
|
+
});
|
|
52
|
+
if (this.autoGrow) ta.addEventListener("input", () => this.grow());
|
|
53
|
+
this.el = h("div", { className: "vela-textarea", slot: textAreaDef.slot("root"), attrs: textAreaVariants({ size: this.ctrl.size }), data: { autogrow: this.autoGrow } }, ta);
|
|
54
|
+
this.input = ta;
|
|
55
|
+
if (this.autoGrow) this.grow();
|
|
56
|
+
}
|
|
57
|
+
get value() {
|
|
58
|
+
return this.ctrl.value;
|
|
59
|
+
}
|
|
60
|
+
setValue(v) {
|
|
61
|
+
this.ctrl.sync(v);
|
|
62
|
+
this.input.value = v;
|
|
63
|
+
if (this.autoGrow) this.grow();
|
|
64
|
+
}
|
|
65
|
+
destroy() {
|
|
66
|
+
}
|
|
67
|
+
grow() {
|
|
68
|
+
const ta = this.input;
|
|
69
|
+
const lh = parseFloat(getComputedStyle(ta).lineHeight) || 18;
|
|
70
|
+
const pad = ta.clientHeight - (ta.offsetHeight ? lh * (ta.rows || 1) : 0);
|
|
71
|
+
const max = lh * this.maxLines + (Number.isFinite(pad) && pad > 0 ? pad : 12);
|
|
72
|
+
ta.style.height = "auto";
|
|
73
|
+
ta.style.height = `${Math.min(ta.scrollHeight, max)}px`;
|
|
74
|
+
ta.style.overflowY = ta.scrollHeight > max ? "auto" : "hidden";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function createTextArea(props = {}) {
|
|
78
|
+
return new TextArea(props);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { TextArea, createTextArea, textAreaController, textAreaDef, textAreaVariants };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/lib/i18n.ts
|
|
2
|
+
function msg(id, defaultMessage) {
|
|
3
|
+
return Object.freeze({ id, defaultMessage });
|
|
4
|
+
}
|
|
5
|
+
function textOf(i18n, message) {
|
|
6
|
+
if (i18n) return i18n.t(message);
|
|
7
|
+
return typeof message === "string" ? message : message.defaultMessage;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { msg, textOf };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { pageState } from './chunk-X66RJAIS.js';
|
|
2
|
+
|
|
3
|
+
// src/lib/kit-text.ts
|
|
4
|
+
var scope = pageState("kit-text@1", () => ({ current: null }));
|
|
5
|
+
function withKitTranslator(i18n, build) {
|
|
6
|
+
const previous = scope.current;
|
|
7
|
+
scope.current = i18n ?? null;
|
|
8
|
+
try {
|
|
9
|
+
return build();
|
|
10
|
+
} finally {
|
|
11
|
+
scope.current = previous;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function kitTranslator() {
|
|
15
|
+
return scope.current;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { kitTranslator, withKitTranslator };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { pageState } from './chunk-X66RJAIS.js';
|
|
2
|
+
|
|
3
|
+
// src/lib/icons.ts
|
|
4
|
+
var registry = pageState("icons@1", () => /* @__PURE__ */ new Map());
|
|
5
|
+
function registerIcon(id, svg) {
|
|
6
|
+
registry.set(id, svg);
|
|
7
|
+
}
|
|
8
|
+
function iconMarkup(id) {
|
|
9
|
+
return registry.get(id) ?? null;
|
|
10
|
+
}
|
|
11
|
+
function icon(id) {
|
|
12
|
+
return registry.get(id) ?? "";
|
|
13
|
+
}
|
|
14
|
+
function iconAt(id, px) {
|
|
15
|
+
return icon(id).replace("<svg ", `<svg width="${px}" height="${px}" `);
|
|
16
|
+
}
|
|
17
|
+
function svg16(body, extra = "") {
|
|
18
|
+
return `<svg viewBox="0 0 16 16" width="1em" height="1em" ${extra ? extra + " " : ""}fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
19
|
+
}
|
|
20
|
+
function svg24(body, extra = "") {
|
|
21
|
+
return `<svg viewBox="0 0 24 24" width="1em" height="1em" ${extra ? extra + " " : ""}fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">${body}</svg>`;
|
|
22
|
+
}
|
|
23
|
+
function svg24Solid(body) {
|
|
24
|
+
return `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none">${body}</svg>`;
|
|
25
|
+
}
|
|
26
|
+
var S = svg16;
|
|
27
|
+
registerIcon(
|
|
28
|
+
"style-candles",
|
|
29
|
+
S('<path d="M4.5 2v2M4.5 12v2M11.5 2v1.5M11.5 11v3"/><rect x="2.8" y="4" width="3.4" height="8" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="3.5" width="3.4" height="7.5" rx="0.6" fill="currentColor"/>')
|
|
30
|
+
);
|
|
31
|
+
registerIcon(
|
|
32
|
+
"style-bars",
|
|
33
|
+
S('<path d="M4.5 2.5v11M2.5 5h2M4.5 11h2"/><path d="M11.5 2.5v11M9.5 4.5h2M11.5 10.5h2"/>')
|
|
34
|
+
);
|
|
35
|
+
registerIcon("style-line", S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/>'));
|
|
36
|
+
registerIcon(
|
|
37
|
+
"style-area",
|
|
38
|
+
S('<path d="M1.5 11.5 5.5 7l3 2.5 5-6"/><path d="M1.5 11.5 5.5 7l3 2.5 5-6V13.5h-12z" fill="currentColor" fill-opacity="0.25" stroke="none"/>')
|
|
39
|
+
);
|
|
40
|
+
registerIcon(
|
|
41
|
+
"style-baseline",
|
|
42
|
+
S('<path d="M1.5 8h13" stroke-dasharray="2 2"/><path d="M2.5 8 5.25 4.5 8 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M2.5 8 5.25 4.5 8 8"/><path d="M8 8l2.75 3.5L13.5 8h-5.5z" fill="currentColor" fill-opacity="0.25" stroke="none"/><path d="M8 8l2.75 3.5L13.5 8"/>')
|
|
43
|
+
);
|
|
44
|
+
registerIcon(
|
|
45
|
+
"style-heikinashi",
|
|
46
|
+
S('<path d="M4.5 12v2M11.5 2v2"/><rect x="2.8" y="5" width="3.4" height="7" rx="0.6" fill="currentColor" fill-opacity="0.25"/><rect x="9.8" y="4" width="3.4" height="7" rx="0.6" fill="currentColor"/>')
|
|
47
|
+
);
|
|
48
|
+
registerIcon("indicators", S('<path d="M1.5 12.5 5 7l2.5 3.5L11 4l3.5 5"/><circle cx="11" cy="4" r="1.4" fill="currentColor" stroke="none"/>'));
|
|
49
|
+
registerIcon("undo", S('<path d="M6.2 9.5 2.7 6l3.5-3.5"/><path d="M2.7 6h6.8a3.65 3.65 0 0 1 0 7.3H7.5"/>'));
|
|
50
|
+
registerIcon("redo", S('<path d="M9.8 9.5 13.3 6 9.8 2.5"/><path d="M13.3 6H6.5a3.65 3.65 0 0 0 0 7.3h2"/>'));
|
|
51
|
+
registerIcon(
|
|
52
|
+
"objects",
|
|
53
|
+
S('<path d="M8 1.8 14 5 8 8.2 2 5z"/><path d="M2 8l6 3.2L14 8" opacity="0.7"/><path d="M2 11l6 3.2 6-3.2" opacity="0.4"/>')
|
|
54
|
+
);
|
|
55
|
+
registerIcon("clock", S('<circle cx="8" cy="8" r="6.2"/><path d="M8 4.8V8l2.4 1.6"/>'));
|
|
56
|
+
registerIcon(
|
|
57
|
+
"calendar",
|
|
58
|
+
S('<rect x="2.2" y="3.2" width="11.6" height="10.6" rx="1.4"/><path d="M5.2 1.8v2.8M10.8 1.8v2.8M2.2 6.8h11.6"/>')
|
|
59
|
+
);
|
|
60
|
+
registerIcon("datawindow", S('<rect x="1.8" y="2.5" width="12.4" height="11" rx="1.5"/><path d="M4.5 5.5h4M4.5 8h7M4.5 10.5h5.5"/>'));
|
|
61
|
+
registerIcon("camera", S('<path d="M5.5 4 6.5 2.5h3L10.5 4h3A1 1 0 0 1 14.5 5v7.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1z"/><circle cx="8" cy="8.5" r="2.6"/>'));
|
|
62
|
+
registerIcon(
|
|
63
|
+
"gear",
|
|
64
|
+
S('<path d="M6.55 1.4h2.9l.32 1.72c.48.14.92.38 1.3.7l1.66-.55 1.45 2.5-1.35 1.1c.08.34.12.7.12 1.07s-.04.73-.12 1.07l1.35 1.1-1.45 2.5-1.66-.55a4.3 4.3 0 0 1-1.3.7L9.45 14.6h-2.9l-.32-1.72a4.3 4.3 0 0 1-1.3-.7l-1.66.55-1.45-2.5 1.35-1.1A4.4 4.4 0 0 1 3.05 7.94c0-.37.04-.73.12-1.07l-1.35-1.1 1.45-2.5 1.66.55c.38-.32.82-.56 1.3-.7L6.55 1.4z"/><circle cx="8" cy="8" r="2.2"/>')
|
|
65
|
+
);
|
|
66
|
+
registerIcon("search", S('<circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3.5 3.5"/>'));
|
|
67
|
+
registerIcon("bell", S('<path d="M8 2a4 4 0 0 0-4 4v2.5L2.5 11v1h11v-1L12 8.5V6a4 4 0 0 0-4-4z"/><path d="M6.5 13.5a1.5 1.5 0 0 0 3 0"/>'));
|
|
68
|
+
registerIcon(
|
|
69
|
+
"market-open",
|
|
70
|
+
svg24('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>')
|
|
71
|
+
);
|
|
72
|
+
registerIcon(
|
|
73
|
+
"market-pre",
|
|
74
|
+
svg24('<path d="M12 2v8"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m8 6 4-4 4 4"/><path d="M16 18a4 4 0 0 0-8 0"/>')
|
|
75
|
+
);
|
|
76
|
+
registerIcon(
|
|
77
|
+
"market-post",
|
|
78
|
+
svg24('<path d="M12 10V2"/><path d="m4.93 10.93 1.41 1.41"/><path d="M2 18h2"/><path d="M20 18h2"/><path d="m19.07 10.93-1.41 1.41"/><path d="M22 22H2"/><path d="m16 14-4 4-4-4"/><path d="M16 6a4 4 0 0 0-8 0"/>')
|
|
79
|
+
);
|
|
80
|
+
registerIcon(
|
|
81
|
+
"market-extended",
|
|
82
|
+
svg24('<path d="M22 22H2"/><path d="M12 3a5 5 0 0 0 7.5 7.5A7.5 7.5 0 1 1 12 3Z"/>')
|
|
83
|
+
);
|
|
84
|
+
registerIcon("market-closed", svg24('<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>'));
|
|
85
|
+
registerIcon(
|
|
86
|
+
"market-holiday",
|
|
87
|
+
svg24('<path d="m10 20-1.25-2.5L6 16"/><path d="M10 4 8.75 6.5 6 8"/><path d="m14 20 1.25-2.5L18 16"/><path d="m14 4 1.25 2.5L18 8"/><path d="m17 10-5 5-5-5"/><path d="M4 12h16"/>')
|
|
88
|
+
);
|
|
89
|
+
registerIcon("chevron-right", S('<path d="m6 3.5 4.5 4.5L6 12.5"/>'));
|
|
90
|
+
registerIcon("chevron-left", S('<path d="M10 3.5 5.5 8l4.5 4.5"/>'));
|
|
91
|
+
registerIcon("chevron-down", S('<path d="M3.5 6 8 10.5 12.5 6"/>'));
|
|
92
|
+
registerIcon("chevron-up", S('<path d="M3.5 10 8 5.5 12.5 10"/>'));
|
|
93
|
+
registerIcon("chevrons-right", S('<path d="m4 3.5 4.5 4.5L4 12.5"/><path d="m8.5 3.5 4.5 4.5-4.5 4.5"/>'));
|
|
94
|
+
registerIcon("chevrons-left", S('<path d="M12 3.5 7.5 8l4.5 4.5"/><path d="M7.5 3.5 3 8l4.5 4.5"/>'));
|
|
95
|
+
registerIcon("replay", S('<path d="M14 4.2v7.6L8.6 8z"/><path d="M7.4 4.2v7.6L2 8z"/>'));
|
|
96
|
+
registerIcon("check", S('<path d="m2.8 8.4 3.4 3.4 7-7.6"/>'));
|
|
97
|
+
registerIcon("close", S('<path d="m3.8 3.8 8.4 8.4M12.2 3.8l-8.4 8.4"/>'));
|
|
98
|
+
registerIcon("pin", S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/>'));
|
|
99
|
+
registerIcon("pin-filled", S('<path d="M5.6 2.5h4.8M6.4 2.5v3.6L4.4 8.4v.9h7.2v-.9L9.6 6.1V2.5M8 9.3v4.2"/><path d="M6.4 2.5h3.2v3.6l2 2.3v.9H4.4v-.9l2-2.3z" fill="currentColor" stroke="none"/>'));
|
|
100
|
+
registerIcon("eye", S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="1.8"/>'));
|
|
101
|
+
registerIcon("eye-off", S('<path d="M1.5 8s2.5-5.4 6.5-5.4S14.5 8 14.5 8 12 13.4 8 13.4 1.5 8 1.5 8z" opacity="0.45"/><path d="m3 13 10-10"/>'));
|
|
102
|
+
registerIcon("lock", S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.8 0V7"/>'));
|
|
103
|
+
registerIcon("unlock", S('<rect x="3.2" y="7" width="9.6" height="6.6" rx="1.2"/><path d="M5.6 7V5.2a2.4 2.4 0 0 1 4.7-.7"/>'));
|
|
104
|
+
registerIcon("trash", S('<path d="M2.5 4.3h11M6.2 4.3V3.1a1 1 0 0 1 1-1h1.6a1 1 0 0 1 1 1v1.2M4.2 4.3l.5 9.1a1.15 1.15 0 0 0 1.15 1.1h4.3a1.15 1.15 0 0 0 1.15-1.1l.5-9.1M6.5 7v4.5M9.5 7v4.5"/>'));
|
|
105
|
+
registerIcon("group", S('<path d="M1.8 4.5V2.4a.6.6 0 0 1 .6-.6h2.1M11.5 1.8h2.1a.6.6 0 0 1 .6.6v2.1M14.2 11.5v2.1a.6.6 0 0 1-.6.6h-2.1M4.5 14.2H2.4a.6.6 0 0 1-.6-.6v-2.1"/><rect x="4" y="4" width="4.2" height="4.2" rx="0.7"/><rect x="7.8" y="7.8" width="4.2" height="4.2" rx="0.7"/>'));
|
|
106
|
+
registerIcon("ungroup", S('<rect x="1.6" y="1.6" width="6.2" height="6.2" rx="0.9"/><rect x="8.2" y="8.2" width="6.2" height="6.2" rx="0.9" stroke-dasharray="2 1.5"/>'));
|
|
107
|
+
registerIcon("clone", S('<rect x="5.5" y="5.5" width="9" height="9" rx="1.2"/><path d="M11 5.5v-3a1 1 0 0 0-1-1H2.5a1 1 0 0 0-1 1V10a1 1 0 0 0 1 1h3"/>'));
|
|
108
|
+
registerIcon("arrow-up", S('<path d="M8 13.2V3M4.2 6.8 8 3l3.8 3.8"/>'));
|
|
109
|
+
registerIcon("arrow-down", S('<path d="M8 2.8V13M4.2 9.2 8 13l3.8-3.8"/>'));
|
|
110
|
+
registerIcon("move-vertical", S('<path d="M8 2.5v11M5 5.5 8 2.5l3 3M5 10.5l3 3 3-3"/>'));
|
|
111
|
+
registerIcon("move", S('<path d="M8 1.8v12.4M1.8 8h12.4M5.6 4.2 8 1.8l2.4 2.4M5.6 11.8 8 14.2l2.4-2.4M4.2 5.6 1.8 8l2.4 2.4M11.8 5.6 14.2 8l-2.4 2.4"/>'));
|
|
112
|
+
registerIcon("pen", S('<path d="m10.8 2.2 3 3-8 8-3.6.6.6-3.6z"/><path d="m9.2 3.8 3 3"/>'));
|
|
113
|
+
registerIcon("wave", S('<path d="M1.5 10.4c1.6 0 1.9-4.8 3.4-4.8s1.8 4.8 3.4 4.8 1.8-4.8 3.4-4.8 1.6 4.8 2.8 4.8"/>'));
|
|
114
|
+
registerIcon("folder-plus", S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M8 7.6v3.6M6.2 9.4h3.6"/>'));
|
|
115
|
+
registerIcon("folder-minus", S('<path d="M1.6 4.4a1 1 0 0 1 1-1h2.7l1.3 1.7h6.8a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-10.8a1 1 0 0 1-1-1z"/><path d="M6.2 9.4h3.6"/>'));
|
|
116
|
+
registerIcon("collapse", S('<path d="M3 8h10"/>'));
|
|
117
|
+
registerIcon("expand", S('<rect x="2.2" y="2.2" width="11.6" height="11.6" rx="1.4"/><path d="M8 5.4v5.2M5.4 8h5.2"/>'));
|
|
118
|
+
registerIcon("plus", S('<path d="M8 2.8v10.4M2.8 8h10.4"/>'));
|
|
119
|
+
registerIcon("minus", S('<path d="M2.8 8h10.4"/>'));
|
|
120
|
+
registerIcon("maximize", S('<path d="M2.5 6V3a.5.5 0 0 1 .5-.5h3M10 2.5h3a.5.5 0 0 1 .5.5v3M13.5 10v3a.5.5 0 0 1-.5.5h-3M6 13.5H3a.5.5 0 0 1-.5-.5v-3"/>'));
|
|
121
|
+
registerIcon("restore", S('<path d="M6 2.5v3a.5.5 0 0 1-.5.5h-3M13.5 6h-3a.5.5 0 0 1-.5-.5v-3M10 13.5v-3a.5.5 0 0 1 .5-.5h3M2.5 10h3a.5.5 0 0 1 .5.5v3"/>'));
|
|
122
|
+
registerIcon("restore", S('<path d="M6.2 2.5v3.7H2.5M9.8 13.5V9.8h3.7M13.5 6.2H9.8V2.5M2.5 9.8h3.7v3.7"/>'));
|
|
123
|
+
registerIcon("star", S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>'));
|
|
124
|
+
registerIcon("star-filled", S('<path d="M8 2.2l1.75 3.55 3.9.55-2.8 2.75.65 3.9L8 11.1l-3.5 1.85.65-3.9-2.8-2.75 3.9-.55z"/>', 'fill="currentColor"'));
|
|
125
|
+
registerIcon("grip", S('<circle cx="6" cy="3.5" r="1"/><circle cx="10" cy="3.5" r="1"/><circle cx="6" cy="8" r="1"/><circle cx="10" cy="8" r="1"/><circle cx="6" cy="12.5" r="1"/><circle cx="10" cy="12.5" r="1"/>', 'fill="currentColor" stroke="none"'));
|
|
126
|
+
registerIcon("kebab", S('<circle cx="8" cy="3.2" r="1.2"/><circle cx="8" cy="8" r="1.2"/><circle cx="8" cy="12.8" r="1.2"/>', 'fill="currentColor" stroke="none"'));
|
|
127
|
+
registerIcon("burger", S('<path d="M2.5 4.5h11M2.5 8h11M2.5 11.5h11"/>'));
|
|
128
|
+
registerIcon("info", S('<path d="M8 7.4v4.4"/><circle cx="8" cy="4.6" r="0.9" fill="currentColor" stroke="none"/>'));
|
|
129
|
+
registerIcon("reset", S('<path d="M2 8a6 6 0 1 0 6-6 6.5 6.5 0 0 0-4.5 1.83L2 5.33"/><path d="M2 2v3.33h3.33"/>'));
|
|
130
|
+
registerIcon("pane-collapse", S('<path d="M2.6 9.4h4v4M13.4 6.6h-4v-4"/><path d="m9.4 6.6 4.2-4.2M2.4 13.6l4.2-4.2"/>'));
|
|
131
|
+
registerIcon("pane-expand", S('<path d="M9.8 2.4h3.8v3.8M6.2 13.6H2.4V9.8"/><path d="m13.6 2.4-4.4 4.4M2.4 13.6l4.4-4.4"/>'));
|
|
132
|
+
registerIcon("cursor", svg24('<path d="M5 3l6 16 2-6 6-2z"/>', 'fill="currentColor" stroke="none"'));
|
|
133
|
+
registerIcon(
|
|
134
|
+
"ruler",
|
|
135
|
+
svg24('<path d="M21.3 15.3 8.7 2.7a1 1 0 0 0-1.4 0L2.7 7.3a1 1 0 0 0 0 1.4l12.6 12.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4Z"/><path d="m7.5 10.5 2 2"/><path d="m10.5 7.5 2 2"/><path d="m13.5 4.5 2 2"/><path d="m4.5 13.5 2 2"/>')
|
|
136
|
+
);
|
|
137
|
+
registerIcon(
|
|
138
|
+
"magnet",
|
|
139
|
+
svg24('<path d="m6 15-4-4 6.75-6.77a7.79 7.79 0 0 1 11 11L13 22l-4-4 6.39-6.36a2.14 2.14 0 0 0-3-3L6 15"/><path d="m5 8 4 4"/><path d="m12 15 4 4"/>')
|
|
140
|
+
);
|
|
141
|
+
registerIcon(
|
|
142
|
+
"eraser",
|
|
143
|
+
svg24('<path d="m7 21-4.3-4.3a1 1 0 0 1 0-1.4L13 5a2 2 0 0 1 2.8 0l4.2 4.2a2 2 0 0 1 0 2.8L12 20"/><path d="M22 21H7"/><path d="m5 11 9 9"/>')
|
|
144
|
+
);
|
|
145
|
+
registerIcon(
|
|
146
|
+
"pen-lock",
|
|
147
|
+
svg24('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="13" y="14.5" width="8" height="6" rx="1.2"/><path d="M15 14.5v-1.6a2 2 0 0 1 4 0v1.6"/>')
|
|
148
|
+
);
|
|
149
|
+
registerIcon(
|
|
150
|
+
"pen-sync",
|
|
151
|
+
// Pen + two stacked panes — drawing onto every linked chart at once.
|
|
152
|
+
svg24('<path d="M13.8 4.2a2.1 2.1 0 0 1 3 3L8.5 15.5l-3.5 1 1-3.5Z"/><rect x="12.5" y="13.5" width="6" height="4.8" rx="1"/><path d="M15.5 18.3v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-2.8a1 1 0 0 0-1-1h-1"/>')
|
|
153
|
+
);
|
|
154
|
+
registerIcon("brush", svg24('<path d="M9.5 12 17 4.5a2.12 2.12 0 0 1 3 3L12.5 15"/><path d="M7 14a3 3 0 0 0-3 3c0 1.3-1.2 1.5-1.5 2 .8.9 2 1.5 3.5 1.5a3.5 3.5 0 0 0 3.5-3.5 3 3 0 0 0-2.5-3Z"/>'));
|
|
155
|
+
registerIcon(
|
|
156
|
+
"bucket",
|
|
157
|
+
svg24('<path d="m18.5 11.5-7-7L4 12a1.8 1.8 0 0 0 0 2.5l5 5a1.8 1.8 0 0 0 2.5 0Z"/><path d="m5 5 4 4"/><path d="M3.5 13.5h13"/><path d="M21 17.5c0 1.1-.9 2-2 2s-2-.9-2-2c0-1 1.2-1.7 2-3 .8 1.3 2 2 2 3Z"/>')
|
|
158
|
+
);
|
|
159
|
+
registerIcon("type", svg24('<path d="M5 6V4.5h14V6"/><path d="M12 4.5v15"/><path d="M9.5 19.5h5"/>'));
|
|
160
|
+
registerIcon("bold", svg24('<path d="M7 5h6a3.5 3.5 0 0 1 0 7H7Z"/><path d="M7 12h7a3.5 3.5 0 0 1 0 7H7Z"/>', 'stroke-width="2.4"'));
|
|
161
|
+
registerIcon("italic", svg24('<path d="M15 5h-5M14 19H9M14.5 5 10 19"/>', 'stroke-width="2.2"'));
|
|
162
|
+
registerIcon("price-delta", svg24('<path d="M12 4v16"/><path d="M8 8l4-4 4 4"/><path d="M8 16l4 4 4-4"/>'));
|
|
163
|
+
registerIcon("date-delta", svg24('<path d="M4 12h16"/><path d="M8 8l-4 4 4 4"/><path d="M16 8l4 4-4 4"/>'));
|
|
164
|
+
registerIcon("bring-front", svg24('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/>'));
|
|
165
|
+
registerIcon(
|
|
166
|
+
"send-back",
|
|
167
|
+
svg24('<rect x="8.5" y="8.5" width="7" height="7" rx="1.5" fill="currentColor" stroke="none" opacity="0.35"/><path d="M4.5 10.5V6a1.5 1.5 0 0 1 1.5-1.5h4.5"/><path d="M19.5 13.5V18a1.5 1.5 0 0 1-1.5 1.5h-4.5"/><rect x="8.5" y="8.5" width="7" height="7" rx="1.5"/>')
|
|
168
|
+
);
|
|
169
|
+
registerIcon("r-squared", '<svg viewBox="0 0 24 24" width="1em" height="1em" fill="currentColor" stroke="none"><text x="2.5" y="17.5" font-size="14" font-family="serif">R\xB2</text></svg>');
|
|
170
|
+
registerIcon("bands", svg24('<path d="M3 6h18"/><path d="M3 18h18"/><path d="M3 12h18" stroke-dasharray="3 3"/>'));
|
|
171
|
+
registerIcon("dedekind", svg24('<path d="M2 20h20"/><path d="M4 20a8 8 0 0 1 16 0"/><path d="M8 20a4 4 0 0 1 8 0"/><path d="M12 4v16"/>'));
|
|
172
|
+
registerIcon("sonic", svg24('<circle cx="15" cy="12" r="4"/><circle cx="12" cy="12" r="2.5"/><path d="M8 5v14"/>'));
|
|
173
|
+
registerIcon("supersonic", svg24('<circle cx="16" cy="12" r="3.5"/><path d="M6 12 15 6M6 12 15 18"/>'));
|
|
174
|
+
function iconEl(id, doc = document) {
|
|
175
|
+
const span = doc.createElement("span");
|
|
176
|
+
span.className = "vela-icon";
|
|
177
|
+
span.setAttribute("aria-hidden", "true");
|
|
178
|
+
const svg = iconMarkup(id);
|
|
179
|
+
if (svg) span.innerHTML = svg;
|
|
180
|
+
return span;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export { icon, iconAt, iconEl, iconMarkup, registerIcon, svg16, svg24, svg24Solid };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/lib/calendar.ts
|
|
2
|
+
var EN_MONTHS_LONG = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
3
|
+
var EN_MONTHS_SHORT = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
4
|
+
var EN_WEEKDAYS_MIN = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
5
|
+
var BIDI_MARKS = /[\u200e\u200f\u061c]/g;
|
|
6
|
+
var stripBidiMarks = (text) => text.replace(BIDI_MARKS, "");
|
|
7
|
+
function calendarSettings(i18n) {
|
|
8
|
+
const locale = i18n?.locale ?? "en";
|
|
9
|
+
let language = locale.split(/[-_]/)[0] ?? locale;
|
|
10
|
+
try {
|
|
11
|
+
language = new Intl.Locale(locale).language;
|
|
12
|
+
} catch {
|
|
13
|
+
}
|
|
14
|
+
return { locale, numberingSystem: i18n?.numberingSystem ?? "latn", english: language.toLowerCase() === "en" };
|
|
15
|
+
}
|
|
16
|
+
var dateFormats = /* @__PURE__ */ new Map();
|
|
17
|
+
function dateFormat(settings, options) {
|
|
18
|
+
const key = `${settings.locale}|${settings.numberingSystem}|${JSON.stringify(options)}`;
|
|
19
|
+
let dtf = dateFormats.get(key);
|
|
20
|
+
if (!dtf) {
|
|
21
|
+
try {
|
|
22
|
+
dtf = new Intl.DateTimeFormat(settings.locale, { ...options, timeZone: "UTC", calendar: "gregory", numberingSystem: settings.numberingSystem });
|
|
23
|
+
} catch {
|
|
24
|
+
dtf = new Intl.DateTimeFormat("en", { ...options, timeZone: "UTC", calendar: "gregory" });
|
|
25
|
+
}
|
|
26
|
+
dateFormats.set(key, dtf);
|
|
27
|
+
}
|
|
28
|
+
return dtf;
|
|
29
|
+
}
|
|
30
|
+
var digitTables = /* @__PURE__ */ new Map();
|
|
31
|
+
function localizeDigits(text, settings) {
|
|
32
|
+
const key = `${settings.locale}|${settings.numberingSystem}`;
|
|
33
|
+
let digits = digitTables.get(key);
|
|
34
|
+
if (digits === void 0) {
|
|
35
|
+
let nf;
|
|
36
|
+
try {
|
|
37
|
+
nf = new Intl.NumberFormat(settings.locale, { numberingSystem: settings.numberingSystem, useGrouping: false, maximumFractionDigits: 0 });
|
|
38
|
+
} catch {
|
|
39
|
+
nf = new Intl.NumberFormat("en", { useGrouping: false, maximumFractionDigits: 0 });
|
|
40
|
+
}
|
|
41
|
+
const table = Array.from({ length: 10 }, (_, d) => stripBidiMarks(nf.format(d)));
|
|
42
|
+
digits = table.every((d, i) => d === String(i)) ? null : table;
|
|
43
|
+
digitTables.set(key, digits);
|
|
44
|
+
}
|
|
45
|
+
if (!digits) return text;
|
|
46
|
+
const map = digits;
|
|
47
|
+
return text.replace(/[0-9]/g, (d) => map[Number(d)]);
|
|
48
|
+
}
|
|
49
|
+
function monthNames(settings, width) {
|
|
50
|
+
if (settings.english) return [...width === "long" ? EN_MONTHS_LONG : EN_MONTHS_SHORT];
|
|
51
|
+
const dtf = dateFormat(settings, { month: width });
|
|
52
|
+
return Array.from({ length: 12 }, (_, m) => stripBidiMarks(dtf.format(Date.UTC(2e3, m, 15))));
|
|
53
|
+
}
|
|
54
|
+
function weekdayNames(settings) {
|
|
55
|
+
if (settings.english) return [...EN_WEEKDAYS_MIN];
|
|
56
|
+
const dtf = dateFormat(settings, { weekday: "short" });
|
|
57
|
+
return Array.from({ length: 7 }, (_, d) => stripBidiMarks(dtf.format(Date.UTC(2e3, 0, 2 + d))));
|
|
58
|
+
}
|
|
59
|
+
function longDate(settings, year, month, day) {
|
|
60
|
+
return stripBidiMarks(dateFormat(settings, { weekday: "long", year: "numeric", month: "long", day: "numeric" }).format(Date.UTC(year, month, day)));
|
|
61
|
+
}
|
|
62
|
+
function yearLabel(settings, year) {
|
|
63
|
+
if (settings.english) return localizeDigits(String(year), settings);
|
|
64
|
+
return stripBidiMarks(dateFormat(settings, { year: "numeric" }).format(Date.UTC(year, 6, 1)));
|
|
65
|
+
}
|
|
66
|
+
function plainInteger(settings, n) {
|
|
67
|
+
return localizeDigits(String(Math.trunc(n)), settings);
|
|
68
|
+
}
|
|
69
|
+
var yearFirstCache = /* @__PURE__ */ new Map();
|
|
70
|
+
function yearBeforeMonth(settings) {
|
|
71
|
+
if (settings.english) return false;
|
|
72
|
+
const key = `${settings.locale}|${settings.numberingSystem}`;
|
|
73
|
+
let first = yearFirstCache.get(key);
|
|
74
|
+
if (first === void 0) {
|
|
75
|
+
const types = dateFormat(settings, { year: "numeric", month: "long" }).formatToParts(Date.UTC(2026, 8, 15)).map((p) => p.type);
|
|
76
|
+
first = types.indexOf("year") < types.indexOf("month");
|
|
77
|
+
yearFirstCache.set(key, first);
|
|
78
|
+
}
|
|
79
|
+
return first;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { calendarSettings, longDate, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/lib/surface-events.ts
|
|
2
|
+
var SURFACE_OPEN_EVENT = "vela:surface-open";
|
|
3
|
+
var SURFACE_CLOSE_EVENT = "vela:surface-close";
|
|
4
|
+
function announceSurface(el, open, kind, trigger = null) {
|
|
5
|
+
const View = el.ownerDocument.defaultView;
|
|
6
|
+
if (!View) return;
|
|
7
|
+
el.dispatchEvent(
|
|
8
|
+
new View.CustomEvent(open ? SURFACE_OPEN_EVENT : SURFACE_CLOSE_EVENT, { bubbles: true, composed: true, detail: { kind, trigger } })
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { SURFACE_CLOSE_EVENT, SURFACE_OPEN_EVENT, announceSurface };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/lib/variants.ts
|
|
2
|
+
function variants(spec) {
|
|
3
|
+
const keys = Object.keys(spec);
|
|
4
|
+
const attrs = keys.map((key) => `data-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`);
|
|
5
|
+
const resolve = (values = {}) => {
|
|
6
|
+
const out = {};
|
|
7
|
+
for (const key of keys) out[key] = values[key] ?? spec[key][0];
|
|
8
|
+
return out;
|
|
9
|
+
};
|
|
10
|
+
const fn = (values = {}) => {
|
|
11
|
+
const out = {};
|
|
12
|
+
for (let i = 0; i < keys.length; i += 1) out[attrs[i]] = values[keys[i]] ?? spec[keys[i]][0];
|
|
13
|
+
return out;
|
|
14
|
+
};
|
|
15
|
+
return Object.assign(fn, { spec, resolve });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { variants };
|