bank20baht-ui 0.1.2 → 0.1.4
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/dist/components/baht-form.d.ts +2 -0
- package/dist/components/baht-workflow.d.ts +2 -2
- package/dist/components/primitives/baht-section.d.ts +13 -0
- package/dist/components/primitives/baht-steps.d.ts +2 -0
- package/dist/components/primitives/index.d.ts +1 -0
- package/dist/core/types.d.ts +2 -1
- package/dist/custom-elements.json +110 -26
- package/dist/engine.js +26 -25
- package/dist/index.js +764 -745
- package/dist/tokens.css +55 -12
- package/dist/vscode.html-custom-data.json +21 -0
- package/dist/web-types.json +48 -1
- package/package.json +1 -1
|
@@ -28,6 +28,8 @@ export declare class BahtForm extends BahtElement {
|
|
|
28
28
|
* if they were never in the schema: no render, no validation, no payload.
|
|
29
29
|
*/
|
|
30
30
|
flags: FeatureFlags;
|
|
31
|
+
/** Force every field readonly — a display-only render of this form's own layout/widths. */
|
|
32
|
+
readonly: boolean;
|
|
31
33
|
/** Edits the user made since the host last set `value` (controlled overlay). */
|
|
32
34
|
private edits;
|
|
33
35
|
private errors;
|
|
@@ -25,6 +25,8 @@ export declare class BahtWorkflow extends BahtElement {
|
|
|
25
25
|
flags: FeatureFlags;
|
|
26
26
|
/** Render a <baht-steps> progress indicator above the current form. */
|
|
27
27
|
showSteps: boolean;
|
|
28
|
+
/** 'default' horizontal markers, or 'sidebar' vertical nav list — forwarded to <baht-steps>. */
|
|
29
|
+
stepsVariant: 'default' | 'sidebar';
|
|
28
30
|
private data;
|
|
29
31
|
private derived;
|
|
30
32
|
private current;
|
|
@@ -66,8 +68,6 @@ export declare class BahtWorkflow extends BahtElement {
|
|
|
66
68
|
private onFormChange;
|
|
67
69
|
private onCommentInput;
|
|
68
70
|
private emit;
|
|
69
|
-
/** Human-readable value for the summary: option labels, Yes/No, em-dash for empty. */
|
|
70
|
-
private displayValue;
|
|
71
71
|
/** Forms the approval step summarizes: configured list, else every earlier plain form. */
|
|
72
72
|
private summaryForms;
|
|
73
73
|
private renderApproval;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { FieldDescriptor } from '../../core/types.js';
|
|
4
|
+
/** Section divider (`type: "section"`): heading + rule, no value, no emits. */
|
|
5
|
+
export declare class BahtSection extends BahtElement {
|
|
6
|
+
field: FieldDescriptor;
|
|
7
|
+
protected render(): TemplateResult;
|
|
8
|
+
}
|
|
9
|
+
declare global {
|
|
10
|
+
interface HTMLElementTagNameMap {
|
|
11
|
+
'baht-section': BahtSection;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -11,6 +11,8 @@ export declare class BahtSteps extends BahtElement {
|
|
|
11
11
|
steps: string[];
|
|
12
12
|
/** 0-based index of the current step. */
|
|
13
13
|
current: number;
|
|
14
|
+
/** 'default' = horizontal numbered markers; 'sidebar' = vertical nav list, current pilled. */
|
|
15
|
+
variant: 'default' | 'sidebar';
|
|
14
16
|
protected render(): TemplateResult;
|
|
15
17
|
}
|
|
16
18
|
declare global {
|
|
@@ -33,6 +33,7 @@ export { BahtToggle } from './baht-toggle.js';
|
|
|
33
33
|
export { BahtDatepicker } from './baht-datepicker.js';
|
|
34
34
|
export { BahtFile } from './baht-file.js';
|
|
35
35
|
export { BahtText } from './baht-text.js';
|
|
36
|
+
export { BahtSection } from './baht-section.js';
|
|
36
37
|
export { BahtStatChart } from './baht-stat-chart.js';
|
|
37
38
|
export { BahtDonutChart } from './baht-donut-chart.js';
|
|
38
39
|
export { BahtBarChart } from './baht-bar-chart.js';
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Control types supported by v1 (spec 01 §2). */
|
|
2
|
-
export type FieldType = 'text' | 'textarea' | 'number' | 'email' | 'dropdown' | 'multiselect' | 'checkbox' | 'radio' | 'toggle' | 'date' | 'file' | 'label' | 'repeater';
|
|
2
|
+
export type FieldType = 'text' | 'textarea' | 'number' | 'email' | 'dropdown' | 'multiselect' | 'checkbox' | 'radio' | 'toggle' | 'date' | 'file' | 'label' | 'section' | 'repeater';
|
|
3
3
|
export type FieldWidth = '1/4' | '1/2' | '3/4' | 'full';
|
|
4
4
|
export interface FieldOption {
|
|
5
5
|
key: string;
|
|
@@ -33,6 +33,7 @@ export interface FieldDescriptor {
|
|
|
33
33
|
width?: FieldWidth;
|
|
34
34
|
value?: unknown;
|
|
35
35
|
disabled?: boolean;
|
|
36
|
+
readonly?: boolean;
|
|
36
37
|
required?: boolean;
|
|
37
38
|
options?: FieldOption[];
|
|
38
39
|
/** Registry name resolving this field's options from current form data. */
|
|
@@ -69,6 +69,16 @@
|
|
|
69
69
|
"default": "{}",
|
|
70
70
|
"description": "Feature-flag values (spec 01 §12) — fields whose `flag` is off behave as\nif they were never in the schema: no render, no validation, no payload."
|
|
71
71
|
},
|
|
72
|
+
{
|
|
73
|
+
"kind": "field",
|
|
74
|
+
"name": "readonly",
|
|
75
|
+
"type": {
|
|
76
|
+
"text": "boolean"
|
|
77
|
+
},
|
|
78
|
+
"default": "false",
|
|
79
|
+
"description": "Force every field readonly — a display-only render of this form's own layout/widths.",
|
|
80
|
+
"attribute": "readonly"
|
|
81
|
+
},
|
|
72
82
|
{
|
|
73
83
|
"kind": "field",
|
|
74
84
|
"name": "edits",
|
|
@@ -362,6 +372,15 @@
|
|
|
362
372
|
},
|
|
363
373
|
"description": "Name of a view from `form.views`. Display-only: when set, only that view's\nfields are rendered and validated (the user can only fix what they see),\nbut getData() still returns the FULL form — the server always validates\nthe complete schema, views never change the submit payload.",
|
|
364
374
|
"fieldName": "view"
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
"name": "readonly",
|
|
378
|
+
"type": {
|
|
379
|
+
"text": "boolean"
|
|
380
|
+
},
|
|
381
|
+
"default": "false",
|
|
382
|
+
"description": "Force every field readonly — a display-only render of this form's own layout/widths.",
|
|
383
|
+
"fieldName": "readonly"
|
|
365
384
|
}
|
|
366
385
|
],
|
|
367
386
|
"superclass": {
|
|
@@ -493,6 +512,16 @@
|
|
|
493
512
|
"description": "Render a <baht-steps> progress indicator above the current form.",
|
|
494
513
|
"attribute": "show-steps"
|
|
495
514
|
},
|
|
515
|
+
{
|
|
516
|
+
"kind": "field",
|
|
517
|
+
"name": "stepsVariant",
|
|
518
|
+
"type": {
|
|
519
|
+
"text": "'default' | 'sidebar'"
|
|
520
|
+
},
|
|
521
|
+
"default": "'default'",
|
|
522
|
+
"description": "'default' horizontal markers, or 'sidebar' vertical nav list — forwarded to <baht-steps>.",
|
|
523
|
+
"attribute": "steps-variant"
|
|
524
|
+
},
|
|
496
525
|
{
|
|
497
526
|
"kind": "field",
|
|
498
527
|
"name": "data",
|
|
@@ -843,31 +872,6 @@
|
|
|
843
872
|
}
|
|
844
873
|
]
|
|
845
874
|
},
|
|
846
|
-
{
|
|
847
|
-
"kind": "method",
|
|
848
|
-
"name": "displayValue",
|
|
849
|
-
"privacy": "private",
|
|
850
|
-
"return": {
|
|
851
|
-
"type": {
|
|
852
|
-
"text": "string"
|
|
853
|
-
}
|
|
854
|
-
},
|
|
855
|
-
"parameters": [
|
|
856
|
-
{
|
|
857
|
-
"name": "fd",
|
|
858
|
-
"type": {
|
|
859
|
-
"text": "FieldDescriptor"
|
|
860
|
-
}
|
|
861
|
-
},
|
|
862
|
-
{
|
|
863
|
-
"name": "value",
|
|
864
|
-
"type": {
|
|
865
|
-
"text": "unknown"
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
],
|
|
869
|
-
"description": "Human-readable value for the summary: option labels, Yes/No, em-dash for empty."
|
|
870
|
-
},
|
|
871
875
|
{
|
|
872
876
|
"kind": "method",
|
|
873
877
|
"name": "summaryForms",
|
|
@@ -961,6 +965,15 @@
|
|
|
961
965
|
"default": "false",
|
|
962
966
|
"description": "Render a <baht-steps> progress indicator above the current form.",
|
|
963
967
|
"fieldName": "showSteps"
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
"name": "steps-variant",
|
|
971
|
+
"type": {
|
|
972
|
+
"text": "'default' | 'sidebar'"
|
|
973
|
+
},
|
|
974
|
+
"default": "'default'",
|
|
975
|
+
"description": "'default' horizontal markers, or 'sidebar' vertical nav list — forwarded to <baht-steps>.",
|
|
976
|
+
"fieldName": "stepsVariant"
|
|
964
977
|
}
|
|
965
978
|
],
|
|
966
979
|
"superclass": {
|
|
@@ -7577,6 +7590,50 @@
|
|
|
7577
7590
|
}
|
|
7578
7591
|
]
|
|
7579
7592
|
},
|
|
7593
|
+
{
|
|
7594
|
+
"kind": "javascript-module",
|
|
7595
|
+
"path": "src/components/primitives/baht-section.ts",
|
|
7596
|
+
"declarations": [
|
|
7597
|
+
{
|
|
7598
|
+
"kind": "class",
|
|
7599
|
+
"description": "Section divider (`type: \"section\"`): heading + rule, no value, no emits.",
|
|
7600
|
+
"name": "BahtSection",
|
|
7601
|
+
"members": [
|
|
7602
|
+
{
|
|
7603
|
+
"kind": "field",
|
|
7604
|
+
"name": "field",
|
|
7605
|
+
"type": {
|
|
7606
|
+
"text": "FieldDescriptor"
|
|
7607
|
+
}
|
|
7608
|
+
}
|
|
7609
|
+
],
|
|
7610
|
+
"superclass": {
|
|
7611
|
+
"name": "BahtElement",
|
|
7612
|
+
"module": "/src/components/base.js"
|
|
7613
|
+
},
|
|
7614
|
+
"tagName": "baht-section",
|
|
7615
|
+
"customElement": true
|
|
7616
|
+
}
|
|
7617
|
+
],
|
|
7618
|
+
"exports": [
|
|
7619
|
+
{
|
|
7620
|
+
"kind": "js",
|
|
7621
|
+
"name": "BahtSection",
|
|
7622
|
+
"declaration": {
|
|
7623
|
+
"name": "BahtSection",
|
|
7624
|
+
"module": "src/components/primitives/baht-section.ts"
|
|
7625
|
+
}
|
|
7626
|
+
},
|
|
7627
|
+
{
|
|
7628
|
+
"kind": "custom-element-definition",
|
|
7629
|
+
"name": "baht-section",
|
|
7630
|
+
"declaration": {
|
|
7631
|
+
"name": "BahtSection",
|
|
7632
|
+
"module": "src/components/primitives/baht-section.ts"
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
]
|
|
7636
|
+
},
|
|
7580
7637
|
{
|
|
7581
7638
|
"kind": "javascript-module",
|
|
7582
7639
|
"path": "src/components/primitives/baht-select.ts",
|
|
@@ -8166,6 +8223,16 @@
|
|
|
8166
8223
|
"default": "0",
|
|
8167
8224
|
"description": "0-based index of the current step.",
|
|
8168
8225
|
"attribute": "current"
|
|
8226
|
+
},
|
|
8227
|
+
{
|
|
8228
|
+
"kind": "field",
|
|
8229
|
+
"name": "variant",
|
|
8230
|
+
"type": {
|
|
8231
|
+
"text": "'default' | 'sidebar'"
|
|
8232
|
+
},
|
|
8233
|
+
"default": "'default'",
|
|
8234
|
+
"description": "'default' = horizontal numbered markers; 'sidebar' = vertical nav list, current pilled.",
|
|
8235
|
+
"attribute": "variant"
|
|
8169
8236
|
}
|
|
8170
8237
|
],
|
|
8171
8238
|
"attributes": [
|
|
@@ -8177,6 +8244,15 @@
|
|
|
8177
8244
|
"default": "0",
|
|
8178
8245
|
"description": "0-based index of the current step.",
|
|
8179
8246
|
"fieldName": "current"
|
|
8247
|
+
},
|
|
8248
|
+
{
|
|
8249
|
+
"name": "variant",
|
|
8250
|
+
"type": {
|
|
8251
|
+
"text": "'default' | 'sidebar'"
|
|
8252
|
+
},
|
|
8253
|
+
"default": "'default'",
|
|
8254
|
+
"description": "'default' = horizontal numbered markers; 'sidebar' = vertical nav list, current pilled.",
|
|
8255
|
+
"fieldName": "variant"
|
|
8180
8256
|
}
|
|
8181
8257
|
],
|
|
8182
8258
|
"superclass": {
|
|
@@ -9973,6 +10049,14 @@
|
|
|
9973
10049
|
"module": "./baht-text.js"
|
|
9974
10050
|
}
|
|
9975
10051
|
},
|
|
10052
|
+
{
|
|
10053
|
+
"kind": "js",
|
|
10054
|
+
"name": "BahtSection",
|
|
10055
|
+
"declaration": {
|
|
10056
|
+
"name": "BahtSection",
|
|
10057
|
+
"module": "./baht-section.js"
|
|
10058
|
+
}
|
|
10059
|
+
},
|
|
9976
10060
|
{
|
|
9977
10061
|
"kind": "js",
|
|
9978
10062
|
"name": "BahtStatChart",
|
|
@@ -10089,7 +10173,7 @@
|
|
|
10089
10173
|
"type": {
|
|
10090
10174
|
"text": "Record<FieldType, string>"
|
|
10091
10175
|
},
|
|
10092
|
-
"default": "{ text: 'baht-input', email: 'baht-input', textarea: 'baht-textarea', number: 'baht-number', dropdown: 'baht-select', multiselect: 'baht-multiselect', checkbox: 'baht-checkbox', radio: 'baht-radio', toggle: 'baht-toggle', date: 'baht-datepicker', file: 'baht-file', label: 'baht-text', repeater: 'baht-repeater', }",
|
|
10176
|
+
"default": "{ text: 'baht-input', email: 'baht-input', textarea: 'baht-textarea', number: 'baht-number', dropdown: 'baht-select', multiselect: 'baht-multiselect', checkbox: 'baht-checkbox', radio: 'baht-radio', toggle: 'baht-toggle', date: 'baht-datepicker', file: 'baht-file', label: 'baht-text', section: 'baht-section', repeater: 'baht-repeater', }",
|
|
10093
10177
|
"description": "field descriptor `type` -> primitive tag (used by <baht-form>, <baht-repeater>\nand the builder). Lives in its own module so baht-repeater can read it\nwithout importing the primitives barrel (which would be circular)."
|
|
10094
10178
|
}
|
|
10095
10179
|
],
|
package/dist/engine.js
CHANGED
|
@@ -10,6 +10,7 @@ function S(e) {
|
|
|
10
10
|
case "file":
|
|
11
11
|
return e.multiple ? [] : null;
|
|
12
12
|
case "label":
|
|
13
|
+
case "section":
|
|
13
14
|
return;
|
|
14
15
|
// static block, no value
|
|
15
16
|
default:
|
|
@@ -282,11 +283,11 @@ function ee(e, t, n) {
|
|
|
282
283
|
return o.forEach((i, u) => {
|
|
283
284
|
const d = i !== null && typeof i == "object" && !Array.isArray(i) ? i : {}, p = {};
|
|
284
285
|
for (const a of s)
|
|
285
|
-
a.type === "label" || a.type === "repeater" || (p[a.key] = Object.hasOwn(d, a.key) ? d[a.key] : S(a));
|
|
286
|
+
a.type === "label" || a.type === "section" || a.type === "repeater" || (p[a.key] = Object.hasOwn(d, a.key) ? d[a.key] : S(a));
|
|
286
287
|
for (const a of s)
|
|
287
|
-
if (!(a.type === "label" || a.type === "repeater"))
|
|
288
|
-
for (const
|
|
289
|
-
r.push({ key: `${e.key}[${u}].${
|
|
288
|
+
if (!(a.type === "label" || a.type === "section" || a.type === "repeater"))
|
|
289
|
+
for (const y of X(a, p[a.key], n, p))
|
|
290
|
+
r.push({ key: `${e.key}[${u}].${y.key}`, message: y.message });
|
|
290
291
|
}), r;
|
|
291
292
|
}
|
|
292
293
|
function ce(e, t) {
|
|
@@ -401,9 +402,9 @@ function oe(e, t) {
|
|
|
401
402
|
continue;
|
|
402
403
|
}
|
|
403
404
|
r.push(a.formName);
|
|
404
|
-
const
|
|
405
|
+
const y = {}, v = V(t, a.formName);
|
|
405
406
|
for (const f of [...a.field_data, ...P(a)]) {
|
|
406
|
-
if (f.type === "label") continue;
|
|
407
|
+
if (f.type === "label" || f.type === "section") continue;
|
|
407
408
|
if (_.has(f.key)) {
|
|
408
409
|
n.push({
|
|
409
410
|
ref: `${a.formName}.${f.key}`,
|
|
@@ -414,35 +415,35 @@ function oe(e, t) {
|
|
|
414
415
|
}
|
|
415
416
|
o.set(`${a.formName}.${f.key}`, f);
|
|
416
417
|
const l = V(v, f.key);
|
|
417
|
-
|
|
418
|
+
y[f.key] = l !== void 0 ? l : S(f);
|
|
418
419
|
}
|
|
419
|
-
s[a.formName] =
|
|
420
|
+
s[a.formName] = y;
|
|
420
421
|
}
|
|
421
422
|
let i = {}, u = {}, d = !1;
|
|
422
423
|
for (let a = 0; a < M; a++) {
|
|
423
424
|
i = {}, u = {};
|
|
424
425
|
for (const l of r) u[l] = { visible: !0 };
|
|
425
|
-
for (const [l,
|
|
426
|
+
for (const [l, h] of o)
|
|
426
427
|
i[l] = {
|
|
427
428
|
visible: !0,
|
|
428
|
-
enabled: !
|
|
429
|
-
readonly:
|
|
430
|
-
required: !!
|
|
429
|
+
enabled: !h.disabled,
|
|
430
|
+
readonly: !!h.readonly,
|
|
431
|
+
required: !!h.required,
|
|
431
432
|
computed: !1
|
|
432
433
|
};
|
|
433
|
-
const
|
|
434
|
-
e.rules.forEach((l,
|
|
434
|
+
const y = /* @__PURE__ */ new Map();
|
|
435
|
+
e.rules.forEach((l, h) => {
|
|
435
436
|
const c = w(l.when, s) ? l.then : l.else;
|
|
436
437
|
if (!c) return;
|
|
437
438
|
const N = l.priority ?? 0;
|
|
438
439
|
for (const g of c) {
|
|
439
|
-
const b = se(g), A =
|
|
440
|
-
A.push({ action: g, priority: N, index:
|
|
440
|
+
const b = se(g), A = y.get(b) ?? [];
|
|
441
|
+
A.push({ action: g, priority: N, index: h }), y.set(b, A);
|
|
441
442
|
}
|
|
442
443
|
});
|
|
443
444
|
const v = [];
|
|
444
|
-
for (const [l,
|
|
445
|
-
const c = re(
|
|
445
|
+
for (const [l, h] of y) {
|
|
446
|
+
const c = re(h);
|
|
446
447
|
if (!c) continue;
|
|
447
448
|
if (c.action === "setValue") {
|
|
448
449
|
v.push({ ref: `${c.target.form}.${c.target.field}`, action: c });
|
|
@@ -492,17 +493,17 @@ function oe(e, t) {
|
|
|
492
493
|
}
|
|
493
494
|
const f = {};
|
|
494
495
|
for (const l of r) f[l] = { ...s[l] };
|
|
495
|
-
for (const [l,
|
|
496
|
+
for (const [l, h] of o) {
|
|
496
497
|
const [c, N] = C(l);
|
|
497
|
-
(!u[c].visible || !i[l].visible) && (f[c][N] = S(
|
|
498
|
+
(!u[c].visible || !i[l].visible) && (f[c][N] = S(h));
|
|
498
499
|
}
|
|
499
|
-
for (const { ref: l, action:
|
|
500
|
+
for (const { ref: l, action: h } of v) {
|
|
500
501
|
const [c, N] = C(l), g = i[l];
|
|
501
502
|
if (!g) {
|
|
502
503
|
n.push({ ref: l, message: "setValue targets unknown field", kind: "schema" });
|
|
503
504
|
continue;
|
|
504
505
|
}
|
|
505
|
-
!u[c].visible || !g.visible || (f[c][N] = ne(
|
|
506
|
+
!u[c].visible || !g.visible || (f[c][N] = ne(h.value, f), h.lock !== !1 && (g.readonly = !0, g.computed = !0));
|
|
506
507
|
}
|
|
507
508
|
if (E(f, s)) {
|
|
508
509
|
d = !0, s = f;
|
|
@@ -518,10 +519,10 @@ function oe(e, t) {
|
|
|
518
519
|
const p = {};
|
|
519
520
|
for (const a of r) {
|
|
520
521
|
if (!u[a].visible) continue;
|
|
521
|
-
const
|
|
522
|
+
const y = {};
|
|
522
523
|
for (const [v, f] of Object.entries(s[a]))
|
|
523
|
-
i[`${a}.${v}`].visible && (
|
|
524
|
-
p[a] =
|
|
524
|
+
i[`${a}.${v}`].visible && (y[v] = f);
|
|
525
|
+
p[a] = y;
|
|
525
526
|
}
|
|
526
527
|
return { data: p, fields: i, forms: u, errors: n };
|
|
527
528
|
}
|