bank20baht-ui 0.0.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 +190 -0
- package/dist/chunks/baht-toast-BlZBbneT.js +324 -0
- package/dist/components/baht-form.d.ts +41 -0
- package/dist/components/baht-workflow.d.ts +64 -0
- package/dist/components/base.d.ts +38 -0
- package/dist/components/primitives/baht-accordion.d.ts +26 -0
- package/dist/components/primitives/baht-alert.d.ts +17 -0
- package/dist/components/primitives/baht-badge.d.ts +19 -0
- package/dist/components/primitives/baht-breadcrumbs.d.ts +22 -0
- package/dist/components/primitives/baht-button.d.ts +31 -0
- package/dist/components/primitives/baht-card.d.ts +18 -0
- package/dist/components/primitives/baht-checkbox.d.ts +7 -0
- package/dist/components/primitives/baht-code.d.ts +18 -0
- package/dist/components/primitives/baht-datepicker.d.ts +6 -0
- package/dist/components/primitives/baht-fieldset.d.ts +17 -0
- package/dist/components/primitives/baht-file.d.ts +9 -0
- package/dist/components/primitives/baht-filter.d.ts +24 -0
- package/dist/components/primitives/baht-input.d.ts +6 -0
- package/dist/components/primitives/baht-link.d.ts +17 -0
- package/dist/components/primitives/baht-list.d.ts +28 -0
- package/dist/components/primitives/baht-modal.d.ts +32 -0
- package/dist/components/primitives/baht-multiselect.d.ts +8 -0
- package/dist/components/primitives/baht-number.d.ts +5 -0
- package/dist/components/primitives/baht-otp.d.ts +26 -0
- package/dist/components/primitives/baht-pagination.d.ts +21 -0
- package/dist/components/primitives/baht-progress.d.ts +16 -0
- package/dist/components/primitives/baht-radio.d.ts +5 -0
- package/dist/components/primitives/baht-range.d.ts +21 -0
- package/dist/components/primitives/baht-rating.d.ts +22 -0
- package/dist/components/primitives/baht-select.d.ts +5 -0
- package/dist/components/primitives/baht-skeleton.d.ts +16 -0
- package/dist/components/primitives/baht-spinner.d.ts +13 -0
- package/dist/components/primitives/baht-table.d.ts +44 -0
- package/dist/components/primitives/baht-text.d.ts +8 -0
- package/dist/components/primitives/baht-textarea.d.ts +5 -0
- package/dist/components/primitives/baht-timeline.d.ts +21 -0
- package/dist/components/primitives/baht-toast.d.ts +27 -0
- package/dist/components/primitives/baht-toggle.d.ts +6 -0
- package/dist/components/primitives/baht-tooltip.d.ts +29 -0
- package/dist/components/primitives/icons.d.ts +13 -0
- package/dist/components/primitives/index.d.ts +38 -0
- package/dist/core/approval.d.ts +9 -0
- package/dist/core/defaults.d.ts +6 -0
- package/dist/core/engine/conditions.d.ts +4 -0
- package/dist/core/engine/evaluate.d.ts +8 -0
- package/dist/core/engine/expressions.d.ts +3 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/types.d.ts +166 -0
- package/dist/core/validators.d.ts +6 -0
- package/dist/custom-elements.json +7761 -0
- package/dist/engine.js +329 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1796 -0
- package/dist/overlay.d.ts +45 -0
- package/dist/overlay.js +121 -0
- package/dist/react.d.ts +191 -0
- package/dist/react.js +1 -0
- package/dist/tokens.css +936 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +479 -0
- package/dist/web-types.json +1226 -0
- package/package.json +94 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Curated inline-SVG icon set for the design system. Intentionally small — the
|
|
4
|
+
* 20baht system uses icons sparingly (only the spinner animates). Each icon is a
|
|
5
|
+
* 16×16 currentColor stroke glyph so it inherits button/link color.
|
|
6
|
+
*
|
|
7
|
+
* Add an icon only when a component genuinely needs it; this is not a general
|
|
8
|
+
* icon library.
|
|
9
|
+
*/
|
|
10
|
+
export type IconName = 'copy' | 'check' | 'download' | 'upload' | 'plus' | 'external' | 'close' | 'play';
|
|
11
|
+
/** Render a named icon, or `nothing`-equivalent empty when the name is unknown. */
|
|
12
|
+
export declare function renderIcon(name: IconName): TemplateResult;
|
|
13
|
+
export declare function isIconName(v: string): v is IconName;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FieldType } from '../../core/types.js';
|
|
2
|
+
export { BahtButton, type ButtonVariant, type ButtonSize } from './baht-button.js';
|
|
3
|
+
export { renderIcon, isIconName, type IconName } from './icons.js';
|
|
4
|
+
export { BahtBadge, type BadgeTone } from './baht-badge.js';
|
|
5
|
+
export { BahtCode, type CodeVariant } from './baht-code.js';
|
|
6
|
+
export { BahtTable, type CellRenderer } from './baht-table.js';
|
|
7
|
+
export { BahtList, type ListItem } from './baht-list.js';
|
|
8
|
+
export { BahtPagination } from './baht-pagination.js';
|
|
9
|
+
export { BahtModal } from './baht-modal.js';
|
|
10
|
+
export { BahtToast, type ToastOptions } from './baht-toast.js';
|
|
11
|
+
export { BahtTooltip } from './baht-tooltip.js';
|
|
12
|
+
export { BahtAlert } from './baht-alert.js';
|
|
13
|
+
export { BahtRating } from './baht-rating.js';
|
|
14
|
+
export { BahtRange } from './baht-range.js';
|
|
15
|
+
export { BahtOtp } from './baht-otp.js';
|
|
16
|
+
export { BahtFilter } from './baht-filter.js';
|
|
17
|
+
export { BahtSkeleton } from './baht-skeleton.js';
|
|
18
|
+
export { BahtProgress } from './baht-progress.js';
|
|
19
|
+
export { BahtSpinner } from './baht-spinner.js';
|
|
20
|
+
export { BahtCard } from './baht-card.js';
|
|
21
|
+
export { BahtFieldset } from './baht-fieldset.js';
|
|
22
|
+
export { BahtTimeline, type TimelineItem } from './baht-timeline.js';
|
|
23
|
+
export { BahtAccordion, type AccordionItem } from './baht-accordion.js';
|
|
24
|
+
export { BahtLink } from './baht-link.js';
|
|
25
|
+
export { BahtBreadcrumbs, type Crumb } from './baht-breadcrumbs.js';
|
|
26
|
+
export { BahtInput } from './baht-input.js';
|
|
27
|
+
export { BahtTextarea } from './baht-textarea.js';
|
|
28
|
+
export { BahtNumber } from './baht-number.js';
|
|
29
|
+
export { BahtSelect } from './baht-select.js';
|
|
30
|
+
export { BahtMultiselect } from './baht-multiselect.js';
|
|
31
|
+
export { BahtCheckbox } from './baht-checkbox.js';
|
|
32
|
+
export { BahtRadio } from './baht-radio.js';
|
|
33
|
+
export { BahtToggle } from './baht-toggle.js';
|
|
34
|
+
export { BahtDatepicker } from './baht-datepicker.js';
|
|
35
|
+
export { BahtFile } from './baht-file.js';
|
|
36
|
+
export { BahtText } from './baht-text.js';
|
|
37
|
+
/** field descriptor `type` -> primitive tag (used by <baht-form> and the builder). */
|
|
38
|
+
export declare const TAG_FOR_TYPE: Record<FieldType, string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FieldDescriptor, WorkflowForm } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The synthetic value-carrying fields of an approval step (spec 03 §4).
|
|
4
|
+
* The engine indexes them like authored fields so `<name>.decision` /
|
|
5
|
+
* `<name>.comment` are rule-addressable, survive `evaluate()`'s output
|
|
6
|
+
* filter, and get clear-on-skip semantics. Authored fields with the same
|
|
7
|
+
* key win (none expected in v1 — approval steps carry no authored fields).
|
|
8
|
+
*/
|
|
9
|
+
export declare function approvalFields(form: WorkflowForm): FieldDescriptor[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Condition, NestedData } from '../types.js';
|
|
2
|
+
/** Read a "formName.fieldKey" reference out of nested data. */
|
|
3
|
+
export declare function readRef(data: NestedData, ref: string): unknown;
|
|
4
|
+
export declare function evalCondition(cond: Condition | undefined, data: NestedData): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Derived, NestedData, WorkflowDefinition } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The rules engine (spec 02 §5). Pure: same inputs -> same Derived.
|
|
4
|
+
* Reactive fixpoint: reset -> eval when -> apply (priority-resolved) ->
|
|
5
|
+
* clear hidden/skipped to defaults -> setValue -> repeat until stable
|
|
6
|
+
* (cycle guard MAX_PASSES; overflow surfaces an error, never hangs).
|
|
7
|
+
*/
|
|
8
|
+
export declare function evaluate(workflow: WorkflowDefinition, input: NestedData): Derived;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './types.js';
|
|
2
|
+
export { defaultValue } from './defaults.js';
|
|
3
|
+
export { approvalFields } from './approval.js';
|
|
4
|
+
export { validateField } from './validators.js';
|
|
5
|
+
export { evaluate } from './engine/evaluate.js';
|
|
6
|
+
export { evalCondition, readRef } from './engine/conditions.js';
|
|
7
|
+
export { evalValueExpr } from './engine/expressions.js';
|
|
@@ -0,0 +1,166 @@
|
|
|
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';
|
|
3
|
+
export type FieldWidth = '1/4' | '1/2' | '3/4' | 'full';
|
|
4
|
+
export interface FieldOption {
|
|
5
|
+
key: string;
|
|
6
|
+
label: string;
|
|
7
|
+
}
|
|
8
|
+
/** Declarative validator (spec 01 §4). `custom` resolves `fn` from the registry. */
|
|
9
|
+
export interface ValidatorSpec {
|
|
10
|
+
type: 'required' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'email' | 'custom';
|
|
11
|
+
value?: unknown;
|
|
12
|
+
fn?: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
}
|
|
15
|
+
/** One item of `field_data[]` (spec 01 §1). */
|
|
16
|
+
export interface FieldDescriptor {
|
|
17
|
+
order: number;
|
|
18
|
+
type: FieldType;
|
|
19
|
+
key: string;
|
|
20
|
+
label?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
help?: string;
|
|
23
|
+
autocomplete?: string;
|
|
24
|
+
width?: FieldWidth;
|
|
25
|
+
value?: unknown;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
options?: FieldOption[];
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
minLength?: number;
|
|
31
|
+
min?: number | string;
|
|
32
|
+
max?: number | string;
|
|
33
|
+
step?: number;
|
|
34
|
+
rows?: number;
|
|
35
|
+
accept?: string;
|
|
36
|
+
multiple?: boolean;
|
|
37
|
+
maxSize?: number;
|
|
38
|
+
text?: string;
|
|
39
|
+
variant?: string;
|
|
40
|
+
validators?: ValidatorSpec[];
|
|
41
|
+
formatter?: string;
|
|
42
|
+
}
|
|
43
|
+
/** A Form definition — consumed standalone by <baht-form> (spec 00 §4.1). */
|
|
44
|
+
export interface FormDefinition {
|
|
45
|
+
formId: string;
|
|
46
|
+
formName: string;
|
|
47
|
+
field_data: FieldDescriptor[];
|
|
48
|
+
}
|
|
49
|
+
export type ApprovalDecision = 'approved' | 'rejected';
|
|
50
|
+
/** Comment box policy on an approval step. */
|
|
51
|
+
export type ApprovalCommentMode = 'hidden' | 'optional' | 'requireOnReject' | 'required';
|
|
52
|
+
export interface ApprovalConfig {
|
|
53
|
+
/** formNames whose data the summary shows; default = every earlier visible form. */
|
|
54
|
+
summaryForms?: string[];
|
|
55
|
+
approveLabel?: string;
|
|
56
|
+
rejectLabel?: string;
|
|
57
|
+
comment?: ApprovalCommentMode;
|
|
58
|
+
/** Reject behavior: end the workflow (default) or send the user back to a form. */
|
|
59
|
+
onReject?: {
|
|
60
|
+
action: 'end';
|
|
61
|
+
} | {
|
|
62
|
+
action: 'goto';
|
|
63
|
+
form: string;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** A form inside a workflow: adds its position in the linear order. */
|
|
67
|
+
export interface WorkflowForm extends FormDefinition {
|
|
68
|
+
order: number;
|
|
69
|
+
/**
|
|
70
|
+
* 'approval' renders a decision step (summary + Approve/Reject) instead of
|
|
71
|
+
* fields; its `decision`/`comment` values live in data like any field.
|
|
72
|
+
* Default 'form'.
|
|
73
|
+
*/
|
|
74
|
+
kind?: 'form' | 'approval';
|
|
75
|
+
approval?: ApprovalConfig;
|
|
76
|
+
}
|
|
77
|
+
export type ConditionOp = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'isEmpty' | 'isNotEmpty';
|
|
78
|
+
/** Leaf: compare `formName.fieldKey` against a constant or another field. */
|
|
79
|
+
export interface FieldCondition {
|
|
80
|
+
field: string;
|
|
81
|
+
op: ConditionOp;
|
|
82
|
+
value?: unknown;
|
|
83
|
+
valueField?: string;
|
|
84
|
+
}
|
|
85
|
+
export type Condition = FieldCondition | {
|
|
86
|
+
and: Condition[];
|
|
87
|
+
} | {
|
|
88
|
+
or: Condition[];
|
|
89
|
+
} | {
|
|
90
|
+
not: Condition;
|
|
91
|
+
};
|
|
92
|
+
export type ValueExpr = {
|
|
93
|
+
ref: string;
|
|
94
|
+
} | {
|
|
95
|
+
const: unknown;
|
|
96
|
+
} | {
|
|
97
|
+
op: 'add' | 'sub' | 'mul' | 'div' | 'concat' | 'coalesce';
|
|
98
|
+
args: ValueExpr[];
|
|
99
|
+
} | {
|
|
100
|
+
if: [Condition, ValueExpr, ValueExpr];
|
|
101
|
+
};
|
|
102
|
+
export interface FieldTarget {
|
|
103
|
+
form: string;
|
|
104
|
+
field: string;
|
|
105
|
+
}
|
|
106
|
+
export interface FormTarget {
|
|
107
|
+
form: string;
|
|
108
|
+
}
|
|
109
|
+
export type FieldActionType = 'show' | 'hide' | 'enable' | 'disable' | 'readonly' | 'required' | 'optional';
|
|
110
|
+
export type Action = {
|
|
111
|
+
action: FieldActionType;
|
|
112
|
+
target: FieldTarget;
|
|
113
|
+
} | {
|
|
114
|
+
action: 'setValue';
|
|
115
|
+
target: FieldTarget;
|
|
116
|
+
value: ValueExpr;
|
|
117
|
+
lock?: boolean;
|
|
118
|
+
} | {
|
|
119
|
+
action: 'showForm' | 'hideForm' | 'skipForm';
|
|
120
|
+
target: FormTarget;
|
|
121
|
+
};
|
|
122
|
+
export interface Rule {
|
|
123
|
+
id?: string;
|
|
124
|
+
priority?: number;
|
|
125
|
+
when?: Condition;
|
|
126
|
+
then?: Action[];
|
|
127
|
+
else?: Action[];
|
|
128
|
+
}
|
|
129
|
+
/** A Workflow definition — consumed by <baht-workflow> (spec 00 §4.2). */
|
|
130
|
+
export interface WorkflowDefinition {
|
|
131
|
+
workflowId: string;
|
|
132
|
+
forms: WorkflowForm[];
|
|
133
|
+
rules: Rule[];
|
|
134
|
+
}
|
|
135
|
+
export interface Registry {
|
|
136
|
+
formatters?: Record<string, (value: unknown) => unknown>;
|
|
137
|
+
/** Return null when valid, or an error message string. */
|
|
138
|
+
validators?: Record<string, (value: unknown) => string | null>;
|
|
139
|
+
}
|
|
140
|
+
export interface DerivedFieldState {
|
|
141
|
+
visible: boolean;
|
|
142
|
+
enabled: boolean;
|
|
143
|
+
readonly: boolean;
|
|
144
|
+
required: boolean;
|
|
145
|
+
/** True while a setValue rule with lock (default) is active on this field. */
|
|
146
|
+
computed: boolean;
|
|
147
|
+
}
|
|
148
|
+
export type NestedData = Record<string, Record<string, unknown>>;
|
|
149
|
+
export interface Derived {
|
|
150
|
+
/** Nested {formName: {key: value}} — possibly mutated by setValue/clears. */
|
|
151
|
+
data: NestedData;
|
|
152
|
+
/** Keyed "formName.key". */
|
|
153
|
+
fields: Record<string, DerivedFieldState>;
|
|
154
|
+
/** skipForm/hideForm result per formName. */
|
|
155
|
+
forms: Record<string, {
|
|
156
|
+
visible: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
errors: Array<{
|
|
159
|
+
ref: string;
|
|
160
|
+
message: string;
|
|
161
|
+
}>;
|
|
162
|
+
}
|
|
163
|
+
export interface ValidationError {
|
|
164
|
+
key: string;
|
|
165
|
+
message: string;
|
|
166
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FieldDescriptor, Registry, ValidationError } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validate one field's value against its declarative validators (spec 01 §4).
|
|
4
|
+
* Empty + not required = valid (other validators only run on non-empty values).
|
|
5
|
+
*/
|
|
6
|
+
export declare function validateField(field: FieldDescriptor, value: unknown, registry?: Registry): ValidationError[];
|