@uipath/apollo-wind 2.47.0 → 2.47.2
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/dist/components/forms/field-renderer.cjs +9 -5
- package/dist/components/forms/field-renderer.js +9 -5
- package/dist/components/forms/form-state-viewer.cjs +8 -4
- package/dist/components/forms/form-state-viewer.d.ts +1 -1
- package/dist/components/forms/form-state-viewer.js +8 -4
- package/dist/components/forms/metadata-form.cjs +129 -60
- package/dist/components/forms/metadata-form.js +121 -62
- package/dist/components/ui/index.cjs +10 -10
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +1 -0
- package/dist/components/ui/prompt-editor/prompt-editor.js +1 -0
- package/package.json +1 -1
|
@@ -132,19 +132,23 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
132
132
|
getValues,
|
|
133
133
|
watchedRuleDependentValues
|
|
134
134
|
]);
|
|
135
|
+
const isOptionsField = (0, external_form_schema_cjs_namespaceObject.hasOptions)(field);
|
|
136
|
+
const inlineOptions = isOptionsField ? field.options : void 0;
|
|
135
137
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
136
138
|
if (field.dataSource) return;
|
|
137
|
-
if (!
|
|
138
|
-
const
|
|
139
|
+
if (!isOptionsField) return;
|
|
140
|
+
const nextOptions = inlineOptions || [];
|
|
139
141
|
setFieldState((prev)=>{
|
|
140
|
-
if ((0, index_cjs_namespaceObject.deepEqual)(prev.options,
|
|
142
|
+
if ((0, index_cjs_namespaceObject.deepEqual)(prev.options, nextOptions)) return prev;
|
|
141
143
|
return {
|
|
142
144
|
...prev,
|
|
143
|
-
options:
|
|
145
|
+
options: nextOptions
|
|
144
146
|
};
|
|
145
147
|
});
|
|
146
148
|
}, [
|
|
147
|
-
field
|
|
149
|
+
field.dataSource,
|
|
150
|
+
isOptionsField,
|
|
151
|
+
inlineOptions
|
|
148
152
|
]);
|
|
149
153
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
150
154
|
if (!field.dataSource) return;
|
|
@@ -104,19 +104,23 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
104
104
|
getValues,
|
|
105
105
|
watchedRuleDependentValues
|
|
106
106
|
]);
|
|
107
|
+
const isOptionsField = hasOptions(field);
|
|
108
|
+
const inlineOptions = isOptionsField ? field.options : void 0;
|
|
107
109
|
useEffect(()=>{
|
|
108
110
|
if (field.dataSource) return;
|
|
109
|
-
if (!
|
|
110
|
-
const
|
|
111
|
+
if (!isOptionsField) return;
|
|
112
|
+
const nextOptions = inlineOptions || [];
|
|
111
113
|
setFieldState((prev)=>{
|
|
112
|
-
if (deepEqual(prev.options,
|
|
114
|
+
if (deepEqual(prev.options, nextOptions)) return prev;
|
|
113
115
|
return {
|
|
114
116
|
...prev,
|
|
115
|
-
options:
|
|
117
|
+
options: nextOptions
|
|
116
118
|
};
|
|
117
119
|
});
|
|
118
120
|
}, [
|
|
119
|
-
field
|
|
121
|
+
field.dataSource,
|
|
122
|
+
isOptionsField,
|
|
123
|
+
inlineOptions
|
|
120
124
|
]);
|
|
121
125
|
useEffect(()=>{
|
|
122
126
|
if (!field.dataSource) return;
|
|
@@ -27,16 +27,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
FormStateViewer: ()=>FormStateViewer
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_lucide_react_namespaceObject = require("lucide-react");
|
|
30
31
|
const external_react_namespaceObject = require("react");
|
|
32
|
+
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
31
33
|
const badge_cjs_namespaceObject = require("../ui/badge.cjs");
|
|
32
34
|
const card_cjs_namespaceObject = require("../ui/card.cjs");
|
|
33
|
-
const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
|
|
34
35
|
const scroll_area_cjs_namespaceObject = require("../ui/scroll-area.cjs");
|
|
35
|
-
const
|
|
36
|
+
const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
|
|
36
37
|
function FormStateViewer({ form, title = 'Form State', className = '', compact = false }) {
|
|
37
38
|
const [activeTab, setActiveTab] = (0, external_react_namespaceObject.useState)('values');
|
|
38
|
-
const { formState,
|
|
39
|
-
|
|
39
|
+
const { formState, control, getValues } = form;
|
|
40
|
+
(0, external_react_hook_form_namespaceObject.useWatch)({
|
|
41
|
+
control
|
|
42
|
+
});
|
|
43
|
+
const values = getValues();
|
|
40
44
|
const stats = {
|
|
41
45
|
isValid: formState.isValid,
|
|
42
46
|
isDirty: formState.isDirty,
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircle, CheckCircle2, Database, Eye, FileEdit, XCircle } from "lucide-react";
|
|
2
3
|
import { useState } from "react";
|
|
4
|
+
import { useWatch } from "react-hook-form";
|
|
3
5
|
import { Badge } from "../ui/badge.js";
|
|
4
6
|
import { Card } from "../ui/card.js";
|
|
5
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs.js";
|
|
6
7
|
import { ScrollArea } from "../ui/scroll-area.js";
|
|
7
|
-
import {
|
|
8
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs.js";
|
|
8
9
|
function FormStateViewer({ form, title = 'Form State', className = '', compact = false }) {
|
|
9
10
|
const [activeTab, setActiveTab] = useState('values');
|
|
10
|
-
const { formState,
|
|
11
|
-
|
|
11
|
+
const { formState, control, getValues } = form;
|
|
12
|
+
useWatch({
|
|
13
|
+
control
|
|
14
|
+
});
|
|
15
|
+
const values = getValues();
|
|
12
16
|
const stats = {
|
|
13
17
|
isValid: formState.isValid,
|
|
14
18
|
isDirty: formState.isDirty,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
3
12
|
(()=>{
|
|
4
13
|
__webpack_require__.d = (exports1, definition)=>{
|
|
5
14
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -29,11 +38,13 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
38
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
39
|
const standard_schema_namespaceObject = require("@hookform/resolvers/standard-schema");
|
|
31
40
|
const external_react_namespaceObject = require("react");
|
|
41
|
+
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
|
|
32
42
|
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
33
43
|
const v4_namespaceObject = require("zod/v4");
|
|
34
44
|
const accordion_cjs_namespaceObject = require("../ui/accordion.cjs");
|
|
35
45
|
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
36
46
|
const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
|
|
47
|
+
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
37
48
|
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
38
49
|
const external_field_renderer_cjs_namespaceObject = require("./field-renderer.cjs");
|
|
39
50
|
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
@@ -43,20 +54,31 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
43
54
|
const [currentStep, setCurrentStep] = (0, external_react_namespaceObject.useState)(0);
|
|
44
55
|
const [customComponents, setCustomComponents] = (0, external_react_namespaceObject.useState)({});
|
|
45
56
|
const [isInitialized, setIsInitialized] = (0, external_react_namespaceObject.useState)(false);
|
|
46
|
-
const
|
|
57
|
+
const schemaRef = (0, external_react_namespaceObject.useRef)(schema);
|
|
58
|
+
const stableSchema = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
59
|
+
if ((0, index_cjs_namespaceObject.deepEqual)(schemaRef.current, schema)) return schemaRef.current;
|
|
60
|
+
schemaRef.current = schema;
|
|
61
|
+
return schema;
|
|
62
|
+
}, [
|
|
47
63
|
schema
|
|
48
64
|
]);
|
|
65
|
+
const zodSchema = (0, external_react_namespaceObject.useMemo)(()=>buildZodSchema(stableSchema), [
|
|
66
|
+
stableSchema
|
|
67
|
+
]);
|
|
49
68
|
const form = (0, external_react_hook_form_namespaceObject.useForm)({
|
|
50
69
|
resolver: (0, standard_schema_namespaceObject.standardSchemaResolver)(zodSchema),
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
defaultValues: stableSchema.initialData || {},
|
|
71
|
+
mode: stableSchema.mode || 'onSubmit',
|
|
72
|
+
reValidateMode: stableSchema.reValidateMode || 'onChange'
|
|
53
73
|
});
|
|
54
74
|
const { watch, handleSubmit, reset } = form;
|
|
55
|
-
const valuesRef = (0, external_react_namespaceObject.useRef)(
|
|
56
|
-
const
|
|
57
|
-
|
|
75
|
+
const valuesRef = (0, external_react_namespaceObject.useRef)(form.getValues());
|
|
76
|
+
const pluginsRef = (0, external_react_namespaceObject.useRef)(plugins);
|
|
77
|
+
pluginsRef.current = plugins;
|
|
78
|
+
const onSubmitRef = (0, external_react_namespaceObject.useRef)(onSubmit);
|
|
79
|
+
onSubmitRef.current = onSubmit;
|
|
58
80
|
const context = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
59
|
-
schema,
|
|
81
|
+
schema: stableSchema,
|
|
60
82
|
form,
|
|
61
83
|
get values () {
|
|
62
84
|
return valuesRef.current;
|
|
@@ -70,7 +92,7 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
70
92
|
get isDirty () {
|
|
71
93
|
return form.formState.isDirty;
|
|
72
94
|
},
|
|
73
|
-
currentStep:
|
|
95
|
+
currentStep: stableSchema.steps ? currentStep : void 0,
|
|
74
96
|
evaluateConditions: (conditions)=>external_rules_engine_cjs_namespaceObject.RulesEngine.evaluateConditions(conditions, valuesRef.current, 'AND'),
|
|
75
97
|
fetchData: async (source)=>{
|
|
76
98
|
const result = await external_data_fetcher_cjs_namespaceObject.DataFetcher.fetch(source, valuesRef.current);
|
|
@@ -83,17 +105,31 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
83
105
|
}));
|
|
84
106
|
}
|
|
85
107
|
}), [
|
|
86
|
-
|
|
108
|
+
stableSchema,
|
|
87
109
|
form,
|
|
88
110
|
currentStep
|
|
89
111
|
]);
|
|
90
112
|
const contextRef = (0, external_react_namespaceObject.useRef)(context);
|
|
91
113
|
contextRef.current = context;
|
|
114
|
+
const isInitializedRef = (0, external_react_namespaceObject.useRef)(isInitialized);
|
|
115
|
+
isInitializedRef.current = isInitialized;
|
|
116
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
117
|
+
const subscription = watch((value, { name })=>{
|
|
118
|
+
valuesRef.current = value;
|
|
119
|
+
if (!name || !isInitializedRef.current) return;
|
|
120
|
+
pluginsRef.current.forEach((plugin)=>{
|
|
121
|
+
plugin.onValueChange?.(name, (0, index_cjs_namespaceObject.get)(value, name), contextRef.current);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
return ()=>subscription.unsubscribe();
|
|
125
|
+
}, [
|
|
126
|
+
watch
|
|
127
|
+
]);
|
|
92
128
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
93
129
|
if (isInitialized) return;
|
|
94
130
|
const initializeForm = async ()=>{
|
|
95
|
-
if (
|
|
96
|
-
const data = await loadInitialData(
|
|
131
|
+
if (stableSchema.initialData) {
|
|
132
|
+
const data = await loadInitialData(stableSchema.initialData, contextRef.current);
|
|
97
133
|
reset(data);
|
|
98
134
|
}
|
|
99
135
|
for (const plugin of plugins)await plugin.onFormInit?.(contextRef.current);
|
|
@@ -103,41 +139,30 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
103
139
|
}, [
|
|
104
140
|
isInitialized
|
|
105
141
|
]);
|
|
106
|
-
(0, external_react_namespaceObject.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
return ()=>subscription.unsubscribe();
|
|
117
|
-
}, [
|
|
118
|
-
watch,
|
|
119
|
-
isInitialized,
|
|
120
|
-
plugins
|
|
142
|
+
const handleFormSubmit = (0, external_react_namespaceObject.useMemo)(()=>handleSubmit(async (data)=>{
|
|
143
|
+
let finalData = data;
|
|
144
|
+
for (const plugin of pluginsRef.current)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, contextRef.current) || finalData;
|
|
145
|
+
if (onSubmitRef.current) await onSubmitRef.current(finalData);
|
|
146
|
+
}), [
|
|
147
|
+
handleSubmit
|
|
148
|
+
]);
|
|
149
|
+
const handleReset = (0, external_react_namespaceObject.useCallback)(()=>reset(), [
|
|
150
|
+
reset
|
|
121
151
|
]);
|
|
122
|
-
const handleFormSubmit = handleSubmit(async (data)=>{
|
|
123
|
-
let finalData = data;
|
|
124
|
-
for (const plugin of plugins)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, context) || finalData;
|
|
125
|
-
if (onSubmit) await onSubmit(finalData);
|
|
126
|
-
});
|
|
127
152
|
const renderContent = ()=>{
|
|
128
|
-
if (
|
|
153
|
+
if (stableSchema.steps) {
|
|
129
154
|
if ('tabs' === stepVariant) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabbedStepForm, {
|
|
130
|
-
schema:
|
|
155
|
+
schema: stableSchema,
|
|
131
156
|
context: context,
|
|
132
157
|
customComponents: customComponents,
|
|
133
158
|
disabled: disabled,
|
|
134
159
|
sectionVariant: sectionVariant,
|
|
135
160
|
activeStepId: activeStepId,
|
|
136
161
|
onActiveStepChange: onActiveStepChange,
|
|
137
|
-
onReset:
|
|
162
|
+
onReset: handleReset
|
|
138
163
|
});
|
|
139
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
140
|
-
schema:
|
|
164
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_MultiStepForm, {
|
|
165
|
+
schema: stableSchema,
|
|
141
166
|
context: context,
|
|
142
167
|
currentStep: currentStep,
|
|
143
168
|
setCurrentStep: setCurrentStep,
|
|
@@ -146,8 +171,8 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
146
171
|
sectionVariant: sectionVariant
|
|
147
172
|
});
|
|
148
173
|
}
|
|
149
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
150
|
-
schema:
|
|
174
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_SinglePageForm, {
|
|
175
|
+
schema: stableSchema,
|
|
151
176
|
context: context,
|
|
152
177
|
customComponents: customComponents,
|
|
153
178
|
disabled: disabled,
|
|
@@ -162,21 +187,36 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
162
187
|
autoComplete: autoComplete,
|
|
163
188
|
children: [
|
|
164
189
|
renderContent(),
|
|
165
|
-
!
|
|
166
|
-
schema:
|
|
190
|
+
!stableSchema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
|
|
191
|
+
schema: stableSchema,
|
|
167
192
|
context: context,
|
|
168
|
-
onReset:
|
|
193
|
+
onReset: handleReset
|
|
169
194
|
})
|
|
170
195
|
]
|
|
171
196
|
})
|
|
172
197
|
});
|
|
173
198
|
}
|
|
174
|
-
function
|
|
199
|
+
function conditionDependencies(conditionGroups) {
|
|
200
|
+
const fields = new Set();
|
|
201
|
+
for (const conditions of conditionGroups)for (const condition of conditions || [])if (condition.when) fields.add(condition.when);
|
|
202
|
+
return Array.from(fields);
|
|
203
|
+
}
|
|
204
|
+
function useConditionDependencies(context, conditionFields) {
|
|
205
|
+
(0, external_react_hook_form_namespaceObject.useWatch)({
|
|
206
|
+
control: context.form.control,
|
|
207
|
+
name: conditionFields
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const metadata_form_SinglePageForm = /*#__PURE__*/ external_react_default().memo(function({ schema, context, customComponents, disabled, sectionVariant }) {
|
|
175
211
|
const sections = schema.sections || [];
|
|
212
|
+
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.sections?.map((section)=>section.conditions) ?? []), [
|
|
213
|
+
schema
|
|
214
|
+
]);
|
|
215
|
+
useConditionDependencies(context, conditionFields);
|
|
176
216
|
const visibleSections = sections.filter((section)=>!section.conditions || context.evaluateConditions(section.conditions));
|
|
177
217
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
178
218
|
className: 'plain' === sectionVariant ? void 0 : 'space-y-2',
|
|
179
|
-
children: visibleSections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
219
|
+
children: visibleSections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormSection, {
|
|
180
220
|
section: section,
|
|
181
221
|
context: context,
|
|
182
222
|
customComponents: customComponents,
|
|
@@ -184,15 +224,30 @@ function SinglePageForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
184
224
|
sectionVariant: sectionVariant
|
|
185
225
|
}, section.id))
|
|
186
226
|
});
|
|
187
|
-
}
|
|
188
|
-
|
|
227
|
+
});
|
|
228
|
+
const metadata_form_MultiStepForm = /*#__PURE__*/ external_react_default().memo(function({ schema, context, currentStep, setCurrentStep, customComponents, disabled, sectionVariant }) {
|
|
189
229
|
const steps = schema.steps || [];
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
230
|
+
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.steps?.map((step)=>step.conditions) ?? []), [
|
|
231
|
+
schema
|
|
232
|
+
]);
|
|
233
|
+
useConditionDependencies(context, conditionFields);
|
|
234
|
+
let visibleStepIndex = -1;
|
|
235
|
+
for(let i = currentStep; i < steps.length; i++){
|
|
236
|
+
const candidate = steps[i];
|
|
237
|
+
if (!candidate.conditions || context.evaluateConditions(candidate.conditions)) {
|
|
238
|
+
visibleStepIndex = i;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
195
241
|
}
|
|
242
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
243
|
+
if (-1 !== visibleStepIndex && visibleStepIndex !== currentStep) setCurrentStep(visibleStepIndex);
|
|
244
|
+
}, [
|
|
245
|
+
visibleStepIndex,
|
|
246
|
+
currentStep,
|
|
247
|
+
setCurrentStep
|
|
248
|
+
]);
|
|
249
|
+
const step = -1 !== visibleStepIndex ? steps[visibleStepIndex] : void 0;
|
|
250
|
+
if (!step || visibleStepIndex !== currentStep) return null;
|
|
196
251
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
197
252
|
className: "space-y-6",
|
|
198
253
|
children: [
|
|
@@ -224,7 +279,7 @@ function MultiStepForm({ schema, context, currentStep, setCurrentStep, customCom
|
|
|
224
279
|
}),
|
|
225
280
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
226
281
|
className: 'plain' === sectionVariant ? void 0 : 'space-y-2',
|
|
227
|
-
children: step.sections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
282
|
+
children: step.sections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormSection, {
|
|
228
283
|
section: section,
|
|
229
284
|
context: context,
|
|
230
285
|
customComponents: customComponents,
|
|
@@ -256,9 +311,16 @@ function MultiStepForm({ schema, context, currentStep, setCurrentStep, customCom
|
|
|
256
311
|
})
|
|
257
312
|
]
|
|
258
313
|
});
|
|
259
|
-
}
|
|
314
|
+
});
|
|
260
315
|
function TabbedStepForm({ schema, context, customComponents, disabled, sectionVariant, onReset, activeStepId, onActiveStepChange }) {
|
|
261
316
|
const steps = schema.steps || [];
|
|
317
|
+
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.steps?.flatMap((step)=>[
|
|
318
|
+
step.conditions,
|
|
319
|
+
...step.sections.map((section)=>section.conditions)
|
|
320
|
+
]) ?? []), [
|
|
321
|
+
schema
|
|
322
|
+
]);
|
|
323
|
+
useConditionDependencies(context, conditionFields);
|
|
262
324
|
const visibleSteps = steps.filter((step)=>{
|
|
263
325
|
if (step.conditions && !context.evaluateConditions(step.conditions)) return false;
|
|
264
326
|
const hasVisibleSection = step.sections.some((section)=>!section.conditions || context.evaluateConditions(section.conditions));
|
|
@@ -334,7 +396,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
334
396
|
children: step.emptyState
|
|
335
397
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
336
398
|
className: 'plain' === sectionVariant ? 'pb-6 [padding-inline:var(--mf-content-inset,0px)]' : 'space-y-2 pb-6 pt-4 [padding-inline:var(--mf-content-inset,0px)]',
|
|
337
|
-
children: stepSections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
399
|
+
children: stepSections.map((section)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormSection, {
|
|
338
400
|
section: section,
|
|
339
401
|
context: context,
|
|
340
402
|
customComponents: customComponents,
|
|
@@ -346,7 +408,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
346
408
|
})
|
|
347
409
|
]
|
|
348
410
|
}),
|
|
349
|
-
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(
|
|
411
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
|
|
350
412
|
schema: schema,
|
|
351
413
|
context: context,
|
|
352
414
|
onReset: onReset
|
|
@@ -354,7 +416,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
354
416
|
]
|
|
355
417
|
});
|
|
356
418
|
}
|
|
357
|
-
|
|
419
|
+
const metadata_form_FormSection = /*#__PURE__*/ external_react_default().memo(function({ section, context, customComponents, disabled, sectionVariant = 'card' }) {
|
|
358
420
|
const gridColumns = context.schema.layout?.columns || 1;
|
|
359
421
|
const gap = context.schema.layout?.gap || 4;
|
|
360
422
|
const isPlain = 'plain' === sectionVariant;
|
|
@@ -430,8 +492,15 @@ function FormSection({ section, context, customComponents, disabled, sectionVari
|
|
|
430
492
|
})
|
|
431
493
|
]
|
|
432
494
|
});
|
|
433
|
-
}
|
|
434
|
-
|
|
495
|
+
});
|
|
496
|
+
const metadata_form_FormActions = /*#__PURE__*/ external_react_default().memo(function({ schema, context, onReset }) {
|
|
497
|
+
const { isSubmitting } = (0, external_react_hook_form_namespaceObject.useFormState)({
|
|
498
|
+
control: context.form.control
|
|
499
|
+
});
|
|
500
|
+
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.actions?.map((action)=>action.conditions) ?? []), [
|
|
501
|
+
schema
|
|
502
|
+
]);
|
|
503
|
+
useConditionDependencies(context, conditionFields);
|
|
435
504
|
const actions = schema.actions || [
|
|
436
505
|
{
|
|
437
506
|
id: 'submit',
|
|
@@ -455,12 +524,12 @@ function FormActions({ schema, context, onReset }) {
|
|
|
455
524
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
456
525
|
type: 'submit' === action.type ? 'submit' : 'button',
|
|
457
526
|
variant: action.variant || 'default',
|
|
458
|
-
disabled: action.disabled || 'submit' === action.type &&
|
|
459
|
-
children: action.loading &&
|
|
527
|
+
disabled: action.disabled || 'submit' === action.type && isSubmitting,
|
|
528
|
+
children: action.loading && isSubmitting ? 'Loading...' : action.label
|
|
460
529
|
}, action.id);
|
|
461
530
|
})
|
|
462
531
|
});
|
|
463
|
-
}
|
|
532
|
+
});
|
|
464
533
|
function buildZodSchema(schema) {
|
|
465
534
|
const shape = {};
|
|
466
535
|
const fields = schema.steps ? schema.steps.flatMap((step)=>step.sections.flatMap((s)=>s.fields)) : schema.sections?.flatMap((s)=>s.fields) || [];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
|
|
3
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { FormProvider, useForm, useFormState } from "react-hook-form";
|
|
3
|
+
import react, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import { FormProvider, useForm, useFormState, useWatch } from "react-hook-form";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion.js";
|
|
7
7
|
import { Button } from "../ui/button.js";
|
|
8
8
|
import { ScrollableTabsList, Tabs, TabsContent, TabsTrigger } from "../ui/tabs.js";
|
|
9
|
+
import { deepEqual, get } from "../../lib/index.js";
|
|
9
10
|
import { DataFetcher } from "./data-fetcher.js";
|
|
10
11
|
import { FormFieldRenderer } from "./field-renderer.js";
|
|
11
12
|
import { RulesEngine } from "./rules-engine.js";
|
|
@@ -15,20 +16,31 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
15
16
|
const [currentStep, setCurrentStep] = useState(0);
|
|
16
17
|
const [customComponents, setCustomComponents] = useState({});
|
|
17
18
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
18
|
-
const
|
|
19
|
+
const schemaRef = useRef(schema);
|
|
20
|
+
const stableSchema = useMemo(()=>{
|
|
21
|
+
if (deepEqual(schemaRef.current, schema)) return schemaRef.current;
|
|
22
|
+
schemaRef.current = schema;
|
|
23
|
+
return schema;
|
|
24
|
+
}, [
|
|
19
25
|
schema
|
|
20
26
|
]);
|
|
27
|
+
const zodSchema = useMemo(()=>buildZodSchema(stableSchema), [
|
|
28
|
+
stableSchema
|
|
29
|
+
]);
|
|
21
30
|
const form = useForm({
|
|
22
31
|
resolver: standardSchemaResolver(zodSchema),
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
defaultValues: stableSchema.initialData || {},
|
|
33
|
+
mode: stableSchema.mode || 'onSubmit',
|
|
34
|
+
reValidateMode: stableSchema.reValidateMode || 'onChange'
|
|
25
35
|
});
|
|
26
36
|
const { watch, handleSubmit, reset } = form;
|
|
27
|
-
const valuesRef = useRef(
|
|
28
|
-
const
|
|
29
|
-
|
|
37
|
+
const valuesRef = useRef(form.getValues());
|
|
38
|
+
const pluginsRef = useRef(plugins);
|
|
39
|
+
pluginsRef.current = plugins;
|
|
40
|
+
const onSubmitRef = useRef(onSubmit);
|
|
41
|
+
onSubmitRef.current = onSubmit;
|
|
30
42
|
const context = useMemo(()=>({
|
|
31
|
-
schema,
|
|
43
|
+
schema: stableSchema,
|
|
32
44
|
form,
|
|
33
45
|
get values () {
|
|
34
46
|
return valuesRef.current;
|
|
@@ -42,7 +54,7 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
42
54
|
get isDirty () {
|
|
43
55
|
return form.formState.isDirty;
|
|
44
56
|
},
|
|
45
|
-
currentStep:
|
|
57
|
+
currentStep: stableSchema.steps ? currentStep : void 0,
|
|
46
58
|
evaluateConditions: (conditions)=>RulesEngine.evaluateConditions(conditions, valuesRef.current, 'AND'),
|
|
47
59
|
fetchData: async (source)=>{
|
|
48
60
|
const result = await DataFetcher.fetch(source, valuesRef.current);
|
|
@@ -55,17 +67,31 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
55
67
|
}));
|
|
56
68
|
}
|
|
57
69
|
}), [
|
|
58
|
-
|
|
70
|
+
stableSchema,
|
|
59
71
|
form,
|
|
60
72
|
currentStep
|
|
61
73
|
]);
|
|
62
74
|
const contextRef = useRef(context);
|
|
63
75
|
contextRef.current = context;
|
|
76
|
+
const isInitializedRef = useRef(isInitialized);
|
|
77
|
+
isInitializedRef.current = isInitialized;
|
|
78
|
+
useEffect(()=>{
|
|
79
|
+
const subscription = watch((value, { name })=>{
|
|
80
|
+
valuesRef.current = value;
|
|
81
|
+
if (!name || !isInitializedRef.current) return;
|
|
82
|
+
pluginsRef.current.forEach((plugin)=>{
|
|
83
|
+
plugin.onValueChange?.(name, get(value, name), contextRef.current);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
return ()=>subscription.unsubscribe();
|
|
87
|
+
}, [
|
|
88
|
+
watch
|
|
89
|
+
]);
|
|
64
90
|
useEffect(()=>{
|
|
65
91
|
if (isInitialized) return;
|
|
66
92
|
const initializeForm = async ()=>{
|
|
67
|
-
if (
|
|
68
|
-
const data = await loadInitialData(
|
|
93
|
+
if (stableSchema.initialData) {
|
|
94
|
+
const data = await loadInitialData(stableSchema.initialData, contextRef.current);
|
|
69
95
|
reset(data);
|
|
70
96
|
}
|
|
71
97
|
for (const plugin of plugins)await plugin.onFormInit?.(contextRef.current);
|
|
@@ -75,41 +101,30 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
75
101
|
}, [
|
|
76
102
|
isInitialized
|
|
77
103
|
]);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
return ()=>subscription.unsubscribe();
|
|
89
|
-
}, [
|
|
90
|
-
watch,
|
|
91
|
-
isInitialized,
|
|
92
|
-
plugins
|
|
104
|
+
const handleFormSubmit = useMemo(()=>handleSubmit(async (data)=>{
|
|
105
|
+
let finalData = data;
|
|
106
|
+
for (const plugin of pluginsRef.current)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, contextRef.current) || finalData;
|
|
107
|
+
if (onSubmitRef.current) await onSubmitRef.current(finalData);
|
|
108
|
+
}), [
|
|
109
|
+
handleSubmit
|
|
110
|
+
]);
|
|
111
|
+
const handleReset = useCallback(()=>reset(), [
|
|
112
|
+
reset
|
|
93
113
|
]);
|
|
94
|
-
const handleFormSubmit = handleSubmit(async (data)=>{
|
|
95
|
-
let finalData = data;
|
|
96
|
-
for (const plugin of plugins)if (plugin.onSubmit) finalData = await plugin.onSubmit(finalData, context) || finalData;
|
|
97
|
-
if (onSubmit) await onSubmit(finalData);
|
|
98
|
-
});
|
|
99
114
|
const renderContent = ()=>{
|
|
100
|
-
if (
|
|
115
|
+
if (stableSchema.steps) {
|
|
101
116
|
if ('tabs' === stepVariant) return /*#__PURE__*/ jsx(TabbedStepForm, {
|
|
102
|
-
schema:
|
|
117
|
+
schema: stableSchema,
|
|
103
118
|
context: context,
|
|
104
119
|
customComponents: customComponents,
|
|
105
120
|
disabled: disabled,
|
|
106
121
|
sectionVariant: sectionVariant,
|
|
107
122
|
activeStepId: activeStepId,
|
|
108
123
|
onActiveStepChange: onActiveStepChange,
|
|
109
|
-
onReset:
|
|
124
|
+
onReset: handleReset
|
|
110
125
|
});
|
|
111
|
-
return /*#__PURE__*/ jsx(
|
|
112
|
-
schema:
|
|
126
|
+
return /*#__PURE__*/ jsx(metadata_form_MultiStepForm, {
|
|
127
|
+
schema: stableSchema,
|
|
113
128
|
context: context,
|
|
114
129
|
currentStep: currentStep,
|
|
115
130
|
setCurrentStep: setCurrentStep,
|
|
@@ -118,8 +133,8 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
118
133
|
sectionVariant: sectionVariant
|
|
119
134
|
});
|
|
120
135
|
}
|
|
121
|
-
return /*#__PURE__*/ jsx(
|
|
122
|
-
schema:
|
|
136
|
+
return /*#__PURE__*/ jsx(metadata_form_SinglePageForm, {
|
|
137
|
+
schema: stableSchema,
|
|
123
138
|
context: context,
|
|
124
139
|
customComponents: customComponents,
|
|
125
140
|
disabled: disabled,
|
|
@@ -134,21 +149,36 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
134
149
|
autoComplete: autoComplete,
|
|
135
150
|
children: [
|
|
136
151
|
renderContent(),
|
|
137
|
-
!
|
|
138
|
-
schema:
|
|
152
|
+
!stableSchema.steps && /*#__PURE__*/ jsx(metadata_form_FormActions, {
|
|
153
|
+
schema: stableSchema,
|
|
139
154
|
context: context,
|
|
140
|
-
onReset:
|
|
155
|
+
onReset: handleReset
|
|
141
156
|
})
|
|
142
157
|
]
|
|
143
158
|
})
|
|
144
159
|
});
|
|
145
160
|
}
|
|
146
|
-
function
|
|
161
|
+
function conditionDependencies(conditionGroups) {
|
|
162
|
+
const fields = new Set();
|
|
163
|
+
for (const conditions of conditionGroups)for (const condition of conditions || [])if (condition.when) fields.add(condition.when);
|
|
164
|
+
return Array.from(fields);
|
|
165
|
+
}
|
|
166
|
+
function useConditionDependencies(context, conditionFields) {
|
|
167
|
+
useWatch({
|
|
168
|
+
control: context.form.control,
|
|
169
|
+
name: conditionFields
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
const metadata_form_SinglePageForm = /*#__PURE__*/ react.memo(function({ schema, context, customComponents, disabled, sectionVariant }) {
|
|
147
173
|
const sections = schema.sections || [];
|
|
174
|
+
const conditionFields = useMemo(()=>conditionDependencies(schema.sections?.map((section)=>section.conditions) ?? []), [
|
|
175
|
+
schema
|
|
176
|
+
]);
|
|
177
|
+
useConditionDependencies(context, conditionFields);
|
|
148
178
|
const visibleSections = sections.filter((section)=>!section.conditions || context.evaluateConditions(section.conditions));
|
|
149
179
|
return /*#__PURE__*/ jsx("div", {
|
|
150
180
|
className: 'plain' === sectionVariant ? void 0 : 'space-y-2',
|
|
151
|
-
children: visibleSections.map((section)=>/*#__PURE__*/ jsx(
|
|
181
|
+
children: visibleSections.map((section)=>/*#__PURE__*/ jsx(metadata_form_FormSection, {
|
|
152
182
|
section: section,
|
|
153
183
|
context: context,
|
|
154
184
|
customComponents: customComponents,
|
|
@@ -156,15 +186,30 @@ function SinglePageForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
156
186
|
sectionVariant: sectionVariant
|
|
157
187
|
}, section.id))
|
|
158
188
|
});
|
|
159
|
-
}
|
|
160
|
-
|
|
189
|
+
});
|
|
190
|
+
const metadata_form_MultiStepForm = /*#__PURE__*/ react.memo(function({ schema, context, currentStep, setCurrentStep, customComponents, disabled, sectionVariant }) {
|
|
161
191
|
const steps = schema.steps || [];
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
192
|
+
const conditionFields = useMemo(()=>conditionDependencies(schema.steps?.map((step)=>step.conditions) ?? []), [
|
|
193
|
+
schema
|
|
194
|
+
]);
|
|
195
|
+
useConditionDependencies(context, conditionFields);
|
|
196
|
+
let visibleStepIndex = -1;
|
|
197
|
+
for(let i = currentStep; i < steps.length; i++){
|
|
198
|
+
const candidate = steps[i];
|
|
199
|
+
if (!candidate.conditions || context.evaluateConditions(candidate.conditions)) {
|
|
200
|
+
visibleStepIndex = i;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
167
203
|
}
|
|
204
|
+
useEffect(()=>{
|
|
205
|
+
if (-1 !== visibleStepIndex && visibleStepIndex !== currentStep) setCurrentStep(visibleStepIndex);
|
|
206
|
+
}, [
|
|
207
|
+
visibleStepIndex,
|
|
208
|
+
currentStep,
|
|
209
|
+
setCurrentStep
|
|
210
|
+
]);
|
|
211
|
+
const step = -1 !== visibleStepIndex ? steps[visibleStepIndex] : void 0;
|
|
212
|
+
if (!step || visibleStepIndex !== currentStep) return null;
|
|
168
213
|
return /*#__PURE__*/ jsxs("div", {
|
|
169
214
|
className: "space-y-6",
|
|
170
215
|
children: [
|
|
@@ -196,7 +241,7 @@ function MultiStepForm({ schema, context, currentStep, setCurrentStep, customCom
|
|
|
196
241
|
}),
|
|
197
242
|
/*#__PURE__*/ jsx("div", {
|
|
198
243
|
className: 'plain' === sectionVariant ? void 0 : 'space-y-2',
|
|
199
|
-
children: step.sections.map((section)=>/*#__PURE__*/ jsx(
|
|
244
|
+
children: step.sections.map((section)=>/*#__PURE__*/ jsx(metadata_form_FormSection, {
|
|
200
245
|
section: section,
|
|
201
246
|
context: context,
|
|
202
247
|
customComponents: customComponents,
|
|
@@ -228,9 +273,16 @@ function MultiStepForm({ schema, context, currentStep, setCurrentStep, customCom
|
|
|
228
273
|
})
|
|
229
274
|
]
|
|
230
275
|
});
|
|
231
|
-
}
|
|
276
|
+
});
|
|
232
277
|
function TabbedStepForm({ schema, context, customComponents, disabled, sectionVariant, onReset, activeStepId, onActiveStepChange }) {
|
|
233
278
|
const steps = schema.steps || [];
|
|
279
|
+
const conditionFields = useMemo(()=>conditionDependencies(schema.steps?.flatMap((step)=>[
|
|
280
|
+
step.conditions,
|
|
281
|
+
...step.sections.map((section)=>section.conditions)
|
|
282
|
+
]) ?? []), [
|
|
283
|
+
schema
|
|
284
|
+
]);
|
|
285
|
+
useConditionDependencies(context, conditionFields);
|
|
234
286
|
const visibleSteps = steps.filter((step)=>{
|
|
235
287
|
if (step.conditions && !context.evaluateConditions(step.conditions)) return false;
|
|
236
288
|
const hasVisibleSection = step.sections.some((section)=>!section.conditions || context.evaluateConditions(section.conditions));
|
|
@@ -306,7 +358,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
306
358
|
children: step.emptyState
|
|
307
359
|
}) : /*#__PURE__*/ jsx("div", {
|
|
308
360
|
className: 'plain' === sectionVariant ? 'pb-6 [padding-inline:var(--mf-content-inset,0px)]' : 'space-y-2 pb-6 pt-4 [padding-inline:var(--mf-content-inset,0px)]',
|
|
309
|
-
children: stepSections.map((section)=>/*#__PURE__*/ jsx(
|
|
361
|
+
children: stepSections.map((section)=>/*#__PURE__*/ jsx(metadata_form_FormSection, {
|
|
310
362
|
section: section,
|
|
311
363
|
context: context,
|
|
312
364
|
customComponents: customComponents,
|
|
@@ -318,7 +370,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
318
370
|
})
|
|
319
371
|
]
|
|
320
372
|
}),
|
|
321
|
-
/*#__PURE__*/ jsx(
|
|
373
|
+
/*#__PURE__*/ jsx(metadata_form_FormActions, {
|
|
322
374
|
schema: schema,
|
|
323
375
|
context: context,
|
|
324
376
|
onReset: onReset
|
|
@@ -326,7 +378,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
326
378
|
]
|
|
327
379
|
});
|
|
328
380
|
}
|
|
329
|
-
|
|
381
|
+
const metadata_form_FormSection = /*#__PURE__*/ react.memo(function({ section, context, customComponents, disabled, sectionVariant = 'card' }) {
|
|
330
382
|
const gridColumns = context.schema.layout?.columns || 1;
|
|
331
383
|
const gap = context.schema.layout?.gap || 4;
|
|
332
384
|
const isPlain = 'plain' === sectionVariant;
|
|
@@ -402,8 +454,15 @@ function FormSection({ section, context, customComponents, disabled, sectionVari
|
|
|
402
454
|
})
|
|
403
455
|
]
|
|
404
456
|
});
|
|
405
|
-
}
|
|
406
|
-
|
|
457
|
+
});
|
|
458
|
+
const metadata_form_FormActions = /*#__PURE__*/ react.memo(function({ schema, context, onReset }) {
|
|
459
|
+
const { isSubmitting } = useFormState({
|
|
460
|
+
control: context.form.control
|
|
461
|
+
});
|
|
462
|
+
const conditionFields = useMemo(()=>conditionDependencies(schema.actions?.map((action)=>action.conditions) ?? []), [
|
|
463
|
+
schema
|
|
464
|
+
]);
|
|
465
|
+
useConditionDependencies(context, conditionFields);
|
|
407
466
|
const actions = schema.actions || [
|
|
408
467
|
{
|
|
409
468
|
id: 'submit',
|
|
@@ -427,12 +486,12 @@ function FormActions({ schema, context, onReset }) {
|
|
|
427
486
|
return /*#__PURE__*/ jsx(Button, {
|
|
428
487
|
type: 'submit' === action.type ? 'submit' : 'button',
|
|
429
488
|
variant: action.variant || 'default',
|
|
430
|
-
disabled: action.disabled || 'submit' === action.type &&
|
|
431
|
-
children: action.loading &&
|
|
489
|
+
disabled: action.disabled || 'submit' === action.type && isSubmitting,
|
|
490
|
+
children: action.loading && isSubmitting ? 'Loading...' : action.label
|
|
432
491
|
}, action.id);
|
|
433
492
|
})
|
|
434
493
|
});
|
|
435
|
-
}
|
|
494
|
+
});
|
|
436
495
|
function buildZodSchema(schema) {
|
|
437
496
|
const shape = {};
|
|
438
497
|
const fields = schema.steps ? schema.steps.flatMap((step)=>step.sections.flatMap((s)=>s.fields)) : schema.sections?.flatMap((s)=>s.fields) || [];
|
|
@@ -30,7 +30,7 @@ var __webpack_modules__ = {
|
|
|
30
30
|
"./calendar" (module) {
|
|
31
31
|
module.exports = require("./calendar.cjs");
|
|
32
32
|
},
|
|
33
|
-
"
|
|
33
|
+
"@/components/ui/card" (module) {
|
|
34
34
|
module.exports = require("./card.cjs");
|
|
35
35
|
},
|
|
36
36
|
"./chart" (module) {
|
|
@@ -87,10 +87,10 @@ var __webpack_modules__ = {
|
|
|
87
87
|
"@/components/ui/input-group" (module) {
|
|
88
88
|
module.exports = require("./input-group.cjs");
|
|
89
89
|
},
|
|
90
|
-
"
|
|
90
|
+
"@/components/ui/input" (module) {
|
|
91
91
|
module.exports = require("./input.cjs");
|
|
92
92
|
},
|
|
93
|
-
"
|
|
93
|
+
"./label" (module) {
|
|
94
94
|
module.exports = require("./label.cjs");
|
|
95
95
|
},
|
|
96
96
|
"./layout" (module) {
|
|
@@ -159,13 +159,13 @@ var __webpack_modules__ = {
|
|
|
159
159
|
"./switch" (module) {
|
|
160
160
|
module.exports = require("./switch.cjs");
|
|
161
161
|
},
|
|
162
|
-
"
|
|
162
|
+
"@/components/ui/table" (module) {
|
|
163
163
|
module.exports = require("./table.cjs");
|
|
164
164
|
},
|
|
165
165
|
"./tabs" (module) {
|
|
166
166
|
module.exports = require("./tabs.cjs");
|
|
167
167
|
},
|
|
168
|
-
"
|
|
168
|
+
"@/components/ui/textarea" (module) {
|
|
169
169
|
module.exports = require("./textarea.cjs");
|
|
170
170
|
},
|
|
171
171
|
"./toggle-group" (module) {
|
|
@@ -300,7 +300,7 @@ var __webpack_exports__ = {};
|
|
|
300
300
|
"default"
|
|
301
301
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_calendar__rspack_import_9[__rspack_import_key];
|
|
302
302
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
303
|
-
var _card__rspack_import_10 = __webpack_require__("
|
|
303
|
+
var _card__rspack_import_10 = __webpack_require__("@/components/ui/card");
|
|
304
304
|
var __rspack_reexport = {};
|
|
305
305
|
for(const __rspack_import_key in _card__rspack_import_10)if ([
|
|
306
306
|
"TreeView",
|
|
@@ -426,7 +426,7 @@ var __webpack_exports__ = {};
|
|
|
426
426
|
"default"
|
|
427
427
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_hover_card__rspack_import_27[__rspack_import_key];
|
|
428
428
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
429
|
-
var _input__rspack_import_28 = __webpack_require__("
|
|
429
|
+
var _input__rspack_import_28 = __webpack_require__("@/components/ui/input");
|
|
430
430
|
var __rspack_reexport = {};
|
|
431
431
|
for(const __rspack_import_key in _input__rspack_import_28)if ([
|
|
432
432
|
"TreeView",
|
|
@@ -440,7 +440,7 @@ var __webpack_exports__ = {};
|
|
|
440
440
|
"default"
|
|
441
441
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_input_group__rspack_import_29[__rspack_import_key];
|
|
442
442
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
443
|
-
var _label__rspack_import_30 = __webpack_require__("
|
|
443
|
+
var _label__rspack_import_30 = __webpack_require__("./label");
|
|
444
444
|
var __rspack_reexport = {};
|
|
445
445
|
for(const __rspack_import_key in _label__rspack_import_30)if ([
|
|
446
446
|
"TreeView",
|
|
@@ -601,7 +601,7 @@ var __webpack_exports__ = {};
|
|
|
601
601
|
"default"
|
|
602
602
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_switch__rspack_import_52[__rspack_import_key];
|
|
603
603
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
604
|
-
var _table__rspack_import_53 = __webpack_require__("
|
|
604
|
+
var _table__rspack_import_53 = __webpack_require__("@/components/ui/table");
|
|
605
605
|
var __rspack_reexport = {};
|
|
606
606
|
for(const __rspack_import_key in _table__rspack_import_53)if ([
|
|
607
607
|
"TreeView",
|
|
@@ -615,7 +615,7 @@ var __webpack_exports__ = {};
|
|
|
615
615
|
"default"
|
|
616
616
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_tabs__rspack_import_54[__rspack_import_key];
|
|
617
617
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
618
|
-
var _textarea__rspack_import_55 = __webpack_require__("
|
|
618
|
+
var _textarea__rspack_import_55 = __webpack_require__("@/components/ui/textarea");
|
|
619
619
|
var __rspack_reexport = {};
|
|
620
620
|
for(const __rspack_import_key in _textarea__rspack_import_55)if ([
|
|
621
621
|
"TreeView",
|
|
@@ -271,6 +271,7 @@ const EditorInner = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)
|
|
|
271
271
|
ErrorBoundary: LexicalErrorBoundary_namespaceObject.LexicalErrorBoundary
|
|
272
272
|
}),
|
|
273
273
|
placeholder && isEmpty && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
274
|
+
"data-slot": "prompt-editor-placeholder",
|
|
274
275
|
style: {
|
|
275
276
|
position: 'absolute',
|
|
276
277
|
top: '8px',
|
|
@@ -243,6 +243,7 @@ const EditorInner = /*#__PURE__*/ forwardRef(({ initialValue, value, onChange, a
|
|
|
243
243
|
ErrorBoundary: LexicalErrorBoundary
|
|
244
244
|
}),
|
|
245
245
|
placeholder && isEmpty && /*#__PURE__*/ jsx("div", {
|
|
246
|
+
"data-slot": "prompt-editor-placeholder",
|
|
246
247
|
style: {
|
|
247
248
|
position: 'absolute',
|
|
248
249
|
top: '8px',
|