@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,97 @@
|
|
|
1
|
+
import { shortcutKeys } from './chunk-C3ICYMI3.js';
|
|
2
|
+
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
3
|
+
import { viewportRect, placePopover, intersectRects } from './chunk-3Q32K4PE.js';
|
|
4
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
6
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
7
|
+
import './chunk-2GQIZM5Z.js';
|
|
8
|
+
import './chunk-BXMWQIBO.js';
|
|
9
|
+
import './chunk-X66RJAIS.js';
|
|
10
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
11
|
+
|
|
12
|
+
// src/components/hover-card.ts
|
|
13
|
+
var hoverCardDef = defineComponent({
|
|
14
|
+
name: "hover-card",
|
|
15
|
+
parts: ["root", "heading", "icon", "title", "description", "body", "hint"],
|
|
16
|
+
settings: { radius: t.radius.md, width: "240px", "wide-width": "280px", "icon-radius": "5px", shadow: t.shadow.toString() }
|
|
17
|
+
});
|
|
18
|
+
var injectStyles = defineStyles(
|
|
19
|
+
"vela-ui-hover-card",
|
|
20
|
+
css`@layer vela.ui{[data-slot=hover-card]{z-index:${t.z.tooltip};width:max-content;max-width:${hoverCardDef.vars.width};border-radius:${hoverCardDef.vars.radius};border:1px solid ${t.border};background:${t.surface.elev};color:${t.fg};box-shadow:${hoverCardDef.vars.shadow};font-family:${t.font};pointer-events:none;animation:vela-hover-card-in ${t.dur.med} ${t.ease};padding:8px 10px;font-size:12px;line-height:1.4;position:fixed}[data-slot=hover-card][data-wide]{width:${hoverCardDef.vars["wide-width"]};max-width:${hoverCardDef.vars["wide-width"]}}[data-slot=hover-card][data-side=left]{--_from:4px}[data-slot=hover-card][data-side=right]{--_from:-4px}[data-slot=hover-card-heading]:where(:not([hidden])){align-items:center;gap:7px;display:flex}[data-slot=hover-card-heading]:where(:not([hidden]))>[data-slot=kbd]:first-of-type{margin-inline-start:auto}[data-slot=hover-card-icon]{border:1px solid ${t.border};border-radius:${hoverCardDef.vars["icon-radius"]};background:${t.hover};width:20px;height:20px;color:${t.fg.bright};flex:0 0 20px;justify-content:center}[data-slot=hover-card-icon]>svg{width:12px;height:12px}[data-slot=hover-card-title]{color:${t.fg.bright};font-size:11.5px;font-weight:600}[data-slot=hover-card-description]{border-top:1px solid ${t.border};color:${t.fg.muted};margin:6px 0 0;padding-top:6px;font-size:12px}[data-slot=hover-card-hint]:where(:not([hidden])){color:${t.fg.muted};align-items:center;gap:6px;margin-top:6px;font-size:11px;display:flex}@keyframes vela-hover-card-in{0%{opacity:0;transform:translateX(var(--_from,0))}to{opacity:1;transform:none}}}`
|
|
21
|
+
);
|
|
22
|
+
function createHoverCard(content, placement = "right") {
|
|
23
|
+
const p = typeof placement === "string" ? { side: placement } : placement;
|
|
24
|
+
const side = p.side ?? "right";
|
|
25
|
+
injectStyles(document);
|
|
26
|
+
let icon = null;
|
|
27
|
+
if (content.icon) {
|
|
28
|
+
icon = iconEl(content.icon, document);
|
|
29
|
+
icon.dataset.slot = hoverCardDef.slot("icon");
|
|
30
|
+
}
|
|
31
|
+
const heading = h("div", { slot: hoverCardDef.slot("heading") }, icon, h("strong", { slot: hoverCardDef.slot("title"), text: content.title }), content.shortcut ? shortcutKeys(content.shortcut) : null);
|
|
32
|
+
const body = content.body ? h("div", { slot: hoverCardDef.slot("body") }, content.body) : null;
|
|
33
|
+
const el = h(
|
|
34
|
+
"div",
|
|
35
|
+
{ slot: hoverCardDef.slot("root"), data: { side, wide: content.wide ?? false }, attrs: { role: "tooltip" } },
|
|
36
|
+
heading,
|
|
37
|
+
content.description ? h("p", { slot: hoverCardDef.slot("description"), text: content.description }) : null,
|
|
38
|
+
body,
|
|
39
|
+
content.hint ? h("div", { slot: hoverCardDef.slot("hint"), text: content.hint }) : null
|
|
40
|
+
);
|
|
41
|
+
return {
|
|
42
|
+
el,
|
|
43
|
+
place(anchor, gap) {
|
|
44
|
+
const view = viewportRect(window.innerWidth, window.innerHeight, p.collisionPadding ?? 6);
|
|
45
|
+
const b = p.collisionBoundary;
|
|
46
|
+
const bound = !b || b === "viewport" ? null : typeof b === "function" ? b() : b.getBoundingClientRect();
|
|
47
|
+
const pos = placePopover({
|
|
48
|
+
trigger: anchor,
|
|
49
|
+
pop: { width: el.offsetWidth, height: el.offsetHeight },
|
|
50
|
+
gap: gap ?? p.sideOffset ?? 8,
|
|
51
|
+
align: p.align ?? "center",
|
|
52
|
+
side,
|
|
53
|
+
alignOffset: p.alignOffset,
|
|
54
|
+
avoidCollisions: p.avoidCollisions,
|
|
55
|
+
clamp: bound ? intersectRects(view, bound) : view,
|
|
56
|
+
originX: 0,
|
|
57
|
+
originY: 0
|
|
58
|
+
});
|
|
59
|
+
el.style.left = `${pos.left}px`;
|
|
60
|
+
el.style.top = `${pos.top}px`;
|
|
61
|
+
el.dataset.side = pos.side;
|
|
62
|
+
},
|
|
63
|
+
destroy: () => el.remove()
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function attachHoverCard(trigger, content, opts) {
|
|
67
|
+
let timer = null;
|
|
68
|
+
let card = null;
|
|
69
|
+
const hide = () => {
|
|
70
|
+
if (timer) clearTimeout(timer);
|
|
71
|
+
timer = null;
|
|
72
|
+
card?.destroy();
|
|
73
|
+
card = null;
|
|
74
|
+
};
|
|
75
|
+
const show = () => {
|
|
76
|
+
const c = content();
|
|
77
|
+
if (!c || !trigger.isConnected) return;
|
|
78
|
+
card = createHoverCard(c, opts);
|
|
79
|
+
opts.host.appendChild(card.el);
|
|
80
|
+
card.place(trigger.getBoundingClientRect());
|
|
81
|
+
};
|
|
82
|
+
const enter = () => {
|
|
83
|
+
hide();
|
|
84
|
+
timer = setTimeout(show, opts.openDelay ?? opts.delay ?? 300);
|
|
85
|
+
};
|
|
86
|
+
trigger.addEventListener("pointerenter", enter);
|
|
87
|
+
trigger.addEventListener("pointerleave", hide);
|
|
88
|
+
trigger.addEventListener("pointerdown", hide);
|
|
89
|
+
return () => {
|
|
90
|
+
hide();
|
|
91
|
+
trigger.removeEventListener("pointerenter", enter);
|
|
92
|
+
trigger.removeEventListener("pointerleave", hide);
|
|
93
|
+
trigger.removeEventListener("pointerdown", hide);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { attachHoverCard, createHoverCard, hoverCardDef };
|
package/dist/i18n.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface MessageDescriptor {
|
|
2
|
+
readonly id: string;
|
|
3
|
+
readonly defaultMessage: string;
|
|
4
|
+
}
|
|
5
|
+
interface Translator {
|
|
6
|
+
t(message: MessageDescriptor | string): string;
|
|
7
|
+
/** The locale tag (default English). Names months and weekdays in the date picker. */
|
|
8
|
+
readonly locale?: string;
|
|
9
|
+
/** The numbering system of digits (default `latn`). */
|
|
10
|
+
readonly numberingSystem?: string;
|
|
11
|
+
/** The first day of the week in date pickers (0 Sunday, 1 Monday, 6 Saturday). */
|
|
12
|
+
readonly weekStart?: 0 | 1 | 6;
|
|
13
|
+
}
|
|
14
|
+
/** Declare a message. The build extracts every call with literal arguments into the English
|
|
15
|
+
* catalog, so keep both arguments string literals. */
|
|
16
|
+
declare function msg(id: string, defaultMessage: string): MessageDescriptor;
|
|
17
|
+
/** A message in the translator's language, or its English text without one. */
|
|
18
|
+
declare function textOf(i18n: Translator | null | undefined, message: MessageDescriptor | string): string;
|
|
19
|
+
|
|
20
|
+
export { type MessageDescriptor, type Translator, msg, textOf };
|
package/dist/i18n.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { msg, textOf } from './chunk-FN2BUFNM.js';
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Register (or replace) an icon's raw `<svg>` markup under an id. */
|
|
2
|
+
declare function registerIcon(id: string, svg: string): void;
|
|
3
|
+
/** The raw `<svg>` markup for an id, or null. */
|
|
4
|
+
declare function iconMarkup(id: string): string | null;
|
|
5
|
+
/** The markup for an id, or empty markup — for the `innerHTML` sites that always want a
|
|
6
|
+
* string. An unknown id renders nothing rather than breaking the surrounding chrome. */
|
|
7
|
+
declare function icon(id: string): string;
|
|
8
|
+
/** {@link icon} pinned to an explicit pixel size, for slots that cannot inherit one (a
|
|
9
|
+
* glyph dropped into a row whose font-size belongs to the text beside it). */
|
|
10
|
+
declare function iconAt(id: string, px: number): string;
|
|
11
|
+
/** Tier A: a 16×16 chrome icon. `extra` overrides root attributes (e.g. a filled variant). */
|
|
12
|
+
declare function svg16(body: string, extra?: string): string;
|
|
13
|
+
/** Tier B: a 24×24 drawing-tool icon. `extra` overrides root attributes. */
|
|
14
|
+
declare function svg24(body: string, extra?: string): string;
|
|
15
|
+
/** A tier-B glyph drawn as a solid shape rather than a stroke (grips, dots, carets). */
|
|
16
|
+
declare function svg24Solid(body: string): string;
|
|
17
|
+
/** A ready-to-insert element rendering the icon (empty span when unknown). */
|
|
18
|
+
declare function iconEl(id: string, doc?: Document): HTMLElement;
|
|
19
|
+
|
|
20
|
+
export { icon, iconAt, iconEl, iconMarkup, registerIcon, svg16, svg24, svg24Solid };
|
package/dist/icons.js
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { C as Child, E as ElementProps, a as addSlot, b as append, h } from './h-Bl37qUis.js';
|
|
2
|
+
export { css, defineStyles } from './css.js';
|
|
3
|
+
export { Token, t, tokenNames } from './t.js';
|
|
4
|
+
export { V as VariantFn, a as VariantProps, b as VariantSpec, c as VariantValues, v as variants } from './variants-B4stUBnY.js';
|
|
5
|
+
export { C as ComponentDef, d as defineComponent } from './define-D5u3F5Dj.js';
|
|
6
|
+
export { disposeWithin, ownTeardown } from './dispose.js';
|
|
7
|
+
export { Align, CollisionBoundary, PlacementProps, Side, placePopover, zagPositioning } from './placement.js';
|
|
8
|
+
export { ComponentDefs, ComponentSettings, CreateThemeOptions, DARK_CHART, LIGHT_CHART, TOKEN_NAMES, ThemeInput, ThemeSettings, ThemedChart, TokenName, UiTheme, applyTheme, checkTheme, createTheme } from './theme.js';
|
|
9
|
+
export { ChartTheme } from './tokens.js';
|
|
10
|
+
export { LAYER_ORDER, injectLayerOrder } from './styles.js';
|
|
11
|
+
import './badge.js';
|
|
12
|
+
import './bar-chart.js';
|
|
13
|
+
import './button.js';
|
|
14
|
+
import './callout-bubble.js';
|
|
15
|
+
import './popover.js';
|
|
16
|
+
import './color-picker.js';
|
|
17
|
+
import './i18n.js';
|
|
18
|
+
import './data-table.js';
|
|
19
|
+
import './date-picker.js';
|
|
20
|
+
import './dialog.js';
|
|
21
|
+
import '@zag-js/dialog';
|
|
22
|
+
import './donut.js';
|
|
23
|
+
import './drawer.js';
|
|
24
|
+
import './empty.js';
|
|
25
|
+
import './field.js';
|
|
26
|
+
import './select.js';
|
|
27
|
+
import './glyph-select.js';
|
|
28
|
+
import './hover-card.js';
|
|
29
|
+
import './kbd.js';
|
|
30
|
+
import './line-chart.js';
|
|
31
|
+
import './dropdown-menu.js';
|
|
32
|
+
import '@zag-js/menu';
|
|
33
|
+
import './number-input.js';
|
|
34
|
+
import './scatter-chart.js';
|
|
35
|
+
import './sparkline.js';
|
|
36
|
+
import './stat.js';
|
|
37
|
+
import './checkbox.js';
|
|
38
|
+
import './collapsible.js';
|
|
39
|
+
import './tabs.js';
|
|
40
|
+
import './text-area.js';
|
|
41
|
+
import './input.js';
|
|
42
|
+
import './input-group.js';
|
|
43
|
+
import './item.js';
|
|
44
|
+
import './month-grid.js';
|
|
45
|
+
import './slider.js';
|
|
46
|
+
import './sort-button.js';
|
|
47
|
+
import './switch.js';
|
|
48
|
+
import './toggle-group.js';
|
|
49
|
+
import './tooltip.js';
|
|
50
|
+
import '@zag-js/tooltip';
|
|
51
|
+
import './color.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
+
export { DARK_CHART, LIGHT_CHART, TOKEN_NAMES, applyTheme, checkTheme, createTheme } from './chunk-V2Q4MRMS.js';
|
|
3
|
+
import './chunk-TAKSIV57.js';
|
|
4
|
+
import './chunk-MMTMOV6R.js';
|
|
5
|
+
export { placePopover, zagPositioning } from './chunk-3Q32K4PE.js';
|
|
6
|
+
export { disposeWithin, ownTeardown } from './chunk-A72NWYNP.js';
|
|
7
|
+
export { addSlot, append, h } from './chunk-Q6WTDVH6.js';
|
|
8
|
+
export { defineComponent } from './chunk-VMCR3S2A.js';
|
|
9
|
+
export { css, defineStyles } from './chunk-XBEL4K33.js';
|
|
10
|
+
export { LAYER_ORDER, injectLayerOrder } from './chunk-2GQIZM5Z.js';
|
|
11
|
+
import './chunk-BXMWQIBO.js';
|
|
12
|
+
import './chunk-X66RJAIS.js';
|
|
13
|
+
export { t, tokenNames } from './chunk-6QCILIT2.js';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { V as VariantFn } from './variants-B4stUBnY.js';
|
|
2
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
type InputGroupSize = 'sm' | 'md';
|
|
6
|
+
type InputGroupAlign = 'inline-start' | 'inline-end' | 'block-start' | 'block-end';
|
|
7
|
+
type InputGroupType = 'text' | 'search' | 'email' | 'password' | 'url' | 'tel';
|
|
8
|
+
interface InputGroupAddon {
|
|
9
|
+
/** Where it sits (default `inline-start`). */
|
|
10
|
+
align?: InputGroupAlign;
|
|
11
|
+
/** An icon from the kit's registry. */
|
|
12
|
+
icon?: string;
|
|
13
|
+
/** A short text: a unit, a prefix. */
|
|
14
|
+
text?: string;
|
|
15
|
+
/** A button: its accessible name, its icon or text, and what a press does. */
|
|
16
|
+
button?: {
|
|
17
|
+
label: string;
|
|
18
|
+
icon?: string;
|
|
19
|
+
text?: string;
|
|
20
|
+
onClick: (e: MouseEvent) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare const inputGroupDef: ComponentDef<"input-group", "root" | "text" | "control" | "addon", "radius" | "height" | "height-sm" | "focus-ring">;
|
|
24
|
+
declare const inputGroupVariants: VariantFn<{
|
|
25
|
+
readonly size: readonly ["md", "sm"];
|
|
26
|
+
}>;
|
|
27
|
+
interface InputGroupProps {
|
|
28
|
+
addons?: readonly InputGroupAddon[];
|
|
29
|
+
type?: InputGroupType;
|
|
30
|
+
value?: string;
|
|
31
|
+
/** The text it starts with when `value` is not given. */
|
|
32
|
+
defaultValue?: string;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
/** Submitted with its form under this name. */
|
|
35
|
+
name?: string;
|
|
36
|
+
required?: boolean;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/** The id of its input, so a `<label for>` reaches it. */
|
|
39
|
+
id?: string;
|
|
40
|
+
size?: InputGroupSize;
|
|
41
|
+
/** Its accessible name, when no `<label>` names it. */
|
|
42
|
+
label?: string;
|
|
43
|
+
/** Called on every keystroke. */
|
|
44
|
+
onValueChange?: (value: string) => void;
|
|
45
|
+
}
|
|
46
|
+
declare class InputGroup {
|
|
47
|
+
readonly el: HTMLElement;
|
|
48
|
+
readonly input: HTMLInputElement;
|
|
49
|
+
constructor(props?: InputGroupProps);
|
|
50
|
+
get value(): string;
|
|
51
|
+
setValue(v: string): void;
|
|
52
|
+
focus(): void;
|
|
53
|
+
destroy(): void;
|
|
54
|
+
}
|
|
55
|
+
declare function createInputGroup(props?: InputGroupProps): InputGroup;
|
|
56
|
+
|
|
57
|
+
export { InputGroup, type InputGroupAddon, type InputGroupAlign, type InputGroupProps, type InputGroupSize, type InputGroupType, createInputGroup, inputGroupDef, inputGroupVariants };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createButton } from './chunk-CC3DDNFC.js';
|
|
2
|
+
import './chunk-C3ICYMI3.js';
|
|
3
|
+
import { variants } from './chunk-LZWZV2ZS.js';
|
|
4
|
+
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
5
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
7
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
8
|
+
import './chunk-2GQIZM5Z.js';
|
|
9
|
+
import './chunk-BXMWQIBO.js';
|
|
10
|
+
import './chunk-X66RJAIS.js';
|
|
11
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
12
|
+
|
|
13
|
+
// src/components/input-group.ts
|
|
14
|
+
var inputGroupDef = defineComponent({
|
|
15
|
+
name: "input-group",
|
|
16
|
+
parts: ["root", "control", "addon", "text"],
|
|
17
|
+
settings: { radius: t.radius.md, height: "34px", "height-sm": "28px", "focus-ring": `0 0 0 3px ${t.focus.soft}` }
|
|
18
|
+
});
|
|
19
|
+
var inputGroupVariants = variants({ size: ["md", "sm"] });
|
|
20
|
+
var injectStyles = defineStyles(
|
|
21
|
+
"vela-ui-input-group",
|
|
22
|
+
css`@layer vela.ui{[data-slot=input-group]{--_h:${inputGroupDef.vars.height};box-sizing:border-box;border:1px solid ${t.border.strong};border-radius:${inputGroupDef.vars.radius};width:100%;min-width:0;color:${t.fg.bright};transition:border-color ${t.dur.fast} ease, box-shadow ${t.dur.fast} ease;background:0 0;align-items:center;font-size:14px}[data-slot=input-group]:where(:not([hidden])){display:flex}[data-slot=input-group]:hover{border-color:${t.fg.muted}}[data-slot=input-group]:focus-within{border-color:${t.focus};box-shadow:${inputGroupDef.vars["focus-ring"]}}[data-slot=input-group][data-size=sm]{--_h:${inputGroupDef.vars["height-sm"]};background:${t.surface.elev};border-radius:${t.radius.sm};color:${t.fg};font-size:13px}[data-slot=input-group][data-block]{flex-wrap:wrap}[data-slot=input-group][data-disabled]{opacity:.5}[data-slot=input-group-control]{min-width:0;height:var(--_h);box-sizing:border-box;color:inherit;font:inherit;-webkit-user-select:text;user-select:text;background:0 0;border:0;outline:2px solid #0000;flex:auto;padding:0 8px}[data-slot=input-group-control]::placeholder{color:currentColor;opacity:.4}[data-slot=input-group][data-start] [data-slot=input-group-control]{padding-inline-start:6px}[data-slot=input-group][data-end] [data-slot=input-group-control]{padding-inline-end:4px}[data-slot=input-group-addon]{color:${t.fg.muted};flex:none;align-items:center;gap:4px;font-size:14px}[data-slot=input-group-addon]:where(:not([hidden])){display:inline-flex}[data-slot=input-group-addon][data-align=inline-start]{padding-inline-start:8px}[data-slot=input-group-addon][data-align=inline-end]{padding-inline-end:4px}[data-slot=input-group-addon][data-align=block-start]{flex-basis:100%;padding:6px 8px 0}[data-slot=input-group-addon][data-align=block-end]{flex-basis:100%;padding:0 8px 6px}[data-slot=input-group-text]{white-space:nowrap;font-size:12px}}`
|
|
23
|
+
);
|
|
24
|
+
var InputGroup = class {
|
|
25
|
+
constructor(props = {}) {
|
|
26
|
+
injectStyles(document);
|
|
27
|
+
const addons = props.addons ?? [];
|
|
28
|
+
const alignOf = (a) => a.align ?? "inline-start";
|
|
29
|
+
const addon = (a) => {
|
|
30
|
+
const el = h("div", { slot: inputGroupDef.slot("addon"), data: { align: alignOf(a) } });
|
|
31
|
+
if (a.icon) el.append(iconEl(a.icon, document));
|
|
32
|
+
if (a.text) el.append(h("span", { slot: inputGroupDef.slot("text"), text: a.text }));
|
|
33
|
+
if (a.button) {
|
|
34
|
+
const iconOnly = !!a.button.icon && !a.button.text;
|
|
35
|
+
el.append(createButton({ variant: "ghost", size: iconOnly ? "icon-xs" : "xs", icon: a.button.icon, text: a.button.text, label: a.button.label, onClick: a.button.onClick }).el);
|
|
36
|
+
}
|
|
37
|
+
return el;
|
|
38
|
+
};
|
|
39
|
+
const at = (align) => addons.filter((a) => alignOf(a) === align).map(addon);
|
|
40
|
+
this.input = h("input", { slot: inputGroupDef.slot("control"), attrs: { type: props.type ?? "text", size: 1, id: props.id, placeholder: props.placeholder, name: props.name, "aria-label": props.label } });
|
|
41
|
+
this.input.value = props.value ?? props.defaultValue ?? "";
|
|
42
|
+
this.input.required = props.required === true;
|
|
43
|
+
this.input.disabled = props.disabled === true;
|
|
44
|
+
this.input.addEventListener("input", () => props.onValueChange?.(this.input.value));
|
|
45
|
+
this.el = h(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: "vela-input-group",
|
|
49
|
+
slot: inputGroupDef.slot("root"),
|
|
50
|
+
attrs: inputGroupVariants({ size: props.size ?? "md" }),
|
|
51
|
+
data: {
|
|
52
|
+
block: addons.some((a) => alignOf(a).startsWith("block")),
|
|
53
|
+
start: addons.some((a) => alignOf(a) === "inline-start"),
|
|
54
|
+
end: addons.some((a) => alignOf(a) === "inline-end"),
|
|
55
|
+
disabled: props.disabled === true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
...at("block-start"),
|
|
59
|
+
...at("inline-start"),
|
|
60
|
+
this.input,
|
|
61
|
+
...at("inline-end"),
|
|
62
|
+
...at("block-end")
|
|
63
|
+
);
|
|
64
|
+
this.el.addEventListener("pointerdown", (e) => {
|
|
65
|
+
const target = e.target;
|
|
66
|
+
if (target === this.input || target.closest("button")) return;
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
this.input.focus();
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
get value() {
|
|
72
|
+
return this.input.value;
|
|
73
|
+
}
|
|
74
|
+
setValue(v) {
|
|
75
|
+
this.input.value = v;
|
|
76
|
+
}
|
|
77
|
+
focus() {
|
|
78
|
+
this.input.focus();
|
|
79
|
+
}
|
|
80
|
+
destroy() {
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
function createInputGroup(props = {}) {
|
|
84
|
+
return new InputGroup(props);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { InputGroup, createInputGroup, inputGroupDef, inputGroupVariants };
|
package/dist/input.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { V as VariantFn } from './variants-B4stUBnY.js';
|
|
2
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
type InputSize = 'sm' | 'md';
|
|
6
|
+
interface InputControllerOptions {
|
|
7
|
+
value?: string;
|
|
8
|
+
/** The text it starts with when `value` is not given. */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
size?: InputSize;
|
|
11
|
+
fill?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
}
|
|
15
|
+
interface InputController {
|
|
16
|
+
value: string;
|
|
17
|
+
size: InputSize;
|
|
18
|
+
fill: boolean;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
commit(next: string): string | null;
|
|
21
|
+
/** Write without emitting (external refresh). */
|
|
22
|
+
sync(next: string): void;
|
|
23
|
+
}
|
|
24
|
+
/** The field's last committed string, without DOM. */
|
|
25
|
+
declare function inputController(opts?: InputControllerOptions): InputController;
|
|
26
|
+
declare const inputDef: ComponentDef<"input", "root" | "control", "radius" | "focus-ring">;
|
|
27
|
+
declare const inputVariants: VariantFn<{
|
|
28
|
+
readonly size: readonly ["md", "sm"];
|
|
29
|
+
}>;
|
|
30
|
+
type InputType = 'text' | 'search' | 'email' | 'password' | 'url' | 'tel';
|
|
31
|
+
interface InputOptions extends InputControllerOptions {
|
|
32
|
+
/** The kind of text it takes (default `text`). */
|
|
33
|
+
type?: InputType;
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** Submitted with its form under this name. */
|
|
36
|
+
name?: string;
|
|
37
|
+
required?: boolean;
|
|
38
|
+
id?: string;
|
|
39
|
+
}
|
|
40
|
+
type InputProps = InputOptions;
|
|
41
|
+
declare const TEXT_STYLE_ID = "vela-ui-text-2";
|
|
42
|
+
declare const TEXT_CSS: string;
|
|
43
|
+
declare class Input {
|
|
44
|
+
readonly el: HTMLElement;
|
|
45
|
+
readonly input: HTMLInputElement;
|
|
46
|
+
private readonly ctrl;
|
|
47
|
+
constructor(opts?: InputOptions);
|
|
48
|
+
get value(): string;
|
|
49
|
+
setValue(v: string): void;
|
|
50
|
+
destroy(): void;
|
|
51
|
+
}
|
|
52
|
+
declare function createInput(props?: InputProps): Input;
|
|
53
|
+
|
|
54
|
+
export { Input, type InputController, type InputControllerOptions, type InputOptions, type InputProps, type InputSize, type InputType, TEXT_CSS, TEXT_STYLE_ID, createInput, inputController, inputDef, inputVariants };
|
package/dist/input.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Input, TEXT_CSS, TEXT_STYLE_ID, createInput, inputController, inputDef, inputVariants } from './chunk-U3EH42YY.js';
|
|
2
|
+
import './chunk-LZWZV2ZS.js';
|
|
3
|
+
import './chunk-Q6WTDVH6.js';
|
|
4
|
+
import './chunk-VMCR3S2A.js';
|
|
5
|
+
import './chunk-XBEL4K33.js';
|
|
6
|
+
import './chunk-2GQIZM5Z.js';
|
|
7
|
+
import './chunk-BXMWQIBO.js';
|
|
8
|
+
import './chunk-X66RJAIS.js';
|
|
9
|
+
import './chunk-6QCILIT2.js';
|
package/dist/item.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { C as Child } from './h-Bl37qUis.js';
|
|
2
|
+
import { a as VariantProps, V as VariantFn } from './variants-B4stUBnY.js';
|
|
3
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
4
|
+
import './t.js';
|
|
5
|
+
|
|
6
|
+
declare const itemDef: ComponentDef<"item", "root" | "meta" | "title" | "group" | "content" | "actions" | "description" | "media", "radius" | "gap">;
|
|
7
|
+
declare const itemVariants: VariantFn<{
|
|
8
|
+
readonly variant: readonly ["default", "outline", "muted"];
|
|
9
|
+
readonly size: readonly ["default", "sm"];
|
|
10
|
+
}>;
|
|
11
|
+
type ItemVariant = (typeof itemVariants.spec.variant)[number];
|
|
12
|
+
type ItemSize = (typeof itemVariants.spec.size)[number];
|
|
13
|
+
interface ItemProps extends VariantProps<typeof itemVariants> {
|
|
14
|
+
/** The first line: text, or an element (a ticker with a chip after it). */
|
|
15
|
+
title: string | Node;
|
|
16
|
+
/** The muted line under the title. */
|
|
17
|
+
description?: string | Node;
|
|
18
|
+
/** Before the text: an icon id from the kit's registry, or an element (a logo, an
|
|
19
|
+
* avatar, a favorite star). */
|
|
20
|
+
media?: string | Node;
|
|
21
|
+
/** After the text, always shown: figures and badges (a price and its change). */
|
|
22
|
+
meta?: Child;
|
|
23
|
+
/** At the row's end: its buttons. */
|
|
24
|
+
actions?: Child;
|
|
25
|
+
/** Show the actions only while the row is hovered or holds focus (on touch screens they
|
|
26
|
+
* always show). The meta stays. */
|
|
27
|
+
revealActions?: boolean;
|
|
28
|
+
/** The current row (the open symbol, the highlighted result). */
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Makes the row clickable: a click, Enter or Space runs it. */
|
|
32
|
+
onSelect?: (e: MouseEvent | KeyboardEvent) => void;
|
|
33
|
+
/** The row's role (default `button` when it has `onSelect` and no actions, its text being
|
|
34
|
+
* the button when it has actions); `option` in a listbox, where `selected` is
|
|
35
|
+
* `aria-selected`. */
|
|
36
|
+
role?: string;
|
|
37
|
+
/** Extra class names (layout hooks). */
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
interface ItemHandle {
|
|
41
|
+
readonly el: HTMLElement;
|
|
42
|
+
setSelected(selected: boolean): void;
|
|
43
|
+
setDisabled(disabled: boolean): void;
|
|
44
|
+
setTitle(title: string | Node): void;
|
|
45
|
+
/** A new description; null removes it. */
|
|
46
|
+
setDescription(description: string | Node | null): void;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
interface ItemGroupProps {
|
|
50
|
+
/** The rows, as elements or as the handles `createItem` returns. */
|
|
51
|
+
items?: ReadonlyArray<HTMLElement | ItemHandle>;
|
|
52
|
+
/** A line between the rows, edge to edge (default: separate rounded rows). */
|
|
53
|
+
separated?: boolean;
|
|
54
|
+
/** The list's accessible name. */
|
|
55
|
+
label?: string;
|
|
56
|
+
/** The group's role: default `group` when it has a `label` (the name needs a role to be
|
|
57
|
+
* read), none otherwise; `listbox` for rows whose role is `option`. */
|
|
58
|
+
role?: string;
|
|
59
|
+
/** Extra class names (layout hooks). */
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
interface ItemGroupHandle {
|
|
63
|
+
readonly el: HTMLElement;
|
|
64
|
+
/** Replace the rows. */
|
|
65
|
+
setItems(items: ReadonlyArray<HTMLElement | ItemHandle>): void;
|
|
66
|
+
destroy(): void;
|
|
67
|
+
}
|
|
68
|
+
declare function createItem(props: ItemProps): ItemHandle;
|
|
69
|
+
/** Rows stacked as one list. */
|
|
70
|
+
declare function createItemGroup(props?: ItemGroupProps): ItemGroupHandle;
|
|
71
|
+
|
|
72
|
+
export { type ItemGroupHandle, type ItemGroupProps, type ItemHandle, type ItemProps, type ItemSize, type ItemVariant, createItem, createItemGroup, itemDef, itemVariants };
|
package/dist/item.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
+
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
3
|
+
import { h, append } from './chunk-Q6WTDVH6.js';
|
|
4
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
5
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
6
|
+
import './chunk-2GQIZM5Z.js';
|
|
7
|
+
import './chunk-BXMWQIBO.js';
|
|
8
|
+
import './chunk-X66RJAIS.js';
|
|
9
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
10
|
+
|
|
11
|
+
// src/components/item.ts
|
|
12
|
+
var itemDef = defineComponent({
|
|
13
|
+
name: "item",
|
|
14
|
+
parts: ["root", "media", "content", "title", "description", "meta", "actions", "group"],
|
|
15
|
+
settings: { radius: t.radius.md, gap: "10px" }
|
|
16
|
+
});
|
|
17
|
+
var itemVariants = variants({ variant: ["default", "outline", "muted"], size: ["default", "sm"] });
|
|
18
|
+
var CONTROL = 'button, a[href], input, select, textarea, label, summary, [role="button"], [role="checkbox"], [role="switch"], [role="menuitem"], [role="option"], [role="link"], [contenteditable]:not([contenteditable="false"])';
|
|
19
|
+
var injectStyles = defineStyles(
|
|
20
|
+
"vela-ui-item",
|
|
21
|
+
css`@layer vela.ui{[data-slot=item]{box-sizing:border-box;border-radius:${itemDef.vars.radius};min-width:0;color:${t.fg};text-align:start;transition:background ${t.dur.fast} ease, border-color ${t.dur.fast} ease;border:1px solid #0000;padding:8px 10px;font-size:13px;position:relative}[data-slot=item]:where(:not([hidden])){align-items:center;gap:${itemDef.vars.gap};display:flex}[data-slot=item][data-size=sm]{gap:8px;padding:4px 8px;font-size:12px}[data-slot=item][data-variant=outline]{border-color:${t.border}}[data-slot=item][data-variant=muted]{background:${t.surface.sunken}}[data-slot=item][data-clickable]{cursor:pointer;-webkit-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}[data-slot=item][data-clickable]:not([data-disabled]):hover{background:${t.hover}}[data-slot=item][data-selected],[data-slot=item][data-selected][data-clickable]:hover{background:${t.active}}[data-slot=item]:focus-visible{outline:2px solid ${t.focus};outline-offset:-2px}[data-slot=item][data-disabled]{cursor:default;opacity:.5}[data-slot=item-media]{color:${t.fg.muted};flex:none}[data-slot=item-media]:where(:not([hidden])){justify-content:center;align-items:center;display:inline-flex}[data-slot=item-media]>[data-icon]{width:1em;height:1em;font-size:16px;line-height:0}[data-slot=item-media]>[data-icon]>svg{width:100%;height:100%}[data-slot=item-content]{flex:auto;min-width:0}[data-slot=item-content]:where(:not([hidden])){flex-direction:column;gap:2px;display:flex}[data-slot=item-content][role=button]:focus-visible{outline:2px solid ${t.focus};outline-offset:2px;border-radius:${t.radius.sm}}[data-slot=item-title],[data-slot=item-description]{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}[data-slot=item-title]{color:${t.fg.bright};font-weight:500;line-height:18px}[data-slot=item-description]{color:${t.fg.muted};font-size:12px;line-height:16px}[data-slot=item-description]:is([data-size=sm] *){font-size:11px;line-height:14px}[data-slot=item-meta]{color:${t.fg};font-variant-numeric:tabular-nums;text-align:end;white-space:nowrap;flex:none;gap:8px}[data-slot=item-meta]:where(:not([hidden])){align-items:center;display:inline-flex}[data-slot=item-actions]{flex:none;gap:4px}[data-slot=item-actions]:where(:not([hidden])){align-items:center;display:inline-flex}[data-slot=item-actions]:is([data-reveal-actions]>*){opacity:0;transition:opacity ${t.dur.fast} ease}[data-slot=item-actions]:is([data-reveal-actions]:hover>*,[data-reveal-actions]:focus-within>*){opacity:1}@media (hover:none){[data-slot=item-actions]:is([data-reveal-actions]>*){opacity:1}}[data-slot=item-group]{min-width:0}[data-slot=item-group]:where(:not([hidden])){flex-direction:column;gap:2px;display:flex}[data-slot=item-group][data-separated]{gap:0}[data-slot=item-group][data-separated]>[data-slot=item]{border-bottom-color:${t.border.faint};border-radius:0}}`
|
|
22
|
+
);
|
|
23
|
+
var ItemImpl = class {
|
|
24
|
+
constructor(props) {
|
|
25
|
+
this.props = props;
|
|
26
|
+
this.descriptionEl = null;
|
|
27
|
+
this.disabled = false;
|
|
28
|
+
this.onClick = (e) => {
|
|
29
|
+
if (this.disabled) return;
|
|
30
|
+
const control = e.target instanceof Element ? e.target.closest(CONTROL) : null;
|
|
31
|
+
if (control && control !== this.control && control !== this.el && this.el.contains(control)) return;
|
|
32
|
+
this.props.onSelect?.(e);
|
|
33
|
+
};
|
|
34
|
+
this.onKey = (e) => {
|
|
35
|
+
if (this.disabled || e.target !== this.control || e.key !== "Enter" && e.key !== " ") return;
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
this.props.onSelect?.(e);
|
|
38
|
+
};
|
|
39
|
+
injectStyles(document);
|
|
40
|
+
const clickable = !!props.onSelect;
|
|
41
|
+
const textControl = clickable && props.role === void 0 && props.actions !== void 0 && props.actions !== null;
|
|
42
|
+
const role = props.role ?? (clickable ? "button" : null);
|
|
43
|
+
this.option = role === "option";
|
|
44
|
+
let media = null;
|
|
45
|
+
if (props.media !== void 0) {
|
|
46
|
+
media = h("div", { slot: itemDef.slot("media") });
|
|
47
|
+
if (typeof props.media === "string") {
|
|
48
|
+
const icon = iconEl(props.media, document);
|
|
49
|
+
icon.dataset.icon = "";
|
|
50
|
+
media.appendChild(icon);
|
|
51
|
+
} else media.appendChild(props.media);
|
|
52
|
+
}
|
|
53
|
+
this.titleEl = h("div", { slot: itemDef.slot("title") }, props.title);
|
|
54
|
+
this.content = h("div", { slot: itemDef.slot("content"), attrs: textControl ? { role, tabindex: "0" } : void 0 }, this.titleEl);
|
|
55
|
+
const trailing = (part, children) => {
|
|
56
|
+
if (children === void 0 || children === null) return null;
|
|
57
|
+
const el = h("div", { slot: itemDef.slot(part) });
|
|
58
|
+
append(el, [children]);
|
|
59
|
+
return el;
|
|
60
|
+
};
|
|
61
|
+
this.el = h(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: props.className,
|
|
65
|
+
slot: itemDef.slot("root"),
|
|
66
|
+
attrs: { ...itemVariants(props), role: textControl ? null : role, tabindex: clickable && !textControl ? "0" : null },
|
|
67
|
+
data: { clickable: clickable || null, "reveal-actions": props.revealActions || null }
|
|
68
|
+
},
|
|
69
|
+
media,
|
|
70
|
+
this.content,
|
|
71
|
+
trailing("meta", props.meta),
|
|
72
|
+
trailing("actions", props.actions)
|
|
73
|
+
);
|
|
74
|
+
this.control = textControl ? this.content : this.el;
|
|
75
|
+
if (props.description !== void 0) this.setDescription(props.description);
|
|
76
|
+
if (clickable) {
|
|
77
|
+
this.el.addEventListener("click", this.onClick);
|
|
78
|
+
this.control.addEventListener("keydown", this.onKey);
|
|
79
|
+
}
|
|
80
|
+
this.setSelected(props.selected ?? false);
|
|
81
|
+
this.setDisabled(props.disabled ?? false);
|
|
82
|
+
}
|
|
83
|
+
setSelected(selected) {
|
|
84
|
+
this.el.toggleAttribute("data-selected", selected);
|
|
85
|
+
if (this.option) this.control.setAttribute("aria-selected", String(selected));
|
|
86
|
+
else if (selected) this.control.setAttribute("aria-current", "true");
|
|
87
|
+
else this.control.removeAttribute("aria-current");
|
|
88
|
+
}
|
|
89
|
+
setDisabled(disabled) {
|
|
90
|
+
this.disabled = disabled;
|
|
91
|
+
this.el.toggleAttribute("data-disabled", disabled);
|
|
92
|
+
if (disabled) this.control.setAttribute("aria-disabled", "true");
|
|
93
|
+
else this.control.removeAttribute("aria-disabled");
|
|
94
|
+
if (this.props.onSelect) this.control.tabIndex = disabled ? -1 : 0;
|
|
95
|
+
}
|
|
96
|
+
setTitle(title) {
|
|
97
|
+
this.titleEl.replaceChildren(title);
|
|
98
|
+
}
|
|
99
|
+
setDescription(description) {
|
|
100
|
+
if (description === null) {
|
|
101
|
+
this.descriptionEl?.remove();
|
|
102
|
+
this.descriptionEl = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.descriptionEl ?? (this.descriptionEl = this.content.appendChild(h("div", { slot: itemDef.slot("description") })));
|
|
106
|
+
this.descriptionEl.replaceChildren(description);
|
|
107
|
+
}
|
|
108
|
+
destroy() {
|
|
109
|
+
this.el.removeEventListener("click", this.onClick);
|
|
110
|
+
this.control.removeEventListener("keydown", this.onKey);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
function createItem(props) {
|
|
114
|
+
return new ItemImpl(props);
|
|
115
|
+
}
|
|
116
|
+
function createItemGroup(props = {}) {
|
|
117
|
+
injectStyles(document);
|
|
118
|
+
const el = h("div", {
|
|
119
|
+
className: props.className,
|
|
120
|
+
slot: itemDef.slot("group"),
|
|
121
|
+
attrs: { role: props.role ?? (props.label ? "group" : null), "aria-label": props.label ?? null },
|
|
122
|
+
data: { separated: props.separated || null }
|
|
123
|
+
});
|
|
124
|
+
const setItems = (items) => {
|
|
125
|
+
el.replaceChildren(...items.map((item) => item instanceof HTMLElement ? item : item.el));
|
|
126
|
+
};
|
|
127
|
+
setItems(props.items ?? []);
|
|
128
|
+
return { el, setItems, destroy: () => el.remove() };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export { createItem, createItemGroup, itemDef, itemVariants };
|
package/dist/kbd.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
2
|
+
import './t.js';
|
|
3
|
+
|
|
4
|
+
declare const kbdDef: ComponentDef<"kbd", "root", "radius" | "shadow">;
|
|
5
|
+
interface KbdProps {
|
|
6
|
+
/** The key's label (`Alt`, `⌘`, `K`). */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Extra class names (layout hooks). */
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
interface KbdHandle {
|
|
12
|
+
readonly el: HTMLElement;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
15
|
+
declare function createKbd(props: KbdProps): KbdHandle;
|
|
16
|
+
/** A shortcut (`Alt+A`) as a row of keycaps, one per key. */
|
|
17
|
+
declare function shortcutKeys(shortcut: string): HTMLElement[];
|
|
18
|
+
|
|
19
|
+
export { type KbdHandle, type KbdProps, createKbd, kbdDef, shortcutKeys };
|