@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,630 @@
|
|
|
1
|
+
import { nothing as c, html as y } from "lit";
|
|
2
|
+
import { property as p, state as I } from "lit/decorators.js";
|
|
3
|
+
import { repeat as V } from "lit/directives/repeat.js";
|
|
4
|
+
import { html as b } from "lit/static-html.js";
|
|
5
|
+
import { BahtElement as _, obj as D, hasDom as O } from "./base.js";
|
|
6
|
+
import { TAG_FOR_TYPE as q, WIDTH_CLASS as j, staticTag as P } from "./primitives/tag-map.js";
|
|
7
|
+
import { emptyFormState as B, updateForm as C, createScriptContext as K, applyFlags as A, resolveViewFields as T, formFieldState as W, defaultValue as E, formData as R, displayValue as U } from "@20baht/engine";
|
|
8
|
+
import "./primitives/baht-input.js";
|
|
9
|
+
import "./primitives/baht-textarea.js";
|
|
10
|
+
import "./primitives/baht-markdown.js";
|
|
11
|
+
import "./primitives/baht-number.js";
|
|
12
|
+
import "./primitives/baht-currency.js";
|
|
13
|
+
import "./primitives/baht-select.js";
|
|
14
|
+
import "./primitives/baht-multiselect.js";
|
|
15
|
+
import "./primitives/baht-tags.js";
|
|
16
|
+
import "./primitives/baht-checkbox.js";
|
|
17
|
+
import "./primitives/baht-radio.js";
|
|
18
|
+
import "./primitives/baht-toggle.js";
|
|
19
|
+
import "./primitives/baht-rating.js";
|
|
20
|
+
import "./primitives/baht-range.js";
|
|
21
|
+
import "./primitives/baht-reference-picker.js";
|
|
22
|
+
import "./primitives/baht-datepicker.js";
|
|
23
|
+
import "./primitives/baht-file.js";
|
|
24
|
+
import "./primitives/baht-text.js";
|
|
25
|
+
import "./primitives/baht-section.js";
|
|
26
|
+
import "./primitives/baht-tabs.js";
|
|
27
|
+
import "./primitives/baht-repeater.js";
|
|
28
|
+
import { customElement as G } from "./define.js";
|
|
29
|
+
import { ReferenceLabels as H } from "./reference-labels.js";
|
|
30
|
+
import { DynamicOptions as N } from "./form-options.js";
|
|
31
|
+
import { renderReadonlyField as Y } from "./form-readonly.js";
|
|
32
|
+
import { buildLayout as z, rowStyle as $, isTabSection as J, tabClass as x, foldClass as M } from "./form-layout.js";
|
|
33
|
+
var Q = Object.defineProperty, X = Object.getOwnPropertyDescriptor, l = (t, e, s, r) => {
|
|
34
|
+
for (var i = r > 1 ? void 0 : r ? X(e, s) : e, o = t.length - 1, n; o >= 0; o--)
|
|
35
|
+
(n = t[o]) && (i = (r ? n(e, s, i) : n(i)) || i);
|
|
36
|
+
return r && i && Q(e, s, i), i;
|
|
37
|
+
};
|
|
38
|
+
const F = (t) => t.split("[")[0] ?? t, Z = /* @__PURE__ */ new Set([
|
|
39
|
+
"text",
|
|
40
|
+
"email",
|
|
41
|
+
"password",
|
|
42
|
+
"number",
|
|
43
|
+
"currency",
|
|
44
|
+
"time"
|
|
45
|
+
]);
|
|
46
|
+
let h = class extends _ {
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments), this.value = {}, this.registry = {}, this.showOptional = !1, this.options = {}, this.fieldStates = {}, this.flags = {}, this.tab = "", this.readonly = !1, this.submitOnEnter = !1, this.busy = !1, this.session = B, this.folded = /* @__PURE__ */ new Set(), this.stepping = !1, this.queued = [], this.stepSink = null, this.scriptContext = null, this.referenceLabels = new H(() => {
|
|
49
|
+
this.requestUpdate();
|
|
50
|
+
}), this.warnedLookups = /* @__PURE__ */ new Set(), this.loadedForm = null, this.dynamicOptions = new N({
|
|
51
|
+
form: () => this.effectiveForm,
|
|
52
|
+
data: () => this.getData(),
|
|
53
|
+
registry: () => this.registry,
|
|
54
|
+
refresh: () => {
|
|
55
|
+
this.requestUpdate();
|
|
56
|
+
}
|
|
57
|
+
}), this.warnedViews = /* @__PURE__ */ new Set(), this.flagCache = {}, this.sortedCache = {
|
|
58
|
+
out: []
|
|
59
|
+
}, this.lastVisible = {}, this.nextVisible = {}, this.rowStatesSeen = /* @__PURE__ */ new Map(), this.rowErrorsSeen = /* @__PURE__ */ new Map(), this.defaultsSeen = /* @__PURE__ */ new WeakMap(), this.rowLookup = (t, e) => this.lookupFor(t, e);
|
|
60
|
+
}
|
|
61
|
+
get edits() {
|
|
62
|
+
return this.session.edits;
|
|
63
|
+
}
|
|
64
|
+
get errors() {
|
|
65
|
+
return this.session.errors;
|
|
66
|
+
}
|
|
67
|
+
get fieldMessages() {
|
|
68
|
+
return this.session.fieldMessages;
|
|
69
|
+
}
|
|
70
|
+
get formMessages() {
|
|
71
|
+
return this.session.formMessages;
|
|
72
|
+
}
|
|
73
|
+
/** What the session is told of this element on every step. */
|
|
74
|
+
sessionInput(t) {
|
|
75
|
+
return {
|
|
76
|
+
form: t,
|
|
77
|
+
value: this.value,
|
|
78
|
+
registry: this.registry,
|
|
79
|
+
fieldStates: this.fieldStates,
|
|
80
|
+
view: this.view,
|
|
81
|
+
validateOn: this.options.validateOn
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One step of the session: it works out the next state and the events, this element keeps
|
|
86
|
+
* the state and dispatches them in order. `settled` runs between the two.
|
|
87
|
+
*/
|
|
88
|
+
send(t, e) {
|
|
89
|
+
const s = this.effectiveForm;
|
|
90
|
+
if (!s) return;
|
|
91
|
+
if (this.stepping) {
|
|
92
|
+
this.queued.push(t);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.stepping = !0;
|
|
96
|
+
let r;
|
|
97
|
+
try {
|
|
98
|
+
r = C(this.sessionInput(s), this.session, t, {
|
|
99
|
+
context: (o, n) => (this.stepSink = n, this.g(s))
|
|
100
|
+
});
|
|
101
|
+
} finally {
|
|
102
|
+
this.stepping = !1, this.stepSink = null;
|
|
103
|
+
}
|
|
104
|
+
this.session = r.state, this.dynamicOptions.sync(), e == null || e(r.state);
|
|
105
|
+
for (const o of r.events) this.emit(o.name, o.detail);
|
|
106
|
+
const i = this.queued.shift();
|
|
107
|
+
i && this.send(i);
|
|
108
|
+
}
|
|
109
|
+
g(t) {
|
|
110
|
+
var r;
|
|
111
|
+
if (((r = this.scriptContext) == null ? void 0 : r.form) === t) return this.scriptContext.g;
|
|
112
|
+
const e = (i) => {
|
|
113
|
+
this.stepSink ? i(this.stepSink) : this.send({ type: "script", write: i });
|
|
114
|
+
}, s = K(t, {
|
|
115
|
+
getData: () => this.stepSink ? this.stepSink.getData() : this.getData(),
|
|
116
|
+
setValue: (i, o) => {
|
|
117
|
+
e((n) => {
|
|
118
|
+
n.setValue(i, o);
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
setState: (i, o) => {
|
|
122
|
+
e((n) => {
|
|
123
|
+
n.setState(i, o);
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
resetState: (i) => {
|
|
127
|
+
e((o) => {
|
|
128
|
+
o.resetState(i);
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
setFieldMessage: (i, o) => {
|
|
132
|
+
e((n) => {
|
|
133
|
+
n.setFieldMessage(i, o);
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
addFormMessage: (i) => {
|
|
137
|
+
e((o) => {
|
|
138
|
+
o.addFormMessage(i);
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
clearFormMessages: () => {
|
|
142
|
+
e((i) => {
|
|
143
|
+
i.clearFormMessages();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return this.scriptContext = { form: t, g: s }, s;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* `form` as the host may actually have left it: a framework can connect the element
|
|
151
|
+
* before it binds the property, so internally it is optional until then.
|
|
152
|
+
*/
|
|
153
|
+
get assignedForm() {
|
|
154
|
+
return this.form;
|
|
155
|
+
}
|
|
156
|
+
get effectiveForm() {
|
|
157
|
+
const t = this.assignedForm;
|
|
158
|
+
if (t)
|
|
159
|
+
return (this.flagCache.form !== t || this.flagCache.flags !== this.flags) && (this.flagCache = { form: t, flags: this.flags, out: A(t, this.flags) }), this.flagCache.out;
|
|
160
|
+
}
|
|
161
|
+
willUpdate(t) {
|
|
162
|
+
var e;
|
|
163
|
+
if ((t.has("form") || t.has("flags")) && this.dynamicOptions.clear(), t.has("value")) {
|
|
164
|
+
const s = D(t.get("value"));
|
|
165
|
+
this.step({ type: "value", previous: s });
|
|
166
|
+
}
|
|
167
|
+
t.has("form") && (this.step({ type: "form", previous: t.get("form") }), this.folded = new Set(
|
|
168
|
+
(((e = this.assignedForm) == null ? void 0 : e.fields) ?? []).filter((s) => s.type === "section" && s.collapsible && s.collapsed).map((s) => s.key)
|
|
169
|
+
)), (t.has("form") || t.has("flags") || t.has("value") || t.has("registry")) && this.dynamicOptions.sync();
|
|
170
|
+
}
|
|
171
|
+
/** A step that tells nothing and needs no options refetch: `willUpdate` syncs them itself. */
|
|
172
|
+
step(t) {
|
|
173
|
+
const e = this.effectiveForm;
|
|
174
|
+
e && (this.session = C(this.sessionInput(e), this.session, t).state);
|
|
175
|
+
}
|
|
176
|
+
get sortedFields() {
|
|
177
|
+
const t = this.effectiveForm;
|
|
178
|
+
if (!t) return [];
|
|
179
|
+
const e = this.sortedCache;
|
|
180
|
+
if (e.form === t && e.view === this.view) return e.out;
|
|
181
|
+
const s = this.resolveSortedFields(t);
|
|
182
|
+
return this.sortedCache = { form: t, view: this.view, out: s }, s;
|
|
183
|
+
}
|
|
184
|
+
resolveSortedFields(t) {
|
|
185
|
+
const e = T(t, this.view);
|
|
186
|
+
return e || (this.view !== void 0 && !this.warnedViews.has(this.view) && (this.warnedViews.add(this.view), console.warn(`[bahtui] unknown view "${this.view}" — showing the full form`)), T(t) ?? []);
|
|
187
|
+
}
|
|
188
|
+
tabLayout() {
|
|
189
|
+
var t, e;
|
|
190
|
+
return z({
|
|
191
|
+
fields: this.sortedFields,
|
|
192
|
+
visible: (s) => this.stateFor(s).visible,
|
|
193
|
+
tab: this.tab,
|
|
194
|
+
folded: this.folded,
|
|
195
|
+
twoColumn: ((e = (t = this.effectiveForm) == null ? void 0 : t.layout) == null ? void 0 : e.columns) === 2
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
selectTab(t) {
|
|
199
|
+
t !== this.tab && (this.tab = t, this.dispatchEvent(
|
|
200
|
+
new CustomEvent("baht-tab-change", {
|
|
201
|
+
detail: { value: t },
|
|
202
|
+
bubbles: !0,
|
|
203
|
+
composed: !0
|
|
204
|
+
})
|
|
205
|
+
));
|
|
206
|
+
}
|
|
207
|
+
toggleFold(t, e) {
|
|
208
|
+
const s = new Set(this.folded);
|
|
209
|
+
e ? s.add(t) : s.delete(t), this.folded = s;
|
|
210
|
+
}
|
|
211
|
+
/** After a validate(): when no error can be seen, open the first tab that has one. */
|
|
212
|
+
openTabWithError(t) {
|
|
213
|
+
const { owner: e, open: s, showing: r, section: i } = this.tabLayout(), o = t.map((a) => i.get(F(a.key)));
|
|
214
|
+
o.some((a) => a !== void 0 && this.folded.has(a)) && (this.folded = new Set([...this.folded].filter((a) => !o.includes(a))));
|
|
215
|
+
const n = t.filter((a) => a.key !== "$").map((a) => e.get(F(a.key)));
|
|
216
|
+
if (n.some((a) => a === void 0 || a === s)) return;
|
|
217
|
+
const u = r.find((a) => n.includes(a.key));
|
|
218
|
+
u && this.selectTab(u.key);
|
|
219
|
+
}
|
|
220
|
+
renderTabStrip(t) {
|
|
221
|
+
if (t.showing.length === 0) return c;
|
|
222
|
+
const e = /* @__PURE__ */ new Map();
|
|
223
|
+
for (const r of this.errors) {
|
|
224
|
+
const i = t.owner.get(F(r.key));
|
|
225
|
+
i && e.set(i, (e.get(i) ?? 0) + 1);
|
|
226
|
+
}
|
|
227
|
+
const s = t.showing.map(({ key: r, label: i }) => {
|
|
228
|
+
const o = e.get(r);
|
|
229
|
+
return o ? { key: r, label: i, badge: String(o) } : { key: r, label: i };
|
|
230
|
+
});
|
|
231
|
+
return y`<div
|
|
232
|
+
class="baht-form-tabs"
|
|
233
|
+
style=${t.first ? $(t, t.first) : c}
|
|
234
|
+
>
|
|
235
|
+
<baht-tabs
|
|
236
|
+
.tabs=${s}
|
|
237
|
+
.value=${t.open ?? ""}
|
|
238
|
+
.label=${this.form.form_name}
|
|
239
|
+
@baht-change=${(r) => {
|
|
240
|
+
r.stopPropagation(), this.selectTab(r.detail.value);
|
|
241
|
+
}}
|
|
242
|
+
></baht-tabs>
|
|
243
|
+
</div>`;
|
|
244
|
+
}
|
|
245
|
+
revealClass(t, e) {
|
|
246
|
+
return this.nextVisible[t] = e, e && this.lastVisible[t] === !1 ? " baht-field--revealed" : "";
|
|
247
|
+
}
|
|
248
|
+
stateFor(t) {
|
|
249
|
+
const e = this.effectiveForm;
|
|
250
|
+
return W(
|
|
251
|
+
e ? this.sessionInput(e) : { form: this.form },
|
|
252
|
+
this.session,
|
|
253
|
+
t
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
/** The row sub-field states of one repeater: `fieldStates` keys starting `key[`. */
|
|
257
|
+
rowStatesFor(t) {
|
|
258
|
+
const e = `${t}[`, s = {};
|
|
259
|
+
for (const [i, o] of Object.entries(this.fieldStates))
|
|
260
|
+
i.startsWith(e) && (s[i] = o);
|
|
261
|
+
const r = this.rowStatesSeen.get(t);
|
|
262
|
+
return r && tt(r, s) ? r : (this.rowStatesSeen.set(t, s), s);
|
|
263
|
+
}
|
|
264
|
+
rowErrorsFor(t) {
|
|
265
|
+
const e = `${t}[`, s = this.errors.filter((i) => i.key.startsWith(e)), r = this.rowErrorsSeen.get(t);
|
|
266
|
+
return (r == null ? void 0 : r.length) === s.length && r.every((i, o) => {
|
|
267
|
+
var n, u;
|
|
268
|
+
return i.key === ((n = s.at(o)) == null ? void 0 : n.key) && i.message === ((u = s.at(o)) == null ? void 0 : u.message);
|
|
269
|
+
}) ? r : (this.rowErrorsSeen.set(t, s), s);
|
|
270
|
+
}
|
|
271
|
+
/** `valueFor` for the render path: an unset collection field keeps one default array. */
|
|
272
|
+
renderValueFor(t) {
|
|
273
|
+
return Object.hasOwn(this.edits, t.key) || Object.hasOwn(this.value, t.key) ? this.valueFor(t) : (this.defaultsSeen.has(t) || this.defaultsSeen.set(t, E(t)), this.defaultsSeen.get(t));
|
|
274
|
+
}
|
|
275
|
+
valueFor(t) {
|
|
276
|
+
return Object.hasOwn(this.edits, t.key) ? this.edits[t.key] : Object.hasOwn(this.value, t.key) ? this.value[t.key] : E(t);
|
|
277
|
+
}
|
|
278
|
+
// ---- public API (spec 01 §6) ----
|
|
279
|
+
/**
|
|
280
|
+
* Keystrokes still in a control's debounce land now: each emits its `baht-change`, as when the
|
|
281
|
+
* field loses focus. `getData()`, `validate()` and `setValue()` do this first, so a read never
|
|
282
|
+
* misses what was typed; `<baht-workflow>` calls it before reading its own data.
|
|
283
|
+
*/
|
|
284
|
+
flushTyped() {
|
|
285
|
+
var t;
|
|
286
|
+
for (const e of this.controls()) (t = e.flushTyped) == null || t.call(e);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Forget keystrokes still in a control's debounce (all, or those of `keys`): the control shows
|
|
290
|
+
* `value` again and nothing is emitted. For a host replacing what the form shows (`restore()`).
|
|
291
|
+
*/
|
|
292
|
+
discardTyped(t) {
|
|
293
|
+
var e, s;
|
|
294
|
+
for (const r of this.controls()) {
|
|
295
|
+
const i = ((e = r.parentElement) == null ? void 0 : e.getAttribute("data-key")) ?? "";
|
|
296
|
+
(!t || t.includes(i)) && ((s = r.discardTyped) == null || s.call(r));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/** The rendered controls: the direct children of each .baht-field wrapper. */
|
|
300
|
+
controls() {
|
|
301
|
+
return O() ? Array.from(this.querySelectorAll(":scope > .baht-form > .baht-field > *")) : [];
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The whole form's data (not only the view's fields). Pending keystrokes land first, so a read
|
|
305
|
+
* can dispatch their `baht-change` before it returns.
|
|
306
|
+
*/
|
|
307
|
+
getData() {
|
|
308
|
+
this.flushTyped();
|
|
309
|
+
const t = this.effectiveForm;
|
|
310
|
+
return t ? R(this.sessionInput(t), this.session) : {};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Merge values programmatically. Runs each key's `change` scripts (like
|
|
314
|
+
* ServiceNow's g_form.setValue) but emits no `baht-change` — the host
|
|
315
|
+
* already knows, and a store adapter would otherwise loop.
|
|
316
|
+
*/
|
|
317
|
+
setValue(t) {
|
|
318
|
+
this.flushTyped(), this.send({ type: "set", patch: t });
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Drop the user's edits to these keys, so each shows `value` again. For a host that refused an
|
|
322
|
+
* edit and has no new `value` to say so with: `<baht-workflow>` calls it when a rule wrote the
|
|
323
|
+
* field back (spec 02 §4). Emits nothing and runs no scripts.
|
|
324
|
+
*/
|
|
325
|
+
revert(t) {
|
|
326
|
+
this.send({ type: "revert", keys: t }), this.discardTyped(t);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Full validation pass: validators, then `submit` scripts (spec 01 §14). A
|
|
330
|
+
* script returning `false` blocks; its `addErrorMessage()` calls become
|
|
331
|
+
* `{ key: '$' }` errors so hosts see why.
|
|
332
|
+
*/
|
|
333
|
+
validate() {
|
|
334
|
+
this.flushTyped(), this.send({ type: "validate" }, (e) => {
|
|
335
|
+
this.openTabWithError(e.errors);
|
|
336
|
+
});
|
|
337
|
+
const t = [...this.errors];
|
|
338
|
+
return { valid: t.length === 0, errors: t };
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* The host's Save: `validate()`, then `baht-submit { data }` when it passes. Returns
|
|
342
|
+
* whether it submitted (never while `busy`).
|
|
343
|
+
*/
|
|
344
|
+
submit() {
|
|
345
|
+
return this.busy || !this.validate().valid ? !1 : (this.dispatchEvent(
|
|
346
|
+
new CustomEvent("baht-submit", {
|
|
347
|
+
detail: { data: this.getData() },
|
|
348
|
+
bubbles: !0,
|
|
349
|
+
composed: !0
|
|
350
|
+
})
|
|
351
|
+
), !0);
|
|
352
|
+
}
|
|
353
|
+
/** `submit-on-enter`: Enter in a single-line control submits (spec 01 §6). */
|
|
354
|
+
onKeydown(t) {
|
|
355
|
+
var r;
|
|
356
|
+
if (!this.submitOnEnter || t.key !== "Enter" || t.defaultPrevented || t.shiftKey || t.ctrlKey || t.altKey || t.metaKey || t.isComposing || t.keyCode === 229) return;
|
|
357
|
+
const e = t.target;
|
|
358
|
+
if (!(e instanceof HTMLInputElement)) return;
|
|
359
|
+
const s = ((r = e.closest(".baht-field")) == null ? void 0 : r.getAttribute("data-type")) ?? "";
|
|
360
|
+
Z.has(s) && (t.preventDefault(), this.submit());
|
|
361
|
+
}
|
|
362
|
+
reset() {
|
|
363
|
+
this.value = {}, this.send({ type: "reset" });
|
|
364
|
+
}
|
|
365
|
+
updated(t) {
|
|
366
|
+
var s;
|
|
367
|
+
if (super.updated(t), this.lastVisible = this.nextVisible, this.nextVisible = {}, !O()) return;
|
|
368
|
+
const e = this.assignedForm;
|
|
369
|
+
e && this.loadedForm !== e && (this.loadedForm = e, (s = e.scripts) != null && s.length && (this.flushTyped(), this.send({ type: "load" })));
|
|
370
|
+
}
|
|
371
|
+
// ---- internal ----
|
|
372
|
+
onFieldInput(t, e) {
|
|
373
|
+
e.stopPropagation();
|
|
374
|
+
const { value: s } = e.detail;
|
|
375
|
+
this.flushTyped(), this.send({ type: "input", key: t.key, value: s });
|
|
376
|
+
}
|
|
377
|
+
/** `validateOn: 'blur'`: validate just the field the user left. */
|
|
378
|
+
onFieldBlur(t) {
|
|
379
|
+
this.options.validateOn === "blur" && this.send({ type: "blur", key: t.key });
|
|
380
|
+
}
|
|
381
|
+
renderField(t, e) {
|
|
382
|
+
var S;
|
|
383
|
+
if (J(t))
|
|
384
|
+
return t.key === e.first ? this.renderTabStrip(e) : c;
|
|
385
|
+
const s = q[t.type];
|
|
386
|
+
if (!s)
|
|
387
|
+
return console.warn(`[bahtui] unknown field type "${t.type}" — skipped`), c;
|
|
388
|
+
const r = this.stateFor(t), i = j[t.width ?? "full"] ?? "baht-field--w-full", o = ((S = this.errors.find((f) => f.key === t.key)) == null ? void 0 : S.message) ?? null;
|
|
389
|
+
if (this.readonly && t.type !== "label" && t.type !== "section")
|
|
390
|
+
return this.renderReadonlyField(t, i, r.visible, e);
|
|
391
|
+
const n = this.dynamicOptions.withOptions(t), u = this.renderValueFor(t), a = !r.enabled || this.busy, v = this.readonly || r.readonly, w = this.options.inputDebounce, g = (f) => {
|
|
392
|
+
this.onControlInput(t.key, f);
|
|
393
|
+
}, d = P(s);
|
|
394
|
+
let m;
|
|
395
|
+
if (t.type === "section")
|
|
396
|
+
m = b`<${d}
|
|
397
|
+
.field=${t}
|
|
398
|
+
.collapsed=${this.folded.has(t.key)}
|
|
399
|
+
@baht-section-toggle=${(f) => {
|
|
400
|
+
f.stopPropagation(), this.toggleFold(t.key, f.detail.collapsed);
|
|
401
|
+
}}
|
|
402
|
+
></${d}>`;
|
|
403
|
+
else if (t.type === "repeater") {
|
|
404
|
+
const f = this.rowErrorsFor(t.key), L = this.rowStatesFor(t.key);
|
|
405
|
+
m = b`<${d}
|
|
406
|
+
.field=${n}
|
|
407
|
+
.value=${u}
|
|
408
|
+
.disabled=${a}
|
|
409
|
+
.readonly=${v}
|
|
410
|
+
.required=${r.required}
|
|
411
|
+
.showOptional=${this.showOptional}
|
|
412
|
+
.error=${o}
|
|
413
|
+
.debounce=${w}
|
|
414
|
+
.rowErrors=${f}
|
|
415
|
+
.rowStates=${L}
|
|
416
|
+
.rowLookup=${this.rowLookup}
|
|
417
|
+
@baht-input=${g}
|
|
418
|
+
></${d}>`;
|
|
419
|
+
} else if (t.type === "reference")
|
|
420
|
+
m = b`<${d}
|
|
421
|
+
.field=${n}
|
|
422
|
+
.value=${u}
|
|
423
|
+
.disabled=${a}
|
|
424
|
+
.readonly=${v}
|
|
425
|
+
.required=${r.required}
|
|
426
|
+
.showOptional=${this.showOptional}
|
|
427
|
+
.error=${o}
|
|
428
|
+
.lookup=${this.lookupFor(t)}
|
|
429
|
+
@baht-input=${g}
|
|
430
|
+
></${d}>`;
|
|
431
|
+
else if (t.type === "file" || t.type === "markdown") {
|
|
432
|
+
const f = this.uploaderFor(t);
|
|
433
|
+
m = b`<${d}
|
|
434
|
+
.field=${n}
|
|
435
|
+
.value=${u}
|
|
436
|
+
.disabled=${a}
|
|
437
|
+
.readonly=${v}
|
|
438
|
+
.required=${r.required}
|
|
439
|
+
.showOptional=${this.showOptional}
|
|
440
|
+
.error=${o}
|
|
441
|
+
.debounce=${w}
|
|
442
|
+
.uploader=${f}
|
|
443
|
+
.allowImage=${this.registry.markdownImage}
|
|
444
|
+
@baht-input=${g}
|
|
445
|
+
></${d}>`;
|
|
446
|
+
} else
|
|
447
|
+
m = b`<${d}
|
|
448
|
+
.field=${n}
|
|
449
|
+
.value=${u}
|
|
450
|
+
.disabled=${a}
|
|
451
|
+
.readonly=${v}
|
|
452
|
+
.required=${r.required}
|
|
453
|
+
.showOptional=${this.showOptional}
|
|
454
|
+
.error=${o}
|
|
455
|
+
.debounce=${w}
|
|
456
|
+
@baht-input=${g}
|
|
457
|
+
></${d}>`;
|
|
458
|
+
const k = this.fieldMessages[t.key];
|
|
459
|
+
return y`<div
|
|
460
|
+
class="baht-field ${i} ${r.visible ? "" : "baht-field--hidden"}${this.revealClass(t.key, r.visible)}${x(e, t.key)}${M(e, t.key, this.folded)}"
|
|
461
|
+
data-column=${t.column ?? c}
|
|
462
|
+
style=${$(e, t.key)}
|
|
463
|
+
data-key=${t.key}
|
|
464
|
+
data-type=${t.type}
|
|
465
|
+
data-testid="${this.form.form_id}.${t.key}"
|
|
466
|
+
@focusout=${() => {
|
|
467
|
+
this.onFieldBlur(t);
|
|
468
|
+
}}
|
|
469
|
+
>
|
|
470
|
+
${m}
|
|
471
|
+
${k ? this.renderFieldMsg(k) : c}
|
|
472
|
+
</div>`;
|
|
473
|
+
}
|
|
474
|
+
lookupFor(t, e) {
|
|
475
|
+
const s = t.reference ?? "", r = this.registry.references ?? {}, i = Object.hasOwn(r, s) ? r[s] : void 0;
|
|
476
|
+
if (!i)
|
|
477
|
+
return this.warnedLookups.has(s) || (this.warnedLookups.add(s), console.warn(`[bahtui] unknown reference lookup "${s}" — search disabled`)), null;
|
|
478
|
+
const o = () => e ? { ...this.getData(), ...e() } : this.getData();
|
|
479
|
+
return {
|
|
480
|
+
search: (n) => i.search(n, o()),
|
|
481
|
+
...i.resolve ? { resolve: i.resolve } : {},
|
|
482
|
+
...i.columns ? { columns: i.columns } : {},
|
|
483
|
+
...i.walk ? { walk: i.walk } : {},
|
|
484
|
+
...i.savedColumns ? { savedColumns: i.savedColumns } : {},
|
|
485
|
+
...i.saveColumns ? { saveColumns: i.saveColumns } : {},
|
|
486
|
+
...i.savedFilters ? { savedFilters: i.savedFilters } : {},
|
|
487
|
+
...i.saveFilters ? { saveFilters: i.saveFilters } : {},
|
|
488
|
+
...i.list ? {
|
|
489
|
+
list: (n) => {
|
|
490
|
+
const { list: u } = i;
|
|
491
|
+
return u ? u(n, o()) : { rows: [], total: 0 };
|
|
492
|
+
}
|
|
493
|
+
} : {}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
/** Read-only view of a reference: its resolved label once known, the raw id until then. */
|
|
497
|
+
referenceText(t, e) {
|
|
498
|
+
var o;
|
|
499
|
+
const s = `${t.reference ?? ""}\0${e}`, r = this.referenceLabels.get(s);
|
|
500
|
+
if (r !== void 0) return r;
|
|
501
|
+
const i = (o = this.lookupFor(t)) == null ? void 0 : o.resolve;
|
|
502
|
+
return i && this.referenceLabels.request(s, e, i), e;
|
|
503
|
+
}
|
|
504
|
+
uploaderFor(t) {
|
|
505
|
+
var s;
|
|
506
|
+
if (!t.uploader) return;
|
|
507
|
+
const e = (s = this.registry.uploaders) == null ? void 0 : s[t.uploader];
|
|
508
|
+
return e || console.warn(`[bahtui] unknown uploader "${t.uploader}" — capture only`), e;
|
|
509
|
+
}
|
|
510
|
+
renderFieldMsg(t) {
|
|
511
|
+
return y`<div
|
|
512
|
+
class="baht-field-msg baht-field-msg--${t.type}"
|
|
513
|
+
role=${t.type === "error" ? "alert" : "status"}
|
|
514
|
+
>
|
|
515
|
+
${t.message}
|
|
516
|
+
</div>`;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Resolve the descriptor at event time — it may have changed since the control
|
|
520
|
+
* was first rendered (the same node is reused across renders, see render()).
|
|
521
|
+
*/
|
|
522
|
+
onControlInput(t, e) {
|
|
523
|
+
var r;
|
|
524
|
+
const s = (r = this.effectiveForm) == null ? void 0 : r.fields.find((i) => i.key === t);
|
|
525
|
+
s && this.onFieldInput(s, e);
|
|
526
|
+
}
|
|
527
|
+
renderReadonlyField(t, e, s, r) {
|
|
528
|
+
const i = this.dynamicOptions.optionsFor(t), o = U(
|
|
529
|
+
this.dynamicOptions.withOptions(t),
|
|
530
|
+
this.valueFor(t),
|
|
531
|
+
i
|
|
532
|
+
);
|
|
533
|
+
return Y(
|
|
534
|
+
{
|
|
535
|
+
field: t,
|
|
536
|
+
shown: o,
|
|
537
|
+
classes: `baht-field ${e} baht-field--readonly ${s ? "" : "baht-field--hidden"}${this.revealClass(t.key, s)}${x(r, t.key)}${M(r, t.key, this.folded)}`,
|
|
538
|
+
style: $(r, t.key),
|
|
539
|
+
testId: `${this.form.form_id}.${t.key}`
|
|
540
|
+
},
|
|
541
|
+
this.readonlyContext()
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
readonlyContext() {
|
|
545
|
+
return {
|
|
546
|
+
referenceText: (t, e) => this.referenceText(t, e),
|
|
547
|
+
markdownImage: this.registry.markdownImage
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
render() {
|
|
551
|
+
var s;
|
|
552
|
+
const t = this.tabLayout(), e = (s = this.effectiveForm) == null ? void 0 : s.layout;
|
|
553
|
+
return y`<div
|
|
554
|
+
class="baht-form ${this.readonly ? "baht-form--readonly" : ""}${(e == null ? void 0 : e.label) === "left" ? " baht-form--label-left" : ""}${(e == null ? void 0 : e.columns) === 2 ? " baht-form--columns" : ""}"
|
|
555
|
+
style=${e != null && e.label_width ? `--baht-form-label-width:${e.label_width}` : c}
|
|
556
|
+
aria-busy=${this.busy ? "true" : c}
|
|
557
|
+
@keydown=${(r) => {
|
|
558
|
+
this.onKeydown(r);
|
|
559
|
+
}}
|
|
560
|
+
>
|
|
561
|
+
${this.formMessages.length > 0 ? y`<div class="baht-form-messages">
|
|
562
|
+
${this.formMessages.map(
|
|
563
|
+
(r) => y`<div
|
|
564
|
+
class="baht-form-msg baht-form-msg--${r.type}"
|
|
565
|
+
role=${r.type === "error" ? "alert" : "status"}
|
|
566
|
+
>
|
|
567
|
+
${r.message}
|
|
568
|
+
</div>`
|
|
569
|
+
)}
|
|
570
|
+
</div>` : c}
|
|
571
|
+
${V(
|
|
572
|
+
this.sortedFields,
|
|
573
|
+
(r) => r.key,
|
|
574
|
+
(r) => this.renderField(r, t)
|
|
575
|
+
)}
|
|
576
|
+
</div>`;
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
l([
|
|
580
|
+
p({ attribute: !1 })
|
|
581
|
+
], h.prototype, "form", 2);
|
|
582
|
+
l([
|
|
583
|
+
p({ attribute: !1 })
|
|
584
|
+
], h.prototype, "value", 2);
|
|
585
|
+
l([
|
|
586
|
+
p({ attribute: !1 })
|
|
587
|
+
], h.prototype, "registry", 2);
|
|
588
|
+
l([
|
|
589
|
+
p({ type: Boolean, attribute: "show-optional" })
|
|
590
|
+
], h.prototype, "showOptional", 2);
|
|
591
|
+
l([
|
|
592
|
+
p({ attribute: !1 })
|
|
593
|
+
], h.prototype, "options", 2);
|
|
594
|
+
l([
|
|
595
|
+
p({ attribute: !1 })
|
|
596
|
+
], h.prototype, "fieldStates", 2);
|
|
597
|
+
l([
|
|
598
|
+
p({ type: String })
|
|
599
|
+
], h.prototype, "view", 2);
|
|
600
|
+
l([
|
|
601
|
+
p({ attribute: !1 })
|
|
602
|
+
], h.prototype, "flags", 2);
|
|
603
|
+
l([
|
|
604
|
+
p()
|
|
605
|
+
], h.prototype, "tab", 2);
|
|
606
|
+
l([
|
|
607
|
+
p({ type: Boolean })
|
|
608
|
+
], h.prototype, "readonly", 2);
|
|
609
|
+
l([
|
|
610
|
+
p({ type: Boolean, attribute: "submit-on-enter" })
|
|
611
|
+
], h.prototype, "submitOnEnter", 2);
|
|
612
|
+
l([
|
|
613
|
+
p({ type: Boolean })
|
|
614
|
+
], h.prototype, "busy", 2);
|
|
615
|
+
l([
|
|
616
|
+
I()
|
|
617
|
+
], h.prototype, "session", 2);
|
|
618
|
+
l([
|
|
619
|
+
I()
|
|
620
|
+
], h.prototype, "folded", 2);
|
|
621
|
+
h = l([
|
|
622
|
+
G("baht-form")
|
|
623
|
+
], h);
|
|
624
|
+
function tt(t, e) {
|
|
625
|
+
const s = Object.keys(t);
|
|
626
|
+
return s.length === Object.keys(e).length && s.every((r) => t[r] === e[r]);
|
|
627
|
+
}
|
|
628
|
+
export {
|
|
629
|
+
h as BahtForm
|
|
630
|
+
};
|