@maif/react-forms 1.0.51 → 1.0.54
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/lib/esm/index.js +59 -70
- package/lib/index.js +59 -70
- package/package.json +2 -3
package/lib/esm/index.js
CHANGED
|
@@ -28515,7 +28515,6 @@ function CodeInput(_ref) {
|
|
|
28515
28515
|
}, []);
|
|
28516
28516
|
useEffect(function () {
|
|
28517
28517
|
if (editor && (_typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value) !== editor.state.doc.toString()) {
|
|
28518
|
-
console.log("set value", value, value === null || value === undefined ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value, editor.state.doc.toString());
|
|
28519
28518
|
editor.dispatch({
|
|
28520
28519
|
changes: {
|
|
28521
28520
|
from: 0,
|
|
@@ -28864,18 +28863,28 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28864
28863
|
return s.condition === ref;
|
|
28865
28864
|
}
|
|
28866
28865
|
});
|
|
28867
|
-
return option(filterSwitch).
|
|
28866
|
+
return option(filterSwitch).orElse(condiSchema["switch"].find(function (s) {
|
|
28868
28867
|
return s["default"];
|
|
28869
|
-
}))
|
|
28870
|
-
|
|
28868
|
+
})).getOrElse({
|
|
28869
|
+
schema: {},
|
|
28870
|
+
flow: []
|
|
28871
|
+
});
|
|
28872
|
+
}).getOrElse({
|
|
28873
|
+
schema: {},
|
|
28874
|
+
flow: []
|
|
28875
|
+
}),
|
|
28871
28876
|
schema = _option$map$getOrElse.schema,
|
|
28872
28877
|
flow = _option$map$getOrElse.flow;
|
|
28873
28878
|
|
|
28874
|
-
var
|
|
28879
|
+
var realFlow = flow || Object.keys(schema);
|
|
28875
28880
|
|
|
28876
|
-
|
|
28877
|
-
|
|
28878
|
-
|
|
28881
|
+
if (realFlow.length) {
|
|
28882
|
+
var _subResolver2 = getShapeAndDependencies(flow || Object.keys(schema), schema, dependencies, rawData);
|
|
28883
|
+
|
|
28884
|
+
return constraints.reduce(function (resolver, constraint) {
|
|
28885
|
+
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28886
|
+
}, yup.object().shape(_subResolver2.shape, dependencies));
|
|
28887
|
+
}
|
|
28879
28888
|
} else {
|
|
28880
28889
|
return constraints.reduce(function (resolver, constraint) {
|
|
28881
28890
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
@@ -28929,6 +28938,10 @@ var CustomizableInput$1 = /*#__PURE__*/React.memo(function (props) {
|
|
|
28929
28938
|
|
|
28930
28939
|
return props.children;
|
|
28931
28940
|
}, function (prev, next) {
|
|
28941
|
+
if (next.render || next.conditionalSchema) {
|
|
28942
|
+
return false;
|
|
28943
|
+
}
|
|
28944
|
+
|
|
28932
28945
|
return prev.field.value === next.field.value && next.errorDisplayed === prev.errorDisplayed;
|
|
28933
28946
|
});
|
|
28934
28947
|
var ControlledInput = function ControlledInput(_ref) {
|
|
@@ -29281,11 +29294,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29281
29294
|
});
|
|
29282
29295
|
};
|
|
29283
29296
|
|
|
29284
|
-
var _useState = useState(false),
|
|
29285
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29286
|
-
expandedAll = _useState2[0],
|
|
29287
|
-
setExpandedAll = _useState2[1];
|
|
29288
|
-
|
|
29289
29297
|
var defaultValues = getDefaultValues(formFlow, schema, value); //FIXME: get real schema through the switch
|
|
29290
29298
|
|
|
29291
29299
|
var _resolver = function resolver(rawData) {
|
|
@@ -29305,10 +29313,10 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29305
29313
|
mode: 'onChange'
|
|
29306
29314
|
});
|
|
29307
29315
|
|
|
29308
|
-
var
|
|
29309
|
-
|
|
29310
|
-
initialReseted =
|
|
29311
|
-
setReset =
|
|
29316
|
+
var _useState = useState(false),
|
|
29317
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29318
|
+
initialReseted = _useState2[0],
|
|
29319
|
+
setReset = _useState2[1];
|
|
29312
29320
|
|
|
29313
29321
|
useEffect(function () {
|
|
29314
29322
|
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
@@ -29319,9 +29327,9 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29319
29327
|
initialReseted && trigger();
|
|
29320
29328
|
}, [trigger, initialReseted]);
|
|
29321
29329
|
var _handleSubmit = methods.handleSubmit,
|
|
29322
|
-
_methods$formState = methods.formState
|
|
29323
|
-
|
|
29324
|
-
dirtyFields = _methods$formState.dirtyFields,
|
|
29330
|
+
_methods$formState = methods.formState;
|
|
29331
|
+
_methods$formState.errors;
|
|
29332
|
+
var dirtyFields = _methods$formState.dirtyFields,
|
|
29325
29333
|
_reset = methods.reset,
|
|
29326
29334
|
trigger = methods.trigger,
|
|
29327
29335
|
getValues = methods.getValues,
|
|
@@ -29374,19 +29382,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29374
29382
|
var clean = cleanOutputArray(data, schema);
|
|
29375
29383
|
onSubmit(clean);
|
|
29376
29384
|
}, onError)
|
|
29377
|
-
},
|
|
29378
|
-
className: classNames(classes.flex, classes.mt_20)
|
|
29379
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
29380
|
-
type: "button",
|
|
29381
|
-
className: classNames(classes.btn, classes.btn_sm),
|
|
29382
|
-
style: {
|
|
29383
|
-
marginLeft: 'auto'
|
|
29384
|
-
},
|
|
29385
|
-
onClick: function onClick(e) {
|
|
29386
|
-
if (e) e.stopPropagation();
|
|
29387
|
-
setExpandedAll(!expandedAll);
|
|
29388
|
-
}
|
|
29389
|
-
}, expandedAll ? 'Expand all' : 'Collapse all')), formFlow.map(function (entry, idx) {
|
|
29385
|
+
}, formFlow.map(function (entry, idx) {
|
|
29390
29386
|
var step = schema[entry];
|
|
29391
29387
|
|
|
29392
29388
|
if (!step && typeof entry === 'string') {
|
|
@@ -29394,9 +29390,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29394
29390
|
return null;
|
|
29395
29391
|
}
|
|
29396
29392
|
|
|
29397
|
-
_typeof$1(entry) === 'object' ? undefined : entry.split('.').reduce(function (object, key) {
|
|
29398
|
-
return object && object[key];
|
|
29399
|
-
}, errors);
|
|
29400
29393
|
var visibleStep = option(step).map(function (s) {
|
|
29401
29394
|
return s.visible;
|
|
29402
29395
|
}).map(function (visible) {
|
|
@@ -29434,8 +29427,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref7, ref) {
|
|
|
29434
29427
|
schema: schema,
|
|
29435
29428
|
inputWrapper: inputWrapper,
|
|
29436
29429
|
httpClient: maybeCustomHttpClient,
|
|
29437
|
-
functionalProperty: functionalProperty
|
|
29438
|
-
expandedAll: expandedAll
|
|
29430
|
+
functionalProperty: functionalProperty
|
|
29439
29431
|
}));
|
|
29440
29432
|
}), /*#__PURE__*/React.createElement(Footer, {
|
|
29441
29433
|
render: footer,
|
|
@@ -29493,8 +29485,7 @@ var Step = function Step(_ref8) {
|
|
|
29493
29485
|
index = _ref8.index,
|
|
29494
29486
|
functionalProperty = _ref8.functionalProperty,
|
|
29495
29487
|
parent = _ref8.parent,
|
|
29496
|
-
onAfterChange = _ref8.onAfterChange
|
|
29497
|
-
expandedAll = _ref8.expandedAll;
|
|
29488
|
+
onAfterChange = _ref8.onAfterChange;
|
|
29498
29489
|
var classes = useCustomStyle();
|
|
29499
29490
|
|
|
29500
29491
|
var _useFormContext2 = useFormContext(),
|
|
@@ -29559,7 +29550,6 @@ var Step = function Step(_ref8) {
|
|
|
29559
29550
|
entry: en,
|
|
29560
29551
|
step: stp,
|
|
29561
29552
|
schema: schema,
|
|
29562
|
-
expandedAll: expandedAll,
|
|
29563
29553
|
inputWrapper: inputWrapper,
|
|
29564
29554
|
httpClient: httpClient,
|
|
29565
29555
|
defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue,
|
|
@@ -29637,8 +29627,7 @@ var Step = function Step(_ref8) {
|
|
|
29637
29627
|
defaultValue: (_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.value,
|
|
29638
29628
|
value: props.value,
|
|
29639
29629
|
index: idx,
|
|
29640
|
-
functionalProperty: functionalProperty
|
|
29641
|
-
expandedAll: expandedAll
|
|
29630
|
+
functionalProperty: functionalProperty
|
|
29642
29631
|
});
|
|
29643
29632
|
}
|
|
29644
29633
|
}));
|
|
@@ -29807,8 +29796,7 @@ var Step = function Step(_ref8) {
|
|
|
29807
29796
|
value: getValues(entry) || defaultValue,
|
|
29808
29797
|
index: index,
|
|
29809
29798
|
functionalProperty: functionalProperty,
|
|
29810
|
-
errorDisplayed: errorDisplayed
|
|
29811
|
-
expandedAll: expandedAll
|
|
29799
|
+
errorDisplayed: errorDisplayed
|
|
29812
29800
|
}));
|
|
29813
29801
|
|
|
29814
29802
|
case format.code:
|
|
@@ -29876,15 +29864,15 @@ var Step = function Step(_ref8) {
|
|
|
29876
29864
|
var FileInput = function FileInput(_ref10) {
|
|
29877
29865
|
var onChange = _ref10.onChange;
|
|
29878
29866
|
|
|
29879
|
-
var
|
|
29880
|
-
|
|
29881
|
-
uploading =
|
|
29882
|
-
setUploading =
|
|
29867
|
+
var _useState3 = useState(false),
|
|
29868
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29869
|
+
uploading = _useState4[0],
|
|
29870
|
+
setUploading = _useState4[1];
|
|
29883
29871
|
|
|
29884
|
-
var
|
|
29885
|
-
|
|
29886
|
-
input =
|
|
29887
|
-
setInput =
|
|
29872
|
+
var _useState5 = useState(undefined),
|
|
29873
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29874
|
+
input = _useState6[0],
|
|
29875
|
+
setInput = _useState6[1];
|
|
29888
29876
|
|
|
29889
29877
|
var setFiles = function setFiles(e) {
|
|
29890
29878
|
var files = e.target.files;
|
|
@@ -30051,7 +30039,7 @@ var ArrayStep = function ArrayStep(_ref11) {
|
|
|
30051
30039
|
};
|
|
30052
30040
|
|
|
30053
30041
|
var NestedForm = function NestedForm(_ref12) {
|
|
30054
|
-
var _classNames17;
|
|
30042
|
+
var _step$conditionalSche, _classNames17;
|
|
30055
30043
|
|
|
30056
30044
|
var schema = _ref12.schema,
|
|
30057
30045
|
flow = _ref12.flow,
|
|
@@ -30062,25 +30050,20 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30062
30050
|
value = _ref12.value,
|
|
30063
30051
|
step = _ref12.step,
|
|
30064
30052
|
functionalProperty = _ref12.functionalProperty,
|
|
30065
|
-
index = _ref12.index
|
|
30066
|
-
expandedAll = _ref12.expandedAll;
|
|
30053
|
+
index = _ref12.index;
|
|
30067
30054
|
|
|
30068
30055
|
var _useFormContext4 = useFormContext(),
|
|
30069
30056
|
getValues = _useFormContext4.getValues,
|
|
30070
30057
|
setValue = _useFormContext4.setValue,
|
|
30071
30058
|
watch = _useFormContext4.watch;
|
|
30072
|
-
_useFormContext4.trigger;
|
|
30073
|
-
_useFormContext4.formState;
|
|
30074
30059
|
|
|
30075
|
-
var
|
|
30076
|
-
|
|
30077
|
-
collapsed =
|
|
30078
|
-
setCollapsed =
|
|
30060
|
+
var _useState7 = useState(!!step.collapsed),
|
|
30061
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
30062
|
+
collapsed = _useState8[0],
|
|
30063
|
+
setCollapsed = _useState8[1];
|
|
30079
30064
|
|
|
30080
30065
|
var classes = useCustomStyle();
|
|
30081
|
-
|
|
30082
|
-
if (!expandedAll || expandedAll && parent.split('.').length >= 2) setCollapsed(expandedAll);
|
|
30083
|
-
}, [expandedAll]);
|
|
30066
|
+
useWatch(step === null || step === void 0 ? void 0 : (_step$conditionalSche = step.conditionalSchema) === null || _step$conditionalSche === void 0 ? void 0 : _step$conditionalSche.ref);
|
|
30084
30067
|
var schemaAndFlow = option(step.conditionalSchema).map(function (condiSchema) {
|
|
30085
30068
|
var ref = option(condiSchema.ref).map(function (ref) {
|
|
30086
30069
|
return getValues(ref);
|
|
@@ -30096,9 +30079,16 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30096
30079
|
return s.condition === ref;
|
|
30097
30080
|
}
|
|
30098
30081
|
});
|
|
30099
|
-
|
|
30082
|
+
var schemaAndFlow = option(filterSwitch).orElse(condiSchema["switch"].find(function (s) {
|
|
30100
30083
|
return s["default"];
|
|
30101
|
-
}))
|
|
30084
|
+
})).getOrElse({
|
|
30085
|
+
schema: {},
|
|
30086
|
+
flow: []
|
|
30087
|
+
});
|
|
30088
|
+
return {
|
|
30089
|
+
schema: schemaAndFlow.schema,
|
|
30090
|
+
flow: schemaAndFlow.flow || Object.keys(schemaAndFlow.schema)
|
|
30091
|
+
};
|
|
30102
30092
|
}).getOrElse({
|
|
30103
30093
|
schema: schema,
|
|
30104
30094
|
flow: flow
|
|
@@ -30140,7 +30130,7 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30140
30130
|
}, []);
|
|
30141
30131
|
var bordered = computedSandF.filter(function (x) {
|
|
30142
30132
|
return x.visibleStep;
|
|
30143
|
-
}).length
|
|
30133
|
+
}).length >= 1 && step.label !== null;
|
|
30144
30134
|
return /*#__PURE__*/React.createElement("div", {
|
|
30145
30135
|
className: classNames((_classNames17 = {}, _defineProperty$1(_classNames17, classes.nestedform__border, bordered), _defineProperty$1(_classNames17, classes.border__error, !!errorDisplayed), _classNames17)),
|
|
30146
30136
|
style: {
|
|
@@ -30199,8 +30189,7 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30199
30189
|
inputWrapper: inputWrapper,
|
|
30200
30190
|
httpClient: maybeCustomHttpClient,
|
|
30201
30191
|
defaultValue: value && value[entry],
|
|
30202
|
-
functionalProperty: functionalProperty
|
|
30203
|
-
expandedAll: expandedAll
|
|
30192
|
+
functionalProperty: functionalProperty
|
|
30204
30193
|
}));
|
|
30205
30194
|
}));
|
|
30206
30195
|
};
|
package/lib/index.js
CHANGED
|
@@ -28549,7 +28549,6 @@ function CodeInput(_ref) {
|
|
|
28549
28549
|
}, []);
|
|
28550
28550
|
React.useEffect(function () {
|
|
28551
28551
|
if (editor && (_typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value) !== editor.state.doc.toString()) {
|
|
28552
|
-
console.log("set value", value, value === null || value === undefined ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value, editor.state.doc.toString());
|
|
28553
28552
|
editor.dispatch({
|
|
28554
28553
|
changes: {
|
|
28555
28554
|
from: 0,
|
|
@@ -28898,18 +28897,28 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28898
28897
|
return s.condition === ref;
|
|
28899
28898
|
}
|
|
28900
28899
|
});
|
|
28901
|
-
return option(filterSwitch).
|
|
28900
|
+
return option(filterSwitch).orElse(condiSchema["switch"].find(function (s) {
|
|
28902
28901
|
return s["default"];
|
|
28903
|
-
}))
|
|
28904
|
-
|
|
28902
|
+
})).getOrElse({
|
|
28903
|
+
schema: {},
|
|
28904
|
+
flow: []
|
|
28905
|
+
});
|
|
28906
|
+
}).getOrElse({
|
|
28907
|
+
schema: {},
|
|
28908
|
+
flow: []
|
|
28909
|
+
}),
|
|
28905
28910
|
schema = _option$map$getOrElse.schema,
|
|
28906
28911
|
flow = _option$map$getOrElse.flow;
|
|
28907
28912
|
|
|
28908
|
-
var
|
|
28913
|
+
var realFlow = flow || Object.keys(schema);
|
|
28909
28914
|
|
|
28910
|
-
|
|
28911
|
-
|
|
28912
|
-
|
|
28915
|
+
if (realFlow.length) {
|
|
28916
|
+
var _subResolver2 = getShapeAndDependencies(flow || Object.keys(schema), schema, dependencies, rawData);
|
|
28917
|
+
|
|
28918
|
+
return constraints.reduce(function (resolver, constraint) {
|
|
28919
|
+
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28920
|
+
}, yup__namespace.object().shape(_subResolver2.shape, dependencies));
|
|
28921
|
+
}
|
|
28913
28922
|
} else {
|
|
28914
28923
|
return constraints.reduce(function (resolver, constraint) {
|
|
28915
28924
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
@@ -28963,6 +28972,10 @@ var CustomizableInput$1 = /*#__PURE__*/React__default["default"].memo(function (
|
|
|
28963
28972
|
|
|
28964
28973
|
return props.children;
|
|
28965
28974
|
}, function (prev, next) {
|
|
28975
|
+
if (next.render || next.conditionalSchema) {
|
|
28976
|
+
return false;
|
|
28977
|
+
}
|
|
28978
|
+
|
|
28966
28979
|
return prev.field.value === next.field.value && next.errorDisplayed === prev.errorDisplayed;
|
|
28967
28980
|
});
|
|
28968
28981
|
var ControlledInput = function ControlledInput(_ref) {
|
|
@@ -29315,11 +29328,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29315
29328
|
});
|
|
29316
29329
|
};
|
|
29317
29330
|
|
|
29318
|
-
var _useState = React.useState(false),
|
|
29319
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29320
|
-
expandedAll = _useState2[0],
|
|
29321
|
-
setExpandedAll = _useState2[1];
|
|
29322
|
-
|
|
29323
29331
|
var defaultValues = getDefaultValues(formFlow, schema, value); //FIXME: get real schema through the switch
|
|
29324
29332
|
|
|
29325
29333
|
var _resolver = function resolver(rawData) {
|
|
@@ -29339,10 +29347,10 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29339
29347
|
mode: 'onChange'
|
|
29340
29348
|
});
|
|
29341
29349
|
|
|
29342
|
-
var
|
|
29343
|
-
|
|
29344
|
-
initialReseted =
|
|
29345
|
-
setReset =
|
|
29350
|
+
var _useState = React.useState(false),
|
|
29351
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29352
|
+
initialReseted = _useState2[0],
|
|
29353
|
+
setReset = _useState2[1];
|
|
29346
29354
|
|
|
29347
29355
|
React.useEffect(function () {
|
|
29348
29356
|
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
@@ -29353,9 +29361,9 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29353
29361
|
initialReseted && trigger();
|
|
29354
29362
|
}, [trigger, initialReseted]);
|
|
29355
29363
|
var _handleSubmit = methods.handleSubmit,
|
|
29356
|
-
_methods$formState = methods.formState
|
|
29357
|
-
|
|
29358
|
-
dirtyFields = _methods$formState.dirtyFields,
|
|
29364
|
+
_methods$formState = methods.formState;
|
|
29365
|
+
_methods$formState.errors;
|
|
29366
|
+
var dirtyFields = _methods$formState.dirtyFields,
|
|
29359
29367
|
_reset = methods.reset,
|
|
29360
29368
|
trigger = methods.trigger,
|
|
29361
29369
|
getValues = methods.getValues,
|
|
@@ -29408,19 +29416,7 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29408
29416
|
var clean = cleanOutputArray(data, schema);
|
|
29409
29417
|
onSubmit(clean);
|
|
29410
29418
|
}, onError)
|
|
29411
|
-
},
|
|
29412
|
-
className: classNames__default["default"](classes.flex, classes.mt_20)
|
|
29413
|
-
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
29414
|
-
type: "button",
|
|
29415
|
-
className: classNames__default["default"](classes.btn, classes.btn_sm),
|
|
29416
|
-
style: {
|
|
29417
|
-
marginLeft: 'auto'
|
|
29418
|
-
},
|
|
29419
|
-
onClick: function onClick(e) {
|
|
29420
|
-
if (e) e.stopPropagation();
|
|
29421
|
-
setExpandedAll(!expandedAll);
|
|
29422
|
-
}
|
|
29423
|
-
}, expandedAll ? 'Expand all' : 'Collapse all')), formFlow.map(function (entry, idx) {
|
|
29419
|
+
}, formFlow.map(function (entry, idx) {
|
|
29424
29420
|
var step = schema[entry];
|
|
29425
29421
|
|
|
29426
29422
|
if (!step && typeof entry === 'string') {
|
|
@@ -29428,9 +29424,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29428
29424
|
return null;
|
|
29429
29425
|
}
|
|
29430
29426
|
|
|
29431
|
-
_typeof$1(entry) === 'object' ? undefined : entry.split('.').reduce(function (object, key) {
|
|
29432
|
-
return object && object[key];
|
|
29433
|
-
}, errors);
|
|
29434
29427
|
var visibleStep = option(step).map(function (s) {
|
|
29435
29428
|
return s.visible;
|
|
29436
29429
|
}).map(function (visible) {
|
|
@@ -29468,8 +29461,7 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref7, re
|
|
|
29468
29461
|
schema: schema,
|
|
29469
29462
|
inputWrapper: inputWrapper,
|
|
29470
29463
|
httpClient: maybeCustomHttpClient,
|
|
29471
|
-
functionalProperty: functionalProperty
|
|
29472
|
-
expandedAll: expandedAll
|
|
29464
|
+
functionalProperty: functionalProperty
|
|
29473
29465
|
}));
|
|
29474
29466
|
}), /*#__PURE__*/React__default["default"].createElement(Footer, {
|
|
29475
29467
|
render: footer,
|
|
@@ -29527,8 +29519,7 @@ var Step = function Step(_ref8) {
|
|
|
29527
29519
|
index = _ref8.index,
|
|
29528
29520
|
functionalProperty = _ref8.functionalProperty,
|
|
29529
29521
|
parent = _ref8.parent,
|
|
29530
|
-
onAfterChange = _ref8.onAfterChange
|
|
29531
|
-
expandedAll = _ref8.expandedAll;
|
|
29522
|
+
onAfterChange = _ref8.onAfterChange;
|
|
29532
29523
|
var classes = useCustomStyle();
|
|
29533
29524
|
|
|
29534
29525
|
var _useFormContext2 = reactHookForm.useFormContext(),
|
|
@@ -29593,7 +29584,6 @@ var Step = function Step(_ref8) {
|
|
|
29593
29584
|
entry: en,
|
|
29594
29585
|
step: stp,
|
|
29595
29586
|
schema: schema,
|
|
29596
|
-
expandedAll: expandedAll,
|
|
29597
29587
|
inputWrapper: inputWrapper,
|
|
29598
29588
|
httpClient: httpClient,
|
|
29599
29589
|
defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue,
|
|
@@ -29671,8 +29661,7 @@ var Step = function Step(_ref8) {
|
|
|
29671
29661
|
defaultValue: (_props$defaultValue = props.defaultValue) === null || _props$defaultValue === void 0 ? void 0 : _props$defaultValue.value,
|
|
29672
29662
|
value: props.value,
|
|
29673
29663
|
index: idx,
|
|
29674
|
-
functionalProperty: functionalProperty
|
|
29675
|
-
expandedAll: expandedAll
|
|
29664
|
+
functionalProperty: functionalProperty
|
|
29676
29665
|
});
|
|
29677
29666
|
}
|
|
29678
29667
|
}));
|
|
@@ -29841,8 +29830,7 @@ var Step = function Step(_ref8) {
|
|
|
29841
29830
|
value: getValues(entry) || defaultValue,
|
|
29842
29831
|
index: index,
|
|
29843
29832
|
functionalProperty: functionalProperty,
|
|
29844
|
-
errorDisplayed: errorDisplayed
|
|
29845
|
-
expandedAll: expandedAll
|
|
29833
|
+
errorDisplayed: errorDisplayed
|
|
29846
29834
|
}));
|
|
29847
29835
|
|
|
29848
29836
|
case format.code:
|
|
@@ -29910,15 +29898,15 @@ var Step = function Step(_ref8) {
|
|
|
29910
29898
|
var FileInput = function FileInput(_ref10) {
|
|
29911
29899
|
var onChange = _ref10.onChange;
|
|
29912
29900
|
|
|
29913
|
-
var
|
|
29914
|
-
|
|
29915
|
-
uploading =
|
|
29916
|
-
setUploading =
|
|
29901
|
+
var _useState3 = React.useState(false),
|
|
29902
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
29903
|
+
uploading = _useState4[0],
|
|
29904
|
+
setUploading = _useState4[1];
|
|
29917
29905
|
|
|
29918
|
-
var
|
|
29919
|
-
|
|
29920
|
-
input =
|
|
29921
|
-
setInput =
|
|
29906
|
+
var _useState5 = React.useState(undefined),
|
|
29907
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29908
|
+
input = _useState6[0],
|
|
29909
|
+
setInput = _useState6[1];
|
|
29922
29910
|
|
|
29923
29911
|
var setFiles = function setFiles(e) {
|
|
29924
29912
|
var files = e.target.files;
|
|
@@ -30085,7 +30073,7 @@ var ArrayStep = function ArrayStep(_ref11) {
|
|
|
30085
30073
|
};
|
|
30086
30074
|
|
|
30087
30075
|
var NestedForm = function NestedForm(_ref12) {
|
|
30088
|
-
var _classNames17;
|
|
30076
|
+
var _step$conditionalSche, _classNames17;
|
|
30089
30077
|
|
|
30090
30078
|
var schema = _ref12.schema,
|
|
30091
30079
|
flow = _ref12.flow,
|
|
@@ -30096,25 +30084,20 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30096
30084
|
value = _ref12.value,
|
|
30097
30085
|
step = _ref12.step,
|
|
30098
30086
|
functionalProperty = _ref12.functionalProperty,
|
|
30099
|
-
index = _ref12.index
|
|
30100
|
-
expandedAll = _ref12.expandedAll;
|
|
30087
|
+
index = _ref12.index;
|
|
30101
30088
|
|
|
30102
30089
|
var _useFormContext4 = reactHookForm.useFormContext(),
|
|
30103
30090
|
getValues = _useFormContext4.getValues,
|
|
30104
30091
|
setValue = _useFormContext4.setValue,
|
|
30105
30092
|
watch = _useFormContext4.watch;
|
|
30106
|
-
_useFormContext4.trigger;
|
|
30107
|
-
_useFormContext4.formState;
|
|
30108
30093
|
|
|
30109
|
-
var
|
|
30110
|
-
|
|
30111
|
-
collapsed =
|
|
30112
|
-
setCollapsed =
|
|
30094
|
+
var _useState7 = React.useState(!!step.collapsed),
|
|
30095
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
30096
|
+
collapsed = _useState8[0],
|
|
30097
|
+
setCollapsed = _useState8[1];
|
|
30113
30098
|
|
|
30114
30099
|
var classes = useCustomStyle();
|
|
30115
|
-
|
|
30116
|
-
if (!expandedAll || expandedAll && parent.split('.').length >= 2) setCollapsed(expandedAll);
|
|
30117
|
-
}, [expandedAll]);
|
|
30100
|
+
reactHookForm.useWatch(step === null || step === void 0 ? void 0 : (_step$conditionalSche = step.conditionalSchema) === null || _step$conditionalSche === void 0 ? void 0 : _step$conditionalSche.ref);
|
|
30118
30101
|
var schemaAndFlow = option(step.conditionalSchema).map(function (condiSchema) {
|
|
30119
30102
|
var ref = option(condiSchema.ref).map(function (ref) {
|
|
30120
30103
|
return getValues(ref);
|
|
@@ -30130,9 +30113,16 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30130
30113
|
return s.condition === ref;
|
|
30131
30114
|
}
|
|
30132
30115
|
});
|
|
30133
|
-
|
|
30116
|
+
var schemaAndFlow = option(filterSwitch).orElse(condiSchema["switch"].find(function (s) {
|
|
30134
30117
|
return s["default"];
|
|
30135
|
-
}))
|
|
30118
|
+
})).getOrElse({
|
|
30119
|
+
schema: {},
|
|
30120
|
+
flow: []
|
|
30121
|
+
});
|
|
30122
|
+
return {
|
|
30123
|
+
schema: schemaAndFlow.schema,
|
|
30124
|
+
flow: schemaAndFlow.flow || Object.keys(schemaAndFlow.schema)
|
|
30125
|
+
};
|
|
30136
30126
|
}).getOrElse({
|
|
30137
30127
|
schema: schema,
|
|
30138
30128
|
flow: flow
|
|
@@ -30174,7 +30164,7 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30174
30164
|
}, []);
|
|
30175
30165
|
var bordered = computedSandF.filter(function (x) {
|
|
30176
30166
|
return x.visibleStep;
|
|
30177
|
-
}).length
|
|
30167
|
+
}).length >= 1 && step.label !== null;
|
|
30178
30168
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
30179
30169
|
className: classNames__default["default"]((_classNames17 = {}, _defineProperty$1(_classNames17, classes.nestedform__border, bordered), _defineProperty$1(_classNames17, classes.border__error, !!errorDisplayed), _classNames17)),
|
|
30180
30170
|
style: {
|
|
@@ -30233,8 +30223,7 @@ var NestedForm = function NestedForm(_ref12) {
|
|
|
30233
30223
|
inputWrapper: inputWrapper,
|
|
30234
30224
|
httpClient: maybeCustomHttpClient,
|
|
30235
30225
|
defaultValue: value && value[entry],
|
|
30236
|
-
functionalProperty: functionalProperty
|
|
30237
|
-
expandedAll: expandedAll
|
|
30226
|
+
functionalProperty: functionalProperty
|
|
30238
30227
|
}));
|
|
30239
30228
|
}));
|
|
30240
30229
|
};
|
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.0.
|
|
4
|
+
"version": "1.0.54",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
7
7
|
"types": "lib/index.js",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
]
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"react": "^17.0.2"
|
|
59
|
+
"react": "^17.0.2 || 18"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@babel/cli": "^7.17.6",
|
|
@@ -98,7 +98,6 @@
|
|
|
98
98
|
"@codemirror/theme-one-dark": "^0.19.1",
|
|
99
99
|
"@fortawesome/fontawesome-free": "^5.15.3",
|
|
100
100
|
"@hookform/resolvers": "2.4.0",
|
|
101
|
-
"@maif/react-forms": "^1.0.37-rc.1",
|
|
102
101
|
"@popperjs/core": "^2.11.2",
|
|
103
102
|
"@testing-library/jest-dom": "^5.11.4",
|
|
104
103
|
"@testing-library/react": "^11.1.0",
|