bank20baht-ui 0.0.11 → 0.1.0

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.
@@ -41,6 +41,8 @@ export declare class BahtForm extends BahtElement {
41
41
  private dynamicOptions;
42
42
  private optionsSnapshots;
43
43
  private optionsEpoch;
44
+ /** Unknown `view` values already warned about — avoid re-warning on every render. */
45
+ private warnedViews;
44
46
  /** applyFlags result, memoized on (form, flags) identity. */
45
47
  private flagCache;
46
48
  private get effectiveForm();
@@ -68,6 +70,12 @@ export declare class BahtForm extends BahtElement {
68
70
  };
69
71
  reset(): void;
70
72
  private onFieldInput;
73
+ /** Validate a single field against current form data (siblings included). */
74
+ private validateOneField;
75
+ /** `validateOn: 'blur'` — validate just the field the user left, same as
76
+ * how errors are shown elsewhere (merged into `this.errors`, painted by
77
+ * `renderField`/`.baht-error`). No-op for 'change'/'submit' modes. */
78
+ private onFieldBlur;
71
79
  private renderField;
72
80
  protected render(): TemplateResult;
73
81
  }
@@ -16,6 +16,12 @@ export declare function adoptLightChildren(host: HTMLElement, slot: HTMLElement)
16
16
  * Dumb and controlled — never mutates its own `value` prop; the host re-feeds it.
17
17
  */
18
18
  export declare abstract class BahtFieldBase extends BahtElement {
19
+ /**
20
+ * Per-instance suffix for controlId: the same field key renders once per
21
+ * repeater row (and can repeat across forms on one page), so key-only ids
22
+ * collide — worst for radios, whose shared native `name` merges groups.
23
+ */
24
+ private readonly uid;
19
25
  field: FieldDescriptor;
20
26
  value: unknown;
21
27
  disabled: boolean;
@@ -20,6 +20,10 @@ export declare class BahtAccordion extends BahtElement {
20
20
  private openSet;
21
21
  private static instances;
22
22
  private uid;
23
+ /** Fingerprint of the panel content — identity-independent, so an equal
24
+ * re-fed array doesn't look like a "new" set of items. */
25
+ private itemsFingerprint;
26
+ private static fingerprint;
23
27
  protected willUpdate(changed: Map<PropertyKey, unknown>): void;
24
28
  toggle(index: number): void;
25
29
  protected render(): TemplateResult;
@@ -11,7 +11,8 @@ export declare class BahtAlert extends BahtElement {
11
11
  heading: string;
12
12
  message: string;
13
13
  dismissible: boolean;
14
- hidden: boolean;
14
+ private dismissed;
15
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
15
16
  private dismiss;
16
17
  protected render(): TemplateResult | typeof nothing;
17
18
  }
@@ -14,6 +14,8 @@ export declare class BahtFile extends BahtFieldBase {
14
14
  uploader?: (file: File) => Promise<UploadedFile>;
15
15
  private uploadingCount;
16
16
  private uploadError;
17
+ /** Names of files the last pick rejected for being over `field.maxSize`. */
18
+ private rejectedNames;
17
19
  private get refs();
18
20
  private emitRefs;
19
21
  private uploadAll;
@@ -1,8 +1,8 @@
1
- import { TemplateResult } from 'lit';
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
2
  import { BahtElement } from '../base.js';
3
3
  /**
4
4
  * One-time-code input: N boxes, auto-advance, backspace steps back, paste
5
- * distributes. Emits `baht-change { value }` per edit and `baht-complete { value }`
5
+ * distributes. Emits `baht-change { value }` per edit and `baht-otp-complete { value }`
6
6
  * when every box is filled.
7
7
  *
8
8
  * <baht-otp length="6"></baht-otp>
@@ -15,9 +15,30 @@ export declare class BahtOtp extends BahtElement {
15
15
  mode: 'numeric' | 'text';
16
16
  /** Accessible name for the group of boxes. */
17
17
  label: string;
18
- private get chars();
18
+ /**
19
+ * Per-box state, index-aligned; '' marks an empty box. This is the source
20
+ * of truth for rendering so that clearing box N never shifts box N+1's
21
+ * character into its place. `value` stays a derived, compacted (gap-free)
22
+ * string — the existing external contract (docs: a plain "controlled"
23
+ * string of the digits typed so far, in order).
24
+ */
25
+ private _chars;
26
+ /**
27
+ * The compacted string `_chars` currently represents. Lets willUpdate tell
28
+ * an external `el.value = …` write (e.g. the docs' reset-on-failure
29
+ * example) apart from `commit()` echoing its own assignment, without a
30
+ * boolean flag that could get stuck across a no-op property set.
31
+ */
32
+ private _lastValue;
33
+ /** Previous "every box filled" state, so `baht-otp-complete` fires only on the
34
+ * not-full → full transition, not on every edit while already full. */
35
+ private _wasFull;
19
36
  private inputs;
20
37
  private clean;
38
+ protected willUpdate(changed: PropertyValues<this>): void;
39
+ /** Writes `text` into `_chars` starting at `start`. Returns the index just
40
+ * past the last box written (may equal `this.length`). */
41
+ private fill;
21
42
  private commit;
22
43
  private onInput;
23
44
  private onKeydown;
@@ -2,9 +2,11 @@ import { NestedData, WorkflowDefinition } from '../types.js';
2
2
  /**
3
3
  * The step after `current` given the data: a formName or 'end'. Rules run
4
4
  * (via evaluate) to decide visibility; hidden targets pass through, cycles
5
- * of invisible forms end the walk.
5
+ * of invisible forms end the walk. `visibility` lets a caller that already
6
+ * ran the rules (walkPath — data never changes during a walk) skip the
7
+ * per-hop evaluate() fixpoint.
6
8
  */
7
- export declare function resolveNext(workflow: WorkflowDefinition, current: string, data: NestedData): string | 'end';
9
+ export declare function resolveNext(workflow: WorkflowDefinition, current: string, data: NestedData, visibility?: ReadonlySet<string>): string | 'end';
8
10
  /**
9
11
  * The full path a submission takes from the start form to 'end' under this
10
12
  * data — what the server validates against (off-path forms are as good as
@@ -14,6 +14,7 @@ export interface MessageCatalog {
14
14
  compareLte: string;
15
15
  fileTooLarge: string;
16
16
  fileTypeNotAllowed: string;
17
+ fileRejectedTooLarge: string;
17
18
  uploading: string;
18
19
  uploadFailed: string;
19
20
  removeFile: string;
@@ -36,6 +37,7 @@ export interface MessageCatalog {
36
37
  yes: string;
37
38
  no: string;
38
39
  emptyValue: string;
40
+ rowCount: string;
39
41
  }
40
42
  export type MessageKey = keyof MessageCatalog;
41
43
  export type Locale = 'en' | 'th';
@@ -49,5 +51,14 @@ export type Locale = 'en' | 'th';
49
51
  * the server). Components read the catalog at render time.
50
52
  */
51
53
  export declare function setLocale(locale: Locale, overrides?: Partial<MessageCatalog>): void;
54
+ /**
55
+ * Snapshot of the active catalog. The catalog is module-global — on a server
56
+ * handling concurrent requests with different locales, wrap the locale switch:
57
+ * snapshot, setLocale, do the synchronous work, then setCatalog the snapshot
58
+ * back (bank20baht-validator's `locale` option does exactly this).
59
+ */
60
+ export declare function getCatalog(): MessageCatalog;
61
+ /** Restore a catalog snapshot taken with getCatalog(). */
62
+ export declare function setCatalog(catalog: MessageCatalog): void;
52
63
  /** Resolve one catalog string, interpolating `{param}` placeholders. */
53
64
  export declare function t(key: MessageKey, params?: Record<string, unknown>): string;
@@ -4,7 +4,7 @@ export { approvalFields } from './approval.js';
4
4
  export { validateField } from './validators.js';
5
5
  export { resolveViewFields } from './views.js';
6
6
  export { applyFlags, flagEnabled } from './flags.js';
7
- export { setLocale, t } from './i18n.js';
7
+ export { getCatalog, setCatalog, setLocale, t } from './i18n.js';
8
8
  export type { Locale, MessageCatalog, MessageKey } from './i18n.js';
9
9
  export { evaluate } from './engine/evaluate.js';
10
10
  export { resolveNext, walkPath } from './engine/graph.js';
@@ -234,9 +234,15 @@ export interface Derived {
234
234
  forms: Record<string, {
235
235
  visible: boolean;
236
236
  }>;
237
+ /**
238
+ * 'schema' = authoring defect (unknown rule target) — belongs at store
239
+ * time, not on a submission; 'data' = depends on the submitted values
240
+ * (non-convergence). Absent kind = 'schema' (pre-0.0.12 engines).
241
+ */
237
242
  errors: Array<{
238
243
  ref: string;
239
244
  message: string;
245
+ kind?: 'schema' | 'data';
240
246
  }>;
241
247
  }
242
248
  export interface ValidationError {