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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -0
  3. package/dist/chunks/baht-toast-BlZBbneT.js +324 -0
  4. package/dist/components/baht-form.d.ts +41 -0
  5. package/dist/components/baht-workflow.d.ts +64 -0
  6. package/dist/components/base.d.ts +38 -0
  7. package/dist/components/primitives/baht-accordion.d.ts +26 -0
  8. package/dist/components/primitives/baht-alert.d.ts +17 -0
  9. package/dist/components/primitives/baht-badge.d.ts +19 -0
  10. package/dist/components/primitives/baht-breadcrumbs.d.ts +22 -0
  11. package/dist/components/primitives/baht-button.d.ts +31 -0
  12. package/dist/components/primitives/baht-card.d.ts +18 -0
  13. package/dist/components/primitives/baht-checkbox.d.ts +7 -0
  14. package/dist/components/primitives/baht-code.d.ts +18 -0
  15. package/dist/components/primitives/baht-datepicker.d.ts +6 -0
  16. package/dist/components/primitives/baht-fieldset.d.ts +17 -0
  17. package/dist/components/primitives/baht-file.d.ts +9 -0
  18. package/dist/components/primitives/baht-filter.d.ts +24 -0
  19. package/dist/components/primitives/baht-input.d.ts +6 -0
  20. package/dist/components/primitives/baht-link.d.ts +17 -0
  21. package/dist/components/primitives/baht-list.d.ts +28 -0
  22. package/dist/components/primitives/baht-modal.d.ts +32 -0
  23. package/dist/components/primitives/baht-multiselect.d.ts +8 -0
  24. package/dist/components/primitives/baht-number.d.ts +5 -0
  25. package/dist/components/primitives/baht-otp.d.ts +26 -0
  26. package/dist/components/primitives/baht-pagination.d.ts +21 -0
  27. package/dist/components/primitives/baht-progress.d.ts +16 -0
  28. package/dist/components/primitives/baht-radio.d.ts +5 -0
  29. package/dist/components/primitives/baht-range.d.ts +21 -0
  30. package/dist/components/primitives/baht-rating.d.ts +22 -0
  31. package/dist/components/primitives/baht-select.d.ts +5 -0
  32. package/dist/components/primitives/baht-skeleton.d.ts +16 -0
  33. package/dist/components/primitives/baht-spinner.d.ts +13 -0
  34. package/dist/components/primitives/baht-table.d.ts +44 -0
  35. package/dist/components/primitives/baht-text.d.ts +8 -0
  36. package/dist/components/primitives/baht-textarea.d.ts +5 -0
  37. package/dist/components/primitives/baht-timeline.d.ts +21 -0
  38. package/dist/components/primitives/baht-toast.d.ts +27 -0
  39. package/dist/components/primitives/baht-toggle.d.ts +6 -0
  40. package/dist/components/primitives/baht-tooltip.d.ts +29 -0
  41. package/dist/components/primitives/icons.d.ts +13 -0
  42. package/dist/components/primitives/index.d.ts +38 -0
  43. package/dist/core/approval.d.ts +9 -0
  44. package/dist/core/defaults.d.ts +6 -0
  45. package/dist/core/engine/conditions.d.ts +4 -0
  46. package/dist/core/engine/evaluate.d.ts +8 -0
  47. package/dist/core/engine/expressions.d.ts +3 -0
  48. package/dist/core/index.d.ts +7 -0
  49. package/dist/core/types.d.ts +166 -0
  50. package/dist/core/validators.d.ts +6 -0
  51. package/dist/custom-elements.json +7761 -0
  52. package/dist/engine.js +329 -0
  53. package/dist/index.d.ts +5 -0
  54. package/dist/index.js +1796 -0
  55. package/dist/overlay.d.ts +45 -0
  56. package/dist/overlay.js +121 -0
  57. package/dist/react.d.ts +191 -0
  58. package/dist/react.js +1 -0
  59. package/dist/tokens.css +936 -0
  60. package/dist/vscode.css-custom-data.json +6 -0
  61. package/dist/vscode.html-custom-data.json +479 -0
  62. package/dist/web-types.json +1226 -0
  63. package/package.json +94 -0
@@ -0,0 +1,45 @@
1
+ import { ToastOptions } from './components/primitives/baht-toast.js';
2
+ export type DialogTone = 'info' | 'success' | 'warning' | 'danger';
3
+ export interface DialogOptions {
4
+ /** Modal heading (also its accessible name). Each API has a dry default. */
5
+ title?: string;
6
+ tone?: DialogTone;
7
+ confirmText?: string;
8
+ cancelText?: string;
9
+ /** Secondary monospace block under the message (error detail, payload, …). */
10
+ detail?: string;
11
+ /** Allow Escape / scrim-click to cancel. Default true. */
12
+ dismissible?: boolean;
13
+ }
14
+ export interface PromptOptions extends DialogOptions {
15
+ placeholder?: string;
16
+ /** Initial input value. */
17
+ value?: string;
18
+ }
19
+ export type DialogReason = 'confirm' | 'cancel' | 'escape' | 'scrim' | 'detached';
20
+ export interface DialogResult {
21
+ confirmed: boolean;
22
+ reason: DialogReason;
23
+ /** Input value (prompt only). */
24
+ value?: string;
25
+ }
26
+ export declare const dialog: {
27
+ /** Yes/no question. Resolves true only on explicit confirm. */
28
+ confirm(message: string, options?: DialogOptions): Promise<boolean>;
29
+ /** One-button notice. Resolves when acknowledged. */
30
+ alert(message: string, options?: DialogOptions): Promise<void>;
31
+ /** Error notice — danger tone, optional monospace `detail`. */
32
+ error(message: string, options?: DialogOptions): Promise<void>;
33
+ /** Single text input. Resolves the value, or null on cancel/dismiss. */
34
+ prompt(message: string, options?: PromptOptions): Promise<string | null>;
35
+ };
36
+ type ToastShorthand = Omit<ToastOptions, 'message' | 'tone'>;
37
+ export declare const toast: {
38
+ show(message: string, options?: Omit<ToastOptions, "message">): number;
39
+ success: (message: string, options?: ToastShorthand) => number;
40
+ info: (message: string, options?: ToastShorthand) => number;
41
+ warning: (message: string, options?: ToastShorthand) => number;
42
+ danger: (message: string, options?: ToastShorthand) => number;
43
+ dismiss(id: number): void;
44
+ };
45
+ export {};
@@ -0,0 +1,121 @@
1
+ import "./chunks/baht-toast-BlZBbneT.js";
2
+ let y = Promise.resolve();
3
+ function N(e) {
4
+ const t = y.then(e, e);
5
+ return y = t.catch(() => {
6
+ }), t;
7
+ }
8
+ function p(e) {
9
+ return N(() => I(e));
10
+ }
11
+ async function I(e) {
12
+ var C;
13
+ const t = document.activeElement, o = e.dismissible !== !1, E = e.tone === "danger" ? "danger" : "primary", a = document.createElement("baht-modal");
14
+ a.heading = e.title ?? "", a.showClose = !1, a.closeOnScrim = o;
15
+ const c = document.createElement("div");
16
+ c.className = `baht-dialog${e.tone ? ` baht-dialog--${e.tone}` : ""}`;
17
+ const b = document.createElement("p");
18
+ if (b.className = "baht-dialog-message", b.textContent = e.message, c.appendChild(b), e.detail) {
19
+ const i = document.createElement("pre");
20
+ i.className = "baht-dialog-detail", i.textContent = e.detail, c.appendChild(i);
21
+ }
22
+ let n = null;
23
+ e.showInput && (n = document.createElement("input"), n.className = "baht-control baht-dialog-input", n.type = "text", n.value = e.value ?? "", e.placeholder && (n.placeholder = e.placeholder), c.appendChild(n));
24
+ const u = document.createElement("div");
25
+ u.className = "baht-dialog-actions";
26
+ let l = null;
27
+ e.showCancel && (l = document.createElement("baht-button"), l.className = "baht-dialog-cancel", l.variant = "secondary", l.label = e.cancelText ?? "Cancel", u.appendChild(l));
28
+ const d = document.createElement("baht-button");
29
+ d.className = "baht-dialog-confirm", d.variant = E, d.label = e.confirmText ?? "OK", u.appendChild(d), c.appendChild(u), a.appendChild(c), document.body.appendChild(a), a.open = !0;
30
+ let h;
31
+ const w = new MutationObserver(() => {
32
+ a.isConnected || h == null || h();
33
+ });
34
+ w.observe(document.documentElement, { childList: !0, subtree: !0 });
35
+ const g = await new Promise((i) => {
36
+ let v = !1;
37
+ const m = (s) => {
38
+ v || (v = !0, i(s));
39
+ };
40
+ h = () => m({ confirmed: !1, reason: "detached" }), d.addEventListener(
41
+ "click",
42
+ () => m({ confirmed: !0, reason: "confirm", value: n == null ? void 0 : n.value })
43
+ ), l == null || l.addEventListener("click", () => m({ confirmed: !1, reason: "cancel" })), a.addEventListener("baht-close", (s) => {
44
+ if (!o) return;
45
+ const x = s.detail.reason;
46
+ m({ confirmed: !1, reason: x === "scrim" ? "scrim" : "escape" });
47
+ }), n == null || n.addEventListener("keydown", (s) => {
48
+ s.key === "Enter" && !s.isComposing && m({ confirmed: !0, reason: "confirm", value: s.target.value });
49
+ }), a.updateComplete.then(() => {
50
+ var s;
51
+ return (s = n ?? d.querySelector("button")) == null ? void 0 : s.focus();
52
+ });
53
+ });
54
+ return w.disconnect(), a.open = !1, a.remove(), (C = t == null ? void 0 : t.focus) == null || C.call(t), g;
55
+ }
56
+ const S = {
57
+ /** Yes/no question. Resolves true only on explicit confirm. */
58
+ async confirm(e, t = {}) {
59
+ return (await p({
60
+ title: "Are you sure?",
61
+ confirmText: "Confirm",
62
+ ...t,
63
+ message: e,
64
+ showCancel: !0,
65
+ showInput: !1
66
+ })).confirmed;
67
+ },
68
+ /** One-button notice. Resolves when acknowledged. */
69
+ async alert(e, t = {}) {
70
+ await p({
71
+ title: "Notice",
72
+ ...t,
73
+ message: e,
74
+ showCancel: !1,
75
+ showInput: !1
76
+ });
77
+ },
78
+ /** Error notice — danger tone, optional monospace `detail`. */
79
+ async error(e, t = {}) {
80
+ await p({
81
+ title: "Something went wrong",
82
+ tone: "danger",
83
+ ...t,
84
+ message: e,
85
+ showCancel: !1,
86
+ showInput: !1
87
+ });
88
+ },
89
+ /** Single text input. Resolves the value, or null on cancel/dismiss. */
90
+ async prompt(e, t = {}) {
91
+ const o = await p({
92
+ title: "Input needed",
93
+ confirmText: "OK",
94
+ ...t,
95
+ message: e,
96
+ showCancel: !0,
97
+ showInput: !0
98
+ });
99
+ return o.confirmed ? o.value ?? "" : null;
100
+ }
101
+ };
102
+ let r = null;
103
+ function T() {
104
+ return r != null && r.isConnected || (r = document.querySelector("baht-toast") ?? document.body.appendChild(document.createElement("baht-toast"))), r;
105
+ }
106
+ const f = (e) => (t, o = {}) => L.show(t, { ...o, tone: e }), L = {
107
+ show(e, t = {}) {
108
+ return T().show({ message: e, ...t });
109
+ },
110
+ success: f("success"),
111
+ info: f("info"),
112
+ warning: f("warning"),
113
+ danger: f("danger"),
114
+ dismiss(e) {
115
+ r == null || r.dismiss(e);
116
+ }
117
+ };
118
+ export {
119
+ S as dialog,
120
+ L as toast
121
+ };
@@ -0,0 +1,191 @@
1
+ import { default as React } from 'react';
2
+ import { FieldDescriptor, FieldOption, FormDefinition, NestedData, Registry, WorkflowDefinition } from './core/index.js';
3
+ import { AccordionItem, BadgeTone, ButtonSize, ButtonVariant, CellRenderer, CodeVariant, Crumb, ListItem, TimelineItem } from './components/primitives/index.js';
4
+ import { BahtFormOptions } from './components/baht-form.js';
5
+ /**
6
+ * Base attributes shared by every custom element (style, event handlers, …).
7
+ * `class` is included alongside React's `className` — web-component users often
8
+ * reach for the plain HTML attribute, and both work on custom elements.
9
+ */
10
+ type WC<Props = object> = React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement> & {
11
+ class?: string;
12
+ } & Props, HTMLElement>;
13
+ /** Shared props of the form-field primitives (all extend BahtFieldBase). */
14
+ type FieldProps = {
15
+ field?: FieldDescriptor;
16
+ value?: unknown;
17
+ disabled?: boolean;
18
+ readonly?: boolean;
19
+ required?: boolean;
20
+ error?: string | null;
21
+ };
22
+ declare module 'react' {
23
+ namespace JSX {
24
+ interface IntrinsicElements {
25
+ 'baht-form': WC<{
26
+ form?: FormDefinition;
27
+ value?: Record<string, unknown>;
28
+ registry?: Registry;
29
+ options?: BahtFormOptions;
30
+ }>;
31
+ 'baht-workflow': WC<{
32
+ workflow?: WorkflowDefinition;
33
+ value?: NestedData;
34
+ registry?: Registry;
35
+ 'validate-gate'?: boolean;
36
+ 'next-label'?: string;
37
+ 'submit-label'?: string;
38
+ 'back-label'?: string;
39
+ 'show-back'?: boolean;
40
+ }>;
41
+ 'baht-input': WC<FieldProps>;
42
+ 'baht-textarea': WC<FieldProps>;
43
+ 'baht-number': WC<FieldProps>;
44
+ 'baht-select': WC<FieldProps>;
45
+ 'baht-multiselect': WC<FieldProps>;
46
+ 'baht-checkbox': WC<FieldProps>;
47
+ 'baht-radio': WC<FieldProps>;
48
+ 'baht-toggle': WC<FieldProps>;
49
+ 'baht-datepicker': WC<FieldProps>;
50
+ 'baht-file': WC<FieldProps>;
51
+ 'baht-text': WC<{
52
+ field?: FieldDescriptor;
53
+ }>;
54
+ 'baht-button': WC<{
55
+ variant?: ButtonVariant;
56
+ size?: ButtonSize;
57
+ disabled?: boolean;
58
+ type?: 'button' | 'submit';
59
+ label?: string;
60
+ icon?: string;
61
+ 'icon-only'?: boolean;
62
+ }>;
63
+ 'baht-badge': WC<{
64
+ tone?: BadgeTone;
65
+ label?: string;
66
+ dot?: boolean;
67
+ }>;
68
+ 'baht-card': WC<{
69
+ heading?: string;
70
+ subtitle?: string;
71
+ hero?: boolean;
72
+ }>;
73
+ 'baht-alert': WC<{
74
+ tone?: 'info' | 'success' | 'warning' | 'danger';
75
+ heading?: string;
76
+ message?: string;
77
+ dismissible?: boolean;
78
+ }>;
79
+ 'baht-code': WC<{
80
+ variant?: CodeVariant;
81
+ code?: string;
82
+ }>;
83
+ 'baht-link': WC<{
84
+ href?: string;
85
+ label?: string;
86
+ external?: boolean;
87
+ }>;
88
+ 'baht-spinner': WC<{
89
+ size?: 'sm' | 'md' | 'lg';
90
+ label?: string;
91
+ }>;
92
+ 'baht-skeleton': WC<{
93
+ variant?: 'rect' | 'text' | 'circle';
94
+ width?: string;
95
+ height?: string;
96
+ }>;
97
+ 'baht-tooltip': WC<{
98
+ text?: string;
99
+ position?: 'top' | 'bottom' | 'left' | 'right';
100
+ }>;
101
+ 'baht-fieldset': WC<{
102
+ legend?: string;
103
+ disabled?: boolean;
104
+ }>;
105
+ 'baht-table': WC<{
106
+ items?: Record<string, unknown>[];
107
+ columns?: Record<string, string>;
108
+ renderers?: Record<string, CellRenderer>;
109
+ loading?: boolean;
110
+ error?: boolean;
111
+ 'error-message'?: string;
112
+ 'empty-message'?: string;
113
+ 'show-index'?: boolean;
114
+ 'index-offset'?: number;
115
+ 'skeleton-rows'?: number;
116
+ 'row-key'?: string;
117
+ clickable?: boolean;
118
+ page?: number;
119
+ 'total-pages'?: number;
120
+ }>;
121
+ 'baht-list': WC<{
122
+ items?: ListItem[];
123
+ loading?: boolean;
124
+ error?: boolean;
125
+ 'error-message'?: string;
126
+ 'empty-message'?: string;
127
+ 'skeleton-rows'?: number;
128
+ clickable?: boolean;
129
+ }>;
130
+ 'baht-accordion': WC<{
131
+ items?: AccordionItem[];
132
+ multiple?: boolean;
133
+ }>;
134
+ 'baht-timeline': WC<{
135
+ items?: TimelineItem[];
136
+ }>;
137
+ 'baht-breadcrumbs': WC<{
138
+ items?: Crumb[];
139
+ separator?: string;
140
+ }>;
141
+ 'baht-filter': WC<{
142
+ options?: FieldOption[];
143
+ selected?: string[];
144
+ multiple?: boolean;
145
+ disabled?: boolean;
146
+ }>;
147
+ 'baht-pagination': WC<{
148
+ page?: number;
149
+ 'total-pages'?: number;
150
+ variant?: 'numbered' | 'compact';
151
+ siblings?: number;
152
+ }>;
153
+ 'baht-progress': WC<{
154
+ value?: number | null;
155
+ tone?: 'primary' | 'success' | 'warning' | 'danger';
156
+ 'show-label'?: boolean;
157
+ label?: string;
158
+ }>;
159
+ 'baht-range': WC<{
160
+ value?: number;
161
+ min?: number;
162
+ max?: number;
163
+ step?: number;
164
+ label?: string;
165
+ disabled?: boolean;
166
+ 'show-value'?: boolean;
167
+ }>;
168
+ 'baht-rating': WC<{
169
+ value?: number;
170
+ max?: number;
171
+ readonly?: boolean;
172
+ }>;
173
+ 'baht-otp': WC<{
174
+ length?: number;
175
+ value?: string;
176
+ disabled?: boolean;
177
+ mode?: 'numeric' | 'text';
178
+ }>;
179
+ 'baht-modal': WC<{
180
+ open?: boolean;
181
+ heading?: string;
182
+ 'show-close'?: boolean;
183
+ 'close-on-scrim'?: boolean;
184
+ }>;
185
+ 'baht-toast': WC<{
186
+ duration?: number;
187
+ }>;
188
+ }
189
+ }
190
+ }
191
+ export {};
package/dist/react.js ADDED
@@ -0,0 +1 @@
1
+