@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,24 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { WorkflowDefinition } from '@20baht/engine';
|
|
3
|
+
import { BahtElement } from '../base.js';
|
|
4
|
+
/**
|
|
5
|
+
* Edits a workflow's `rules` without code: "when all / any of <field> <is>
|
|
6
|
+
* <value>, then show / hide / make mandatory / set value / skip step". Takes
|
|
7
|
+
* the `workflow` (its fields and steps are the choices) and emits
|
|
8
|
+
* `baht-change` with `{ rules }` on every edit. A rule it cannot represent
|
|
9
|
+
* (nested conditions) is shown as such and returned untouched.
|
|
10
|
+
* @fires {CustomEvent<{ rules: Rule[] }>} baht-change - A rule was edited.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BahtRuleBuilder extends BahtElement {
|
|
13
|
+
workflow: WorkflowDefinition | null;
|
|
14
|
+
private get rows();
|
|
15
|
+
private get fields();
|
|
16
|
+
private get steps();
|
|
17
|
+
private emitRows;
|
|
18
|
+
private change;
|
|
19
|
+
private firstField;
|
|
20
|
+
private actionFor;
|
|
21
|
+
private needsValue;
|
|
22
|
+
private renderRule;
|
|
23
|
+
protected render(): TemplateResult;
|
|
24
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { html as r, nothing as p } from "lit";
|
|
2
|
+
import { property as m } from "lit/decorators.js";
|
|
3
|
+
import { toRows as v, fieldChoices as $, toRules as g, CONDITION_OPS as d, ACTIONS as w } from "./rule-rows.js";
|
|
4
|
+
import { BahtElement as k, arr as b } from "../base.js";
|
|
5
|
+
import { customElement as y } from "../define.js";
|
|
6
|
+
var R = Object.defineProperty, F = Object.getOwnPropertyDescriptor, f = (e, o, i, a) => {
|
|
7
|
+
for (var t = a > 1 ? void 0 : a ? F(o, i) : o, s = e.length - 1, l; s >= 0; s--)
|
|
8
|
+
(l = e[s]) && (t = (a ? l(o, i, t) : l(t)) || t);
|
|
9
|
+
return a && t && R(o, i, t), t;
|
|
10
|
+
};
|
|
11
|
+
const c = (e) => e.target.value;
|
|
12
|
+
let u = class extends k {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.workflow = null;
|
|
15
|
+
}
|
|
16
|
+
get rows() {
|
|
17
|
+
var e;
|
|
18
|
+
return v(b((e = this.workflow) == null ? void 0 : e.rules));
|
|
19
|
+
}
|
|
20
|
+
get fields() {
|
|
21
|
+
return this.workflow ? $(this.workflow) : [];
|
|
22
|
+
}
|
|
23
|
+
get steps() {
|
|
24
|
+
var e;
|
|
25
|
+
return b((e = this.workflow) == null ? void 0 : e.forms).filter((o) => o.kind === "approval").map((o) => o.form_name);
|
|
26
|
+
}
|
|
27
|
+
emitRows(e) {
|
|
28
|
+
if (!this.workflow) return;
|
|
29
|
+
const o = g(e, this.workflow);
|
|
30
|
+
this.emit("baht-change", { rules: o });
|
|
31
|
+
}
|
|
32
|
+
change(e, o) {
|
|
33
|
+
this.emitRows(this.rows.map((i, a) => a === e ? o(i) : i));
|
|
34
|
+
}
|
|
35
|
+
firstField() {
|
|
36
|
+
var e;
|
|
37
|
+
return ((e = this.fields[0]) == null ? void 0 : e.ref) ?? "";
|
|
38
|
+
}
|
|
39
|
+
actionFor(e) {
|
|
40
|
+
return e === "skipForm" ? { action: "skipForm", form: this.steps[0] ?? "" } : e === "setValue" ? { action: "setValue", field: this.firstField(), value: "" } : { action: e, field: this.firstField() };
|
|
41
|
+
}
|
|
42
|
+
needsValue(e) {
|
|
43
|
+
var o;
|
|
44
|
+
return ((o = d.find((i) => i.op === e)) == null ? void 0 : o.needsValue) ?? !0;
|
|
45
|
+
}
|
|
46
|
+
renderRule(e, o) {
|
|
47
|
+
return e.raw ? r`<div class="baht-rule">
|
|
48
|
+
<p class="baht-rule-hint"><strong>${e.id}</strong> uses conditions this editor cannot show; it is kept as it is.</p>
|
|
49
|
+
<button type="button" class="baht-rule-link baht-rule-link--danger" @click=${() => {
|
|
50
|
+
this.emitRows(this.rows.filter((i, a) => a !== o));
|
|
51
|
+
}}>Remove rule</button>
|
|
52
|
+
</div>` : r`<div class="baht-rule">
|
|
53
|
+
<div class="baht-rule-line">
|
|
54
|
+
<strong>When</strong>
|
|
55
|
+
<select class="baht-control" aria-label="Match" @change=${(i) => {
|
|
56
|
+
this.change(o, (a) => ({ ...a, match: c(i) === "any" ? "any" : "all" }));
|
|
57
|
+
}}>
|
|
58
|
+
<option value="all" ?selected=${e.match === "all"}>all of these hold</option>
|
|
59
|
+
<option value="any" ?selected=${e.match === "any"}>any of these holds</option>
|
|
60
|
+
</select>
|
|
61
|
+
<button type="button" class="baht-rule-link baht-rule-link--danger baht-rule-push" @click=${() => {
|
|
62
|
+
this.emitRows(this.rows.filter((i, a) => a !== o));
|
|
63
|
+
}}>Remove rule</button>
|
|
64
|
+
</div>
|
|
65
|
+
${e.conditions.map(
|
|
66
|
+
(i, a) => r`<div class="baht-rule-line baht-rule-indent">
|
|
67
|
+
<select class="baht-control" aria-label="Field" @change=${(t) => {
|
|
68
|
+
this.change(o, (s) => ({
|
|
69
|
+
...s,
|
|
70
|
+
conditions: s.conditions.map((l, n) => n === a ? { ...l, field: c(t) } : l)
|
|
71
|
+
}));
|
|
72
|
+
}}>
|
|
73
|
+
${this.fields.map((t) => r`<option value=${t.ref} ?selected=${t.ref === i.field}>${t.label}</option>`)}
|
|
74
|
+
</select>
|
|
75
|
+
<select class="baht-control" aria-label="Comparison" @change=${(t) => {
|
|
76
|
+
this.change(o, (s) => ({
|
|
77
|
+
...s,
|
|
78
|
+
conditions: s.conditions.map(
|
|
79
|
+
(l, n) => n === a ? { ...l, op: c(t) } : l
|
|
80
|
+
)
|
|
81
|
+
}));
|
|
82
|
+
}}>
|
|
83
|
+
${d.map((t) => r`<option value=${t.op} ?selected=${t.op === i.op}>${t.label}</option>`)}
|
|
84
|
+
</select>
|
|
85
|
+
${this.needsValue(i.op) ? r`<input class="baht-control" aria-label="Value" .value=${i.value} @change=${(t) => {
|
|
86
|
+
this.change(o, (s) => ({
|
|
87
|
+
...s,
|
|
88
|
+
conditions: s.conditions.map(
|
|
89
|
+
(l, n) => n === a ? { ...l, value: c(t) } : l
|
|
90
|
+
)
|
|
91
|
+
}));
|
|
92
|
+
}} />` : p}
|
|
93
|
+
<button type="button" class="baht-rule-link" aria-label="Remove condition" @click=${() => {
|
|
94
|
+
this.change(o, (t) => ({ ...t, conditions: t.conditions.filter((s, l) => l !== a) }));
|
|
95
|
+
}}>✕</button>
|
|
96
|
+
</div>`
|
|
97
|
+
)}
|
|
98
|
+
<button type="button" class="baht-rule-link baht-rule-indent" @click=${() => {
|
|
99
|
+
this.change(o, (i) => ({
|
|
100
|
+
...i,
|
|
101
|
+
conditions: [...i.conditions, { field: this.firstField(), op: "eq", value: "" }]
|
|
102
|
+
}));
|
|
103
|
+
}}>+ condition</button>
|
|
104
|
+
<div class="baht-rule-line"><strong>Then</strong></div>
|
|
105
|
+
${e.actions.map(
|
|
106
|
+
(i, a) => r`<div class="baht-rule-line baht-rule-indent">
|
|
107
|
+
<select class="baht-control" aria-label="Action" @change=${(t) => {
|
|
108
|
+
const s = this.actionFor(c(t));
|
|
109
|
+
this.change(o, (l) => ({
|
|
110
|
+
...l,
|
|
111
|
+
actions: l.actions.map((n, h) => h === a ? s : n)
|
|
112
|
+
}));
|
|
113
|
+
}}>
|
|
114
|
+
${w.map((t) => r`<option value=${t.action} ?selected=${t.action === i.action}>${t.label}</option>`)}
|
|
115
|
+
</select>
|
|
116
|
+
<select class="baht-control" aria-label="Target" @change=${(t) => {
|
|
117
|
+
const s = c(t);
|
|
118
|
+
this.change(o, (l) => ({
|
|
119
|
+
...l,
|
|
120
|
+
actions: l.actions.map(
|
|
121
|
+
(n, h) => h !== a ? n : n.action === "skipForm" ? { ...n, form: s } : { ...n, field: s }
|
|
122
|
+
)
|
|
123
|
+
}));
|
|
124
|
+
}}>
|
|
125
|
+
${i.action === "skipForm" ? this.steps.map(
|
|
126
|
+
(t) => r`<option value=${t} ?selected=${t === i.form}>${t.replace(/_/g, " ")}</option>`
|
|
127
|
+
) : this.fields.map(
|
|
128
|
+
(t) => r`<option value=${t.ref} ?selected=${t.ref === i.field}>${t.label}</option>`
|
|
129
|
+
)}
|
|
130
|
+
</select>
|
|
131
|
+
${i.action === "setValue" ? r`<input class="baht-control" aria-label="New value" .value=${i.value} @change=${(t) => {
|
|
132
|
+
const s = c(t);
|
|
133
|
+
this.change(o, (l) => ({
|
|
134
|
+
...l,
|
|
135
|
+
actions: l.actions.map(
|
|
136
|
+
(n, h) => h === a && n.action === "setValue" ? { ...n, value: s } : n
|
|
137
|
+
)
|
|
138
|
+
}));
|
|
139
|
+
}} />` : p}
|
|
140
|
+
<button type="button" class="baht-rule-link" aria-label="Remove action" @click=${() => {
|
|
141
|
+
this.change(o, (t) => ({ ...t, actions: t.actions.filter((s, l) => l !== a) }));
|
|
142
|
+
}}>✕</button>
|
|
143
|
+
</div>`
|
|
144
|
+
)}
|
|
145
|
+
<button type="button" class="baht-rule-link baht-rule-indent" @click=${() => {
|
|
146
|
+
this.change(o, (i) => ({ ...i, actions: [...i.actions, this.actionFor("show")] }));
|
|
147
|
+
}}>+ action</button>
|
|
148
|
+
</div>`;
|
|
149
|
+
}
|
|
150
|
+
render() {
|
|
151
|
+
const e = this.rows;
|
|
152
|
+
return r`<div class="baht-rule-builder">
|
|
153
|
+
${e.length === 0 ? r`<p class="baht-rule-hint">No rules yet.</p>` : e.map((o, i) => this.renderRule(o, i))}
|
|
154
|
+
<button type="button" class="baht-button baht-button--secondary baht-button--sm" @click=${() => {
|
|
155
|
+
const o = this.firstField();
|
|
156
|
+
this.emitRows([
|
|
157
|
+
...e,
|
|
158
|
+
{
|
|
159
|
+
id: `rule-${Date.now().toString(36)}`,
|
|
160
|
+
match: "all",
|
|
161
|
+
conditions: [{ field: o, op: "eq", value: "" }],
|
|
162
|
+
actions: [{ action: "show", field: o }]
|
|
163
|
+
}
|
|
164
|
+
]);
|
|
165
|
+
}}>Add rule</button>
|
|
166
|
+
</div>`;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
f([
|
|
170
|
+
m({ attribute: !1 })
|
|
171
|
+
], u.prototype, "workflow", 2);
|
|
172
|
+
u = f([
|
|
173
|
+
y("baht-rule-builder")
|
|
174
|
+
], u);
|
|
175
|
+
export {
|
|
176
|
+
u as BahtRuleBuilder
|
|
177
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { FilterField, FilterValue, SavedFilter } from '@20baht/engine';
|
|
4
|
+
/**
|
|
5
|
+
* ServiceNow's Save Filters: name the filter being built, apply a saved one, delete one. It only
|
|
6
|
+
* edits the list; the host keeps it. A saved filter naming a column no longer on offer can be
|
|
7
|
+
* deleted but not applied, because dropping that condition would quietly match more rows than it
|
|
8
|
+
* was saved for.
|
|
9
|
+
*
|
|
10
|
+
* @fires {CustomEvent<{ value: FilterValue }>} baht-filter-pick - A saved filter was chosen. `detail: { value }`.
|
|
11
|
+
* @fires {CustomEvent<{ filters: SavedFilter[] }>} baht-saved-filters-change - One was saved or deleted. `detail: { filters }`.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BahtSavedFilters extends BahtElement {
|
|
14
|
+
filters: SavedFilter[];
|
|
15
|
+
/** The filter Save would keep. */
|
|
16
|
+
current: FilterValue;
|
|
17
|
+
/** What can be filtered on now. */
|
|
18
|
+
fields: FilterField[];
|
|
19
|
+
private chosen;
|
|
20
|
+
private naming;
|
|
21
|
+
private name;
|
|
22
|
+
private isStale;
|
|
23
|
+
private get chosenIsStale();
|
|
24
|
+
private commit;
|
|
25
|
+
private readonly onChoose;
|
|
26
|
+
private readonly onDelete;
|
|
27
|
+
private readonly onStartSaving;
|
|
28
|
+
private readonly onStopSaving;
|
|
29
|
+
private readonly onName;
|
|
30
|
+
/** The same name replaces the filter it names, where it stands. */
|
|
31
|
+
private readonly onSave;
|
|
32
|
+
private readonly onNameKeydown;
|
|
33
|
+
private renderNaming;
|
|
34
|
+
private renderChoosing;
|
|
35
|
+
protected render(): TemplateResult;
|
|
36
|
+
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface HTMLElementTagNameMap {
|
|
39
|
+
'baht-saved-filters': BahtSavedFilters;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { html as h, nothing as m } from "lit";
|
|
2
|
+
import { property as u, state as b } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as f } from "../base.js";
|
|
4
|
+
import { t as n } from "@20baht/engine";
|
|
5
|
+
import { customElement as p } from "../define.js";
|
|
6
|
+
var v = Object.defineProperty, d = Object.getOwnPropertyDescriptor, r = (t, e, s, i) => {
|
|
7
|
+
for (var o = i > 1 ? void 0 : i ? d(e, s) : e, l = t.length - 1, c; l >= 0; l--)
|
|
8
|
+
(c = t[l]) && (o = (i ? c(e, s, o) : c(o)) || o);
|
|
9
|
+
return i && o && v(e, s, o), o;
|
|
10
|
+
};
|
|
11
|
+
const g = { match: "all", conditions: [] };
|
|
12
|
+
let a = class extends f {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.filters = [], this.current = g, this.fields = [], this.chosen = "", this.naming = !1, this.name = "", this.onChoose = (t) => {
|
|
15
|
+
this.chosen = t.target.value;
|
|
16
|
+
const e = this.filters.find((s) => s.name === this.chosen);
|
|
17
|
+
e && !this.isStale(e) && this.emit("baht-filter-pick", { value: e.value });
|
|
18
|
+
}, this.onDelete = () => {
|
|
19
|
+
const { chosen: t } = this;
|
|
20
|
+
this.chosen = "", this.commit(this.filters.filter((e) => e.name !== t));
|
|
21
|
+
}, this.onStartSaving = () => {
|
|
22
|
+
this.name = this.chosen, this.naming = !0;
|
|
23
|
+
}, this.onStopSaving = () => {
|
|
24
|
+
this.naming = !1;
|
|
25
|
+
}, this.onName = (t) => {
|
|
26
|
+
this.name = t.target.value;
|
|
27
|
+
}, this.onSave = () => {
|
|
28
|
+
const t = this.name.trim();
|
|
29
|
+
if (!t || this.current.conditions.length === 0) return;
|
|
30
|
+
const e = { name: t, value: this.current }, s = this.filters.some((i) => i.name === t);
|
|
31
|
+
this.commit(
|
|
32
|
+
s ? this.filters.map((i) => i.name === t ? e : i) : [...this.filters, e]
|
|
33
|
+
), this.chosen = t, this.naming = !1;
|
|
34
|
+
}, this.onNameKeydown = (t) => {
|
|
35
|
+
t.key === "Enter" && (t.preventDefault(), this.onSave());
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
isStale(t) {
|
|
39
|
+
return t.value.conditions.some((e) => !this.fields.some((s) => s.key === e.field));
|
|
40
|
+
}
|
|
41
|
+
get chosenIsStale() {
|
|
42
|
+
const t = this.filters.find((e) => e.name === this.chosen);
|
|
43
|
+
return t !== void 0 && this.isStale(t);
|
|
44
|
+
}
|
|
45
|
+
commit(t) {
|
|
46
|
+
this.filters = t, this.emit("baht-saved-filters-change", { filters: t });
|
|
47
|
+
}
|
|
48
|
+
renderNaming() {
|
|
49
|
+
return h`<input
|
|
50
|
+
class="baht-control baht-saved-filters-name"
|
|
51
|
+
type="text"
|
|
52
|
+
maxlength="80"
|
|
53
|
+
aria-label=${n("filterSaveName")}
|
|
54
|
+
placeholder=${n("filterSaveName")}
|
|
55
|
+
.value=${this.name}
|
|
56
|
+
@input=${this.onName}
|
|
57
|
+
@keydown=${this.onNameKeydown}
|
|
58
|
+
/>
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
class="baht-saved-filters-confirm baht-button baht-button--secondary baht-button--sm"
|
|
62
|
+
?disabled=${!this.name.trim()}
|
|
63
|
+
@click=${this.onSave}
|
|
64
|
+
>${n("saveRow")}</button>
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
class="baht-button baht-button--ghost baht-button--sm"
|
|
68
|
+
@click=${this.onStopSaving}
|
|
69
|
+
>${n("cancelRow")}</button>`;
|
|
70
|
+
}
|
|
71
|
+
renderChoosing() {
|
|
72
|
+
return h`<button
|
|
73
|
+
type="button"
|
|
74
|
+
class="baht-saved-filters-save baht-button baht-button--ghost baht-button--sm"
|
|
75
|
+
?disabled=${this.current.conditions.length === 0}
|
|
76
|
+
@click=${this.onStartSaving}
|
|
77
|
+
>${n("saveRow")}</button>
|
|
78
|
+
${this.filters.length > 0 ? h`<select
|
|
79
|
+
class="baht-control baht-saved-filters-select"
|
|
80
|
+
aria-label=${n("filterSaved")}
|
|
81
|
+
@change=${this.onChoose}
|
|
82
|
+
>
|
|
83
|
+
<option value="" ?selected=${this.chosen === ""}>${n("filterSaved")}</option>
|
|
84
|
+
${this.filters.map((t) => h`<option
|
|
85
|
+
value=${t.name}
|
|
86
|
+
?selected=${t.name === this.chosen}
|
|
87
|
+
>${t.name}</option>`)}
|
|
88
|
+
</select>` : m}
|
|
89
|
+
${this.chosen ? h`<button
|
|
90
|
+
type="button"
|
|
91
|
+
class="baht-saved-filters-delete baht-button baht-button--ghost baht-button--sm"
|
|
92
|
+
aria-label=${n("filterDelete", { name: this.chosen })}
|
|
93
|
+
@click=${this.onDelete}
|
|
94
|
+
>×</button>` : m}
|
|
95
|
+
${this.chosenIsStale ? h`<span class="baht-saved-filters-stale" role="status">${n("filterStale")}</span>` : m}`;
|
|
96
|
+
}
|
|
97
|
+
render() {
|
|
98
|
+
return h`<div class="baht-saved-filters">
|
|
99
|
+
${this.naming ? this.renderNaming() : this.renderChoosing()}
|
|
100
|
+
</div>`;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
r([
|
|
104
|
+
u({ attribute: !1 })
|
|
105
|
+
], a.prototype, "filters", 2);
|
|
106
|
+
r([
|
|
107
|
+
u({ attribute: !1 })
|
|
108
|
+
], a.prototype, "current", 2);
|
|
109
|
+
r([
|
|
110
|
+
u({ attribute: !1 })
|
|
111
|
+
], a.prototype, "fields", 2);
|
|
112
|
+
r([
|
|
113
|
+
b()
|
|
114
|
+
], a.prototype, "chosen", 2);
|
|
115
|
+
r([
|
|
116
|
+
b()
|
|
117
|
+
], a.prototype, "naming", 2);
|
|
118
|
+
r([
|
|
119
|
+
b()
|
|
120
|
+
], a.prototype, "name", 2);
|
|
121
|
+
a = r([
|
|
122
|
+
p("baht-saved-filters")
|
|
123
|
+
], a);
|
|
124
|
+
export {
|
|
125
|
+
a as BahtSavedFilters
|
|
126
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* A search box outside a form: beside a table's title, over a list. It sends the term as you
|
|
5
|
+
* type, after a quiet spell (`debounce`), and at once on Enter; Escape clears it. The element
|
|
6
|
+
* filters nothing itself: the host narrows its rows on `baht-search`.
|
|
7
|
+
*
|
|
8
|
+
* <baht-search placeholder="Search servers" label="Search servers"></baht-search>
|
|
9
|
+
* search.addEventListener('baht-search', (e) => (term = e.detail.value));
|
|
10
|
+
*
|
|
11
|
+
* @fires {CustomEvent<{ value: string }>} baht-search - The term changed (after `debounce` ms of quiet, on Enter, or cleared by Escape); `value` is already set.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BahtSearch extends BahtElement {
|
|
14
|
+
/** The term. */
|
|
15
|
+
value: string;
|
|
16
|
+
placeholder: string;
|
|
17
|
+
/** Accessible name; `t('search')` when empty. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Milliseconds of quiet before the term is sent while typing; 0 sends every keystroke. */
|
|
20
|
+
debounce: number;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
private timer;
|
|
23
|
+
private sent;
|
|
24
|
+
disconnectedCallback(): void;
|
|
25
|
+
private send;
|
|
26
|
+
private readonly onInput;
|
|
27
|
+
private readonly onKeydown;
|
|
28
|
+
protected render(): TemplateResult;
|
|
29
|
+
}
|
|
30
|
+
declare global {
|
|
31
|
+
interface HTMLElementTagNameMap {
|
|
32
|
+
'baht-search': BahtSearch;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { html as p } from "lit";
|
|
2
|
+
import { property as o } from "lit/decorators.js";
|
|
3
|
+
import { live as c } from "lit/directives/live.js";
|
|
4
|
+
import { BahtElement as u } from "../base.js";
|
|
5
|
+
import { renderIcon as d } from "./icons.js";
|
|
6
|
+
import { customElement as m } from "../define.js";
|
|
7
|
+
import { t as b } from "@20baht/engine";
|
|
8
|
+
var v = Object.defineProperty, f = Object.getOwnPropertyDescriptor, i = (e, t, l, a) => {
|
|
9
|
+
for (var s = a > 1 ? void 0 : a ? f(t, l) : t, n = e.length - 1, h; n >= 0; n--)
|
|
10
|
+
(h = e[n]) && (s = (a ? h(t, l, s) : h(s)) || s);
|
|
11
|
+
return a && s && v(t, l, s), s;
|
|
12
|
+
};
|
|
13
|
+
let r = class extends u {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.value = "", this.placeholder = "", this.label = "", this.debounce = 250, this.disabled = !1, this.sent = null, this.onInput = (e) => {
|
|
16
|
+
const t = e.target.value;
|
|
17
|
+
if (clearTimeout(this.timer), this.debounce <= 0) {
|
|
18
|
+
this.send(t);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.timer = setTimeout(() => {
|
|
22
|
+
this.send(t);
|
|
23
|
+
}, this.debounce);
|
|
24
|
+
}, this.onKeydown = (e) => {
|
|
25
|
+
const t = e.target;
|
|
26
|
+
e.key === "Enter" ? (e.preventDefault(), this.send(t.value)) : e.key === "Escape" && t.value !== "" && (e.preventDefault(), t.value = "", this.send(""));
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
disconnectedCallback() {
|
|
30
|
+
clearTimeout(this.timer), super.disconnectedCallback();
|
|
31
|
+
}
|
|
32
|
+
send(e) {
|
|
33
|
+
clearTimeout(this.timer), this.timer = void 0, this.value = e, e !== this.sent && (this.sent = e, this.emit("baht-search", { value: e }));
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
return p`<span class="baht-search">
|
|
37
|
+
${d("search")}
|
|
38
|
+
<input
|
|
39
|
+
class="baht-control baht-search-input"
|
|
40
|
+
type="search"
|
|
41
|
+
.value=${c(this.value)}
|
|
42
|
+
placeholder=${this.placeholder}
|
|
43
|
+
aria-label=${this.label || b("search")}
|
|
44
|
+
?disabled=${this.disabled}
|
|
45
|
+
@input=${this.onInput}
|
|
46
|
+
@keydown=${this.onKeydown}
|
|
47
|
+
/>
|
|
48
|
+
</span>`;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
i([
|
|
52
|
+
o()
|
|
53
|
+
], r.prototype, "value", 2);
|
|
54
|
+
i([
|
|
55
|
+
o()
|
|
56
|
+
], r.prototype, "placeholder", 2);
|
|
57
|
+
i([
|
|
58
|
+
o()
|
|
59
|
+
], r.prototype, "label", 2);
|
|
60
|
+
i([
|
|
61
|
+
o({ type: Number })
|
|
62
|
+
], r.prototype, "debounce", 2);
|
|
63
|
+
i([
|
|
64
|
+
o({ type: Boolean })
|
|
65
|
+
], r.prototype, "disabled", 2);
|
|
66
|
+
r = i([
|
|
67
|
+
m("baht-search")
|
|
68
|
+
], r);
|
|
69
|
+
export {
|
|
70
|
+
r as BahtSearch
|
|
71
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* The head of a titled section of a page: a heading, a line about it and its actions. Lighter
|
|
5
|
+
* than `<baht-page-header>` (one per page), heavier than `<baht-card heading>` (one per card).
|
|
6
|
+
* Children are the actions, at the end of the row.
|
|
7
|
+
*
|
|
8
|
+
* <baht-section-header heading="In your cloud" description="Images you uploaded or downloaded.">
|
|
9
|
+
* <baht-button variant="secondary" icon="upload">Upload</baht-button>
|
|
10
|
+
* </baht-section-header>
|
|
11
|
+
*/
|
|
12
|
+
export declare class BahtSectionHeader extends BahtElement {
|
|
13
|
+
/** Section title. */
|
|
14
|
+
heading: string;
|
|
15
|
+
/** One line about the section, under the title. */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Heading level: 2 (default), 3 or 4. Anything else renders `<h2>`. */
|
|
18
|
+
level: 2 | 3 | 4;
|
|
19
|
+
private actionsEl;
|
|
20
|
+
protected adoptChildren(): void;
|
|
21
|
+
private renderHeading;
|
|
22
|
+
protected render(): TemplateResult;
|
|
23
|
+
}
|
|
24
|
+
declare global {
|
|
25
|
+
interface HTMLElementTagNameMap {
|
|
26
|
+
'baht-section-header': BahtSectionHeader;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { html as i, nothing as p } from "lit";
|
|
2
|
+
import { property as d, query as l } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as v, adoptLightChildren as m } from "../base.js";
|
|
4
|
+
import { customElement as b } from "../define.js";
|
|
5
|
+
var u = Object.defineProperty, f = Object.getOwnPropertyDescriptor, s = (t, h, n, o) => {
|
|
6
|
+
for (var e = o > 1 ? void 0 : o ? f(h, n) : h, a = t.length - 1, c; a >= 0; a--)
|
|
7
|
+
(c = t[a]) && (e = (o ? c(h, n, e) : c(e)) || e);
|
|
8
|
+
return o && e && u(h, n, e), e;
|
|
9
|
+
};
|
|
10
|
+
let r = class extends v {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.heading = "", this.description = "", this.level = 2;
|
|
13
|
+
}
|
|
14
|
+
adoptChildren() {
|
|
15
|
+
m(this, this.actionsEl);
|
|
16
|
+
}
|
|
17
|
+
renderHeading() {
|
|
18
|
+
const t = this.heading;
|
|
19
|
+
return this.level === 3 ? i`<h3 class="baht-section-header-title">${t}</h3>` : this.level === 4 ? i`<h4 class="baht-section-header-title">${t}</h4>` : i`<h2 class="baht-section-header-title">${t}</h2>`;
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
return i`<div class="baht-section-header">
|
|
23
|
+
<div class="baht-section-header-text">
|
|
24
|
+
${this.renderHeading()}
|
|
25
|
+
${this.description ? i`<p class="baht-section-header-description">${this.description}</p>` : p}
|
|
26
|
+
</div>
|
|
27
|
+
<div class="baht-section-header-actions"></div>
|
|
28
|
+
</div>`;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
s([
|
|
32
|
+
d()
|
|
33
|
+
], r.prototype, "heading", 2);
|
|
34
|
+
s([
|
|
35
|
+
d()
|
|
36
|
+
], r.prototype, "description", 2);
|
|
37
|
+
s([
|
|
38
|
+
d({ type: Number })
|
|
39
|
+
], r.prototype, "level", 2);
|
|
40
|
+
s([
|
|
41
|
+
l(".baht-section-header-actions")
|
|
42
|
+
], r.prototype, "actionsEl", 2);
|
|
43
|
+
r = s([
|
|
44
|
+
b("baht-section-header")
|
|
45
|
+
], r);
|
|
46
|
+
export {
|
|
47
|
+
r as BahtSectionHeader
|
|
48
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { FieldDescriptor } from '@20baht/engine';
|
|
4
|
+
/**
|
|
5
|
+
* Section divider (`type: "section"`): heading + rule, no value. With `field.collapsible` the
|
|
6
|
+
* heading is a button that folds what follows; `<baht-form>` hides those fields.
|
|
7
|
+
*
|
|
8
|
+
* @fires {CustomEvent<{ collapsed: boolean }>} baht-section-toggle - The user folded or unfolded it. `detail: { collapsed }`.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BahtSection extends BahtElement {
|
|
11
|
+
field: FieldDescriptor;
|
|
12
|
+
/** Folded right now. */
|
|
13
|
+
collapsed: boolean;
|
|
14
|
+
/** `field` as the host may actually have left it: a framework can bind it after connecting. */
|
|
15
|
+
private get assignedField();
|
|
16
|
+
private readonly onToggle;
|
|
17
|
+
protected render(): TemplateResult | typeof nothing;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
'baht-section': BahtSection;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { nothing as h, html as c } from "lit";
|
|
2
|
+
import { property as p } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as d } from "../base.js";
|
|
4
|
+
import { customElement as f } from "../define.js";
|
|
5
|
+
var b = Object.defineProperty, u = Object.getOwnPropertyDescriptor, n = (e, s, i, l) => {
|
|
6
|
+
for (var t = l > 1 ? void 0 : l ? u(s, i) : s, a = e.length - 1, r; a >= 0; a--)
|
|
7
|
+
(r = e[a]) && (t = (l ? r(s, i, t) : r(t)) || t);
|
|
8
|
+
return l && t && b(s, i, t), t;
|
|
9
|
+
};
|
|
10
|
+
let o = class extends d {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments), this.collapsed = !1, this.onToggle = () => {
|
|
13
|
+
this.collapsed = !this.collapsed, this.emit("baht-section-toggle", { collapsed: this.collapsed });
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** `field` as the host may actually have left it: a framework can bind it after connecting. */
|
|
17
|
+
get assignedField() {
|
|
18
|
+
return this.field;
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
if (!this.assignedField) return h;
|
|
22
|
+
const e = this.field.text ?? this.field.label ?? "";
|
|
23
|
+
return this.field.collapsible ? c`<div class="baht-section">
|
|
24
|
+
<button
|
|
25
|
+
type="button"
|
|
26
|
+
class="baht-section-toggle"
|
|
27
|
+
aria-expanded=${this.collapsed ? "false" : "true"}
|
|
28
|
+
@click=${this.onToggle}
|
|
29
|
+
>
|
|
30
|
+
<span class="baht-section-chevron" aria-hidden="true">${this.collapsed ? "▸" : "▾"}</span>
|
|
31
|
+
<span class="baht-section-label">${e}</span>
|
|
32
|
+
</button>
|
|
33
|
+
</div>` : c`<div class="baht-section">
|
|
34
|
+
<span class="baht-section-label">${e}</span>
|
|
35
|
+
</div>`;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
n([
|
|
39
|
+
p({ attribute: !1 })
|
|
40
|
+
], o.prototype, "field", 2);
|
|
41
|
+
n([
|
|
42
|
+
p({ type: Boolean, reflect: !0 })
|
|
43
|
+
], o.prototype, "collapsed", 2);
|
|
44
|
+
o = n([
|
|
45
|
+
f("baht-section")
|
|
46
|
+
], o);
|
|
47
|
+
export {
|
|
48
|
+
o as BahtSection
|
|
49
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtFieldBase } from '../field-base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Single-choice dropdown. Renders ITS OWN list (light DOM, positioned under
|
|
5
|
+
* the trigger) instead of the native `<select>` — so the picker looks the same
|
|
6
|
+
* on iOS/macOS as everywhere else (no UIKit wheel, no AppKit menu), and every
|
|
7
|
+
* option is styleable with the tokens.
|
|
8
|
+
*
|
|
9
|
+
* ARIA: APG "select-only combobox". The trigger is a `<button role="combobox">`
|
|
10
|
+
* (so `<label for>` still names it); `aria-activedescendant` tracks the
|
|
11
|
+
* highlighted option while focus stays on the trigger. Keys: Arrow Up/Down,
|
|
12
|
+
* Home/End, Enter/Space pick, Escape closes, Tab picks the highlighted option
|
|
13
|
+
* and moves on, typing jumps to the first option starting with those letters
|
|
14
|
+
* (while closed it picks it directly, like a native select).
|
|
15
|
+
*
|
|
16
|
+
* An option's `description` renders as a muted second line under its label in
|
|
17
|
+
* the list, and after the label on the closed trigger while it is selected
|
|
18
|
+
* (e.g. label "Food", description "฿580 left").
|
|
19
|
+
*
|
|
20
|
+
* Value contract unchanged: option `key`, or `null` for the placeholder row.
|
|
21
|
+
*/
|
|
22
|
+
export declare class BahtSelect extends BahtFieldBase {
|
|
23
|
+
constructor();
|
|
24
|
+
private open;
|
|
25
|
+
/** Index into `rows` (0 = the placeholder row) — the highlighted option. */
|
|
26
|
+
private active;
|
|
27
|
+
private typeBuffer;
|
|
28
|
+
private readonly combo;
|
|
29
|
+
private get listId();
|
|
30
|
+
private optionId;
|
|
31
|
+
/** Placeholder row first (picks `null`), then the field's options. */
|
|
32
|
+
private get rows();
|
|
33
|
+
private get currentKey();
|
|
34
|
+
private get selectedIndex();
|
|
35
|
+
private get interactive();
|
|
36
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
37
|
+
protected updated(): void;
|
|
38
|
+
private openList;
|
|
39
|
+
private close;
|
|
40
|
+
private toggle;
|
|
41
|
+
private commit;
|
|
42
|
+
private highlight;
|
|
43
|
+
/** ArrowUp/Down/Home/End: stops at the ends (a native select does not wrap). */
|
|
44
|
+
private move;
|
|
45
|
+
/** Type-to-select: first option (after the highlighted one) starting with the buffer. */
|
|
46
|
+
private typeahead;
|
|
47
|
+
private onKeydown;
|
|
48
|
+
protected renderControl(): TemplateResult;
|
|
49
|
+
}
|