@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/toast.js
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
import { kitTranslator } from './chunk-FVH6L7FM.js';
|
|
2
|
+
import { msg, textOf } from './chunk-FN2BUFNM.js';
|
|
3
|
+
import { ensureUIHost } from './chunk-TBXUF5YX.js';
|
|
4
|
+
import './chunk-TAKSIV57.js';
|
|
5
|
+
import './chunk-MMTMOV6R.js';
|
|
6
|
+
import { iconEl } from './chunk-C3PXY2SW.js';
|
|
7
|
+
import { h } from './chunk-Q6WTDVH6.js';
|
|
8
|
+
import { t } from './chunk-6QCILIT2.js';
|
|
9
|
+
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
10
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
11
|
+
import './chunk-2GQIZM5Z.js';
|
|
12
|
+
import './chunk-BXMWQIBO.js';
|
|
13
|
+
import { pageState } from './chunk-X66RJAIS.js';
|
|
14
|
+
|
|
15
|
+
// src/components/toast.ts
|
|
16
|
+
var toastDef = defineComponent({
|
|
17
|
+
name: "toast",
|
|
18
|
+
parts: ["root", "list", "item", "close", "icon", "content", "title", "description", "cancel", "action"],
|
|
19
|
+
settings: {
|
|
20
|
+
width: "356px",
|
|
21
|
+
radius: t.radius.lg,
|
|
22
|
+
background: t.surface.elev,
|
|
23
|
+
border: t.border,
|
|
24
|
+
foreground: t.fg.bright,
|
|
25
|
+
"description-color": t.fg.muted,
|
|
26
|
+
shadow: t.shadow,
|
|
27
|
+
success: t.profit,
|
|
28
|
+
info: t.accent,
|
|
29
|
+
warning: t.highlight,
|
|
30
|
+
error: t.danger
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var QUEUE_CAP = 50;
|
|
34
|
+
var queue = pageState("toasts@1", () => ({ toasts: [], listeners: /* @__PURE__ */ new Set(), n: 0 }));
|
|
35
|
+
function emit(e) {
|
|
36
|
+
for (const fn of [...queue.listeners]) fn(e);
|
|
37
|
+
}
|
|
38
|
+
function raise(title, type, data = {}) {
|
|
39
|
+
const id = data.id ?? ++queue.n;
|
|
40
|
+
const at = queue.toasts.findIndex((x) => x.id === id);
|
|
41
|
+
const next = { ...at >= 0 ? queue.toasts[at] : {}, ...data, id, type, title };
|
|
42
|
+
if (at >= 0) queue.toasts[at] = next;
|
|
43
|
+
else {
|
|
44
|
+
queue.toasts.push(next);
|
|
45
|
+
if (queue.toasts.length > QUEUE_CAP) queue.toasts.shift();
|
|
46
|
+
}
|
|
47
|
+
emit({ kind: "show", toast: next });
|
|
48
|
+
return id;
|
|
49
|
+
}
|
|
50
|
+
function settle(id, reason) {
|
|
51
|
+
const at = queue.toasts.findIndex((x) => x.id === id);
|
|
52
|
+
if (at >= 0) {
|
|
53
|
+
const [gone] = queue.toasts.splice(at, 1);
|
|
54
|
+
if (reason === "auto") gone.onAutoClose?.(gone);
|
|
55
|
+
else gone.onDismiss?.(gone);
|
|
56
|
+
}
|
|
57
|
+
emit({ kind: "dismiss", id });
|
|
58
|
+
}
|
|
59
|
+
var resolve = (v, arg) => typeof v === "function" && v.length > 0 ? v(arg) : v;
|
|
60
|
+
function promiseToast(source, data = {}) {
|
|
61
|
+
const { loading, success, error, description, finally: done, ...rest } = data;
|
|
62
|
+
let id = rest.id;
|
|
63
|
+
if (loading !== void 0) id = raise(loading, "loading", { ...rest, description: resolve(description, void 0) });
|
|
64
|
+
const p = typeof source === "function" ? source() : source;
|
|
65
|
+
p.then(
|
|
66
|
+
(value) => {
|
|
67
|
+
const title = resolve(success, value);
|
|
68
|
+
if (title !== void 0) raise(title, "success", { ...rest, id, description: resolve(description, value) });
|
|
69
|
+
else if (id !== void 0) settle(id, "dismiss");
|
|
70
|
+
},
|
|
71
|
+
(err) => {
|
|
72
|
+
const title = resolve(error, err);
|
|
73
|
+
if (title !== void 0) raise(title, "error", { ...rest, id, description: resolve(description, err) });
|
|
74
|
+
else if (id !== void 0) settle(id, "dismiss");
|
|
75
|
+
}
|
|
76
|
+
).finally(() => done?.());
|
|
77
|
+
return { id, unwrap: () => p };
|
|
78
|
+
}
|
|
79
|
+
var kind = (type) => (message, data) => raise(message, type, data);
|
|
80
|
+
var toast = Object.assign(kind("default"), {
|
|
81
|
+
message: kind("default"),
|
|
82
|
+
success: kind("success"),
|
|
83
|
+
info: kind("info"),
|
|
84
|
+
warning: kind("warning"),
|
|
85
|
+
error: kind("error"),
|
|
86
|
+
loading: kind("loading"),
|
|
87
|
+
promise: promiseToast,
|
|
88
|
+
dismiss(id) {
|
|
89
|
+
if (id === void 0) for (const x of [...queue.toasts]) settle(x.id, "dismiss");
|
|
90
|
+
else settle(id, "dismiss");
|
|
91
|
+
return id;
|
|
92
|
+
},
|
|
93
|
+
getToasts: () => queue.toasts.slice()
|
|
94
|
+
});
|
|
95
|
+
var TEXT = {
|
|
96
|
+
region: msg("ui.toast.region", "Notifications"),
|
|
97
|
+
close: msg("ui.toast.close", "Close toast")
|
|
98
|
+
};
|
|
99
|
+
var DEFAULT_ICONS = {
|
|
100
|
+
success: "circle-check",
|
|
101
|
+
info: "circle-info",
|
|
102
|
+
warning: "triangle-alert",
|
|
103
|
+
error: "circle-x",
|
|
104
|
+
loading: "loader",
|
|
105
|
+
close: "close"
|
|
106
|
+
};
|
|
107
|
+
var KEY_NAMES = { altKey: "Alt", ctrlKey: "Control", metaKey: "Meta", shiftKey: "Shift" };
|
|
108
|
+
var SWIPE_THRESHOLD = 45;
|
|
109
|
+
var VELOCITY_THRESHOLD = 0.11;
|
|
110
|
+
var EXIT_MS = 400;
|
|
111
|
+
var injectStyles = defineStyles(
|
|
112
|
+
"vela-ui-toast",
|
|
113
|
+
css`@layer vela.ui{[data-slot=toast]{display:contents}[data-slot=toast-list]{--_offset-top:24px;--_offset-bottom:24px;--_offset-start:24px;--_offset-end:24px;--_gap:14px;z-index:${t.z.popover};box-sizing:border-box;width:min(${toastDef.vars.width}, calc(100% - var(--_offset-start) - var(--_offset-end)));font-family:${t.font};transition:height calc(${t.dur.med} * 2.5) ${t.ease};margin:0;padding:0;list-style:none;position:fixed}[data-slot=toast-list][data-contained]{position:absolute}[data-slot=toast-list][data-y=top]{top:var(--_offset-top)}[data-slot=toast-list][data-y=bottom]{bottom:var(--_offset-bottom)}[data-slot=toast-list][data-x=left]{inset-inline-start:var(--_offset-start)}[data-slot=toast-list][data-x=right]{inset-inline-end:var(--_offset-end)}[data-slot=toast-list][data-x=center]{margin-inline:auto;inset-inline:0}[data-slot=toast-list]:focus-visible{outline:2px solid ${t.focus};outline-offset:4px;border-radius:${toastDef.vars.radius}}[data-slot=toast-item]{--_y:0px;--_scale:1;--_swipe-x:0px;--_swipe-y:0px;--_tint:${toastDef.vars.foreground};box-sizing:border-box;border:1px solid ${toastDef.vars.border};border-radius:${toastDef.vars.radius};background:${toastDef.vars.background};box-shadow:${toastDef.vars.shadow};color:${toastDef.vars.foreground};opacity:0;overflow-wrap:anywhere;touch-action:none;-webkit-user-select:none;user-select:none;transition:transform calc(${t.dur.med} * 2.5) ${t.ease}, opacity calc(${t.dur.med} * 2.5) ${t.ease}, height calc(${t.dur.med} * 2.5) ${t.ease};gap:6px;padding:16px;font-size:13px;line-height:1.4;position:absolute;inset-inline:0}[data-slot=toast-item]:where(:not([hidden])){align-items:center;display:flex}[data-slot=toast-item][data-y=bottom]{transform-origin:bottom;bottom:0;transform:translateY(100%)}[data-slot=toast-item][data-y=top]{transform-origin:top;top:0;transform:translateY(-100%)}[data-slot=toast-item][data-mounted]{opacity:1;transform:translate(var(--_swipe-x), calc(var(--_y) + var(--_swipe-y))) scale(var(--_scale))}[data-slot=toast-item][data-mounted][data-visible=false]{opacity:0;pointer-events:none}[data-slot=toast-item][data-expanded=false][data-front=false]{overflow:hidden}[data-slot=toast-item][data-expanded=false][data-front=false]>*{opacity:0}[data-slot=toast-item][data-removed]{opacity:0;pointer-events:none}[data-slot=toast-item][data-removed=front][data-y=bottom]{transform:translateY(100%)}[data-slot=toast-item][data-removed=front][data-y=top]{transform:translateY(-100%)}[data-slot=toast-item][data-swiping]{transition:none}[data-slot=toast-item]:after{height:var(--_gap);content:"";position:absolute;inset-inline:0}[data-slot=toast-item][data-y=bottom]:after{top:100%}[data-slot=toast-item][data-y=top]:after{bottom:100%}[data-slot=toast-item]:focus-visible{outline:2px solid ${t.focus};outline-offset:2px}[data-slot=toast-item][data-invert]{--_tint:${toastDef.vars.background};border-color:${toastDef.vars.foreground};background:${toastDef.vars.foreground};color:${toastDef.vars.background}}[data-slot=toast-item][data-rich-colors][data-type=success]{--_tint:${toastDef.vars.success}}[data-slot=toast-item][data-rich-colors][data-type=info]{--_tint:${toastDef.vars.info}}[data-slot=toast-item][data-rich-colors][data-type=warning]{--_tint:${toastDef.vars.warning}}[data-slot=toast-item][data-rich-colors][data-type=error]{--_tint:${toastDef.vars.error}}[data-slot=toast-item][data-rich-colors]:is([data-type=success],[data-type=info],[data-type=warning],[data-type=error]){border-color:color-mix(in srgb, var(--_tint) 40%, ${toastDef.vars.background});background:color-mix(in srgb, var(--_tint) 14%, ${toastDef.vars.background});color:color-mix(in srgb, var(--_tint) 80%, ${toastDef.vars.foreground})}[data-slot=toast-icon]{flex:none;width:16px;height:16px;margin-inline:-3px 4px;font-size:16px;line-height:0}[data-slot=toast-icon]:where(:not([hidden])){justify-content:center;align-items:center;display:flex}[data-slot=toast-icon]:is([data-type=loading] *){animation:vela-toast-spin calc(${t.dur.med} * 5) linear infinite}[data-slot=toast-content]{flex:auto;gap:2px;min-width:0}[data-slot=toast-content]:where(:not([hidden])){flex-direction:column;display:flex}[data-slot=toast-title]{font-weight:500;line-height:1.5}[data-slot=toast-description]{color:${toastDef.vars["description-color"]};font-weight:400;line-height:1.4}[data-slot=toast-description]:is([data-rich-colors] *),[data-slot=toast-description]:is([data-invert] *){color:inherit;opacity:.85}[data-slot=toast-action],[data-slot=toast-cancel]{border-radius:${t.radius.sm};height:24px;font:inherit;cursor:pointer;transition:opacity ${t.dur.fast} ease;border:0;flex:none;padding:0 8px;font-size:12px;font-weight:500}:is([data-slot=toast-action],[data-slot=toast-cancel]):hover{opacity:.88}:is([data-slot=toast-action],[data-slot=toast-cancel]):focus-visible{outline:2px solid ${t.focus};outline-offset:2px}[data-slot=toast-action]{background:var(--_tint);color:${toastDef.vars.background}}[data-slot=toast-cancel]{background:color-mix(in srgb, currentcolor 12%, transparent);color:inherit}[data-slot=toast-close]{top:0;border:1px solid ${toastDef.vars.border};background:${toastDef.vars.background};width:20px;height:20px;color:${toastDef.vars.foreground};cursor:pointer;transition:opacity ${t.dur.fast} ease, background ${t.dur.fast} ease;border-radius:50%;padding:0;font-size:12px;line-height:0;position:absolute;inset-inline-start:0;translate:-35% -35%}[data-slot=toast-close]:where(:not([hidden])){justify-content:center;align-items:center;display:flex}[data-slot=toast-close]:is([dir=rtl] *){translate:35% -35%}[data-slot=toast-close]:hover{background:${t.surface.overlay}}[data-slot=toast-close]:focus-visible{outline:2px solid ${t.focus};outline-offset:1px}@keyframes vela-toast-spin{to{transform:rotate(360deg)}}}`
|
|
114
|
+
);
|
|
115
|
+
var px = (v) => typeof v === "number" ? `${v}px` : v;
|
|
116
|
+
var ToasterImpl = class {
|
|
117
|
+
constructor(props) {
|
|
118
|
+
this.props = props;
|
|
119
|
+
this.stacks = /* @__PURE__ */ new Map();
|
|
120
|
+
this.views = /* @__PURE__ */ new Map();
|
|
121
|
+
this.byLi = /* @__PURE__ */ new WeakMap();
|
|
122
|
+
this.paused = false;
|
|
123
|
+
this.hotkeyOpen = false;
|
|
124
|
+
this.onQueue = (e) => {
|
|
125
|
+
if (e.kind === "show") {
|
|
126
|
+
if ((e.toast.toasterId ?? null) !== (this.props.id ?? null)) return;
|
|
127
|
+
this.show(e.toast);
|
|
128
|
+
} else if (e.id === void 0) for (const v of [...this.views.values()]) this.remove(v);
|
|
129
|
+
else {
|
|
130
|
+
const v = this.views.get(e.id);
|
|
131
|
+
if (v) this.remove(v);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
this.onKey = (e) => {
|
|
135
|
+
const keys = this.props.hotkey ?? ["altKey", "KeyT"];
|
|
136
|
+
const pressed = keys.length > 0 && keys.every((k) => e[k] === true || e.code === k);
|
|
137
|
+
if (pressed) {
|
|
138
|
+
const first = [...this.stacks.values()].find((s) => s.ol.childElementCount > 0);
|
|
139
|
+
if (!first) return;
|
|
140
|
+
this.hotkeyOpen = true;
|
|
141
|
+
first.ol.focus();
|
|
142
|
+
this.relayoutAll();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (e.key === "Escape" && this.hotkeyOpen && this.el.contains(document.activeElement)) {
|
|
146
|
+
this.hotkeyOpen = false;
|
|
147
|
+
document.activeElement?.blur();
|
|
148
|
+
this.relayoutAll();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
this.onVisibility = () => this.syncTimers();
|
|
152
|
+
const host = props.host ?? document.body;
|
|
153
|
+
const root = host.getRootNode();
|
|
154
|
+
injectStyles(root instanceof ShadowRoot ? root : host.ownerDocument);
|
|
155
|
+
this.i18n = props.i18n ?? kitTranslator();
|
|
156
|
+
this.position = props.position ?? "bottom-right";
|
|
157
|
+
this.gap = props.gap ?? 14;
|
|
158
|
+
this.visible = props.visibleToasts ?? 3;
|
|
159
|
+
const keys = (props.hotkey ?? ["altKey", "KeyT"]).map((k) => KEY_NAMES[k] ?? k.replace(/^(Key|Digit)/, "")).join("+");
|
|
160
|
+
this.el = h("section", {
|
|
161
|
+
className: props.className,
|
|
162
|
+
slot: toastDef.slot("root"),
|
|
163
|
+
attrs: {
|
|
164
|
+
"aria-keyshortcuts": keys || null,
|
|
165
|
+
tabindex: -1,
|
|
166
|
+
"aria-live": "polite",
|
|
167
|
+
"aria-relevant": "additions text",
|
|
168
|
+
"aria-atomic": "false",
|
|
169
|
+
dir: props.dir && props.dir !== "auto" ? props.dir : null
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
this.relabel();
|
|
173
|
+
host.append(this.el);
|
|
174
|
+
if (props.theme || !this.el.parentElement?.closest(".vela-ui")) ensureUIHost(this.el, props.theme);
|
|
175
|
+
queue.listeners.add(this.onQueue);
|
|
176
|
+
document.addEventListener("keydown", this.onKey);
|
|
177
|
+
document.addEventListener("visibilitychange", this.onVisibility);
|
|
178
|
+
}
|
|
179
|
+
relabel() {
|
|
180
|
+
this.el.setAttribute("aria-label", this.props.containerAriaLabel ?? textOf(this.i18n, TEXT.region));
|
|
181
|
+
const close = textOf(this.i18n, TEXT.close);
|
|
182
|
+
for (const b of this.el.querySelectorAll(`[data-slot='${toastDef.slot("close")}']`)) b.setAttribute("aria-label", close);
|
|
183
|
+
}
|
|
184
|
+
destroy() {
|
|
185
|
+
queue.listeners.delete(this.onQueue);
|
|
186
|
+
document.removeEventListener("keydown", this.onKey);
|
|
187
|
+
document.removeEventListener("visibilitychange", this.onVisibility);
|
|
188
|
+
for (const v of this.views.values()) if (v.timer) clearTimeout(v.timer);
|
|
189
|
+
this.views.clear();
|
|
190
|
+
this.stacks.clear();
|
|
191
|
+
this.el.remove();
|
|
192
|
+
}
|
|
193
|
+
stack(position) {
|
|
194
|
+
let s = this.stacks.get(position);
|
|
195
|
+
if (s) return s;
|
|
196
|
+
const [y, x] = position.split("-");
|
|
197
|
+
const ol = h("ol", { slot: toastDef.slot("list"), data: { y, x, contained: this.props.contained ?? false }, attrs: { tabindex: -1 } });
|
|
198
|
+
this.applyOffset(ol);
|
|
199
|
+
const stack = { ol, y, x, hovered: false, interacting: false };
|
|
200
|
+
ol.addEventListener("mouseenter", () => this.setHover(stack, true));
|
|
201
|
+
ol.addEventListener("mousemove", () => this.setHover(stack, true));
|
|
202
|
+
ol.addEventListener("mouseleave", () => {
|
|
203
|
+
if (!stack.interacting) this.setHover(stack, false);
|
|
204
|
+
});
|
|
205
|
+
ol.addEventListener("pointerdown", (e) => {
|
|
206
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
207
|
+
stack.interacting = true;
|
|
208
|
+
this.relayout(position);
|
|
209
|
+
});
|
|
210
|
+
ol.addEventListener("pointerup", () => {
|
|
211
|
+
stack.interacting = false;
|
|
212
|
+
this.relayout(position);
|
|
213
|
+
});
|
|
214
|
+
ol.addEventListener("focusout", (e) => {
|
|
215
|
+
if (e.relatedTarget instanceof Node && ol.contains(e.relatedTarget)) return;
|
|
216
|
+
this.hotkeyOpen = false;
|
|
217
|
+
this.relayout(position);
|
|
218
|
+
});
|
|
219
|
+
this.el.append(ol);
|
|
220
|
+
this.stacks.set(position, stack);
|
|
221
|
+
return stack;
|
|
222
|
+
}
|
|
223
|
+
applyOffset(ol) {
|
|
224
|
+
const fallback = this.props.contained ? "16px" : "24px";
|
|
225
|
+
const offset = this.props.offset ?? fallback;
|
|
226
|
+
const sides = typeof offset === "object" ? offset : { top: offset, right: offset, bottom: offset, left: offset };
|
|
227
|
+
const rtl = this.props.dir === "rtl";
|
|
228
|
+
ol.style.setProperty("--_offset-top", px(sides.top ?? fallback));
|
|
229
|
+
ol.style.setProperty("--_offset-bottom", px(sides.bottom ?? fallback));
|
|
230
|
+
ol.style.setProperty("--_offset-start", px((rtl ? sides.right : sides.left) ?? fallback));
|
|
231
|
+
ol.style.setProperty("--_offset-end", px((rtl ? sides.left : sides.right) ?? fallback));
|
|
232
|
+
ol.style.setProperty("--_gap", `${this.gap}px`);
|
|
233
|
+
}
|
|
234
|
+
setHover(stack, hovered) {
|
|
235
|
+
if (stack.hovered === hovered) return;
|
|
236
|
+
stack.hovered = hovered;
|
|
237
|
+
this.relayoutAll();
|
|
238
|
+
}
|
|
239
|
+
show(toast2) {
|
|
240
|
+
const existing = this.views.get(toast2.id);
|
|
241
|
+
if (existing && !existing.removed) {
|
|
242
|
+
existing.toast = toast2;
|
|
243
|
+
this.render(existing);
|
|
244
|
+
existing.height = this.measure(existing.li);
|
|
245
|
+
this.restartTimer(existing);
|
|
246
|
+
this.relayout(existing.position);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const position = toast2.position ?? this.position;
|
|
250
|
+
const stack = this.stack(position);
|
|
251
|
+
const li = h("li", { slot: toastDef.slot("item"), data: { y: stack.y, x: stack.x }, attrs: { tabindex: 0 } });
|
|
252
|
+
const view = { toast: toast2, li, position, height: 0, removed: false, duration: 0, remaining: 0, started: 0, timer: null };
|
|
253
|
+
this.views.set(toast2.id, view);
|
|
254
|
+
this.byLi.set(li, view);
|
|
255
|
+
this.render(view);
|
|
256
|
+
stack.ol.prepend(li);
|
|
257
|
+
view.height = this.measure(li);
|
|
258
|
+
this.bindSwipe(view, stack);
|
|
259
|
+
this.restartTimer(view);
|
|
260
|
+
this.relayout(position);
|
|
261
|
+
requestAnimationFrame(() => li.setAttribute("data-mounted", ""));
|
|
262
|
+
}
|
|
263
|
+
render(view) {
|
|
264
|
+
const { toast: x, li } = view;
|
|
265
|
+
const opts = this.props.toastOptions ?? {};
|
|
266
|
+
const dismissible = x.dismissible ?? opts.dismissible ?? true;
|
|
267
|
+
li.className = [opts.className, x.className].filter(Boolean).join(" ");
|
|
268
|
+
li.setAttribute("data-type", x.type);
|
|
269
|
+
li.setAttribute("data-dismissible", String(dismissible));
|
|
270
|
+
li.toggleAttribute("data-rich-colors", x.richColors ?? opts.richColors ?? this.props.richColors ?? false);
|
|
271
|
+
li.toggleAttribute("data-invert", x.invert ?? opts.invert ?? this.props.invert ?? false);
|
|
272
|
+
li.replaceChildren();
|
|
273
|
+
if (dismissible && x.type !== "loading" && (x.closeButton ?? opts.closeButton ?? this.props.closeButton ?? false)) {
|
|
274
|
+
const close = h("button", {
|
|
275
|
+
slot: toastDef.slot("close"),
|
|
276
|
+
attrs: { type: "button", "aria-label": textOf(this.i18n, TEXT.close) },
|
|
277
|
+
on: { click: () => settle(x.id, "dismiss") }
|
|
278
|
+
});
|
|
279
|
+
close.append(this.icon(this.props.icons?.close ?? DEFAULT_ICONS.close));
|
|
280
|
+
li.append(close);
|
|
281
|
+
}
|
|
282
|
+
const icon = x.icon === null ? null : x.icon ?? (x.type === "default" ? null : this.props.icons?.[x.type] ?? DEFAULT_ICONS[x.type]);
|
|
283
|
+
if (icon !== null) li.append(h("div", { slot: toastDef.slot("icon"), data: { type: x.type } }, this.icon(icon)));
|
|
284
|
+
const content = h("div", { slot: toastDef.slot("content") });
|
|
285
|
+
const title = read(x.title);
|
|
286
|
+
if (title !== void 0) content.append(h("div", { slot: toastDef.slot("title") }, title));
|
|
287
|
+
const description = read(x.description);
|
|
288
|
+
if (description !== void 0) content.append(h("div", { slot: toastDef.slot("description") }, description));
|
|
289
|
+
li.append(content);
|
|
290
|
+
if (x.cancel) li.append(this.button(x, x.cancel, "cancel"));
|
|
291
|
+
if (x.action) li.append(this.button(x, x.action, "action"));
|
|
292
|
+
}
|
|
293
|
+
icon(icon) {
|
|
294
|
+
return typeof icon === "string" ? iconEl(icon, this.el.ownerDocument) : icon.cloneNode(true);
|
|
295
|
+
}
|
|
296
|
+
button(x, action, part) {
|
|
297
|
+
if (action instanceof Node) return action;
|
|
298
|
+
return h("button", {
|
|
299
|
+
slot: toastDef.slot(part),
|
|
300
|
+
attrs: { type: "button" },
|
|
301
|
+
text: action.label,
|
|
302
|
+
on: {
|
|
303
|
+
click: (e) => {
|
|
304
|
+
action.onClick(e);
|
|
305
|
+
if (part === "cancel" || !e.defaultPrevented) settle(x.id, "dismiss");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
/** The toast's natural height, whatever height the stack gives it. */
|
|
311
|
+
measure(li) {
|
|
312
|
+
const height = li.style.height;
|
|
313
|
+
li.style.height = "auto";
|
|
314
|
+
const natural = li.offsetHeight;
|
|
315
|
+
li.style.height = height;
|
|
316
|
+
return natural;
|
|
317
|
+
}
|
|
318
|
+
remove(view) {
|
|
319
|
+
if (view.removed) return;
|
|
320
|
+
view.removed = true;
|
|
321
|
+
if (view.timer) clearTimeout(view.timer);
|
|
322
|
+
view.timer = null;
|
|
323
|
+
const front = view.li.getAttribute("data-front") === "true" && !view.li.hasAttribute("data-swiped");
|
|
324
|
+
view.li.setAttribute("data-removed", front ? "front" : "");
|
|
325
|
+
this.views.delete(view.toast.id);
|
|
326
|
+
this.relayout(view.position);
|
|
327
|
+
setTimeout(() => view.li.remove(), EXIT_MS);
|
|
328
|
+
}
|
|
329
|
+
expanded(stack) {
|
|
330
|
+
return (this.props.expand ?? false) || stack.hovered || stack.interacting || this.hotkeyOpen;
|
|
331
|
+
}
|
|
332
|
+
relayoutAll() {
|
|
333
|
+
for (const position of this.stacks.keys()) this.relayout(position);
|
|
334
|
+
}
|
|
335
|
+
relayout(position) {
|
|
336
|
+
const stack = this.stacks.get(position);
|
|
337
|
+
if (!stack) return;
|
|
338
|
+
const items = [...stack.ol.children].flatMap((li) => {
|
|
339
|
+
const v = this.byLi.get(li);
|
|
340
|
+
return v && !v.removed ? [v] : [];
|
|
341
|
+
});
|
|
342
|
+
const expanded = this.expanded(stack);
|
|
343
|
+
const lift = stack.y === "bottom" ? -1 : 1;
|
|
344
|
+
const front = items[0]?.height ?? 0;
|
|
345
|
+
let offset = 0;
|
|
346
|
+
let extent = 0;
|
|
347
|
+
items.forEach((v, i) => {
|
|
348
|
+
const visible = i < this.visible;
|
|
349
|
+
const y = expanded ? lift * offset : lift * this.gap * i;
|
|
350
|
+
const scale = expanded ? 1 : 1 - i * 0.05;
|
|
351
|
+
const li = v.li;
|
|
352
|
+
li.style.setProperty("--_y", `${y}px`);
|
|
353
|
+
li.style.setProperty("--_scale", String(scale));
|
|
354
|
+
li.style.height = `${expanded || i === 0 ? v.height : front}px`;
|
|
355
|
+
li.style.zIndex = String(items.length - i);
|
|
356
|
+
li.setAttribute("data-index", String(i));
|
|
357
|
+
li.setAttribute("data-front", String(i === 0));
|
|
358
|
+
li.setAttribute("data-expanded", String(expanded));
|
|
359
|
+
li.setAttribute("data-visible", String(visible));
|
|
360
|
+
if (visible) extent = expanded ? offset + v.height : front + this.gap * i;
|
|
361
|
+
offset += v.height + this.gap;
|
|
362
|
+
});
|
|
363
|
+
stack.ol.style.height = `${extent}px`;
|
|
364
|
+
stack.ol.toggleAttribute("data-expanded", expanded);
|
|
365
|
+
this.syncTimers();
|
|
366
|
+
}
|
|
367
|
+
restartTimer(view) {
|
|
368
|
+
if (view.timer) clearTimeout(view.timer);
|
|
369
|
+
view.timer = null;
|
|
370
|
+
const opts = this.props.toastOptions ?? {};
|
|
371
|
+
view.duration = view.toast.type === "loading" ? Infinity : view.toast.duration ?? opts.duration ?? this.props.duration ?? 4e3;
|
|
372
|
+
view.remaining = view.duration;
|
|
373
|
+
view.started = 0;
|
|
374
|
+
if (!this.paused) this.runTimer(view);
|
|
375
|
+
}
|
|
376
|
+
runTimer(view) {
|
|
377
|
+
if (view.timer || view.removed || !Number.isFinite(view.remaining)) return;
|
|
378
|
+
view.started = Date.now();
|
|
379
|
+
view.timer = setTimeout(() => {
|
|
380
|
+
view.timer = null;
|
|
381
|
+
settle(view.toast.id, "auto");
|
|
382
|
+
}, view.remaining);
|
|
383
|
+
}
|
|
384
|
+
/** Timers stand still while a stack is spread out or held, and while the page is hidden. */
|
|
385
|
+
syncTimers() {
|
|
386
|
+
const paused = document.hidden || [...this.stacks.values()].some((s) => s.hovered || s.interacting) || this.hotkeyOpen;
|
|
387
|
+
if (paused === this.paused) return;
|
|
388
|
+
this.paused = paused;
|
|
389
|
+
for (const v of this.views.values()) {
|
|
390
|
+
if (paused) {
|
|
391
|
+
if (!v.timer) continue;
|
|
392
|
+
clearTimeout(v.timer);
|
|
393
|
+
v.timer = null;
|
|
394
|
+
v.remaining = Math.max(0, v.remaining - (Date.now() - v.started));
|
|
395
|
+
} else this.runTimer(v);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
bindSwipe(view, stack) {
|
|
399
|
+
const li = view.li;
|
|
400
|
+
const allowed = new Set(this.props.swipeDirections ?? [stack.y, ...stack.x === "center" ? [] : [this.physicalX(stack.x)]]);
|
|
401
|
+
let start = null;
|
|
402
|
+
let axis = null;
|
|
403
|
+
let amount = 0;
|
|
404
|
+
const reset = () => {
|
|
405
|
+
start = null;
|
|
406
|
+
axis = null;
|
|
407
|
+
amount = 0;
|
|
408
|
+
li.removeAttribute("data-swiping");
|
|
409
|
+
li.style.setProperty("--_swipe-x", "0px");
|
|
410
|
+
li.style.setProperty("--_swipe-y", "0px");
|
|
411
|
+
};
|
|
412
|
+
li.addEventListener("pointerdown", (e) => {
|
|
413
|
+
if (view.removed || li.getAttribute("data-dismissible") === "false" || view.toast.type === "loading") return;
|
|
414
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
415
|
+
if (e.target instanceof Element && e.target.closest("button, a, input, select, textarea")) return;
|
|
416
|
+
start = { x: e.clientX, y: e.clientY, time: Date.now() };
|
|
417
|
+
li.setPointerCapture(e.pointerId);
|
|
418
|
+
});
|
|
419
|
+
li.addEventListener("pointermove", (e) => {
|
|
420
|
+
if (!start) return;
|
|
421
|
+
const dx = e.clientX - start.x;
|
|
422
|
+
const dy = e.clientY - start.y;
|
|
423
|
+
if (!axis) {
|
|
424
|
+
if (Math.abs(dx) < 2 && Math.abs(dy) < 2) return;
|
|
425
|
+
axis = Math.abs(dx) > Math.abs(dy) ? "x" : "y";
|
|
426
|
+
li.setAttribute("data-swiping", "");
|
|
427
|
+
}
|
|
428
|
+
const delta = axis === "x" ? dx : dy;
|
|
429
|
+
const dir = axis === "x" ? delta > 0 ? "right" : "left" : delta > 0 ? "bottom" : "top";
|
|
430
|
+
amount = allowed.has(dir) ? delta : delta / (1.5 + Math.abs(delta) / 20);
|
|
431
|
+
li.style.setProperty(axis === "x" ? "--_swipe-x" : "--_swipe-y", `${amount}px`);
|
|
432
|
+
});
|
|
433
|
+
const end = () => {
|
|
434
|
+
if (!start) return;
|
|
435
|
+
const elapsed = Math.max(1, Date.now() - start.time);
|
|
436
|
+
const dir = axis === "x" ? amount > 0 ? "right" : "left" : axis === "y" ? amount > 0 ? "bottom" : "top" : null;
|
|
437
|
+
if (dir && allowed.has(dir) && (Math.abs(amount) >= SWIPE_THRESHOLD || Math.abs(amount) / elapsed > VELOCITY_THRESHOLD)) {
|
|
438
|
+
const out = (axis === "x" ? li.offsetWidth : li.offsetHeight) * Math.sign(amount);
|
|
439
|
+
li.removeAttribute("data-swiping");
|
|
440
|
+
li.setAttribute("data-swiped", "");
|
|
441
|
+
li.style.setProperty(axis === "x" ? "--_swipe-x" : "--_swipe-y", `${out}px`);
|
|
442
|
+
start = null;
|
|
443
|
+
settle(view.toast.id, "dismiss");
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
reset();
|
|
447
|
+
};
|
|
448
|
+
li.addEventListener("pointerup", end);
|
|
449
|
+
li.addEventListener("pointercancel", reset);
|
|
450
|
+
}
|
|
451
|
+
physicalX(x) {
|
|
452
|
+
const rtl = (this.props.dir === "rtl" || getComputedStyle(this.el.parentElement ?? document.documentElement).direction === "rtl") && this.props.dir !== "ltr";
|
|
453
|
+
return rtl ? x === "left" ? "right" : "left" : x;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
function read(content) {
|
|
457
|
+
return typeof content === "function" ? content() : content;
|
|
458
|
+
}
|
|
459
|
+
function createToaster(props = {}) {
|
|
460
|
+
return new ToasterImpl(props);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export { createToaster, toast, toastDef };
|
package/dist/toggle-group.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { variants } from './chunk-LZWZV2ZS.js';
|
|
2
|
-
import { iconEl } from './chunk-G7IQLY3A.js';
|
|
3
|
-
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-P4MTEMT7.js';
|
|
4
1
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
2
|
+
import { nextUid, runMachine, normalizeProps, spreadProps } from './chunk-P4MTEMT7.js';
|
|
3
|
+
import { iconEl } from './chunk-C3PXY2SW.js';
|
|
4
|
+
import { variants } from './chunk-LZWZV2ZS.js';
|
|
5
5
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
6
6
|
import { t } from './chunk-6QCILIT2.js';
|
|
7
7
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
8
|
-
import { css, defineStyles } from './chunk-
|
|
8
|
+
import { css, defineStyles } from './chunk-XBEL4K33.js';
|
|
9
9
|
import './chunk-2GQIZM5Z.js';
|
|
10
10
|
import './chunk-BXMWQIBO.js';
|
|
11
11
|
import './chunk-X66RJAIS.js';
|
package/dist/tooltip.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { zagPositioning, splitPlacement } from './chunk-3Q32K4PE.js';
|
|
2
|
-
import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-P4MTEMT7.js';
|
|
3
2
|
import { ownTeardown } from './chunk-A72NWYNP.js';
|
|
3
|
+
import { normalizeProps, nextUid, runMachine, spreadProps } from './chunk-P4MTEMT7.js';
|
|
4
4
|
import { h } from './chunk-Q6WTDVH6.js';
|
|
5
5
|
import { t } from './chunk-6QCILIT2.js';
|
|
6
6
|
import { defineComponent } from './chunk-VMCR3S2A.js';
|
|
7
|
-
import { defineStyles, css } from './chunk-
|
|
7
|
+
import { defineStyles, css } from './chunk-XBEL4K33.js';
|
|
8
8
|
import './chunk-2GQIZM5Z.js';
|
|
9
9
|
import './chunk-BXMWQIBO.js';
|
|
10
10
|
import './chunk-X66RJAIS.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { C as ComponentDef } from './define-D5u3F5Dj.js';
|
|
2
|
+
import { Translator } from './i18n.js';
|
|
3
|
+
import './t.js';
|
|
4
|
+
|
|
5
|
+
declare const treemapDef: ComponentDef<"treemap", "legend" | "map" | "root" | "tip" | "group" | "crumbs" | "crumb" | "group-name" | "group-value" | "tile" | "tile-label" | "tile-value" | "legend-bar", "up" | "down" | "radius" | "tip-radius" | "tip-shadow" | "tip-z" | "tip-bg" | "tile-bg" | "tint-min" | "tint-max" | "hover-z">;
|
|
6
|
+
interface TreemapItem {
|
|
7
|
+
/** Stable across updates: a tile keeps its element by id. */
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
/** The tile's share of the area (default 1, equal tiles); zero or less leaves it out. A
|
|
11
|
+
* group's share is the sum of its items'. */
|
|
12
|
+
weight?: number;
|
|
13
|
+
/** What the tile is tinted by and shows; null while it is unknown. */
|
|
14
|
+
value?: number | null;
|
|
15
|
+
/** The tile's ink instead of its value's tone: a token's `var()` (`t.accent.var`) or a color. */
|
|
16
|
+
color?: string;
|
|
17
|
+
/** The group's items: the item becomes a group. */
|
|
18
|
+
children?: readonly TreemapItem[];
|
|
19
|
+
}
|
|
20
|
+
/** How a group's header sums up its items' values, or a function of them. */
|
|
21
|
+
type TreemapGroupValue = 'median' | 'mean' | 'sum' | 'none' | ((values: readonly number[], group: TreemapItem) => number | null);
|
|
22
|
+
interface TreemapProps {
|
|
23
|
+
items?: readonly TreemapItem[];
|
|
24
|
+
/** The size of a value whose tint is full. Default: the largest one on the map. */
|
|
25
|
+
domain?: number;
|
|
26
|
+
/** A value as the tiles, the headers, the readout and the legend write it. Default: signed,
|
|
27
|
+
* two decimals. */
|
|
28
|
+
format?: (value: number) => string;
|
|
29
|
+
/** A group header's figure (default the median of its items' values). */
|
|
30
|
+
groupValue?: TreemapGroupValue;
|
|
31
|
+
/** The readout beside a hovered or focused tile, or `false` for none. Default: its label,
|
|
32
|
+
* value and groups. */
|
|
33
|
+
tip?: ((item: TreemapItem, path: readonly TreemapItem[]) => string | Node) | false;
|
|
34
|
+
/** A tile's click, Enter or Space. `path` lists its groups, outermost first. */
|
|
35
|
+
onSelect?: (item: TreemapItem, path: readonly TreemapItem[]) => void;
|
|
36
|
+
/** The id of the tile drawn as selected. */
|
|
37
|
+
selected?: string | null;
|
|
38
|
+
/** Group headers zoom into their group, and a breadcrumb above the map leads back. */
|
|
39
|
+
drill?: boolean;
|
|
40
|
+
/** A zoom changed: `path` is the zoomed group's path (empty at the top). */
|
|
41
|
+
onDrill?: (path: readonly TreemapItem[]) => void;
|
|
42
|
+
/** The breadcrumb's first entry (default "All"). */
|
|
43
|
+
rootLabel?: string;
|
|
44
|
+
/** A scale under the map, from the negative to the positive domain. */
|
|
45
|
+
legend?: boolean;
|
|
46
|
+
/** Space between tiles, in pixels (default 3). */
|
|
47
|
+
gap?: number;
|
|
48
|
+
/** The map's accessible name. */
|
|
49
|
+
label?: string;
|
|
50
|
+
/** The translator of the treemap's own words. Default: the kit build's, else English. */
|
|
51
|
+
i18n?: Translator | null;
|
|
52
|
+
/** Extra class names (layout hooks). */
|
|
53
|
+
className?: string;
|
|
54
|
+
}
|
|
55
|
+
interface TreemapHandle {
|
|
56
|
+
readonly el: HTMLElement;
|
|
57
|
+
/** New items: lays the map out again. A zoom stays on its group while the group exists. */
|
|
58
|
+
setData(items: readonly TreemapItem[]): void;
|
|
59
|
+
/** New values by id: repaints the tints, figures and readout without a new layout. */
|
|
60
|
+
setValues(values: ReadonlyMap<string, number | null> | Readonly<Record<string, number | null>>): void;
|
|
61
|
+
setSelected(id: string | null): void;
|
|
62
|
+
/** Zoom into a group by id, or back to the top with null. */
|
|
63
|
+
drillTo(id: string | null): void;
|
|
64
|
+
destroy(): void;
|
|
65
|
+
}
|
|
66
|
+
interface TreemapRect {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
w: number;
|
|
70
|
+
h: number;
|
|
71
|
+
}
|
|
72
|
+
/** Lay weighted items into `bounds` as tiles close to square (the squarified layout): areas
|
|
73
|
+
* follow the weights and fill the bounds exactly, heaviest first. Items weighing nothing are
|
|
74
|
+
* left out. */
|
|
75
|
+
declare function squarify<T extends {
|
|
76
|
+
weight: number;
|
|
77
|
+
}>(items: readonly T[], bounds: TreemapRect): Array<T & TreemapRect>;
|
|
78
|
+
declare function createTreemap(props?: TreemapProps): TreemapHandle;
|
|
79
|
+
|
|
80
|
+
export { type TreemapGroupValue, type TreemapHandle, type TreemapItem, type TreemapProps, type TreemapRect, createTreemap, squarify, treemapDef };
|