@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.
- package/CHANGELOG.md +43 -0
- package/LICENSE +201 -0
- package/NOTICE +28 -0
- package/README.md +83 -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 +41 -0
- package/dist/button.js +10 -0
- package/dist/calendar.d.ts +22 -0
- package/dist/calendar.js +1 -0
- package/dist/callout-bubble.d.ts +98 -0
- package/dist/callout-bubble.js +173 -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-2Q4JRINP.js +403 -0
- package/dist/chunk-3Q32K4PE.js +85 -0
- package/dist/chunk-5QHXOAZA.js +351 -0
- package/dist/chunk-6NXY62JS.js +25 -0
- package/dist/chunk-6QCILIT2.js +52 -0
- package/dist/chunk-A2FJ7Y7D.js +55 -0
- package/dist/chunk-A72NWYNP.js +26 -0
- package/dist/chunk-AJ2IYSOI.js +553 -0
- package/dist/chunk-BXMWQIBO.js +66 -0
- package/dist/chunk-CH3DV6FD.js +280 -0
- package/dist/chunk-EZQXTO6K.js +89 -0
- package/dist/chunk-FCO3YZLT.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-IDA2BT7D.js +29 -0
- package/dist/chunk-J2QJATCD.js +12 -0
- package/dist/chunk-LZWZV2ZS.js +18 -0
- package/dist/chunk-MMTMOV6R.js +31 -0
- package/dist/chunk-OBLIX3VN.js +227 -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-SAPURP46.js +133 -0
- package/dist/chunk-TAKSIV57.js +90 -0
- package/dist/chunk-V6TTTMTE.js +79 -0
- package/dist/chunk-VMCR3S2A.js +22 -0
- package/dist/chunk-X4YPSIW6.js +72 -0
- package/dist/chunk-X66RJAIS.js +14 -0
- package/dist/chunk-XJAPCCOJ.js +101 -0
- package/dist/chunk-ZB3BZHSN.js +219 -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 +15 -0
- package/dist/css.js +4 -0
- package/dist/data-table-DtU3FX9j.d.ts +61 -0
- package/dist/data-table.d.ts +3 -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/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 +45 -0
- package/dist/index.js +13 -0
- package/dist/input-group.d.ts +57 -0
- package/dist/input-group.js +86 -0
- package/dist/input.d.ts +54 -0
- package/dist/input.js +9 -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 +3854 -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/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 +63 -0
- package/dist/tabs.js +150 -0
- package/dist/text-area.d.ts +54 -0
- package/dist/text-area.js +9 -0
- package/dist/theme.d.ts +188 -0
- package/dist/theme.js +8 -0
- package/dist/theme.schema.json +1745 -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 +211 -0
- package/docs/what-to-change.md +20 -0
- package/docs/writing-a-component.md +247 -0
- package/llms.txt +66 -0
- package/package.json +90 -6
- package/registry/badge.ts +119 -0
- package/registry/bar-chart.ts +215 -0
- package/registry/button.ts +303 -0
- package/registry/callout-bubble.ts +336 -0
- package/registry/checkbox.ts +234 -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/kbd.ts +64 -0
- package/registry/line-chart.ts +218 -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/sparkline.ts +114 -0
- package/registry/stat.ts +96 -0
- package/registry/switch.ts +205 -0
- package/registry/tabs.ts +392 -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 +134 -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 +303 -0
- package/src/components/callout-bubble.ts +336 -0
- package/src/components/checkbox.ts +234 -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/kbd.ts +64 -0
- package/src/components/line-chart.ts +218 -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/sparkline.ts +114 -0
- package/src/components/stat.ts +96 -0
- package/src/components/switch.ts +205 -0
- package/src/components/tabs.ts +392 -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 +112 -0
- package/src/lib/chart.ts +72 -0
- package/src/lib/color.ts +89 -0
- package/src/lib/component-index.ts +131 -0
- package/src/lib/css.ts +44 -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/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 +654 -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
package/dist/tabs.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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 tabsDef: ComponentDef<"tabs", "count" | "icon" | "trigger" | "content" | "list", "track-radius" | "trigger-radius" | "filled-radius" | "soft-radius" | "count-radius">;
|
|
6
|
+
declare const tabsVariants: VariantFn<{
|
|
7
|
+
readonly variant: readonly ["default", "line", "filled", "soft", "nav"];
|
|
8
|
+
}>;
|
|
9
|
+
type TabsVariant = (typeof tabsVariants.spec.variant)[number];
|
|
10
|
+
interface TabItem {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Out of the strip for now (its content does not apply); the arrow keys skip it. */
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
/** Icon id from the kit's registry, before the label. */
|
|
17
|
+
icon?: string;
|
|
18
|
+
/** A count after the label (open orders, trades); null shows none. */
|
|
19
|
+
count?: number | null;
|
|
20
|
+
}
|
|
21
|
+
interface TabsProps extends VariantProps<typeof tabsVariants> {
|
|
22
|
+
items: readonly TabItem[];
|
|
23
|
+
/** The selected tab (default: the first available one). */
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
onValueChange?: (value: string) => void;
|
|
26
|
+
/** Default `horizontal` (`nav` reads best vertical). */
|
|
27
|
+
orientation?: 'horizontal' | 'vertical';
|
|
28
|
+
/** `automatic` (default): moving focus with the arrow keys selects. `manual`: Enter or
|
|
29
|
+
* Space selects the focused tab. */
|
|
30
|
+
activationMode?: 'automatic' | 'manual';
|
|
31
|
+
/** The text direction the arrow keys follow (default `ltr`). */
|
|
32
|
+
dir?: 'ltr' | 'rtl';
|
|
33
|
+
/** Extra class names on the list (the host's layout of the strip). */
|
|
34
|
+
className?: string;
|
|
35
|
+
/** Extra class names on every trigger. */
|
|
36
|
+
triggerClassName?: string;
|
|
37
|
+
}
|
|
38
|
+
interface TabsHandle {
|
|
39
|
+
readonly el: HTMLElement;
|
|
40
|
+
/** The selected tab. */
|
|
41
|
+
readonly value: string | null;
|
|
42
|
+
/** Show a tab as selected without calling `onValueChange`. */
|
|
43
|
+
setValue(value: string | null): void;
|
|
44
|
+
setItems(items: readonly TabItem[]): void;
|
|
45
|
+
/** Hide or show a tab. Hiding the selected tab selects the first available one (and
|
|
46
|
+
* calls `onValueChange`). */
|
|
47
|
+
setHidden(value: string, hidden: boolean): void;
|
|
48
|
+
/** A tab's count (null: none). */
|
|
49
|
+
setCount(value: string, count: number | null): void;
|
|
50
|
+
/** The trigger of a tab (null: unknown value). */
|
|
51
|
+
trigger(value: string): HTMLButtonElement | null;
|
|
52
|
+
/** Make `el` the panel of tab `value`: it gets the tabpanel role, its link to the trigger,
|
|
53
|
+
* and `hidden` while another tab is selected. */
|
|
54
|
+
panel(value: string, el: HTMLElement): void;
|
|
55
|
+
destroy(): void;
|
|
56
|
+
}
|
|
57
|
+
/** A tab a user can reach: neither disabled nor hidden. */
|
|
58
|
+
declare const tabAvailable: (item: TabItem) => boolean;
|
|
59
|
+
declare const TABS_STYLE_ID = "vela-ui-tabs";
|
|
60
|
+
declare const TABS_CSS: string;
|
|
61
|
+
declare function createTabs(props: TabsProps): TabsHandle;
|
|
62
|
+
|
|
63
|
+
export { TABS_CSS, TABS_STYLE_ID, type TabItem, type TabsHandle, type TabsProps, type TabsVariant, createTabs, tabAvailable, tabsDef, tabsVariants };
|
package/dist/tabs.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
+
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
3
|
+
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-P4MTEMT7.js';
|
|
4
|
+
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
5
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
7
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
8
|
+
import { css, defineStyles } from './chunk-IDA2BT7D.js';
|
|
9
|
+
import './chunk-2GQIZM5Z.js';
|
|
10
|
+
import './chunk-BXMWQIBO.js';
|
|
11
|
+
import './chunk-X66RJAIS.js';
|
|
12
|
+
import * as tabs from '@zag-js/tabs';
|
|
13
|
+
|
|
14
|
+
var tabsDef = defineComponent({
|
|
15
|
+
name: "tabs",
|
|
16
|
+
parts: ["list", "trigger", "icon", "count", "content"],
|
|
17
|
+
settings: { "track-radius": "8px", "trigger-radius": t.radius.md, "filled-radius": "5px", "soft-radius": "8px", "count-radius": "8px" }
|
|
18
|
+
});
|
|
19
|
+
var tabsVariants = variants({ variant: ["default", "line", "filled", "soft", "nav"] });
|
|
20
|
+
var tabAvailable = (item) => !item.disabled && !item.hidden;
|
|
21
|
+
var countEl = (count) => count == null ? null : h("span", { slot: tabsDef.slot("count"), text: String(count) });
|
|
22
|
+
var TABS_STYLE_ID = "vela-ui-tabs";
|
|
23
|
+
var TABS_CSS = css`@layer vela.ui{[data-slot=tabs-icon]{margin-inline-end:6px}[data-slot=tabs-count]{border-radius:${tabsDef.vars["count-radius"]};background:${t.hover};min-width:16px;height:16px;color:${t.fg.muted};font-variant-numeric:tabular-nums;margin-inline-start:6px;padding:0 5px;font-size:10px;font-weight:600}[data-slot=tabs-count]:where(:not([hidden])){justify-content:center;align-items:center;display:inline-flex}[data-slot=tabs-list]{display:flex}[data-slot=tabs-list][data-orientation=vertical]{flex-direction:column}[data-slot=tabs-list][data-variant=default]{box-sizing:border-box;border-radius:${tabsDef.vars["track-radius"]};background:color-mix(in srgb, ${t.fg.bright} 6%, transparent);gap:2px;padding:3px;display:inline-flex}[data-slot=tabs-list][data-variant=default][data-orientation=horizontal]{align-items:stretch;height:32px}[data-slot=tabs-list][data-variant=line]{border-bottom:1px solid ${t.border};gap:12px}[data-slot=tabs-list][data-variant=nav]{gap:2px}[data-slot=tabs-trigger]:where(:not([hidden])){all:unset;cursor:pointer;white-space:nowrap;-webkit-tap-highlight-color:transparent}[data-slot=tabs-trigger]:where(:not([hidden]))[data-disabled]{cursor:default;opacity:.45}[data-slot=tabs-trigger]:where(:not([hidden])):focus-visible{outline:2px solid ${t.focus};outline-offset:-2px}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=default]{border-radius:${tabsDef.vars["trigger-radius"]};color:${t.fg.muted};transition:background ${t.dur.fast} ease, color ${t.dur.fast} ease;justify-content:center;align-items:center;padding:0 10px;font-size:13px;font-weight:500;display:inline-flex}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=default][data-orientation=vertical]{justify-content:flex-start;padding:6px 10px}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=default]:not([data-selected],[data-disabled]):hover{color:${t.fg.bright}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=default][data-selected]{background:color-mix(in srgb, ${t.fg.bright} 12%, transparent);color:${t.fg.bright}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=line]{color:${t.fg.muted};transition:color ${t.dur.fast} ease, border-color ${t.dur.fast} ease;border-bottom:2px solid #0000;margin-bottom:-1px;padding-bottom:8px;font-size:13px;font-weight:600;line-height:20px}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=line]:not([data-selected],[data-disabled]):hover{color:${t.fg}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=line][data-selected]{color:${t.fg};border-bottom-color:${t.fg.bright}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=filled]{border-radius:${tabsDef.vars["filled-radius"]};color:${t.fg.muted};padding:3px 10px;font-size:13px;font-weight:600}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=filled]:not([data-selected],[data-disabled]):hover{color:${t.fg}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=filled][data-selected]{background:${t.selected.bg};color:${t.selected.fg}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=soft]{border-radius:${tabsDef.vars["soft-radius"]};min-height:36px;color:${t.fg.muted};flex:none;align-items:center;padding:0 12px;font-size:13px;font-weight:600;display:inline-flex}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=soft][data-selected]{color:${t.fg.bright};background:${t.hover}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=nav]{border-radius:${t.radius.md};color:${t.fg.muted};transition:background ${t.dur.fast} ease, color ${t.dur.fast} ease;padding:9px 12px;font-size:13px;font-weight:600}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=nav]:not([data-selected],[data-disabled]):hover{background:${t.hover};color:${t.fg.bright}}[data-slot=tabs-trigger]:where(:not([hidden]))[data-variant=nav][data-selected]{background:${t.active};color:${t.fg.bright}}}`;
|
|
24
|
+
var injectStyles = defineStyles(TABS_STYLE_ID, TABS_CSS);
|
|
25
|
+
var TabsImpl = class {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
this.triggers = /* @__PURE__ */ new Map();
|
|
28
|
+
this.panels = /* @__PURE__ */ new Map();
|
|
29
|
+
injectStyles(document);
|
|
30
|
+
this.variant = tabsVariants.resolve(props).variant;
|
|
31
|
+
this.triggerClassName = props.triggerClassName;
|
|
32
|
+
this.items = [...props.items];
|
|
33
|
+
this.current = props.defaultValue ?? this.items.find(tabAvailable)?.value ?? null;
|
|
34
|
+
this.mid = nextUid("vela-tabs");
|
|
35
|
+
this.el = h("div", {
|
|
36
|
+
className: props.className ? `vela-tabs ${props.className}` : "vela-tabs",
|
|
37
|
+
slot: tabsDef.slot("list"),
|
|
38
|
+
data: { variant: this.variant }
|
|
39
|
+
});
|
|
40
|
+
this.build();
|
|
41
|
+
this.machine = runMachine(
|
|
42
|
+
tabs.machine,
|
|
43
|
+
{
|
|
44
|
+
id: this.mid,
|
|
45
|
+
defaultValue: this.current,
|
|
46
|
+
orientation: props.orientation ?? "horizontal",
|
|
47
|
+
activationMode: props.activationMode ?? "automatic",
|
|
48
|
+
dir: props.dir ?? "ltr",
|
|
49
|
+
loopFocus: true,
|
|
50
|
+
onValueChange: ({ value }) => {
|
|
51
|
+
if (value == null) return;
|
|
52
|
+
this.current = value;
|
|
53
|
+
if (this.silentNext === value) {
|
|
54
|
+
this.silentNext = void 0;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
props.onValueChange?.(value);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
(service) => this.render(service)
|
|
61
|
+
);
|
|
62
|
+
this.release = ownTeardown(this.el, () => this.machine.stop());
|
|
63
|
+
}
|
|
64
|
+
get value() {
|
|
65
|
+
return this.current;
|
|
66
|
+
}
|
|
67
|
+
setValue(value) {
|
|
68
|
+
if (value === this.current) return;
|
|
69
|
+
this.current = value;
|
|
70
|
+
if (value === null) {
|
|
71
|
+
this.api().clearValue();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this.silentNext = value;
|
|
75
|
+
this.api().setValue(value);
|
|
76
|
+
}
|
|
77
|
+
setItems(items) {
|
|
78
|
+
this.items = [...items];
|
|
79
|
+
this.build();
|
|
80
|
+
if (this.current === null || !this.items.some((i) => i.value === this.current)) this.setValue(this.items.find(tabAvailable)?.value ?? null);
|
|
81
|
+
this.machine.flush();
|
|
82
|
+
}
|
|
83
|
+
setHidden(value, hidden) {
|
|
84
|
+
this.items = this.items.map((i) => i.value === value ? { ...i, hidden } : i);
|
|
85
|
+
if (hidden && this.current === value) {
|
|
86
|
+
const next = this.items.find(tabAvailable)?.value;
|
|
87
|
+
if (next !== void 0) {
|
|
88
|
+
this.current = next;
|
|
89
|
+
this.api().setValue(next);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
this.machine.flush();
|
|
93
|
+
}
|
|
94
|
+
setCount(value, count) {
|
|
95
|
+
const b = this.triggers.get(value);
|
|
96
|
+
if (!b) return;
|
|
97
|
+
this.items = this.items.map((i) => i.value === value ? { ...i, count } : i);
|
|
98
|
+
b.querySelector(`[data-slot="${tabsDef.slot("count")}"]`)?.remove();
|
|
99
|
+
const el = countEl(count);
|
|
100
|
+
if (el) b.appendChild(el);
|
|
101
|
+
}
|
|
102
|
+
trigger(value) {
|
|
103
|
+
return this.triggers.get(value) ?? null;
|
|
104
|
+
}
|
|
105
|
+
panel(value, el) {
|
|
106
|
+
el.dataset.slot = tabsDef.slot("content");
|
|
107
|
+
this.panels.set(value, el);
|
|
108
|
+
this.machine.flush();
|
|
109
|
+
}
|
|
110
|
+
destroy() {
|
|
111
|
+
this.release();
|
|
112
|
+
}
|
|
113
|
+
api() {
|
|
114
|
+
return tabs.connect(this.machine.service, normalizeProps);
|
|
115
|
+
}
|
|
116
|
+
build() {
|
|
117
|
+
this.triggers.clear();
|
|
118
|
+
const className = this.triggerClassName ? `vela-tab ${this.triggerClassName}` : "vela-tab";
|
|
119
|
+
this.el.replaceChildren(
|
|
120
|
+
...this.items.map((item) => {
|
|
121
|
+
let icon = null;
|
|
122
|
+
if (item.icon) {
|
|
123
|
+
icon = iconEl(item.icon, document);
|
|
124
|
+
icon.dataset.slot = tabsDef.slot("icon");
|
|
125
|
+
}
|
|
126
|
+
const b = h("button", { className, slot: tabsDef.slot("trigger"), data: { variant: this.variant } }, icon, item.label, countEl(item.count));
|
|
127
|
+
this.triggers.set(item.value, b);
|
|
128
|
+
return b;
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
render(service) {
|
|
133
|
+
const api = tabs.connect(service, normalizeProps);
|
|
134
|
+
spreadProps(this.el, api.getListProps(), this.mid);
|
|
135
|
+
for (const item of this.items) {
|
|
136
|
+
const b = this.triggers.get(item.value);
|
|
137
|
+
if (!b) continue;
|
|
138
|
+
const props = api.getTriggerProps({ value: item.value, disabled: !tabAvailable(item) });
|
|
139
|
+
if (!this.panels.has(item.value)) delete props["aria-controls"];
|
|
140
|
+
spreadProps(b, props, this.mid);
|
|
141
|
+
b.hidden = item.hidden === true;
|
|
142
|
+
}
|
|
143
|
+
for (const [value, el] of this.panels) spreadProps(el, api.getContentProps({ value }), this.mid);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
function createTabs(props) {
|
|
147
|
+
return new TabsImpl(props);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { TABS_CSS, TABS_STYLE_ID, createTabs, tabAvailable, tabsDef, tabsVariants };
|
|
@@ -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 TextAreaSize = 'sm' | 'md';
|
|
6
|
+
interface TextAreaControllerOptions {
|
|
7
|
+
value?: string;
|
|
8
|
+
/** The text it starts with when `value` is not given. */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
size?: TextAreaSize;
|
|
11
|
+
rows?: number;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onChange?: (value: string) => void;
|
|
14
|
+
}
|
|
15
|
+
interface TextAreaController {
|
|
16
|
+
value: string;
|
|
17
|
+
size: TextAreaSize;
|
|
18
|
+
rows: number;
|
|
19
|
+
disabled: boolean;
|
|
20
|
+
commit(next: string): string | null;
|
|
21
|
+
sync(next: string): void;
|
|
22
|
+
}
|
|
23
|
+
/** The text area's last committed string, without DOM. */
|
|
24
|
+
declare function textAreaController(opts?: TextAreaControllerOptions): TextAreaController;
|
|
25
|
+
declare const textAreaDef: ComponentDef<"text-area", "input" | "root", "radius" | "focus-ring">;
|
|
26
|
+
declare const textAreaVariants: VariantFn<{
|
|
27
|
+
readonly size: readonly ["md", "sm"];
|
|
28
|
+
}>;
|
|
29
|
+
interface TextAreaOptions extends TextAreaControllerOptions {
|
|
30
|
+
/** Submitted with its form under this name. */
|
|
31
|
+
name?: string;
|
|
32
|
+
required?: boolean;
|
|
33
|
+
id?: string;
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** Grow with content up to `maxLines`, then scroll. */
|
|
36
|
+
autoGrow?: boolean;
|
|
37
|
+
maxLines?: number;
|
|
38
|
+
}
|
|
39
|
+
type TextAreaProps = TextAreaOptions;
|
|
40
|
+
declare class TextArea {
|
|
41
|
+
readonly el: HTMLElement;
|
|
42
|
+
readonly input: HTMLTextAreaElement;
|
|
43
|
+
private readonly ctrl;
|
|
44
|
+
private readonly autoGrow;
|
|
45
|
+
private readonly maxLines;
|
|
46
|
+
constructor(opts?: TextAreaOptions);
|
|
47
|
+
get value(): string;
|
|
48
|
+
setValue(v: string): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
private grow;
|
|
51
|
+
}
|
|
52
|
+
declare function createTextArea(props?: TextAreaProps): TextArea;
|
|
53
|
+
|
|
54
|
+
export { TextArea, type TextAreaController, type TextAreaControllerOptions, type TextAreaOptions, type TextAreaProps, type TextAreaSize, createTextArea, textAreaController, textAreaDef, textAreaVariants };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { TextArea, createTextArea, textAreaController, textAreaDef, textAreaVariants } from './chunk-FCO3YZLT.js';
|
|
2
|
+
import './chunk-LZWZV2ZS.js';
|
|
3
|
+
import './chunk-Q6WTDVH6.js';
|
|
4
|
+
import './chunk-6QCILIT2.js';
|
|
5
|
+
import './chunk-VMCR3S2A.js';
|
|
6
|
+
import './chunk-IDA2BT7D.js';
|
|
7
|
+
import './chunk-2GQIZM5Z.js';
|
|
8
|
+
import './chunk-BXMWQIBO.js';
|
|
9
|
+
import './chunk-X66RJAIS.js';
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { badgeDef } from './badge.js';
|
|
2
|
+
import { barChartDef } from './bar-chart.js';
|
|
3
|
+
import { buttonDef } from './button.js';
|
|
4
|
+
import { calloutBubbleDef } from './callout-bubble.js';
|
|
5
|
+
import { colorPickerDef } from './color-picker.js';
|
|
6
|
+
import { d as dataTableDef } from './data-table-DtU3FX9j.js';
|
|
7
|
+
import { datePickerDef } from './date-picker.js';
|
|
8
|
+
import { dialogDef } from './dialog.js';
|
|
9
|
+
import { donutDef } from './donut.js';
|
|
10
|
+
import { drawerDef } from './drawer.js';
|
|
11
|
+
import { emptyDef } from './empty.js';
|
|
12
|
+
import { fieldDef } from './field.js';
|
|
13
|
+
import { glyphSelectDef } from './glyph-select.js';
|
|
14
|
+
import { hoverCardDef } from './hover-card.js';
|
|
15
|
+
import { kbdDef } from './kbd.js';
|
|
16
|
+
import { lineChartDef } from './line-chart.js';
|
|
17
|
+
import { dropdownMenuDef } from './dropdown-menu.js';
|
|
18
|
+
import { numberInputDef } from './number-input.js';
|
|
19
|
+
import { popoverDef } from './popover.js';
|
|
20
|
+
import { scatterChartDef } from './scatter-chart.js';
|
|
21
|
+
import { selectDef } from './select.js';
|
|
22
|
+
import { sparklineDef } from './sparkline.js';
|
|
23
|
+
import { statDef } from './stat.js';
|
|
24
|
+
import { checkboxDef } from './checkbox.js';
|
|
25
|
+
import { tabsDef } from './tabs.js';
|
|
26
|
+
import { textAreaDef } from './text-area.js';
|
|
27
|
+
import { inputDef } from './input.js';
|
|
28
|
+
import { inputGroupDef } from './input-group.js';
|
|
29
|
+
import { switchDef } from './switch.js';
|
|
30
|
+
import { toggleGroupDef } from './toggle-group.js';
|
|
31
|
+
import { tooltipDef } from './tooltip.js';
|
|
32
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
33
|
+
import { ChartTheme } from './tokens.js';
|
|
34
|
+
import './variants-B4stUBnY.js';
|
|
35
|
+
import './t.js';
|
|
36
|
+
import './placement.js';
|
|
37
|
+
import './i18n.js';
|
|
38
|
+
import '@zag-js/dialog';
|
|
39
|
+
import '@zag-js/menu';
|
|
40
|
+
import '@zag-js/tooltip';
|
|
41
|
+
|
|
42
|
+
/** The built-in dark chart theme. */
|
|
43
|
+
declare const DARK_CHART: ChartTheme;
|
|
44
|
+
/** The built-in light chart theme. Candle hues are shared across themes: switching themes
|
|
45
|
+
* recolors surfaces and text, never the series. */
|
|
46
|
+
declare const LIGHT_CHART: ChartTheme;
|
|
47
|
+
/** Every token, by name without the `--vela-` prefix. A test checks the list against what
|
|
48
|
+
* `createTheme` writes. */
|
|
49
|
+
declare const TOKEN_NAMES: readonly ["space-1", "space-2", "space-3", "space-4", "radius-sm", "radius-md", "radius-lg", "z-tooltip", "z-menu", "z-dialog", "z-popover", "ease", "dur-fast", "dur-med", "font-size-sm", "font-size-md", "font-size-lg", "scroll-size", "font", "bg", "fg", "fg-muted", "fg-faint", "fg-bright", "surface", "surface-elev", "surface-overlay", "surface-sunken", "border", "border-strong", "border-soft", "border-faint", "hover", "active", "hover-strong", "focus", "focus-soft", "separator-hover-band", "separator-hover-line", "scroll", "accent", "accent-bright", "highlight", "selected-bg", "selected-fg", "fg-on-fill", "up", "down", "profit", "loss", "danger", "shadow", "shadow-dialog", "backdrop"];
|
|
50
|
+
type TokenName = (typeof TOKEN_NAMES)[number];
|
|
51
|
+
/** The components a theme can set, by name: each one's declaration. A package with
|
|
52
|
+
* components of its own adds them here by declaration merging. */
|
|
53
|
+
interface ComponentDefs {
|
|
54
|
+
badge: typeof badgeDef;
|
|
55
|
+
'bar-chart': typeof barChartDef;
|
|
56
|
+
button: typeof buttonDef;
|
|
57
|
+
'callout-bubble': typeof calloutBubbleDef;
|
|
58
|
+
'color-picker': typeof colorPickerDef;
|
|
59
|
+
'data-table': typeof dataTableDef;
|
|
60
|
+
'date-picker': typeof datePickerDef;
|
|
61
|
+
dialog: typeof dialogDef;
|
|
62
|
+
donut: typeof donutDef;
|
|
63
|
+
drawer: typeof drawerDef;
|
|
64
|
+
empty: typeof emptyDef;
|
|
65
|
+
field: typeof fieldDef;
|
|
66
|
+
'glyph-select': typeof glyphSelectDef;
|
|
67
|
+
'hover-card': typeof hoverCardDef;
|
|
68
|
+
kbd: typeof kbdDef;
|
|
69
|
+
'line-chart': typeof lineChartDef;
|
|
70
|
+
'dropdown-menu': typeof dropdownMenuDef;
|
|
71
|
+
'number-input': typeof numberInputDef;
|
|
72
|
+
popover: typeof popoverDef;
|
|
73
|
+
'scatter-chart': typeof scatterChartDef;
|
|
74
|
+
select: typeof selectDef;
|
|
75
|
+
sparkline: typeof sparklineDef;
|
|
76
|
+
stat: typeof statDef;
|
|
77
|
+
checkbox: typeof checkboxDef;
|
|
78
|
+
tabs: typeof tabsDef;
|
|
79
|
+
'text-area': typeof textAreaDef;
|
|
80
|
+
input: typeof inputDef;
|
|
81
|
+
'input-group': typeof inputGroupDef;
|
|
82
|
+
switch: typeof switchDef;
|
|
83
|
+
'toggle-group': typeof toggleGroupDef;
|
|
84
|
+
tooltip: typeof tooltipDef;
|
|
85
|
+
}
|
|
86
|
+
type SettingsOf<D> = D extends ComponentDef<string, string, infer S> ? S : never;
|
|
87
|
+
type PartsOf<D> = D extends ComponentDef<string, infer P, string> ? P : never;
|
|
88
|
+
/** Settings by component, then by setting (`{ button: { radius: '2px' } }`), each written
|
|
89
|
+
* as `--vela-<component>-<setting>`. `css` restyles the component's parts completely: each
|
|
90
|
+
* part's CSS, written with the `css` tag, applies to that part under the theme, after every
|
|
91
|
+
* other layer of the kit. */
|
|
92
|
+
type ComponentSettings = {
|
|
93
|
+
[K in keyof ComponentDefs]?: {
|
|
94
|
+
[S in SettingsOf<ComponentDefs[K]>]?: string;
|
|
95
|
+
} & {
|
|
96
|
+
css?: {
|
|
97
|
+
[P in PartsOf<ComponentDefs[K]>]?: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
interface CreateThemeOptions {
|
|
102
|
+
/** Apply part CSS that was not written with the `css` tag (a theme loaded from data).
|
|
103
|
+
* Off by default: CSS from someone else can restyle the page to mislead, and load
|
|
104
|
+
* remote images that leak what the page shows. */
|
|
105
|
+
allowCss?: boolean;
|
|
106
|
+
}
|
|
107
|
+
/** A theme's settings beyond the chart's colors. */
|
|
108
|
+
interface ThemeSettings {
|
|
109
|
+
/** The brand color; its readable ink derives from it. */
|
|
110
|
+
accent?: string;
|
|
111
|
+
/** Scales every radius token: `none`, `sm`, `md` (default), `lg`. */
|
|
112
|
+
radius?: 'none' | 'sm' | 'md' | 'lg';
|
|
113
|
+
font?: string;
|
|
114
|
+
/** Any token, by name. */
|
|
115
|
+
tokens?: Partial<Record<TokenName, string>>;
|
|
116
|
+
components?: ComponentSettings;
|
|
117
|
+
}
|
|
118
|
+
/** The choices a theme is built from. Every field is optional: `createTheme()` is the dark theme. */
|
|
119
|
+
interface ThemeInput extends ThemeSettings {
|
|
120
|
+
/** The theme to start from: `dark` (default), `light`, or a chart theme's seven fields. */
|
|
121
|
+
base?: 'dark' | 'light' | ChartTheme;
|
|
122
|
+
/** A theme from colors alone: everything else derives from them, light or dark read
|
|
123
|
+
* from the background. */
|
|
124
|
+
colors?: {
|
|
125
|
+
background?: string;
|
|
126
|
+
text?: string;
|
|
127
|
+
grid?: string;
|
|
128
|
+
border?: string;
|
|
129
|
+
up?: string;
|
|
130
|
+
down?: string;
|
|
131
|
+
accent?: string;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/** A theme built by {@link createTheme}. */
|
|
135
|
+
interface UiTheme {
|
|
136
|
+
/** Derived from the values: equal themes share one rule. */
|
|
137
|
+
readonly id: string;
|
|
138
|
+
/** The chart's colors and font. */
|
|
139
|
+
readonly chart: ChartTheme;
|
|
140
|
+
/** Every token, by custom property (`--vela-accent`). */
|
|
141
|
+
readonly tokens: Readonly<Record<string, string>>;
|
|
142
|
+
/** Component settings, by component then setting. */
|
|
143
|
+
readonly components: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
144
|
+
/** Part CSS, by component then part. */
|
|
145
|
+
readonly css: Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
146
|
+
/** Its settings beyond the chart's colors: with {@link chart}, they rebuild the theme. */
|
|
147
|
+
readonly settings: Readonly<ThemeSettings>;
|
|
148
|
+
}
|
|
149
|
+
/** A chart theme with optional settings: its seven fields seed the UI theme and `ui`
|
|
150
|
+
* adjusts it. Chrome that recolors its surface (an overlay following the plot's
|
|
151
|
+
* background) keeps the settings. */
|
|
152
|
+
type ThemedChart = ChartTheme & {
|
|
153
|
+
readonly ui?: ThemeSettings;
|
|
154
|
+
};
|
|
155
|
+
/** What is wrong with a theme's input: unknown tokens, components, settings and parts, colors
|
|
156
|
+
* the theme cannot derive from, text with too little contrast on its background, and part
|
|
157
|
+
* CSS that is left out or reaches past the component's contract. `createTheme` warns about
|
|
158
|
+
* each. */
|
|
159
|
+
declare function checkTheme(input?: ThemeInput, options?: CreateThemeOptions): string[];
|
|
160
|
+
/** Build a theme. Without overrides, `dark` and `light` give exactly the built-in tokens. */
|
|
161
|
+
declare function createTheme(input?: ThemeInput, options?: CreateThemeOptions): UiTheme;
|
|
162
|
+
/** The theme's rules: every token and component setting, by default on the hosts that carry
|
|
163
|
+
* its id; and the part CSS, on those parts inside them, in the last layer. */
|
|
164
|
+
declare function themeCss(theme: UiTheme, selector?: string): string;
|
|
165
|
+
/** Theme a host and everything inside it. A chart theme's seven fields build the theme on
|
|
166
|
+
* the way, keeping the choices of the UI theme it carries. */
|
|
167
|
+
declare function applyTheme(host: HTMLElement, theme: UiTheme | ThemedChart): UiTheme;
|
|
168
|
+
/** Theme a host from a chart theme's seven fields.
|
|
169
|
+
* @deprecated Use {@link applyTheme}, which also takes a theme from {@link createTheme}. */
|
|
170
|
+
declare function applyThemeTokens(el: HTMLElement, t: ThemedChart): void;
|
|
171
|
+
/** Re-token a chart-overlay host (statusline, watermark, toast — chrome floating OVER
|
|
172
|
+
* the plot) from the LIVE plot surface: a config edit can recolor the plot background
|
|
173
|
+
* independently of the app theme (a white plot typed into settings on the dark theme),
|
|
174
|
+
* and the overlay ink must stay readable either way. `config` is the renderer's
|
|
175
|
+
* `getConfig()` snapshot; a missing/shapeless one falls back to the base app theme.
|
|
176
|
+
* Floating menus and dropdowns do NOT use this — they mount on {@link floatingLayerHost}
|
|
177
|
+
* so their surface follows the app theme alone. */
|
|
178
|
+
declare function applyPlotOverlayTokens(host: HTMLElement, base: ThemedChart, config: unknown): void;
|
|
179
|
+
/** Mount floating kit layers (menus, select lists) on the nearest `.vela-ui` so they
|
|
180
|
+
* inherit the app-theme tokens. A plot-overlay host (the cell) retokens from
|
|
181
|
+
* `layout.background`; chrome panels must not follow that. Falls back to `fallback`
|
|
182
|
+
* (typically `document.body`) when no kit host is an ancestor. */
|
|
183
|
+
declare function floatingLayerHost(from: HTMLElement, fallback?: HTMLElement): HTMLElement;
|
|
184
|
+
/** Mark an element as a kit host (the `.vela-ui` class and the shared sheet), themed when
|
|
185
|
+
* a theme is given. */
|
|
186
|
+
declare function ensureUIHost(el: HTMLElement, theme?: UiTheme | ThemedChart): void;
|
|
187
|
+
|
|
188
|
+
export { type ComponentDefs, type ComponentSettings, type CreateThemeOptions, DARK_CHART, LIGHT_CHART, TOKEN_NAMES, type ThemeInput, type ThemeSettings, type ThemedChart, type TokenName, type UiTheme, applyPlotOverlayTokens, applyTheme, applyThemeTokens, checkTheme, createTheme, ensureUIHost, floatingLayerHost, themeCss };
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DARK_CHART, LIGHT_CHART, TOKEN_NAMES, applyPlotOverlayTokens, applyTheme, applyThemeTokens, checkTheme, createTheme, ensureUIHost, floatingLayerHost, themeCss } from './chunk-AJ2IYSOI.js';
|
|
2
|
+
import './chunk-TAKSIV57.js';
|
|
3
|
+
import './chunk-MMTMOV6R.js';
|
|
4
|
+
import './chunk-VMCR3S2A.js';
|
|
5
|
+
import './chunk-IDA2BT7D.js';
|
|
6
|
+
import './chunk-2GQIZM5Z.js';
|
|
7
|
+
import './chunk-BXMWQIBO.js';
|
|
8
|
+
import './chunk-X66RJAIS.js';
|