@uipath/apollo-wind 2.50.0 → 2.52.0
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 +80 -6
- package/dist/components/forms/field-renderer.js +80 -6
- package/dist/components/forms/form-designer.cjs +10 -10
- package/dist/components/forms/form-designer.js +10 -10
- package/dist/components/forms/form-schema.d.ts +38 -2
- package/dist/components/forms/index.cjs +15 -5
- package/dist/components/forms/index.d.ts +7 -6
- package/dist/components/forms/index.js +6 -5
- package/dist/components/forms/metadata-form.cjs +97 -37
- package/dist/components/forms/metadata-form.d.ts +11 -3
- package/dist/components/forms/metadata-form.js +94 -37
- package/dist/components/forms/rules-engine.cjs +14 -3
- package/dist/components/forms/rules-engine.d.ts +16 -0
- package/dist/components/forms/rules-engine.js +14 -3
- package/dist/components/forms/schema-serializer.cjs +10 -0
- package/dist/components/forms/schema-serializer.js +10 -0
- package/dist/components/forms/string-list-field.cjs +154 -0
- package/dist/components/forms/string-list-field.d.ts +29 -0
- package/dist/components/forms/string-list-field.js +117 -0
- package/dist/components/forms/validation-converter.cjs +68 -23
- package/dist/components/forms/validation-converter.d.ts +23 -2
- package/dist/components/forms/validation-converter.js +64 -22
- package/dist/components/ui/datetime-picker.cjs +3 -1
- package/dist/components/ui/datetime-picker.d.ts +4 -0
- package/dist/components/ui/datetime-picker.js +3 -1
- package/dist/components/ui/form-field.cjs +17 -2
- package/dist/components/ui/form-field.d.ts +7 -0
- package/dist/components/ui/form-field.js +17 -2
- package/dist/components/ui/index.cjs +124 -114
- package/dist/components/ui/index.d.ts +3 -2
- package/dist/components/ui/index.js +2 -1
- package/dist/components/ui/info-tooltip.cjs +61 -0
- package/dist/components/ui/info-tooltip.d.ts +10 -0
- package/dist/components/ui/info-tooltip.js +27 -0
- package/dist/components/ui/prompt-editor/components/EditorToolbar.cjs +18 -2
- package/dist/components/ui/prompt-editor/components/EditorToolbar.d.ts +3 -1
- package/dist/components/ui/prompt-editor/components/EditorToolbar.js +19 -3
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.cjs +4 -2
- package/dist/components/ui/prompt-editor/components/MarkdownPreview.js +4 -2
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.cjs +14 -4
- package/dist/components/ui/prompt-editor/plugins/ToolbarActionsPlugin.js +14 -4
- package/dist/components/ui/prompt-editor/prompt-editor-config.cjs +2 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.d.ts +2 -0
- package/dist/components/ui/prompt-editor/prompt-editor-config.js +2 -0
- package/dist/components/ui/prompt-editor/prompt-editor.cjs +10 -1
- package/dist/components/ui/prompt-editor/prompt-editor.js +10 -1
- package/dist/components/ui/prompt-editor/types.d.ts +7 -1
- package/dist/components/ui/prompt-editor/utils/rich-serialization.cjs +48 -1
- package/dist/components/ui/prompt-editor/utils/rich-serialization.d.ts +0 -14
- package/dist/components/ui/prompt-editor/utils/rich-serialization.js +50 -3
- package/dist/components/ui/select.cjs +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/textarea.cjs +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/index.cjs +14 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -2
- package/dist/styles.css +13 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FieldValues, UseFormReturn } from 'react-hook-form';
|
|
2
2
|
/**
|
|
3
3
|
* Core Schema Types for Apollo-Wind Metadata Forms
|
|
4
4
|
* Designed for enterprise automation workflows with extensibility
|
|
@@ -148,6 +148,10 @@ interface BaseFieldMetadata {
|
|
|
148
148
|
grid?: GridConfig;
|
|
149
149
|
ariaLabel?: string;
|
|
150
150
|
ariaDescribedBy?: string;
|
|
151
|
+
/** Info tooltip rendered next to the field label. */
|
|
152
|
+
tooltip?: string;
|
|
153
|
+
/** Accessible name of the tooltip trigger (default 'More information'). */
|
|
154
|
+
tooltipAriaLabel?: string;
|
|
151
155
|
}
|
|
152
156
|
export interface TextFieldMetadata extends BaseFieldMetadata {
|
|
153
157
|
type: 'text';
|
|
@@ -158,6 +162,10 @@ export interface EmailFieldMetadata extends BaseFieldMetadata {
|
|
|
158
162
|
export interface TextareaFieldMetadata extends BaseFieldMetadata {
|
|
159
163
|
type: 'textarea';
|
|
160
164
|
rows?: number;
|
|
165
|
+
/** Autosize floor in rows; takes precedence over `rows` when set. */
|
|
166
|
+
minRows?: number;
|
|
167
|
+
/** DOM maxLength character cap. */
|
|
168
|
+
maxLength?: number;
|
|
161
169
|
}
|
|
162
170
|
export interface NumberFieldMetadata extends BaseFieldMetadata {
|
|
163
171
|
type: 'number';
|
|
@@ -173,6 +181,10 @@ export interface MultiSelectFieldMetadata extends BaseFieldMetadata {
|
|
|
173
181
|
type: 'multiselect';
|
|
174
182
|
options?: FieldOption[];
|
|
175
183
|
maxSelected?: number;
|
|
184
|
+
/** Shown when the search matches nothing (default 'No items found.'). */
|
|
185
|
+
emptyMessage?: string;
|
|
186
|
+
/** Placeholder of the search input (default 'Search...'). */
|
|
187
|
+
searchPlaceholder?: string;
|
|
176
188
|
}
|
|
177
189
|
export interface RadioFieldMetadata extends BaseFieldMetadata {
|
|
178
190
|
type: 'radio';
|
|
@@ -220,16 +232,40 @@ export interface FileFieldMetadata extends BaseFieldMetadata {
|
|
|
220
232
|
maxSize?: number;
|
|
221
233
|
showPreview?: boolean;
|
|
222
234
|
}
|
|
235
|
+
export interface StringListFieldMetadata extends BaseFieldMetadata {
|
|
236
|
+
type: 'string-list';
|
|
237
|
+
/** Cap on how many rows can be added; the Add button hides at the cap. */
|
|
238
|
+
maxItems?: number;
|
|
239
|
+
/** Per-row character cap (DOM maxLength on each row's textarea). */
|
|
240
|
+
maxLength?: number;
|
|
241
|
+
/** Autosize floor for each row's textarea (default 2). */
|
|
242
|
+
minRows?: number;
|
|
243
|
+
/** Label of the Add button (default 'Add'). */
|
|
244
|
+
addItemLabel?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Aria-label template of each row's remove button; `{{label}}` and `{{position}}` are
|
|
247
|
+
* interpolated (default 'Remove {{label}} {{position}}').
|
|
248
|
+
*/
|
|
249
|
+
removeItemAriaLabel?: string;
|
|
250
|
+
}
|
|
251
|
+
/** Value shapes a `type: 'custom'` field can declare so metadata constraints apply to it. */
|
|
252
|
+
export type CustomValueType = 'string' | 'number' | 'boolean' | 'string-array';
|
|
223
253
|
export interface CustomFieldMetadata extends BaseFieldMetadata {
|
|
224
254
|
type: 'custom';
|
|
225
255
|
component: string;
|
|
226
256
|
componentProps?: Record<string, unknown>;
|
|
257
|
+
/**
|
|
258
|
+
* Shape of the value the component owns. Without it the field validates as `z.any()`, so
|
|
259
|
+
* `required` (and `minItems` for lists) silently does nothing — declare it and the normal
|
|
260
|
+
* metadata constraints apply to custom components like any other field.
|
|
261
|
+
*/
|
|
262
|
+
valueType?: CustomValueType;
|
|
227
263
|
}
|
|
228
264
|
/**
|
|
229
265
|
* Discriminated union of all field types
|
|
230
266
|
* TypeScript will enforce that only valid properties exist for each type
|
|
231
267
|
*/
|
|
232
|
-
export type FieldMetadata = TextFieldMetadata | EmailFieldMetadata | TextareaFieldMetadata | NumberFieldMetadata | SelectFieldMetadata | MultiSelectFieldMetadata | RadioFieldMetadata | CheckboxFieldMetadata | SwitchFieldMetadata | SliderFieldMetadata | DateFieldMetadata | DateTimeFieldMetadata | FileFieldMetadata | CustomFieldMetadata;
|
|
268
|
+
export type FieldMetadata = TextFieldMetadata | EmailFieldMetadata | TextareaFieldMetadata | NumberFieldMetadata | SelectFieldMetadata | MultiSelectFieldMetadata | RadioFieldMetadata | CheckboxFieldMetadata | SwitchFieldMetadata | SliderFieldMetadata | DateFieldMetadata | DateTimeFieldMetadata | FileFieldMetadata | StringListFieldMetadata | CustomFieldMetadata;
|
|
233
269
|
/**
|
|
234
270
|
* Extract the field type from FieldMetadata
|
|
235
271
|
*/
|
|
@@ -24,10 +24,12 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
useWatch: ()=>external_metadata_form_cjs_namespaceObject.useWatch,
|
|
27
28
|
formattingPlugin: ()=>external_form_plugins_cjs_namespaceObject.formattingPlugin,
|
|
28
29
|
isCustomField: ()=>external_form_schema_cjs_namespaceObject.isCustomField,
|
|
29
30
|
isFileField: ()=>external_form_schema_cjs_namespaceObject.isFileField,
|
|
30
31
|
validationPlugin: ()=>external_form_plugins_cjs_namespaceObject.validationPlugin,
|
|
32
|
+
StringListField: ()=>external_string_list_field_cjs_namespaceObject.StringListField,
|
|
31
33
|
FormFieldRenderer: ()=>external_field_renderer_cjs_namespaceObject.FormFieldRenderer,
|
|
32
34
|
analyticsPlugin: ()=>external_form_plugins_cjs_namespaceObject.analyticsPlugin,
|
|
33
35
|
MetadataForm: ()=>external_metadata_form_cjs_namespaceObject.MetadataForm,
|
|
@@ -36,24 +38,26 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
36
38
|
DataTransformers: ()=>external_data_fetcher_cjs_namespaceObject.DataTransformers,
|
|
37
39
|
FetchAdapter: ()=>external_data_fetcher_cjs_namespaceObject.FetchAdapter,
|
|
38
40
|
FormStateViewer: ()=>external_form_state_viewer_cjs_namespaceObject.FormStateViewer,
|
|
41
|
+
formatTemplate: ()=>external_string_list_field_cjs_namespaceObject.formatTemplate,
|
|
39
42
|
RulesEngine: ()=>external_rules_engine_cjs_namespaceObject.RulesEngine,
|
|
40
43
|
RuleBuilder: ()=>external_rules_engine_cjs_namespaceObject.RuleBuilder,
|
|
41
44
|
auditPlugin: ()=>external_form_plugins_cjs_namespaceObject.auditPlugin,
|
|
42
45
|
FormDesigner: ()=>external_form_designer_cjs_namespaceObject.FormDesigner,
|
|
43
|
-
autoSavePlugin: ()=>external_form_plugins_cjs_namespaceObject.autoSavePlugin,
|
|
44
46
|
DataSourceBuilder: ()=>external_data_fetcher_cjs_namespaceObject.DataSourceBuilder,
|
|
45
47
|
ExpressionBuilder: ()=>external_rules_engine_cjs_namespaceObject.ExpressionBuilder,
|
|
48
|
+
autoSavePlugin: ()=>external_form_plugins_cjs_namespaceObject.autoSavePlugin,
|
|
46
49
|
hasMinMaxStep: ()=>external_form_schema_cjs_namespaceObject.hasMinMaxStep,
|
|
47
50
|
workflowPlugin: ()=>external_form_plugins_cjs_namespaceObject.workflowPlugin
|
|
48
51
|
});
|
|
49
|
-
const
|
|
52
|
+
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
50
53
|
const external_field_renderer_cjs_namespaceObject = require("./field-renderer.cjs");
|
|
51
54
|
const external_form_designer_cjs_namespaceObject = require("./form-designer.cjs");
|
|
52
|
-
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
53
|
-
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
54
|
-
const external_form_state_viewer_cjs_namespaceObject = require("./form-state-viewer.cjs");
|
|
55
55
|
const external_form_plugins_cjs_namespaceObject = require("./form-plugins.cjs");
|
|
56
56
|
const external_form_schema_cjs_namespaceObject = require("./form-schema.cjs");
|
|
57
|
+
const external_form_state_viewer_cjs_namespaceObject = require("./form-state-viewer.cjs");
|
|
58
|
+
const external_metadata_form_cjs_namespaceObject = require("./metadata-form.cjs");
|
|
59
|
+
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
60
|
+
const external_string_list_field_cjs_namespaceObject = require("./string-list-field.cjs");
|
|
57
61
|
exports.DataFetcher = __webpack_exports__.DataFetcher;
|
|
58
62
|
exports.DataSourceBuilder = __webpack_exports__.DataSourceBuilder;
|
|
59
63
|
exports.DataTransformers = __webpack_exports__.DataTransformers;
|
|
@@ -65,14 +69,17 @@ exports.FormStateViewer = __webpack_exports__.FormStateViewer;
|
|
|
65
69
|
exports.MetadataForm = __webpack_exports__.MetadataForm;
|
|
66
70
|
exports.RuleBuilder = __webpack_exports__.RuleBuilder;
|
|
67
71
|
exports.RulesEngine = __webpack_exports__.RulesEngine;
|
|
72
|
+
exports.StringListField = __webpack_exports__.StringListField;
|
|
68
73
|
exports.analyticsPlugin = __webpack_exports__.analyticsPlugin;
|
|
69
74
|
exports.auditPlugin = __webpack_exports__.auditPlugin;
|
|
70
75
|
exports.autoSavePlugin = __webpack_exports__.autoSavePlugin;
|
|
76
|
+
exports.formatTemplate = __webpack_exports__.formatTemplate;
|
|
71
77
|
exports.formattingPlugin = __webpack_exports__.formattingPlugin;
|
|
72
78
|
exports.hasMinMaxStep = __webpack_exports__.hasMinMaxStep;
|
|
73
79
|
exports.hasOptions = __webpack_exports__.hasOptions;
|
|
74
80
|
exports.isCustomField = __webpack_exports__.isCustomField;
|
|
75
81
|
exports.isFileField = __webpack_exports__.isFileField;
|
|
82
|
+
exports.useWatch = __webpack_exports__.useWatch;
|
|
76
83
|
exports.validationPlugin = __webpack_exports__.validationPlugin;
|
|
77
84
|
exports.workflowPlugin = __webpack_exports__.workflowPlugin;
|
|
78
85
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -87,14 +94,17 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
87
94
|
"MetadataForm",
|
|
88
95
|
"RuleBuilder",
|
|
89
96
|
"RulesEngine",
|
|
97
|
+
"StringListField",
|
|
90
98
|
"analyticsPlugin",
|
|
91
99
|
"auditPlugin",
|
|
92
100
|
"autoSavePlugin",
|
|
101
|
+
"formatTemplate",
|
|
93
102
|
"formattingPlugin",
|
|
94
103
|
"hasMinMaxStep",
|
|
95
104
|
"hasOptions",
|
|
96
105
|
"isCustomField",
|
|
97
106
|
"isFileField",
|
|
107
|
+
"useWatch",
|
|
98
108
|
"validationPlugin",
|
|
99
109
|
"workflowPlugin"
|
|
100
110
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* Apollo-Wind Metadata Forms
|
|
3
3
|
* Enterprise-grade metadata-driven form system
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { type AdapterRequest, type AdapterResponse, type DataAdapter, DataFetcher, DataSourceBuilder, DataTransformers, FetchAdapter, } from './data-fetcher';
|
|
6
6
|
export { FormFieldRenderer } from './field-renderer';
|
|
7
7
|
export { FormDesigner } from './form-designer';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
8
|
+
export { analyticsPlugin, auditPlugin, autoSavePlugin, formattingPlugin, validationPlugin, workflowPlugin, } from './form-plugins';
|
|
9
|
+
export type { CustomFieldComponentProps, CustomValueType, DataSource, FieldCondition, FieldMetadata, FieldOption, FieldRule, FieldType, FormAction, FormContext, FormPlugin, FormSchema, FormSection, FormStep, StringListFieldMetadata, } from './form-schema';
|
|
10
|
+
export { hasMinMaxStep, hasOptions, isCustomField, isFileField, } from './form-schema';
|
|
10
11
|
export { FormStateViewer } from './form-state-viewer';
|
|
11
|
-
export {
|
|
12
|
-
export
|
|
13
|
-
export {
|
|
12
|
+
export { MetadataForm, type MetadataFormProps, useWatch } from './metadata-form';
|
|
13
|
+
export { ExpressionBuilder, RuleBuilder, RulesEngine } from './rules-engine';
|
|
14
|
+
export { formatTemplate, StringListField, type StringListFieldProps } from './string-list-field';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataFetcher, DataSourceBuilder, DataTransformers, FetchAdapter } from "./data-fetcher.js";
|
|
2
2
|
import { FormFieldRenderer } from "./field-renderer.js";
|
|
3
3
|
import { FormDesigner } from "./form-designer.js";
|
|
4
|
-
import { ExpressionBuilder, RuleBuilder, RulesEngine } from "./rules-engine.js";
|
|
5
|
-
import { DataFetcher, DataSourceBuilder, DataTransformers, FetchAdapter } from "./data-fetcher.js";
|
|
6
|
-
import { FormStateViewer } from "./form-state-viewer.js";
|
|
7
4
|
import { analyticsPlugin, auditPlugin, autoSavePlugin, formattingPlugin, validationPlugin, workflowPlugin } from "./form-plugins.js";
|
|
8
5
|
import { hasMinMaxStep, hasOptions, isCustomField, isFileField } from "./form-schema.js";
|
|
9
|
-
|
|
6
|
+
import { FormStateViewer } from "./form-state-viewer.js";
|
|
7
|
+
import { MetadataForm, useWatch } from "./metadata-form.js";
|
|
8
|
+
import { ExpressionBuilder, RuleBuilder, RulesEngine } from "./rules-engine.js";
|
|
9
|
+
import { StringListField, formatTemplate } from "./string-list-field.js";
|
|
10
|
+
export { DataFetcher, DataSourceBuilder, DataTransformers, ExpressionBuilder, FetchAdapter, FormDesigner, FormFieldRenderer, FormStateViewer, MetadataForm, RuleBuilder, RulesEngine, StringListField, analyticsPlugin, auditPlugin, autoSavePlugin, formatTemplate, formattingPlugin, hasMinMaxStep, hasOptions, isCustomField, isFileField, useWatch, validationPlugin, workflowPlugin };
|
|
@@ -33,7 +33,8 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
MetadataForm: ()=>MetadataForm
|
|
36
|
+
MetadataForm: ()=>MetadataForm,
|
|
37
|
+
useWatch: ()=>external_react_hook_form_namespaceObject.useWatch
|
|
37
38
|
});
|
|
38
39
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
39
40
|
const standard_schema_namespaceObject = require("@hookform/resolvers/standard-schema");
|
|
@@ -44,13 +45,14 @@ const v4_namespaceObject = require("zod/v4");
|
|
|
44
45
|
const accordion_cjs_namespaceObject = require("../ui/accordion.cjs");
|
|
45
46
|
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
46
47
|
const tabs_cjs_namespaceObject = require("../ui/tabs.cjs");
|
|
48
|
+
const tooltip_cjs_namespaceObject = require("../ui/tooltip.cjs");
|
|
47
49
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
48
50
|
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
49
51
|
const external_field_renderer_cjs_namespaceObject = require("./field-renderer.cjs");
|
|
50
52
|
const external_rules_engine_cjs_namespaceObject = require("./rules-engine.cjs");
|
|
51
53
|
const external_validation_converter_cjs_namespaceObject = require("./validation-converter.cjs");
|
|
52
54
|
const DEFAULT_PLUGINS = [];
|
|
53
|
-
function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete, stepVariant = 'wizard', sectionVariant = 'card', activeStepId, onActiveStepChange }) {
|
|
55
|
+
function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete, stepVariant = 'wizard', sectionVariant = 'card', activeStepId, onActiveStepChange, container = 'form' }) {
|
|
54
56
|
const [currentStep, setCurrentStep] = (0, external_react_namespaceObject.useState)(0);
|
|
55
57
|
const [customComponents, setCustomComponents] = (0, external_react_namespaceObject.useState)({});
|
|
56
58
|
const [isInitialized, setIsInitialized] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -62,6 +64,15 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
62
64
|
}, [
|
|
63
65
|
schema
|
|
64
66
|
]);
|
|
67
|
+
const hasFieldTooltip = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
68
|
+
const sections = [
|
|
69
|
+
...stableSchema.sections ?? [],
|
|
70
|
+
...(stableSchema.steps ?? []).flatMap((step)=>step.sections)
|
|
71
|
+
];
|
|
72
|
+
return sections.some((section)=>section.fields.some((field)=>void 0 !== field.tooltip));
|
|
73
|
+
}, [
|
|
74
|
+
stableSchema
|
|
75
|
+
]);
|
|
65
76
|
const zodSchema = (0, external_react_namespaceObject.useMemo)(()=>buildZodSchema(stableSchema), [
|
|
66
77
|
stableSchema
|
|
67
78
|
]);
|
|
@@ -111,12 +122,12 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
111
122
|
]);
|
|
112
123
|
const contextRef = (0, external_react_namespaceObject.useRef)(context);
|
|
113
124
|
contextRef.current = context;
|
|
114
|
-
const
|
|
115
|
-
isInitializedRef.current = isInitialized;
|
|
125
|
+
const initializingRef = (0, external_react_namespaceObject.useRef)(false);
|
|
116
126
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
117
127
|
const subscription = watch((value, { name })=>{
|
|
118
128
|
valuesRef.current = value;
|
|
119
|
-
if (!name
|
|
129
|
+
if (!name) return;
|
|
130
|
+
if (initializingRef.current) return;
|
|
120
131
|
pluginsRef.current.forEach((plugin)=>{
|
|
121
132
|
plugin.onValueChange?.(name, (0, index_cjs_namespaceObject.get)(value, name), contextRef.current);
|
|
122
133
|
});
|
|
@@ -130,9 +141,17 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
130
141
|
const initializeForm = async ()=>{
|
|
131
142
|
if (stableSchema.initialData) {
|
|
132
143
|
const data = await loadInitialData(stableSchema.initialData, contextRef.current);
|
|
133
|
-
|
|
144
|
+
initializingRef.current = true;
|
|
145
|
+
try {
|
|
146
|
+
reset(data);
|
|
147
|
+
} finally{
|
|
148
|
+
initializingRef.current = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
for (const plugin of plugins){
|
|
152
|
+
const result = plugin.onFormInit?.(contextRef.current);
|
|
153
|
+
if (result instanceof Promise) await result;
|
|
134
154
|
}
|
|
135
|
-
for (const plugin of plugins)await plugin.onFormInit?.(contextRef.current);
|
|
136
155
|
setIsInitialized(true);
|
|
137
156
|
};
|
|
138
157
|
initializeForm();
|
|
@@ -149,51 +168,89 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
149
168
|
const handleReset = (0, external_react_namespaceObject.useCallback)(()=>reset(), [
|
|
150
169
|
reset
|
|
151
170
|
]);
|
|
171
|
+
const allCustomComponents = (0, external_react_namespaceObject.useMemo)(()=>{
|
|
172
|
+
const fromPlugins = {};
|
|
173
|
+
for (const plugin of plugins)Object.assign(fromPlugins, plugin.components);
|
|
174
|
+
return {
|
|
175
|
+
...fromPlugins,
|
|
176
|
+
...customComponents
|
|
177
|
+
};
|
|
178
|
+
}, [
|
|
179
|
+
plugins,
|
|
180
|
+
customComponents
|
|
181
|
+
]);
|
|
182
|
+
const enterSwallowRef = (0, external_react_namespaceObject.useRef)(null);
|
|
183
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
184
|
+
const node = enterSwallowRef.current;
|
|
185
|
+
if (!node) return;
|
|
186
|
+
const swallowEnter = (event)=>{
|
|
187
|
+
if ('Enter' !== event.key || event.defaultPrevented) return;
|
|
188
|
+
const target = event.target;
|
|
189
|
+
if (target instanceof HTMLInputElement && 'button' !== target.type) event.preventDefault();
|
|
190
|
+
};
|
|
191
|
+
node.addEventListener('keydown', swallowEnter);
|
|
192
|
+
return ()=>node.removeEventListener('keydown', swallowEnter);
|
|
193
|
+
}, [
|
|
194
|
+
container
|
|
195
|
+
]);
|
|
152
196
|
const renderContent = ()=>{
|
|
153
197
|
if (stableSchema.steps) {
|
|
154
198
|
if ('tabs' === stepVariant) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TabbedStepForm, {
|
|
155
199
|
schema: stableSchema,
|
|
156
200
|
context: context,
|
|
157
|
-
customComponents:
|
|
201
|
+
customComponents: allCustomComponents,
|
|
158
202
|
disabled: disabled,
|
|
159
203
|
sectionVariant: sectionVariant,
|
|
160
204
|
activeStepId: activeStepId,
|
|
161
205
|
onActiveStepChange: onActiveStepChange,
|
|
162
|
-
onReset: handleReset
|
|
206
|
+
onReset: handleReset,
|
|
207
|
+
onSubmit: 'div' === container ? handleFormSubmit : void 0
|
|
163
208
|
});
|
|
164
209
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_MultiStepForm, {
|
|
165
210
|
schema: stableSchema,
|
|
166
211
|
context: context,
|
|
167
212
|
currentStep: currentStep,
|
|
168
213
|
setCurrentStep: setCurrentStep,
|
|
169
|
-
customComponents:
|
|
214
|
+
customComponents: allCustomComponents,
|
|
170
215
|
disabled: disabled,
|
|
171
|
-
sectionVariant: sectionVariant
|
|
216
|
+
sectionVariant: sectionVariant,
|
|
217
|
+
onSubmit: 'div' === container ? handleFormSubmit : void 0
|
|
172
218
|
});
|
|
173
219
|
}
|
|
174
220
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_SinglePageForm, {
|
|
175
221
|
schema: stableSchema,
|
|
176
222
|
context: context,
|
|
177
|
-
customComponents:
|
|
223
|
+
customComponents: allCustomComponents,
|
|
178
224
|
disabled: disabled,
|
|
179
225
|
sectionVariant: sectionVariant
|
|
180
226
|
});
|
|
181
227
|
};
|
|
228
|
+
const content = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
229
|
+
children: [
|
|
230
|
+
renderContent(),
|
|
231
|
+
!stableSchema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
|
|
232
|
+
schema: stableSchema,
|
|
233
|
+
context: context,
|
|
234
|
+
onReset: handleReset,
|
|
235
|
+
onSubmit: 'div' === container ? handleFormSubmit : void 0
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
});
|
|
239
|
+
const body = 'div' === container ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
240
|
+
className: className,
|
|
241
|
+
ref: enterSwallowRef,
|
|
242
|
+
children: content
|
|
243
|
+
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("form", {
|
|
244
|
+
onSubmit: handleFormSubmit,
|
|
245
|
+
className: className,
|
|
246
|
+
autoComplete: autoComplete,
|
|
247
|
+
children: content
|
|
248
|
+
});
|
|
182
249
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.FormProvider, {
|
|
183
250
|
...form,
|
|
184
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
autoComplete: autoComplete,
|
|
188
|
-
children: [
|
|
189
|
-
renderContent(),
|
|
190
|
-
!stableSchema.steps && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
|
|
191
|
-
schema: stableSchema,
|
|
192
|
-
context: context,
|
|
193
|
-
onReset: handleReset
|
|
194
|
-
})
|
|
195
|
-
]
|
|
196
|
-
})
|
|
251
|
+
children: hasFieldTooltip ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(tooltip_cjs_namespaceObject.TooltipProvider, {
|
|
252
|
+
children: body
|
|
253
|
+
}) : body
|
|
197
254
|
});
|
|
198
255
|
}
|
|
199
256
|
function conditionDependencies(conditionGroups) {
|
|
@@ -225,7 +282,7 @@ const metadata_form_SinglePageForm = /*#__PURE__*/ external_react_default().memo
|
|
|
225
282
|
}, section.id))
|
|
226
283
|
});
|
|
227
284
|
});
|
|
228
|
-
const metadata_form_MultiStepForm = /*#__PURE__*/ external_react_default().memo(function({ schema, context, currentStep, setCurrentStep, customComponents, disabled, sectionVariant }) {
|
|
285
|
+
const metadata_form_MultiStepForm = /*#__PURE__*/ external_react_default().memo(function({ schema, context, currentStep, setCurrentStep, customComponents, disabled, sectionVariant, onSubmit }) {
|
|
229
286
|
const steps = schema.steps || [];
|
|
230
287
|
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.steps?.map((step)=>step.conditions) ?? []), [
|
|
231
288
|
schema
|
|
@@ -303,7 +360,8 @@ const metadata_form_MultiStepForm = /*#__PURE__*/ external_react_default().memo(
|
|
|
303
360
|
variant: "default",
|
|
304
361
|
children: "Next"
|
|
305
362
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
306
|
-
type:
|
|
363
|
+
type: onSubmit ? 'button' : 'submit',
|
|
364
|
+
onClick: onSubmit,
|
|
307
365
|
variant: "default",
|
|
308
366
|
children: "Submit"
|
|
309
367
|
})
|
|
@@ -312,7 +370,7 @@ const metadata_form_MultiStepForm = /*#__PURE__*/ external_react_default().memo(
|
|
|
312
370
|
]
|
|
313
371
|
});
|
|
314
372
|
});
|
|
315
|
-
function TabbedStepForm({ schema, context, customComponents, disabled, sectionVariant, onReset, activeStepId, onActiveStepChange }) {
|
|
373
|
+
function TabbedStepForm({ schema, context, customComponents, disabled, sectionVariant, onReset, activeStepId, onActiveStepChange, onSubmit }) {
|
|
316
374
|
const steps = schema.steps || [];
|
|
317
375
|
const conditionFields = (0, external_react_namespaceObject.useMemo)(()=>conditionDependencies(schema.steps?.flatMap((step)=>[
|
|
318
376
|
step.conditions,
|
|
@@ -378,7 +436,7 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
378
436
|
role: "img",
|
|
379
437
|
"aria-label": `${errorCount} ${1 === errorCount ? 'issue' : 'issues'}`,
|
|
380
438
|
title: `${errorCount} ${1 === errorCount ? 'issue' : 'issues'}`,
|
|
381
|
-
className: "grid h-4 min-w-4 place-items-center rounded-full bg-error px-1 text-[10px] font-semibold leading-none text-
|
|
439
|
+
className: "grid h-4 min-w-4 place-items-center rounded-full bg-error px-1 text-[10px] font-semibold leading-none text-error-background",
|
|
382
440
|
children: errorCount
|
|
383
441
|
})
|
|
384
442
|
]
|
|
@@ -411,7 +469,8 @@ function TabbedStepForm({ schema, context, customComponents, disabled, sectionVa
|
|
|
411
469
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(metadata_form_FormActions, {
|
|
412
470
|
schema: schema,
|
|
413
471
|
context: context,
|
|
414
|
-
onReset: onReset
|
|
472
|
+
onReset: onReset,
|
|
473
|
+
onSubmit: onSubmit
|
|
415
474
|
})
|
|
416
475
|
]
|
|
417
476
|
});
|
|
@@ -493,7 +552,7 @@ const metadata_form_FormSection = /*#__PURE__*/ external_react_default().memo(fu
|
|
|
493
552
|
]
|
|
494
553
|
});
|
|
495
554
|
});
|
|
496
|
-
const metadata_form_FormActions = /*#__PURE__*/ external_react_default().memo(function({ schema, context, onReset }) {
|
|
555
|
+
const metadata_form_FormActions = /*#__PURE__*/ external_react_default().memo(function({ schema, context, onReset, onSubmit }) {
|
|
497
556
|
const { isSubmitting } = (0, external_react_hook_form_namespaceObject.useFormState)({
|
|
498
557
|
control: context.form.control
|
|
499
558
|
});
|
|
@@ -522,7 +581,8 @@ const metadata_form_FormActions = /*#__PURE__*/ external_react_default().memo(fu
|
|
|
522
581
|
children: action.label
|
|
523
582
|
}, action.id);
|
|
524
583
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
525
|
-
type: 'submit'
|
|
584
|
+
type: 'submit' !== action.type || onSubmit ? 'button' : 'submit',
|
|
585
|
+
onClick: 'submit' === action.type && onSubmit ? onSubmit : void 0,
|
|
526
586
|
variant: action.variant || 'default',
|
|
527
587
|
disabled: action.disabled || 'submit' === action.type && isSubmitting,
|
|
528
588
|
children: action.loading && isSubmitting ? 'Loading...' : action.label
|
|
@@ -553,7 +613,7 @@ function buildZodSchema(schema) {
|
|
|
553
613
|
} : shouldIncludeRequiredInBase ? {
|
|
554
614
|
required: true
|
|
555
615
|
} : void 0;
|
|
556
|
-
shape[field.name] = (0, external_validation_converter_cjs_namespaceObject.validationConfigToZod)(validationConfig, field.type);
|
|
616
|
+
shape[field.name] = (0, external_validation_converter_cjs_namespaceObject.validationConfigToZod)(validationConfig, field.type, 'custom' === field.type ? field.valueType : void 0);
|
|
557
617
|
});
|
|
558
618
|
const baseSchema = v4_namespaceObject.z.object(shape);
|
|
559
619
|
if (0 === dynamicValidationFields.length) return baseSchema;
|
|
@@ -565,9 +625,7 @@ function buildZodSchema(schema) {
|
|
|
565
625
|
const ruleResult = external_rules_engine_cjs_namespaceObject.RulesEngine.applyRules(rules, values, {});
|
|
566
626
|
const isRequired = true === ruleResult.required || staticRequired;
|
|
567
627
|
if (isRequired) {
|
|
568
|
-
|
|
569
|
-
const isEmpty = null == value || '' === value || Array.isArray(value) && 0 === value.length;
|
|
570
|
-
if (isEmpty) ctx.addIssue({
|
|
628
|
+
if ((0, external_validation_converter_cjs_namespaceObject.isEmptyFieldValue)(values[name])) ctx.addIssue({
|
|
571
629
|
code: v4_namespaceObject.z.ZodIssueCode.custom,
|
|
572
630
|
message: customRequiredMessage || 'This field is required',
|
|
573
631
|
path: [
|
|
@@ -583,8 +641,10 @@ async function loadInitialData(initialData, _context) {
|
|
|
583
641
|
return initialData;
|
|
584
642
|
}
|
|
585
643
|
exports.MetadataForm = __webpack_exports__.MetadataForm;
|
|
644
|
+
exports.useWatch = __webpack_exports__.useWatch;
|
|
586
645
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
587
|
-
"MetadataForm"
|
|
646
|
+
"MetadataForm",
|
|
647
|
+
"useWatch"
|
|
588
648
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
589
649
|
Object.defineProperty(exports, '__esModule', {
|
|
590
650
|
value: true
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { FormPlugin, FormSchema } from './form-schema';
|
|
2
|
+
export { useWatch } from 'react-hook-form';
|
|
2
3
|
/**
|
|
3
4
|
* Core MetadataForm Component
|
|
4
5
|
* Renders forms from JSON/object schema with full RHF integration
|
|
5
6
|
*/
|
|
6
|
-
interface MetadataFormProps {
|
|
7
|
+
export interface MetadataFormProps {
|
|
7
8
|
schema: FormSchema;
|
|
8
9
|
plugins?: FormPlugin[];
|
|
9
10
|
onSubmit?: (data: unknown) => void | Promise<void>;
|
|
@@ -42,6 +43,13 @@ interface MetadataFormProps {
|
|
|
42
43
|
* and uncontrolled mode. Pair it with `activeStepId` to persist the selection.
|
|
43
44
|
*/
|
|
44
45
|
onActiveStepChange?: (stepId: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Render a `<div>` instead of a `<form>` — for hosts that embed the form inside their own
|
|
48
|
+
* chrome and own submission. Enter is swallowed for single-line inputs so it cannot trigger
|
|
49
|
+
* the host form's implicit submission, and schema submit actions become plain buttons.
|
|
50
|
+
*
|
|
51
|
+
* Suppressing the action row is the schema's job, not this prop's: pass `actions: []`.
|
|
52
|
+
*/
|
|
53
|
+
container?: 'form' | 'div';
|
|
45
54
|
}
|
|
46
|
-
export declare function MetadataForm({ schema, plugins, onSubmit, className, disabled, autoComplete, stepVariant, sectionVariant, activeStepId, onActiveStepChange, }: MetadataFormProps): import("react/jsx-runtime").JSX.Element;
|
|
47
|
-
export {};
|
|
55
|
+
export declare function MetadataForm({ schema, plugins, onSubmit, className, disabled, autoComplete, stepVariant, sectionVariant, activeStepId, onActiveStepChange, container, }: MetadataFormProps): import("react/jsx-runtime").JSX.Element;
|