@20baht/ui 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +501 -2
- package/dist/components/baht-form.d.ts +191 -0
- package/dist/components/baht-form.js +614 -0
- package/dist/components/baht-workflow.d.ts +173 -0
- package/dist/components/baht-workflow.js +430 -0
- package/dist/components/base.d.ts +92 -0
- package/dist/components/base.js +138 -0
- package/dist/components/combobox-controller.d.ts +65 -0
- package/dist/components/combobox-controller.js +82 -0
- package/dist/components/define.d.ts +7 -0
- package/dist/components/define.js +16 -0
- package/dist/components/field-base.d.ts +84 -0
- package/dist/components/field-base.js +152 -0
- package/dist/components/floating.d.ts +84 -0
- package/dist/components/floating.js +182 -0
- package/dist/components/form-layout.d.ts +39 -0
- package/dist/components/form-layout.js +67 -0
- package/dist/components/form-options.d.ts +39 -0
- package/dist/components/form-options.js +65 -0
- package/dist/components/form-readonly.d.ts +20 -0
- package/dist/components/form-readonly.js +70 -0
- package/dist/components/layers.d.ts +4 -0
- package/dist/components/layers.js +15 -0
- package/dist/components/menu-controller.d.ts +65 -0
- package/dist/components/menu-controller.js +134 -0
- package/dist/components/motion.d.ts +9 -0
- package/dist/components/motion.js +16 -0
- package/dist/components/primitives/baht-accordion.d.ts +29 -0
- package/dist/components/primitives/baht-accordion.js +66 -0
- package/dist/components/primitives/baht-alert.d.ts +20 -0
- package/dist/components/primitives/baht-alert.js +62 -0
- package/dist/components/primitives/baht-app-shell.d.ts +81 -0
- package/dist/components/primitives/baht-app-shell.js +161 -0
- package/dist/components/primitives/baht-approval-chain.d.ts +59 -0
- package/dist/components/primitives/baht-approval-chain.js +80 -0
- package/dist/components/primitives/baht-avatar.d.ts +19 -0
- package/dist/components/primitives/baht-avatar.js +43 -0
- package/dist/components/primitives/baht-badge.d.ts +24 -0
- package/dist/components/primitives/baht-badge.js +41 -0
- package/dist/components/primitives/baht-bar-chart.d.ts +78 -0
- package/dist/components/primitives/baht-bar-chart.js +361 -0
- package/dist/components/primitives/baht-breadcrumbs.d.ts +23 -0
- package/dist/components/primitives/baht-breadcrumbs.js +45 -0
- package/dist/components/primitives/baht-button.d.ts +89 -0
- package/dist/components/primitives/baht-button.js +146 -0
- package/dist/components/primitives/baht-calendar.d.ts +96 -0
- package/dist/components/primitives/baht-calendar.js +398 -0
- package/dist/components/primitives/baht-card.d.ts +34 -0
- package/dist/components/primitives/baht-card.js +70 -0
- package/dist/components/primitives/baht-catalog-card.d.ts +52 -0
- package/dist/components/primitives/baht-catalog-card.js +90 -0
- package/dist/components/primitives/baht-checkbox.d.ts +7 -0
- package/dist/components/primitives/baht-checkbox.js +40 -0
- package/dist/components/primitives/baht-choice-group.d.ts +52 -0
- package/dist/components/primitives/baht-choice-group.js +71 -0
- package/dist/components/primitives/baht-code.d.ts +18 -0
- package/dist/components/primitives/baht-code.js +33 -0
- package/dist/components/primitives/baht-column-picker.d.ts +69 -0
- package/dist/components/primitives/baht-column-picker.js +234 -0
- package/dist/components/primitives/baht-comments.d.ts +38 -0
- package/dist/components/primitives/baht-comments.js +102 -0
- package/dist/components/primitives/baht-currency.d.ts +13 -0
- package/dist/components/primitives/baht-currency.js +69 -0
- package/dist/components/primitives/baht-datepicker.d.ts +77 -0
- package/dist/components/primitives/baht-datepicker.js +235 -0
- package/dist/components/primitives/baht-donut-chart.d.ts +24 -0
- package/dist/components/primitives/baht-donut-chart.js +88 -0
- package/dist/components/primitives/baht-edit-table.d.ts +45 -0
- package/dist/components/primitives/baht-edit-table.js +176 -0
- package/dist/components/primitives/baht-empty-state.d.ts +26 -0
- package/dist/components/primitives/baht-empty-state.js +51 -0
- package/dist/components/primitives/baht-error-state.d.ts +21 -0
- package/dist/components/primitives/baht-error-state.js +44 -0
- package/dist/components/primitives/baht-facts.d.ts +42 -0
- package/dist/components/primitives/baht-facts.js +49 -0
- package/dist/components/primitives/baht-fieldset.d.ts +19 -0
- package/dist/components/primitives/baht-fieldset.js +42 -0
- package/dist/components/primitives/baht-file.d.ts +27 -0
- package/dist/components/primitives/baht-file.js +158 -0
- package/dist/components/primitives/baht-filter-builder.d.ts +39 -0
- package/dist/components/primitives/baht-filter-builder.js +201 -0
- package/dist/components/primitives/baht-filter.d.ts +36 -0
- package/dist/components/primitives/baht-filter.js +64 -0
- package/dist/components/primitives/baht-heatmap.d.ts +49 -0
- package/dist/components/primitives/baht-heatmap.js +168 -0
- package/dist/components/primitives/baht-input.d.ts +10 -0
- package/dist/components/primitives/baht-input.js +44 -0
- package/dist/components/primitives/baht-keyvalue-editor.d.ts +28 -0
- package/dist/components/primitives/baht-keyvalue-editor.js +106 -0
- package/dist/components/primitives/baht-line-chart.d.ts +45 -0
- package/dist/components/primitives/baht-line-chart.js +183 -0
- package/dist/components/primitives/baht-link.d.ts +26 -0
- package/dist/components/primitives/baht-link.js +48 -0
- package/dist/components/primitives/baht-list.d.ts +29 -0
- package/dist/components/primitives/baht-list.js +79 -0
- package/dist/components/primitives/baht-loading-overlay.d.ts +15 -0
- package/dist/components/primitives/baht-loading-overlay.js +33 -0
- package/dist/components/primitives/baht-markdown-view.d.ts +17 -0
- package/dist/components/primitives/baht-markdown-view.js +39 -0
- package/dist/components/primitives/baht-markdown.d.ts +34 -0
- package/dist/components/primitives/baht-markdown.js +177 -0
- package/dist/components/primitives/baht-menu.d.ts +53 -0
- package/dist/components/primitives/baht-menu.js +100 -0
- package/dist/components/primitives/baht-meter.d.ts +67 -0
- package/dist/components/primitives/baht-meter.js +107 -0
- package/dist/components/primitives/baht-modal.d.ts +71 -0
- package/dist/components/primitives/baht-modal.js +164 -0
- package/dist/components/primitives/baht-multiselect.d.ts +8 -0
- package/dist/components/primitives/baht-multiselect.js +47 -0
- package/dist/components/primitives/baht-notification-bell.d.ts +54 -0
- package/dist/components/primitives/baht-notification-bell.js +143 -0
- package/dist/components/primitives/baht-number.d.ts +5 -0
- package/dist/components/primitives/baht-number.js +39 -0
- package/dist/components/primitives/baht-order-box.d.ts +24 -0
- package/dist/components/primitives/baht-order-box.js +50 -0
- package/dist/components/primitives/baht-otp.d.ts +49 -0
- package/dist/components/primitives/baht-otp.js +109 -0
- package/dist/components/primitives/baht-page-header.d.ts +43 -0
- package/dist/components/primitives/baht-page-header.js +78 -0
- package/dist/components/primitives/baht-pagination.d.ts +33 -0
- package/dist/components/primitives/baht-pagination.js +86 -0
- package/dist/components/primitives/baht-popover.d.ts +45 -0
- package/dist/components/primitives/baht-popover.js +112 -0
- package/dist/components/primitives/baht-progress-ring.d.ts +22 -0
- package/dist/components/primitives/baht-progress-ring.js +62 -0
- package/dist/components/primitives/baht-progress.d.ts +17 -0
- package/dist/components/primitives/baht-progress.js +48 -0
- package/dist/components/primitives/baht-radio.d.ts +7 -0
- package/dist/components/primitives/baht-radio.js +74 -0
- package/dist/components/primitives/baht-range.d.ts +38 -0
- package/dist/components/primitives/baht-range.js +88 -0
- package/dist/components/primitives/baht-rating.d.ts +40 -0
- package/dist/components/primitives/baht-rating.js +107 -0
- package/dist/components/primitives/baht-record-bar.d.ts +30 -0
- package/dist/components/primitives/baht-record-bar.js +60 -0
- package/dist/components/primitives/baht-reference-dialog.d.ts +87 -0
- package/dist/components/primitives/baht-reference-dialog.js +418 -0
- package/dist/components/primitives/baht-reference-picker.d.ts +110 -0
- package/dist/components/primitives/baht-reference-picker.js +321 -0
- package/dist/components/primitives/baht-repeater.d.ts +59 -0
- package/dist/components/primitives/baht-repeater.js +315 -0
- package/dist/components/primitives/baht-rule-builder.d.ts +24 -0
- package/dist/components/primitives/baht-rule-builder.js +177 -0
- package/dist/components/primitives/baht-saved-filters.d.ts +41 -0
- package/dist/components/primitives/baht-saved-filters.js +126 -0
- package/dist/components/primitives/baht-search.d.ts +34 -0
- package/dist/components/primitives/baht-search.js +71 -0
- package/dist/components/primitives/baht-section-header.d.ts +28 -0
- package/dist/components/primitives/baht-section-header.js +48 -0
- package/dist/components/primitives/baht-section.d.ts +23 -0
- package/dist/components/primitives/baht-section.js +49 -0
- package/dist/components/primitives/baht-select.d.ts +49 -0
- package/dist/components/primitives/baht-select.js +197 -0
- package/dist/components/primitives/baht-skeleton.d.ts +16 -0
- package/dist/components/primitives/baht-skeleton.js +37 -0
- package/dist/components/primitives/baht-sparkline.d.ts +23 -0
- package/dist/components/primitives/baht-sparkline.js +56 -0
- package/dist/components/primitives/baht-spinner.d.ts +13 -0
- package/dist/components/primitives/baht-spinner.js +30 -0
- package/dist/components/primitives/baht-split-button.d.ts +43 -0
- package/dist/components/primitives/baht-split-button.js +87 -0
- package/dist/components/primitives/baht-stat-chart.d.ts +14 -0
- package/dist/components/primitives/baht-stat-chart.js +38 -0
- package/dist/components/primitives/baht-stat.d.ts +56 -0
- package/dist/components/primitives/baht-stat.js +117 -0
- package/dist/components/primitives/baht-steps.d.ts +33 -0
- package/dist/components/primitives/baht-steps.js +60 -0
- package/dist/components/primitives/baht-swipe-row.d.ts +64 -0
- package/dist/components/primitives/baht-swipe-row.js +178 -0
- package/dist/components/primitives/baht-table.d.ts +315 -0
- package/dist/components/primitives/baht-table.js +640 -0
- package/dist/components/primitives/baht-tabs.d.ts +54 -0
- package/dist/components/primitives/baht-tabs.js +128 -0
- package/dist/components/primitives/baht-tags.d.ts +96 -0
- package/dist/components/primitives/baht-tags.js +323 -0
- package/dist/components/primitives/baht-text.d.ts +10 -0
- package/dist/components/primitives/baht-text.js +29 -0
- package/dist/components/primitives/baht-textarea.d.ts +5 -0
- package/dist/components/primitives/baht-textarea.js +40 -0
- package/dist/components/primitives/baht-theme-toggle.d.ts +44 -0
- package/dist/components/primitives/baht-theme-toggle.js +101 -0
- package/dist/components/primitives/baht-timeline.d.ts +21 -0
- package/dist/components/primitives/baht-timeline.js +42 -0
- package/dist/components/primitives/baht-toast.d.ts +29 -0
- package/dist/components/primitives/baht-toast.js +83 -0
- package/dist/components/primitives/baht-toggle.d.ts +6 -0
- package/dist/components/primitives/baht-toggle.js +42 -0
- package/dist/components/primitives/baht-tooltip.d.ts +34 -0
- package/dist/components/primitives/baht-tooltip.js +85 -0
- package/dist/components/primitives/baht-tree.d.ts +58 -0
- package/dist/components/primitives/baht-tree.js +159 -0
- package/dist/components/primitives/baht-typeahead.d.ts +92 -0
- package/dist/components/primitives/baht-typeahead.js +258 -0
- package/dist/components/primitives/baht-upload.d.ts +108 -0
- package/dist/components/primitives/baht-upload.js +325 -0
- package/dist/components/primitives/baht-wizard.d.ts +57 -0
- package/dist/components/primitives/baht-wizard.js +147 -0
- package/dist/components/primitives/charts.d.ts +134 -0
- package/dist/components/primitives/charts.js +184 -0
- package/dist/components/primitives/column-map.d.ts +56 -0
- package/dist/components/primitives/column-map.js +70 -0
- package/dist/components/primitives/control-icons.d.ts +2 -0
- package/dist/components/primitives/control-icons.js +40 -0
- package/dist/components/primitives/icons.d.ts +24 -0
- package/dist/components/primitives/icons.js +86 -0
- package/dist/components/primitives/illustrations.d.ts +21 -0
- package/dist/components/primitives/illustrations.js +78 -0
- package/dist/components/primitives/index.d.ts +89 -0
- package/dist/components/primitives/kbd.d.ts +6 -0
- package/dist/components/primitives/kbd.js +9 -0
- package/dist/components/primitives/listbox.d.ts +2 -0
- package/dist/components/primitives/listbox.js +7 -0
- package/dist/components/primitives/markdown-render.d.ts +9 -0
- package/dist/components/primitives/markdown-render.js +77 -0
- package/dist/components/primitives/rule-rows.d.ts +55 -0
- package/dist/components/primitives/rule-rows.js +75 -0
- package/dist/components/primitives/tag-map.d.ts +6 -0
- package/dist/components/primitives/tag-map.js +39 -0
- package/dist/components/reference-labels.d.ts +22 -0
- package/dist/components/reference-labels.js +29 -0
- package/dist/components/shortcuts.d.ts +7 -0
- package/dist/components/shortcuts.js +43 -0
- package/dist/css/components.css +7517 -0
- package/dist/css/datepicker.css +346 -0
- package/dist/css/tokens.css +679 -0
- package/dist/custom-elements.json +45110 -0
- package/dist/engine.d.ts +1 -0
- package/dist/engine.js +1 -0
- package/dist/hydrate.d.ts +9 -0
- package/dist/hydrate.js +46 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +210 -0
- package/dist/overlay.d.ts +50 -0
- package/dist/overlay.js +140 -0
- package/dist/react.d.ts +557 -0
- package/dist/react.js +1 -0
- package/dist/register.d.ts +106 -0
- package/dist/register.js +99 -0
- package/dist/ssr.d.ts +16 -0
- package/dist/ssr.js +125 -0
- package/dist/tokens.css +8197 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +2261 -0
- package/dist/web-types.json +6523 -0
- package/package.json +157 -4
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { nothing as l, html as h } from "lit";
|
|
2
|
+
import { state as d } from "lit/decorators.js";
|
|
3
|
+
import { stringOf as p } from "../base.js";
|
|
4
|
+
import { ComboboxController as b } from "../combobox-controller.js";
|
|
5
|
+
import { BahtFieldBase as f } from "../field-base.js";
|
|
6
|
+
import { t as u } from "@20baht/engine";
|
|
7
|
+
import { renderIcon as m } from "./icons.js";
|
|
8
|
+
import { customElement as v } from "../define.js";
|
|
9
|
+
import { floatPanel as y } from "../floating.js";
|
|
10
|
+
var $ = Object.defineProperty, w = Object.getOwnPropertyDescriptor, c = (t, e, a, s) => {
|
|
11
|
+
for (var i = s > 1 ? void 0 : s ? w(e, a) : e, o = t.length - 1, r; o >= 0; o--)
|
|
12
|
+
(r = t[o]) && (i = (s ? r(e, a, i) : r(i)) || i);
|
|
13
|
+
return s && i && $(e, a, i), i;
|
|
14
|
+
};
|
|
15
|
+
const g = 500;
|
|
16
|
+
let n = class extends f {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(), this.open = !1, this.active = 0, this.typeBuffer = "", this.combo = new b(this, {
|
|
19
|
+
onOutside: () => {
|
|
20
|
+
this.close();
|
|
21
|
+
}
|
|
22
|
+
}), y(this, { panel: ".baht-select-list", fit: !0, gap: 2 });
|
|
23
|
+
}
|
|
24
|
+
get listId() {
|
|
25
|
+
return `${this.controlId}-list`;
|
|
26
|
+
}
|
|
27
|
+
optionId(t) {
|
|
28
|
+
return `${this.listId}-${t}`;
|
|
29
|
+
}
|
|
30
|
+
/** Placeholder row first (picks `null`), then the field's options. */
|
|
31
|
+
get rows() {
|
|
32
|
+
return [
|
|
33
|
+
{ key: "", label: this.field.empty_label ?? this.field.placeholder ?? u("choose") },
|
|
34
|
+
...this.field.options ?? []
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
get currentKey() {
|
|
38
|
+
return p(this.value);
|
|
39
|
+
}
|
|
40
|
+
get selectedIndex() {
|
|
41
|
+
const t = this.rows.findIndex((e) => e.key === this.currentKey);
|
|
42
|
+
return t < 0 ? 0 : t;
|
|
43
|
+
}
|
|
44
|
+
get interactive() {
|
|
45
|
+
return !this.disabled && !this.readonly;
|
|
46
|
+
}
|
|
47
|
+
willUpdate(t) {
|
|
48
|
+
super.willUpdate(t), this.assignedField && t.has("value") && !this.open && (this.active = this.selectedIndex);
|
|
49
|
+
}
|
|
50
|
+
updated() {
|
|
51
|
+
if (!this.open) return;
|
|
52
|
+
const t = this.querySelector(`#${this.optionId(this.active)}`);
|
|
53
|
+
t == null || t.scrollIntoView({ block: "nearest" });
|
|
54
|
+
}
|
|
55
|
+
openList() {
|
|
56
|
+
!this.interactive || this.open || (this.active = this.selectedIndex, this.open = !0, this.combo.watchOutside());
|
|
57
|
+
}
|
|
58
|
+
close() {
|
|
59
|
+
this.open && (this.open = !1, this.combo.unwatchOutside());
|
|
60
|
+
}
|
|
61
|
+
toggle() {
|
|
62
|
+
this.open ? this.close() : this.openList();
|
|
63
|
+
}
|
|
64
|
+
commit(t) {
|
|
65
|
+
const e = this.rows[t];
|
|
66
|
+
this.close(), e && this.emitInput(e.key === "" ? null : e.key);
|
|
67
|
+
}
|
|
68
|
+
highlight(t) {
|
|
69
|
+
this.active !== t && (this.active = t);
|
|
70
|
+
}
|
|
71
|
+
/** ArrowUp/Down/Home/End: stops at the ends (a native select does not wrap). */
|
|
72
|
+
move(t) {
|
|
73
|
+
const e = this.combo.nextActive(t, this.active, this.rows.length, {
|
|
74
|
+
wrap: !1,
|
|
75
|
+
homeEnd: !0
|
|
76
|
+
});
|
|
77
|
+
e !== void 0 && (this.active = e);
|
|
78
|
+
}
|
|
79
|
+
/** Type-to-select: first option (after the highlighted one) starting with the buffer. */
|
|
80
|
+
typeahead(t) {
|
|
81
|
+
this.typeBuffer += t.toLowerCase(), this.combo.schedule(() => {
|
|
82
|
+
this.typeBuffer = "";
|
|
83
|
+
}, g);
|
|
84
|
+
const e = this.rows, a = this.typeBuffer.length === 1 ? this.active + 1 : this.active;
|
|
85
|
+
for (let s = 0; s < e.length; s++) {
|
|
86
|
+
const i = (a + s) % e.length;
|
|
87
|
+
if (i !== 0 && e[i].label.toLowerCase().startsWith(this.typeBuffer)) {
|
|
88
|
+
this.open ? this.active = i : this.commit(i);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
onKeydown(t) {
|
|
94
|
+
if (!this.interactive) return;
|
|
95
|
+
const { key: e } = t;
|
|
96
|
+
if (!this.open) {
|
|
97
|
+
e === "ArrowDown" || e === "ArrowUp" || e === "Enter" || e === " " ? (t.preventDefault(), this.openList()) : e === "Home" || e === "End" ? (t.preventDefault(), this.commit(e === "Home" ? Math.min(1, this.rows.length - 1) : this.rows.length - 1)) : e.length === 1 && !t.altKey && !t.ctrlKey && !t.metaKey && this.typeahead(e);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
switch (e) {
|
|
101
|
+
case "ArrowDown":
|
|
102
|
+
case "ArrowUp":
|
|
103
|
+
case "Home":
|
|
104
|
+
case "End":
|
|
105
|
+
t.preventDefault(), this.move(e);
|
|
106
|
+
break;
|
|
107
|
+
case "Enter":
|
|
108
|
+
case " ":
|
|
109
|
+
t.preventDefault(), this.commit(this.active);
|
|
110
|
+
break;
|
|
111
|
+
case "Escape":
|
|
112
|
+
t.preventDefault(), this.close();
|
|
113
|
+
break;
|
|
114
|
+
case "Tab":
|
|
115
|
+
this.commit(this.active);
|
|
116
|
+
break;
|
|
117
|
+
default:
|
|
118
|
+
e.length === 1 && !t.altKey && !t.ctrlKey && !t.metaKey && this.typeahead(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
renderControl() {
|
|
122
|
+
const t = this.rows, e = this.selectedIndex, a = e === 0 && this.field.empty_label === void 0, s = t[e];
|
|
123
|
+
return h`<div class="baht-select${this.open ? " baht-select--open" : ""}">
|
|
124
|
+
<button
|
|
125
|
+
type="button"
|
|
126
|
+
class="baht-control baht-control--select baht-select-trigger${a ? " baht-select-trigger--placeholder" : ""}"
|
|
127
|
+
id=${this.controlId}
|
|
128
|
+
role="combobox"
|
|
129
|
+
aria-haspopup="listbox"
|
|
130
|
+
aria-expanded=${this.open ? "true" : "false"}
|
|
131
|
+
aria-controls=${this.listId}
|
|
132
|
+
aria-labelledby=${this.field.label ? this.labelId : l}
|
|
133
|
+
aria-activedescendant=${this.open ? this.optionId(this.active) : l}
|
|
134
|
+
aria-required=${this.required ? "true" : l}
|
|
135
|
+
aria-invalid=${this.invalidAttr}
|
|
136
|
+
aria-describedby=${this.describedBy}
|
|
137
|
+
?disabled=${this.disabled}
|
|
138
|
+
aria-readonly=${this.readonly && !this.disabled ? "true" : l}
|
|
139
|
+
@click=${() => {
|
|
140
|
+
this.toggle();
|
|
141
|
+
}}
|
|
142
|
+
@keydown=${(i) => {
|
|
143
|
+
this.onKeydown(i);
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
${this.renderFieldIcon()}
|
|
147
|
+
<span class="baht-select-value">${s == null ? void 0 : s.label}</span>
|
|
148
|
+
${s != null && s.description ? h`<span class="baht-select-desc">${s.description}</span>` : l}
|
|
149
|
+
<span class="baht-select-chevron" aria-hidden="true">${m("chevron-down")}</span>
|
|
150
|
+
</button>
|
|
151
|
+
<div
|
|
152
|
+
class="baht-listbox baht-select-list"
|
|
153
|
+
id=${this.listId}
|
|
154
|
+
role="listbox"
|
|
155
|
+
aria-labelledby=${this.field.label ? this.labelId : l}
|
|
156
|
+
?hidden=${!this.open}
|
|
157
|
+
>
|
|
158
|
+
${t.map(
|
|
159
|
+
// eslint-disable-next-line lit-a11y/click-events-have-key-events -- keyboard lives on the combobox (aria-activedescendant pattern); options are never focused
|
|
160
|
+
(i, o) => h`<div
|
|
161
|
+
class="baht-listbox-option${o === this.active ? " baht-listbox-option--active" : ""}${o === 0 && this.field.empty_label === void 0 ? " baht-listbox-option--placeholder" : ""}"
|
|
162
|
+
id=${this.optionId(o)}
|
|
163
|
+
role="option"
|
|
164
|
+
aria-selected=${o === e ? "true" : "false"}
|
|
165
|
+
data-key=${i.key}
|
|
166
|
+
@mousedown=${(r) => {
|
|
167
|
+
r.preventDefault();
|
|
168
|
+
}}
|
|
169
|
+
@mousemove=${() => {
|
|
170
|
+
this.highlight(o);
|
|
171
|
+
}}
|
|
172
|
+
@click=${() => {
|
|
173
|
+
this.commit(o);
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
${i.description ? h`<span class="baht-listbox-option-text"
|
|
177
|
+
><span class="baht-listbox-option-label">${i.label}</span
|
|
178
|
+
><span class="baht-listbox-option-desc">${i.description}</span></span
|
|
179
|
+
>` : i.label}
|
|
180
|
+
</div>`
|
|
181
|
+
)}
|
|
182
|
+
</div>
|
|
183
|
+
</div>`;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
c([
|
|
187
|
+
d()
|
|
188
|
+
], n.prototype, "open", 2);
|
|
189
|
+
c([
|
|
190
|
+
d()
|
|
191
|
+
], n.prototype, "active", 2);
|
|
192
|
+
n = c([
|
|
193
|
+
v("baht-select")
|
|
194
|
+
], n);
|
|
195
|
+
export {
|
|
196
|
+
n as BahtSelect
|
|
197
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loading placeholder (opacity pulse — the 20baht system bans gradients in
|
|
5
|
+
* core UI, so no shimmer).
|
|
6
|
+
*
|
|
7
|
+
* <baht-skeleton variant="text" width="60%"></baht-skeleton>
|
|
8
|
+
* <baht-skeleton variant="circle" width="40px" height="40px"></baht-skeleton>
|
|
9
|
+
* <baht-skeleton height="120px"></baht-skeleton>
|
|
10
|
+
*/
|
|
11
|
+
export declare class BahtSkeleton extends BahtElement {
|
|
12
|
+
variant: 'rect' | 'text' | 'circle';
|
|
13
|
+
width: string;
|
|
14
|
+
height: string;
|
|
15
|
+
protected render(): TemplateResult;
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { html as l } from "lit";
|
|
2
|
+
import { property as p } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as m } from "../base.js";
|
|
4
|
+
import { customElement as v } from "../define.js";
|
|
5
|
+
var c = Object.defineProperty, f = Object.getOwnPropertyDescriptor, i = (s, e, o, h) => {
|
|
6
|
+
for (var t = h > 1 ? void 0 : h ? f(e, o) : e, a = s.length - 1, n; a >= 0; a--)
|
|
7
|
+
(n = s[a]) && (t = (h ? n(e, o, t) : n(t)) || t);
|
|
8
|
+
return h && t && c(e, o, t), t;
|
|
9
|
+
};
|
|
10
|
+
let r = class extends m {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.variant = "rect", this.width = "100%", this.height = "";
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
const s = this.height || (this.variant === "text" ? "1em" : "20px"), e = this.variant === "rect" ? "" : ` baht-skeleton--${this.variant}`;
|
|
16
|
+
return l`<span
|
|
17
|
+
class="baht-skeleton${e}"
|
|
18
|
+
style="width:${this.width}; height:${s};"
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
></span>`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
i([
|
|
24
|
+
p()
|
|
25
|
+
], r.prototype, "variant", 2);
|
|
26
|
+
i([
|
|
27
|
+
p()
|
|
28
|
+
], r.prototype, "width", 2);
|
|
29
|
+
i([
|
|
30
|
+
p()
|
|
31
|
+
], r.prototype, "height", 2);
|
|
32
|
+
r = i([
|
|
33
|
+
v("baht-skeleton")
|
|
34
|
+
], r);
|
|
35
|
+
export {
|
|
36
|
+
r as BahtSkeleton
|
|
37
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Micro trend line — no axes, no ticks, no tooltip. Used inside `<baht-stat>`
|
|
5
|
+
* and anywhere a number needs its recent shape beside it.
|
|
6
|
+
*
|
|
7
|
+
* <baht-sparkline values="[4,7,6,9,12]" accent-last></baht-sparkline>
|
|
8
|
+
*/
|
|
9
|
+
export declare class BahtSparkline extends BahtElement {
|
|
10
|
+
/** The points, oldest first. Fewer than two points renders nothing. */
|
|
11
|
+
values: number[];
|
|
12
|
+
/** Drawing width in px. */
|
|
13
|
+
width: number;
|
|
14
|
+
/** Drawing height in px. */
|
|
15
|
+
height: number;
|
|
16
|
+
/** Mark the newest point with an accent dot. */
|
|
17
|
+
accentLast: boolean;
|
|
18
|
+
/** Line color; defaults to the de-emphasis chart token. */
|
|
19
|
+
color: string;
|
|
20
|
+
/** Accessible name; falls back to a plain "Trend of N points" sentence. */
|
|
21
|
+
label: string;
|
|
22
|
+
protected render(): TemplateResult | typeof nothing;
|
|
23
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { nothing as m, svg as u, html as d } from "lit";
|
|
2
|
+
import { property as h } from "lit/decorators.js";
|
|
3
|
+
import { boolOff as w, BahtElement as _, arr as F } from "../base.js";
|
|
4
|
+
import { linearScale as b } from "./charts.js";
|
|
5
|
+
import { customElement as O } from "../define.js";
|
|
6
|
+
var M = Object.defineProperty, P = Object.getOwnPropertyDescriptor, i = (t, o, a, r) => {
|
|
7
|
+
for (var e = r > 1 ? void 0 : r ? P(o, a) : o, n = t.length - 1, l; n >= 0; n--)
|
|
8
|
+
(l = t[n]) && (e = (r ? l(o, a, e) : l(e)) || e);
|
|
9
|
+
return r && e && M(o, a, e), e;
|
|
10
|
+
};
|
|
11
|
+
let s = class extends _ {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.values = [], this.width = 96, this.height = 24, this.accentLast = !0, this.color = "", this.label = "";
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
const t = F(this.values).filter((c) => Number.isFinite(c));
|
|
17
|
+
if (t.length < 2) return m;
|
|
18
|
+
const o = Math.max(16, this.width), a = Math.max(8, this.height), r = 3, e = Math.min(...t), n = Math.max(...t), l = b([0, t.length - 1], [r, o - r]), p = b([e, n === e ? e + 1 : n], [a - r, r]), f = t.map((c, x) => `${l(x).toFixed(2)},${p(c).toFixed(2)}`).join(" "), v = l(t.length - 1), g = p(t[t.length - 1]), y = this.color || "var(--baht-chart-muted)", $ = this.label || `Trend of ${t.length} points`;
|
|
19
|
+
return d`<svg
|
|
20
|
+
class="baht-sparkline"
|
|
21
|
+
width=${o}
|
|
22
|
+
height=${a}
|
|
23
|
+
viewBox="0 0 ${o} ${a}"
|
|
24
|
+
role="img"
|
|
25
|
+
aria-label=${$}
|
|
26
|
+
>
|
|
27
|
+
${u`<polyline class="baht-sparkline-line" points=${f} fill="none" stroke=${y}/>`}
|
|
28
|
+
${this.accentLast ? u`<circle class="baht-sparkline-dot" cx=${v.toFixed(2)} cy=${g.toFixed(2)} r="3"
|
|
29
|
+
fill="var(--baht-chart-1)"/>` : m}
|
|
30
|
+
</svg>`;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
i([
|
|
34
|
+
h({ type: Array })
|
|
35
|
+
], s.prototype, "values", 2);
|
|
36
|
+
i([
|
|
37
|
+
h({ type: Number })
|
|
38
|
+
], s.prototype, "width", 2);
|
|
39
|
+
i([
|
|
40
|
+
h({ type: Number })
|
|
41
|
+
], s.prototype, "height", 2);
|
|
42
|
+
i([
|
|
43
|
+
h({ attribute: "accent-last", converter: w })
|
|
44
|
+
], s.prototype, "accentLast", 2);
|
|
45
|
+
i([
|
|
46
|
+
h()
|
|
47
|
+
], s.prototype, "color", 2);
|
|
48
|
+
i([
|
|
49
|
+
h()
|
|
50
|
+
], s.prototype, "label", 2);
|
|
51
|
+
s = i([
|
|
52
|
+
O("baht-sparkline")
|
|
53
|
+
], s);
|
|
54
|
+
export {
|
|
55
|
+
s as BahtSparkline
|
|
56
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Loading spinner — the single animated icon the 20baht system allows.
|
|
5
|
+
*
|
|
6
|
+
* <baht-spinner></baht-spinner>
|
|
7
|
+
* <baht-spinner size="lg"></baht-spinner>
|
|
8
|
+
*/
|
|
9
|
+
export declare class BahtSpinner extends BahtElement {
|
|
10
|
+
size: 'sm' | 'md' | 'lg';
|
|
11
|
+
label: string;
|
|
12
|
+
protected render(): TemplateResult;
|
|
13
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { html as m } from "lit";
|
|
2
|
+
import { property as l } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as h } from "../base.js";
|
|
4
|
+
import { customElement as b } from "../define.js";
|
|
5
|
+
var f = Object.defineProperty, c = Object.getOwnPropertyDescriptor, i = (r, t, o, s) => {
|
|
6
|
+
for (var e = s > 1 ? void 0 : s ? c(t, o) : t, n = r.length - 1, a; n >= 0; n--)
|
|
7
|
+
(a = r[n]) && (e = (s ? a(t, o, e) : a(e)) || e);
|
|
8
|
+
return s && e && f(t, o, e), e;
|
|
9
|
+
};
|
|
10
|
+
let p = class extends h {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.size = "md", this.label = "Loading";
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
const r = this.size === "md" ? "" : ` baht-spinner--${this.size}`;
|
|
16
|
+
return m`<span class="baht-spinner${r}" role="status" aria-label=${this.label}></span>`;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
i([
|
|
20
|
+
l()
|
|
21
|
+
], p.prototype, "size", 2);
|
|
22
|
+
i([
|
|
23
|
+
l()
|
|
24
|
+
], p.prototype, "label", 2);
|
|
25
|
+
p = i([
|
|
26
|
+
b("baht-spinner")
|
|
27
|
+
], p);
|
|
28
|
+
export {
|
|
29
|
+
p as BahtSpinner
|
|
30
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { ButtonSize, ButtonVariant } from './baht-button.js';
|
|
4
|
+
import { MenuItem } from '../menu-controller.js';
|
|
5
|
+
export type { MenuItem } from '../menu-controller.js';
|
|
6
|
+
/**
|
|
7
|
+
* Split button: a main action plus a ▾ toggle that opens a menu of related actions
|
|
8
|
+
* (NOTES 2026-10-31). Each action can carry a keyboard `shortcut` — the main one shows
|
|
9
|
+
* in the main button's tooltip, item ones as a right-aligned hint in the menu — and all
|
|
10
|
+
* of them are bound document-wide (same scoping as `<baht-button shortcut>`).
|
|
11
|
+
*
|
|
12
|
+
* <baht-split-button label="Save" shortcut="alt+s"></baht-split-button>
|
|
13
|
+
* el.items = [{ value: 'save-close', label: 'Save and close', shortcut: 'shift+alt+s' }];
|
|
14
|
+
* el.addEventListener('baht-click', save);
|
|
15
|
+
* el.addEventListener('baht-select', (e) => run(e.detail.value));
|
|
16
|
+
*
|
|
17
|
+
* Keyboard: ↓ / Enter / Space on the toggle opens on the first item, ↑ on the last;
|
|
18
|
+
* in the menu ↑ ↓ (wrapping, skipping disabled) · Home · End · Enter/Space picks ·
|
|
19
|
+
* Escape closes back to the toggle (and is marked handled, so a surrounding
|
|
20
|
+
* `<baht-modal>` stays open) · Tab closes and moves on. A click outside closes.
|
|
21
|
+
*
|
|
22
|
+
* @fires {CustomEvent<void>} baht-click - The main action was activated (click or its shortcut).
|
|
23
|
+
* @fires {CustomEvent<{ value: string; item: MenuItem }>} baht-select - A menu item was picked. `detail: { value, item }`.
|
|
24
|
+
*/
|
|
25
|
+
export declare class BahtSplitButton extends BahtElement {
|
|
26
|
+
/** Main action label. */
|
|
27
|
+
label: string;
|
|
28
|
+
variant: ButtonVariant;
|
|
29
|
+
size: ButtonSize;
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
/** Shortcut for the main action, e.g. `alt+s` (see `<baht-button shortcut>`). */
|
|
32
|
+
shortcut: string;
|
|
33
|
+
/** Menu entries. Set as a property: `el.items = [...]`. */
|
|
34
|
+
items: MenuItem[];
|
|
35
|
+
/** Menu edge aligned with the button: `'end'` (default, right in LTR) or `'start'`. */
|
|
36
|
+
align: 'start' | 'end';
|
|
37
|
+
/** Accessible name of the ▾ toggle. Defaults to the localized "More actions". */
|
|
38
|
+
menuLabel: string;
|
|
39
|
+
private readonly menu;
|
|
40
|
+
private get menuId();
|
|
41
|
+
protected updated(changed: Map<PropertyKey, unknown>): void;
|
|
42
|
+
protected render(): TemplateResult;
|
|
43
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { html as u } from "lit";
|
|
2
|
+
import { property as s } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as p, arr as b } from "../base.js";
|
|
4
|
+
import { customElement as m } from "../define.js";
|
|
5
|
+
import { t as d } from "@20baht/engine";
|
|
6
|
+
import { MenuController as c } from "../menu-controller.js";
|
|
7
|
+
import { renderIcon as $ } from "./icons.js";
|
|
8
|
+
var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, i = (e, o, a, n) => {
|
|
9
|
+
for (var r = n > 1 ? void 0 : n ? v(o, a) : o, l = e.length - 1, h; l >= 0; l--)
|
|
10
|
+
(h = e[l]) && (r = (n ? h(o, a, r) : h(r)) || r);
|
|
11
|
+
return n && r && f(o, a, r), r;
|
|
12
|
+
};
|
|
13
|
+
let t = class extends p {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.label = "", this.variant = "primary", this.size = "md", this.disabled = !1, this.shortcut = "", this.items = [], this.align = "end", this.menuLabel = "", this.menu = new c(this, {
|
|
16
|
+
items: () => b(this.items),
|
|
17
|
+
trigger: () => this.querySelector(".baht-split-button-toggle"),
|
|
18
|
+
onPick: (e) => {
|
|
19
|
+
this.emit("baht-select", { value: e.value, item: e });
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
get menuId() {
|
|
24
|
+
return `baht-split-menu-${this.uid}`;
|
|
25
|
+
}
|
|
26
|
+
updated(e) {
|
|
27
|
+
e.has("items") && this.menu.rebind();
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
const e = this.variant === "primary" ? "" : ` baht-button--${this.variant}`, o = this.size === "md" ? "" : ` baht-button--${this.size}`, a = this.menu.open;
|
|
31
|
+
return u`<div class="baht-split-button${a ? " baht-split-button--open" : ""}">
|
|
32
|
+
<baht-button
|
|
33
|
+
class="baht-split-button-main"
|
|
34
|
+
.label=${this.label}
|
|
35
|
+
.variant=${this.variant}
|
|
36
|
+
.size=${this.size}
|
|
37
|
+
.disabled=${this.disabled}
|
|
38
|
+
.shortcut=${this.shortcut}
|
|
39
|
+
@click=${() => {
|
|
40
|
+
this.disabled || this.emit("baht-click");
|
|
41
|
+
}}
|
|
42
|
+
></baht-button>
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
class="baht-button${e}${o} baht-split-button-toggle"
|
|
46
|
+
aria-haspopup="menu"
|
|
47
|
+
aria-expanded=${a ? "true" : "false"}
|
|
48
|
+
aria-controls=${this.menuId}
|
|
49
|
+
aria-label=${this.menuLabel || d("moreActions")}
|
|
50
|
+
?disabled=${this.disabled}
|
|
51
|
+
@click=${this.menu.onTriggerClick}
|
|
52
|
+
@keydown=${this.menu.onTriggerKeydown}
|
|
53
|
+
>${$("chevron-down")}</button>
|
|
54
|
+
${this.menu.render(this.menuId, this.align, this.label)}
|
|
55
|
+
</div>`;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
i([
|
|
59
|
+
s()
|
|
60
|
+
], t.prototype, "label", 2);
|
|
61
|
+
i([
|
|
62
|
+
s()
|
|
63
|
+
], t.prototype, "variant", 2);
|
|
64
|
+
i([
|
|
65
|
+
s()
|
|
66
|
+
], t.prototype, "size", 2);
|
|
67
|
+
i([
|
|
68
|
+
s({ type: Boolean, reflect: !0 })
|
|
69
|
+
], t.prototype, "disabled", 2);
|
|
70
|
+
i([
|
|
71
|
+
s()
|
|
72
|
+
], t.prototype, "shortcut", 2);
|
|
73
|
+
i([
|
|
74
|
+
s({ attribute: !1 })
|
|
75
|
+
], t.prototype, "items", 2);
|
|
76
|
+
i([
|
|
77
|
+
s()
|
|
78
|
+
], t.prototype, "align", 2);
|
|
79
|
+
i([
|
|
80
|
+
s({ attribute: "menu-label" })
|
|
81
|
+
], t.prototype, "menuLabel", 2);
|
|
82
|
+
t = i([
|
|
83
|
+
m("baht-split-button")
|
|
84
|
+
], t);
|
|
85
|
+
export {
|
|
86
|
+
t as BahtSplitButton
|
|
87
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Big single-number stat (report type "count").
|
|
5
|
+
*
|
|
6
|
+
* <baht-stat-chart total="1284" label="Open incidents"></baht-stat-chart>
|
|
7
|
+
*/
|
|
8
|
+
export declare class BahtStatChart extends BahtElement {
|
|
9
|
+
total: number;
|
|
10
|
+
label: string;
|
|
11
|
+
/** Overrides the number color (defaults to the primary token). */
|
|
12
|
+
color: string;
|
|
13
|
+
protected render(): TemplateResult;
|
|
14
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { nothing as c, html as m } from "lit";
|
|
2
|
+
import { property as i } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as n } from "../base.js";
|
|
4
|
+
import { customElement as b } from "../define.js";
|
|
5
|
+
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, a = (p, o, l, e) => {
|
|
6
|
+
for (var t = e > 1 ? void 0 : e ? f(o, l) : o, s = p.length - 1, h; s >= 0; s--)
|
|
7
|
+
(h = p[s]) && (t = (e ? h(o, l, t) : h(t)) || t);
|
|
8
|
+
return e && t && v(o, l, t), t;
|
|
9
|
+
};
|
|
10
|
+
let r = class extends n {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.total = 0, this.label = "", this.color = "";
|
|
13
|
+
}
|
|
14
|
+
render() {
|
|
15
|
+
return m`<div class="baht-stat-chart">
|
|
16
|
+
<div
|
|
17
|
+
class="baht-stat-chart-total"
|
|
18
|
+
style=${this.color ? `color:${this.color}` : c}
|
|
19
|
+
>${this.total.toLocaleString("en-US")}</div>
|
|
20
|
+
${this.label ? m`<div class="baht-stat-chart-label">${this.label}</div>` : c}
|
|
21
|
+
</div>`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
a([
|
|
25
|
+
i({ type: Number })
|
|
26
|
+
], r.prototype, "total", 2);
|
|
27
|
+
a([
|
|
28
|
+
i()
|
|
29
|
+
], r.prototype, "label", 2);
|
|
30
|
+
a([
|
|
31
|
+
i()
|
|
32
|
+
], r.prototype, "color", 2);
|
|
33
|
+
r = a([
|
|
34
|
+
b("baht-stat-chart")
|
|
35
|
+
], r);
|
|
36
|
+
export {
|
|
37
|
+
r as BahtStatChart
|
|
38
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { ChartFormat } from './charts.js';
|
|
4
|
+
export declare class BahtStat extends BahtElement {
|
|
5
|
+
/** Sentence-case caption above the figure, no trailing colon. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The figure. */
|
|
8
|
+
value: number;
|
|
9
|
+
/**
|
|
10
|
+
* How the figure reads: number | currency | percent | percent-100 | compact.
|
|
11
|
+
* `percent` expects a fraction (`0.14` → "14%"); `percent-100` expects 0 to 100
|
|
12
|
+
* (`14` → "14%").
|
|
13
|
+
*/
|
|
14
|
+
format: ChartFormat;
|
|
15
|
+
/** ISO currency code for `format="currency"` (THB renders `฿`). */
|
|
16
|
+
currency: string;
|
|
17
|
+
/**
|
|
18
|
+
* Change against the previous period. `null` hides the delta row.
|
|
19
|
+
* With `delta-kind="pct"` it is a percentage on a 0 to 100 scale (18 → "18%"),
|
|
20
|
+
* whatever `format` is; with `"abs"` it is
|
|
21
|
+
* a raw amount rendered with this tile's `format`.
|
|
22
|
+
*/
|
|
23
|
+
delta: number | null;
|
|
24
|
+
/** Whether `delta` is a percentage or an absolute amount. */
|
|
25
|
+
deltaKind: 'abs' | 'pct';
|
|
26
|
+
/**
|
|
27
|
+
* What the delta is measured against, e.g. "vs August". With no `delta` it is
|
|
28
|
+
* still rendered on its own as a muted caption, so a figure can name its period.
|
|
29
|
+
*/
|
|
30
|
+
deltaLabel: string;
|
|
31
|
+
/** Is a rise good news? Spending tiles set `up-is-good="false"`. */
|
|
32
|
+
upIsGood: boolean;
|
|
33
|
+
/** Recent points drawn as a muted sparkline with an accent on the newest. */
|
|
34
|
+
trend: number[];
|
|
35
|
+
/** `hero` is the one 48px+ figure a view leads with. */
|
|
36
|
+
size: 'md' | 'hero';
|
|
37
|
+
/** Icon name from the curated set (see icons.ts), shown in a chip before the label. */
|
|
38
|
+
icon?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The previous period's figure. With no `delta`, the tile works the % change out itself, and a
|
|
41
|
+
* base under 5 reads "was 1" in grey instead of a loud −100% on a tiny count.
|
|
42
|
+
*/
|
|
43
|
+
previous: number | null;
|
|
44
|
+
/** `neutral` keeps the delta grey both ways: spend or volume, where up is neither good nor bad. */
|
|
45
|
+
deltaTone: 'auto' | 'neutral';
|
|
46
|
+
/** A previous figure too small for a percentage to mean anything. */
|
|
47
|
+
private get tinyBase();
|
|
48
|
+
/** The delta shown: the one given, or the % change worked out from `previous`. */
|
|
49
|
+
private get change();
|
|
50
|
+
/** Direction of the delta paired with whether up is good. */
|
|
51
|
+
private get tone();
|
|
52
|
+
private get arrow();
|
|
53
|
+
private get deltaText();
|
|
54
|
+
private renderChange;
|
|
55
|
+
protected render(): TemplateResult;
|
|
56
|
+
}
|