@maif/react-forms 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/lib/esm/index.js +14 -14
- package/lib/index.d.ts +6 -0
- package/lib/index.js +14 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -100,6 +100,26 @@ export const Example = () => {
|
|
|
100
100
|
```javascript
|
|
101
101
|
({rawValues, value, setValue}) => if (value.length) { setValue('entry', false) }
|
|
102
102
|
```
|
|
103
|
+
- **onAfterChange**: a callback function to the value change.
|
|
104
|
+
```javascript
|
|
105
|
+
({entry, value, rawValues, previousValue, getValue, setValue, onChange, informations}) => {
|
|
106
|
+
const otherEntryVal = getValue('otherEntry')
|
|
107
|
+
console.debug({entry, value, rawValues, otherEntryVal})
|
|
108
|
+
setValue('anotherEntry', v + 1)
|
|
109
|
+
const {path, parent, index} = informations
|
|
110
|
+
console.debug({path, parent, index})
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
where :
|
|
114
|
+
- entry [string] is the updated entry of schema
|
|
115
|
+
- value [any] is the actual value of your entry
|
|
116
|
+
- previousValue [any] is the previous value of your entry
|
|
117
|
+
- rawValues [any] is the actual value of antire form
|
|
118
|
+
- getValue [function] is a function to get value of a form entry
|
|
119
|
+
- setValue [function] is a function to set value of a form entry
|
|
120
|
+
- onSave [function] is a function to update actual entry
|
|
121
|
+
- informations [Information] is an object to get information about the actual entry (path, index and parent informations)
|
|
122
|
+
|
|
103
123
|
- **render**: a function to completely custom the rendering of form field
|
|
104
124
|
```javascript
|
|
105
125
|
({rawValues, value, onChange, error, setValue, parent}) => <input type="text" className="is-invalid" value={value} onChange={e => onChange(e.target.value)} />
|
package/lib/esm/index.js
CHANGED
|
@@ -27921,7 +27921,7 @@ const ControlledInput = (inputProps) => {
|
|
|
27921
27921
|
return prop;
|
|
27922
27922
|
}
|
|
27923
27923
|
};
|
|
27924
|
-
const props = Object.assign(Object.assign(
|
|
27924
|
+
const props = Object.assign(Object.assign({ name: field.name }, step.props), { id: entry, readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null, placeholder: step.placeholder, onChange: (e) => {
|
|
27925
27925
|
const value = (() => {
|
|
27926
27926
|
if (!e) {
|
|
27927
27927
|
if (step.type === type.bool ||
|
|
@@ -27960,7 +27960,6 @@ const usePrevious = (value) => {
|
|
|
27960
27960
|
};
|
|
27961
27961
|
const BasicWrapper = ({ entry, children, render, functionalProperty, step }) => {
|
|
27962
27962
|
const { formState, watch } = useFormContext();
|
|
27963
|
-
console.debug({ entry, step });
|
|
27964
27963
|
if (typeof entry === 'object') {
|
|
27965
27964
|
return children;
|
|
27966
27965
|
}
|
|
@@ -28186,7 +28185,6 @@ const Form = React__default.forwardRef(function Form({ schema, flow, value, inpu
|
|
|
28186
28185
|
trigger,
|
|
28187
28186
|
methods: Object.assign(Object.assign({}, methods), { data: () => cleanOutputArray(getValues(), schema) })
|
|
28188
28187
|
}));
|
|
28189
|
-
console.debug({ formFlow });
|
|
28190
28188
|
return (React__default.createElement(FormProvider, Object.assign({}, methods),
|
|
28191
28189
|
React__default.createElement(Watcher, { options: options, control: methods.control, schema: schema, onSubmit: onSubmit, handleSubmit: handleSubmit }),
|
|
28192
28190
|
React__default.createElement("form", { className: className || `mrf-pr_15 mrf-w_100`, onSubmit: handleSubmit(data => {
|
|
@@ -28216,8 +28214,8 @@ const Footer = (props) => {
|
|
|
28216
28214
|
isSubmitDisplayed && React__default.createElement("button", { className: 'mrf-btn mrf-btn_green mrf-ml_10', type: "submit" }, ((_p = (_o = props.actions) === null || _o === void 0 ? void 0 : _o.submit) === null || _p === void 0 ? void 0 : _p.label) || 'Save')));
|
|
28217
28215
|
};
|
|
28218
28216
|
const Step = (props) => {
|
|
28219
|
-
let { entry, realEntry, step, schema, inputWrapper, httpClient, defaultValue, index, functionalProperty, parent,
|
|
28220
|
-
const { formState: { errors, dirtyFields, touchedFields, isSubmitted }, control,
|
|
28217
|
+
let { entry, realEntry, step, schema, inputWrapper, httpClient, defaultValue, index, functionalProperty, parent, parentInformations } = props;
|
|
28218
|
+
const { formState: { errors, dirtyFields, touchedFields, isSubmitted }, control, getValues, setValue, watch } = useFormContext();
|
|
28221
28219
|
if (entry && typeof entry === 'object') {
|
|
28222
28220
|
const errored = extractFlowString(entry).some(step => !!errors[step] && (dirtyFields[step] || touchedFields[step]));
|
|
28223
28221
|
return (React__default.createElement(Collapse, Object.assign({}, entry, { errored: errored }), entry.flow.map((en, entryIdx) => {
|
|
@@ -28227,13 +28225,14 @@ const Step = (props) => {
|
|
|
28227
28225
|
return null;
|
|
28228
28226
|
}
|
|
28229
28227
|
return (React__default.createElement(BasicWrapper, { key: `collapse-${en}-${entryIdx}`, entry: en, functionalProperty: functionalProperty, step: stp, render: inputWrapper },
|
|
28230
|
-
React__default.createElement(Step, { entry: en, step: stp, schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue, functionalProperty: functionalProperty })));
|
|
28228
|
+
React__default.createElement(Step, { entry: en, step: stp, schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue, functionalProperty: functionalProperty, parentInformations: parentInformations })));
|
|
28231
28229
|
})));
|
|
28232
28230
|
}
|
|
28233
28231
|
const error = entry.split('.').reduce((acc, curr) => acc && acc[curr], errors);
|
|
28234
28232
|
const isDirty = entry.split('.').reduce((acc, curr) => acc && acc[curr], dirtyFields);
|
|
28235
28233
|
const isTouched = entry.split('.').reduce((acc, curr) => acc && acc[curr], touchedFields);
|
|
28236
28234
|
const errorDisplayed = (!!error && (isSubmitted || isDirty || isTouched));
|
|
28235
|
+
const informations = { path: entry, parent: parentInformations, index };
|
|
28237
28236
|
step = step;
|
|
28238
28237
|
if (step.onAfterChange) {
|
|
28239
28238
|
const data = watch();
|
|
@@ -28247,11 +28246,12 @@ const Step = (props) => {
|
|
|
28247
28246
|
step.onAfterChange({
|
|
28248
28247
|
entry,
|
|
28249
28248
|
value: getValues(entry),
|
|
28250
|
-
rawValues:
|
|
28249
|
+
rawValues: getValues(),
|
|
28251
28250
|
previousValue: currentData,
|
|
28252
28251
|
getValue: (e) => getValues(e),
|
|
28253
28252
|
setValue,
|
|
28254
|
-
onChange: (v) => setValue(entry, v)
|
|
28253
|
+
onChange: (v) => setValue(entry, v),
|
|
28254
|
+
informations
|
|
28255
28255
|
});
|
|
28256
28256
|
}
|
|
28257
28257
|
if (step.array) {
|
|
@@ -28260,7 +28260,7 @@ const Step = (props) => {
|
|
|
28260
28260
|
}, error: !!error },
|
|
28261
28261
|
React__default.createElement(ArrayStep, { entry: entry, step: step, disabled: functionalProperty(entry, step.disabled || false), component: ((props, idx) => {
|
|
28262
28262
|
var _a;
|
|
28263
|
-
return (React__default.createElement(Step, { entry: `${entry}.${idx}.value`, step: Object.assign(Object.assign({}, (schema[realEntry || entry])), { render: step.itemRender, onChange: undefined, array: false, onAfterChange: step.onAfterChange }), schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: (_a = props.defaultValue) === null || _a === void 0 ? void 0 : _a.value, index: idx, functionalProperty: functionalProperty }));
|
|
28263
|
+
return (React__default.createElement(Step, { entry: `${entry}.${idx}.value`, step: Object.assign(Object.assign({}, (schema[realEntry || entry])), { render: step.itemRender, onChange: undefined, array: false, onAfterChange: step.onAfterChange }), schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: (_a = props.defaultValue) === null || _a === void 0 ? void 0 : _a.value, index: idx, functionalProperty: functionalProperty, parentInformations: informations }));
|
|
28264
28264
|
}) })));
|
|
28265
28265
|
}
|
|
28266
28266
|
switch (step.type) {
|
|
@@ -28280,7 +28280,7 @@ const Step = (props) => {
|
|
|
28280
28280
|
case format.buttonsSelect:
|
|
28281
28281
|
case format.select: {
|
|
28282
28282
|
return (React__default.createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed },
|
|
28283
|
-
React__default.createElement(SelectInput, Object.assign({ className: classNames('mrf-flex_grow_1', step.className, { 'mrf-input__invalid': !!errorDisplayed }), disabled: functionalProperty(entry, step.disabled || false) }, step.props, { possibleValues: step.options, httpClient: httpClient, isMulti: step.isMulti, createOption: step.createOption, transformer: step.transformer, buttons: step.format === format.buttonsSelect, optionsFrom: step.optionsFrom }))));
|
|
28283
|
+
React__default.createElement(SelectInput, Object.assign({ className: classNames('mrf-flex_grow_1', step.className, { 'mrf-input__invalid': !!errorDisplayed }), disabled: functionalProperty(entry, step.disabled || false) }, step.props, { possibleValues: step.options, httpClient: httpClient, isMulti: step.isMulti, createOption: step.createOption, onCreateOption: step.onCreateOption, transformer: step.transformer, buttons: step.format === format.buttonsSelect, optionsFrom: step.optionsFrom }))));
|
|
28284
28284
|
}
|
|
28285
28285
|
default:
|
|
28286
28286
|
return (React__default.createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed },
|
|
@@ -28308,7 +28308,7 @@ const Step = (props) => {
|
|
|
28308
28308
|
case format.form: //todo: disabled ?
|
|
28309
28309
|
const flow = option(step.flow).getOrElse(option(step.schema).map(s => Object.keys(s)).getOrElse([]));
|
|
28310
28310
|
return (React__default.createElement(CustomizableInput, { render: step.render, field: { parent, setValue: (key, value) => setValue(key, value), rawValues: getValues(), value: getValues(entry), onChange: (v) => setValue(entry, v, { shouldValidate: true }) } },
|
|
28311
|
-
React__default.createElement(NestedForm, { schema: step.schema, flow: flow, step: step, parent: entry, inputWrapper: inputWrapper, maybeCustomHttpClient: httpClient, value: getValues(entry) || defaultValue,
|
|
28311
|
+
React__default.createElement(NestedForm, { schema: step.schema, flow: flow, step: step, parent: entry, inputWrapper: inputWrapper, maybeCustomHttpClient: httpClient, value: getValues(entry) || defaultValue, functionalProperty: functionalProperty, errorDisplayed: errorDisplayed, informations: informations })));
|
|
28312
28312
|
case format.code:
|
|
28313
28313
|
return (React__default.createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed, component: (field, props) => (React__default.createElement(CodeInput, Object.assign({}, props, {
|
|
28314
28314
|
/* TODO className={classNames(step.className, { 'mrf-input__invalid': !!error })}*/
|
|
@@ -28399,9 +28399,9 @@ const ArrayStep = ({ entry, step, component, disabled }) => {
|
|
|
28399
28399
|
}, disabled: disabled }, "Add"),
|
|
28400
28400
|
error && React__default.createElement("div", { className: "mrf-invalid-feedback" }, error.message))));
|
|
28401
28401
|
};
|
|
28402
|
-
const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient, errorDisplayed, value, step, functionalProperty,
|
|
28402
|
+
const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient, errorDisplayed, value, step, functionalProperty, informations }) => {
|
|
28403
28403
|
var _a;
|
|
28404
|
-
const { getValues, setValue,
|
|
28404
|
+
const { getValues, setValue, control, formState: { errors, dirtyFields, touchedFields } } = useFormContext();
|
|
28405
28405
|
const [collapsed, setCollapsed] = useState(!!step.collapsed);
|
|
28406
28406
|
useWatch({ name: ((_a = step === null || step === void 0 ? void 0 : step.conditionalSchema) === null || _a === void 0 ? void 0 : _a.ref) || "", control });
|
|
28407
28407
|
const schemaAndFlow = option(step.conditionalSchema)
|
|
@@ -28455,7 +28455,7 @@ const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient,
|
|
|
28455
28455
|
// TODO return collapse, then entry will always be a string in below return
|
|
28456
28456
|
}
|
|
28457
28457
|
return (React__default.createElement(BasicWrapper, { key: `${entry}.${idx}`, className: classNames({ ['mrf-display__none']: (collapsed && !step.visibleOnCollapse) }), entry: `${parent}.${entry}`, functionalProperty: functionalProperty, step: step, render: inputWrapper },
|
|
28458
|
-
React__default.createElement(Step, { key: `step.${entry}.${idx}`, entry: `${parent}.${entry}`, realEntry: entry, step: schemaAndFlow.schema[entry], parent: parent, schema: schemaAndFlow.schema, inputWrapper: inputWrapper, httpClient: maybeCustomHttpClient, defaultValue: value && value[entry], functionalProperty: functionalProperty })));
|
|
28458
|
+
React__default.createElement(Step, { key: `step.${entry}.${idx}`, entry: `${parent}.${entry}`, realEntry: entry, step: schemaAndFlow.schema[entry], parent: parent, schema: schemaAndFlow.schema, inputWrapper: inputWrapper, httpClient: maybeCustomHttpClient, defaultValue: value && value[entry], functionalProperty: functionalProperty, parentInformations: informations })));
|
|
28459
28459
|
})));
|
|
28460
28460
|
};
|
|
28461
28461
|
function extractFlowString(entry) {
|
package/lib/index.d.ts
CHANGED
|
@@ -328,6 +328,7 @@ interface SchemaEntry {
|
|
|
328
328
|
getValue: (entry: string) => any;
|
|
329
329
|
setValue: (entry: string, value: any) => void;
|
|
330
330
|
onChange: (v: any) => void;
|
|
331
|
+
informations?: Informations;
|
|
331
332
|
}) => void;
|
|
332
333
|
visibleOnCollapse?: boolean;
|
|
333
334
|
addableDefaultValue: any;
|
|
@@ -340,6 +341,11 @@ interface FlowObject {
|
|
|
340
341
|
collapse: boolean;
|
|
341
342
|
}
|
|
342
343
|
declare type Flow = Array<string | FlowObject>;
|
|
344
|
+
interface Informations {
|
|
345
|
+
path: string;
|
|
346
|
+
parent?: Informations;
|
|
347
|
+
index?: number;
|
|
348
|
+
}
|
|
343
349
|
declare const validate: (flow: string[], schema: Schema, value: object) => Promise<yup_lib_object.AssertsShape<yup_lib_object.Assign<yup_lib_object.ObjectShape, yup_lib_object.ObjectShape>>>;
|
|
344
350
|
declare const Form: React.ForwardRefExoticComponent<{
|
|
345
351
|
schema: Schema;
|
package/lib/index.js
CHANGED
|
@@ -27956,7 +27956,7 @@ const ControlledInput = (inputProps) => {
|
|
|
27956
27956
|
return prop;
|
|
27957
27957
|
}
|
|
27958
27958
|
};
|
|
27959
|
-
const props = Object.assign(Object.assign(
|
|
27959
|
+
const props = Object.assign(Object.assign({ name: field.name }, step.props), { id: entry, readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null, placeholder: step.placeholder, onChange: (e) => {
|
|
27960
27960
|
const value = (() => {
|
|
27961
27961
|
if (!e) {
|
|
27962
27962
|
if (step.type === type.bool ||
|
|
@@ -27995,7 +27995,6 @@ const usePrevious = (value) => {
|
|
|
27995
27995
|
};
|
|
27996
27996
|
const BasicWrapper = ({ entry, children, render, functionalProperty, step }) => {
|
|
27997
27997
|
const { formState, watch } = reactHookForm.useFormContext();
|
|
27998
|
-
console.debug({ entry, step });
|
|
27999
27998
|
if (typeof entry === 'object') {
|
|
28000
27999
|
return children;
|
|
28001
28000
|
}
|
|
@@ -28221,7 +28220,6 @@ const Form = React__default["default"].forwardRef(function Form({ schema, flow,
|
|
|
28221
28220
|
trigger,
|
|
28222
28221
|
methods: Object.assign(Object.assign({}, methods), { data: () => cleanOutputArray(getValues(), schema) })
|
|
28223
28222
|
}));
|
|
28224
|
-
console.debug({ formFlow });
|
|
28225
28223
|
return (React__default["default"].createElement(reactHookForm.FormProvider, Object.assign({}, methods),
|
|
28226
28224
|
React__default["default"].createElement(Watcher, { options: options, control: methods.control, schema: schema, onSubmit: onSubmit, handleSubmit: handleSubmit }),
|
|
28227
28225
|
React__default["default"].createElement("form", { className: className || `mrf-pr_15 mrf-w_100`, onSubmit: handleSubmit(data => {
|
|
@@ -28251,8 +28249,8 @@ const Footer = (props) => {
|
|
|
28251
28249
|
isSubmitDisplayed && React__default["default"].createElement("button", { className: 'mrf-btn mrf-btn_green mrf-ml_10', type: "submit" }, ((_p = (_o = props.actions) === null || _o === void 0 ? void 0 : _o.submit) === null || _p === void 0 ? void 0 : _p.label) || 'Save')));
|
|
28252
28250
|
};
|
|
28253
28251
|
const Step = (props) => {
|
|
28254
|
-
let { entry, realEntry, step, schema, inputWrapper, httpClient, defaultValue, index, functionalProperty, parent,
|
|
28255
|
-
const { formState: { errors, dirtyFields, touchedFields, isSubmitted }, control,
|
|
28252
|
+
let { entry, realEntry, step, schema, inputWrapper, httpClient, defaultValue, index, functionalProperty, parent, parentInformations } = props;
|
|
28253
|
+
const { formState: { errors, dirtyFields, touchedFields, isSubmitted }, control, getValues, setValue, watch } = reactHookForm.useFormContext();
|
|
28256
28254
|
if (entry && typeof entry === 'object') {
|
|
28257
28255
|
const errored = extractFlowString(entry).some(step => !!errors[step] && (dirtyFields[step] || touchedFields[step]));
|
|
28258
28256
|
return (React__default["default"].createElement(Collapse, Object.assign({}, entry, { errored: errored }), entry.flow.map((en, entryIdx) => {
|
|
@@ -28262,13 +28260,14 @@ const Step = (props) => {
|
|
|
28262
28260
|
return null;
|
|
28263
28261
|
}
|
|
28264
28262
|
return (React__default["default"].createElement(BasicWrapper, { key: `collapse-${en}-${entryIdx}`, entry: en, functionalProperty: functionalProperty, step: stp, render: inputWrapper },
|
|
28265
|
-
React__default["default"].createElement(Step, { entry: en, step: stp, schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue, functionalProperty: functionalProperty })));
|
|
28263
|
+
React__default["default"].createElement(Step, { entry: en, step: stp, schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue, functionalProperty: functionalProperty, parentInformations: parentInformations })));
|
|
28266
28264
|
})));
|
|
28267
28265
|
}
|
|
28268
28266
|
const error = entry.split('.').reduce((acc, curr) => acc && acc[curr], errors);
|
|
28269
28267
|
const isDirty = entry.split('.').reduce((acc, curr) => acc && acc[curr], dirtyFields);
|
|
28270
28268
|
const isTouched = entry.split('.').reduce((acc, curr) => acc && acc[curr], touchedFields);
|
|
28271
28269
|
const errorDisplayed = (!!error && (isSubmitted || isDirty || isTouched));
|
|
28270
|
+
const informations = { path: entry, parent: parentInformations, index };
|
|
28272
28271
|
step = step;
|
|
28273
28272
|
if (step.onAfterChange) {
|
|
28274
28273
|
const data = watch();
|
|
@@ -28282,11 +28281,12 @@ const Step = (props) => {
|
|
|
28282
28281
|
step.onAfterChange({
|
|
28283
28282
|
entry,
|
|
28284
28283
|
value: getValues(entry),
|
|
28285
|
-
rawValues:
|
|
28284
|
+
rawValues: getValues(),
|
|
28286
28285
|
previousValue: currentData,
|
|
28287
28286
|
getValue: (e) => getValues(e),
|
|
28288
28287
|
setValue,
|
|
28289
|
-
onChange: (v) => setValue(entry, v)
|
|
28288
|
+
onChange: (v) => setValue(entry, v),
|
|
28289
|
+
informations
|
|
28290
28290
|
});
|
|
28291
28291
|
}
|
|
28292
28292
|
if (step.array) {
|
|
@@ -28295,7 +28295,7 @@ const Step = (props) => {
|
|
|
28295
28295
|
}, error: !!error },
|
|
28296
28296
|
React__default["default"].createElement(ArrayStep, { entry: entry, step: step, disabled: functionalProperty(entry, step.disabled || false), component: ((props, idx) => {
|
|
28297
28297
|
var _a;
|
|
28298
|
-
return (React__default["default"].createElement(Step, { entry: `${entry}.${idx}.value`, step: Object.assign(Object.assign({}, (schema[realEntry || entry])), { render: step.itemRender, onChange: undefined, array: false, onAfterChange: step.onAfterChange }), schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: (_a = props.defaultValue) === null || _a === void 0 ? void 0 : _a.value, index: idx, functionalProperty: functionalProperty }));
|
|
28298
|
+
return (React__default["default"].createElement(Step, { entry: `${entry}.${idx}.value`, step: Object.assign(Object.assign({}, (schema[realEntry || entry])), { render: step.itemRender, onChange: undefined, array: false, onAfterChange: step.onAfterChange }), schema: schema, inputWrapper: inputWrapper, httpClient: httpClient, defaultValue: (_a = props.defaultValue) === null || _a === void 0 ? void 0 : _a.value, index: idx, functionalProperty: functionalProperty, parentInformations: informations }));
|
|
28299
28299
|
}) })));
|
|
28300
28300
|
}
|
|
28301
28301
|
switch (step.type) {
|
|
@@ -28315,7 +28315,7 @@ const Step = (props) => {
|
|
|
28315
28315
|
case format.buttonsSelect:
|
|
28316
28316
|
case format.select: {
|
|
28317
28317
|
return (React__default["default"].createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed },
|
|
28318
|
-
React__default["default"].createElement(SelectInput, Object.assign({ className: classNames__default["default"]('mrf-flex_grow_1', step.className, { 'mrf-input__invalid': !!errorDisplayed }), disabled: functionalProperty(entry, step.disabled || false) }, step.props, { possibleValues: step.options, httpClient: httpClient, isMulti: step.isMulti, createOption: step.createOption, transformer: step.transformer, buttons: step.format === format.buttonsSelect, optionsFrom: step.optionsFrom }))));
|
|
28318
|
+
React__default["default"].createElement(SelectInput, Object.assign({ className: classNames__default["default"]('mrf-flex_grow_1', step.className, { 'mrf-input__invalid': !!errorDisplayed }), disabled: functionalProperty(entry, step.disabled || false) }, step.props, { possibleValues: step.options, httpClient: httpClient, isMulti: step.isMulti, createOption: step.createOption, onCreateOption: step.onCreateOption, transformer: step.transformer, buttons: step.format === format.buttonsSelect, optionsFrom: step.optionsFrom }))));
|
|
28319
28319
|
}
|
|
28320
28320
|
default:
|
|
28321
28321
|
return (React__default["default"].createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed },
|
|
@@ -28343,7 +28343,7 @@ const Step = (props) => {
|
|
|
28343
28343
|
case format.form: //todo: disabled ?
|
|
28344
28344
|
const flow = option(step.flow).getOrElse(option(step.schema).map(s => Object.keys(s)).getOrElse([]));
|
|
28345
28345
|
return (React__default["default"].createElement(CustomizableInput, { render: step.render, field: { parent, setValue: (key, value) => setValue(key, value), rawValues: getValues(), value: getValues(entry), onChange: (v) => setValue(entry, v, { shouldValidate: true }) } },
|
|
28346
|
-
React__default["default"].createElement(NestedForm, { schema: step.schema, flow: flow, step: step, parent: entry, inputWrapper: inputWrapper, maybeCustomHttpClient: httpClient, value: getValues(entry) || defaultValue,
|
|
28346
|
+
React__default["default"].createElement(NestedForm, { schema: step.schema, flow: flow, step: step, parent: entry, inputWrapper: inputWrapper, maybeCustomHttpClient: httpClient, value: getValues(entry) || defaultValue, functionalProperty: functionalProperty, errorDisplayed: errorDisplayed, informations: informations })));
|
|
28347
28347
|
case format.code:
|
|
28348
28348
|
return (React__default["default"].createElement(ControlledInput, { step: step, entry: entry, errorDisplayed: errorDisplayed, component: (field, props) => (React__default["default"].createElement(CodeInput, Object.assign({}, props, {
|
|
28349
28349
|
/* TODO className={classNames(step.className, { 'mrf-input__invalid': !!error })}*/
|
|
@@ -28434,9 +28434,9 @@ const ArrayStep = ({ entry, step, component, disabled }) => {
|
|
|
28434
28434
|
}, disabled: disabled }, "Add"),
|
|
28435
28435
|
error && React__default["default"].createElement("div", { className: "mrf-invalid-feedback" }, error.message))));
|
|
28436
28436
|
};
|
|
28437
|
-
const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient, errorDisplayed, value, step, functionalProperty,
|
|
28437
|
+
const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient, errorDisplayed, value, step, functionalProperty, informations }) => {
|
|
28438
28438
|
var _a;
|
|
28439
|
-
const { getValues, setValue,
|
|
28439
|
+
const { getValues, setValue, control, formState: { errors, dirtyFields, touchedFields } } = reactHookForm.useFormContext();
|
|
28440
28440
|
const [collapsed, setCollapsed] = React.useState(!!step.collapsed);
|
|
28441
28441
|
reactHookForm.useWatch({ name: ((_a = step === null || step === void 0 ? void 0 : step.conditionalSchema) === null || _a === void 0 ? void 0 : _a.ref) || "", control });
|
|
28442
28442
|
const schemaAndFlow = option(step.conditionalSchema)
|
|
@@ -28490,7 +28490,7 @@ const NestedForm = ({ schema, flow, parent, inputWrapper, maybeCustomHttpClient,
|
|
|
28490
28490
|
// TODO return collapse, then entry will always be a string in below return
|
|
28491
28491
|
}
|
|
28492
28492
|
return (React__default["default"].createElement(BasicWrapper, { key: `${entry}.${idx}`, className: classNames__default["default"]({ ['mrf-display__none']: (collapsed && !step.visibleOnCollapse) }), entry: `${parent}.${entry}`, functionalProperty: functionalProperty, step: step, render: inputWrapper },
|
|
28493
|
-
React__default["default"].createElement(Step, { key: `step.${entry}.${idx}`, entry: `${parent}.${entry}`, realEntry: entry, step: schemaAndFlow.schema[entry], parent: parent, schema: schemaAndFlow.schema, inputWrapper: inputWrapper, httpClient: maybeCustomHttpClient, defaultValue: value && value[entry], functionalProperty: functionalProperty })));
|
|
28493
|
+
React__default["default"].createElement(Step, { key: `step.${entry}.${idx}`, entry: `${parent}.${entry}`, realEntry: entry, step: schemaAndFlow.schema[entry], parent: parent, schema: schemaAndFlow.schema, inputWrapper: inputWrapper, httpClient: maybeCustomHttpClient, defaultValue: value && value[entry], functionalProperty: functionalProperty, parentInformations: informations })));
|
|
28494
28494
|
})));
|
|
28495
28495
|
};
|
|
28496
28496
|
function extractFlowString(entry) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maif/react-forms",
|
|
3
3
|
"description": "Build react safe forms as fast as possible",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"moment": "2.29.1",
|
|
122
122
|
"object-hash": "3.0.0",
|
|
123
123
|
"react-feather": "2.0.9",
|
|
124
|
-
"react-hook-form": "7.
|
|
124
|
+
"react-hook-form": "7.32.1",
|
|
125
125
|
"react-rainbow-components": "1.26.0",
|
|
126
126
|
"react-select": "5.2.1",
|
|
127
127
|
"react-tooltip": "4.2.21",
|