bank20baht-ui 0.2.3 → 0.2.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/README.md +12 -0
- package/dist/components/baht-form.d.ts +1 -0
- package/dist/core/display.d.ts +23 -0
- package/dist/core/i18n.d.ts +2 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/custom-elements.json +30 -0
- package/dist/engine.js +207 -166
- package/dist/index.js +884 -857
- package/dist/tokens.css +38 -12
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,6 +53,13 @@ the user can only fix what they see), but `getData()` still returns the full for
|
|
|
53
53
|
server (`bank20baht-validator`) always validates the complete schema. In a workflow, set
|
|
54
54
|
`view: 'summary'` on a step's form to pin the view that step renders.
|
|
55
55
|
|
|
56
|
+
### Read-only display
|
|
57
|
+
|
|
58
|
+
`<baht-form readonly>` shows a submission instead of editing it: values as text, option
|
|
59
|
+
labels instead of keys, chips for multi-picks, Yes/No, no help text, "Not provided" for
|
|
60
|
+
blanks. Same grid, same widths. `displayValue(field, value)` from `bank20baht-ui/engine`
|
|
61
|
+
gives you the same formatting for tables.
|
|
62
|
+
|
|
56
63
|
### Repeater — line items / repeating rows
|
|
57
64
|
|
|
58
65
|
```js
|
|
@@ -284,6 +291,11 @@ React 19+ sets non-string JSX props as DOM properties, so object props (`form`,
|
|
|
284
291
|
@Component({ schemas: [CUSTOM_ELEMENTS_SCHEMA], /* … */ })
|
|
285
292
|
```
|
|
286
293
|
|
|
294
|
+
Bind `readonly` as an attribute (`[attr.readonly]="x ? '' : null"`), not a property — Angular
|
|
295
|
+
rewrites `[readonly]` to the native `readOnly`. Zoneless Angular may connect an element before
|
|
296
|
+
binding its props; since 0.2.3 every field primitive renders empty until `field` arrives. Full
|
|
297
|
+
list of gotchas: [docs/frameworks/angular.md](./docs/frameworks/angular.md#gotchas).
|
|
298
|
+
|
|
287
299
|
**Vue 3** — `vite.config.ts`:
|
|
288
300
|
|
|
289
301
|
```ts
|
|
@@ -79,6 +79,7 @@ export declare class BahtForm extends BahtElement {
|
|
|
79
79
|
* `renderField`/`.baht-error`). No-op for 'change'/'submit' modes. */
|
|
80
80
|
private onFieldBlur;
|
|
81
81
|
private renderField;
|
|
82
|
+
private renderReadonlyField;
|
|
82
83
|
protected render(): TemplateResult;
|
|
83
84
|
}
|
|
84
85
|
declare global {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FieldDescriptor, FieldOption } from './types.js';
|
|
2
|
+
export type DisplayValue = {
|
|
3
|
+
kind: 'empty';
|
|
4
|
+
} | {
|
|
5
|
+
kind: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'chips';
|
|
9
|
+
items: string[];
|
|
10
|
+
}
|
|
11
|
+
/** Repeater rows: one entry per row, each a list of `label: value` pairs. */
|
|
12
|
+
| {
|
|
13
|
+
kind: 'rows';
|
|
14
|
+
rows: Array<Array<{
|
|
15
|
+
label: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}>>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The read-only rendering of one field's value. `options` overrides the
|
|
21
|
+
* descriptor's own list when they were resolved dynamically (`optionsFrom`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function displayValue(field: FieldDescriptor, value: unknown, options?: FieldOption[] | undefined): DisplayValue;
|
package/dist/core/i18n.d.ts
CHANGED
package/dist/core/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { evaluate } from './engine/evaluate.js';
|
|
|
10
10
|
export { resolveNext, walkPath } from './engine/graph.js';
|
|
11
11
|
export { evalCondition, readRef } from './engine/conditions.js';
|
|
12
12
|
export { evalValueExpr } from './engine/expressions.js';
|
|
13
|
+
export { displayValue, type DisplayValue } from './display.js';
|
|
@@ -348,6 +348,36 @@
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
]
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
"kind": "method",
|
|
354
|
+
"name": "renderReadonlyField",
|
|
355
|
+
"privacy": "private",
|
|
356
|
+
"return": {
|
|
357
|
+
"type": {
|
|
358
|
+
"text": "TemplateResult"
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
"parameters": [
|
|
362
|
+
{
|
|
363
|
+
"name": "field",
|
|
364
|
+
"type": {
|
|
365
|
+
"text": "FieldDescriptor"
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"name": "width",
|
|
370
|
+
"type": {
|
|
371
|
+
"text": "string"
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "visible",
|
|
376
|
+
"type": {
|
|
377
|
+
"text": "boolean"
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
]
|
|
351
381
|
}
|
|
352
382
|
],
|
|
353
383
|
"events": [
|