@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,213 @@
|
|
|
1
|
+
function serializeOptions(options) {
|
|
2
|
+
return options.map((opt)=>({
|
|
3
|
+
label: opt.label,
|
|
4
|
+
value: opt.value,
|
|
5
|
+
...void 0 !== opt.disabled && {
|
|
6
|
+
disabled: opt.disabled
|
|
7
|
+
}
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
function serializeValidationConfig(config) {
|
|
11
|
+
const result = {};
|
|
12
|
+
if (void 0 !== config.required) result.required = config.required;
|
|
13
|
+
if (void 0 !== config.minLength) result.minLength = config.minLength;
|
|
14
|
+
if (void 0 !== config.maxLength) result.maxLength = config.maxLength;
|
|
15
|
+
if (void 0 !== config.pattern) result.pattern = config.pattern;
|
|
16
|
+
if (void 0 !== config.email) result.email = config.email;
|
|
17
|
+
if (void 0 !== config.url) result.url = config.url;
|
|
18
|
+
if (void 0 !== config.min) result.min = config.min;
|
|
19
|
+
if (void 0 !== config.max) result.max = config.max;
|
|
20
|
+
if (void 0 !== config.integer) result.integer = config.integer;
|
|
21
|
+
if (void 0 !== config.positive) result.positive = config.positive;
|
|
22
|
+
if (void 0 !== config.negative) result.negative = config.negative;
|
|
23
|
+
if (void 0 !== config.minItems) result.minItems = config.minItems;
|
|
24
|
+
if (void 0 !== config.maxItems) result.maxItems = config.maxItems;
|
|
25
|
+
if (void 0 !== config.maxFileSize) result.maxFileSize = config.maxFileSize;
|
|
26
|
+
if (void 0 !== config.allowedTypes) result.allowedTypes = config.allowedTypes;
|
|
27
|
+
if (void 0 !== config.custom) result.custom = config.custom;
|
|
28
|
+
if (config.messages && Object.keys(config.messages).length > 0) {
|
|
29
|
+
const messages = {};
|
|
30
|
+
const m = config.messages;
|
|
31
|
+
if (m.required) messages.required = m.required;
|
|
32
|
+
if (m.minLength) messages.minLength = m.minLength;
|
|
33
|
+
if (m.maxLength) messages.maxLength = m.maxLength;
|
|
34
|
+
if (m.pattern) messages.pattern = m.pattern;
|
|
35
|
+
if (m.min) messages.min = m.min;
|
|
36
|
+
if (m.max) messages.max = m.max;
|
|
37
|
+
if (m.email) messages.email = m.email;
|
|
38
|
+
if (m.url) messages.url = m.url;
|
|
39
|
+
if (m.integer) messages.integer = m.integer;
|
|
40
|
+
if (m.positive) messages.positive = m.positive;
|
|
41
|
+
if (m.negative) messages.negative = m.negative;
|
|
42
|
+
if (m.minItems) messages.minItems = m.minItems;
|
|
43
|
+
if (m.maxItems) messages.maxItems = m.maxItems;
|
|
44
|
+
if (m.custom) messages.custom = m.custom;
|
|
45
|
+
if (Object.keys(messages).length > 0) result.messages = messages;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function serializeActions(actions) {
|
|
50
|
+
return actions.map((action)=>({
|
|
51
|
+
id: action.id,
|
|
52
|
+
type: action.type,
|
|
53
|
+
label: action.label,
|
|
54
|
+
...action.variant && {
|
|
55
|
+
variant: action.variant
|
|
56
|
+
},
|
|
57
|
+
...void 0 !== action.loading && {
|
|
58
|
+
loading: action.loading
|
|
59
|
+
},
|
|
60
|
+
...void 0 !== action.disabled && {
|
|
61
|
+
disabled: action.disabled
|
|
62
|
+
},
|
|
63
|
+
...action.conditions && {
|
|
64
|
+
conditions: action.conditions.map(serializeCondition)
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function serializeCondition(condition) {
|
|
69
|
+
const result = {
|
|
70
|
+
when: condition.when
|
|
71
|
+
};
|
|
72
|
+
if (void 0 !== condition.is) result.is = condition.is;
|
|
73
|
+
if (void 0 !== condition.isNot) result.isNot = condition.isNot;
|
|
74
|
+
if (void 0 !== condition.in) result.in = condition.in;
|
|
75
|
+
if (void 0 !== condition.notIn) result.notIn = condition.notIn;
|
|
76
|
+
if (void 0 !== condition.matches) result.matches = condition.matches;
|
|
77
|
+
if (void 0 !== condition.custom) result.custom = condition.custom;
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
function serializeRule(rule) {
|
|
81
|
+
const result = {
|
|
82
|
+
id: rule.id,
|
|
83
|
+
conditions: rule.conditions.map(serializeCondition)
|
|
84
|
+
};
|
|
85
|
+
if (rule.operator && 'AND' !== rule.operator) result.operator = rule.operator;
|
|
86
|
+
const effects = {};
|
|
87
|
+
if (void 0 !== rule.effects.visible) effects.visible = rule.effects.visible;
|
|
88
|
+
if (void 0 !== rule.effects.disabled) effects.disabled = rule.effects.disabled;
|
|
89
|
+
if (void 0 !== rule.effects.required) effects.required = rule.effects.required;
|
|
90
|
+
if (void 0 !== rule.effects.value) effects.value = rule.effects.value;
|
|
91
|
+
if (rule.effects.validate) effects.validate = serializeValidationConfig(rule.effects.validate);
|
|
92
|
+
if (rule.effects.options) effects.options = serializeDataSource(rule.effects.options);
|
|
93
|
+
result.effects = effects;
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
function serializeDataSource(dataSource) {
|
|
97
|
+
switch(dataSource.type){
|
|
98
|
+
case 'static':
|
|
99
|
+
return {
|
|
100
|
+
type: 'static',
|
|
101
|
+
options: serializeOptions(dataSource.options)
|
|
102
|
+
};
|
|
103
|
+
case 'fetch':
|
|
104
|
+
return {
|
|
105
|
+
type: 'fetch',
|
|
106
|
+
url: dataSource.url,
|
|
107
|
+
...dataSource.method && {
|
|
108
|
+
method: dataSource.method
|
|
109
|
+
},
|
|
110
|
+
...dataSource.transform && {
|
|
111
|
+
transform: dataSource.transform
|
|
112
|
+
},
|
|
113
|
+
...dataSource.params && {
|
|
114
|
+
params: dataSource.params
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
case 'remote':
|
|
118
|
+
return {
|
|
119
|
+
type: 'remote',
|
|
120
|
+
endpoint: dataSource.endpoint,
|
|
121
|
+
...dataSource.method && {
|
|
122
|
+
method: dataSource.method
|
|
123
|
+
},
|
|
124
|
+
...dataSource.params && {
|
|
125
|
+
params: dataSource.params
|
|
126
|
+
},
|
|
127
|
+
...dataSource.transform && {
|
|
128
|
+
transform: dataSource.transform
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
case 'computed':
|
|
132
|
+
return {
|
|
133
|
+
type: 'computed',
|
|
134
|
+
dependency: dataSource.dependency,
|
|
135
|
+
compute: dataSource.compute
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function serializeField(field) {
|
|
140
|
+
const result = {
|
|
141
|
+
name: field.name,
|
|
142
|
+
type: field.type,
|
|
143
|
+
label: field.label
|
|
144
|
+
};
|
|
145
|
+
if (field.placeholder) result.placeholder = field.placeholder;
|
|
146
|
+
if (field.description) result.description = field.description;
|
|
147
|
+
if (void 0 !== field.defaultValue) result.defaultValue = field.defaultValue;
|
|
148
|
+
if (field.validation) result.validation = serializeValidationConfig(field.validation);
|
|
149
|
+
if (field.dataSource) result.dataSource = serializeDataSource(field.dataSource);
|
|
150
|
+
if (field.rules && field.rules.length > 0) result.rules = field.rules.map(serializeRule);
|
|
151
|
+
if (field.grid) result.grid = field.grid;
|
|
152
|
+
if (field.ariaLabel) result.ariaLabel = field.ariaLabel;
|
|
153
|
+
if (field.ariaDescribedBy) result.ariaDescribedBy = field.ariaDescribedBy;
|
|
154
|
+
if ('options' in field && field.options) result.options = serializeOptions(field.options);
|
|
155
|
+
if ('rows' in field && field.rows) result.rows = field.rows;
|
|
156
|
+
if ('min' in field && void 0 !== field.min) result.min = field.min;
|
|
157
|
+
if ('max' in field && void 0 !== field.max) result.max = field.max;
|
|
158
|
+
if ('step' in field && void 0 !== field.step) result.step = field.step;
|
|
159
|
+
if ('maxSelected' in field && field.maxSelected) result.maxSelected = field.maxSelected;
|
|
160
|
+
if ('accept' in field && field.accept) result.accept = field.accept;
|
|
161
|
+
if ('multiple' in field && field.multiple) result.multiple = field.multiple;
|
|
162
|
+
if ('maxSize' in field && field.maxSize) result.maxSize = field.maxSize;
|
|
163
|
+
if ('showPreview' in field && field.showPreview) result.showPreview = field.showPreview;
|
|
164
|
+
if ('use12Hour' in field && field.use12Hour) result.use12Hour = field.use12Hour;
|
|
165
|
+
if ('component' in field && field.component) result.component = field.component;
|
|
166
|
+
if ('componentProps' in field && field.componentProps) result.componentProps = field.componentProps;
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
function serializeSection(section) {
|
|
170
|
+
const result = {
|
|
171
|
+
id: section.id,
|
|
172
|
+
fields: section.fields.map(serializeField)
|
|
173
|
+
};
|
|
174
|
+
if (section.title) result.title = section.title;
|
|
175
|
+
if (section.description) result.description = section.description;
|
|
176
|
+
if (void 0 !== section.collapsible) result.collapsible = section.collapsible;
|
|
177
|
+
if (void 0 !== section.defaultExpanded) result.defaultExpanded = section.defaultExpanded;
|
|
178
|
+
if (section.conditions && section.conditions.length > 0) result.conditions = section.conditions.map(serializeCondition);
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
function serializeStep(step) {
|
|
182
|
+
const result = {
|
|
183
|
+
id: step.id,
|
|
184
|
+
title: step.title,
|
|
185
|
+
sections: step.sections.map(serializeSection)
|
|
186
|
+
};
|
|
187
|
+
if (step.description) result.description = step.description;
|
|
188
|
+
if (step.validation) result.validation = step.validation;
|
|
189
|
+
if (void 0 !== step.canSkip) result.canSkip = step.canSkip;
|
|
190
|
+
if (step.conditions && step.conditions.length > 0) result.conditions = step.conditions.map(serializeCondition);
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
function serializeSchema(schema) {
|
|
194
|
+
const result = {
|
|
195
|
+
id: schema.id,
|
|
196
|
+
title: schema.title
|
|
197
|
+
};
|
|
198
|
+
if (schema.description) result.description = schema.description;
|
|
199
|
+
if (schema.version) result.version = schema.version;
|
|
200
|
+
if (schema.initialData) result.initialData = schema.initialData;
|
|
201
|
+
if (schema.mode) result.mode = schema.mode;
|
|
202
|
+
if (schema.reValidateMode) result.reValidateMode = schema.reValidateMode;
|
|
203
|
+
if (schema.actions && schema.actions.length > 0) result.actions = serializeActions(schema.actions);
|
|
204
|
+
if (schema.layout) result.layout = schema.layout;
|
|
205
|
+
if (schema.metadata) result.metadata = schema.metadata;
|
|
206
|
+
if ('sections' in schema && schema.sections) result.sections = schema.sections.map(serializeSection);
|
|
207
|
+
if ('steps' in schema && schema.steps) result.steps = schema.steps.map(serializeStep);
|
|
208
|
+
return result;
|
|
209
|
+
}
|
|
210
|
+
function schemaToJson(schema, indent = 2) {
|
|
211
|
+
return JSON.stringify(serializeSchema(schema), null, indent);
|
|
212
|
+
}
|
|
213
|
+
export { schemaToJson, serializeSchema };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
withSchemaViewer: ()=>withSchemaViewer,
|
|
28
|
+
FormWithSchemaViewer: ()=>FormWithSchemaViewer,
|
|
29
|
+
SchemaViewer: ()=>SchemaViewer
|
|
30
|
+
});
|
|
31
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
34
|
+
const external_sonner_namespaceObject = require("sonner");
|
|
35
|
+
const external_schema_serializer_cjs_namespaceObject = require("./schema-serializer.cjs");
|
|
36
|
+
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
37
|
+
const sheet_cjs_namespaceObject = require("../ui/sheet.cjs");
|
|
38
|
+
const scroll_area_cjs_namespaceObject = require("../ui/scroll-area.cjs");
|
|
39
|
+
function SchemaViewer({ schema, triggerLabel = 'View Schema' }) {
|
|
40
|
+
const [copied, setCopied] = (0, external_react_namespaceObject.useState)(false);
|
|
41
|
+
const jsonString = (0, external_schema_serializer_cjs_namespaceObject.schemaToJson)(schema);
|
|
42
|
+
const handleCopy = async ()=>{
|
|
43
|
+
try {
|
|
44
|
+
await navigator.clipboard.writeText(jsonString);
|
|
45
|
+
setCopied(true);
|
|
46
|
+
external_sonner_namespaceObject.toast.success('Schema copied to clipboard');
|
|
47
|
+
setTimeout(()=>setCopied(false), 2000);
|
|
48
|
+
} catch {
|
|
49
|
+
external_sonner_namespaceObject.toast.error('Failed to copy schema');
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(sheet_cjs_namespaceObject.Sheet, {
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sheet_cjs_namespaceObject.SheetTrigger, {
|
|
55
|
+
asChild: true,
|
|
56
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
|
|
57
|
+
variant: "outline",
|
|
58
|
+
size: "sm",
|
|
59
|
+
className: "gap-2",
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Code2, {
|
|
62
|
+
className: "h-4 w-4"
|
|
63
|
+
}),
|
|
64
|
+
triggerLabel
|
|
65
|
+
]
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(sheet_cjs_namespaceObject.SheetContent, {
|
|
69
|
+
side: "right",
|
|
70
|
+
className: "w-full sm:max-w-2xl",
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(sheet_cjs_namespaceObject.SheetHeader, {
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(sheet_cjs_namespaceObject.SheetTitle, {
|
|
75
|
+
className: "flex items-center gap-2",
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
78
|
+
children: "Schema JSON"
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(button_cjs_namespaceObject.Button, {
|
|
81
|
+
variant: "outline",
|
|
82
|
+
size: "sm",
|
|
83
|
+
onClick: handleCopy,
|
|
84
|
+
className: "gap-2",
|
|
85
|
+
children: [
|
|
86
|
+
copied ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Check, {
|
|
87
|
+
className: "h-4 w-4"
|
|
88
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Copy, {
|
|
89
|
+
className: "h-4 w-4"
|
|
90
|
+
}),
|
|
91
|
+
copied ? 'Copied!' : 'Copy'
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(sheet_cjs_namespaceObject.SheetDescription, {
|
|
97
|
+
children: "JSON representation of the form schema."
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(scroll_area_cjs_namespaceObject.ScrollArea, {
|
|
102
|
+
className: "mt-4 h-[calc(100vh-10rem)] rounded-md border bg-muted/50",
|
|
103
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("pre", {
|
|
104
|
+
className: "p-2 text-sm font-mono whitespace-pre-wrap break-words",
|
|
105
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("code", {
|
|
106
|
+
children: jsonString
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function withSchemaViewer(WrappedComponent) {
|
|
116
|
+
return function(props) {
|
|
117
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
118
|
+
className: "space-y-4",
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
121
|
+
className: "flex justify-end",
|
|
122
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaViewer, {
|
|
123
|
+
schema: props.schema
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(WrappedComponent, {
|
|
127
|
+
...props
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function FormWithSchemaViewer({ schema, children }) {
|
|
134
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
135
|
+
className: "space-y-4",
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
138
|
+
className: "flex justify-end",
|
|
139
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaViewer, {
|
|
140
|
+
schema: schema
|
|
141
|
+
})
|
|
142
|
+
}),
|
|
143
|
+
children
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
exports.FormWithSchemaViewer = __webpack_exports__.FormWithSchemaViewer;
|
|
148
|
+
exports.SchemaViewer = __webpack_exports__.SchemaViewer;
|
|
149
|
+
exports.withSchemaViewer = __webpack_exports__.withSchemaViewer;
|
|
150
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
151
|
+
"FormWithSchemaViewer",
|
|
152
|
+
"SchemaViewer",
|
|
153
|
+
"withSchemaViewer"
|
|
154
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
155
|
+
Object.defineProperty(exports, '__esModule', {
|
|
156
|
+
value: true
|
|
157
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { FormSchema } from './form-schema';
|
|
2
|
+
interface SchemaViewerProps {
|
|
3
|
+
schema: FormSchema;
|
|
4
|
+
triggerLabel?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* SchemaViewer - Displays form schema JSON with copy functionality
|
|
8
|
+
*
|
|
9
|
+
* Shows the backing JSON schema in a slide-out sheet panel.
|
|
10
|
+
* Includes syntax highlighting and one-click copy to clipboard.
|
|
11
|
+
*/
|
|
12
|
+
export declare function SchemaViewer({ schema, triggerLabel }: SchemaViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* withSchemaViewer - HOC to wrap a form component with schema viewer
|
|
15
|
+
*
|
|
16
|
+
* Adds a "View Schema" button above the form.
|
|
17
|
+
*/
|
|
18
|
+
export declare function withSchemaViewer<P extends {
|
|
19
|
+
schema: FormSchema;
|
|
20
|
+
}>(WrappedComponent: React.ComponentType<P>): (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* FormWithSchemaViewer - Render children with a schema viewer button
|
|
23
|
+
*/
|
|
24
|
+
interface FormWithSchemaViewerProps {
|
|
25
|
+
schema: FormSchema;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
export declare function FormWithSchemaViewer({ schema, children }: FormWithSchemaViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Check, Code2, Copy } from "lucide-react";
|
|
4
|
+
import { toast } from "sonner";
|
|
5
|
+
import { schemaToJson } from "./schema-serializer.js";
|
|
6
|
+
import { Button } from "../ui/button.js";
|
|
7
|
+
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "../ui/sheet.js";
|
|
8
|
+
import { ScrollArea } from "../ui/scroll-area.js";
|
|
9
|
+
function SchemaViewer({ schema, triggerLabel = 'View Schema' }) {
|
|
10
|
+
const [copied, setCopied] = useState(false);
|
|
11
|
+
const jsonString = schemaToJson(schema);
|
|
12
|
+
const handleCopy = async ()=>{
|
|
13
|
+
try {
|
|
14
|
+
await navigator.clipboard.writeText(jsonString);
|
|
15
|
+
setCopied(true);
|
|
16
|
+
toast.success('Schema copied to clipboard');
|
|
17
|
+
setTimeout(()=>setCopied(false), 2000);
|
|
18
|
+
} catch {
|
|
19
|
+
toast.error('Failed to copy schema');
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return /*#__PURE__*/ jsxs(Sheet, {
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ jsx(SheetTrigger, {
|
|
25
|
+
asChild: true,
|
|
26
|
+
children: /*#__PURE__*/ jsxs(Button, {
|
|
27
|
+
variant: "outline",
|
|
28
|
+
size: "sm",
|
|
29
|
+
className: "gap-2",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ jsx(Code2, {
|
|
32
|
+
className: "h-4 w-4"
|
|
33
|
+
}),
|
|
34
|
+
triggerLabel
|
|
35
|
+
]
|
|
36
|
+
})
|
|
37
|
+
}),
|
|
38
|
+
/*#__PURE__*/ jsxs(SheetContent, {
|
|
39
|
+
side: "right",
|
|
40
|
+
className: "w-full sm:max-w-2xl",
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ jsxs(SheetHeader, {
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ jsxs(SheetTitle, {
|
|
45
|
+
className: "flex items-center gap-2",
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ jsx("span", {
|
|
48
|
+
children: "Schema JSON"
|
|
49
|
+
}),
|
|
50
|
+
/*#__PURE__*/ jsxs(Button, {
|
|
51
|
+
variant: "outline",
|
|
52
|
+
size: "sm",
|
|
53
|
+
onClick: handleCopy,
|
|
54
|
+
className: "gap-2",
|
|
55
|
+
children: [
|
|
56
|
+
copied ? /*#__PURE__*/ jsx(Check, {
|
|
57
|
+
className: "h-4 w-4"
|
|
58
|
+
}) : /*#__PURE__*/ jsx(Copy, {
|
|
59
|
+
className: "h-4 w-4"
|
|
60
|
+
}),
|
|
61
|
+
copied ? 'Copied!' : 'Copy'
|
|
62
|
+
]
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsx(SheetDescription, {
|
|
67
|
+
children: "JSON representation of the form schema."
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ jsx(ScrollArea, {
|
|
72
|
+
className: "mt-4 h-[calc(100vh-10rem)] rounded-md border bg-muted/50",
|
|
73
|
+
children: /*#__PURE__*/ jsx("pre", {
|
|
74
|
+
className: "p-2 text-sm font-mono whitespace-pre-wrap break-words",
|
|
75
|
+
children: /*#__PURE__*/ jsx("code", {
|
|
76
|
+
children: jsonString
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
})
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function withSchemaViewer(WrappedComponent) {
|
|
86
|
+
return function(props) {
|
|
87
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
88
|
+
className: "space-y-4",
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsx("div", {
|
|
91
|
+
className: "flex justify-end",
|
|
92
|
+
children: /*#__PURE__*/ jsx(SchemaViewer, {
|
|
93
|
+
schema: props.schema
|
|
94
|
+
})
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ jsx(WrappedComponent, {
|
|
97
|
+
...props
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function FormWithSchemaViewer({ schema, children }) {
|
|
104
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
105
|
+
className: "space-y-4",
|
|
106
|
+
children: [
|
|
107
|
+
/*#__PURE__*/ jsx("div", {
|
|
108
|
+
className: "flex justify-end",
|
|
109
|
+
children: /*#__PURE__*/ jsx(SchemaViewer, {
|
|
110
|
+
schema: schema
|
|
111
|
+
})
|
|
112
|
+
}),
|
|
113
|
+
children
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
export { FormWithSchemaViewer, SchemaViewer, withSchemaViewer };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
buildZodSchemaFromFields: ()=>buildZodSchemaFromFields,
|
|
28
|
+
validationConfigToZod: ()=>validationConfigToZod,
|
|
29
|
+
mergeValidationConfigs: ()=>mergeValidationConfigs
|
|
30
|
+
});
|
|
31
|
+
const external_zod_namespaceObject = require("zod");
|
|
32
|
+
function validationConfigToZod(config, fieldType) {
|
|
33
|
+
let schema = getBaseSchemaForType(fieldType);
|
|
34
|
+
if (!config) return schema.optional();
|
|
35
|
+
schema = applyStringConstraints(schema, config, fieldType);
|
|
36
|
+
schema = applyNumberConstraints(schema, config, fieldType);
|
|
37
|
+
schema = applyArrayConstraints(schema, config, fieldType);
|
|
38
|
+
if (config.required) {
|
|
39
|
+
if (isStringType(fieldType) && !config.minLength) schema = schema.min(1, config.messages?.required || 'This field is required');
|
|
40
|
+
return schema;
|
|
41
|
+
}
|
|
42
|
+
return schema.optional();
|
|
43
|
+
}
|
|
44
|
+
function getBaseSchemaForType(fieldType) {
|
|
45
|
+
switch(fieldType){
|
|
46
|
+
case 'text':
|
|
47
|
+
case 'textarea':
|
|
48
|
+
return external_zod_namespaceObject.z.string();
|
|
49
|
+
case 'email':
|
|
50
|
+
return external_zod_namespaceObject.z.string().email();
|
|
51
|
+
case 'number':
|
|
52
|
+
case 'slider':
|
|
53
|
+
return external_zod_namespaceObject.z.coerce.number();
|
|
54
|
+
case 'checkbox':
|
|
55
|
+
case 'switch':
|
|
56
|
+
return external_zod_namespaceObject.z.boolean();
|
|
57
|
+
case 'select':
|
|
58
|
+
case 'radio':
|
|
59
|
+
return external_zod_namespaceObject.z.string();
|
|
60
|
+
case 'multiselect':
|
|
61
|
+
return external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string());
|
|
62
|
+
case 'date':
|
|
63
|
+
return external_zod_namespaceObject.z.coerce.date();
|
|
64
|
+
case 'datetime':
|
|
65
|
+
return external_zod_namespaceObject.z.coerce.date();
|
|
66
|
+
case 'file':
|
|
67
|
+
return external_zod_namespaceObject.z.any();
|
|
68
|
+
case 'custom':
|
|
69
|
+
return external_zod_namespaceObject.z.any();
|
|
70
|
+
default:
|
|
71
|
+
return external_zod_namespaceObject.z.string();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function isStringType(fieldType) {
|
|
75
|
+
return [
|
|
76
|
+
'text',
|
|
77
|
+
'textarea',
|
|
78
|
+
'email',
|
|
79
|
+
'select',
|
|
80
|
+
'radio'
|
|
81
|
+
].includes(fieldType);
|
|
82
|
+
}
|
|
83
|
+
function isNumberType(fieldType) {
|
|
84
|
+
return [
|
|
85
|
+
'number',
|
|
86
|
+
'slider'
|
|
87
|
+
].includes(fieldType);
|
|
88
|
+
}
|
|
89
|
+
function isArrayType(fieldType) {
|
|
90
|
+
return [
|
|
91
|
+
'multiselect'
|
|
92
|
+
].includes(fieldType);
|
|
93
|
+
}
|
|
94
|
+
function applyStringConstraints(schema, config, fieldType) {
|
|
95
|
+
if (!isStringType(fieldType)) return schema;
|
|
96
|
+
let stringSchema = schema;
|
|
97
|
+
if (null != config.minLength) stringSchema = stringSchema.min(config.minLength, config.messages?.minLength || `Must be at least ${config.minLength} characters`);
|
|
98
|
+
if (null != config.maxLength) stringSchema = stringSchema.max(config.maxLength, config.messages?.maxLength || `Must be at most ${config.maxLength} characters`);
|
|
99
|
+
if (config.pattern) try {
|
|
100
|
+
const regex = new RegExp(config.pattern);
|
|
101
|
+
stringSchema = stringSchema.regex(regex, config.messages?.pattern || 'Invalid format');
|
|
102
|
+
} catch {
|
|
103
|
+
console.warn(`Invalid regex pattern: ${config.pattern}`);
|
|
104
|
+
}
|
|
105
|
+
if (config.email && 'email' !== fieldType) stringSchema = stringSchema.email(config.messages?.email || 'Invalid email address');
|
|
106
|
+
if (config.url) stringSchema = stringSchema.url(config.messages?.url || 'Invalid URL');
|
|
107
|
+
return stringSchema;
|
|
108
|
+
}
|
|
109
|
+
function applyNumberConstraints(schema, config, fieldType) {
|
|
110
|
+
if (!isNumberType(fieldType)) return schema;
|
|
111
|
+
let numberSchema = schema;
|
|
112
|
+
if (config.integer) numberSchema = numberSchema.int(config.messages?.integer || 'Must be a whole number');
|
|
113
|
+
if (null != config.min) numberSchema = numberSchema.min(config.min, config.messages?.min || `Must be at least ${config.min}`);
|
|
114
|
+
if (null != config.max) numberSchema = numberSchema.max(config.max, config.messages?.max || `Must be at most ${config.max}`);
|
|
115
|
+
if (config.positive) numberSchema = numberSchema.positive(config.messages?.positive || 'Must be a positive number');
|
|
116
|
+
if (config.negative) numberSchema = numberSchema.negative(config.messages?.negative || 'Must be a negative number');
|
|
117
|
+
return numberSchema;
|
|
118
|
+
}
|
|
119
|
+
function applyArrayConstraints(schema, config, fieldType) {
|
|
120
|
+
if (!isArrayType(fieldType)) return schema;
|
|
121
|
+
let arraySchema = schema;
|
|
122
|
+
if (null != config.minItems) arraySchema = arraySchema.min(config.minItems, config.messages?.minItems || `Select at least ${config.minItems} item(s)`);
|
|
123
|
+
if (null != config.maxItems) arraySchema = arraySchema.max(config.maxItems, config.messages?.maxItems || `Select at most ${config.maxItems} item(s)`);
|
|
124
|
+
return arraySchema;
|
|
125
|
+
}
|
|
126
|
+
function buildZodSchemaFromFields(fields) {
|
|
127
|
+
const shape = {};
|
|
128
|
+
for (const field of fields)shape[field.name] = validationConfigToZod(field.validation, field.type);
|
|
129
|
+
return external_zod_namespaceObject.z.object(shape);
|
|
130
|
+
}
|
|
131
|
+
function mergeValidationConfigs(base, override) {
|
|
132
|
+
if (!base && !override) return;
|
|
133
|
+
if (!base) return override;
|
|
134
|
+
if (!override) return base;
|
|
135
|
+
return {
|
|
136
|
+
...base,
|
|
137
|
+
...override,
|
|
138
|
+
messages: {
|
|
139
|
+
...base.messages,
|
|
140
|
+
...override.messages
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
exports.buildZodSchemaFromFields = __webpack_exports__.buildZodSchemaFromFields;
|
|
145
|
+
exports.mergeValidationConfigs = __webpack_exports__.mergeValidationConfigs;
|
|
146
|
+
exports.validationConfigToZod = __webpack_exports__.validationConfigToZod;
|
|
147
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
148
|
+
"buildZodSchemaFromFields",
|
|
149
|
+
"mergeValidationConfigs",
|
|
150
|
+
"validationConfigToZod"
|
|
151
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
152
|
+
Object.defineProperty(exports, '__esModule', {
|
|
153
|
+
value: true
|
|
154
|
+
});
|