@luxalgo/vela-ui 0.1.0 → 0.3.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 +89 -0
- package/README.md +5 -2
- package/dist/badge.js +1 -1
- package/dist/bar-chart.js +1 -1
- package/dist/button.d.ts +18 -4
- package/dist/button.js +4 -3
- package/dist/calendar.d.ts +3 -1
- package/dist/calendar.js +1 -1
- package/dist/callout-bubble.d.ts +6 -1
- package/dist/callout-bubble.js +12 -8
- package/dist/card.d.ts +52 -0
- package/dist/card.js +179 -0
- package/dist/checkbox.js +5 -5
- package/dist/{chunk-X4YPSIW6.js → chunk-5BJV5FY5.js} +1 -1
- package/dist/{chunk-FCO3YZLT.js → chunk-ALAHGSLC.js} +1 -1
- package/dist/{chunk-5QHXOAZA.js → chunk-B2EZB5ZG.js} +4 -4
- package/dist/{chunk-G7IQLY3A.js → chunk-C3PXY2SW.js} +5 -0
- package/dist/chunk-DXDCKZ2M.js +117 -0
- package/dist/{chunk-6NXY62JS.js → chunk-FYVQO5TN.js} +1 -1
- package/dist/{chunk-V6TTTMTE.js → chunk-GVRX3UAV.js} +4 -1
- package/dist/{chunk-XJAPCCOJ.js → chunk-IOOYDSSK.js} +4 -4
- package/dist/{chunk-OBLIX3VN.js → chunk-KKS6NEGI.js} +2 -2
- package/dist/{chunk-SAPURP46.js → chunk-OJ2SEMN6.js} +3 -3
- package/dist/{chunk-2Q4JRINP.js → chunk-OQXFQMZM.js} +3 -3
- package/dist/{chunk-AJ2IYSOI.js → chunk-TBXUF5YX.js} +35 -3
- package/dist/{chunk-ZB3BZHSN.js → chunk-UEO6W37Z.js} +4 -4
- package/dist/{chunk-CH3DV6FD.js → chunk-WWHNUKSZ.js} +5 -5
- package/dist/chunk-XBEL4K33.js +142 -0
- package/dist/collapsible.d.ts +49 -0
- package/dist/collapsible.js +106 -0
- package/dist/color-picker.js +5 -5
- package/dist/context-menu.js +5 -5
- package/dist/css.d.ts +3 -1
- package/dist/css.js +1 -1
- package/dist/data-table.d.ts +39 -2
- package/dist/data-table.js +1 -1
- package/dist/date-picker.js +3 -3
- package/dist/dialog.d.ts +8 -0
- package/dist/dialog.js +15 -5
- package/dist/donut.js +1 -1
- package/dist/drawer.js +2 -2
- package/dist/dropdown-menu.js +4 -4
- package/dist/empty.js +2 -2
- package/dist/field.js +13 -13
- package/dist/glyph-select.js +5 -5
- package/dist/h-Bl37qUis.d.ts +24 -0
- package/dist/hover-card.d.ts +1 -1
- package/dist/hover-card.js +3 -3
- package/dist/icons.js +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.js +3 -3
- package/dist/input-group.js +4 -3
- package/dist/input.js +2 -2
- package/dist/item.d.ts +72 -0
- package/dist/item.js +131 -0
- package/dist/kbd.js +2 -2
- package/dist/line-chart.js +1 -1
- package/dist/manifest.json +1336 -65
- package/dist/month-grid.d.ts +45 -0
- package/dist/month-grid.js +157 -0
- package/dist/number-input.js +5 -5
- package/dist/popover.js +3 -3
- package/dist/scatter-chart.js +1 -1
- package/dist/select.js +7 -7
- 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.js +1 -1
- package/dist/stat.js +1 -1
- package/dist/switch.js +3 -3
- package/dist/tabs.d.ts +3 -1
- package/dist/tabs.js +13 -8
- package/dist/text-area.js +2 -2
- package/dist/theme-Ct-q58xz.d.ts +341 -0
- package/dist/theme.d.ts +42 -181
- package/dist/theme.js +2 -2
- package/dist/theme.schema.json +541 -1
- package/dist/toast.d.ts +49 -0
- package/dist/toast.js +463 -0
- package/dist/toggle-group.js +4 -4
- package/dist/tooltip.js +2 -2
- package/dist/treemap.d.ts +80 -0
- package/dist/treemap.js +470 -0
- package/docs/theming.md +6 -0
- package/docs/writing-a-component.md +4 -1
- package/llms.txt +11 -3
- package/package.json +1 -1
- package/registry/button.ts +105 -21
- package/registry/callout-bubble.ts +14 -3
- package/registry/card.ts +379 -0
- package/registry/collapsible.ts +271 -0
- package/registry/dialog.ts +16 -0
- package/registry/dropdown-menu.ts +3 -3
- package/registry/item.ts +376 -0
- package/registry/month-grid.ts +328 -0
- package/registry/slider.ts +259 -0
- package/registry/sort-button.ts +189 -0
- package/registry/tabs.ts +38 -4
- package/registry/toast.ts +965 -0
- package/registry/treemap.ts +847 -0
- package/skills/using-vela-ui-components/SKILL.md +14 -9
- package/src/components/button.ts +105 -21
- package/src/components/callout-bubble.ts +14 -3
- package/src/components/card.ts +379 -0
- package/src/components/collapsible.ts +271 -0
- package/src/components/dialog.ts +16 -0
- package/src/components/dropdown-menu.ts +3 -3
- package/src/components/item.ts +376 -0
- package/src/components/month-grid.ts +328 -0
- package/src/components/slider.ts +259 -0
- package/src/components/sort-button.ts +189 -0
- package/src/components/tabs.ts +38 -4
- package/src/components/toast.ts +965 -0
- package/src/components/treemap.ts +847 -0
- package/src/lib/calendar.ts +5 -0
- package/src/lib/component-index.ts +34 -2
- package/src/lib/css.ts +6 -2
- package/src/lib/icons.ts +7 -0
- package/src/lib/scope.ts +135 -0
- package/src/lib/theme.ts +21 -5
- package/dist/chunk-EZQXTO6K.js +0 -89
- package/dist/chunk-IDA2BT7D.js +0 -29
- package/dist/data-table-DtU3FX9j.d.ts +0 -61
package/dist/treemap.js
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
2
|
+
import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
3
|
+
import { showTip } from './chunk-A2FJ7Y7D.js';
|
|
4
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
6
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
7
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
8
|
+
import './chunk-2GQIZM5Z.js';
|
|
9
|
+
import './chunk-BXMWQIBO.js';
|
|
10
|
+
import './chunk-X66RJAIS.js';
|
|
11
|
+
|
|
12
|
+
// src/components/treemap.ts
|
|
13
|
+
var treemapDef = defineComponent({
|
|
14
|
+
name: "treemap",
|
|
15
|
+
parts: ["root", "crumbs", "crumb", "map", "group", "group-name", "group-value", "tile", "tile-label", "tile-value", "legend", "legend-bar", "tip"],
|
|
16
|
+
settings: {
|
|
17
|
+
radius: t.radius.sm,
|
|
18
|
+
up: t.up,
|
|
19
|
+
down: t.down,
|
|
20
|
+
"tile-bg": `color-mix(in srgb, ${t.fg.bright} 2.5%, ${t.surface})`,
|
|
21
|
+
"tint-min": "3%",
|
|
22
|
+
"tint-max": "25%",
|
|
23
|
+
"hover-z": "1",
|
|
24
|
+
"tip-radius": t.radius.md,
|
|
25
|
+
"tip-bg": t.surface.elev,
|
|
26
|
+
"tip-shadow": t.shadow,
|
|
27
|
+
"tip-z": "2"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
function squarify(items, bounds) {
|
|
31
|
+
const total = items.reduce((s, item) => s + Math.max(0, item.weight), 0);
|
|
32
|
+
if (!total || bounds.w <= 0 || bounds.h <= 0) return [];
|
|
33
|
+
const scale = bounds.w * bounds.h / total;
|
|
34
|
+
let queue = items.filter((item) => item.weight > 0).map((item) => ({ item, area: item.weight * scale })).sort((a, b) => b.area - a.area);
|
|
35
|
+
let { x, y, w, h: h2 } = bounds;
|
|
36
|
+
const out = [];
|
|
37
|
+
const worst = (row, side) => {
|
|
38
|
+
const sum = row.reduce((s, r) => s + r.area, 0);
|
|
39
|
+
const max = Math.max(...row.map((r) => r.area));
|
|
40
|
+
const min = Math.min(...row.map((r) => r.area));
|
|
41
|
+
return Math.max(side * side * max / (sum * sum), sum * sum / (side * side * min));
|
|
42
|
+
};
|
|
43
|
+
while (queue.length) {
|
|
44
|
+
const side = Math.min(w, h2);
|
|
45
|
+
const row = [queue[0]];
|
|
46
|
+
let i = 1;
|
|
47
|
+
while (i < queue.length && worst([...row, queue[i]], side) <= worst(row, side)) row.push(queue[i++]);
|
|
48
|
+
queue = queue.slice(i);
|
|
49
|
+
const sum = row.reduce((s, r) => s + r.area, 0);
|
|
50
|
+
if (w >= h2) {
|
|
51
|
+
const cw = sum / h2;
|
|
52
|
+
let cy = y;
|
|
53
|
+
for (const r of row) {
|
|
54
|
+
const ch = r.area / cw;
|
|
55
|
+
out.push({ ...r.item, x, y: cy, w: cw, h: ch });
|
|
56
|
+
cy += ch;
|
|
57
|
+
}
|
|
58
|
+
x += cw;
|
|
59
|
+
w -= cw;
|
|
60
|
+
} else {
|
|
61
|
+
const rh = sum / w;
|
|
62
|
+
let cx = x;
|
|
63
|
+
for (const r of row) {
|
|
64
|
+
const rw = r.area / rh;
|
|
65
|
+
out.push({ ...r.item, x: cx, y, w: rw, h: rh });
|
|
66
|
+
cx += rw;
|
|
67
|
+
}
|
|
68
|
+
y += rh;
|
|
69
|
+
h2 -= rh;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
var TEXT = {
|
|
75
|
+
all: msg("ui.treemap.all", "All"),
|
|
76
|
+
zoomIn: msg("ui.treemap.zoomIn", "Zoom in")
|
|
77
|
+
};
|
|
78
|
+
var HEADER = 16;
|
|
79
|
+
var HEADED = { w: 80, h: 64 };
|
|
80
|
+
var injectStyles = defineStyles(
|
|
81
|
+
"vela-ui-treemap",
|
|
82
|
+
css`@layer vela.ui{[data-slot=treemap]{width:100%;height:100%;min-height:0;color:${t.fg};font-size:${t.fontSize.sm};position:relative}[data-slot=treemap]:where(:not([hidden])){flex-direction:column;gap:8px;display:flex}[data-slot=treemap-crumbs]{min-height:22px;color:${t.fg.muted};flex-wrap:wrap;align-items:center;gap:2px;font-size:12px;display:flex}[data-slot=treemap-crumb]{all:unset;border-radius:${treemapDef.vars.radius};cursor:pointer;padding:2px 6px}[data-slot=treemap-crumb]:hover{background:${t.hover};color:${t.fg.bright}}[data-slot=treemap-crumb]:focus-visible{outline:2px solid ${t.focus}}[data-slot=treemap-crumb][aria-current]{cursor:default;color:${t.fg.bright};background:0 0;font-weight:600}[data-slot=treemap-crumb]:not(:first-child):before{content:"›";color:${t.fg.faint};margin-inline-end:8px}[data-slot=treemap-map]{isolation:isolate;flex:auto;min-height:0;position:relative}[data-slot=treemap-group]{all:unset;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap;height:16px;color:${t.fg.muted};transition:left ${t.dur.med} ${t.ease}, top ${t.dur.med} ${t.ease}, width ${t.dur.med} ${t.ease};align-items:center;gap:6px;padding-inline:2px;font-size:9px;font-weight:500;display:flex;position:absolute;overflow:hidden}[data-slot=treemap-group][data-drill]{border-radius:${treemapDef.vars.radius};cursor:zoom-in}[data-slot=treemap-group][data-drill]:hover{color:${t.fg.bright};background:${t.hover}}[data-slot=treemap-group]:focus-visible{outline:2px solid ${t.focus}}[data-slot=treemap-group-name]{text-overflow:ellipsis;overflow:hidden}[data-slot=treemap-group-value]{font-variant-numeric:tabular-nums;margin-inline-start:auto}[data-slot=treemap-group-value][data-tone=up]{color:${treemapDef.vars.up}}[data-slot=treemap-group-value][data-tone=down]{color:${treemapDef.vars.down}}[data-slot=treemap-tile]{all:unset;--_tone:${t.fg.muted};--_tint:calc(${treemapDef.vars["tint-min"]} + (${treemapDef.vars["tint-max"]} - ${treemapDef.vars["tint-min"]}) * var(--_level,0));border:1px solid color-mix(in srgb, var(--_tone) calc(var(--_tint) * .8), ${t.border});border-radius:${treemapDef.vars.radius};background:color-mix(in srgb, var(--_tone) var(--_tint), ${treemapDef.vars["tile-bg"]});text-align:center;cursor:pointer;transition:left ${t.dur.med} ${t.ease}, top ${t.dur.med} ${t.ease}, width ${t.dur.med} ${t.ease}, height ${t.dur.med} ${t.ease}, background-color ${t.dur.med} linear, scale ${t.dur.fast} ${t.ease};flex-direction:column;justify-content:center;align-items:center;gap:1px;display:flex;position:absolute;overflow:hidden}[data-slot=treemap-tile][data-tone=up]{--_tone:${treemapDef.vars.up}}[data-slot=treemap-tile][data-tone=down]{--_tone:${treemapDef.vars.down}}[data-slot=treemap-tile][data-tone=custom]{--_tone:var(--_color)}[data-slot=treemap-tile][data-tone=none]{--_tint:0%}[data-slot=treemap-tile]:hover{z-index:${treemapDef.vars["hover-z"]};border-color:${t.fg.bright};scale:1.04}[data-slot=treemap-tile]:focus-visible{z-index:${treemapDef.vars["hover-z"]};outline:2px solid ${t.focus}}[data-slot=treemap-tile][data-selected]{border-color:${t.fg.bright};outline:1px solid ${t.fg.bright}}[data-slot=treemap-tile-label]{text-overflow:ellipsis;white-space:nowrap;max-width:100%;color:${t.fg.bright};font-weight:600;line-height:1.1;overflow:hidden}[data-slot=treemap-tile-value]{white-space:nowrap;font-variant-numeric:tabular-nums;color:${t.fg.bright};opacity:.92}[data-slot=treemap-legend]{font-variant-numeric:tabular-nums;color:${t.fg.muted};grid-template-columns:auto 1fr auto;align-items:center;gap:8px;font-size:10px;display:grid}[data-slot=treemap-legend-bar]{border:1px solid ${t.border};background:linear-gradient(to right, color-mix(in srgb, ${treemapDef.vars.down} 70%, ${treemapDef.vars["tile-bg"]}), ${treemapDef.vars["tile-bg"]}, color-mix(in srgb, ${treemapDef.vars.up} 70%, ${treemapDef.vars["tile-bg"]}));border-radius:999px;height:6px}[data-slot=treemap-tip]{z-index:${treemapDef.vars["tip-z"]};pointer-events:none;border:1px solid ${t.border};border-radius:${treemapDef.vars["tip-radius"]};background:${treemapDef.vars["tip-bg"]};box-shadow:${treemapDef.vars["tip-shadow"]};color:${t.fg.bright};white-space:nowrap;font-variant-numeric:tabular-nums;transition:left ${t.dur.fast} ease-out, top ${t.dur.fast} ease-out;gap:2px;padding:8px;font-size:12px;line-height:1.35;position:absolute;top:0}[data-slot=treemap-tip]:where(:not([hidden])){display:grid}[data-slot=treemap-tip][data-instant]{transition:none}[data-slot=treemap-tip] [data-tone=up]{color:${treemapDef.vars.up}}[data-slot=treemap-tip] [data-tone=down]{color:${treemapDef.vars.down}}[data-slot=treemap-tip] small{color:${t.fg.muted}}}`
|
|
83
|
+
);
|
|
84
|
+
var weightOf = (item) => item.children ? item.children.reduce((s, c) => s + weightOf(c), 0) : Math.max(0, item.weight ?? 1);
|
|
85
|
+
function median(values) {
|
|
86
|
+
if (values.length === 0) return null;
|
|
87
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
88
|
+
const mid = (sorted.length - 1) / 2;
|
|
89
|
+
return (sorted[Math.floor(mid)] + sorted[Math.ceil(mid)]) / 2;
|
|
90
|
+
}
|
|
91
|
+
var toneOf = (value) => value === null ? "none" : value > 0 ? "up" : value < 0 ? "down" : "flat";
|
|
92
|
+
var defaultFormat = (value) => `${value > 0 ? "+" : ""}${value.toFixed(2)}`;
|
|
93
|
+
var TreemapImpl = class {
|
|
94
|
+
constructor(props) {
|
|
95
|
+
this.props = props;
|
|
96
|
+
this.values = /* @__PURE__ */ new Map();
|
|
97
|
+
this.tiles = /* @__PURE__ */ new Map();
|
|
98
|
+
this.groups = /* @__PURE__ */ new Map();
|
|
99
|
+
/** The zoomed groups' ids, outermost first. */
|
|
100
|
+
this.zoom = [];
|
|
101
|
+
/** The tile that takes the map's tab stop. */
|
|
102
|
+
this.current = null;
|
|
103
|
+
/** The tile the readout describes. */
|
|
104
|
+
this.tipFor = null;
|
|
105
|
+
this.box = { w: 0, h: 0 };
|
|
106
|
+
injectStyles(document);
|
|
107
|
+
this.i18n = props.i18n ?? kitTranslator();
|
|
108
|
+
this.gap = Math.max(0, props.gap ?? 3);
|
|
109
|
+
this.items = props.items ?? [];
|
|
110
|
+
this.selected = props.selected ?? null;
|
|
111
|
+
this.map = h("div", { slot: treemapDef.slot("map"), attrs: { role: "group", dir: "ltr", "aria-label": props.label ?? null } });
|
|
112
|
+
this.tip = h("div", { slot: treemapDef.slot("tip"), attrs: { "aria-hidden": "true" } });
|
|
113
|
+
this.tip.hidden = true;
|
|
114
|
+
this.crumbs = props.drill ? h("nav", { slot: treemapDef.slot("crumbs") }) : null;
|
|
115
|
+
let legendEl = null;
|
|
116
|
+
if (props.legend) {
|
|
117
|
+
const low = h("span");
|
|
118
|
+
const high = h("span");
|
|
119
|
+
legendEl = h("div", { slot: treemapDef.slot("legend"), attrs: { "aria-hidden": "true", dir: "ltr" } }, low, h("i", { slot: treemapDef.slot("legend-bar") }), high);
|
|
120
|
+
this.legend = { low, high };
|
|
121
|
+
} else this.legend = null;
|
|
122
|
+
this.el = h("div", { className: props.className, slot: treemapDef.slot("root") }, this.crumbs, this.map, legendEl, this.tip);
|
|
123
|
+
this.map.addEventListener("keydown", (e) => this.onKey(e));
|
|
124
|
+
this.map.addEventListener("pointerleave", () => this.hideTip());
|
|
125
|
+
this.el.addEventListener("keydown", (e) => {
|
|
126
|
+
if (e.key !== "Escape" || this.zoom.length === 0) return;
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
e.stopPropagation();
|
|
129
|
+
this.setZoom(this.zoom.slice(0, -1), true);
|
|
130
|
+
});
|
|
131
|
+
this.ro = typeof ResizeObserver === "function" ? new ResizeObserver(() => this.measure()) : null;
|
|
132
|
+
this.ro?.observe(this.map);
|
|
133
|
+
this.renderCrumbs();
|
|
134
|
+
this.layout();
|
|
135
|
+
}
|
|
136
|
+
setData(items) {
|
|
137
|
+
this.items = items;
|
|
138
|
+
this.values.clear();
|
|
139
|
+
const zoom = [];
|
|
140
|
+
let level = items;
|
|
141
|
+
for (const id of this.zoom) {
|
|
142
|
+
const group = level.find((item) => item.id === id && item.children);
|
|
143
|
+
if (!group) break;
|
|
144
|
+
zoom.push(id);
|
|
145
|
+
level = group.children;
|
|
146
|
+
}
|
|
147
|
+
const changed = zoom.length !== this.zoom.length;
|
|
148
|
+
this.zoom = zoom;
|
|
149
|
+
this.renderCrumbs();
|
|
150
|
+
this.layout();
|
|
151
|
+
if (changed) this.props.onDrill?.(this.zoomPath());
|
|
152
|
+
}
|
|
153
|
+
setValues(values) {
|
|
154
|
+
const entries = values instanceof Map ? values.entries() : Object.entries(values);
|
|
155
|
+
for (const [id, value] of entries) this.values.set(id, value);
|
|
156
|
+
this.paint();
|
|
157
|
+
}
|
|
158
|
+
setSelected(id) {
|
|
159
|
+
this.selected = id;
|
|
160
|
+
for (const [key, tile] of this.tiles) tile.el.toggleAttribute("data-selected", key === id);
|
|
161
|
+
}
|
|
162
|
+
drillTo(id) {
|
|
163
|
+
if (id === null) {
|
|
164
|
+
this.setZoom([], true);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const path = this.pathTo(id, this.items, []);
|
|
168
|
+
if (path) this.setZoom([...path.map((g) => g.id), id], true);
|
|
169
|
+
}
|
|
170
|
+
destroy() {
|
|
171
|
+
this.ro?.disconnect();
|
|
172
|
+
this.el.remove();
|
|
173
|
+
}
|
|
174
|
+
pathTo(id, level, above) {
|
|
175
|
+
for (const item of level) {
|
|
176
|
+
if (!item.children) continue;
|
|
177
|
+
if (item.id === id) return above;
|
|
178
|
+
const found = this.pathTo(id, item.children, [...above, item]);
|
|
179
|
+
if (found) return found;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
/** The zoomed groups, outermost first. */
|
|
184
|
+
zoomPath() {
|
|
185
|
+
const path = [];
|
|
186
|
+
let level = this.items;
|
|
187
|
+
for (const id of this.zoom) {
|
|
188
|
+
const group = level.find((item) => item.id === id);
|
|
189
|
+
if (!group?.children) break;
|
|
190
|
+
path.push(group);
|
|
191
|
+
level = group.children;
|
|
192
|
+
}
|
|
193
|
+
return path;
|
|
194
|
+
}
|
|
195
|
+
setZoom(zoom, announce) {
|
|
196
|
+
if (zoom.join("\0") === this.zoom.join("\0")) return;
|
|
197
|
+
this.zoom = zoom;
|
|
198
|
+
this.current = null;
|
|
199
|
+
this.hideTip();
|
|
200
|
+
this.renderCrumbs();
|
|
201
|
+
this.layout();
|
|
202
|
+
if (announce) this.props.onDrill?.(this.zoomPath());
|
|
203
|
+
}
|
|
204
|
+
renderCrumbs() {
|
|
205
|
+
if (!this.crumbs) return;
|
|
206
|
+
const path = this.zoomPath();
|
|
207
|
+
const entries = [{ label: this.props.rootLabel ?? textOf(this.i18n, TEXT.all), zoom: [] }];
|
|
208
|
+
path.forEach((group, i) => entries.push({ label: group.label, zoom: this.zoom.slice(0, i + 1) }));
|
|
209
|
+
this.crumbs.replaceChildren(
|
|
210
|
+
...entries.map((entry, i) => {
|
|
211
|
+
const last = i === entries.length - 1;
|
|
212
|
+
return h("button", {
|
|
213
|
+
slot: treemapDef.slot("crumb"),
|
|
214
|
+
text: entry.label,
|
|
215
|
+
attrs: { type: "button", "aria-current": last ? "true" : null, tabindex: last ? "-1" : null },
|
|
216
|
+
on: { click: () => !last && this.setZoom(entry.zoom, true) }
|
|
217
|
+
});
|
|
218
|
+
})
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
measure() {
|
|
222
|
+
const w = this.map.clientWidth;
|
|
223
|
+
const hh = this.map.clientHeight;
|
|
224
|
+
if (Math.abs(w - this.box.w) < 0.5 && Math.abs(hh - this.box.h) < 0.5) return;
|
|
225
|
+
this.box = { w, h: hh };
|
|
226
|
+
this.layout();
|
|
227
|
+
}
|
|
228
|
+
/** The items on the map: the zoomed group's, or the top level's. */
|
|
229
|
+
level() {
|
|
230
|
+
const path = this.zoomPath();
|
|
231
|
+
return { items: path.length > 0 ? path[path.length - 1].children : this.items, path };
|
|
232
|
+
}
|
|
233
|
+
place(items, bounds, path, groups, tiles) {
|
|
234
|
+
const half = this.gap / 2;
|
|
235
|
+
for (const r of squarify(
|
|
236
|
+
items.map((item) => ({ item, weight: weightOf(item) })),
|
|
237
|
+
bounds
|
|
238
|
+
)) {
|
|
239
|
+
const box = { x: r.x + half, y: r.y + half, w: Math.max(0, r.w - this.gap), h: Math.max(0, r.h - this.gap) };
|
|
240
|
+
if (r.item.children) {
|
|
241
|
+
const headed = box.w >= HEADED.w && box.h >= HEADED.h;
|
|
242
|
+
if (headed) groups.push({ item: r.item, path, ...box, h: HEADER });
|
|
243
|
+
const top = headed ? HEADER : 0;
|
|
244
|
+
this.place(r.item.children, { x: box.x, y: box.y + top, w: box.w, h: box.h - top }, [...path, r.item], groups, tiles);
|
|
245
|
+
} else tiles.push({ item: r.item, path, ...box });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
layout() {
|
|
249
|
+
const level = this.level();
|
|
250
|
+
const groups = [];
|
|
251
|
+
const tiles = [];
|
|
252
|
+
this.place(level.items, { x: 0, y: 0, w: this.box.w, h: this.box.h }, level.path, groups, tiles);
|
|
253
|
+
const nextGroups = /* @__PURE__ */ new Map();
|
|
254
|
+
for (const placed of groups) {
|
|
255
|
+
const view = this.groups.get(placed.item.id) ?? this.groupView(placed);
|
|
256
|
+
view.placed = placed;
|
|
257
|
+
view.el.firstElementChild.textContent = placed.item.label;
|
|
258
|
+
position(view.el, placed);
|
|
259
|
+
nextGroups.set(placed.item.id, view);
|
|
260
|
+
}
|
|
261
|
+
const nextTiles = /* @__PURE__ */ new Map();
|
|
262
|
+
for (const placed of tiles) {
|
|
263
|
+
const old = this.tiles.get(placed.item.id);
|
|
264
|
+
const view = old ?? this.tileView(placed);
|
|
265
|
+
view.placed = placed;
|
|
266
|
+
this.fitTile(view);
|
|
267
|
+
position(view.el, placed);
|
|
268
|
+
nextTiles.set(placed.item.id, view);
|
|
269
|
+
}
|
|
270
|
+
for (const [id, view] of this.groups) if (!nextGroups.has(id)) view.el.remove();
|
|
271
|
+
for (const [id, view] of this.tiles) if (!nextTiles.has(id)) view.el.remove();
|
|
272
|
+
this.groups = nextGroups;
|
|
273
|
+
this.tiles = nextTiles;
|
|
274
|
+
const order = [];
|
|
275
|
+
const headerOf = new Map(groups.map((g) => [g.item.id, nextGroups.get(g.item.id).el]));
|
|
276
|
+
const written = /* @__PURE__ */ new Set();
|
|
277
|
+
for (const placed of tiles) {
|
|
278
|
+
for (const group of placed.path) {
|
|
279
|
+
const header = headerOf.get(group.id);
|
|
280
|
+
if (header && !written.has(group.id)) {
|
|
281
|
+
written.add(group.id);
|
|
282
|
+
order.push(header);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
order.push(nextTiles.get(placed.item.id).el);
|
|
286
|
+
}
|
|
287
|
+
const children = this.map.children;
|
|
288
|
+
const same = children.length === order.length && order.every((node, i) => children[i] === node);
|
|
289
|
+
if (!same) this.map.replaceChildren(...order);
|
|
290
|
+
if (this.current === null || !this.tiles.has(this.current)) this.current = tiles[0]?.item.id ?? null;
|
|
291
|
+
for (const [id, tile] of this.tiles) {
|
|
292
|
+
tile.el.tabIndex = id === this.current ? 0 : -1;
|
|
293
|
+
tile.el.toggleAttribute("data-selected", id === this.selected);
|
|
294
|
+
}
|
|
295
|
+
this.paint();
|
|
296
|
+
}
|
|
297
|
+
groupView(placed) {
|
|
298
|
+
const name = h("span", { slot: treemapDef.slot("group-name") });
|
|
299
|
+
const value = h("span", { slot: treemapDef.slot("group-value") });
|
|
300
|
+
const drill = this.props.drill === true;
|
|
301
|
+
const el = drill ? h(
|
|
302
|
+
"button",
|
|
303
|
+
{
|
|
304
|
+
slot: treemapDef.slot("group"),
|
|
305
|
+
data: { drill: true },
|
|
306
|
+
attrs: { type: "button", title: textOf(this.i18n, TEXT.zoomIn) }
|
|
307
|
+
},
|
|
308
|
+
name,
|
|
309
|
+
value
|
|
310
|
+
) : h("div", { slot: treemapDef.slot("group") }, name, value);
|
|
311
|
+
const view = { el, value, placed };
|
|
312
|
+
if (drill) el.addEventListener("click", () => this.drillTo(view.placed.item.id));
|
|
313
|
+
return view;
|
|
314
|
+
}
|
|
315
|
+
tileView(placed) {
|
|
316
|
+
const el = h("button", { slot: treemapDef.slot("tile"), attrs: { type: "button" } });
|
|
317
|
+
const view = { el, label: null, value: null, placed };
|
|
318
|
+
el.addEventListener("click", () => this.choose(view));
|
|
319
|
+
el.addEventListener("focus", () => {
|
|
320
|
+
this.current = view.placed.item.id;
|
|
321
|
+
for (const tile of this.tiles.values()) tile.el.tabIndex = tile === view ? 0 : -1;
|
|
322
|
+
this.showTipFor(view);
|
|
323
|
+
});
|
|
324
|
+
el.addEventListener("blur", () => this.hideTip());
|
|
325
|
+
el.addEventListener("pointerenter", () => this.showTipFor(view));
|
|
326
|
+
return view;
|
|
327
|
+
}
|
|
328
|
+
/** Text sized to the tile: the label from a small tile up, the value from a larger one. */
|
|
329
|
+
fitTile(view) {
|
|
330
|
+
const { w, h: ht } = view.placed;
|
|
331
|
+
const font = Math.max(10, Math.min(18, Math.min(w, ht) / 4.2));
|
|
332
|
+
const showLabel = w > 34 && ht > 20;
|
|
333
|
+
const showValue = w > 48 && ht > 38;
|
|
334
|
+
if (showLabel && !view.label) view.label = h("span", { slot: treemapDef.slot("tile-label") });
|
|
335
|
+
if (!showLabel) view.label = null;
|
|
336
|
+
if (showValue && !view.value) view.value = h("span", { slot: treemapDef.slot("tile-value") });
|
|
337
|
+
if (!showValue) view.value = null;
|
|
338
|
+
if (view.label) {
|
|
339
|
+
view.label.textContent = view.placed.item.label;
|
|
340
|
+
view.label.style.fontSize = `${font}px`;
|
|
341
|
+
}
|
|
342
|
+
if (view.value) view.value.style.fontSize = `${Math.max(9.5, font * 0.72)}px`;
|
|
343
|
+
const parts = [view.label, view.value].filter((part) => part !== null);
|
|
344
|
+
if (parts.length !== view.el.childElementCount || parts.some((part, i) => view.el.children[i] !== part)) view.el.replaceChildren(...parts);
|
|
345
|
+
}
|
|
346
|
+
valueOf(item) {
|
|
347
|
+
const value = this.values.has(item.id) ? this.values.get(item.id) : item.value ?? null;
|
|
348
|
+
return value === null || !Number.isFinite(value) ? null : value;
|
|
349
|
+
}
|
|
350
|
+
leafValues(item) {
|
|
351
|
+
if (!item.children) {
|
|
352
|
+
const value = this.valueOf(item);
|
|
353
|
+
return value === null ? [] : [value];
|
|
354
|
+
}
|
|
355
|
+
return item.children.flatMap((child) => this.leafValues(child));
|
|
356
|
+
}
|
|
357
|
+
groupFigure(group) {
|
|
358
|
+
const mode = this.props.groupValue ?? "median";
|
|
359
|
+
if (mode === "none") return null;
|
|
360
|
+
const values = this.leafValues(group);
|
|
361
|
+
if (typeof mode === "function") return mode(values, group);
|
|
362
|
+
if (values.length === 0) return null;
|
|
363
|
+
if (mode === "sum") return values.reduce((s, v) => s + v, 0);
|
|
364
|
+
if (mode === "mean") return values.reduce((s, v) => s + v, 0) / values.length;
|
|
365
|
+
return median(values);
|
|
366
|
+
}
|
|
367
|
+
format(value) {
|
|
368
|
+
return (this.props.format ?? defaultFormat)(value);
|
|
369
|
+
}
|
|
370
|
+
paint() {
|
|
371
|
+
let largest = 0;
|
|
372
|
+
for (const tile of this.tiles.values()) largest = Math.max(largest, Math.abs(this.valueOf(tile.placed.item) ?? 0));
|
|
373
|
+
const domain = this.props.domain !== void 0 && this.props.domain > 0 ? this.props.domain : largest;
|
|
374
|
+
for (const tile of this.tiles.values()) {
|
|
375
|
+
const item = tile.placed.item;
|
|
376
|
+
const value = this.valueOf(item);
|
|
377
|
+
if (item.color !== void 0) {
|
|
378
|
+
tile.el.dataset.tone = "custom";
|
|
379
|
+
tile.el.style.setProperty("--_color", item.color);
|
|
380
|
+
} else tile.el.dataset.tone = toneOf(value);
|
|
381
|
+
tile.el.style.setProperty("--_level", value === null || domain === 0 ? "0" : String(Math.min(Math.abs(value) / domain, 1)));
|
|
382
|
+
const text = value === null ? "" : this.format(value);
|
|
383
|
+
if (tile.value) tile.value.textContent = text;
|
|
384
|
+
tile.el.setAttribute("aria-label", text === "" ? item.label : `${item.label} ${text}`);
|
|
385
|
+
}
|
|
386
|
+
for (const group of this.groups.values()) {
|
|
387
|
+
const figure = this.groupFigure(group.placed.item);
|
|
388
|
+
group.value.textContent = figure === null ? "" : this.format(figure);
|
|
389
|
+
group.value.dataset.tone = toneOf(figure);
|
|
390
|
+
const name = group.placed.item.label;
|
|
391
|
+
group.el.setAttribute("aria-label", figure === null ? name : `${name} ${this.format(figure)}`);
|
|
392
|
+
}
|
|
393
|
+
if (this.legend) {
|
|
394
|
+
this.legend.low.textContent = domain > 0 ? this.format(-domain) : "";
|
|
395
|
+
this.legend.high.textContent = domain > 0 ? this.format(domain) : "";
|
|
396
|
+
}
|
|
397
|
+
const shown = this.tipFor !== null ? this.tiles.get(this.tipFor) : void 0;
|
|
398
|
+
if (shown) this.showTipFor(shown);
|
|
399
|
+
else this.hideTip();
|
|
400
|
+
}
|
|
401
|
+
choose(view) {
|
|
402
|
+
this.props.onSelect?.(view.placed.item, view.placed.path);
|
|
403
|
+
}
|
|
404
|
+
tipContent(view) {
|
|
405
|
+
const { item, path } = view.placed;
|
|
406
|
+
if (this.props.tip === false) return null;
|
|
407
|
+
if (this.props.tip) return this.props.tip(item, path);
|
|
408
|
+
const value = this.valueOf(item);
|
|
409
|
+
return h(
|
|
410
|
+
"div",
|
|
411
|
+
{},
|
|
412
|
+
h("div", {}, h("b", { text: item.label }), value === null ? null : h("span", { text: ` ${this.format(value)}`, data: { tone: toneOf(value) } })),
|
|
413
|
+
path.length > 0 ? h("small", { text: path.map((g) => g.label).join(" \u203A ") }) : null
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
showTipFor(view) {
|
|
417
|
+
const content = this.tipContent(view);
|
|
418
|
+
if (content === null) return;
|
|
419
|
+
this.tipFor = view.placed.item.id;
|
|
420
|
+
const { x, y, w, h: ht } = view.placed;
|
|
421
|
+
showTip(this.tip, content, { w: this.el.clientWidth, h: this.el.clientHeight }, this.map.offsetLeft + x + w / 2, this.map.offsetTop + y + ht / 2);
|
|
422
|
+
}
|
|
423
|
+
hideTip() {
|
|
424
|
+
this.tipFor = null;
|
|
425
|
+
this.tip.hidden = true;
|
|
426
|
+
}
|
|
427
|
+
/** Arrows move to the nearest tile that way, Home and End to the first and the last. */
|
|
428
|
+
onKey(e) {
|
|
429
|
+
const from = this.current !== null ? this.tiles.get(this.current) : void 0;
|
|
430
|
+
if (!from || !(e.target instanceof HTMLElement) || e.target.dataset.slot !== treemapDef.slot("tile")) return;
|
|
431
|
+
const list = [...this.tiles.values()];
|
|
432
|
+
let next;
|
|
433
|
+
if (e.key === "Home") next = list[0];
|
|
434
|
+
else if (e.key === "End") next = list[list.length - 1];
|
|
435
|
+
else {
|
|
436
|
+
const dir = { ArrowRight: [1, 0], ArrowLeft: [-1, 0], ArrowDown: [0, 1], ArrowUp: [0, -1] }[e.key];
|
|
437
|
+
if (!dir) return;
|
|
438
|
+
const cx = from.placed.x + from.placed.w / 2;
|
|
439
|
+
const cy = from.placed.y + from.placed.h / 2;
|
|
440
|
+
let best = Infinity;
|
|
441
|
+
for (const tile of list) {
|
|
442
|
+
if (tile === from) continue;
|
|
443
|
+
const dx = tile.placed.x + tile.placed.w / 2 - cx;
|
|
444
|
+
const dy = tile.placed.y + tile.placed.h / 2 - cy;
|
|
445
|
+
const along = dx * dir[0] + dy * dir[1];
|
|
446
|
+
if (along <= 0) continue;
|
|
447
|
+
const across = Math.abs(dx * dir[1] - dy * dir[0]);
|
|
448
|
+
const score = along + across * 2;
|
|
449
|
+
if (score < best) {
|
|
450
|
+
best = score;
|
|
451
|
+
next = tile;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (!next) return;
|
|
456
|
+
e.preventDefault();
|
|
457
|
+
next.el.focus();
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
function position(el, box) {
|
|
461
|
+
el.style.left = `${box.x}px`;
|
|
462
|
+
el.style.top = `${box.y}px`;
|
|
463
|
+
el.style.width = `${box.w}px`;
|
|
464
|
+
el.style.height = `${box.h}px`;
|
|
465
|
+
}
|
|
466
|
+
function createTreemap(props = {}) {
|
|
467
|
+
return new TreemapImpl(props);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export { createTreemap, squarify, treemapDef };
|
package/docs/theming.md
CHANGED
|
@@ -167,6 +167,10 @@ Unlayered CSS also reaches the kit when you did not mean it to: a global reset s
|
|
|
167
167
|
fields. Scope such rules away from Vela (`button:where(:not(.vela-ui *)) { … }`), or move them
|
|
168
168
|
into a layer declared before Vela's (`@layer reset;` first in your stylesheet).
|
|
169
169
|
|
|
170
|
+
The kit's CSS does not reach the other way: a component's styles apply inside kit hosts and
|
|
171
|
+
the floating layers they open only, so a page's own components keep their look, even those
|
|
172
|
+
that use the same part names (`data-slot="select-trigger"`).
|
|
173
|
+
|
|
170
174
|
## Overriding from a page's CSS
|
|
171
175
|
|
|
172
176
|
The theme layer sits below every other style, so a page's own CSS overrides any token without
|
|
@@ -209,3 +213,5 @@ sets every token on the page root:
|
|
|
209
213
|
```
|
|
210
214
|
|
|
211
215
|
Bundlers resolve `@luxalgo/vela-ui/themes/dark.css` and `@luxalgo/vela-ui/themes/light.css`.
|
|
216
|
+
The components still go in a kit host, which gives them their base styles: call
|
|
217
|
+
`ensureUIHost(el)` without a theme on the element that holds them.
|
|
@@ -127,7 +127,10 @@ change.
|
|
|
127
127
|
- **`css`** marks a template as CSS (editors highlight it, stylelint checks it) and
|
|
128
128
|
**`defineStyles(id, text)`** returns the injector a component calls at creation, never at
|
|
129
129
|
import: it declares the layer order once per document or shadow root, then injects the
|
|
130
|
-
sheet, id-guarded.
|
|
130
|
+
sheet, id-guarded. The sheet applies inside kit hosts, their floating layers and themed
|
|
131
|
+
hosts only: a `:where()` joins the first compound of each top-level selector, adding no
|
|
132
|
+
weight, so a page's own elements that carry the same `data-slot` names are never restyled.
|
|
133
|
+
Inject a component's CSS through it, never by hand.
|
|
131
134
|
- **`t`** reads the design tokens: `${t.radius.md}` prints `var(--vela-radius-md)`, and a
|
|
132
135
|
name that does not exist fails the typecheck. A test checks that `t` and the tokens the
|
|
133
136
|
theme writes match in both directions.
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @luxalgo/vela-ui 0.
|
|
1
|
+
# @luxalgo/vela-ui 0.3.0
|
|
2
2
|
|
|
3
3
|
> The component kit of Vela: one file per component, Zag state machines for behavior, CSS in
|
|
4
4
|
> cascade layers over design tokens, and one typed theme config.
|
|
@@ -11,7 +11,7 @@ kit host: `ensureUIHost(el, createTheme())` (`@luxalgo/vela-ui/theme`), or insid
|
|
|
11
11
|
## Skills (agent instructions in this package)
|
|
12
12
|
|
|
13
13
|
- [theming-vela-ui](skills/theming-vela-ui/SKILL.md): Themes and restyles Vela charts and @luxalgo/vela-ui components with createTheme - brand colors, light, dark and custom themes, design tokens, component settings, part-by-part CSS restyles, scrollbars, cascade layers and theme JSON files checked with checkTheme.
|
|
14
|
-
- [using-vela-ui-components](skills/using-vela-ui-components/SKILL.md): Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, form controls (checkbox, switch, input, select, number input, date and color pickers) and data components (data table, stat, sparkline, bar, line and scatter charts).
|
|
14
|
+
- [using-vela-ui-components](skills/using-vela-ui-components/SKILL.md): Builds interface pieces with @luxalgo/vela-ui, the component kit behind Vela charts - buttons, tabs, toggle groups, badges, dialogs, drawers, dropdown and context menus, tooltips, hover cards, popovers, toasts, collapsible sections, cards, list rows, form controls (checkbox, switch, slider, input, select, number input, date and color pickers) and data components (data table, sort buttons, month grid, stat, sparkline, bar, line and scatter charts, treemap).
|
|
15
15
|
- [writing-vela-ui-components](skills/writing-vela-ui-components/SKILL.md): Writes new UI components with the @luxalgo/vela-ui authoring helpers (defineComponent, h, css, defineStyles, variants, t), customizes a kit component's markup or behavior by copying its source with "vela-ui add --source", and adds components to the kit itself.
|
|
16
16
|
|
|
17
17
|
Link them into a project's coding agent with `npx skills experimental_sync` once the package is
|
|
@@ -34,9 +34,11 @@ installed, or install them from the repository with `npx skills add LuxAlgo/Vela
|
|
|
34
34
|
|
|
35
35
|
- createBadge (`@luxalgo/vela-ui/badge`): Badge: a short status label, or a round count.
|
|
36
36
|
- createBarChart (`@luxalgo/vela-ui/bar-chart`): BarChart: vertical bars around a zero line with a hover readout (daily P&L, a distribution), in the profit tone above zero and the loss tone below unless a bar names its own; optionally a value axis with gridlines and a title, slanted labels, and dashed markers.
|
|
37
|
-
- createButton (`@luxalgo/vela-ui/button`): Button: a <button> with optional icons before and after its text.
|
|
37
|
+
- createButton (`@luxalgo/vela-ui/button`): Button: a <button> with optional icons and key caps before and after its text (`↵ Open`, `Esc Close` in a picker's footer).
|
|
38
38
|
- createCalloutBubble (`@luxalgo/vela-ui/callout-bubble`): CalloutBubble: a small tinted circle with a centered icon.
|
|
39
|
+
- createCard (`@luxalgo/vela-ui/card`): Card: a surface for one subject (a panel of figures, a chart, a summary): a header with an eyebrow over the title and a description under it, an action at its end (buttons, a toggle group), then the content and a footer past a line.
|
|
39
40
|
- createCheckbox (`@luxalgo/vela-ui/checkbox`): Checkbox: a square check toggle, filled with a check mark when on.
|
|
41
|
+
- createCollapsible (`@luxalgo/vela-ui/collapsible`): Collapsible: a section that shows or hides its content.
|
|
40
42
|
- createColorField (`@luxalgo/vela-ui/color-picker`): ColorPicker: a swatch grid (grays, then hue × shade), a recents row with a custom "+" chooser, and an opacity slider over a transparency checker; and ColorField, the swatch button that opens it on a popover.
|
|
41
43
|
- createContextMenu (`@luxalgo/vela-ui/context-menu`): ContextMenu: the dropdown menu's list, opened where the user asks for it instead of from a button: a right-click on the target, a long press on a touch screen, or the keyboard's context-menu key on a focused target.
|
|
42
44
|
- createDataTable (`@luxalgo/vela-ui/data-table`): DataTable: a sortable table with a sticky header in its own scroller (positions, orders, trades).
|
|
@@ -51,16 +53,22 @@ installed, or install them from the repository with `npx skills add LuxAlgo/Vela
|
|
|
51
53
|
- createHoverCard (`@luxalgo/vela-ui/hover-card`): HoverCard: a card beside a control while the pointer rests on it, richer than a tooltip: a title with an icon tile and a shortcut drawn as keycaps, a description, rich content (figures, a sparkline) and a hint line.
|
|
52
54
|
- createInputGroup (`@luxalgo/vela-ui/input-group`): InputGroup: an input with addons inside its border: an icon, a short text or a button, at its start or end, or in a row above or below it (a search field with its magnifier, an amount with its unit).
|
|
53
55
|
- createInput (`@luxalgo/vela-ui/input`): Input: a one-line text input that commits on blur or Enter.
|
|
56
|
+
- createItem (`@luxalgo/vela-ui/item`): Item: one row of a list (a watchlist, a list of alerts, search results): media (an icon, a logo, an avatar, a star), a title over a description, then at its end the meta (figures, badges) and the actions (buttons).
|
|
54
57
|
- createKbd (`@luxalgo/vela-ui/kbd`): Kbd: one key of a shortcut, drawn as a keycap (`Alt`, `A`).
|
|
55
58
|
- createLineChart (`@luxalgo/vela-ui/line-chart`): LineChart: a compact area chart with a hover readout (equity curves, P&L over time): one line over a fading area, in the profit tone when its last point ends at or above the baseline and the loss tone below it, with optional axis labels under and beside the plot.
|
|
59
|
+
- createMonthGrid (`@luxalgo/vela-ui/month-grid`): MonthGrid: a month of day cells, each with a figure: a trading journal's P&L by day.
|
|
56
60
|
- createNumberInput (`@luxalgo/vela-ui/number-input`): NumberInput: a typed number field with optional steppers that show on hover and repeat while pressed.
|
|
57
61
|
- createPopover (`@luxalgo/vela-ui/popover`): Popover: a positioned floating shell.
|
|
58
62
|
- createScatterChart (`@luxalgo/vela-ui/scatter-chart`): ScatterChart: dots on two value axes with an optional dashed trend line and a hover readout (a trade's P&L against its length).
|
|
59
63
|
- createSelect (`@luxalgo/vela-ui/select`): Select: a trigger button and a themed option list on a popover, with an overlay scrollbar for long lists.
|
|
64
|
+
- createSlider (`@luxalgo/vela-ui/slider`): Slider: a value on a track, dragged by its thumb or moved with the arrow keys, Page Up/Down and Home/End, over Zag's slider machine.
|
|
65
|
+
- createSortButton (`@luxalgo/vela-ui/sort-button`): SortButton: the header of a column that sorts a list which is not a table (a watchlist's Last and Day %).
|
|
60
66
|
- createSparkline (`@luxalgo/vela-ui/sparkline`): Sparkline: a tiny line of values (a watchlist row's day, an equity curve in a card), in the profit tone when it ends at or above where it started (or its baseline) and the loss tone below, with an optional soft area under it and a dotted baseline (the previous close).
|
|
61
67
|
- createStat (`@luxalgo/vela-ui/stat`): Stat: a figure under its label (Net P&L, Win rate), with an optional line under it.
|
|
62
68
|
- createSwitch (`@luxalgo/vela-ui/switch`): Switch: a sliding on/off toggle, a track with a round thumb, for a setting that applies at once.
|
|
63
69
|
- createTabs (`@luxalgo/vela-ui/tabs`): Tabs: a tab list over Zag's tabs machine (WAI-ARIA tabs: roving focus, the arrow keys along the orientation, Home/End, automatic or manual activation).
|
|
64
70
|
- createTextArea (`@luxalgo/vela-ui/text-area`): TextArea: a multi-line text input that commits on blur, and can grow with its content up to a number of lines before it scrolls.
|
|
71
|
+
- createToaster (`@luxalgo/vela-ui/toast`): Toast: short notices that stack in a corner and leave on their own, shaped after shadcn's toast (Sonner).
|
|
65
72
|
- createToggleGroup (`@luxalgo/vela-ui/toggle-group`): ToggleGroup: a few options side by side on one track, over Zag's toggle-group machine.
|
|
66
73
|
- createTooltip (`@luxalgo/vela-ui/tooltip`): Tooltip: a floating label over Zag's tooltip machine (floating-ui placement).
|
|
74
|
+
- createTreemap (`@luxalgo/vela-ui/treemap`): Treemap: weighted items laid into a rectangle as tiles close to square, each tinted by its value on a diverging scale (up above zero, down below, stronger as the value grows) and labeled when it has room.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxalgo/vela-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The component kit of Vela: one file per component, Zag state machines for behavior, CSS in cascade layers over design tokens.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "LuxAlgo",
|