@20baht/ui 0.0.0-stage → 0.1.1
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 +512 -2
- package/dist/components/baht-form.d.ts +206 -0
- package/dist/components/baht-form.js +630 -0
- package/dist/components/baht-workflow.d.ts +187 -0
- package/dist/components/baht-workflow.js +455 -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 +45172 -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,106 @@
|
|
|
1
|
+
import { html as u } from "lit";
|
|
2
|
+
import { property as i, state as p } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as v, obj as n } from "../base.js";
|
|
4
|
+
import { renderIcon as c } from "./icons.js";
|
|
5
|
+
import { customElement as b } from "../define.js";
|
|
6
|
+
var y = Object.defineProperty, m = Object.getOwnPropertyDescriptor, r = (a, e, t, s) => {
|
|
7
|
+
for (var o = s > 1 ? void 0 : s ? m(e, t) : e, h = a.length - 1, d; h >= 0; h--)
|
|
8
|
+
(d = a[h]) && (o = (s ? d(e, t, o) : d(o)) || o);
|
|
9
|
+
return s && o && y(e, t, o), o;
|
|
10
|
+
};
|
|
11
|
+
let l = class extends v {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.value = {}, this.keyPlaceholder = "key", this.valuePlaceholder = "value", this.add_label = "Add row", this.disabled = !1, this.rows = [{ k: "", v: "" }], this.syncedJson = "", this.addRow = () => {
|
|
14
|
+
this.rows = [...this.rows, { k: "", v: "" }];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
willUpdate(a) {
|
|
18
|
+
if (!a.has("value")) return;
|
|
19
|
+
const e = JSON.stringify(n(this.value));
|
|
20
|
+
e !== this.syncedJson && (this.syncedJson = e, this.rows = this.toRows(this.value));
|
|
21
|
+
}
|
|
22
|
+
toRows(a) {
|
|
23
|
+
const e = Object.entries(n(a)).map(([t, s]) => ({
|
|
24
|
+
k: t,
|
|
25
|
+
v: typeof s == "string" ? s : JSON.stringify(s)
|
|
26
|
+
}));
|
|
27
|
+
return e.length > 0 ? e : [{ k: "", v: "" }];
|
|
28
|
+
}
|
|
29
|
+
commit(a) {
|
|
30
|
+
this.rows = a.length > 0 ? a : [{ k: "", v: "" }];
|
|
31
|
+
const e = {};
|
|
32
|
+
for (const t of a) t.k.trim() && (e[t.k.trim()] = t.v);
|
|
33
|
+
this.syncedJson = JSON.stringify(e), this.emit("baht-change", { value: e });
|
|
34
|
+
}
|
|
35
|
+
edit(a, e) {
|
|
36
|
+
this.commit(this.rows.map((t, s) => s === a ? { ...t, ...e } : t));
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
return u`<div class="baht-keyvalue">
|
|
40
|
+
${this.rows.map(
|
|
41
|
+
(a, e) => u`<div class="baht-keyvalue-row">
|
|
42
|
+
<input
|
|
43
|
+
class="baht-control baht-keyvalue-key"
|
|
44
|
+
placeholder=${this.keyPlaceholder}
|
|
45
|
+
aria-label="${this.keyPlaceholder} ${e + 1}"
|
|
46
|
+
.value=${a.k}
|
|
47
|
+
?disabled=${this.disabled}
|
|
48
|
+
@input=${(t) => {
|
|
49
|
+
this.edit(e, { k: t.target.value });
|
|
50
|
+
}}
|
|
51
|
+
/>
|
|
52
|
+
<span class="baht-keyvalue-eq" aria-hidden="true">=</span>
|
|
53
|
+
<input
|
|
54
|
+
class="baht-control baht-keyvalue-value"
|
|
55
|
+
placeholder=${this.valuePlaceholder}
|
|
56
|
+
aria-label="${this.valuePlaceholder} ${e + 1}"
|
|
57
|
+
.value=${a.v}
|
|
58
|
+
?disabled=${this.disabled}
|
|
59
|
+
@input=${(t) => {
|
|
60
|
+
this.edit(e, { v: t.target.value });
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
<button
|
|
64
|
+
type="button"
|
|
65
|
+
class="baht-keyvalue-remove"
|
|
66
|
+
aria-label="Remove row ${e + 1}"
|
|
67
|
+
?disabled=${this.disabled}
|
|
68
|
+
@click=${() => {
|
|
69
|
+
this.commit(this.rows.filter((t, s) => s !== e));
|
|
70
|
+
}}
|
|
71
|
+
>${c("close")}</button>
|
|
72
|
+
</div>`
|
|
73
|
+
)}
|
|
74
|
+
<button
|
|
75
|
+
type="button"
|
|
76
|
+
class="baht-keyvalue-add"
|
|
77
|
+
?disabled=${this.disabled}
|
|
78
|
+
@click=${this.addRow}
|
|
79
|
+
>${c("plus")}${this.add_label}</button>
|
|
80
|
+
</div>`;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
r([
|
|
84
|
+
i({ attribute: !1 })
|
|
85
|
+
], l.prototype, "value", 2);
|
|
86
|
+
r([
|
|
87
|
+
i({ attribute: "key-placeholder" })
|
|
88
|
+
], l.prototype, "keyPlaceholder", 2);
|
|
89
|
+
r([
|
|
90
|
+
i({ attribute: "value-placeholder" })
|
|
91
|
+
], l.prototype, "valuePlaceholder", 2);
|
|
92
|
+
r([
|
|
93
|
+
i({ attribute: "add-label" })
|
|
94
|
+
], l.prototype, "add_label", 2);
|
|
95
|
+
r([
|
|
96
|
+
i({ type: Boolean })
|
|
97
|
+
], l.prototype, "disabled", 2);
|
|
98
|
+
r([
|
|
99
|
+
p()
|
|
100
|
+
], l.prototype, "rows", 2);
|
|
101
|
+
l = r([
|
|
102
|
+
b("baht-keyvalue-editor")
|
|
103
|
+
], l);
|
|
104
|
+
export {
|
|
105
|
+
l as BahtKeyvalueEditor
|
|
106
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtChartBase, ChartMarker, ChartSeries } from './charts.js';
|
|
3
|
+
/**
|
|
4
|
+
* Multi-series line chart with a crosshair tooltip that lists every series at
|
|
5
|
+
* the hovered x. One y axis only — never a second scale.
|
|
6
|
+
*
|
|
7
|
+
* const el = document.createElement('baht-line-chart');
|
|
8
|
+
* el.categories = ['Oct', 'Nov', 'Dec'];
|
|
9
|
+
* el.series = [{ name: 'Income', values: [1, 2, 3] }];
|
|
10
|
+
*/
|
|
11
|
+
export declare class BahtLineChart extends BahtChartBase {
|
|
12
|
+
/** One entry per line: `{ name, values, color? }`. */
|
|
13
|
+
series: ChartSeries[];
|
|
14
|
+
/** X labels, one per value index. */
|
|
15
|
+
categories: string[];
|
|
16
|
+
/** Fill under the line at 10% opacity. Single series only. */
|
|
17
|
+
area: boolean;
|
|
18
|
+
/** Reference lines (targets, averages) drawn across the plot. */
|
|
19
|
+
markers: ChartMarker[];
|
|
20
|
+
/** Draw the last N points dashed — a projection, not measured data. */
|
|
21
|
+
forecast: number;
|
|
22
|
+
/** Hairline at this value (0, a target). `null` draws none. */
|
|
23
|
+
baseline: number | null;
|
|
24
|
+
/** `ends` labels the last point of each line when the labels do not collide. */
|
|
25
|
+
labelValues: 'ends' | 'none';
|
|
26
|
+
/** Accessible summary; falls back to a generated sentence. */
|
|
27
|
+
label: string;
|
|
28
|
+
/**
|
|
29
|
+
* Drawing width in SVG units. It follows the host, so one unit is one CSS
|
|
30
|
+
* pixel and tick text keeps its real size: not shrunk on a phone, not blown
|
|
31
|
+
* up in a wide card (a capped drawing stretched to 1050px set 11px ticks at 18px).
|
|
32
|
+
*/
|
|
33
|
+
private width;
|
|
34
|
+
private resizeObserver;
|
|
35
|
+
connectedCallback(): void;
|
|
36
|
+
disconnectedCallback(): void;
|
|
37
|
+
protected firstUpdated(): void;
|
|
38
|
+
/** Host width → drawing width. Never runs on the server (`hasDom` guard). */
|
|
39
|
+
private measure;
|
|
40
|
+
private get plot();
|
|
41
|
+
protected render(): TemplateResult;
|
|
42
|
+
private crosshairAt;
|
|
43
|
+
private onHover;
|
|
44
|
+
private onLeave;
|
|
45
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { html as _, nothing as y, svg as l } from "lit";
|
|
2
|
+
import { property as b, state as H } from "lit/decorators.js";
|
|
3
|
+
import { hasDom as k, arr as L } from "../base.js";
|
|
4
|
+
import { BahtChartBase as N, niceRange as R, minTickStep as W, linearScale as O, chartColor as g, renderTableTwin as q } from "./charts.js";
|
|
5
|
+
import { customElement as U } from "../define.js";
|
|
6
|
+
var V = Object.defineProperty, S = Object.getOwnPropertyDescriptor, $ = (o, s, d, r) => {
|
|
7
|
+
for (var n = r > 1 ? void 0 : r ? S(s, d) : s, v = o.length - 1, x; v >= 0; v--)
|
|
8
|
+
(x = o[v]) && (n = (r ? x(s, d, n) : x(n)) || n);
|
|
9
|
+
return r && n && V(s, d, n), n;
|
|
10
|
+
};
|
|
11
|
+
const X = 640, I = 280, A = 260, Y = 56, a = { top: 14, right: 72, bottom: 30, left: 60 };
|
|
12
|
+
let h = class extends N {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.series = [], this.categories = [], this.area = !1, this.markers = [], this.forecast = 0, this.baseline = null, this.labelValues = "ends", this.label = "", this.width = X, this.crosshairAt = null;
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
super.connectedCallback(), !(!k() || typeof ResizeObserver > "u") && (this.resizeObserver = new ResizeObserver(() => {
|
|
18
|
+
this.measure();
|
|
19
|
+
}), this.resizeObserver.observe(this));
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
var o;
|
|
23
|
+
(o = this.resizeObserver) == null || o.disconnect(), this.resizeObserver = void 0, super.disconnectedCallback();
|
|
24
|
+
}
|
|
25
|
+
firstUpdated() {
|
|
26
|
+
k() && queueMicrotask(() => {
|
|
27
|
+
this.measure();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** Host width → drawing width. Never runs on the server (`hasDom` guard). */
|
|
31
|
+
measure() {
|
|
32
|
+
if (!k() || !this.isConnected) return;
|
|
33
|
+
const o = this.clientWidth;
|
|
34
|
+
if (o <= 0) return;
|
|
35
|
+
const s = Math.max(I, Math.round(o));
|
|
36
|
+
s !== this.width && (this.width = s);
|
|
37
|
+
}
|
|
38
|
+
get plot() {
|
|
39
|
+
return { w: this.width - a.left - a.right, h: A - a.top - a.bottom };
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const o = this.hold({
|
|
43
|
+
series: L(this.series).filter((t) => t.values.length > 0),
|
|
44
|
+
categories: L(this.categories)
|
|
45
|
+
}), { series: s, categories: d } = o;
|
|
46
|
+
if (s.length === 0)
|
|
47
|
+
return _`<div class=${this.rootClass("baht-line-chart")}>${this.renderEmpty()}</div>`;
|
|
48
|
+
const r = Math.max(...s.map((t) => t.values.length)), n = s.flatMap((t) => t.values).filter((t) => Number.isFinite(t)), v = this.markers.map((t) => t.value), x = R(
|
|
49
|
+
Math.min(0, ...n, ...v),
|
|
50
|
+
Math.max(0, ...n, ...v),
|
|
51
|
+
4,
|
|
52
|
+
W(this.format)
|
|
53
|
+
), T = x[0] ?? 0, z = x[x.length - 1] ?? 1, { w: f, h: F } = this.plot, p = O([0, Math.max(1, r - 1)], [a.left, a.left + f]), i = O([T, z], [a.top + F, a.top]), M = Math.max(0, r - 1 - Math.max(0, this.forecast)), w = (t, e, c) => t.slice(e, c + 1).map((m, u) => `${u === 0 ? "M" : "L"}${p(e + u).toFixed(2)},${i(m).toFixed(2)}`).join(" "), P = s.map((t, e) => ({
|
|
54
|
+
i: e,
|
|
55
|
+
name: t.name,
|
|
56
|
+
value: t.values[t.values.length - 1] ?? 0,
|
|
57
|
+
yPos: i(t.values[t.values.length - 1] ?? 0),
|
|
58
|
+
color: g(e, t.color)
|
|
59
|
+
})), C = [...P].sort((t, e) => t.yPos - e.yPos), B = C.some((t, e) => e > 0 && t.yPos - C[e - 1].yPos < 15), j = this.labelValues === "ends" && !B, D = Math.max(1, Math.ceil(r / Math.max(2, Math.min(8, Math.floor(f / Y))))), E = this.label || `Line chart, ${s.length} series over ${r} points. ${s.map((t, e) => `${t.name}: ${this.fmt(P[e].value)} at the end`).join(". ")}`;
|
|
60
|
+
return _`<div class=${this.rootClass("baht-line-chart")}>
|
|
61
|
+
<svg
|
|
62
|
+
class="baht-chart-svg"
|
|
63
|
+
viewBox="0 0 ${this.width} ${A}"
|
|
64
|
+
preserveAspectRatio="xMidYMid meet"
|
|
65
|
+
role="img"
|
|
66
|
+
aria-label=${E}
|
|
67
|
+
>
|
|
68
|
+
${x.map(
|
|
69
|
+
(t) => l`
|
|
70
|
+
<line class="baht-chart-grid-line" x1=${a.left} x2=${a.left + f}
|
|
71
|
+
y1=${i(t).toFixed(2)} y2=${i(t).toFixed(2)}/>
|
|
72
|
+
<text class="baht-chart-tick" x=${a.left - 8} y=${(i(t) + 4).toFixed(2)}
|
|
73
|
+
text-anchor="end">${this.fmt(t)}</text>`
|
|
74
|
+
)}
|
|
75
|
+
${this.baseline != null ? [
|
|
76
|
+
l`<line class="baht-chart-baseline" x1=${a.left} x2=${a.left + f}
|
|
77
|
+
y1=${i(this.baseline).toFixed(2)} y2=${i(this.baseline).toFixed(2)}/>`
|
|
78
|
+
] : []}
|
|
79
|
+
${L(this.markers).map(
|
|
80
|
+
(t) => l`
|
|
81
|
+
<line class="baht-chart-marker-line" x1=${a.left} x2=${a.left + f}
|
|
82
|
+
y1=${i(t.value).toFixed(2)} y2=${i(t.value).toFixed(2)}/>
|
|
83
|
+
<text class="baht-chart-marker-label" x=${a.left + f} y=${(i(t.value) - 5).toFixed(2)}
|
|
84
|
+
text-anchor="end">${t.label ?? this.fmt(t.value)}</text>`
|
|
85
|
+
)}
|
|
86
|
+
${this.area && s.length === 1 ? l`<path class="baht-chart-area" fill=${g(0, s[0].color)}
|
|
87
|
+
d=${`${w(s[0].values, 0, r - 1)} L${p(r - 1).toFixed(2)},${i(0).toFixed(2)} L${p(0).toFixed(2)},${i(0).toFixed(2)} Z`}/>` : y}
|
|
88
|
+
${s.map((t, e) => {
|
|
89
|
+
const c = g(e, t.color), m = [
|
|
90
|
+
l`<path class="baht-chart-line" d=${w(t.values, 0, M)} stroke=${c} fill="none"/>`
|
|
91
|
+
];
|
|
92
|
+
return M < r - 1 && m.push(
|
|
93
|
+
l`<path class="baht-chart-line baht-chart-line--forecast" d=${w(t.values, M, r - 1)}
|
|
94
|
+
stroke=${c} fill="none"/>`
|
|
95
|
+
), m.push(
|
|
96
|
+
l`<circle class="baht-chart-end-dot" cx=${p(r - 1).toFixed(2)}
|
|
97
|
+
cy=${i(t.values[t.values.length - 1] ?? 0).toFixed(2)} r="4" fill=${c}/>`
|
|
98
|
+
), m;
|
|
99
|
+
})}
|
|
100
|
+
${j ? P.map(
|
|
101
|
+
(t) => l`
|
|
102
|
+
<text class="baht-chart-end-label" x=${p(r - 1) + 10} y=${(t.yPos + 4).toFixed(2)}
|
|
103
|
+
text-anchor="start">${this.fmt(t.value)}</text>`
|
|
104
|
+
) : y}
|
|
105
|
+
${d.map(
|
|
106
|
+
(t, e) => e % D === 0 ? l`<text class="baht-chart-tick" x=${p(e).toFixed(2)} y=${A - 10} text-anchor="middle">${t}</text>` : y
|
|
107
|
+
)}
|
|
108
|
+
${Array.from({ length: r }, (t, e) => {
|
|
109
|
+
const c = f / Math.max(1, r - 1), m = `${d[e] ?? `Point ${e + 1}`}: ${s.map((u) => `${u.name} ${this.fmt(u.values[e] ?? 0)}`).join(", ")}`;
|
|
110
|
+
return l`<rect class="baht-chart-hit" x=${(p(e) - c / 2).toFixed(2)} y=${a.top}
|
|
111
|
+
width=${Math.max(24, c).toFixed(2)} height=${F} tabindex="0" role="button"
|
|
112
|
+
aria-label=${m}
|
|
113
|
+
@pointermove=${(u) => {
|
|
114
|
+
this.onHover(u, e, m);
|
|
115
|
+
}}
|
|
116
|
+
@pointerleave=${() => {
|
|
117
|
+
this.onLeave();
|
|
118
|
+
}}
|
|
119
|
+
@focus=${(u) => {
|
|
120
|
+
this.onHover(u, e, m);
|
|
121
|
+
}}
|
|
122
|
+
@blur=${() => {
|
|
123
|
+
this.onLeave();
|
|
124
|
+
}}/>`;
|
|
125
|
+
})}
|
|
126
|
+
${this.crosshairAt != null ? l`<line class="baht-chart-crosshair" x1=${p(this.crosshairAt).toFixed(2)}
|
|
127
|
+
x2=${p(this.crosshairAt).toFixed(2)} y1=${a.top} y2=${a.top + F}/>` : y}
|
|
128
|
+
</svg>
|
|
129
|
+
${this.renderTooltip()}
|
|
130
|
+
${this.renderLegend(
|
|
131
|
+
s.map((t, e) => ({ label: t.name, color: g(e, t.color) })),
|
|
132
|
+
"line"
|
|
133
|
+
)}
|
|
134
|
+
${this.showTable ? q(
|
|
135
|
+
this.label || "Line chart data",
|
|
136
|
+
["Point", ...s.map((t) => t.name)],
|
|
137
|
+
Array.from({ length: r }, (t, e) => [
|
|
138
|
+
d[e] ?? `Point ${e + 1}`,
|
|
139
|
+
...s.map((c) => this.fmt(c.values[e] ?? 0))
|
|
140
|
+
])
|
|
141
|
+
) : y}
|
|
142
|
+
</div>`;
|
|
143
|
+
}
|
|
144
|
+
onHover(o, s, d) {
|
|
145
|
+
this.crosshairAt = s, this.requestUpdate(), this.showTip(o, d);
|
|
146
|
+
}
|
|
147
|
+
onLeave() {
|
|
148
|
+
this.crosshairAt = null, this.requestUpdate(), this.hideTip();
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
$([
|
|
152
|
+
b({ attribute: !1 })
|
|
153
|
+
], h.prototype, "series", 2);
|
|
154
|
+
$([
|
|
155
|
+
b({ attribute: !1 })
|
|
156
|
+
], h.prototype, "categories", 2);
|
|
157
|
+
$([
|
|
158
|
+
b({ type: Boolean })
|
|
159
|
+
], h.prototype, "area", 2);
|
|
160
|
+
$([
|
|
161
|
+
b({ attribute: !1 })
|
|
162
|
+
], h.prototype, "markers", 2);
|
|
163
|
+
$([
|
|
164
|
+
b({ type: Number })
|
|
165
|
+
], h.prototype, "forecast", 2);
|
|
166
|
+
$([
|
|
167
|
+
b({ type: Number })
|
|
168
|
+
], h.prototype, "baseline", 2);
|
|
169
|
+
$([
|
|
170
|
+
b({ attribute: "label-values" })
|
|
171
|
+
], h.prototype, "labelValues", 2);
|
|
172
|
+
$([
|
|
173
|
+
b()
|
|
174
|
+
], h.prototype, "label", 2);
|
|
175
|
+
$([
|
|
176
|
+
H()
|
|
177
|
+
], h.prototype, "width", 2);
|
|
178
|
+
h = $([
|
|
179
|
+
U("baht-line-chart")
|
|
180
|
+
], h);
|
|
181
|
+
export {
|
|
182
|
+
h as BahtLineChart
|
|
183
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Styled anchor (20baht underline treatment). `external` opens a new tab and
|
|
5
|
+
* shows the ↗ mark.
|
|
6
|
+
*
|
|
7
|
+
* <baht-link href="/docs" label="Read the docs"></baht-link>
|
|
8
|
+
* <baht-link href="https://…" label="Status page" external></baht-link>
|
|
9
|
+
*
|
|
10
|
+
* A press on an in-app link (not `external`) fires a cancelable `baht-navigate`: a router calls
|
|
11
|
+
* `preventDefault()` and navigates itself, so a federation host does no full page load. A
|
|
12
|
+
* press with a modifier key (new tab) is left to the browser.
|
|
13
|
+
*
|
|
14
|
+
* @fires {CustomEvent<{ href: string }>} baht-navigate - An in-app link was pressed. Cancelable: `preventDefault()` to route yourself.
|
|
15
|
+
*/
|
|
16
|
+
export declare class BahtLink extends BahtElement {
|
|
17
|
+
href: string;
|
|
18
|
+
label: string;
|
|
19
|
+
external: boolean;
|
|
20
|
+
/** Screen-reader suffix for external links (override to localize). */
|
|
21
|
+
externalHint: string;
|
|
22
|
+
private readonly onClick;
|
|
23
|
+
/** `href`, or '' when its scheme is not one a link may carry (`javascript:`, `data:`). */
|
|
24
|
+
private get safeHref();
|
|
25
|
+
protected render(): TemplateResult;
|
|
26
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { nothing as i, html as f } from "lit";
|
|
2
|
+
import { property as l } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as m, routeClick as c } from "../base.js";
|
|
4
|
+
import { customElement as b } from "../define.js";
|
|
5
|
+
import { isSafeUrl as u } from "@20baht/engine";
|
|
6
|
+
var x = Object.defineProperty, v = Object.getOwnPropertyDescriptor, r = (a, n, h, s) => {
|
|
7
|
+
for (var e = s > 1 ? void 0 : s ? v(n, h) : n, o = a.length - 1, p; o >= 0; o--)
|
|
8
|
+
(p = a[o]) && (e = (s ? p(n, h, e) : p(e)) || e);
|
|
9
|
+
return s && e && x(n, h, e), e;
|
|
10
|
+
};
|
|
11
|
+
let t = class extends m {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.href = "", this.label = "", this.external = !1, this.externalHint = "opens in new tab", this.onClick = (a) => {
|
|
14
|
+
this.external || !this.safeHref || c(this, "baht-navigate", a, { href: this.safeHref });
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** `href`, or '' when its scheme is not one a link may carry (`javascript:`, `data:`). */
|
|
18
|
+
get safeHref() {
|
|
19
|
+
return u(this.href) ? this.href : "";
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return f`<a
|
|
23
|
+
class="baht-link"
|
|
24
|
+
href=${this.safeHref || i}
|
|
25
|
+
target=${this.external ? "_blank" : i}
|
|
26
|
+
rel=${this.external ? "noopener noreferrer" : i}
|
|
27
|
+
@click=${this.onClick}
|
|
28
|
+
>${this.label}${this.external ? f` <span class="baht-link-external" aria-hidden="true">↗</span><span class="baht-visually-hidden"> (${this.externalHint})</span>` : i}</a>`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
r([
|
|
32
|
+
l()
|
|
33
|
+
], t.prototype, "href", 2);
|
|
34
|
+
r([
|
|
35
|
+
l()
|
|
36
|
+
], t.prototype, "label", 2);
|
|
37
|
+
r([
|
|
38
|
+
l({ type: Boolean })
|
|
39
|
+
], t.prototype, "external", 2);
|
|
40
|
+
r([
|
|
41
|
+
l({ attribute: "external-hint" })
|
|
42
|
+
], t.prototype, "externalHint", 2);
|
|
43
|
+
t = r([
|
|
44
|
+
b("baht-link")
|
|
45
|
+
], t);
|
|
46
|
+
export {
|
|
47
|
+
t as BahtLink
|
|
48
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
export interface ListItem {
|
|
4
|
+
id?: string | number;
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle?: string;
|
|
7
|
+
meta?: string;
|
|
8
|
+
badge?: string;
|
|
9
|
+
badgeTone?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Display list — same server-side contract as <baht-table>: `items` is the
|
|
14
|
+
* current page, `loading` shows skeleton rows, the host fetches on
|
|
15
|
+
* `baht-page-change` (pair with <baht-pagination>).
|
|
16
|
+
* @fires {CustomEvent<{ item: ListItem; index: number; id: string | number | undefined }>} baht-item-click - An item was pressed.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BahtList extends BahtElement {
|
|
19
|
+
items: ListItem[];
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: boolean;
|
|
22
|
+
errorMessage: string;
|
|
23
|
+
emptyMessage: string;
|
|
24
|
+
skeletonRows: number;
|
|
25
|
+
clickable: boolean;
|
|
26
|
+
private emitItem;
|
|
27
|
+
private renderRows;
|
|
28
|
+
protected render(): TemplateResult;
|
|
29
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { html as e, nothing as n } from "lit";
|
|
2
|
+
import { property as o } from "lit/decorators.js";
|
|
3
|
+
import { boolOff as d, BahtElement as m } from "../base.js";
|
|
4
|
+
import "./baht-badge.js";
|
|
5
|
+
import { customElement as c } from "../define.js";
|
|
6
|
+
var v = Object.defineProperty, g = Object.getOwnPropertyDescriptor, i = (t, s, a, h) => {
|
|
7
|
+
for (var l = h > 1 ? void 0 : h ? g(s, a) : s, p = t.length - 1, b; p >= 0; p--)
|
|
8
|
+
(b = t[p]) && (l = (h ? b(s, a, l) : b(l)) || l);
|
|
9
|
+
return h && l && v(s, a, l), l;
|
|
10
|
+
};
|
|
11
|
+
let r = class extends m {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.items = [], this.loading = !1, this.error = !1, this.errorMessage = "Couldn't load data. Try again.", this.emptyMessage = "Nothing here yet.", this.skeletonRows = 5, this.clickable = !0;
|
|
14
|
+
}
|
|
15
|
+
emitItem(t, s) {
|
|
16
|
+
this.clickable && this.emit("baht-item-click", { item: t, index: s, id: t.id });
|
|
17
|
+
}
|
|
18
|
+
renderRows() {
|
|
19
|
+
return this.loading ? e`${Array.from(
|
|
20
|
+
{ length: this.skeletonRows },
|
|
21
|
+
() => e`<div class="baht-list-item">
|
|
22
|
+
<div class="baht-list-main">
|
|
23
|
+
<span class="baht-skeleton baht-skeleton--text" style="width:40%; margin-bottom:6px;"></span>
|
|
24
|
+
<span class="baht-skeleton baht-skeleton--text" style="width:65%;"></span>
|
|
25
|
+
</div>
|
|
26
|
+
</div>`
|
|
27
|
+
)}` : this.error ? e`<div class="baht-list-state baht-list-state--error" role="alert">${this.errorMessage}</div>` : this.items.length === 0 ? e`<div class="baht-list-state">${this.emptyMessage}</div>` : e`${this.items.map(
|
|
28
|
+
(t, s) => e`<div
|
|
29
|
+
class="baht-list-item"
|
|
30
|
+
role="listitem"
|
|
31
|
+
tabindex=${this.clickable ? "0" : n}
|
|
32
|
+
@click=${() => {
|
|
33
|
+
this.emitItem(t, s);
|
|
34
|
+
}}
|
|
35
|
+
@keydown=${(a) => {
|
|
36
|
+
a.key !== "Enter" && a.key !== " " || (a.preventDefault(), this.emitItem(t, s));
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<div class="baht-list-main">
|
|
40
|
+
<div class="baht-list-title">${t.title}</div>
|
|
41
|
+
${t.subtitle ? e`<div class="baht-list-subtitle">${t.subtitle}</div>` : n}
|
|
42
|
+
</div>
|
|
43
|
+
${t.badge ? e`<baht-badge tone=${t.badgeTone ?? "neutral"} label=${t.badge}></baht-badge>` : n}
|
|
44
|
+
${t.meta ? e`<span class="baht-list-meta">${t.meta}</span>` : n}
|
|
45
|
+
</div>`
|
|
46
|
+
)}`;
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
const t = !this.loading && !this.error && this.items.length > 0;
|
|
50
|
+
return e`<div class="baht-list" role=${t ? "list" : n}>${this.renderRows()}</div>`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
i([
|
|
54
|
+
o({ attribute: !1 })
|
|
55
|
+
], r.prototype, "items", 2);
|
|
56
|
+
i([
|
|
57
|
+
o({ type: Boolean })
|
|
58
|
+
], r.prototype, "loading", 2);
|
|
59
|
+
i([
|
|
60
|
+
o({ type: Boolean })
|
|
61
|
+
], r.prototype, "error", 2);
|
|
62
|
+
i([
|
|
63
|
+
o({ attribute: "error-message" })
|
|
64
|
+
], r.prototype, "errorMessage", 2);
|
|
65
|
+
i([
|
|
66
|
+
o({ attribute: "empty-message" })
|
|
67
|
+
], r.prototype, "emptyMessage", 2);
|
|
68
|
+
i([
|
|
69
|
+
o({ type: Number, attribute: "skeleton-rows" })
|
|
70
|
+
], r.prototype, "skeletonRows", 2);
|
|
71
|
+
i([
|
|
72
|
+
o({ converter: d })
|
|
73
|
+
], r.prototype, "clickable", 2);
|
|
74
|
+
r = i([
|
|
75
|
+
c("baht-list")
|
|
76
|
+
], r);
|
|
77
|
+
export {
|
|
78
|
+
r as BahtList
|
|
79
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Full-viewport loading scrim with a centered spinner (0.4 ink scrim, same
|
|
5
|
+
* as `<baht-modal>`'s). Controlled: the host flips `open` — e.g. from an
|
|
6
|
+
* in-flight HTTP request counter.
|
|
7
|
+
*
|
|
8
|
+
* <baht-loading-overlay [open]="loading()"></baht-loading-overlay>
|
|
9
|
+
*/
|
|
10
|
+
export declare class BahtLoadingOverlay extends BahtElement {
|
|
11
|
+
constructor();
|
|
12
|
+
open: boolean;
|
|
13
|
+
label: string;
|
|
14
|
+
protected render(): TemplateResult;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { nothing as m, html as s } from "lit";
|
|
2
|
+
import { property as h } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as f } from "../base.js";
|
|
4
|
+
import "./baht-spinner.js";
|
|
5
|
+
import { customElement as v } from "../define.js";
|
|
6
|
+
import { floatLayer as b } from "../floating.js";
|
|
7
|
+
var y = Object.defineProperty, c = Object.getOwnPropertyDescriptor, n = (i, r, l, t) => {
|
|
8
|
+
for (var e = t > 1 ? void 0 : t ? c(r, l) : r, a = i.length - 1, p; a >= 0; a--)
|
|
9
|
+
(p = i[a]) && (e = (t ? p(r, l, e) : p(e)) || e);
|
|
10
|
+
return t && e && y(r, l, e), e;
|
|
11
|
+
};
|
|
12
|
+
let o = class extends f {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(), this.open = !1, this.label = "Loading", b(this, { layer: ".baht-loading-overlay" });
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
return this.open ? s`<div class="baht-loading-overlay">
|
|
18
|
+
<baht-spinner size="lg" label=${this.label}></baht-spinner>
|
|
19
|
+
</div>` : s`${m}`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
n([
|
|
23
|
+
h({ type: Boolean, reflect: !0 })
|
|
24
|
+
], o.prototype, "open", 2);
|
|
25
|
+
n([
|
|
26
|
+
h()
|
|
27
|
+
], o.prototype, "label", 2);
|
|
28
|
+
o = n([
|
|
29
|
+
v("baht-loading-overlay")
|
|
30
|
+
], o);
|
|
31
|
+
export {
|
|
32
|
+
o as BahtLoadingOverlay
|
|
33
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { MarkdownImagePolicy } from './markdown-render.js';
|
|
4
|
+
/**
|
|
5
|
+
* `<baht-markdown-view>` — markdown source as sanitized HTML: GitHub-flavoured, raw HTML
|
|
6
|
+
* shown as text, and images only where `allowImage` says (same origin by default).
|
|
7
|
+
* Until the `marked` and `dompurify` peers land, or if they are missing, it shows the source.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BahtMarkdownView extends BahtElement {
|
|
10
|
+
/** The markdown source. */
|
|
11
|
+
source: string;
|
|
12
|
+
/** Which image URLs may embed; any other image renders as a link. */
|
|
13
|
+
allowImage?: MarkdownImagePolicy;
|
|
14
|
+
private render_;
|
|
15
|
+
protected firstUpdated(): void;
|
|
16
|
+
protected render(): TemplateResult | typeof nothing;
|
|
17
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { nothing as h, html as d } from "lit";
|
|
2
|
+
import { property as n, state as l } from "lit/decorators.js";
|
|
3
|
+
import { unsafeHTML as u } from "lit/directives/unsafe-html.js";
|
|
4
|
+
import { BahtElement as f } from "../base.js";
|
|
5
|
+
import { customElement as c } from "../define.js";
|
|
6
|
+
import { loadMarkdown as v } from "./markdown-render.js";
|
|
7
|
+
var b = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, i = (t, o, a, s) => {
|
|
8
|
+
for (var r = s > 1 ? void 0 : s ? _(o, a) : o, m = t.length - 1, p; m >= 0; m--)
|
|
9
|
+
(p = t[m]) && (r = (s ? p(o, a, r) : p(r)) || r);
|
|
10
|
+
return s && r && b(o, a, r), r;
|
|
11
|
+
};
|
|
12
|
+
let e = class extends f {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.source = "";
|
|
15
|
+
}
|
|
16
|
+
firstUpdated() {
|
|
17
|
+
v().then((t) => {
|
|
18
|
+
this.render_ = t;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return this.source ? this.render_ ? d`<div class="baht-md-body">${u(this.render_(this.source, this.allowImage))}</div>` : d`<div class="baht-md-body baht-md-body--source">${this.source}</div>` : h;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
i([
|
|
26
|
+
n()
|
|
27
|
+
], e.prototype, "source", 2);
|
|
28
|
+
i([
|
|
29
|
+
n({ attribute: !1 })
|
|
30
|
+
], e.prototype, "allowImage", 2);
|
|
31
|
+
i([
|
|
32
|
+
l()
|
|
33
|
+
], e.prototype, "render_", 2);
|
|
34
|
+
e = i([
|
|
35
|
+
c("baht-markdown-view")
|
|
36
|
+
], e);
|
|
37
|
+
export {
|
|
38
|
+
e as BahtMarkdownView
|
|
39
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { UploadedFile } from '@20baht/engine';
|
|
3
|
+
import { BahtFieldBase } from '../field-base.js';
|
|
4
|
+
import { MarkdownImagePolicy } from './markdown-render.js';
|
|
5
|
+
/**
|
|
6
|
+
* `type: 'markdown'` — GitHub's comment box: Write and Preview tabs over a plain string
|
|
7
|
+
* of markdown. With `field.uploader`, files pasted, dropped or picked upload at once and
|
|
8
|
+
* land in the text as `` for an image and `[name](url)` for anything else.
|
|
9
|
+
* Read-only or disabled, it shows the rendered markdown alone.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BahtMarkdown extends BahtFieldBase {
|
|
12
|
+
/** Resolved registry uploader — <baht-form> injects it when `field.uploader` is set. */
|
|
13
|
+
uploader?: (file: File) => Promise<UploadedFile>;
|
|
14
|
+
/** Which image URLs may embed — <baht-form> injects `registry.markdownImage`. */
|
|
15
|
+
allowImage?: MarkdownImagePolicy;
|
|
16
|
+
private tab;
|
|
17
|
+
private dropping;
|
|
18
|
+
private uploadError;
|
|
19
|
+
private uploads;
|
|
20
|
+
private get textarea();
|
|
21
|
+
private select;
|
|
22
|
+
private readonly onTabKey;
|
|
23
|
+
private readonly onPaste;
|
|
24
|
+
private readonly onDragOver;
|
|
25
|
+
private readonly onDrop;
|
|
26
|
+
private readonly onPick;
|
|
27
|
+
private uploadAll;
|
|
28
|
+
/** The upload's placeholder becomes its result, wherever typing has moved it to. */
|
|
29
|
+
private fill;
|
|
30
|
+
private renderTab;
|
|
31
|
+
private renderView;
|
|
32
|
+
private renderHint;
|
|
33
|
+
protected renderControl(): TemplateResult;
|
|
34
|
+
}
|