@uipath/apollo-wind 2.46.0 → 2.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +13 -13
- package/dist/components/ui/index.cjs +34 -34
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +101 -68
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +16 -2
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +101 -68
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +13 -8
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +13 -1
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +13 -8
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +22 -11
- package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +23 -12
- package/dist/components/ui/prompt-editor/components/TokenPill.cjs +4 -2
- package/dist/components/ui/prompt-editor/components/TokenPill.js +4 -2
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.cjs +58 -0
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.d.ts +7 -0
- package/dist/components/ui/prompt-editor/components/TokenPillSlot.js +24 -0
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +8 -9
- package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +8 -9
- package/dist/components/ui/prompt-editor/index.cjs +152 -9
- package/dist/components/ui/prompt-editor/index.d.ts +13 -1
- package/dist/components/ui/prompt-editor/index.js +11 -1
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +2 -2
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +1 -1
- package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +2 -2
- package/dist/components/ui/prompt-editor/nodes/index.cjs +1 -1
- package/dist/components/ui/prompt-editor/nodes/index.d.ts +5 -5
- package/dist/components/ui/prompt-editor/nodes/index.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +11 -5
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +8 -1
- package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +12 -6
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +1 -1
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +12 -6
- package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +13 -7
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +64 -3
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +6 -2
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +65 -4
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +4 -9
- package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +4 -9
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +10 -5
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +3 -1
- package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +10 -5
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +1 -1
- package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +2 -2
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +10 -1
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +4 -1
- package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +8 -2
- package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +69 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +70 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.js +29 -0
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +198 -88
- package/dist/components/ui/prompt-editor/prompt-editor.d.ts +46 -1
- package/dist/components/ui/prompt-editor/prompt-editor.js +199 -89
- package/dist/components/ui/prompt-editor/types.cjs +5 -5
- package/dist/components/ui/prompt-editor/types.d.ts +18 -2
- package/dist/components/ui/prompt-editor/types.js +5 -5
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +10 -5
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +13 -0
- package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +8 -6
- package/dist/components/ui/prompt-editor/utils/index.cjs +1 -1
- package/dist/components/ui/prompt-editor/utils/index.d.ts +1 -1
- package/dist/components/ui/prompt-editor/utils/index.js +1 -1
- package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +1 -1
- package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +186 -0
- package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +38 -0
- package/dist/components/ui/prompt-editor/utils/rich-serialization.js +140 -0
- package/dist/components/ui/prompt-editor/utils/serialization.cjs +13 -5
- package/dist/components/ui/prompt-editor/utils/serialization.js +14 -6
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/index.cjs +136 -61
- package/dist/index.d.ts +89 -89
- package/dist/index.js +61 -61
- package/dist/styles.css +15 -0
- package/package.json +3 -1
|
@@ -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) || [];
|
|
@@ -2,7 +2,7 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
|
2
2
|
import { type VariantProps } from 'class-variance-authority';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
declare const avatarVariants: (props?: ({
|
|
5
|
-
size?: "
|
|
5
|
+
size?: "sm" | "lg" | "default" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
7
|
export interface AvatarProps extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>, VariantProps<typeof avatarVariants> {
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const badgeVariants: (props?: ({
|
|
4
|
-
variant?: "default" | "
|
|
4
|
+
variant?: "default" | "secondary" | "destructive" | "outline" | "error" | "warning" | "info" | "success" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type VariantProps } from 'class-variance-authority';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
5
|
-
size?: "
|
|
4
|
+
variant?: "text" | "default" | "secondary" | "destructive" | "outline" | "ghost" | "link" | null | undefined;
|
|
5
|
+
size?: "sm" | "lg" | "default" | "xs" | "2xs" | "3xs" | "4xs" | "icon" | null | undefined;
|
|
6
6
|
icon?: boolean | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
@@ -2,11 +2,11 @@ import { type DialogProps } from '@radix-ui/react-dialog';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
declare const Command: React.ForwardRefExoticComponent<Omit<{
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
5
|
+
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
6
6
|
ref?: React.Ref<HTMLDivElement>;
|
|
7
7
|
} & {
|
|
8
8
|
asChild?: boolean;
|
|
9
|
-
},
|
|
9
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
10
10
|
label?: string;
|
|
11
11
|
shouldFilter?: boolean;
|
|
12
12
|
filter?: (value: string, search: string, keywords?: string[]) => number;
|
|
@@ -22,51 +22,51 @@ declare const CommandInput: React.ForwardRefExoticComponent<Omit<Omit<Pick<Pick<
|
|
|
22
22
|
ref?: React.Ref<HTMLInputElement>;
|
|
23
23
|
} & {
|
|
24
24
|
asChild?: boolean;
|
|
25
|
-
}, "
|
|
25
|
+
}, "key" | "asChild" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "type" | "onChange" | "value"> & {
|
|
26
26
|
value?: string;
|
|
27
27
|
onValueChange?: (search: string) => void;
|
|
28
28
|
} & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
29
29
|
declare const CommandList: React.ForwardRefExoticComponent<Omit<{
|
|
30
30
|
children?: React.ReactNode;
|
|
31
|
-
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
31
|
+
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
32
32
|
ref?: React.Ref<HTMLDivElement>;
|
|
33
33
|
} & {
|
|
34
34
|
asChild?: boolean;
|
|
35
|
-
},
|
|
35
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
36
36
|
label?: string;
|
|
37
37
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
38
38
|
declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
|
|
39
39
|
children?: React.ReactNode;
|
|
40
|
-
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
40
|
+
} & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
41
41
|
ref?: React.Ref<HTMLDivElement>;
|
|
42
42
|
} & {
|
|
43
43
|
asChild?: boolean;
|
|
44
|
-
},
|
|
44
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
45
45
|
declare const CommandGroup: React.ForwardRefExoticComponent<Omit<{
|
|
46
46
|
children?: React.ReactNode;
|
|
47
|
-
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
47
|
+
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
48
48
|
ref?: React.Ref<HTMLDivElement>;
|
|
49
49
|
} & {
|
|
50
50
|
asChild?: boolean;
|
|
51
|
-
},
|
|
51
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "heading"> & {
|
|
52
52
|
heading?: React.ReactNode;
|
|
53
53
|
value?: string;
|
|
54
54
|
forceMount?: boolean;
|
|
55
55
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
56
|
-
declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
56
|
+
declare const CommandSeparator: React.ForwardRefExoticComponent<Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
57
57
|
ref?: React.Ref<HTMLDivElement>;
|
|
58
58
|
} & {
|
|
59
59
|
asChild?: boolean;
|
|
60
|
-
},
|
|
60
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
61
61
|
alwaysRender?: boolean;
|
|
62
62
|
} & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
63
63
|
declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
|
|
64
64
|
children?: React.ReactNode;
|
|
65
|
-
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement
|
|
65
|
+
} & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
66
66
|
ref?: React.Ref<HTMLDivElement>;
|
|
67
67
|
} & {
|
|
68
68
|
asChild?: boolean;
|
|
69
|
-
},
|
|
69
|
+
}, "key" | "asChild" | keyof React.HTMLAttributes<HTMLDivElement>>, "value" | "disabled" | "onSelect"> & {
|
|
70
70
|
disabled?: boolean;
|
|
71
71
|
onSelect?: (value: string) => void;
|
|
72
72
|
value?: string;
|