@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.
Files changed (100) hide show
  1. package/dist/components/forms/field-renderer.cjs +9 -5
  2. package/dist/components/forms/field-renderer.js +9 -5
  3. package/dist/components/forms/form-state-viewer.cjs +8 -4
  4. package/dist/components/forms/form-state-viewer.d.ts +1 -1
  5. package/dist/components/forms/form-state-viewer.js +8 -4
  6. package/dist/components/forms/metadata-form.cjs +129 -60
  7. package/dist/components/forms/metadata-form.js +121 -62
  8. package/dist/components/ui/avatar.d.ts +1 -1
  9. package/dist/components/ui/badge.d.ts +1 -1
  10. package/dist/components/ui/button.d.ts +2 -2
  11. package/dist/components/ui/command.d.ts +13 -13
  12. package/dist/components/ui/index.cjs +34 -34
  13. package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +101 -68
  14. package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +16 -2
  15. package/dist/components/ui/prompt-editor/components/EditorToolbar.js +101 -68
  16. package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +13 -8
  17. package/dist/components/ui/prompt-editor/components/MarkdownPreview.d.ts +13 -1
  18. package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +13 -8
  19. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.cjs +22 -11
  20. package/dist/components/ui/prompt-editor/components/PromptEditorAutocompleteMenu.js +23 -12
  21. package/dist/components/ui/prompt-editor/components/TokenPill.cjs +4 -2
  22. package/dist/components/ui/prompt-editor/components/TokenPill.js +4 -2
  23. package/dist/components/ui/prompt-editor/components/TokenPillSlot.cjs +58 -0
  24. package/dist/components/ui/prompt-editor/components/TokenPillSlot.d.ts +7 -0
  25. package/dist/components/ui/prompt-editor/components/TokenPillSlot.js +24 -0
  26. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.cjs +8 -9
  27. package/dist/components/ui/prompt-editor/components/TokenPillWithTooltip.js +8 -9
  28. package/dist/components/ui/prompt-editor/index.cjs +152 -9
  29. package/dist/components/ui/prompt-editor/index.d.ts +13 -1
  30. package/dist/components/ui/prompt-editor/index.js +11 -1
  31. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.cjs +2 -2
  32. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.d.ts +1 -1
  33. package/dist/components/ui/prompt-editor/nodes/InputTokenNode.js +2 -2
  34. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.cjs +2 -2
  35. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.d.ts +1 -1
  36. package/dist/components/ui/prompt-editor/nodes/OutputTokenNode.js +2 -2
  37. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.cjs +2 -2
  38. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.d.ts +1 -1
  39. package/dist/components/ui/prompt-editor/nodes/ResourceTokenNode.js +2 -2
  40. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.cjs +2 -2
  41. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.d.ts +1 -1
  42. package/dist/components/ui/prompt-editor/nodes/StateTokenNode.js +2 -2
  43. package/dist/components/ui/prompt-editor/nodes/index.cjs +1 -1
  44. package/dist/components/ui/prompt-editor/nodes/index.d.ts +5 -5
  45. package/dist/components/ui/prompt-editor/nodes/index.js +1 -1
  46. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.cjs +11 -5
  47. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.d.ts +8 -1
  48. package/dist/components/ui/prompt-editor/plugins/AutocompletePlugin.js +12 -6
  49. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.cjs +1 -1
  50. package/dist/components/ui/prompt-editor/plugins/CopyPastePlugin.js +1 -1
  51. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.cjs +1 -1
  52. package/dist/components/ui/prompt-editor/plugins/EditorRefPlugin.js +1 -1
  53. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.cjs +1 -1
  54. package/dist/components/ui/prompt-editor/plugins/MultilinePlugin.js +1 -1
  55. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.cjs +12 -6
  56. package/dist/components/ui/prompt-editor/plugins/NodeSelectionFixPlugin.js +13 -7
  57. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +64 -3
  58. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.d.ts +6 -2
  59. package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +65 -4
  60. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.cjs +4 -9
  61. package/dist/components/ui/prompt-editor/plugins/ValidateTokensPlugin.js +4 -9
  62. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.cjs +10 -5
  63. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.d.ts +3 -1
  64. package/dist/components/ui/prompt-editor/plugins/ValueSyncPlugin.js +10 -5
  65. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.cjs +1 -1
  66. package/dist/components/ui/prompt-editor/plugins/VariableDropPlugin.js +2 -2
  67. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.cjs +10 -1
  68. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.d.ts +4 -1
  69. package/dist/components/ui/prompt-editor/plugins/shared/token-nodes.js +8 -2
  70. package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +69 -0
  71. package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +70 -0
  72. package/dist/components/ui/prompt-editor/prompt-editor-config.js +29 -0
  73. package/dist/components/ui/prompt-editor/prompt-editor.cjs +198 -88
  74. package/dist/components/ui/prompt-editor/prompt-editor.d.ts +46 -1
  75. package/dist/components/ui/prompt-editor/prompt-editor.js +199 -89
  76. package/dist/components/ui/prompt-editor/types.cjs +5 -5
  77. package/dist/components/ui/prompt-editor/types.d.ts +18 -2
  78. package/dist/components/ui/prompt-editor/types.js +5 -5
  79. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.cjs +10 -5
  80. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.d.ts +13 -0
  81. package/dist/components/ui/prompt-editor/utils/autocomplete-segments.js +8 -6
  82. package/dist/components/ui/prompt-editor/utils/index.cjs +1 -1
  83. package/dist/components/ui/prompt-editor/utils/index.d.ts +1 -1
  84. package/dist/components/ui/prompt-editor/utils/index.js +1 -1
  85. package/dist/components/ui/prompt-editor/utils/insert-token.d.ts +1 -1
  86. package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +186 -0
  87. package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +38 -0
  88. package/dist/components/ui/prompt-editor/utils/rich-serialization.js +140 -0
  89. package/dist/components/ui/prompt-editor/utils/serialization.cjs +13 -5
  90. package/dist/components/ui/prompt-editor/utils/serialization.js +14 -6
  91. package/dist/components/ui/sheet.d.ts +1 -1
  92. package/dist/components/ui/spinner.d.ts +1 -1
  93. package/dist/components/ui/switch.d.ts +2 -2
  94. package/dist/components/ui/toggle-group.d.ts +2 -2
  95. package/dist/components/ui/toggle.d.ts +2 -2
  96. package/dist/index.cjs +136 -61
  97. package/dist/index.d.ts +89 -89
  98. package/dist/index.js +61 -61
  99. package/dist/styles.css +15 -0
  100. package/package.json +3 -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 (!(0, external_form_schema_cjs_namespaceObject.hasOptions)(field)) return;
138
- const inlineOptions = field.options || [];
139
+ if (!isOptionsField) return;
140
+ const nextOptions = inlineOptions || [];
139
141
  setFieldState((prev)=>{
140
- if ((0, index_cjs_namespaceObject.deepEqual)(prev.options, inlineOptions)) return prev;
142
+ if ((0, index_cjs_namespaceObject.deepEqual)(prev.options, nextOptions)) return prev;
141
143
  return {
142
144
  ...prev,
143
- options: inlineOptions
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 (!hasOptions(field)) return;
110
- const inlineOptions = field.options || [];
111
+ if (!isOptionsField) return;
112
+ const nextOptions = inlineOptions || [];
111
113
  setFieldState((prev)=>{
112
- if (deepEqual(prev.options, inlineOptions)) return prev;
114
+ if (deepEqual(prev.options, nextOptions)) return prev;
113
115
  return {
114
116
  ...prev,
115
- options: inlineOptions
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 external_lucide_react_namespaceObject = require("lucide-react");
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, watch } = form;
39
- const values = watch();
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,4 +1,4 @@
1
- import type { UseFormReturn, FieldValues } from 'react-hook-form';
1
+ import { type FieldValues, type UseFormReturn } from 'react-hook-form';
2
2
  /**
3
3
  * FormStateViewer Component
4
4
  *
@@ -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 { AlertCircle, CheckCircle2, Database, Eye, FileEdit, XCircle } from "lucide-react";
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, watch } = form;
11
- const values = watch();
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 zodSchema = (0, external_react_namespaceObject.useMemo)(()=>buildZodSchema(schema), [
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
- mode: schema.mode || 'onSubmit',
52
- reValidateMode: schema.reValidateMode || 'onChange'
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 watchedValues = watch();
57
- valuesRef.current = watchedValues;
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: schema.steps ? currentStep : void 0,
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
- schema,
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 (schema.initialData) {
96
- const data = await loadInitialData(schema.initialData, contextRef.current);
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.useEffect)(()=>{
107
- if (!isInitialized) return;
108
- const subscription = watch((value, { name })=>{
109
- if (name) {
110
- valuesRef.current = value;
111
- plugins.forEach((plugin)=>{
112
- plugin.onValueChange?.(name, value[name], contextRef.current);
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 (schema.steps) {
153
+ if (stableSchema.steps) {
129
154
  if ('tabs' === stepVariant) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabbedStepForm, {
130
- schema: 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: ()=>reset()
162
+ onReset: handleReset
138
163
  });
139
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MultiStepForm, {
140
- schema: 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)(SinglePageForm, {
150
- schema: 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
- !schema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FormActions, {
166
- schema: schema,
190
+ !stableSchema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
191
+ schema: stableSchema,
167
192
  context: context,
168
- onReset: ()=>reset()
193
+ onReset: handleReset
169
194
  })
170
195
  ]
171
196
  })
172
197
  });
173
198
  }
174
- function SinglePageForm({ schema, context, customComponents, disabled, sectionVariant }) {
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)(FormSection, {
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
- function MultiStepForm({ schema, context, currentStep, setCurrentStep, customComponents, disabled, sectionVariant }) {
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 step = steps[currentStep];
191
- if (!step) return null;
192
- if (step.conditions && !context.evaluateConditions(step.conditions)) {
193
- if (currentStep < steps.length - 1) setCurrentStep(currentStep + 1);
194
- return null;
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)(FormSection, {
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)(FormSection, {
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)(FormActions, {
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
- function FormSection({ section, context, customComponents, disabled, sectionVariant = 'card' }) {
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
- function FormActions({ schema, context, onReset }) {
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 && context.isSubmitting,
459
- children: action.loading && context.isSubmitting ? 'Loading...' : action.label
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) || [];