@uipath/apollo-wind 0.7.2-pr188.4865fad
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 +188 -0
- package/dist/components/forms/data-fetcher.cjs +250 -0
- package/dist/components/forms/data-fetcher.d.ts +173 -0
- package/dist/components/forms/data-fetcher.js +207 -0
- package/dist/components/forms/demo-mocks.cjs +1031 -0
- package/dist/components/forms/demo-mocks.d.ts +10 -0
- package/dist/components/forms/demo-mocks.js +997 -0
- package/dist/components/forms/field-renderer.cjs +595 -0
- package/dist/components/forms/field-renderer.d.ts +14 -0
- package/dist/components/forms/field-renderer.js +561 -0
- package/dist/components/forms/form-designer.cjs +2314 -0
- package/dist/components/forms/form-designer.d.ts +1 -0
- package/dist/components/forms/form-designer.js +2280 -0
- package/dist/components/forms/form-examples.cjs +962 -0
- package/dist/components/forms/form-examples.d.ts +46 -0
- package/dist/components/forms/form-examples.js +907 -0
- package/dist/components/forms/form-plugins.cjs +225 -0
- package/dist/components/forms/form-plugins.d.ts +11 -0
- package/dist/components/forms/form-plugins.js +176 -0
- package/dist/components/forms/form-schema.cjs +56 -0
- package/dist/components/forms/form-schema.d.ts +324 -0
- package/dist/components/forms/form-schema.js +13 -0
- package/dist/components/forms/form-state-viewer.cjs +498 -0
- package/dist/components/forms/form-state-viewer.d.ts +15 -0
- package/dist/components/forms/form-state-viewer.js +464 -0
- package/dist/components/forms/index.cjs +103 -0
- package/dist/components/forms/index.d.ts +13 -0
- package/dist/components/forms/index.js +9 -0
- package/dist/components/forms/metadata-form.cjs +400 -0
- package/dist/components/forms/metadata-form.d.ts +16 -0
- package/dist/components/forms/metadata-form.js +366 -0
- package/dist/components/forms/rules-engine.cjs +343 -0
- package/dist/components/forms/rules-engine.d.ts +99 -0
- package/dist/components/forms/rules-engine.js +293 -0
- package/dist/components/forms/schema-serializer.cjs +250 -0
- package/dist/components/forms/schema-serializer.d.ts +27 -0
- package/dist/components/forms/schema-serializer.js +213 -0
- package/dist/components/forms/schema-viewer.cjs +157 -0
- package/dist/components/forms/schema-viewer.d.ts +29 -0
- package/dist/components/forms/schema-viewer.js +117 -0
- package/dist/components/forms/validation-converter.cjs +154 -0
- package/dist/components/forms/validation-converter.d.ts +42 -0
- package/dist/components/forms/validation-converter.js +114 -0
- package/dist/components/ui/accordion.cjs +82 -0
- package/dist/components/ui/accordion.d.ts +7 -0
- package/dist/components/ui/accordion.js +39 -0
- package/dist/components/ui/alert-dialog.cjs +126 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert-dialog.js +62 -0
- package/dist/components/ui/alert.cjs +77 -0
- package/dist/components/ui/alert.d.ts +8 -0
- package/dist/components/ui/alert.js +37 -0
- package/dist/components/ui/aspect-ratio.cjs +38 -0
- package/dist/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/components/ui/aspect-ratio.js +4 -0
- package/dist/components/ui/avatar.cjs +63 -0
- package/dist/components/ui/avatar.d.ts +6 -0
- package/dist/components/ui/avatar.js +23 -0
- package/dist/components/ui/badge.cjs +63 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/badge.js +26 -0
- package/dist/components/ui/breadcrumb.cjs +118 -0
- package/dist/components/ui/breadcrumb.d.ts +19 -0
- package/dist/components/ui/breadcrumb.js +66 -0
- package/dist/components/ui/button-group.cjs +68 -0
- package/dist/components/ui/button-group.d.ts +14 -0
- package/dist/components/ui/button-group.js +28 -0
- package/dist/components/ui/button.cjs +78 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.js +41 -0
- package/dist/components/ui/calendar.cjs +144 -0
- package/dist/components/ui/calendar.d.ts +8 -0
- package/dist/components/ui/calendar.js +107 -0
- package/dist/components/ui/card.cjs +89 -0
- package/dist/components/ui/card.d.ts +8 -0
- package/dist/components/ui/card.js +40 -0
- package/dist/components/ui/checkbox.cjs +52 -0
- package/dist/components/ui/checkbox.d.ts +6 -0
- package/dist/components/ui/checkbox.js +18 -0
- package/dist/components/ui/collapsible.cjs +45 -0
- package/dist/components/ui/collapsible.d.ts +5 -0
- package/dist/components/ui/collapsible.js +5 -0
- package/dist/components/ui/combobox.cjs +102 -0
- package/dist/components/ui/combobox.d.ts +15 -0
- package/dist/components/ui/combobox.js +68 -0
- package/dist/components/ui/command.cjs +131 -0
- package/dist/components/ui/command.d.ts +80 -0
- package/dist/components/ui/command.js +73 -0
- package/dist/components/ui/context-menu.cjs +173 -0
- package/dist/components/ui/context-menu.d.ts +27 -0
- package/dist/components/ui/context-menu.js +97 -0
- package/dist/components/ui/data-table.cjs +292 -0
- package/dist/components/ui/data-table.d.ts +23 -0
- package/dist/components/ui/data-table.js +252 -0
- package/dist/components/ui/date-picker.cjs +118 -0
- package/dist/components/ui/date-picker.d.ts +21 -0
- package/dist/components/ui/date-picker.js +81 -0
- package/dist/components/ui/datetime-picker.cjs +154 -0
- package/dist/components/ui/datetime-picker.d.ts +9 -0
- package/dist/components/ui/datetime-picker.js +120 -0
- package/dist/components/ui/dialog.cjs +159 -0
- package/dist/components/ui/dialog.d.ts +15 -0
- package/dist/components/ui/dialog.js +98 -0
- package/dist/components/ui/drawer.cjs +116 -0
- package/dist/components/ui/drawer.d.ts +18 -0
- package/dist/components/ui/drawer.js +55 -0
- package/dist/components/ui/dropdown-menu.cjs +174 -0
- package/dist/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/components/ui/dropdown-menu.js +98 -0
- package/dist/components/ui/editable-cell.cjs +256 -0
- package/dist/components/ui/editable-cell.d.ts +24 -0
- package/dist/components/ui/editable-cell.js +219 -0
- package/dist/components/ui/empty-state.cjs +73 -0
- package/dist/components/ui/empty-state.d.ts +16 -0
- package/dist/components/ui/empty-state.js +39 -0
- package/dist/components/ui/file-upload.cjs +236 -0
- package/dist/components/ui/file-upload.d.ts +10 -0
- package/dist/components/ui/file-upload.js +202 -0
- package/dist/components/ui/hover-card.cjs +55 -0
- package/dist/components/ui/hover-card.d.ts +6 -0
- package/dist/components/ui/hover-card.js +15 -0
- package/dist/components/ui/index.cjs +546 -0
- package/dist/components/ui/index.d.ts +55 -0
- package/dist/components/ui/index.js +55 -0
- package/dist/components/ui/input.cjs +45 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +11 -0
- package/dist/components/ui/label.cjs +47 -0
- package/dist/components/ui/label.d.ts +7 -0
- package/dist/components/ui/label.js +13 -0
- package/dist/components/ui/layout/column.cjs +84 -0
- package/dist/components/ui/layout/column.d.ts +21 -0
- package/dist/components/ui/layout/column.js +50 -0
- package/dist/components/ui/layout/grid.cjs +101 -0
- package/dist/components/ui/layout/grid.d.ts +22 -0
- package/dist/components/ui/layout/grid.js +67 -0
- package/dist/components/ui/layout/index.cjs +44 -0
- package/dist/components/ui/layout/index.d.ts +7 -0
- package/dist/components/ui/layout/index.js +4 -0
- package/dist/components/ui/layout/row.cjs +84 -0
- package/dist/components/ui/layout/row.d.ts +21 -0
- package/dist/components/ui/layout/row.js +50 -0
- package/dist/components/ui/layout/types.cjs +18 -0
- package/dist/components/ui/layout/types.d.ts +149 -0
- package/dist/components/ui/layout/types.js +0 -0
- package/dist/components/ui/layout/utils.cjs +324 -0
- package/dist/components/ui/layout/utils.d.ts +76 -0
- package/dist/components/ui/layout/utils.js +239 -0
- package/dist/components/ui/menubar.cjs +210 -0
- package/dist/components/ui/menubar.d.ts +28 -0
- package/dist/components/ui/menubar.js +131 -0
- package/dist/components/ui/multi-select.cjs +187 -0
- package/dist/components/ui/multi-select.d.ts +18 -0
- package/dist/components/ui/multi-select.js +153 -0
- package/dist/components/ui/navigation-menu.cjs +122 -0
- package/dist/components/ui/navigation-menu.d.ts +12 -0
- package/dist/components/ui/navigation-menu.js +64 -0
- package/dist/components/ui/pagination.cjs +131 -0
- package/dist/components/ui/pagination.d.ts +28 -0
- package/dist/components/ui/pagination.js +79 -0
- package/dist/components/ui/popover.cjs +61 -0
- package/dist/components/ui/popover.d.ts +7 -0
- package/dist/components/ui/popover.js +18 -0
- package/dist/components/ui/progress.cjs +51 -0
- package/dist/components/ui/progress.d.ts +4 -0
- package/dist/components/ui/progress.js +17 -0
- package/dist/components/ui/radio-group.cjs +61 -0
- package/dist/components/ui/radio-group.d.ts +5 -0
- package/dist/components/ui/radio-group.js +24 -0
- package/dist/components/ui/resizable.cjs +60 -0
- package/dist/components/ui/resizable.d.ts +23 -0
- package/dist/components/ui/resizable.js +20 -0
- package/dist/components/ui/scroll-area.cjs +67 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/scroll-area.js +30 -0
- package/dist/components/ui/search.cjs +153 -0
- package/dist/components/ui/search.d.ts +19 -0
- package/dist/components/ui/search.js +116 -0
- package/dist/components/ui/select.cjs +151 -0
- package/dist/components/ui/select.d.ts +13 -0
- package/dist/components/ui/select.js +90 -0
- package/dist/components/ui/separator.cjs +47 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/separator.js +13 -0
- package/dist/components/ui/sheet.cjs +142 -0
- package/dist/components/ui/sheet.d.ts +25 -0
- package/dist/components/ui/sheet.js +81 -0
- package/dist/components/ui/skeleton.cjs +43 -0
- package/dist/components/ui/skeleton.d.ts +2 -0
- package/dist/components/ui/skeleton.js +9 -0
- package/dist/components/ui/slider.cjs +63 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/slider.js +29 -0
- package/dist/components/ui/sonner.cjs +76 -0
- package/dist/components/ui/sonner.d.ts +4 -0
- package/dist/components/ui/sonner.js +39 -0
- package/dist/components/ui/spinner.cjs +78 -0
- package/dist/components/ui/spinner.d.ts +11 -0
- package/dist/components/ui/spinner.js +41 -0
- package/dist/components/ui/stats-card.cjs +102 -0
- package/dist/components/ui/stats-card.d.ts +15 -0
- package/dist/components/ui/stats-card.js +68 -0
- package/dist/components/ui/stepper.cjs +99 -0
- package/dist/components/ui/stepper.d.ts +14 -0
- package/dist/components/ui/stepper.js +65 -0
- package/dist/components/ui/switch.cjs +48 -0
- package/dist/components/ui/switch.d.ts +4 -0
- package/dist/components/ui/switch.js +14 -0
- package/dist/components/ui/table.cjs +110 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/table.js +55 -0
- package/dist/components/ui/tabs.cjs +67 -0
- package/dist/components/ui/tabs.d.ts +7 -0
- package/dist/components/ui/tabs.js +24 -0
- package/dist/components/ui/textarea.cjs +44 -0
- package/dist/components/ui/textarea.d.ts +4 -0
- package/dist/components/ui/textarea.js +10 -0
- package/dist/components/ui/toggle-group.cjs +73 -0
- package/dist/components/ui/toggle-group.d.ts +12 -0
- package/dist/components/ui/toggle-group.js +36 -0
- package/dist/components/ui/toggle.cjs +71 -0
- package/dist/components/ui/toggle.d.ts +12 -0
- package/dist/components/ui/toggle.js +34 -0
- package/dist/components/ui/tooltip.cjs +58 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tooltip.js +15 -0
- package/dist/examples/admin-layout-example.d.ts +92 -0
- package/dist/examples/app-shell-example.d.ts +52 -0
- package/dist/examples/dashboard-example.d.ts +11 -0
- package/dist/examples/data-management-example.d.ts +1 -0
- package/dist/examples/flow-editor-layout-example.d.ts +22 -0
- package/dist/examples/flow-start-example.d.ts +30 -0
- package/dist/examples/form-builder-example.d.ts +1 -0
- package/dist/examples/new-project-example.d.ts +30 -0
- package/dist/examples/settings-example.d.ts +1 -0
- package/dist/examples/vscode-example.d.ts +80 -0
- package/dist/index.cjs +830 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +67 -0
- package/dist/lib/index.cjs +42 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +2 -0
- package/dist/lib/utils.cjs +70 -0
- package/dist/lib/utils.d.ts +14 -0
- package/dist/lib/utils.js +30 -0
- package/dist/postcss.config.export.cjs +43 -0
- package/dist/postcss.config.export.js +9 -0
- package/dist/styles.css +6868 -0
- package/dist/tailwind.css +239 -0
- package/dist/tailwind.preset.cjs +77 -0
- package/dist/tailwind.preset.js +43 -0
- package/package.json +157 -0
- package/postcss.config.export.js +9 -0
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import type { UseFormReturn, FieldValues } from 'react-hook-form';
|
|
2
|
+
/**
|
|
3
|
+
* Core Schema Types for Apollo-Wind Metadata Forms
|
|
4
|
+
* Designed for enterprise automation workflows with extensibility
|
|
5
|
+
*
|
|
6
|
+
* Uses discriminated unions for type-safe field metadata
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Field option for select, multiselect, and radio fields
|
|
10
|
+
*/
|
|
11
|
+
export interface FieldOption {
|
|
12
|
+
label: string;
|
|
13
|
+
value: string | number | boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Grid layout configuration
|
|
18
|
+
*/
|
|
19
|
+
export interface GridConfig {
|
|
20
|
+
span?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
|
21
|
+
order?: number;
|
|
22
|
+
breakpoint?: 'sm' | 'md' | 'lg' | 'xl';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Data source for dynamic options
|
|
26
|
+
*/
|
|
27
|
+
export type DataSource = {
|
|
28
|
+
type: 'static';
|
|
29
|
+
options: FieldOption[];
|
|
30
|
+
} | {
|
|
31
|
+
type: 'fetch';
|
|
32
|
+
url: string;
|
|
33
|
+
method?: 'GET' | 'POST';
|
|
34
|
+
transform?: string;
|
|
35
|
+
params?: Record<string, unknown>;
|
|
36
|
+
} | {
|
|
37
|
+
type: 'remote';
|
|
38
|
+
endpoint: string;
|
|
39
|
+
method?: 'GET' | 'POST';
|
|
40
|
+
params?: Record<string, unknown>;
|
|
41
|
+
transform?: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'computed';
|
|
44
|
+
dependency: string[];
|
|
45
|
+
compute: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Condition for rules engine
|
|
49
|
+
*/
|
|
50
|
+
export interface FieldCondition {
|
|
51
|
+
when: string;
|
|
52
|
+
is?: unknown;
|
|
53
|
+
isNot?: unknown;
|
|
54
|
+
in?: unknown[];
|
|
55
|
+
notIn?: unknown[];
|
|
56
|
+
matches?: string;
|
|
57
|
+
custom?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Rule for conditional behavior
|
|
61
|
+
*/
|
|
62
|
+
export interface FieldRule {
|
|
63
|
+
id: string;
|
|
64
|
+
conditions: FieldCondition[];
|
|
65
|
+
operator?: 'AND' | 'OR';
|
|
66
|
+
effects: {
|
|
67
|
+
visible?: boolean;
|
|
68
|
+
disabled?: boolean;
|
|
69
|
+
required?: boolean;
|
|
70
|
+
value?: unknown;
|
|
71
|
+
options?: DataSource;
|
|
72
|
+
validate?: ValidationConfig;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Validation error messages
|
|
77
|
+
* Used within ValidationConfig for custom error text
|
|
78
|
+
*/
|
|
79
|
+
export interface ValidationMessages {
|
|
80
|
+
required?: string;
|
|
81
|
+
minLength?: string;
|
|
82
|
+
maxLength?: string;
|
|
83
|
+
pattern?: string;
|
|
84
|
+
min?: string;
|
|
85
|
+
max?: string;
|
|
86
|
+
email?: string;
|
|
87
|
+
url?: string;
|
|
88
|
+
integer?: string;
|
|
89
|
+
positive?: string;
|
|
90
|
+
negative?: string;
|
|
91
|
+
minItems?: string;
|
|
92
|
+
maxItems?: string;
|
|
93
|
+
custom?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Validation configuration - JSON-serializable
|
|
97
|
+
*
|
|
98
|
+
* Maps 1:1 to JSON for database storage and API transmission.
|
|
99
|
+
* Converted to Zod schema at runtime for actual validation.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Simple required email
|
|
103
|
+
* { required: true, email: true, messages: { email: "Invalid email" } }
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Password with constraints
|
|
107
|
+
* {
|
|
108
|
+
* required: true,
|
|
109
|
+
* minLength: 8,
|
|
110
|
+
* pattern: "^(?=.*[A-Z])(?=.*[0-9]).*$",
|
|
111
|
+
* messages: {
|
|
112
|
+
* minLength: "Password must be at least 8 characters",
|
|
113
|
+
* pattern: "Must contain uppercase letter and number"
|
|
114
|
+
* }
|
|
115
|
+
* }
|
|
116
|
+
*/
|
|
117
|
+
export interface ValidationConfig {
|
|
118
|
+
required?: boolean;
|
|
119
|
+
minLength?: number;
|
|
120
|
+
maxLength?: number;
|
|
121
|
+
pattern?: string;
|
|
122
|
+
email?: boolean;
|
|
123
|
+
url?: boolean;
|
|
124
|
+
min?: number;
|
|
125
|
+
max?: number;
|
|
126
|
+
integer?: boolean;
|
|
127
|
+
positive?: boolean;
|
|
128
|
+
negative?: boolean;
|
|
129
|
+
minItems?: number;
|
|
130
|
+
maxItems?: number;
|
|
131
|
+
maxFileSize?: number;
|
|
132
|
+
allowedTypes?: string[];
|
|
133
|
+
custom?: string;
|
|
134
|
+
messages?: ValidationMessages;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Base metadata common to all field types
|
|
138
|
+
*/
|
|
139
|
+
interface BaseFieldMetadata {
|
|
140
|
+
name: string;
|
|
141
|
+
label: string;
|
|
142
|
+
placeholder?: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
defaultValue?: unknown;
|
|
145
|
+
validation?: ValidationConfig;
|
|
146
|
+
dataSource?: DataSource;
|
|
147
|
+
rules?: FieldRule[];
|
|
148
|
+
grid?: GridConfig;
|
|
149
|
+
ariaLabel?: string;
|
|
150
|
+
ariaDescribedBy?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface TextFieldMetadata extends BaseFieldMetadata {
|
|
153
|
+
type: 'text';
|
|
154
|
+
}
|
|
155
|
+
export interface EmailFieldMetadata extends BaseFieldMetadata {
|
|
156
|
+
type: 'email';
|
|
157
|
+
}
|
|
158
|
+
export interface TextareaFieldMetadata extends BaseFieldMetadata {
|
|
159
|
+
type: 'textarea';
|
|
160
|
+
rows?: number;
|
|
161
|
+
}
|
|
162
|
+
export interface NumberFieldMetadata extends BaseFieldMetadata {
|
|
163
|
+
type: 'number';
|
|
164
|
+
min?: number;
|
|
165
|
+
max?: number;
|
|
166
|
+
step?: number;
|
|
167
|
+
}
|
|
168
|
+
export interface SelectFieldMetadata extends BaseFieldMetadata {
|
|
169
|
+
type: 'select';
|
|
170
|
+
options?: FieldOption[];
|
|
171
|
+
}
|
|
172
|
+
export interface MultiSelectFieldMetadata extends BaseFieldMetadata {
|
|
173
|
+
type: 'multiselect';
|
|
174
|
+
options?: FieldOption[];
|
|
175
|
+
maxSelected?: number;
|
|
176
|
+
}
|
|
177
|
+
export interface RadioFieldMetadata extends BaseFieldMetadata {
|
|
178
|
+
type: 'radio';
|
|
179
|
+
options?: FieldOption[];
|
|
180
|
+
}
|
|
181
|
+
export interface CheckboxFieldMetadata extends BaseFieldMetadata {
|
|
182
|
+
type: 'checkbox';
|
|
183
|
+
}
|
|
184
|
+
export interface SwitchFieldMetadata extends BaseFieldMetadata {
|
|
185
|
+
type: 'switch';
|
|
186
|
+
}
|
|
187
|
+
export interface SliderFieldMetadata extends BaseFieldMetadata {
|
|
188
|
+
type: 'slider';
|
|
189
|
+
min?: number;
|
|
190
|
+
max?: number;
|
|
191
|
+
step?: number;
|
|
192
|
+
}
|
|
193
|
+
export interface DateFieldMetadata extends BaseFieldMetadata {
|
|
194
|
+
type: 'date';
|
|
195
|
+
}
|
|
196
|
+
export interface DateTimeFieldMetadata extends BaseFieldMetadata {
|
|
197
|
+
type: 'datetime';
|
|
198
|
+
use12Hour?: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface FileFieldMetadata extends BaseFieldMetadata {
|
|
201
|
+
type: 'file';
|
|
202
|
+
accept?: string;
|
|
203
|
+
multiple?: boolean;
|
|
204
|
+
maxSize?: number;
|
|
205
|
+
showPreview?: boolean;
|
|
206
|
+
}
|
|
207
|
+
export interface CustomFieldMetadata extends BaseFieldMetadata {
|
|
208
|
+
type: 'custom';
|
|
209
|
+
component: string;
|
|
210
|
+
componentProps?: Record<string, unknown>;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Discriminated union of all field types
|
|
214
|
+
* TypeScript will enforce that only valid properties exist for each type
|
|
215
|
+
*/
|
|
216
|
+
export type FieldMetadata = TextFieldMetadata | EmailFieldMetadata | TextareaFieldMetadata | NumberFieldMetadata | SelectFieldMetadata | MultiSelectFieldMetadata | RadioFieldMetadata | CheckboxFieldMetadata | SwitchFieldMetadata | SliderFieldMetadata | DateFieldMetadata | DateTimeFieldMetadata | FileFieldMetadata | CustomFieldMetadata;
|
|
217
|
+
/**
|
|
218
|
+
* Extract the field type from FieldMetadata
|
|
219
|
+
*/
|
|
220
|
+
export type FieldType = FieldMetadata['type'];
|
|
221
|
+
export declare function hasOptions(field: FieldMetadata): field is SelectFieldMetadata | MultiSelectFieldMetadata | RadioFieldMetadata;
|
|
222
|
+
export declare function hasMinMaxStep(field: FieldMetadata): field is NumberFieldMetadata | SliderFieldMetadata;
|
|
223
|
+
export declare function isFileField(field: FieldMetadata): field is FileFieldMetadata;
|
|
224
|
+
export declare function isCustomField(field: FieldMetadata): field is CustomFieldMetadata;
|
|
225
|
+
export interface FormSection {
|
|
226
|
+
id: string;
|
|
227
|
+
title?: string;
|
|
228
|
+
description?: string;
|
|
229
|
+
fields: FieldMetadata[];
|
|
230
|
+
collapsible?: boolean;
|
|
231
|
+
defaultExpanded?: boolean;
|
|
232
|
+
conditions?: FieldCondition[];
|
|
233
|
+
}
|
|
234
|
+
export interface FormStep {
|
|
235
|
+
id: string;
|
|
236
|
+
title: string;
|
|
237
|
+
description?: string;
|
|
238
|
+
sections: FormSection[];
|
|
239
|
+
validation?: 'onChange' | 'onBlur' | 'onSubmit';
|
|
240
|
+
canSkip?: boolean;
|
|
241
|
+
conditions?: FieldCondition[];
|
|
242
|
+
}
|
|
243
|
+
export interface FormAction {
|
|
244
|
+
id: string;
|
|
245
|
+
type: 'submit' | 'save-draft' | 'reset' | 'custom';
|
|
246
|
+
label: string;
|
|
247
|
+
variant?: 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost';
|
|
248
|
+
loading?: boolean;
|
|
249
|
+
disabled?: boolean;
|
|
250
|
+
conditions?: FieldCondition[];
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Base form schema with common properties
|
|
254
|
+
*/
|
|
255
|
+
interface BaseFormSchema {
|
|
256
|
+
id: string;
|
|
257
|
+
title: string;
|
|
258
|
+
description?: string;
|
|
259
|
+
version?: string;
|
|
260
|
+
initialData?: Record<string, unknown>;
|
|
261
|
+
mode?: 'onChange' | 'onBlur' | 'onSubmit' | 'all';
|
|
262
|
+
reValidateMode?: 'onChange' | 'onBlur' | 'onSubmit';
|
|
263
|
+
actions?: FormAction[];
|
|
264
|
+
layout?: {
|
|
265
|
+
columns?: number;
|
|
266
|
+
gap?: number;
|
|
267
|
+
variant?: 'default' | 'compact' | 'spacious';
|
|
268
|
+
};
|
|
269
|
+
metadata?: Record<string, unknown>;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Single-page form schema
|
|
273
|
+
*/
|
|
274
|
+
export interface SinglePageFormSchema extends BaseFormSchema {
|
|
275
|
+
sections: FormSection[];
|
|
276
|
+
steps?: never;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Multi-step form schema
|
|
280
|
+
*/
|
|
281
|
+
export interface MultiStepFormSchema extends BaseFormSchema {
|
|
282
|
+
steps: FormStep[];
|
|
283
|
+
sections?: never;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Form schema - either single-page or multi-step (discriminated union)
|
|
287
|
+
*/
|
|
288
|
+
export type FormSchema = SinglePageFormSchema | MultiStepFormSchema;
|
|
289
|
+
export interface CustomFieldComponentProps {
|
|
290
|
+
value: unknown;
|
|
291
|
+
onChange: (value: unknown) => void;
|
|
292
|
+
onBlur: () => void;
|
|
293
|
+
name: string;
|
|
294
|
+
field?: FieldMetadata;
|
|
295
|
+
disabled?: boolean;
|
|
296
|
+
required?: boolean;
|
|
297
|
+
error?: string;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
}
|
|
300
|
+
export interface FormContext<T extends FieldValues = FieldValues> {
|
|
301
|
+
schema: FormSchema;
|
|
302
|
+
form: UseFormReturn<T>;
|
|
303
|
+
values: T;
|
|
304
|
+
errors: Record<string, unknown>;
|
|
305
|
+
isSubmitting: boolean;
|
|
306
|
+
isDirty: boolean;
|
|
307
|
+
currentStep?: number;
|
|
308
|
+
evaluateConditions: (conditions: FieldCondition[]) => boolean;
|
|
309
|
+
fetchData: (source: DataSource) => Promise<FieldOption[]>;
|
|
310
|
+
registerCustomComponent: (name: string, component: React.ComponentType<CustomFieldComponentProps>) => void;
|
|
311
|
+
}
|
|
312
|
+
export interface FormPlugin<T extends FieldValues = FieldValues> {
|
|
313
|
+
name: string;
|
|
314
|
+
version?: string;
|
|
315
|
+
onFormInit?: (context: FormContext<T>) => void | Promise<void>;
|
|
316
|
+
onFieldRegister?: (field: FieldMetadata, context: FormContext<T>) => void;
|
|
317
|
+
onValueChange?: (fieldName: string, value: unknown, context: FormContext<T>) => void;
|
|
318
|
+
onSubmit?: (data: T, context: FormContext<T>) => T | Promise<T>;
|
|
319
|
+
validators?: Record<string, ValidationConfig>;
|
|
320
|
+
components?: Record<string, React.ComponentType<CustomFieldComponentProps>>;
|
|
321
|
+
customConditions?: Record<string, (value: unknown, condition: unknown) => boolean>;
|
|
322
|
+
customEffects?: Record<string, (field: FieldMetadata, context: FormContext<T>) => void>;
|
|
323
|
+
}
|
|
324
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function hasOptions(field) {
|
|
2
|
+
return 'select' === field.type || 'multiselect' === field.type || 'radio' === field.type;
|
|
3
|
+
}
|
|
4
|
+
function hasMinMaxStep(field) {
|
|
5
|
+
return 'number' === field.type || 'slider' === field.type;
|
|
6
|
+
}
|
|
7
|
+
function isFileField(field) {
|
|
8
|
+
return 'file' === field.type;
|
|
9
|
+
}
|
|
10
|
+
function isCustomField(field) {
|
|
11
|
+
return 'custom' === field.type;
|
|
12
|
+
}
|
|
13
|
+
export { hasMinMaxStep, hasOptions, isCustomField, isFileField };
|