@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
package/dist/button.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { a as VariantProps, V as VariantFn } from './variants-B4stUBnY.js';
|
|
2
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
declare const buttonDef: ComponentDef<"button", "root" | "keys" | "icon", "radius" | "font-size-sm" | "height" | "height-xs" | "height-sm" | "height-lg" | "font-size" | "font-size-xs">;
|
|
6
|
+
declare const buttonVariants: VariantFn<{
|
|
7
|
+
readonly variant: readonly ["default", "outline", "secondary", "ghost", "destructive", "link", "up", "down", "favorite"];
|
|
8
|
+
readonly size: readonly ["default", "xs", "sm", "lg", "icon", "icon-xs", "icon-sm", "icon-lg"];
|
|
9
|
+
}>;
|
|
10
|
+
type ButtonVariant = (typeof buttonVariants.spec.variant)[number];
|
|
11
|
+
type ButtonSize = (typeof buttonVariants.spec.size)[number];
|
|
12
|
+
interface ButtonProps extends VariantProps<typeof buttonVariants> {
|
|
13
|
+
/** The visible text (the `icon*` sizes show none; `label` names them). */
|
|
14
|
+
text?: string;
|
|
15
|
+
/** Icon id from the kit's registry, before the text (the icon of an `icon*` size).
|
|
16
|
+
* `favorite` defaults to `star`. */
|
|
17
|
+
icon?: string;
|
|
18
|
+
/** The icon while pressed (`star-filled` for `star`). `favorite` defaults to `star-filled`. */
|
|
19
|
+
iconPressed?: string;
|
|
20
|
+
/** Icon id after the text (a menu trigger's chevron). */
|
|
21
|
+
iconEnd?: string;
|
|
22
|
+
/** Key caps before the text, one per key (`['↑', '↓']`). */
|
|
23
|
+
keys?: readonly string[];
|
|
24
|
+
/** Key caps after the text. */
|
|
25
|
+
keysEnd?: readonly string[];
|
|
26
|
+
/** Accessible name; required for the `icon*` sizes, defaults to `text`. */
|
|
27
|
+
label?: string;
|
|
28
|
+
/** A controlled toggle's state (`aria-pressed`): a press only calls `onPressedChange`, and
|
|
29
|
+
* `setPressed` moves it. Omitted with `defaultPressed` and `onPressedChange`: not a toggle. */
|
|
30
|
+
pressed?: boolean;
|
|
31
|
+
/** An uncontrolled toggle's first state: a press flips it and calls `onPressedChange`. */
|
|
32
|
+
defaultPressed?: boolean;
|
|
33
|
+
/** A press asked for this state (a toggle without `pressed` or `defaultPressed` starts
|
|
34
|
+
* unpressed). */
|
|
35
|
+
onPressedChange?: (pressed: boolean) => void;
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
onClick?: (e: MouseEvent) => void;
|
|
38
|
+
/** Extra class names (layout hooks). */
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
interface ButtonHandle {
|
|
42
|
+
readonly el: HTMLButtonElement;
|
|
43
|
+
readonly pressed: boolean | undefined;
|
|
44
|
+
/** Show a toggle's state, without calling `onPressedChange`. */
|
|
45
|
+
setPressed(pressed: boolean): void;
|
|
46
|
+
setDisabled(disabled: boolean): void;
|
|
47
|
+
/** New text (or, for an `icon*` size, a new accessible name). */
|
|
48
|
+
setText(text: string): void;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
}
|
|
51
|
+
declare const BUTTON_STYLE_ID = "vela-ui-button";
|
|
52
|
+
declare const BUTTON_CSS: string;
|
|
53
|
+
declare function createButton(props?: ButtonProps): ButtonHandle;
|
|
54
|
+
|
|
55
|
+
export { BUTTON_CSS, BUTTON_STYLE_ID, type ButtonHandle, type ButtonProps, type ButtonSize, type ButtonVariant, buttonDef, buttonVariants, createButton };
|
package/dist/button.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { BUTTON_CSS, BUTTON_STYLE_ID, buttonDef, buttonVariants, createButton } from './chunk-CC3DDNFC.js';
|
|
2
|
+
import './chunk-C3ICYMI3.js';
|
|
3
|
+
import './chunk-LZWZV2ZS.js';
|
|
4
|
+
import './chunk-G7IQLY3A.js';
|
|
5
|
+
import './chunk-Q6WTDVH6.js';
|
|
6
|
+
import './chunk-VMCR3S2A.js';
|
|
7
|
+
import './chunk-XBEL4K33.js';
|
|
8
|
+
import './chunk-2GQIZM5Z.js';
|
|
9
|
+
import './chunk-BXMWQIBO.js';
|
|
10
|
+
import './chunk-X66RJAIS.js';
|
|
11
|
+
import './chunk-6QCILIT2.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Translator } from './i18n.js';
|
|
2
|
+
|
|
3
|
+
interface CalendarSettings {
|
|
4
|
+
readonly locale: string;
|
|
5
|
+
readonly numberingSystem: string;
|
|
6
|
+
/** The locale's language is English: the picker's own tables apply. */
|
|
7
|
+
readonly english: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** The calendar settings of a translator (English, Latin digits, without one). */
|
|
10
|
+
declare function calendarSettings(i18n: Translator | null | undefined): CalendarSettings;
|
|
11
|
+
/** Twelve month names, January first. */
|
|
12
|
+
declare function monthNames(settings: CalendarSettings, width: 'long' | 'short'): string[];
|
|
13
|
+
/** Seven short weekday names, Sunday first (index = `Date#getDay()`). */
|
|
14
|
+
declare function weekdayNames(settings: CalendarSettings): string[];
|
|
15
|
+
/** A day in words, for a screen reader (`Friday, November 6, 2026`). `month` counts from 0. */
|
|
16
|
+
declare function longDate(settings: CalendarSettings, year: number, month: number, day: number): string;
|
|
17
|
+
/** A year as a header label (`2026`, `2026年`). */
|
|
18
|
+
declare function yearLabel(settings: CalendarSettings, year: number): string;
|
|
19
|
+
/** An integer in the settings' digits, without grouping (`2026`, `٢٠٢٦`). */
|
|
20
|
+
declare function plainInteger(settings: CalendarSettings, n: number): string;
|
|
21
|
+
/** Whether the locale writes the year before the month (`2026年9月`, not `September 2026`). */
|
|
22
|
+
declare function yearBeforeMonth(settings: CalendarSettings): boolean;
|
|
23
|
+
|
|
24
|
+
export { type CalendarSettings, calendarSettings, longDate, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel };
|
package/dist/calendar.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { calendarSettings, longDate, monthNames, plainInteger, weekdayNames, yearBeforeMonth, yearLabel } from './chunk-GVRX3UAV.js';
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
2
|
+
import { PlacementProps } from './placement.js';
|
|
3
|
+
import { ChartTheme } from './tokens.js';
|
|
4
|
+
import { PopoverBoundary } from './popover.js';
|
|
5
|
+
import './t.js';
|
|
6
|
+
|
|
7
|
+
/** One block of a deployed callout panel — plain text, or a button running a caller action. */
|
|
8
|
+
type CalloutPanelItem = {
|
|
9
|
+
type: 'text';
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: 'button';
|
|
13
|
+
label: string;
|
|
14
|
+
/** Emphasized (selection-colored) button — the panel's main action. */
|
|
15
|
+
primary?: boolean;
|
|
16
|
+
/** Close the panel after `run` (default true — an action answers the panel). */
|
|
17
|
+
close?: boolean;
|
|
18
|
+
run(): void;
|
|
19
|
+
};
|
|
20
|
+
/** The deployed panel: an optional heading over ordered text/button blocks. */
|
|
21
|
+
interface CalloutPanel {
|
|
22
|
+
title?: string;
|
|
23
|
+
items: CalloutPanelItem[];
|
|
24
|
+
}
|
|
25
|
+
/** What dresses the bubble itself (the panel is what the click deploys). */
|
|
26
|
+
interface CalloutBubbleSpec {
|
|
27
|
+
/** Icon id in the icon registry (`registerIcon`), centered in the bubble. */
|
|
28
|
+
icon: string;
|
|
29
|
+
/** Bubble fill — any CSS color, token expressions included. */
|
|
30
|
+
background: string;
|
|
31
|
+
/** Icon ink (default: `currentColor` inherited from the slot). */
|
|
32
|
+
color?: string;
|
|
33
|
+
/** Accessible name. Callers typically show the same text in their own tooltip. */
|
|
34
|
+
label: string;
|
|
35
|
+
/** Deployed panel — presence makes the bubble clickable. */
|
|
36
|
+
panel?: CalloutPanel;
|
|
37
|
+
}
|
|
38
|
+
/** Whether activating a panel button also closes the panel (defaults to yes). */
|
|
39
|
+
declare function closesPanel(item: Extract<CalloutPanelItem, {
|
|
40
|
+
type: 'button';
|
|
41
|
+
}>): boolean;
|
|
42
|
+
/** A panel row as the view lays it out: one text block, or a run of adjacent buttons. */
|
|
43
|
+
type CalloutPanelRow = {
|
|
44
|
+
type: 'text';
|
|
45
|
+
text: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'buttons';
|
|
48
|
+
buttons: Array<Extract<CalloutPanelItem, {
|
|
49
|
+
type: 'button';
|
|
50
|
+
}>>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Group a panel's ordered items into layout rows: consecutive buttons share one row
|
|
54
|
+
* (the common "text above, actions below" shape falls out naturally), text blocks
|
|
55
|
+
* stand alone. Pure — unit-tested apart from the DOM.
|
|
56
|
+
*/
|
|
57
|
+
declare function calloutPanelRows(items: CalloutPanelItem[]): CalloutPanelRow[];
|
|
58
|
+
declare const calloutBubbleDef: ComponentDef<"callout-bubble", "root" | "text" | "button" | "title" | "panel" | "actions", "panel-radius" | "button-radius">;
|
|
59
|
+
/** The panel opens where the placement props say (default below and start-aligned, 6px away,
|
|
60
|
+
* flipping above near the bottom edge). */
|
|
61
|
+
interface CalloutBubbleOptions extends CalloutBubbleSpec, PlacementProps {
|
|
62
|
+
/** Bubble diameter in px (default 16; the icon renders 4px smaller). */
|
|
63
|
+
size?: number;
|
|
64
|
+
/** Where the deployed panel portals (default: the document body). Pass the chart
|
|
65
|
+
* or widget root so the panel lives inside the host's DOM. */
|
|
66
|
+
host?: HTMLElement;
|
|
67
|
+
/** Live theme, for a panel deployed OUTSIDE a `.vela-ui` token host (renderer
|
|
68
|
+
* chrome on a bare chart passes its theme getter; widget chrome may omit it). */
|
|
69
|
+
theme?: () => ChartTheme;
|
|
70
|
+
/** @deprecated Use `collisionBoundary`. */
|
|
71
|
+
boundary?: PopoverBoundary;
|
|
72
|
+
}
|
|
73
|
+
type CalloutBubbleProps = CalloutBubbleOptions;
|
|
74
|
+
declare const CALLOUT_STYLE_ID = "vela-ui-callout-bubble";
|
|
75
|
+
declare const CALLOUT_CSS: string;
|
|
76
|
+
/** A part of the deployed panel, as {@link calloutPart} gives it. */
|
|
77
|
+
type CalloutPanelPart = Exclude<(typeof calloutBubbleDef.parts)[number], 'root'>;
|
|
78
|
+
/** Make `el` a part of a deployed panel, with the panel's look: for a panel built without a
|
|
79
|
+
* bubble, such as a chart's timeline-mark popup. Returns `el`. */
|
|
80
|
+
declare function calloutPart<E extends HTMLElement>(el: E, part: CalloutPanelPart): E;
|
|
81
|
+
declare class CalloutBubble {
|
|
82
|
+
readonly el: HTMLElement;
|
|
83
|
+
private spec;
|
|
84
|
+
private readonly size;
|
|
85
|
+
private readonly host;
|
|
86
|
+
private readonly theme;
|
|
87
|
+
private readonly placement;
|
|
88
|
+
private pop;
|
|
89
|
+
constructor(opts: CalloutBubbleOptions);
|
|
90
|
+
/** Re-dress the bubble (a status change: new icon, tint, label, panel). */
|
|
91
|
+
set(spec: Partial<CalloutBubbleSpec>): void;
|
|
92
|
+
/** Whether the deployed panel is currently open. */
|
|
93
|
+
get open(): boolean;
|
|
94
|
+
/** Close the deployed panel, if any. The bubble itself stays. */
|
|
95
|
+
hidePanel(): void;
|
|
96
|
+
destroy(): void;
|
|
97
|
+
private dress;
|
|
98
|
+
private toggle;
|
|
99
|
+
private buildPanel;
|
|
100
|
+
}
|
|
101
|
+
declare function createCalloutBubble(props: CalloutBubbleProps): CalloutBubble;
|
|
102
|
+
|
|
103
|
+
export { CALLOUT_CSS, CALLOUT_STYLE_ID, CalloutBubble, type CalloutBubbleOptions, type CalloutBubbleProps, type CalloutBubbleSpec, type CalloutPanel, type CalloutPanelItem, type CalloutPanelPart, type CalloutPanelRow, calloutBubbleDef, calloutPanelRows, calloutPart, closesPanel, createCalloutBubble };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { iconAt } from './chunk-G7IQLY3A.js';
|
|
2
|
+
import { Popover } from './chunk-B5ZSRUDQ.js';
|
|
3
|
+
import './chunk-J2QJATCD.js';
|
|
4
|
+
import './chunk-S7USVSYP.js';
|
|
5
|
+
import './chunk-V2Q4MRMS.js';
|
|
6
|
+
import './chunk-TAKSIV57.js';
|
|
7
|
+
import './chunk-MMTMOV6R.js';
|
|
8
|
+
import './chunk-3Q32K4PE.js';
|
|
9
|
+
import './chunk-A72NWYNP.js';
|
|
10
|
+
import { addSlot } from './chunk-Q6WTDVH6.js';
|
|
11
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
12
|
+
import { css, defineStyles } from './chunk-XBEL4K33.js';
|
|
13
|
+
import './chunk-2GQIZM5Z.js';
|
|
14
|
+
import './chunk-BXMWQIBO.js';
|
|
15
|
+
import './chunk-X66RJAIS.js';
|
|
16
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
17
|
+
|
|
18
|
+
// src/components/callout-bubble.ts
|
|
19
|
+
function closesPanel(item) {
|
|
20
|
+
return item.close !== false;
|
|
21
|
+
}
|
|
22
|
+
function calloutPanelRows(items) {
|
|
23
|
+
const rows = [];
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
if (item.type === "text") {
|
|
26
|
+
rows.push({ type: "text", text: item.text });
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const last = rows[rows.length - 1];
|
|
30
|
+
if (last && last.type === "buttons") last.buttons.push(item);
|
|
31
|
+
else rows.push({ type: "buttons", buttons: [item] });
|
|
32
|
+
}
|
|
33
|
+
return rows;
|
|
34
|
+
}
|
|
35
|
+
var calloutBubbleDef = defineComponent({
|
|
36
|
+
name: "callout-bubble",
|
|
37
|
+
parts: ["root", "panel", "title", "text", "actions", "button"],
|
|
38
|
+
settings: { "panel-radius": t.radius.md, "button-radius": "5px" }
|
|
39
|
+
});
|
|
40
|
+
var CALLOUT_STYLE_ID = "vela-ui-callout-bubble";
|
|
41
|
+
var CALLOUT_CSS = css`@layer vela.ui{[data-slot=callout-bubble]{box-sizing:border-box;cursor:default;-webkit-user-select:none;user-select:none;border-radius:50%;flex:none;place-items:center;line-height:0}[data-slot=callout-bubble]:where(:not([hidden])){display:inline-grid}[data-slot=callout-bubble][role=button]{cursor:pointer}[data-slot=callout-bubble] svg{display:block}[data-slot=callout-bubble-panel]{box-sizing:border-box;background:${t.surface.elev};border:1px solid ${t.border.strong};border-radius:${calloutBubbleDef.vars["panel-radius"]};max-width:280px;box-shadow:${t.shadow};color:${t.fg};font:${t.fontSize.md} ${t.font};flex-direction:column;gap:8px;padding:10px 12px;display:flex}[data-slot=callout-bubble-title]{color:${t.fg.bright};font-weight:600}[data-slot=callout-bubble-text]{color:${t.fg.muted};white-space:pre-line;line-height:1.45}[data-slot=callout-bubble-actions]{flex-wrap:wrap;gap:8px;display:flex}[data-slot=callout-bubble-button]{cursor:pointer;border-radius:${calloutBubbleDef.vars["button-radius"]};border:1px solid ${t.border};height:26px;color:${t.fg};font-size:${t.fontSize.md};transition:background ${t.dur.fast} ease, color ${t.dur.fast} ease, opacity ${t.dur.fast} ease, border-color ${t.dur.fast} ease;background:0 0;padding:0 10px;font-family:inherit}[data-slot=callout-bubble-button]:where([data-primary]){border-color:${t.selected.bg};background:${t.selected.bg};color:${t.selected.fg}}[data-slot=callout-bubble-button]:hover{background:${t.hover};color:${t.fg.bright};border-color:${t.fg.muted}}[data-slot=callout-bubble-button]:where([data-primary]):hover{background:${t.selected.bg};color:${t.selected.fg};opacity:.85;border-color:${t.selected.bg}}}`;
|
|
42
|
+
var injectStyles = defineStyles(CALLOUT_STYLE_ID, CALLOUT_CSS);
|
|
43
|
+
function calloutPart(el, part) {
|
|
44
|
+
injectStyles(el.ownerDocument);
|
|
45
|
+
addSlot(el, calloutBubbleDef.slot(part));
|
|
46
|
+
return el;
|
|
47
|
+
}
|
|
48
|
+
var CalloutBubble = class {
|
|
49
|
+
constructor(opts) {
|
|
50
|
+
this.pop = null;
|
|
51
|
+
this.spec = { icon: opts.icon, background: opts.background, label: opts.label };
|
|
52
|
+
if (opts.color !== void 0) this.spec.color = opts.color;
|
|
53
|
+
if (opts.panel !== void 0) this.spec.panel = opts.panel;
|
|
54
|
+
this.size = opts.size ?? 16;
|
|
55
|
+
this.host = opts.host;
|
|
56
|
+
this.theme = opts.theme;
|
|
57
|
+
this.placement = { ...opts, collisionBoundary: opts.collisionBoundary ?? opts.boundary };
|
|
58
|
+
const doc = (opts.host ?? document.body).ownerDocument;
|
|
59
|
+
injectStyles(doc);
|
|
60
|
+
this.el = doc.createElement("span");
|
|
61
|
+
this.el.className = "vela-callout";
|
|
62
|
+
this.el.dataset.slot = calloutBubbleDef.slot("root");
|
|
63
|
+
this.el.style.width = `${this.size}px`;
|
|
64
|
+
this.el.style.height = `${this.size}px`;
|
|
65
|
+
this.el.addEventListener("click", (e) => {
|
|
66
|
+
if (!this.spec.panel) return;
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
this.toggle();
|
|
69
|
+
});
|
|
70
|
+
this.el.addEventListener("dblclick", (e) => {
|
|
71
|
+
if (this.spec.panel) e.stopPropagation();
|
|
72
|
+
});
|
|
73
|
+
this.el.addEventListener("keydown", (e) => {
|
|
74
|
+
if (!this.spec.panel || e.key !== "Enter" && e.key !== " ") return;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
this.toggle();
|
|
77
|
+
});
|
|
78
|
+
this.dress();
|
|
79
|
+
}
|
|
80
|
+
/** Re-dress the bubble (a status change: new icon, tint, label, panel). */
|
|
81
|
+
set(spec) {
|
|
82
|
+
this.spec = { ...this.spec, ...spec };
|
|
83
|
+
if ("panel" in spec) this.pop?.hide();
|
|
84
|
+
this.dress();
|
|
85
|
+
}
|
|
86
|
+
/** Whether the deployed panel is currently open. */
|
|
87
|
+
get open() {
|
|
88
|
+
return this.pop?.open ?? false;
|
|
89
|
+
}
|
|
90
|
+
/** Close the deployed panel, if any. The bubble itself stays. */
|
|
91
|
+
hidePanel() {
|
|
92
|
+
this.pop?.hide();
|
|
93
|
+
}
|
|
94
|
+
destroy() {
|
|
95
|
+
this.pop?.destroy();
|
|
96
|
+
this.pop = null;
|
|
97
|
+
this.el.remove();
|
|
98
|
+
}
|
|
99
|
+
dress() {
|
|
100
|
+
const clickable = this.spec.panel !== void 0;
|
|
101
|
+
this.el.style.background = this.spec.background;
|
|
102
|
+
this.el.style.color = this.spec.color ?? "";
|
|
103
|
+
this.el.innerHTML = iconAt(this.spec.icon, this.size - 4);
|
|
104
|
+
this.el.setAttribute("aria-label", this.spec.label);
|
|
105
|
+
if (clickable) {
|
|
106
|
+
this.el.setAttribute("role", "button");
|
|
107
|
+
this.el.tabIndex = 0;
|
|
108
|
+
} else {
|
|
109
|
+
this.el.removeAttribute("role");
|
|
110
|
+
this.el.removeAttribute("tabindex");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
toggle() {
|
|
114
|
+
if (this.pop?.open) {
|
|
115
|
+
this.pop.hide();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const panel = this.spec.panel;
|
|
119
|
+
if (!panel) return;
|
|
120
|
+
this.pop?.destroy();
|
|
121
|
+
this.pop = new Popover({
|
|
122
|
+
trigger: this.el,
|
|
123
|
+
side: this.placement.side,
|
|
124
|
+
align: this.placement.align,
|
|
125
|
+
sideOffset: this.placement.sideOffset ?? 6,
|
|
126
|
+
alignOffset: this.placement.alignOffset,
|
|
127
|
+
avoidCollisions: this.placement.avoidCollisions,
|
|
128
|
+
collisionPadding: this.placement.collisionPadding,
|
|
129
|
+
content: (body) => this.buildPanel(body, panel),
|
|
130
|
+
...this.host ? { host: this.host } : {},
|
|
131
|
+
...this.theme ? { theme: this.theme() } : {},
|
|
132
|
+
...this.placement.collisionBoundary ? { collisionBoundary: this.placement.collisionBoundary } : {}
|
|
133
|
+
});
|
|
134
|
+
this.pop.show();
|
|
135
|
+
}
|
|
136
|
+
buildPanel(body, panel) {
|
|
137
|
+
const doc = body.ownerDocument;
|
|
138
|
+
const part = (tag, className, name) => {
|
|
139
|
+
const el = doc.createElement(tag);
|
|
140
|
+
el.className = className;
|
|
141
|
+
return calloutPart(el, name);
|
|
142
|
+
};
|
|
143
|
+
const root = part("div", "vela-callout-panel", "panel");
|
|
144
|
+
if (panel.title) {
|
|
145
|
+
const title = part("div", "vela-callout-title", "title");
|
|
146
|
+
title.textContent = panel.title;
|
|
147
|
+
root.appendChild(title);
|
|
148
|
+
}
|
|
149
|
+
for (const row of calloutPanelRows(panel.items)) {
|
|
150
|
+
if (row.type === "text") {
|
|
151
|
+
const text = part("div", "vela-callout-text", "text");
|
|
152
|
+
text.textContent = row.text;
|
|
153
|
+
root.appendChild(text);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
const actions = part("div", "vela-callout-actions", "actions");
|
|
157
|
+
for (const item of row.buttons) {
|
|
158
|
+
const btn = part("button", "vela-callout-btn" + (item.primary ? " vela-callout-btn-primary" : ""), "button");
|
|
159
|
+
btn.type = "button";
|
|
160
|
+
if (item.primary) btn.dataset.primary = "";
|
|
161
|
+
btn.textContent = item.label;
|
|
162
|
+
btn.addEventListener("click", () => {
|
|
163
|
+
item.run();
|
|
164
|
+
if (closesPanel(item)) this.pop?.hide();
|
|
165
|
+
});
|
|
166
|
+
actions.appendChild(btn);
|
|
167
|
+
}
|
|
168
|
+
root.appendChild(actions);
|
|
169
|
+
}
|
|
170
|
+
body.appendChild(root);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
function createCalloutBubble(props) {
|
|
174
|
+
return new CalloutBubble(props);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export { CALLOUT_CSS, CALLOUT_STYLE_ID, CalloutBubble, calloutBubbleDef, calloutPanelRows, calloutPart, closesPanel, createCalloutBubble };
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** A round step for `range` in about `ticks` steps: 1, 2 or 5 times a power of ten. */
|
|
2
|
+
declare function niceStep(range: number, ticks: number): number;
|
|
3
|
+
/**
|
|
4
|
+
* A value axis spanning `lo..hi` in about `count` round steps: its bounds widened to whole
|
|
5
|
+
* steps, and its ticks from bound to bound with zero among them. One step serves both, so no
|
|
6
|
+
* tick falls outside the plot.
|
|
7
|
+
*/
|
|
8
|
+
declare function valueAxis(lo: number, hi: number, count: number): {
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
step: number;
|
|
12
|
+
ticks: number[];
|
|
13
|
+
};
|
|
14
|
+
/** `1.2k`, `-3.4M`, `0.25`. */
|
|
15
|
+
declare function compactNumber(v: number): string;
|
|
16
|
+
declare function escapeXml(s: string): string;
|
|
17
|
+
/** Fill the tip with a readout and place it beside the point at (x, y), inside the box. */
|
|
18
|
+
declare function showTip(tip: HTMLElement, content: string | Node, box: {
|
|
19
|
+
w: number;
|
|
20
|
+
h: number;
|
|
21
|
+
}, x: number, y: number): void;
|
|
22
|
+
/** A chart's root (sized by its parent), its SVG and its tip, redrawn as the root resizes. */
|
|
23
|
+
declare function chartFrame(rootSlot: string, tipSlot: string, className: string | undefined, draw: () => void): {
|
|
24
|
+
el: HTMLElement;
|
|
25
|
+
svg: SVGSVGElement;
|
|
26
|
+
tip: HTMLElement;
|
|
27
|
+
disconnect(): void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { chartFrame, compactNumber, escapeXml, niceStep, showTip, valueAxis };
|
package/dist/chart.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { chartFrame, compactNumber, escapeXml, niceStep, showTip, valueAxis } from './chunk-A2FJ7Y7D.js';
|
|
@@ -0,0 +1,60 @@
|
|
|
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 CheckboxSize = 'sm' | 'md';
|
|
6
|
+
/** `bright` = settings-dialog fill (`--vela-fg-bright`); `selected` = `--vela-selected-bg`. */
|
|
7
|
+
type CheckboxTone = 'bright' | 'selected';
|
|
8
|
+
interface CheckboxControllerOptions {
|
|
9
|
+
checked?: boolean;
|
|
10
|
+
/** The state it starts in when `checked` is not given. */
|
|
11
|
+
defaultChecked?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
size?: CheckboxSize;
|
|
14
|
+
tone?: CheckboxTone;
|
|
15
|
+
/** Called when the user toggles it. */
|
|
16
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
17
|
+
/** @deprecated Use `onCheckedChange`. */
|
|
18
|
+
onChange?: (checked: boolean) => void;
|
|
19
|
+
}
|
|
20
|
+
interface CheckboxController {
|
|
21
|
+
checked: boolean;
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
size: CheckboxSize;
|
|
24
|
+
tone: CheckboxTone;
|
|
25
|
+
setChecked(v: boolean): void;
|
|
26
|
+
toggle(): boolean;
|
|
27
|
+
}
|
|
28
|
+
/** The switch's state without DOM: checked, and the option mapping. */
|
|
29
|
+
declare function checkboxController(opts?: CheckboxControllerOptions): CheckboxController;
|
|
30
|
+
declare const checkboxDef: ComponentDef<"checkbox", "root" | "icon", "radius">;
|
|
31
|
+
declare const checkboxVariants: VariantFn<{
|
|
32
|
+
readonly size: readonly ["md", "sm"];
|
|
33
|
+
readonly tone: readonly ["bright", "selected"];
|
|
34
|
+
}>;
|
|
35
|
+
interface CheckboxOptions extends CheckboxControllerOptions {
|
|
36
|
+
id?: string;
|
|
37
|
+
/** Submitted with its form under this name (`on` when checked). */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** A form does not submit while it is off. */
|
|
40
|
+
required?: boolean;
|
|
41
|
+
}
|
|
42
|
+
type CheckboxProps = CheckboxOptions;
|
|
43
|
+
declare class Checkbox {
|
|
44
|
+
readonly el: HTMLLabelElement;
|
|
45
|
+
private readonly input;
|
|
46
|
+
private readonly machine;
|
|
47
|
+
private readonly mid;
|
|
48
|
+
private readonly release;
|
|
49
|
+
/** The state as the switch's users see it, at once: the machine settles a beat later. */
|
|
50
|
+
private current;
|
|
51
|
+
constructor(opts?: CheckboxOptions);
|
|
52
|
+
get checked(): boolean;
|
|
53
|
+
setChecked(v: boolean): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
private api;
|
|
56
|
+
private render;
|
|
57
|
+
}
|
|
58
|
+
declare function createCheckbox(props?: CheckboxProps): Checkbox;
|
|
59
|
+
|
|
60
|
+
export { Checkbox, type CheckboxController, type CheckboxControllerOptions, type CheckboxOptions, type CheckboxProps, type CheckboxSize, type CheckboxTone, checkboxController, checkboxDef, checkboxVariants, createCheckbox };
|
package/dist/checkbox.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { Checkbox, checkboxController, checkboxDef, checkboxVariants, createCheckbox } from './chunk-WBGSYCV2.js';
|
|
2
|
+
import './chunk-LZWZV2ZS.js';
|
|
3
|
+
import './chunk-G7IQLY3A.js';
|
|
4
|
+
import './chunk-A72NWYNP.js';
|
|
5
|
+
import './chunk-P4MTEMT7.js';
|
|
6
|
+
import './chunk-Q6WTDVH6.js';
|
|
7
|
+
import './chunk-VMCR3S2A.js';
|
|
8
|
+
import './chunk-XBEL4K33.js';
|
|
9
|
+
import './chunk-2GQIZM5Z.js';
|
|
10
|
+
import './chunk-BXMWQIBO.js';
|
|
11
|
+
import './chunk-X66RJAIS.js';
|
|
12
|
+
import './chunk-6QCILIT2.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/lib/styles.ts
|
|
2
|
+
function overlayScrollbarCss(selector, width) {
|
|
3
|
+
const size = width === void 0 ? "var(--vela-scroll-size, 5px)" : `${width}px`;
|
|
4
|
+
return `${selector}::-webkit-scrollbar{width:${size};height:${size};}${selector}::-webkit-scrollbar-thumb{background:var(--vela-scroll);border-radius:${size};}${selector}::-webkit-scrollbar-track,${selector}::-webkit-scrollbar-corner{background:transparent;}${selector}::-webkit-scrollbar-button{display:none;width:0;height:0;}`;
|
|
5
|
+
}
|
|
6
|
+
var FIELD_FOCUS_CSS = "outline:none;transition:border-color .12s ease,box-shadow .12s ease;";
|
|
7
|
+
var FIELD_FOCUS_RING = "border-color:var(--vela-focus);box-shadow:0 0 0 3px var(--vela-focus-soft);";
|
|
8
|
+
var LAYER_ORDER = "@layer vela.theme, vela.ui, vela.chrome, vela.pro, vela.custom;";
|
|
9
|
+
function injectLayerOrder(root = document) {
|
|
10
|
+
const sheet = injectStyles("vela-layers", LAYER_ORDER, root);
|
|
11
|
+
const parent = sheet?.parentNode;
|
|
12
|
+
if (!sheet || !parent) return;
|
|
13
|
+
const first = Array.from(parent.children).find((el) => el.tagName === "STYLE" && el.id.startsWith("vela"));
|
|
14
|
+
if (first && first !== sheet) parent.insertBefore(sheet, first);
|
|
15
|
+
}
|
|
16
|
+
function injectStyles(id, css, root = document) {
|
|
17
|
+
if (typeof document === "undefined") return null;
|
|
18
|
+
const host = root instanceof Document ? root.head : root;
|
|
19
|
+
const existing = typeof root.getElementById === "function" ? root.getElementById(id) : host.querySelector(`#${CSS.escape(id)}`);
|
|
20
|
+
if (existing) return existing;
|
|
21
|
+
const s = document.createElement("style");
|
|
22
|
+
s.id = id;
|
|
23
|
+
s.textContent = css;
|
|
24
|
+
host.appendChild(s);
|
|
25
|
+
return s;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { FIELD_FOCUS_CSS, FIELD_FOCUS_RING, LAYER_ORDER, injectLayerOrder, injectStyles, overlayScrollbarCss };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/lib/placement.ts
|
|
2
|
+
function insetRect(r, inset) {
|
|
3
|
+
return {
|
|
4
|
+
left: r.left + inset,
|
|
5
|
+
top: r.top + inset,
|
|
6
|
+
right: r.right - inset,
|
|
7
|
+
bottom: r.bottom - inset,
|
|
8
|
+
width: r.width - inset * 2,
|
|
9
|
+
height: r.height - inset * 2
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function viewportRect(width, height, inset) {
|
|
13
|
+
return {
|
|
14
|
+
left: inset,
|
|
15
|
+
top: inset,
|
|
16
|
+
right: width - inset,
|
|
17
|
+
bottom: height - inset,
|
|
18
|
+
width: width - inset * 2,
|
|
19
|
+
height: height - inset * 2
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function intersectRects(a, b) {
|
|
23
|
+
const left = Math.max(a.left, b.left);
|
|
24
|
+
const top = Math.max(a.top, b.top);
|
|
25
|
+
const right = Math.min(a.right, b.right);
|
|
26
|
+
const bottom = Math.min(a.bottom, b.bottom);
|
|
27
|
+
return { left, top, right, bottom, width: right - left, height: bottom - top };
|
|
28
|
+
}
|
|
29
|
+
function placePopover(a) {
|
|
30
|
+
const side = a.side ?? "bottom";
|
|
31
|
+
const avoid = a.avoidCollisions ?? true;
|
|
32
|
+
const shift = a.alignOffset ?? 0;
|
|
33
|
+
const vertical = side === "top" || side === "bottom";
|
|
34
|
+
const t = vertical ? { start: a.trigger.top, end: a.trigger.bottom, crossStart: a.trigger.left, crossEnd: a.trigger.right, crossSize: a.trigger.width } : { start: a.trigger.left, end: a.trigger.right, crossStart: a.trigger.top, crossEnd: a.trigger.bottom, crossSize: a.trigger.height };
|
|
35
|
+
const size = vertical ? a.pop.height : a.pop.width;
|
|
36
|
+
const crossSize = vertical ? a.pop.width : a.pop.height;
|
|
37
|
+
const clamp = vertical ? { start: a.clamp.top, end: a.clamp.bottom, crossStart: a.clamp.left, crossEnd: a.clamp.right } : { start: a.clamp.left, end: a.clamp.right, crossStart: a.clamp.top, crossEnd: a.clamp.bottom };
|
|
38
|
+
let cross = a.align === "end" ? t.crossEnd - crossSize - shift : a.align === "center" ? t.crossStart + t.crossSize / 2 - crossSize / 2 + shift : t.crossStart + shift;
|
|
39
|
+
const after = t.end + a.gap;
|
|
40
|
+
const before = t.start - size - a.gap;
|
|
41
|
+
let useAfter = side === "bottom" || side === "right";
|
|
42
|
+
if (avoid) {
|
|
43
|
+
const fitsAfter = after + size <= clamp.end;
|
|
44
|
+
const fitsBefore = before >= clamp.start;
|
|
45
|
+
const roomBefore = t.start - clamp.start;
|
|
46
|
+
const roomAfter = clamp.end - t.end;
|
|
47
|
+
if (useAfter && !fitsAfter && (fitsBefore || roomBefore > roomAfter)) useAfter = false;
|
|
48
|
+
else if (!useAfter && !fitsBefore && (fitsAfter || roomAfter > roomBefore)) useAfter = true;
|
|
49
|
+
}
|
|
50
|
+
let main = useAfter ? after : before;
|
|
51
|
+
if (avoid) {
|
|
52
|
+
if (cross + crossSize > clamp.crossEnd) cross = clamp.crossEnd - crossSize;
|
|
53
|
+
if (cross < clamp.crossStart) cross = clamp.crossStart;
|
|
54
|
+
if (main + size > clamp.end) main = clamp.end - size;
|
|
55
|
+
if (main < clamp.start) main = clamp.start;
|
|
56
|
+
}
|
|
57
|
+
const left = vertical ? cross : main;
|
|
58
|
+
const top = vertical ? main : cross;
|
|
59
|
+
return {
|
|
60
|
+
left: Math.round(left - a.originX),
|
|
61
|
+
top: Math.round(top - a.originY),
|
|
62
|
+
side: vertical ? useAfter ? "bottom" : "top" : useAfter ? "right" : "left"
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function splitPlacement(placement) {
|
|
66
|
+
const [side, align] = placement.split("-");
|
|
67
|
+
return { side, align: align ?? "center" };
|
|
68
|
+
}
|
|
69
|
+
function zagPositioning(props, defaults) {
|
|
70
|
+
const side = props.side ?? defaults.side;
|
|
71
|
+
const align = props.align ?? defaults.align;
|
|
72
|
+
const placement = align === "center" ? side : `${side}-${align}`;
|
|
73
|
+
const boundary = props.collisionBoundary;
|
|
74
|
+
return {
|
|
75
|
+
placement,
|
|
76
|
+
...props.sideOffset !== void 0 ? { gutter: props.sideOffset } : {},
|
|
77
|
+
// Zag shifts along the axis; shadcn's offset moves away from the aligned edge.
|
|
78
|
+
...props.alignOffset !== void 0 ? { shift: align === "end" ? -props.alignOffset : props.alignOffset } : {},
|
|
79
|
+
...props.avoidCollisions === false ? { flip: false, slide: false } : {},
|
|
80
|
+
...props.collisionPadding !== void 0 ? { overflowPadding: props.collisionPadding } : {},
|
|
81
|
+
...boundary && typeof boundary === "object" ? { boundary: () => boundary } : {}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { insetRect, intersectRects, placePopover, splitPlacement, viewportRect, zagPositioning };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/lib/t.ts
|
|
2
|
+
function tok(name) {
|
|
3
|
+
const prop = `--vela-${name}`;
|
|
4
|
+
const ref = `var(${prop})`;
|
|
5
|
+
return { name: prop, var: ref, toString: () => ref };
|
|
6
|
+
}
|
|
7
|
+
function group(base, subs) {
|
|
8
|
+
const out = base ? tok(base) : {};
|
|
9
|
+
for (const [key, name] of Object.entries(subs)) out[key] = tok(name);
|
|
10
|
+
return out;
|
|
11
|
+
}
|
|
12
|
+
var t = {
|
|
13
|
+
space: group(null, { 1: "space-1", 2: "space-2", 3: "space-3", 4: "space-4" }),
|
|
14
|
+
radius: group(null, { sm: "radius-sm", md: "radius-md", lg: "radius-lg" }),
|
|
15
|
+
z: group(null, { tooltip: "z-tooltip", menu: "z-menu", dialog: "z-dialog", popover: "z-popover" }),
|
|
16
|
+
ease: tok("ease"),
|
|
17
|
+
dur: group(null, { fast: "dur-fast", med: "dur-med" }),
|
|
18
|
+
fontSize: group(null, { sm: "font-size-sm", md: "font-size-md", lg: "font-size-lg" }),
|
|
19
|
+
font: tok("font"),
|
|
20
|
+
bg: tok("bg"),
|
|
21
|
+
fg: group("fg", { muted: "fg-muted", faint: "fg-faint", bright: "fg-bright", onFill: "fg-on-fill" }),
|
|
22
|
+
surface: group("surface", { elev: "surface-elev", overlay: "surface-overlay", sunken: "surface-sunken" }),
|
|
23
|
+
border: group("border", { strong: "border-strong", soft: "border-soft", faint: "border-faint" }),
|
|
24
|
+
hover: group("hover", { strong: "hover-strong" }),
|
|
25
|
+
active: tok("active"),
|
|
26
|
+
focus: group("focus", { soft: "focus-soft" }),
|
|
27
|
+
separatorHover: group(null, { band: "separator-hover-band", line: "separator-hover-line" }),
|
|
28
|
+
scroll: group("scroll", { size: "scroll-size" }),
|
|
29
|
+
accent: group("accent", { bright: "accent-bright" }),
|
|
30
|
+
highlight: tok("highlight"),
|
|
31
|
+
selected: group(null, { bg: "selected-bg", fg: "selected-fg" }),
|
|
32
|
+
up: tok("up"),
|
|
33
|
+
down: tok("down"),
|
|
34
|
+
profit: tok("profit"),
|
|
35
|
+
loss: tok("loss"),
|
|
36
|
+
danger: tok("danger"),
|
|
37
|
+
shadow: group("shadow", { dialog: "shadow-dialog" }),
|
|
38
|
+
backdrop: tok("backdrop")
|
|
39
|
+
};
|
|
40
|
+
function tokenNames() {
|
|
41
|
+
const names = [];
|
|
42
|
+
const walk = (v) => {
|
|
43
|
+
if (!v || typeof v !== "object") return;
|
|
44
|
+
const name = v.name;
|
|
45
|
+
if (typeof name === "string") names.push(name);
|
|
46
|
+
for (const [k, sub] of Object.entries(v)) if (k !== "name" && k !== "var") walk(sub);
|
|
47
|
+
};
|
|
48
|
+
walk(t);
|
|
49
|
+
return names;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { t, tokenNames };
|