@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,103 @@
|
|
|
1
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
2
|
+
import { PlacementProps } from './placement.js';
|
|
3
|
+
import { ChartTheme } from './tokens.js';
|
|
4
|
+
import { PopoverOptions } from './popover.js';
|
|
5
|
+
import { Translator } from './i18n.js';
|
|
6
|
+
import './t.js';
|
|
7
|
+
|
|
8
|
+
/** Split a color into its `#RRGGBB` part + alpha 0..1 (handles `#RGB`, `#RRGGBB(AA)`, `rgba()`). */
|
|
9
|
+
declare function splitColor(color: string): {
|
|
10
|
+
hex6: string;
|
|
11
|
+
alpha: number;
|
|
12
|
+
};
|
|
13
|
+
/** Combine a `#RRGGBB` + alpha into `#RRGGBB` (opaque) or `#RRGGBBAA`. */
|
|
14
|
+
declare function combineColor(hex6: string, alpha: number): string;
|
|
15
|
+
/** Composite `fg` over `bg` at `alpha`, returning an opaque `#rrggbb`. */
|
|
16
|
+
declare function blendOver(fg: string, bg: string, alpha: number): string;
|
|
17
|
+
/** HSL (h 0-360, s/l 0-100) → `#rrggbb`. */
|
|
18
|
+
declare function hslHex(hue: number, s: number, l: number): string;
|
|
19
|
+
/** A swatch palette: a grayscale row, then hue columns × shade rows. */
|
|
20
|
+
declare function buildPalette(): string[][];
|
|
21
|
+
/** The alpha checkerboard laid under translucent colors. Its grays are fixed on purpose:
|
|
22
|
+
* it stands for "nothing here", so it must not shift with the theme. */
|
|
23
|
+
declare function transparencyChecker(size: number): string;
|
|
24
|
+
type ColorFieldShape = 'square' | 'circle';
|
|
25
|
+
interface ColorPickerControllerOptions {
|
|
26
|
+
color?: string;
|
|
27
|
+
onChange?: (value: string) => void;
|
|
28
|
+
}
|
|
29
|
+
interface ColorPickerController {
|
|
30
|
+
hex6: string;
|
|
31
|
+
alpha: number;
|
|
32
|
+
combined(): string;
|
|
33
|
+
setHex(hex: string): void;
|
|
34
|
+
setAlpha(a: number): void;
|
|
35
|
+
}
|
|
36
|
+
/** The picked color as a hex part and an opacity, without DOM. */
|
|
37
|
+
declare function colorPickerController(opts?: ColorPickerControllerOptions): ColorPickerController;
|
|
38
|
+
declare const colorPickerDef: ComponentDef<"color-picker", "root" | "trigger" | "content" | "swatch", "swatch-ring" | "circle-swatch-radius" | "content-radius">;
|
|
39
|
+
/**
|
|
40
|
+
* When the opacity slider hands its value to `onChange` during a drag: `'live'` on every
|
|
41
|
+
* pointer move (the consumer repaints cheaply, so the chart previews the drag), `'release'`
|
|
42
|
+
* once on pointerup/pointercancel (the consumer recomputes — a script re-runs over its whole
|
|
43
|
+
* history, so a per-move commit would queue seconds of work behind the pointer). The knob,
|
|
44
|
+
* gradient and percentage follow the pointer either way; swatch picks always emit at once.
|
|
45
|
+
*/
|
|
46
|
+
type ColorCommit = 'live' | 'release';
|
|
47
|
+
interface ColorPickerOptions {
|
|
48
|
+
commit?: ColorCommit;
|
|
49
|
+
/** The translator of the picker's labels (default: the kit build's, else English). */
|
|
50
|
+
i18n?: Translator | null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A self-contained color picker: a swatch grid (grays + hue × shade), a
|
|
54
|
+
* recents row with a custom "+" picker, and an opacity slider over a transparency checker.
|
|
55
|
+
* Emits `#RRGGBB` / `#RRGGBBAA` through `onChange`.
|
|
56
|
+
*/
|
|
57
|
+
declare function buildColorPicker(color: string, theme: ChartTheme, onChange: (v: string) => void, options?: ColorPickerOptions): HTMLElement;
|
|
58
|
+
/** Where the picker opens beside the swatch (shadcn's placement props; default below and
|
|
59
|
+
* end-aligned, 6px away). */
|
|
60
|
+
interface ColorFieldOpts extends PlacementProps {
|
|
61
|
+
shape?: ColorFieldShape;
|
|
62
|
+
theme: ChartTheme;
|
|
63
|
+
getVal: () => string;
|
|
64
|
+
onVal: (v: string) => void;
|
|
65
|
+
id?: string;
|
|
66
|
+
/** The picker's host, layer and positioning strategy. `gap`, `align` and `boundary` here
|
|
67
|
+
* are deprecated: the field's placement props replace them. */
|
|
68
|
+
popover?: Pick<PopoverOptions, 'host' | 'position' | 'boundary' | 'zIndex' | 'gap' | 'align'>;
|
|
69
|
+
/** Opacity-drag commit policy of the popover picker (default `'live'`) — see {@link ColorCommit}. */
|
|
70
|
+
commit?: ColorCommit;
|
|
71
|
+
/** The translator of the picker's labels (default: the kit build's, else English). */
|
|
72
|
+
i18n?: Translator | null;
|
|
73
|
+
}
|
|
74
|
+
type ColorFieldProps = ColorFieldOpts;
|
|
75
|
+
/** Closed-state swatch shape. `circle` is the settings-dialog preview (a square chip
|
|
76
|
+
* inset from a matching field border); `square` is the compact drawing-chrome swatch. */
|
|
77
|
+
declare function colorField(theme: ChartTheme, getVal: () => string, onVal: (v: string) => void, opts?: {
|
|
78
|
+
shape?: ColorFieldShape;
|
|
79
|
+
id?: string;
|
|
80
|
+
popover?: ColorFieldOpts['popover'];
|
|
81
|
+
commit?: ColorCommit;
|
|
82
|
+
} & PlacementProps): HTMLElement;
|
|
83
|
+
declare class ColorField {
|
|
84
|
+
readonly el: HTMLButtonElement;
|
|
85
|
+
private readonly swatch;
|
|
86
|
+
private readonly getVal;
|
|
87
|
+
private readonly onVal;
|
|
88
|
+
private readonly theme;
|
|
89
|
+
private readonly popoverOpts;
|
|
90
|
+
private readonly placement;
|
|
91
|
+
private readonly commit;
|
|
92
|
+
private readonly i18n;
|
|
93
|
+
private readonly release;
|
|
94
|
+
constructor(opts: ColorFieldOpts);
|
|
95
|
+
destroy(): void;
|
|
96
|
+
private paint;
|
|
97
|
+
private toggle;
|
|
98
|
+
}
|
|
99
|
+
declare function createColorField(props: ColorFieldProps): ColorField;
|
|
100
|
+
/** Close any open color (or other kit) popover — dialog teardown. */
|
|
101
|
+
declare function closeColorPopover(): void;
|
|
102
|
+
|
|
103
|
+
export { type ColorCommit, ColorField, type ColorFieldOpts, type ColorFieldProps, type ColorFieldShape, type ColorPickerController, type ColorPickerControllerOptions, type ColorPickerOptions, blendOver, buildColorPicker, buildPalette, closeColorPopover, colorField, colorPickerController, colorPickerDef, combineColor, createColorField, hslHex, splitColor, transparencyChecker };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { ColorField, blendOver, buildColorPicker, buildPalette, closeColorPopover, colorField, colorPickerController, colorPickerDef, combineColor, createColorField, hslHex, splitColor, transparencyChecker } from './chunk-MJ4RUGX7.js';
|
|
2
|
+
import './chunk-FVH6L7FM.js';
|
|
3
|
+
import './chunk-FN2BUFNM.js';
|
|
4
|
+
import './chunk-B5ZSRUDQ.js';
|
|
5
|
+
import './chunk-J2QJATCD.js';
|
|
6
|
+
import './chunk-S7USVSYP.js';
|
|
7
|
+
import './chunk-V2Q4MRMS.js';
|
|
8
|
+
import './chunk-TAKSIV57.js';
|
|
9
|
+
import './chunk-MMTMOV6R.js';
|
|
10
|
+
import './chunk-3Q32K4PE.js';
|
|
11
|
+
import './chunk-A72NWYNP.js';
|
|
12
|
+
import './chunk-P4MTEMT7.js';
|
|
13
|
+
import './chunk-Q6WTDVH6.js';
|
|
14
|
+
import './chunk-VMCR3S2A.js';
|
|
15
|
+
import './chunk-XBEL4K33.js';
|
|
16
|
+
import './chunk-2GQIZM5Z.js';
|
|
17
|
+
import './chunk-BXMWQIBO.js';
|
|
18
|
+
import './chunk-X66RJAIS.js';
|
|
19
|
+
import './chunk-6QCILIT2.js';
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface Rgb {
|
|
2
|
+
r: number;
|
|
3
|
+
g: number;
|
|
4
|
+
b: number;
|
|
5
|
+
}
|
|
6
|
+
/** Parse `#RGB` / `#RRGGBB` / `#RRGGBBAA` / `rgb()` / `rgba()` into 0-255 channels. */
|
|
7
|
+
declare function parseRgb(color: string): Rgb | null;
|
|
8
|
+
/** Apply an alpha to any parseable color → an `rgba(...)` string. Unparseable input is
|
|
9
|
+
* returned unchanged so callers can pass through `transparent`, `currentColor`, etc. */
|
|
10
|
+
declare function withAlpha(color: string, alpha: number): string;
|
|
11
|
+
/** Flatten `top` at `alpha` over `base` into an OPAQUE color. Panels and menus float above
|
|
12
|
+
* the chart, so their surface must not let candles show through — a translucent wash is not
|
|
13
|
+
* interchangeable with the flattened result here. */
|
|
14
|
+
declare function mix(base: string, top: string, alpha: number): string;
|
|
15
|
+
/** `#rrggbb` for any parseable color; `fallback` when it cannot be parsed (native color
|
|
16
|
+
* inputs only accept six-digit hex). */
|
|
17
|
+
declare function toHex6(color: string, fallback?: string): string;
|
|
18
|
+
/** Perceived-dark check (relative luminance below mid-gray). Unparseable input counts as
|
|
19
|
+
* dark — the dark palette is Vela's default, so it is the safer assumption. */
|
|
20
|
+
declare function isDarkColor(color: string): boolean;
|
|
21
|
+
/** The WCAG contrast ratio of two colors, from 1 to 21; null when either cannot be parsed. */
|
|
22
|
+
declare function contrastRatio(a: string, b: string): number | null;
|
|
23
|
+
|
|
24
|
+
export { contrastRatio, isDarkColor, mix, parseRgb, toHex6, withAlpha };
|
package/dist/color.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { contrastRatio, isDarkColor, mix, parseRgb, toHex6, withAlpha } from './chunk-BXMWQIBO.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Translator } from './i18n.js';
|
|
2
|
+
import { CollisionBoundary } from './placement.js';
|
|
3
|
+
import { MenuItemDescriptor, DropdownMenuApi } from './dropdown-menu.js';
|
|
4
|
+
import './define-D5u3F5Dj.js';
|
|
5
|
+
import './t.js';
|
|
6
|
+
import '@zag-js/menu';
|
|
7
|
+
|
|
8
|
+
/** The rows, or a function of the opening event that returns them (null: no menu here). */
|
|
9
|
+
type ContextMenuItems = readonly MenuItemDescriptor[] | ((event: MouseEvent | PointerEvent) => readonly MenuItemDescriptor[] | null);
|
|
10
|
+
interface ContextMenuProps {
|
|
11
|
+
/** What a right-click, a long press or the context-menu key opens the menu on. */
|
|
12
|
+
target: HTMLElement;
|
|
13
|
+
/** The rows, or a function asked with the event at every opening (rows that depend on the
|
|
14
|
+
* spot: a list's row, a chart's zone). A function returning null or no rows opens nothing
|
|
15
|
+
* and leaves the event to the page. */
|
|
16
|
+
items: ContextMenuItems;
|
|
17
|
+
onSelect?: (id: string) => void;
|
|
18
|
+
onOpenChange?: (open: boolean) => void;
|
|
19
|
+
/** Where the list mounts (default: the target's kit host, found when the menu first opens). */
|
|
20
|
+
host?: HTMLElement;
|
|
21
|
+
/** Open on a long press on touch screens (default true). Turn it off where a long press
|
|
22
|
+
* already means something, like a chart's touch crosshair. */
|
|
23
|
+
longPress?: boolean;
|
|
24
|
+
/** Checked rows show a leading ✓ (default true), see the dropdown menu's `checkmarks`. */
|
|
25
|
+
checkmarks?: boolean;
|
|
26
|
+
/** See the dropdown menu's `iconBadges`. */
|
|
27
|
+
iconBadges?: boolean;
|
|
28
|
+
/** Override the list's min-width. */
|
|
29
|
+
minWidth?: string;
|
|
30
|
+
/** Star-toggle reports from rows carrying `favorite`. */
|
|
31
|
+
onFavorite?: (id: string, on: boolean) => void;
|
|
32
|
+
/** Room kept from the collision area's edges, in px. */
|
|
33
|
+
collisionPadding?: number;
|
|
34
|
+
/** The area the list stays inside (default: the viewport and the target's clipping containers). */
|
|
35
|
+
collisionBoundary?: CollisionBoundary;
|
|
36
|
+
/** The translator of the menu's own words (a star's name). Default: the kit build's, else English. */
|
|
37
|
+
i18n?: Translator | null;
|
|
38
|
+
}
|
|
39
|
+
declare class ContextMenu {
|
|
40
|
+
readonly target: HTMLElement;
|
|
41
|
+
private readonly props;
|
|
42
|
+
private readonly i18n;
|
|
43
|
+
private readonly longPress;
|
|
44
|
+
private items;
|
|
45
|
+
private menu;
|
|
46
|
+
private press;
|
|
47
|
+
/** A long press opened the menu: the click its release makes, and the native context menu
|
|
48
|
+
* some touch browsers send, are its own. */
|
|
49
|
+
private pressOpened;
|
|
50
|
+
private readonly release;
|
|
51
|
+
constructor(props: ContextMenuProps);
|
|
52
|
+
/** Zag's menu api (the list is built if it was not yet). */
|
|
53
|
+
get api(): DropdownMenuApi;
|
|
54
|
+
get open(): boolean;
|
|
55
|
+
/** Open at a viewport point. A function `items` is asked with `event`, else with a
|
|
56
|
+
* synthetic `contextmenu` at that point. Returns whether a menu opened. */
|
|
57
|
+
openAt(x: number, y: number, event?: MouseEvent | PointerEvent): boolean;
|
|
58
|
+
close(): void;
|
|
59
|
+
/** Replace the rows (or the function that gives them). An open menu shows rows at once. */
|
|
60
|
+
setItems(items: ContextMenuItems): void;
|
|
61
|
+
destroy(): void;
|
|
62
|
+
private ensureMenu;
|
|
63
|
+
private readonly onContextMenu;
|
|
64
|
+
private readonly onPointerDown;
|
|
65
|
+
private readonly onPointerMove;
|
|
66
|
+
private readonly cancelPress;
|
|
67
|
+
private readonly onClick;
|
|
68
|
+
private teardown;
|
|
69
|
+
}
|
|
70
|
+
declare function createContextMenu(props: ContextMenuProps): ContextMenu;
|
|
71
|
+
|
|
72
|
+
export { ContextMenu, type ContextMenuItems, type ContextMenuProps, createContextMenu };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { DropdownMenu } from './chunk-WGULXRWD.js';
|
|
2
|
+
import './chunk-G7IQLY3A.js';
|
|
3
|
+
import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
4
|
+
import './chunk-FN2BUFNM.js';
|
|
5
|
+
import './chunk-J2QJATCD.js';
|
|
6
|
+
import './chunk-S7USVSYP.js';
|
|
7
|
+
import './chunk-V2Q4MRMS.js';
|
|
8
|
+
import './chunk-TAKSIV57.js';
|
|
9
|
+
import './chunk-MMTMOV6R.js';
|
|
10
|
+
import './chunk-3Q32K4PE.js';
|
|
11
|
+
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
12
|
+
import './chunk-P4MTEMT7.js';
|
|
13
|
+
import './chunk-Q6WTDVH6.js';
|
|
14
|
+
import './chunk-VMCR3S2A.js';
|
|
15
|
+
import './chunk-XBEL4K33.js';
|
|
16
|
+
import './chunk-2GQIZM5Z.js';
|
|
17
|
+
import './chunk-BXMWQIBO.js';
|
|
18
|
+
import './chunk-X66RJAIS.js';
|
|
19
|
+
import './chunk-6QCILIT2.js';
|
|
20
|
+
|
|
21
|
+
// src/components/context-menu.ts
|
|
22
|
+
var LONG_PRESS_MS = 500;
|
|
23
|
+
var PRESS_SLOP_PX = 10;
|
|
24
|
+
var ContextMenu = class {
|
|
25
|
+
constructor(props) {
|
|
26
|
+
this.menu = null;
|
|
27
|
+
this.press = null;
|
|
28
|
+
/** A long press opened the menu: the click its release makes, and the native context menu
|
|
29
|
+
* some touch browsers send, are its own. */
|
|
30
|
+
this.pressOpened = false;
|
|
31
|
+
this.onContextMenu = (e) => {
|
|
32
|
+
if (e.defaultPrevented) return;
|
|
33
|
+
if (this.pressOpened) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const pressing = this.press !== null;
|
|
38
|
+
this.cancelPress();
|
|
39
|
+
let x = e.clientX;
|
|
40
|
+
let y = e.clientY;
|
|
41
|
+
const focused = e.target;
|
|
42
|
+
if (x === 0 && y === 0 && focused && typeof focused.getBoundingClientRect === "function") {
|
|
43
|
+
const r = focused.getBoundingClientRect();
|
|
44
|
+
x = r.left;
|
|
45
|
+
y = r.bottom;
|
|
46
|
+
}
|
|
47
|
+
if (!this.openAt(x, y, e)) return;
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
if (pressing) this.pressOpened = true;
|
|
50
|
+
};
|
|
51
|
+
this.onPointerDown = (e) => {
|
|
52
|
+
this.pressOpened = false;
|
|
53
|
+
if (e.pointerType === "mouse" || !e.isPrimary) return;
|
|
54
|
+
this.cancelPress();
|
|
55
|
+
const timer = setTimeout(() => {
|
|
56
|
+
const press = this.press;
|
|
57
|
+
this.press = null;
|
|
58
|
+
if (press && this.openAt(press.x, press.y, press.event)) this.pressOpened = true;
|
|
59
|
+
}, LONG_PRESS_MS);
|
|
60
|
+
this.press = { x: e.clientX, y: e.clientY, pointer: e.pointerId, event: e, timer };
|
|
61
|
+
};
|
|
62
|
+
this.onPointerMove = (e) => {
|
|
63
|
+
const press = this.press;
|
|
64
|
+
if (press && e.pointerId === press.pointer && Math.hypot(e.clientX - press.x, e.clientY - press.y) > PRESS_SLOP_PX) this.cancelPress();
|
|
65
|
+
};
|
|
66
|
+
this.cancelPress = () => {
|
|
67
|
+
if (this.press) clearTimeout(this.press.timer);
|
|
68
|
+
this.press = null;
|
|
69
|
+
};
|
|
70
|
+
this.onClick = (e) => {
|
|
71
|
+
if (!this.pressOpened) return;
|
|
72
|
+
this.pressOpened = false;
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
};
|
|
76
|
+
this.props = props;
|
|
77
|
+
this.target = props.target;
|
|
78
|
+
this.items = props.items;
|
|
79
|
+
this.i18n = props.i18n ?? kitTranslator();
|
|
80
|
+
this.longPress = props.longPress !== false;
|
|
81
|
+
const target = this.target;
|
|
82
|
+
target.addEventListener("contextmenu", this.onContextMenu);
|
|
83
|
+
if (this.longPress) {
|
|
84
|
+
target.addEventListener("pointerdown", this.onPointerDown);
|
|
85
|
+
target.addEventListener("pointermove", this.onPointerMove);
|
|
86
|
+
target.addEventListener("pointerup", this.cancelPress);
|
|
87
|
+
target.addEventListener("pointercancel", this.cancelPress);
|
|
88
|
+
target.addEventListener("click", this.onClick, true);
|
|
89
|
+
target.style.setProperty("-webkit-touch-callout", "none");
|
|
90
|
+
}
|
|
91
|
+
this.release = ownTeardown(target, () => this.teardown());
|
|
92
|
+
}
|
|
93
|
+
/** Zag's menu api (the list is built if it was not yet). */
|
|
94
|
+
get api() {
|
|
95
|
+
return this.ensureMenu().api;
|
|
96
|
+
}
|
|
97
|
+
get open() {
|
|
98
|
+
return this.menu?.api.open ?? false;
|
|
99
|
+
}
|
|
100
|
+
/** Open at a viewport point. A function `items` is asked with `event`, else with a
|
|
101
|
+
* synthetic `contextmenu` at that point. Returns whether a menu opened. */
|
|
102
|
+
openAt(x, y, event) {
|
|
103
|
+
const items = typeof this.items === "function" ? this.items(event ?? new MouseEvent("contextmenu", { clientX: x, clientY: y })) : this.items;
|
|
104
|
+
if (!items || items.length === 0) return false;
|
|
105
|
+
const menu = this.ensureMenu();
|
|
106
|
+
menu.setItems(items);
|
|
107
|
+
menu.openAt(x, y);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
close() {
|
|
111
|
+
this.menu?.close();
|
|
112
|
+
}
|
|
113
|
+
/** Replace the rows (or the function that gives them). An open menu shows rows at once. */
|
|
114
|
+
setItems(items) {
|
|
115
|
+
this.items = items;
|
|
116
|
+
if (this.menu && this.open && typeof items !== "function") this.menu.setItems(items);
|
|
117
|
+
}
|
|
118
|
+
destroy() {
|
|
119
|
+
this.release();
|
|
120
|
+
}
|
|
121
|
+
ensureMenu() {
|
|
122
|
+
if (this.menu) return this.menu;
|
|
123
|
+
const p = this.props;
|
|
124
|
+
this.menu = new DropdownMenu({
|
|
125
|
+
host: p.host ?? this.target,
|
|
126
|
+
items: [],
|
|
127
|
+
side: "bottom",
|
|
128
|
+
align: "start",
|
|
129
|
+
checkmarks: p.checkmarks ?? true,
|
|
130
|
+
i18n: this.i18n,
|
|
131
|
+
onSelect: (id) => p.onSelect?.(id),
|
|
132
|
+
...p.onOpenChange ? { onOpenChange: p.onOpenChange } : {},
|
|
133
|
+
...p.iconBadges !== void 0 ? { iconBadges: p.iconBadges } : {},
|
|
134
|
+
...p.minWidth !== void 0 ? { minWidth: p.minWidth } : {},
|
|
135
|
+
...p.onFavorite ? { onFavorite: p.onFavorite } : {},
|
|
136
|
+
...p.collisionPadding !== void 0 ? { collisionPadding: p.collisionPadding } : {},
|
|
137
|
+
...p.collisionBoundary !== void 0 ? { collisionBoundary: p.collisionBoundary } : {}
|
|
138
|
+
});
|
|
139
|
+
return this.menu;
|
|
140
|
+
}
|
|
141
|
+
teardown() {
|
|
142
|
+
this.cancelPress();
|
|
143
|
+
const target = this.target;
|
|
144
|
+
target.removeEventListener("contextmenu", this.onContextMenu);
|
|
145
|
+
if (this.longPress) {
|
|
146
|
+
target.removeEventListener("pointerdown", this.onPointerDown);
|
|
147
|
+
target.removeEventListener("pointermove", this.onPointerMove);
|
|
148
|
+
target.removeEventListener("pointerup", this.cancelPress);
|
|
149
|
+
target.removeEventListener("pointercancel", this.cancelPress);
|
|
150
|
+
target.removeEventListener("click", this.onClick, true);
|
|
151
|
+
target.style.removeProperty("-webkit-touch-callout");
|
|
152
|
+
}
|
|
153
|
+
this.menu?.destroy();
|
|
154
|
+
this.menu = null;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
function createContextMenu(props) {
|
|
158
|
+
return new ContextMenu(props);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export { ContextMenu, createContextMenu };
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { LAYER_ORDER, injectLayerOrder } from './styles.js';
|
|
2
|
+
import './color.js';
|
|
3
|
+
|
|
4
|
+
/** Joins a template into its CSS text. Interpolations are tokens (`t.*`) and component
|
|
5
|
+
* settings, which print as `var(--vela-…)`. */
|
|
6
|
+
declare function css(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
7
|
+
/** Whether a CSS text was written with the {@link css} tag, or accepted as if it were. */
|
|
8
|
+
declare function isWrittenCss(text: string): boolean;
|
|
9
|
+
/** Accept a CSS text from data as if code wrote it (a host's explicit `allowCss`). */
|
|
10
|
+
declare function acceptCss(text: string): void;
|
|
11
|
+
/** A component's stylesheet: call the result with the root it renders in, at creation, never
|
|
12
|
+
* at import (a component nobody creates injects nothing). Its rules apply inside kit hosts,
|
|
13
|
+
* their floating layers and themed hosts only: the page's own elements may carry the same
|
|
14
|
+
* part names. */
|
|
15
|
+
declare function defineStyles(id: string, text: string): (root?: Document | ShadowRoot) => void;
|
|
16
|
+
|
|
17
|
+
export { acceptCss, css, defineStyles, isWrittenCss };
|
package/dist/css.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { C as Child } from './h-Bl37qUis.js';
|
|
2
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
declare const dataTableDef: ComponentDef<"data-table", "root" | "head" | "table" | "sort" | "actions" | "row" | "cell" | "empty", "row-height" | "head-height" | "head-z">;
|
|
6
|
+
interface DataTableColumn<T> {
|
|
7
|
+
id: string;
|
|
8
|
+
header: string;
|
|
9
|
+
/** What the header stands for, on hover (`MFE`: maximum favorable excursion). */
|
|
10
|
+
title?: string;
|
|
11
|
+
align?: 'start' | 'end' | 'center';
|
|
12
|
+
width?: string;
|
|
13
|
+
/** The cell's content; a string or a number renders as text. */
|
|
14
|
+
cell(row: T): Child;
|
|
15
|
+
/** The value the column sorts by; without it the column does not sort. */
|
|
16
|
+
sort?(row: T): number | string;
|
|
17
|
+
tone?(row: T): 'profit' | 'loss' | 'muted' | null;
|
|
18
|
+
}
|
|
19
|
+
interface DataTableProps<T> {
|
|
20
|
+
columns: readonly DataTableColumn<T>[];
|
|
21
|
+
rowKey(row: T): string;
|
|
22
|
+
onRowClick?(row: T, e: MouseEvent): void;
|
|
23
|
+
/** What shows when there are no rows. */
|
|
24
|
+
empty?: () => HTMLElement;
|
|
25
|
+
/** The initial sort. */
|
|
26
|
+
sort?: {
|
|
27
|
+
column: string;
|
|
28
|
+
dir: 'asc' | 'desc';
|
|
29
|
+
};
|
|
30
|
+
/** Extra class names (layout hooks). */
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
interface DataTableHandle<T> {
|
|
34
|
+
readonly el: HTMLElement;
|
|
35
|
+
setRows(rows: readonly T[]): void;
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
declare function createDataTable<T>(props: DataTableProps<T>): DataTableHandle<T>;
|
|
39
|
+
|
|
40
|
+
export { type DataTableColumn, type DataTableHandle, type DataTableProps, createDataTable, dataTableDef };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { h, append } from './chunk-Q6WTDVH6.js';
|
|
2
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
3
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
4
|
+
import './chunk-2GQIZM5Z.js';
|
|
5
|
+
import './chunk-BXMWQIBO.js';
|
|
6
|
+
import './chunk-X66RJAIS.js';
|
|
7
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
8
|
+
|
|
9
|
+
// src/components/data-table.ts
|
|
10
|
+
var dataTableDef = defineComponent({
|
|
11
|
+
name: "data-table",
|
|
12
|
+
parts: ["root", "table", "head", "sort", "row", "cell", "actions", "empty"],
|
|
13
|
+
settings: { "row-height": "28px", "head-height": "28px", "head-z": "1" }
|
|
14
|
+
});
|
|
15
|
+
var injectStyles = defineStyles(
|
|
16
|
+
"vela-ui-data-table",
|
|
17
|
+
css`@layer vela.ui{[data-slot=data-table]{height:100%;min-height:0;overflow:auto}[data-slot=data-table-table]{border-collapse:separate;border-spacing:0;width:100%;font-size:12px}[data-slot=data-table-head]{z-index:${dataTableDef.vars["head-z"]};height:${dataTableDef.vars["head-height"]};text-align:start;color:${t.fg.muted};background:${t.surface};border-bottom:1px solid ${t.border.faint};white-space:nowrap;-webkit-user-select:none;user-select:none;padding:0 10px;font-size:11px;font-weight:500;position:sticky;top:0}[data-slot=data-table-head][data-sortable]{cursor:pointer}[data-slot=data-table-head][data-sortable]:hover{color:${t.fg}}[data-slot=data-table-sort]{opacity:.8;margin-inline-start:4px;font-size:9px;display:inline-block}[data-slot=data-table-row]{transition:background ${t.dur.fast} ease}[data-slot=data-table-row]:hover{background:${t.hover}}[data-slot=data-table-row][data-clickable]{cursor:pointer}[data-slot=data-table-cell]{height:${dataTableDef.vars["row-height"]};border-bottom:1px solid ${t.border.faint};white-space:nowrap;color:${t.fg};padding:0 10px}[data-slot=data-table-cell][data-tone=profit]{color:${t.profit}}[data-slot=data-table-cell][data-tone=loss]{color:${t.loss}}[data-slot=data-table-cell][data-tone=muted]{color:${t.fg.muted}}:is([data-slot~=data-table-head],[data-slot~=data-table-cell])[data-align=end]{text-align:end;font-variant-numeric:tabular-nums}:is([data-slot~=data-table-head],[data-slot~=data-table-cell])[data-align=center]{text-align:center}[data-slot=data-table-actions]{opacity:0;transition:opacity ${t.dur.fast} ease;gap:2px}[data-slot=data-table-actions]:where(:not([hidden])){display:inline-flex}[data-slot=data-table-actions]:focus-within,[data-slot=data-table-actions]:is([data-slot=data-table-row]:hover *){opacity:1}}`
|
|
18
|
+
);
|
|
19
|
+
function createDataTable(props) {
|
|
20
|
+
injectStyles(document);
|
|
21
|
+
let rows = [];
|
|
22
|
+
let sort = props.sort ?? null;
|
|
23
|
+
const table = h("table", { slot: dataTableDef.slot("table") });
|
|
24
|
+
const thead = table.createTHead();
|
|
25
|
+
const tbody = h("tbody");
|
|
26
|
+
const emptyHost = h("div", { slot: dataTableDef.slot("empty") });
|
|
27
|
+
const el = h("div", { className: props.className, slot: dataTableDef.slot("root") }, table, emptyHost);
|
|
28
|
+
table.appendChild(tbody);
|
|
29
|
+
const renderHead = () => {
|
|
30
|
+
const tr = h("tr");
|
|
31
|
+
for (const col of props.columns) {
|
|
32
|
+
const th = h("th", {
|
|
33
|
+
slot: dataTableDef.slot("head"),
|
|
34
|
+
data: { align: col.align ?? null, sortable: !!col.sort, col: col.id },
|
|
35
|
+
attrs: { title: col.title ?? null, scope: "col", "aria-sort": sort?.column === col.id ? sort.dir === "asc" ? "ascending" : "descending" : null },
|
|
36
|
+
text: col.header
|
|
37
|
+
});
|
|
38
|
+
if (col.width) th.style.width = col.width;
|
|
39
|
+
if (col.sort) {
|
|
40
|
+
if (sort?.column === col.id) th.appendChild(h("span", { slot: dataTableDef.slot("sort"), attrs: { "aria-hidden": "true" }, text: sort.dir === "asc" ? "\u25B2" : "\u25BC" }));
|
|
41
|
+
th.addEventListener("click", () => {
|
|
42
|
+
sort = { column: col.id, dir: sort?.column === col.id && sort.dir === "desc" ? "asc" : "desc" };
|
|
43
|
+
renderHead();
|
|
44
|
+
renderBody();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
tr.appendChild(th);
|
|
48
|
+
}
|
|
49
|
+
thead.replaceChildren(tr);
|
|
50
|
+
};
|
|
51
|
+
const renderBody = () => {
|
|
52
|
+
let shown = rows;
|
|
53
|
+
const col = sort ? props.columns.find((c) => c.id === sort.column) : void 0;
|
|
54
|
+
if (sort && col?.sort) {
|
|
55
|
+
const dir = sort.dir === "asc" ? 1 : -1;
|
|
56
|
+
shown = [...rows].sort((a, b) => {
|
|
57
|
+
const va = col.sort(a);
|
|
58
|
+
const vb = col.sort(b);
|
|
59
|
+
return dir * (typeof va === "number" && typeof vb === "number" ? va - vb : String(va).localeCompare(String(vb)));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const frag = document.createDocumentFragment();
|
|
63
|
+
for (const row of shown) {
|
|
64
|
+
const tr = h("tr", { slot: dataTableDef.slot("row"), data: { key: props.rowKey(row), clickable: !!props.onRowClick } });
|
|
65
|
+
if (props.onRowClick) tr.addEventListener("click", (e) => props.onRowClick(row, e));
|
|
66
|
+
for (const c of props.columns) {
|
|
67
|
+
const td = h("td", { slot: dataTableDef.slot("cell"), data: { align: c.align ?? null, tone: c.tone?.(row) ?? null, col: c.id } });
|
|
68
|
+
append(td, [c.cell(row)]);
|
|
69
|
+
tr.appendChild(td);
|
|
70
|
+
}
|
|
71
|
+
frag.appendChild(tr);
|
|
72
|
+
}
|
|
73
|
+
tbody.replaceChildren(frag);
|
|
74
|
+
const empty = shown.length === 0 && props.empty ? props.empty() : null;
|
|
75
|
+
emptyHost.replaceChildren(...empty ? [empty] : []);
|
|
76
|
+
};
|
|
77
|
+
renderHead();
|
|
78
|
+
return {
|
|
79
|
+
el,
|
|
80
|
+
setRows(next) {
|
|
81
|
+
rows = next;
|
|
82
|
+
renderBody();
|
|
83
|
+
},
|
|
84
|
+
destroy: () => el.remove()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { createDataTable, dataTableDef };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
2
|
+
import { Translator } from './i18n.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
type DatePickerPanel = 'date' | 'month' | 'year';
|
|
6
|
+
interface DatePickerControllerOptions {
|
|
7
|
+
/** The selected date (`YYYY-MM-DD`); the calendar opens on its month. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** "Today" for the today ring and the initial month when nothing is selected. */
|
|
10
|
+
today?: Date;
|
|
11
|
+
/** The translator whose locale names the months and weekdays, picks the first day of
|
|
12
|
+
* the week and the digits: `chart.i18n` inside a chart, `createTranslator(...)`
|
|
13
|
+
* elsewhere. Default: English, weeks starting on Sunday. */
|
|
14
|
+
i18n?: Translator;
|
|
15
|
+
}
|
|
16
|
+
/** One cell of the current panel. `blank` cells pad the first week of a month. */
|
|
17
|
+
interface DatePickerCell {
|
|
18
|
+
label: string;
|
|
19
|
+
/** The day (`YYYY-MM-DD`) on the date panel; the month index or the year otherwise. */
|
|
20
|
+
value: string | number;
|
|
21
|
+
checked: boolean;
|
|
22
|
+
today: boolean;
|
|
23
|
+
/** A padding year outside the decade on the year panel. */
|
|
24
|
+
outside?: boolean;
|
|
25
|
+
blank?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface DatePickerController {
|
|
28
|
+
readonly panel: DatePickerPanel;
|
|
29
|
+
readonly year: number;
|
|
30
|
+
readonly month: number;
|
|
31
|
+
readonly value: string | null;
|
|
32
|
+
/** Whether the locale writes the year before the month (the header's switch order). */
|
|
33
|
+
readonly yearFirst: boolean;
|
|
34
|
+
/** The weekday column labels, starting on the locale's first day of the week. */
|
|
35
|
+
weekdays(): string[];
|
|
36
|
+
/** Header text: the month switch (hidden off the date panel) and the year switch. */
|
|
37
|
+
header(): {
|
|
38
|
+
month: string;
|
|
39
|
+
monthVisible: boolean;
|
|
40
|
+
year: string;
|
|
41
|
+
yearDisabled: boolean;
|
|
42
|
+
};
|
|
43
|
+
/** What the arrows step on the current panel. */
|
|
44
|
+
navLabels(): {
|
|
45
|
+
prev: string;
|
|
46
|
+
next: string;
|
|
47
|
+
};
|
|
48
|
+
cells(): DatePickerCell[];
|
|
49
|
+
/** One month, one year or ten, depending on the panel. */
|
|
50
|
+
step(dir: 1 | -1): void;
|
|
51
|
+
showMonths(): void;
|
|
52
|
+
showYears(): void;
|
|
53
|
+
/** Activate a cell: a day returns its date (the pick); a month or year only navigates. */
|
|
54
|
+
choose(cell: DatePickerCell): string | null;
|
|
55
|
+
/** Rewrite the selection without emitting (and open on its month). */
|
|
56
|
+
setValue(value: string | null): void;
|
|
57
|
+
}
|
|
58
|
+
/** `YYYY-MM-DD` for a local date. */
|
|
59
|
+
declare function isoDate(d: Date): string;
|
|
60
|
+
/** Accept `YYYY-MM-DD` or `YYYY-M-D` and return a padded ISO date, or null if unusable. */
|
|
61
|
+
declare function normalizeDateInput(raw: string): string | null;
|
|
62
|
+
/** The calendar's panels, navigation and selection, without DOM. */
|
|
63
|
+
declare function datePickerController(opts?: DatePickerControllerOptions): DatePickerController;
|
|
64
|
+
declare const datePickerDef: ComponentDef<"date-picker", "root" | "head" | "nav" | "title" | "switch" | "grid" | "cell" | "day" | "week" | "cells" | "blank", "radius" | "today-ring">;
|
|
65
|
+
interface DatePickerOptions extends DatePickerControllerOptions {
|
|
66
|
+
/** A day was picked (`YYYY-MM-DD`). */
|
|
67
|
+
onPick?: (value: string) => void;
|
|
68
|
+
}
|
|
69
|
+
type DatePickerProps = DatePickerOptions;
|
|
70
|
+
declare class DatePicker {
|
|
71
|
+
private readonly opts;
|
|
72
|
+
readonly el: HTMLDivElement;
|
|
73
|
+
private readonly ctrl;
|
|
74
|
+
private readonly prev;
|
|
75
|
+
private readonly next;
|
|
76
|
+
private readonly monthBtn;
|
|
77
|
+
private readonly yearBtn;
|
|
78
|
+
private readonly week;
|
|
79
|
+
private readonly grid;
|
|
80
|
+
constructor(opts?: DatePickerOptions);
|
|
81
|
+
get value(): string | null;
|
|
82
|
+
/** Rewrite the selection without emitting (the calendar opens on its month). */
|
|
83
|
+
setValue(value: string | null): void;
|
|
84
|
+
destroy(): void;
|
|
85
|
+
private paint;
|
|
86
|
+
private cellEl;
|
|
87
|
+
}
|
|
88
|
+
declare function createDatePicker(props?: DatePickerProps): DatePicker;
|
|
89
|
+
|
|
90
|
+
export { DatePicker, type DatePickerCell, type DatePickerController, type DatePickerControllerOptions, type DatePickerOptions, type DatePickerPanel, type DatePickerProps, createDatePicker, datePickerController, datePickerDef, isoDate, normalizeDateInput };
|