@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,400 @@
|
|
|
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
|
+
MetadataForm: ()=>MetadataForm
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
32
|
+
const v4_namespaceObject = require("zod/v4");
|
|
33
|
+
const accordion_cjs_namespaceObject = require("../ui/accordion.cjs");
|
|
34
|
+
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
35
|
+
const standard_schema_namespaceObject = require("@hookform/resolvers/standard-schema");
|
|
36
|
+
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
37
|
+
const external_field_renderer_cjs_namespaceObject = require("./field-renderer.cjs");
|
|
38
|
+
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
39
|
+
const external_validation_converter_cjs_namespaceObject = require("./validation-converter.cjs");
|
|
40
|
+
const DEFAULT_PLUGINS = [];
|
|
41
|
+
function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete }) {
|
|
42
|
+
const [currentStep, setCurrentStep] = (0, external_react_namespaceObject.useState)(0);
|
|
43
|
+
const [customComponents, setCustomComponents] = (0, external_react_namespaceObject.useState)({});
|
|
44
|
+
const [isInitialized, setIsInitialized] = (0, external_react_namespaceObject.useState)(false);
|
|
45
|
+
const zodSchema = (0, external_react_namespaceObject.useMemo)(()=>buildZodSchema(schema), [
|
|
46
|
+
schema
|
|
47
|
+
]);
|
|
48
|
+
const form = (0, external_react_hook_form_namespaceObject.useForm)({
|
|
49
|
+
resolver: (0, standard_schema_namespaceObject.standardSchemaResolver)(zodSchema),
|
|
50
|
+
mode: schema.mode || 'onSubmit',
|
|
51
|
+
reValidateMode: schema.reValidateMode || 'onChange'
|
|
52
|
+
});
|
|
53
|
+
const { watch, handleSubmit, reset } = form;
|
|
54
|
+
const valuesRef = (0, external_react_namespaceObject.useRef)({});
|
|
55
|
+
const watchedValues = watch();
|
|
56
|
+
valuesRef.current = watchedValues;
|
|
57
|
+
const context = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
58
|
+
schema,
|
|
59
|
+
form,
|
|
60
|
+
get values () {
|
|
61
|
+
return valuesRef.current;
|
|
62
|
+
},
|
|
63
|
+
get errors () {
|
|
64
|
+
return form.formState.errors;
|
|
65
|
+
},
|
|
66
|
+
get isSubmitting () {
|
|
67
|
+
return form.formState.isSubmitting;
|
|
68
|
+
},
|
|
69
|
+
get isDirty () {
|
|
70
|
+
return form.formState.isDirty;
|
|
71
|
+
},
|
|
72
|
+
currentStep: schema.steps ? currentStep : void 0,
|
|
73
|
+
evaluateConditions: (conditions)=>external_rules_engine_cjs_namespaceObject.RulesEngine.evaluateConditions(conditions, valuesRef.current, 'AND'),
|
|
74
|
+
fetchData: async (source)=>{
|
|
75
|
+
const result = await external_data_fetcher_cjs_namespaceObject.DataFetcher.fetch(source, valuesRef.current);
|
|
76
|
+
return result;
|
|
77
|
+
},
|
|
78
|
+
registerCustomComponent: (name, component)=>{
|
|
79
|
+
setCustomComponents((prev)=>({
|
|
80
|
+
...prev,
|
|
81
|
+
[name]: component
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
}), [
|
|
85
|
+
schema,
|
|
86
|
+
form,
|
|
87
|
+
currentStep
|
|
88
|
+
]);
|
|
89
|
+
const contextRef = (0, external_react_namespaceObject.useRef)(context);
|
|
90
|
+
contextRef.current = context;
|
|
91
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
92
|
+
if (isInitialized) return;
|
|
93
|
+
const initializeForm = async ()=>{
|
|
94
|
+
if (schema.initialData) {
|
|
95
|
+
const data = await loadInitialData(schema.initialData, contextRef.current);
|
|
96
|
+
reset(data);
|
|
97
|
+
}
|
|
98
|
+
for (const plugin of plugins)await plugin.onFormInit?.(contextRef.current);
|
|
99
|
+
setIsInitialized(true);
|
|
100
|
+
};
|
|
101
|
+
initializeForm();
|
|
102
|
+
}, [
|
|
103
|
+
isInitialized
|
|
104
|
+
]);
|
|
105
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
106
|
+
if (!isInitialized) return;
|
|
107
|
+
const subscription = watch((value, { name })=>{
|
|
108
|
+
if (name) {
|
|
109
|
+
valuesRef.current = value;
|
|
110
|
+
plugins.forEach((plugin)=>{
|
|
111
|
+
plugin.onValueChange?.(name, value[name], contextRef.current);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return ()=>subscription.unsubscribe();
|
|
116
|
+
}, [
|
|
117
|
+
watch,
|
|
118
|
+
isInitialized,
|
|
119
|
+
plugins
|
|
120
|
+
]);
|
|
121
|
+
const handleFormSubmit = handleSubmit(async (data)=>{
|
|
122
|
+
let finalData = data;
|
|
123
|
+
for (const plugin of plugins)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, context) || finalData;
|
|
124
|
+
if (onSubmit) await onSubmit(finalData);
|
|
125
|
+
});
|
|
126
|
+
const renderContent = ()=>{
|
|
127
|
+
if (schema.steps) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MultiStepForm, {
|
|
128
|
+
schema: schema,
|
|
129
|
+
context: context,
|
|
130
|
+
currentStep: currentStep,
|
|
131
|
+
setCurrentStep: setCurrentStep,
|
|
132
|
+
customComponents: customComponents,
|
|
133
|
+
disabled: disabled
|
|
134
|
+
});
|
|
135
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SinglePageForm, {
|
|
136
|
+
schema: schema,
|
|
137
|
+
context: context,
|
|
138
|
+
customComponents: customComponents,
|
|
139
|
+
disabled: disabled
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.FormProvider, {
|
|
143
|
+
...form,
|
|
144
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("form", {
|
|
145
|
+
onSubmit: handleFormSubmit,
|
|
146
|
+
className: className,
|
|
147
|
+
autoComplete: autoComplete,
|
|
148
|
+
children: [
|
|
149
|
+
renderContent(),
|
|
150
|
+
!schema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormActions, {
|
|
151
|
+
schema: schema,
|
|
152
|
+
context: context,
|
|
153
|
+
onReset: ()=>reset()
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function SinglePageForm({ schema, context, customComponents, disabled }) {
|
|
160
|
+
const sections = schema.sections || [];
|
|
161
|
+
const visibleSections = sections.filter((section)=>!section.conditions || context.evaluateConditions(section.conditions));
|
|
162
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
163
|
+
className: "space-y-2",
|
|
164
|
+
children: visibleSections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormSection, {
|
|
165
|
+
section: section,
|
|
166
|
+
context: context,
|
|
167
|
+
customComponents: customComponents,
|
|
168
|
+
disabled: disabled
|
|
169
|
+
}, section.id))
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function MultiStepForm({ schema, context, currentStep, setCurrentStep, customComponents, disabled }) {
|
|
173
|
+
const steps = schema.steps || [];
|
|
174
|
+
const step = steps[currentStep];
|
|
175
|
+
if (!step) return null;
|
|
176
|
+
if (step.conditions && !context.evaluateConditions(step.conditions)) {
|
|
177
|
+
if (currentStep < steps.length - 1) setCurrentStep(currentStep + 1);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
181
|
+
className: "space-y-6",
|
|
182
|
+
children: [
|
|
183
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
184
|
+
className: "flex items-center justify-between",
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
187
|
+
children: [
|
|
188
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("h2", {
|
|
189
|
+
className: "text-2xl font-semibold",
|
|
190
|
+
children: step.title
|
|
191
|
+
}),
|
|
192
|
+
step.description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
193
|
+
className: "text-muted-foreground mt-1",
|
|
194
|
+
children: step.description
|
|
195
|
+
})
|
|
196
|
+
]
|
|
197
|
+
}),
|
|
198
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
199
|
+
className: "text-sm text-muted-foreground",
|
|
200
|
+
children: [
|
|
201
|
+
"Step ",
|
|
202
|
+
currentStep + 1,
|
|
203
|
+
" of ",
|
|
204
|
+
steps.length
|
|
205
|
+
]
|
|
206
|
+
})
|
|
207
|
+
]
|
|
208
|
+
}),
|
|
209
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
210
|
+
className: "space-y-2",
|
|
211
|
+
children: step.sections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormSection, {
|
|
212
|
+
section: section,
|
|
213
|
+
context: context,
|
|
214
|
+
customComponents: customComponents,
|
|
215
|
+
disabled: disabled
|
|
216
|
+
}, section.id))
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
219
|
+
className: "flex justify-between pt-6",
|
|
220
|
+
children: [
|
|
221
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
222
|
+
type: "button",
|
|
223
|
+
onClick: ()=>setCurrentStep(Math.max(0, currentStep - 1)),
|
|
224
|
+
disabled: 0 === currentStep,
|
|
225
|
+
variant: "secondary",
|
|
226
|
+
children: "Previous"
|
|
227
|
+
}),
|
|
228
|
+
currentStep < steps.length - 1 ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
229
|
+
type: "button",
|
|
230
|
+
onClick: ()=>setCurrentStep(currentStep + 1),
|
|
231
|
+
variant: "default",
|
|
232
|
+
children: "Next"
|
|
233
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
234
|
+
type: "submit",
|
|
235
|
+
variant: "default",
|
|
236
|
+
children: "Submit"
|
|
237
|
+
})
|
|
238
|
+
]
|
|
239
|
+
})
|
|
240
|
+
]
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
function FormSection({ section, context, customComponents, disabled }) {
|
|
244
|
+
const gridColumns = context.schema.layout?.columns || 1;
|
|
245
|
+
const gap = context.schema.layout?.gap || 4;
|
|
246
|
+
const fieldsGrid = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
247
|
+
className: "grid",
|
|
248
|
+
style: {
|
|
249
|
+
gridTemplateColumns: `repeat(${gridColumns}, minmax(0, 1fr))`,
|
|
250
|
+
gap: `${0.25 * gap}rem`
|
|
251
|
+
},
|
|
252
|
+
children: section.fields.map((field)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_field_renderer_cjs_namespaceObject.FormFieldRenderer, {
|
|
253
|
+
field: field,
|
|
254
|
+
context: context,
|
|
255
|
+
customComponents: customComponents,
|
|
256
|
+
disabled: disabled
|
|
257
|
+
}, field.name))
|
|
258
|
+
});
|
|
259
|
+
if (!section.title) return fieldsGrid;
|
|
260
|
+
const innerContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
261
|
+
className: "flex flex-col gap-4",
|
|
262
|
+
children: [
|
|
263
|
+
section.description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("p", {
|
|
264
|
+
className: "text-sm text-muted-foreground",
|
|
265
|
+
children: section.description
|
|
266
|
+
}),
|
|
267
|
+
fieldsGrid
|
|
268
|
+
]
|
|
269
|
+
});
|
|
270
|
+
if (section.collapsible) {
|
|
271
|
+
const defaultValue = false !== section.defaultExpanded ? [
|
|
272
|
+
section.id
|
|
273
|
+
] : [];
|
|
274
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.Accordion, {
|
|
275
|
+
type: "multiple",
|
|
276
|
+
defaultValue: defaultValue,
|
|
277
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(accordion_cjs_namespaceObject.AccordionItem, {
|
|
278
|
+
value: section.id,
|
|
279
|
+
className: "border rounded-lg px-3",
|
|
280
|
+
children: [
|
|
281
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionTrigger, {
|
|
282
|
+
className: "text-sm font-medium",
|
|
283
|
+
children: section.title
|
|
284
|
+
}),
|
|
285
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(accordion_cjs_namespaceObject.AccordionContent, {
|
|
286
|
+
children: innerContent
|
|
287
|
+
})
|
|
288
|
+
]
|
|
289
|
+
})
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
293
|
+
className: "border rounded-lg px-3",
|
|
294
|
+
children: [
|
|
295
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
296
|
+
className: "flex",
|
|
297
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
298
|
+
className: "flex flex-1 items-center justify-between py-4 text-sm font-medium",
|
|
299
|
+
children: section.title
|
|
300
|
+
})
|
|
301
|
+
}),
|
|
302
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
303
|
+
className: "text-sm",
|
|
304
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
305
|
+
className: "pb-4 pt-0",
|
|
306
|
+
children: innerContent
|
|
307
|
+
})
|
|
308
|
+
})
|
|
309
|
+
]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function FormActions({ schema, context, onReset }) {
|
|
313
|
+
const actions = schema.actions || [
|
|
314
|
+
{
|
|
315
|
+
id: 'submit',
|
|
316
|
+
type: 'submit',
|
|
317
|
+
label: 'Submit',
|
|
318
|
+
variant: 'default'
|
|
319
|
+
}
|
|
320
|
+
];
|
|
321
|
+
if (0 === actions.length) return null;
|
|
322
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
323
|
+
className: "flex gap-2 pt-6",
|
|
324
|
+
children: actions.map((action)=>{
|
|
325
|
+
if (action.conditions && !context.evaluateConditions(action.conditions)) return null;
|
|
326
|
+
if ('reset' === action.type) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
327
|
+
type: "button",
|
|
328
|
+
onClick: onReset,
|
|
329
|
+
variant: action.variant || 'secondary',
|
|
330
|
+
disabled: action.disabled,
|
|
331
|
+
children: action.label
|
|
332
|
+
}, action.id);
|
|
333
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
334
|
+
type: 'submit' === action.type ? 'submit' : 'button',
|
|
335
|
+
variant: action.variant || 'default',
|
|
336
|
+
disabled: action.disabled || 'submit' === action.type && context.isSubmitting,
|
|
337
|
+
children: action.loading && context.isSubmitting ? 'Loading...' : action.label
|
|
338
|
+
}, action.id);
|
|
339
|
+
})
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
function buildZodSchema(schema) {
|
|
343
|
+
const shape = {};
|
|
344
|
+
const fields = schema.steps ? schema.steps.flatMap((step)=>step.sections.flatMap((s)=>s.fields)) : schema.sections?.flatMap((s)=>s.fields) || [];
|
|
345
|
+
const dynamicValidationFields = [];
|
|
346
|
+
fields.forEach((field)=>{
|
|
347
|
+
const hasUnconditionalRequired = field.rules?.some((rule)=>true === rule.effects.required && 0 === rule.conditions.length);
|
|
348
|
+
const hasConditionalRequired = field.rules?.some((rule)=>true === rule.effects.required && rule.conditions.length > 0);
|
|
349
|
+
const hasVisibilityRules = field.rules?.some((rule)=>void 0 !== rule.effects.visible);
|
|
350
|
+
const hasStaticRequired = field.validation?.required === true;
|
|
351
|
+
const hasAnyRequired = hasStaticRequired || hasUnconditionalRequired || hasConditionalRequired;
|
|
352
|
+
if (field.rules && (hasConditionalRequired || hasAnyRequired && hasVisibilityRules)) dynamicValidationFields.push({
|
|
353
|
+
name: field.name,
|
|
354
|
+
rules: field.rules,
|
|
355
|
+
staticRequired: hasStaticRequired || hasUnconditionalRequired || false,
|
|
356
|
+
customRequiredMessage: field.validation?.messages?.required
|
|
357
|
+
});
|
|
358
|
+
const shouldIncludeRequiredInBase = (hasUnconditionalRequired || hasStaticRequired) && !hasVisibilityRules;
|
|
359
|
+
const validationConfig = field.validation ? {
|
|
360
|
+
...field.validation,
|
|
361
|
+
required: shouldIncludeRequiredInBase
|
|
362
|
+
} : shouldIncludeRequiredInBase ? {
|
|
363
|
+
required: true
|
|
364
|
+
} : void 0;
|
|
365
|
+
shape[field.name] = (0, external_validation_converter_cjs_namespaceObject.validationConfigToZod)(validationConfig, field.type);
|
|
366
|
+
});
|
|
367
|
+
const baseSchema = v4_namespaceObject.z.object(shape);
|
|
368
|
+
if (0 === dynamicValidationFields.length) return baseSchema;
|
|
369
|
+
return baseSchema.superRefine((data, ctx)=>{
|
|
370
|
+
const values = data;
|
|
371
|
+
for (const { name, rules, staticRequired, customRequiredMessage } of dynamicValidationFields){
|
|
372
|
+
const isVisible = external_rules_engine_cjs_namespaceObject.RulesEngine.isFieldVisible(rules, values);
|
|
373
|
+
if (!isVisible) continue;
|
|
374
|
+
const ruleResult = external_rules_engine_cjs_namespaceObject.RulesEngine.applyRules(rules, values, {});
|
|
375
|
+
const isRequired = true === ruleResult.required || staticRequired;
|
|
376
|
+
if (isRequired) {
|
|
377
|
+
const value = values[name];
|
|
378
|
+
const isEmpty = null == value || '' === value || Array.isArray(value) && 0 === value.length;
|
|
379
|
+
if (isEmpty) ctx.addIssue({
|
|
380
|
+
code: v4_namespaceObject.z.ZodIssueCode.custom,
|
|
381
|
+
message: customRequiredMessage || 'This field is required',
|
|
382
|
+
path: [
|
|
383
|
+
name
|
|
384
|
+
]
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
async function loadInitialData(initialData, _context) {
|
|
391
|
+
if (!initialData) return {};
|
|
392
|
+
return initialData;
|
|
393
|
+
}
|
|
394
|
+
exports.MetadataForm = __webpack_exports__.MetadataForm;
|
|
395
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
396
|
+
"MetadataForm"
|
|
397
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
398
|
+
Object.defineProperty(exports, '__esModule', {
|
|
399
|
+
value: true
|
|
400
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FormPlugin, FormSchema } from './form-schema';
|
|
2
|
+
/**
|
|
3
|
+
* Core MetadataForm Component
|
|
4
|
+
* Renders forms from JSON/object schema with full RHF integration
|
|
5
|
+
*/
|
|
6
|
+
interface MetadataFormProps {
|
|
7
|
+
schema: FormSchema;
|
|
8
|
+
plugins?: FormPlugin[];
|
|
9
|
+
onSubmit?: (data: unknown) => void | Promise<void>;
|
|
10
|
+
className?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** Disable browser autocomplete suggestions. Defaults to undefined (browser default). */
|
|
13
|
+
autoComplete?: 'off' | 'on';
|
|
14
|
+
}
|
|
15
|
+
export declare function MetadataForm({ schema, plugins, onSubmit, className, disabled, autoComplete, }: MetadataFormProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|