@overmap-ai/core 1.0.33-revamp-forms-builder.0 → 1.0.33-revamp-forms-builder.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,5 +13,5 @@ interface PatchFieldProps {
|
|
|
13
13
|
name: string;
|
|
14
14
|
render: (args: RenderArgs) => ReactNode;
|
|
15
15
|
}
|
|
16
|
-
export declare const PatchField: import("react").MemoExoticComponent<(props: PatchFieldProps) =>
|
|
16
|
+
export declare const PatchField: import("react").MemoExoticComponent<(props: PatchFieldProps) => import("react/jsx-runtime").JSX.Element>;
|
|
17
17
|
export {};
|
package/dist/overmap-core.js
CHANGED
|
@@ -9255,10 +9255,10 @@ const _FieldSection = class _FieldSection extends BaseFormElement {
|
|
|
9255
9255
|
this.condition = null;
|
|
9256
9256
|
}
|
|
9257
9257
|
}
|
|
9258
|
-
static getFieldCreationSchema(options, parentPath) {
|
|
9258
|
+
static getFieldCreationSchema(options, parentPath = "") {
|
|
9259
9259
|
if (options.length === 0)
|
|
9260
9260
|
return [];
|
|
9261
|
-
const path = parentPath
|
|
9261
|
+
const path = parentPath && `${parentPath}.`;
|
|
9262
9262
|
return [
|
|
9263
9263
|
{
|
|
9264
9264
|
field: new BooleanField({
|
|
@@ -9338,6 +9338,8 @@ const _FieldSection = class _FieldSection extends BaseFormElement {
|
|
|
9338
9338
|
static deserialize(data) {
|
|
9339
9339
|
if (data.type !== "section")
|
|
9340
9340
|
throw new Error("Invalid type");
|
|
9341
|
+
if (!Array.isArray(data.fields))
|
|
9342
|
+
throw new Error(`Invalid fields: ${data.fields} (not an array)`);
|
|
9341
9343
|
const fields = data.fields.map(deserializeField);
|
|
9342
9344
|
return new _FieldSection({ ...data, fields });
|
|
9343
9345
|
}
|
|
@@ -9374,6 +9376,7 @@ let FieldSection = _FieldSection;
|
|
|
9374
9376
|
const deserializeField = (serializedField) => {
|
|
9375
9377
|
const fieldType = serializedField.type;
|
|
9376
9378
|
const fieldCls = FieldTypeToClsMapping[fieldType];
|
|
9379
|
+
console.log(serializedField, fieldType, fieldCls);
|
|
9377
9380
|
return fieldCls.deserialize(serializedField);
|
|
9378
9381
|
};
|
|
9379
9382
|
const deserialize = (serialized) => {
|
|
@@ -9939,7 +9942,7 @@ const PatchField = memo((props) => {
|
|
|
9939
9942
|
const { name, render } = props;
|
|
9940
9943
|
const { submitForm } = useFormikContext();
|
|
9941
9944
|
const [fieldProps, _meta, helpers] = useField(name);
|
|
9942
|
-
|
|
9945
|
+
const ret = useMemo(() => {
|
|
9943
9946
|
const setValue = (value) => {
|
|
9944
9947
|
void helpers.setValue(value, false);
|
|
9945
9948
|
};
|
|
@@ -9952,6 +9955,7 @@ const PatchField = memo((props) => {
|
|
|
9952
9955
|
}
|
|
9953
9956
|
});
|
|
9954
9957
|
}, [render, fieldProps.value, _meta, submitForm, helpers]);
|
|
9958
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: ret });
|
|
9955
9959
|
});
|
|
9956
9960
|
PatchField.displayName = "PatchField";
|
|
9957
9961
|
const PatchFormProvider = memo(
|
|
@@ -10015,6 +10019,7 @@ const useFieldTypeItems = (onSelect = () => null) => {
|
|
|
10015
10019
|
return fieldsToChoose.map((fieldGroup) => {
|
|
10016
10020
|
return fieldGroup.map((identifier) => {
|
|
10017
10021
|
const field = FieldTypeToClsMapping[identifier];
|
|
10022
|
+
console.log(fieldGroup, identifier, field);
|
|
10018
10023
|
const Icon = field.Icon;
|
|
10019
10024
|
return {
|
|
10020
10025
|
content: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
|
|
@@ -10849,7 +10854,7 @@ const FormBuilder = memo(
|
|
|
10849
10854
|
if (!form.title) {
|
|
10850
10855
|
errors.title = "Title is required.";
|
|
10851
10856
|
}
|
|
10852
|
-
if (form.fields.length === 0) {
|
|
10857
|
+
if (!form.fields || form.fields.length === 0) {
|
|
10853
10858
|
errors.fields = "At least one field is required.";
|
|
10854
10859
|
}
|
|
10855
10860
|
let fieldsToValidate = [];
|
|
@@ -10890,11 +10895,7 @@ const FormBuilder = memo(
|
|
|
10890
10895
|
const formik = useFormik({
|
|
10891
10896
|
initialValues: wrapRootFieldsWithFieldSection(revision) ?? initialValues,
|
|
10892
10897
|
validate,
|
|
10893
|
-
|
|
10894
|
-
onSubmit: (form) => {
|
|
10895
|
-
onSave(form);
|
|
10896
|
-
},
|
|
10897
|
-
// only validate the entire form on submit
|
|
10898
|
+
onSubmit: onSave,
|
|
10898
10899
|
validateOnChange: false,
|
|
10899
10900
|
validateOnBlur: false
|
|
10900
10901
|
});
|