@maif/react-forms 1.0.35 → 1.0.38
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 +2 -12
- package/lib/esm/index.js +614 -819
- package/lib/index.js +616 -820
- package/package.json +11 -4
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -10
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -10
- package/.github/workflows/build-playground.yml +0 -34
- package/.github/workflows/generate-release-note.yml +0 -48
- package/.github/workflows/release.yml +0 -73
- package/docs/asset-manifest.json +0 -24
- package/docs/index.html +0 -1
- package/docs/manifest.json +0 -25
- package/docs/robots.txt +0 -3
- package/docs/static/css/2.6902daba.chunk.css +0 -11
- package/docs/static/css/2.6902daba.chunk.css.map +0 -1
- package/docs/static/css/main.8693c9f3.chunk.css +0 -2
- package/docs/static/css/main.8693c9f3.chunk.css.map +0 -1
- package/docs/static/js/2.bc3a307f.chunk.js +0 -3
- package/docs/static/js/2.bc3a307f.chunk.js.LICENSE.txt +0 -147
- package/docs/static/js/2.bc3a307f.chunk.js.map +0 -1
- package/docs/static/js/main.a5abf7f1.chunk.js +0 -2
- package/docs/static/js/main.a5abf7f1.chunk.js.map +0 -1
- package/docs/static/js/runtime-main.368a22f5.js +0 -2
- package/docs/static/js/runtime-main.368a22f5.js.map +0 -1
- package/docs/static/media/fa-brands-400.2285773e.woff +0 -0
- package/docs/static/media/fa-brands-400.23f19bb0.eot +0 -0
- package/docs/static/media/fa-brands-400.2f517e09.svg +0 -3717
- package/docs/static/media/fa-brands-400.527940b1.ttf +0 -0
- package/docs/static/media/fa-brands-400.d878b0a6.woff2 +0 -0
- package/docs/static/media/fa-regular-400.4689f52c.svg +0 -801
- package/docs/static/media/fa-regular-400.491974d1.ttf +0 -0
- package/docs/static/media/fa-regular-400.77206a6b.eot +0 -0
- package/docs/static/media/fa-regular-400.7a333762.woff2 +0 -0
- package/docs/static/media/fa-regular-400.bb58e57c.woff +0 -0
- package/docs/static/media/fa-solid-900.1551f4f6.woff2 +0 -0
- package/docs/static/media/fa-solid-900.7a8b4f13.svg +0 -5034
- package/docs/static/media/fa-solid-900.9bbb245e.eot +0 -0
- package/docs/static/media/fa-solid-900.be9ee23c.ttf +0 -0
- package/docs/static/media/fa-solid-900.eeccf4f6.woff +0 -0
- package/examples/.env +0 -2
- package/examples/README.md +0 -0
- package/examples/package.json +0 -43
- package/examples/public/index.html +0 -43
- package/examples/public/manifest.json +0 -25
- package/examples/public/robots.txt +0 -3
- package/examples/src/App.css +0 -10
- package/examples/src/Playground.js +0 -158
- package/examples/src/WrapperError.js +0 -21
- package/examples/src/index.css +0 -13
- package/examples/src/index.js +0 -11
- package/examples/src/reportWebVitals.js +0 -13
- package/examples/src/schema/basic.json +0 -15
- package/examples/src/schema/constrainedBasic.json +0 -28
- package/examples/src/schema/constraintsWithRef.json +0 -44
- package/examples/src/schema/dynamicForm.json +0 -57
- package/examples/src/schema/formArray.js +0 -30
- package/examples/src/schema/formInForm.json +0 -39
- package/examples/src/schema/selector.json +0 -14
- package/jest-sync.config.json +0 -17
- package/rollup.config.js +0 -64
- package/scripts/build.sh +0 -34
- package/test/array.spec.js +0 -78
- package/test/bool.spec.js +0 -29
- package/test/date.spec.js +0 -41
- package/test/number.spec.js +0 -124
- package/test/object.spec.js +0 -14
- package/test/string.spec.js +0 -87
- package/test/testUtils.js +0 -30
- package/test-setup.js +0 -9
package/lib/esm/index.js
CHANGED
|
@@ -3,13 +3,14 @@ import React, { useState, useEffect, useRef, useImperativeHandle } from 'react';
|
|
|
3
3
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
5
|
import { Eye, EyeOff, PlusCircle, MinusCircle, Trash2, ChevronDown, ChevronUp, HelpCircle, Loader, Upload } from 'react-feather';
|
|
6
|
-
import { useForm, FormProvider,
|
|
6
|
+
import { useController, useFormContext, useForm, FormProvider, Controller, useFieldArray, useWatch } from 'react-hook-form';
|
|
7
7
|
import { DatePicker } from 'react-rainbow-components';
|
|
8
8
|
import ReactToolTip from 'react-tooltip';
|
|
9
9
|
import { v4 } from 'uuid';
|
|
10
10
|
import { createUseStyles } from 'react-jss';
|
|
11
11
|
import CreatableSelect from 'react-select/creatable';
|
|
12
12
|
import Select from 'react-select';
|
|
13
|
+
import deepEqual from 'fast-deep-equal';
|
|
13
14
|
import showdown from 'showdown';
|
|
14
15
|
import '@fortawesome/fontawesome-free/css/all.css';
|
|
15
16
|
import 'highlight.js/styles/monokai.css';
|
|
@@ -29,7 +30,8 @@ var format = {
|
|
|
29
30
|
select: 'select',
|
|
30
31
|
code: 'code',
|
|
31
32
|
markdown: 'markdown',
|
|
32
|
-
text: '
|
|
33
|
+
text: 'textarea',
|
|
34
|
+
textarea: 'textarea',
|
|
33
35
|
email: 'email',
|
|
34
36
|
password: 'password',
|
|
35
37
|
hidden: 'hidden',
|
|
@@ -180,12 +182,6 @@ var _maxSize = function maxSize(ref) {
|
|
|
180
182
|
};
|
|
181
183
|
}; //mixed
|
|
182
184
|
|
|
183
|
-
var _nullable = function nullable() {
|
|
184
|
-
return function (r) {
|
|
185
|
-
return r.nullable().optional();
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
|
|
189
185
|
var _test = function test(name) {
|
|
190
186
|
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Test failed';
|
|
191
187
|
var test = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -220,12 +216,23 @@ var _oneOf = function oneOf(arrayOfValues) {
|
|
|
220
216
|
};
|
|
221
217
|
};
|
|
222
218
|
|
|
223
|
-
var
|
|
219
|
+
var _blacklist = function blacklist(arrayOfValues) {
|
|
220
|
+
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This value can't include the following values ".concat(arrayOfValues.join(', '));
|
|
221
|
+
return function (r) {
|
|
222
|
+
return r.test('blacklist' + Date.now(), message, function (value) {
|
|
223
|
+
return !arrayOfValues.some(function (f) {
|
|
224
|
+
return value.includes(f);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
var _ref21 = function ref(_ref) {
|
|
224
231
|
return yup.ref(_ref);
|
|
225
232
|
};
|
|
226
233
|
|
|
227
234
|
var maybeRef = function maybeRef(x) {
|
|
228
|
-
return x !== null && x !== void 0 && x.ref ?
|
|
235
|
+
return x !== null && x !== void 0 && x.ref ? _ref21(x.ref) : x;
|
|
229
236
|
}; //### JSON method ###
|
|
230
237
|
|
|
231
238
|
|
|
@@ -338,11 +345,14 @@ var jsonConstraints = {
|
|
|
338
345
|
message = _ref19$message === void 0 ? "This value must be one of ".concat(arrayOfValues.join(', ')) : _ref19$message;
|
|
339
346
|
return _oneOf(arrayOfValues, message);
|
|
340
347
|
},
|
|
341
|
-
|
|
342
|
-
|
|
348
|
+
blacklist: function blacklist(_ref20) {
|
|
349
|
+
var arrayOfValues = _ref20.arrayOfValues,
|
|
350
|
+
_ref20$message = _ref20.message,
|
|
351
|
+
message = _ref20$message === void 0 ? "This value can't include the following values ".concat(arrayOfValues.join(', ')) : _ref20$message;
|
|
352
|
+
return _blacklist(arrayOfValues, message);
|
|
343
353
|
},
|
|
344
|
-
|
|
345
|
-
return
|
|
354
|
+
ref: function ref(val) {
|
|
355
|
+
return _ref21(val.ref);
|
|
346
356
|
}
|
|
347
357
|
};
|
|
348
358
|
|
|
@@ -364,11 +374,11 @@ var constraints = /*#__PURE__*/Object.freeze({
|
|
|
364
374
|
supportedFormat: _supportedFormat,
|
|
365
375
|
unsupportedFormat: _unsupportedFormat,
|
|
366
376
|
maxSize: _maxSize,
|
|
367
|
-
nullable: _nullable,
|
|
368
377
|
test: _test,
|
|
369
378
|
when: _when,
|
|
370
379
|
oneOf: _oneOf,
|
|
371
|
-
|
|
380
|
+
blacklist: _blacklist,
|
|
381
|
+
ref: _ref21,
|
|
372
382
|
jsonConstraints: jsonConstraints
|
|
373
383
|
});
|
|
374
384
|
|
|
@@ -650,6 +660,9 @@ var style = (_style = {
|
|
|
650
660
|
jc_flex_end: {
|
|
651
661
|
justifyContent: "flex-end"
|
|
652
662
|
},
|
|
663
|
+
jc_flex_start: {
|
|
664
|
+
justifyContent: "flex-start"
|
|
665
|
+
},
|
|
653
666
|
ac_center: {
|
|
654
667
|
alignContent: "center"
|
|
655
668
|
},
|
|
@@ -726,6 +739,15 @@ var style = (_style = {
|
|
|
726
739
|
border: "1px solid green",
|
|
727
740
|
justifyContent: "flex-end"
|
|
728
741
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
742
|
+
width: "35px",
|
|
743
|
+
height: "22px",
|
|
744
|
+
borderRadius: "20px",
|
|
745
|
+
display: "flex",
|
|
746
|
+
marginTop: "10px",
|
|
747
|
+
backgroundColor: "#dc3545",
|
|
748
|
+
border: "1px solid #dc3545",
|
|
749
|
+
justifyContent: "flex-start"
|
|
750
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
729
751
|
width: "35px",
|
|
730
752
|
height: "22px",
|
|
731
753
|
borderRadius: "20px",
|
|
@@ -741,6 +763,14 @@ var style = (_style = {
|
|
|
741
763
|
width: "20px",
|
|
742
764
|
height: "20px"
|
|
743
765
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
766
|
+
backgroundColor: "#fff",
|
|
767
|
+
borderRadius: "20px",
|
|
768
|
+
cursor: "pointer",
|
|
769
|
+
width: "20px",
|
|
770
|
+
height: "20px",
|
|
771
|
+
border: "1px solid #dfdfdf",
|
|
772
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
773
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
744
774
|
backgroundColor: "#fff",
|
|
745
775
|
borderRadius: "20px",
|
|
746
776
|
cursor: "pointer",
|
|
@@ -759,7 +789,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
759
789
|
return classes;
|
|
760
790
|
};
|
|
761
791
|
|
|
762
|
-
var BooleanInput = function
|
|
792
|
+
var BooleanInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
763
793
|
var _classNames;
|
|
764
794
|
|
|
765
795
|
var onChange = _ref.onChange,
|
|
@@ -782,15 +812,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
782
812
|
}
|
|
783
813
|
}, /*#__PURE__*/React.createElement("div", {
|
|
784
814
|
className: classNames(classes.switch_button_on)
|
|
785
|
-
})), !value && /*#__PURE__*/React.createElement("div", {
|
|
815
|
+
})), !value && value !== null && /*#__PURE__*/React.createElement("div", {
|
|
786
816
|
className: classNames(classes.content_switch_button_off),
|
|
787
817
|
onClick: function onClick() {
|
|
788
818
|
return handleClick(true);
|
|
789
819
|
}
|
|
790
820
|
}, /*#__PURE__*/React.createElement("div", {
|
|
791
821
|
className: classNames(classes.switch_button_off)
|
|
822
|
+
})), value === null && /*#__PURE__*/React.createElement("div", {
|
|
823
|
+
className: classNames(classes.content_switch_button_null),
|
|
824
|
+
onClick: function onClick() {
|
|
825
|
+
return handleClick(true);
|
|
826
|
+
}
|
|
827
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
828
|
+
className: classNames(classes.switch_button_null)
|
|
792
829
|
})));
|
|
793
|
-
};
|
|
830
|
+
});
|
|
794
831
|
|
|
795
832
|
var Collapse = function Collapse(props) {
|
|
796
833
|
var _classNames4;
|
|
@@ -881,35 +918,22 @@ var None = {
|
|
|
881
918
|
}
|
|
882
919
|
};
|
|
883
920
|
|
|
884
|
-
var deepEqual = function deepEqual(a, b) {
|
|
885
|
-
if (a === b) return true;
|
|
886
|
-
if (_typeof$1(a) !== 'object' || _typeof$1(b) !== 'object' || a === null || b === null) return false;
|
|
887
|
-
var keysA = Object.keys(a),
|
|
888
|
-
keysB = Object.keys(b);
|
|
889
|
-
if (keysA.length !== keysB.length) return false;
|
|
890
|
-
|
|
891
|
-
for (var _i = 0, _keysA = keysA; _i < _keysA.length; _i++) {
|
|
892
|
-
var key = _keysA[_i];
|
|
893
|
-
if (!keysB.includes(key)) return false;
|
|
894
|
-
|
|
895
|
-
if (typeof a[key] === 'function' || typeof b[key] === 'function') {
|
|
896
|
-
if (a[key].toString() !== b[key].toString()) return false;
|
|
897
|
-
} else {
|
|
898
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
return true;
|
|
903
|
-
};
|
|
904
921
|
var isPromise = function isPromise(value) {
|
|
905
922
|
return Boolean(value && typeof value.then === 'function');
|
|
906
923
|
};
|
|
924
|
+
var arrayFlatten = function arrayFlatten(array) {
|
|
925
|
+
if (array.some(Array.isArray)) {
|
|
926
|
+
return arrayFlatten(array.flat());
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
return array;
|
|
930
|
+
};
|
|
907
931
|
|
|
908
932
|
var valueToSelectOption = function valueToSelectOption(value) {
|
|
909
933
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
910
934
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
911
935
|
|
|
912
|
-
if (value === null) {
|
|
936
|
+
if (value === null || !value) {
|
|
913
937
|
return null;
|
|
914
938
|
}
|
|
915
939
|
|
|
@@ -937,7 +961,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
937
961
|
});
|
|
938
962
|
};
|
|
939
963
|
|
|
940
|
-
var SelectInput = function
|
|
964
|
+
var SelectInput = /*#__PURE__*/React.forwardRef(function (props, _) {
|
|
941
965
|
var classes = useCustomStyle();
|
|
942
966
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
943
967
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1038,7 +1062,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1038
1062
|
return onChange(v);
|
|
1039
1063
|
};
|
|
1040
1064
|
|
|
1041
|
-
if (props.
|
|
1065
|
+
if (props.buttons) {
|
|
1042
1066
|
return /*#__PURE__*/React.createElement("div", {
|
|
1043
1067
|
style: {
|
|
1044
1068
|
display: 'flex'
|
|
@@ -1081,6 +1105,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1081
1105
|
name: "".concat(props.label, "-search"),
|
|
1082
1106
|
isLoading: loading,
|
|
1083
1107
|
value: value,
|
|
1108
|
+
isClearable: true,
|
|
1084
1109
|
defaultValue: value,
|
|
1085
1110
|
isDisabled: props.disabled,
|
|
1086
1111
|
placeholder: props.placeholder,
|
|
@@ -1091,7 +1116,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1091
1116
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1092
1117
|
}));
|
|
1093
1118
|
}
|
|
1094
|
-
};
|
|
1119
|
+
});
|
|
1095
1120
|
|
|
1096
1121
|
var ObjectInput = function ObjectInput(props) {
|
|
1097
1122
|
var _useState = useState(),
|
|
@@ -28427,7 +28452,7 @@ function Editor(parent, mode, onChange, value) {
|
|
|
28427
28452
|
}
|
|
28428
28453
|
} catch (_) {}
|
|
28429
28454
|
}), EditorView.editable.of(!readOnly)]),
|
|
28430
|
-
doc: _typeof(value) === 'object' ? value.value : value
|
|
28455
|
+
doc: !value ? '' : _typeof(value) === 'object' ? value.value : value
|
|
28431
28456
|
});
|
|
28432
28457
|
return new EditorView({
|
|
28433
28458
|
state: state,
|
|
@@ -28478,7 +28503,7 @@ function CodeInput(_ref) {
|
|
|
28478
28503
|
changes: {
|
|
28479
28504
|
from: 0,
|
|
28480
28505
|
to: editor.state.doc.length,
|
|
28481
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28506
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28482
28507
|
}
|
|
28483
28508
|
});
|
|
28484
28509
|
}, [value]);
|
|
@@ -28487,68 +28512,6 @@ function CodeInput(_ref) {
|
|
|
28487
28512
|
});
|
|
28488
28513
|
}
|
|
28489
28514
|
|
|
28490
|
-
window.hljs = window.hljs || hljs;
|
|
28491
|
-
|
|
28492
|
-
var DaikokuExtension = function DaikokuExtension() {
|
|
28493
|
-
// @ref: []()
|
|
28494
|
-
var refextension = {
|
|
28495
|
-
type: 'lang',
|
|
28496
|
-
regex: /@ref:\[(.*)\]\((.*)\)/g,
|
|
28497
|
-
replace: function replace(expression, title, docId) {
|
|
28498
|
-
var path = window.location.pathname;
|
|
28499
|
-
var rawParts = path.split('/');
|
|
28500
|
-
rawParts.shift();
|
|
28501
|
-
var parts = rawParts.splice(0, 5);
|
|
28502
|
-
var teamId = parts[1];
|
|
28503
|
-
var apiId = parts[3];
|
|
28504
|
-
var versionId = parts[4];
|
|
28505
|
-
return "<a href=\"/".concat(teamId, "/").concat(apiId, "/").concat(versionId, "/documentation/").concat(docId, "\">").concat(title, "</a>");
|
|
28506
|
-
}
|
|
28507
|
-
}; // @@@
|
|
28508
|
-
|
|
28509
|
-
var tripleArobase = {
|
|
28510
|
-
type: 'lang',
|
|
28511
|
-
regex: /@@@/g,
|
|
28512
|
-
replace: function replace() {
|
|
28513
|
-
console.log('@@@');
|
|
28514
|
-
return '</div>';
|
|
28515
|
-
}
|
|
28516
|
-
}; // @@@warning
|
|
28517
|
-
|
|
28518
|
-
var warningExtension = {
|
|
28519
|
-
type: 'lang',
|
|
28520
|
-
regex: /@@@ warning/g,
|
|
28521
|
-
replace: function replace() {
|
|
28522
|
-
return '<div class="note note-warning">';
|
|
28523
|
-
}
|
|
28524
|
-
}; // @@@warning { title = }
|
|
28525
|
-
|
|
28526
|
-
var warningTitleExtension = {
|
|
28527
|
-
type: 'lang',
|
|
28528
|
-
regex: /@@@ warning \{ title='(.*)' \}/g,
|
|
28529
|
-
replace: function replace(expr, title) {
|
|
28530
|
-
return "<div class=\"note note-warning\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28531
|
-
}
|
|
28532
|
-
}; // @@@note
|
|
28533
|
-
|
|
28534
|
-
var noteExtension = {
|
|
28535
|
-
type: 'lang',
|
|
28536
|
-
regex: /@@@ note/g,
|
|
28537
|
-
replace: function replace() {
|
|
28538
|
-
return '<div class="note">';
|
|
28539
|
-
}
|
|
28540
|
-
}; // @@@note { title = }
|
|
28541
|
-
|
|
28542
|
-
var noteTitleExtension = {
|
|
28543
|
-
type: 'lang',
|
|
28544
|
-
regex: /@@@ note \{ title='(.*)' \}/g,
|
|
28545
|
-
replace: function replace(expr, title) {
|
|
28546
|
-
return "<div class=\"note\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28547
|
-
}
|
|
28548
|
-
};
|
|
28549
|
-
return [refextension, warningTitleExtension, noteTitleExtension, warningExtension, noteExtension, tripleArobase];
|
|
28550
|
-
};
|
|
28551
|
-
|
|
28552
28515
|
var converter = new showdown.Converter({
|
|
28553
28516
|
omitExtraWLInCodeBlocks: true,
|
|
28554
28517
|
ghCompatibleHeaderId: true,
|
|
@@ -28559,20 +28522,15 @@ var converter = new showdown.Converter({
|
|
|
28559
28522
|
requireSpaceBeforeHeadingText: true,
|
|
28560
28523
|
ghMentions: true,
|
|
28561
28524
|
emoji: true,
|
|
28562
|
-
ghMentionsLink: '/{u}'
|
|
28563
|
-
extensions: [DaikokuExtension]
|
|
28525
|
+
ghMentionsLink: '/{u}'
|
|
28564
28526
|
});
|
|
28565
28527
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28566
|
-
var _useState = useState(
|
|
28528
|
+
var _useState = useState(props.preview),
|
|
28567
28529
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28568
28530
|
preview = _useState2[0],
|
|
28569
28531
|
setPreview = _useState2[1];
|
|
28570
28532
|
|
|
28571
|
-
var
|
|
28572
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28573
|
-
editor = _useState4[0];
|
|
28574
|
-
_useState4[1];
|
|
28575
|
-
|
|
28533
|
+
var ref = useRef();
|
|
28576
28534
|
useEffect(function () {
|
|
28577
28535
|
if (preview) {
|
|
28578
28536
|
showPreview();
|
|
@@ -28581,162 +28539,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28581
28539
|
var commands = [{
|
|
28582
28540
|
name: 'Add header',
|
|
28583
28541
|
icon: 'heading',
|
|
28584
|
-
inject: function inject() {
|
|
28585
|
-
|
|
28586
|
-
|
|
28542
|
+
inject: function inject(range) {
|
|
28543
|
+
return !range ? '#' : [{
|
|
28544
|
+
from: range.from,
|
|
28545
|
+
insert: "# "
|
|
28546
|
+
}];
|
|
28587
28547
|
}
|
|
28588
28548
|
}, {
|
|
28589
28549
|
name: 'Add bold text',
|
|
28590
28550
|
icon: 'bold',
|
|
28591
|
-
inject: function inject() {
|
|
28592
|
-
|
|
28593
|
-
|
|
28551
|
+
inject: function inject(range) {
|
|
28552
|
+
return !range ? '** **' : [{
|
|
28553
|
+
from: range.from,
|
|
28554
|
+
insert: "**"
|
|
28555
|
+
}, {
|
|
28556
|
+
from: range.to,
|
|
28557
|
+
insert: '**'
|
|
28558
|
+
}];
|
|
28594
28559
|
}
|
|
28595
28560
|
}, {
|
|
28596
28561
|
name: 'Add italic text',
|
|
28597
28562
|
icon: 'italic',
|
|
28598
|
-
inject: function inject() {
|
|
28599
|
-
|
|
28600
|
-
|
|
28563
|
+
inject: function inject(range) {
|
|
28564
|
+
return !range ? '* *' : [{
|
|
28565
|
+
from: range.from,
|
|
28566
|
+
insert: '*'
|
|
28567
|
+
}, {
|
|
28568
|
+
from: range.to,
|
|
28569
|
+
insert: '*'
|
|
28570
|
+
}];
|
|
28601
28571
|
}
|
|
28602
28572
|
}, {
|
|
28603
28573
|
name: 'Add strikethrough text',
|
|
28604
28574
|
icon: 'strikethrough',
|
|
28605
|
-
inject: function inject() {
|
|
28606
|
-
|
|
28607
|
-
|
|
28575
|
+
inject: function inject(range) {
|
|
28576
|
+
return !range ? '~~ ~~' : [{
|
|
28577
|
+
from: range.from,
|
|
28578
|
+
insert: '~~'
|
|
28579
|
+
}, {
|
|
28580
|
+
from: range.to,
|
|
28581
|
+
insert: '~~'
|
|
28582
|
+
}];
|
|
28608
28583
|
}
|
|
28609
28584
|
}, {
|
|
28610
28585
|
name: 'Add link',
|
|
28611
28586
|
icon: 'link',
|
|
28612
|
-
inject: function inject() {
|
|
28613
|
-
|
|
28614
|
-
|
|
28587
|
+
inject: function inject(range) {
|
|
28588
|
+
return !range ? '[ ](url)' : [{
|
|
28589
|
+
from: range.from,
|
|
28590
|
+
insert: '['
|
|
28591
|
+
}, {
|
|
28592
|
+
from: range.to,
|
|
28593
|
+
insert: '](url)'
|
|
28594
|
+
}];
|
|
28615
28595
|
}
|
|
28616
28596
|
}, {
|
|
28617
28597
|
name: 'Add code',
|
|
28618
28598
|
icon: 'code',
|
|
28619
|
-
inject: function inject() {
|
|
28620
|
-
|
|
28621
|
-
|
|
28622
|
-
|
|
28623
|
-
|
|
28624
|
-
|
|
28625
|
-
|
|
28626
|
-
|
|
28627
|
-
});
|
|
28599
|
+
inject: function inject(range) {
|
|
28600
|
+
return !range ? '```\n\n```\n' : [{
|
|
28601
|
+
from: range.from,
|
|
28602
|
+
insert: '```\n'
|
|
28603
|
+
}, {
|
|
28604
|
+
from: range.to,
|
|
28605
|
+
insert: '\n```\n'
|
|
28606
|
+
}];
|
|
28628
28607
|
}
|
|
28629
28608
|
}, {
|
|
28630
28609
|
name: 'Add quotes',
|
|
28631
28610
|
icon: 'quote-right',
|
|
28632
|
-
inject: function inject() {
|
|
28633
|
-
|
|
28634
|
-
|
|
28611
|
+
inject: function inject(range) {
|
|
28612
|
+
return !range ? '> ' : [{
|
|
28613
|
+
from: range.from,
|
|
28614
|
+
insert: '> '
|
|
28615
|
+
}];
|
|
28635
28616
|
}
|
|
28636
28617
|
}, {
|
|
28637
28618
|
name: 'Add image',
|
|
28638
28619
|
icon: 'image',
|
|
28639
|
-
inject: function inject() {
|
|
28640
|
-
|
|
28641
|
-
|
|
28620
|
+
inject: function inject(range) {
|
|
28621
|
+
return !range ? '' : [{
|
|
28622
|
+
from: range.from,
|
|
28623
|
+
insert: ''
|
|
28627
|
+
}];
|
|
28642
28628
|
}
|
|
28643
28629
|
}, {
|
|
28644
28630
|
name: 'Add unordered list',
|
|
28645
28631
|
icon: 'list-ul',
|
|
28646
|
-
inject: function inject() {
|
|
28647
|
-
|
|
28648
|
-
|
|
28632
|
+
inject: function inject(range) {
|
|
28633
|
+
return !range ? '* ' : [{
|
|
28634
|
+
from: range.from,
|
|
28635
|
+
insert: '* '
|
|
28636
|
+
}];
|
|
28649
28637
|
}
|
|
28650
28638
|
}, {
|
|
28651
28639
|
name: 'Add ordered list',
|
|
28652
28640
|
icon: 'list-ol',
|
|
28653
|
-
inject: function inject() {
|
|
28654
|
-
|
|
28655
|
-
|
|
28641
|
+
inject: function inject(range) {
|
|
28642
|
+
return !range ? '1. ' : [{
|
|
28643
|
+
from: range.from,
|
|
28644
|
+
insert: '1. '
|
|
28645
|
+
}];
|
|
28656
28646
|
}
|
|
28657
28647
|
}, {
|
|
28658
28648
|
name: 'Add check list',
|
|
28659
28649
|
icon: 'tasks',
|
|
28660
|
-
inject: function inject() {
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
name: 'Page ref',
|
|
28666
|
-
icon: 'book',
|
|
28667
|
-
inject: function inject() {
|
|
28668
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28669
|
-
return "@ref:[".concat(selected, "](team/api/doc)");
|
|
28670
|
-
}
|
|
28671
|
-
}, {
|
|
28672
|
-
name: 'Warning',
|
|
28673
|
-
icon: 'exclamation-triangle',
|
|
28674
|
-
inject: function inject() {
|
|
28675
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28676
|
-
return "@@@ warning\n".concat(selected, "\n@@@\n");
|
|
28677
|
-
},
|
|
28678
|
-
move: function move(pos, setPos) {
|
|
28679
|
-
return setPos({
|
|
28680
|
-
column: 0,
|
|
28681
|
-
row: pos.row - 2
|
|
28682
|
-
});
|
|
28683
|
-
}
|
|
28684
|
-
}, {
|
|
28685
|
-
name: 'Warning with title',
|
|
28686
|
-
icon: 'exclamation-circle',
|
|
28687
|
-
inject: function inject() {
|
|
28688
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28689
|
-
return "@@@ warning { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28690
|
-
},
|
|
28691
|
-
move: function move(pos, setPos) {
|
|
28692
|
-
return setPos({
|
|
28693
|
-
column: 0,
|
|
28694
|
-
row: pos.row - 2
|
|
28695
|
-
});
|
|
28696
|
-
}
|
|
28697
|
-
}, {
|
|
28698
|
-
name: 'Note',
|
|
28699
|
-
icon: 'sticky-note',
|
|
28700
|
-
inject: function inject() {
|
|
28701
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28702
|
-
return "@@@ note\n".concat(selected, "\n@@@\n");
|
|
28703
|
-
},
|
|
28704
|
-
move: function move(pos, setPos) {
|
|
28705
|
-
return setPos({
|
|
28706
|
-
column: 0,
|
|
28707
|
-
row: pos.row - 2
|
|
28708
|
-
});
|
|
28709
|
-
}
|
|
28710
|
-
}, {
|
|
28711
|
-
name: 'Note with title',
|
|
28712
|
-
icon: 'clipboard',
|
|
28713
|
-
inject: function inject() {
|
|
28714
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28715
|
-
return "@@@ note { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28716
|
-
},
|
|
28717
|
-
move: function move(pos, setPos) {
|
|
28718
|
-
return setPos({
|
|
28719
|
-
column: 0,
|
|
28720
|
-
row: pos.row - 2
|
|
28721
|
-
});
|
|
28722
|
-
}
|
|
28723
|
-
}, {
|
|
28724
|
-
name: 'Lorem Ipsum',
|
|
28725
|
-
icon: 'feather-alt',
|
|
28726
|
-
inject: function inject() {
|
|
28727
|
-
return 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida convallis leo et aliquet. Aenean venenatis, elit et dignissim scelerisque, urna dui mollis nunc, id eleifend velit sem et ante. Quisque pharetra sed tellus id finibus. In quis porta libero. Nunc egestas eros elementum lacinia blandit. Donec nisi lacus, tristique vel blandit in, sodales eget lacus. Phasellus ultrices magna vel odio vestibulum, a rhoncus nunc ornare. Sed laoreet finibus arcu vitae aliquam. Aliquam quis ex dui.';
|
|
28728
|
-
}
|
|
28729
|
-
}, {
|
|
28730
|
-
name: 'Long Lorem Ipsum',
|
|
28731
|
-
icon: 'feather',
|
|
28732
|
-
inject: function inject() {
|
|
28733
|
-
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida convallis leo et aliquet. Aenean venenatis, elit et dignissim scelerisque, urna dui mollis nunc, id eleifend velit sem et ante. Quisque pharetra sed tellus id finibus. In quis porta libero. Nunc egestas eros elementum lacinia blandit. Donec nisi lacus, tristique vel blandit in, sodales eget lacus. Phasellus ultrices magna vel odio vestibulum, a rhoncus nunc ornare. Sed laoreet finibus arcu vitae aliquam. Aliquam quis ex dui.\n\nCras ut ultrices quam. Nulla eu purus sed turpis consequat sodales. Aenean vitae efficitur velit, vel accumsan felis. Curabitur aliquam odio dictum urna convallis faucibus. Vivamus eu dignissim lorem. Donec sed hendrerit massa. Suspendisse volutpat, nisi at fringilla consequat, eros lacus aliquam metus, eu convallis nulla mauris quis lacus. Aliquam ultricies, mi eget feugiat vestibulum, enim nunc eleifend nisi, nec tincidunt turpis elit id diam. Nunc placerat accumsan tincidunt. Nulla ut interdum dui. Praesent venenatis cursus aliquet. Nunc pretium rutrum felis nec pharetra.\n\nVivamus sapien ligula, hendrerit a libero vitae, convallis maximus massa. Praesent ante leo, fermentum vitae libero finibus, blandit porttitor risus. Nulla ac hendrerit turpis. Sed varius velit at libero feugiat luctus. Nunc rhoncus sem dolor, nec euismod justo rhoncus vitae. Vivamus finibus nulla a purus vestibulum sagittis. Maecenas maximus orci at est lobortis, nec facilisis erat rhoncus. Sed tempus leo et est dictum lobortis. Vestibulum rhoncus, nisl ut porta sollicitudin, arcu urna egestas arcu, eget efficitur neque ipsum ut felis. Ut commodo purus quis turpis tempus tincidunt. Donec id hendrerit eros. Vestibulum vitae justo consectetur, egestas nisi ac, eleifend odio.\n\nDonec id mi cursus, volutpat dolor sed, bibendum sapien. Etiam vitae mauris sit amet urna semper tempus vel non metus. Integer sed ligula diam. Aenean molestie ultrices libero eget suscipit. Phasellus maximus euismod eros ut scelerisque. Ut quis tempus metus. Sed mollis volutpat velit eget pellentesque. Integer hendrerit ultricies massa eu tincidunt. Quisque at cursus augue. Sed diam odio, molestie sed dictum eget, efficitur nec nulla. Nullam vulputate posuere nunc nec laoreet. Integer varius sed erat vitae cursus. Vivamus auctor augue enim, a fringilla mauris molestie eget.\n\nProin vehicula ligula vel enim euismod, sed congue mi egestas. Nullam varius ut felis eu fringilla. Quisque sodales tortor nec justo tristique, sit amet consequat mi tincidunt. Suspendisse porttitor laoreet velit, non gravida nibh cursus at. Pellentesque faucibus, tellus in dapibus viverra, dolor mi dignissim tortor, id convallis ipsum lorem id nisl. Sed id nisi felis. Aliquam in ullamcorper ipsum, vel consequat magna. Donec nec mollis lacus, a euismod elit.";
|
|
28650
|
+
inject: function inject(range) {
|
|
28651
|
+
return !range ? '* [ ] ' : [{
|
|
28652
|
+
from: range.from,
|
|
28653
|
+
insert: '* [ ] '
|
|
28654
|
+
}];
|
|
28734
28655
|
}
|
|
28735
28656
|
}];
|
|
28736
28657
|
|
|
28737
28658
|
var showPreview = function showPreview() {
|
|
28738
|
-
|
|
28739
|
-
|
|
28659
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28660
|
+
|
|
28661
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28662
|
+
return hljs.highlightElement(block);
|
|
28740
28663
|
});
|
|
28741
28664
|
};
|
|
28742
28665
|
|
|
@@ -28754,21 +28677,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28754
28677
|
title: command.name,
|
|
28755
28678
|
key: "toolbar-btn-".concat(idx),
|
|
28756
28679
|
onClick: function onClick() {
|
|
28757
|
-
var
|
|
28758
|
-
|
|
28759
|
-
if (
|
|
28760
|
-
|
|
28761
|
-
|
|
28762
|
-
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
|
-
|
|
28766
|
-
|
|
28767
|
-
return
|
|
28768
|
-
|
|
28680
|
+
var editor = ref.current;
|
|
28681
|
+
var selections = editor.state.selection.ranges;
|
|
28682
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28683
|
+
changes: {
|
|
28684
|
+
from: 0,
|
|
28685
|
+
to: editor.state.doc.length,
|
|
28686
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28687
|
+
}
|
|
28688
|
+
});else {
|
|
28689
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28690
|
+
return {
|
|
28691
|
+
changes: command.inject(range),
|
|
28692
|
+
range: range
|
|
28693
|
+
};
|
|
28694
|
+
}));
|
|
28769
28695
|
}
|
|
28770
|
-
|
|
28771
|
-
editor.focus();
|
|
28772
28696
|
}
|
|
28773
28697
|
}, /*#__PURE__*/React.createElement("i", {
|
|
28774
28698
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28779,7 +28703,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28779
28703
|
var classes = useCustomStyle();
|
|
28780
28704
|
return /*#__PURE__*/React.createElement("div", {
|
|
28781
28705
|
className: classNames(props.className)
|
|
28782
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
28706
|
+
}, !props.readOnly && /*#__PURE__*/React.createElement("div", {
|
|
28783
28707
|
style: {
|
|
28784
28708
|
marginBottom: 10
|
|
28785
28709
|
}
|
|
@@ -28805,8 +28729,12 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28805
28729
|
}
|
|
28806
28730
|
}, "Preview"))), /*#__PURE__*/React.createElement("div", {
|
|
28807
28731
|
className: classNames(classes.flex)
|
|
28808
|
-
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput,
|
|
28809
|
-
|
|
28732
|
+
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput, _extends({}, props, {
|
|
28733
|
+
setRef: function setRef(e) {
|
|
28734
|
+
return ref.current = e;
|
|
28735
|
+
}
|
|
28736
|
+
})), preview && /*#__PURE__*/React.createElement("div", {
|
|
28737
|
+
className: "preview",
|
|
28810
28738
|
dangerouslySetInnerHTML: {
|
|
28811
28739
|
__html: converter.makeHtml(props.value)
|
|
28812
28740
|
}
|
|
@@ -28854,16 +28782,18 @@ function SingleLineCode(_ref) {
|
|
|
28854
28782
|
}
|
|
28855
28783
|
|
|
28856
28784
|
var _resolvers;
|
|
28857
|
-
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function () {
|
|
28858
|
-
return yup.string();
|
|
28785
|
+
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28786
|
+
return yup.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28859
28787
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28860
|
-
return yup.number().
|
|
28788
|
+
return yup.number().nullable().optional().transform(function (v) {
|
|
28789
|
+
return isNaN(v) ? null : v;
|
|
28790
|
+
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28861
28791
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28862
|
-
return yup.bool();
|
|
28792
|
+
return yup.bool().nullable().optional();
|
|
28863
28793
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28864
|
-
return yup.object();
|
|
28794
|
+
return yup.object().nullable().optional();
|
|
28865
28795
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28866
|
-
return yup.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28796
|
+
return yup.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28867
28797
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28868
28798
|
return yup.mixed();
|
|
28869
28799
|
}), _resolvers);
|
|
@@ -28890,6 +28820,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28890
28820
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28891
28821
|
}, arrayResolver);
|
|
28892
28822
|
} else if (props.type === type.object && props.schema) {
|
|
28823
|
+
if (!Object.keys(props.schema).length) {
|
|
28824
|
+
return yup.object();
|
|
28825
|
+
}
|
|
28826
|
+
|
|
28893
28827
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28894
28828
|
|
|
28895
28829
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -28940,11 +28874,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
28940
28874
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
28941
28875
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
28942
28876
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28877
|
+
|
|
28878
|
+
if (!Object.keys(schema).length) {
|
|
28879
|
+
return {
|
|
28880
|
+
shape: yup.object().shape({}),
|
|
28881
|
+
dependencies: dependencies
|
|
28882
|
+
};
|
|
28883
|
+
}
|
|
28884
|
+
|
|
28943
28885
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
28944
28886
|
if (_typeof$1(key) === 'object') {
|
|
28945
28887
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
28946
28888
|
}
|
|
28947
28889
|
|
|
28890
|
+
if (!schema[key]) {
|
|
28891
|
+
return resolvers;
|
|
28892
|
+
}
|
|
28893
|
+
|
|
28948
28894
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
28949
28895
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
28950
28896
|
}, {});
|
|
@@ -28954,13 +28900,102 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
28954
28900
|
};
|
|
28955
28901
|
};
|
|
28956
28902
|
|
|
28903
|
+
var CustomizableInput$1 = /*#__PURE__*/React.memo(function (props) {
|
|
28904
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
28905
|
+
if (props.render) {
|
|
28906
|
+
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
28907
|
+
error: props.error
|
|
28908
|
+
}));
|
|
28909
|
+
}
|
|
28910
|
+
|
|
28911
|
+
return props.children;
|
|
28912
|
+
}, function (prev, next) {
|
|
28913
|
+
return prev.field.value === next.field.value;
|
|
28914
|
+
});
|
|
28915
|
+
var ControlledInput = function ControlledInput(_ref) {
|
|
28916
|
+
var defaultValue = _ref.defaultValue,
|
|
28917
|
+
step = _ref.step,
|
|
28918
|
+
entry = _ref.entry,
|
|
28919
|
+
children = _ref.children,
|
|
28920
|
+
component = _ref.component;
|
|
28921
|
+
|
|
28922
|
+
var _useController = useController({
|
|
28923
|
+
defaultValue: defaultValue || null,
|
|
28924
|
+
name: entry
|
|
28925
|
+
}),
|
|
28926
|
+
field = _useController.field;
|
|
28927
|
+
|
|
28928
|
+
var _useFormContext = useFormContext(),
|
|
28929
|
+
getValues = _useFormContext.getValues,
|
|
28930
|
+
_setValue = _useFormContext.setValue,
|
|
28931
|
+
errors = _useFormContext.formState.errors;
|
|
28932
|
+
|
|
28933
|
+
var functionalProperty = function functionalProperty(entry, prop) {
|
|
28934
|
+
if (typeof prop === 'function') {
|
|
28935
|
+
return prop({
|
|
28936
|
+
rawValues: getValues(),
|
|
28937
|
+
value: getValues(entry)
|
|
28938
|
+
});
|
|
28939
|
+
} else {
|
|
28940
|
+
return prop;
|
|
28941
|
+
}
|
|
28942
|
+
};
|
|
28943
|
+
|
|
28944
|
+
var props = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, field), step.props), {}, {
|
|
28945
|
+
id: entry,
|
|
28946
|
+
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
28947
|
+
placeholder: step.placeholder,
|
|
28948
|
+
onChange: function onChange(e) {
|
|
28949
|
+
var value = function () {
|
|
28950
|
+
if (!e) {
|
|
28951
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28952
|
+
return e;
|
|
28953
|
+
} else {
|
|
28954
|
+
return null;
|
|
28955
|
+
}
|
|
28956
|
+
} else if (e.target) {
|
|
28957
|
+
return e.target.value || null;
|
|
28958
|
+
} else {
|
|
28959
|
+
return e;
|
|
28960
|
+
}
|
|
28961
|
+
}(); // field.onChange(!e ? null : e.target ? e.target.value || null : e)
|
|
28962
|
+
|
|
28963
|
+
|
|
28964
|
+
field.onChange(value);
|
|
28965
|
+
option(step.onChange).map(function (onChange) {
|
|
28966
|
+
return onChange({
|
|
28967
|
+
rawValues: getValues(),
|
|
28968
|
+
value: value,
|
|
28969
|
+
setValue: _setValue
|
|
28970
|
+
});
|
|
28971
|
+
});
|
|
28972
|
+
},
|
|
28973
|
+
value: field.value
|
|
28974
|
+
});
|
|
28975
|
+
|
|
28976
|
+
var error = entry.split('.').reduce(function (acc, curr) {
|
|
28977
|
+
return acc && acc[curr];
|
|
28978
|
+
}, errors);
|
|
28979
|
+
return /*#__PURE__*/React.createElement(CustomizableInput$1, {
|
|
28980
|
+
render: step.render,
|
|
28981
|
+
field: _objectSpread2$1({
|
|
28982
|
+
parent: parent,
|
|
28983
|
+
setValue: function setValue(key, value) {
|
|
28984
|
+
return _setValue(key, value);
|
|
28985
|
+
},
|
|
28986
|
+
rawValues: getValues()
|
|
28987
|
+
}, field),
|
|
28988
|
+
error: error
|
|
28989
|
+
}, component ? component(field, props) : /*#__PURE__*/React.cloneElement(children, _objectSpread2$1({}, props)));
|
|
28990
|
+
};
|
|
28991
|
+
|
|
28957
28992
|
var usePrevious = function usePrevious(value) {
|
|
28958
28993
|
// The ref object is a generic container whose current property is mutable ...
|
|
28959
28994
|
// ... and can hold any value, similar to an instance property on a class
|
|
28960
28995
|
var ref = useRef(); // Store current value in ref
|
|
28961
28996
|
|
|
28962
28997
|
useEffect(function () {
|
|
28963
|
-
ref.current = value
|
|
28998
|
+
ref.current = value;
|
|
28964
28999
|
}, [value]); // Only re-run if value changes
|
|
28965
29000
|
// Return previous value (happens before update in useEffect above)
|
|
28966
29001
|
|
|
@@ -29045,33 +29080,16 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29045
29080
|
return props.children;
|
|
29046
29081
|
};
|
|
29047
29082
|
|
|
29048
|
-
var defaultVal = function defaultVal(
|
|
29083
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29049
29084
|
if (!!defaultValue) return defaultValue;
|
|
29050
29085
|
if (!!array) return [];
|
|
29051
|
-
|
|
29052
|
-
switch (t) {
|
|
29053
|
-
case type.bool:
|
|
29054
|
-
return false;
|
|
29055
|
-
|
|
29056
|
-
case type.number:
|
|
29057
|
-
return 0;
|
|
29058
|
-
|
|
29059
|
-
case type.object:
|
|
29060
|
-
return undefined;
|
|
29061
|
-
//todo: passur de moi
|
|
29062
|
-
|
|
29063
|
-
case type.string:
|
|
29064
|
-
return "";
|
|
29065
|
-
|
|
29066
|
-
default:
|
|
29067
|
-
return undefined;
|
|
29068
|
-
}
|
|
29086
|
+
return value;
|
|
29069
29087
|
};
|
|
29070
29088
|
|
|
29071
|
-
var getDefaultValues = function getDefaultValues(flow, schema) {
|
|
29089
|
+
var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
29072
29090
|
return flow.reduce(function (acc, key) {
|
|
29073
29091
|
if (_typeof$1(key) === 'object') {
|
|
29074
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema));
|
|
29092
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema, value));
|
|
29075
29093
|
}
|
|
29076
29094
|
|
|
29077
29095
|
var entry = schema[key];
|
|
@@ -29080,19 +29098,29 @@ var getDefaultValues = function getDefaultValues(flow, schema) {
|
|
|
29080
29098
|
return acc;
|
|
29081
29099
|
}
|
|
29082
29100
|
|
|
29083
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(
|
|
29101
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29084
29102
|
}, {});
|
|
29085
29103
|
};
|
|
29086
29104
|
|
|
29087
|
-
var cleanInputArray = function cleanInputArray(obj, defaultValues, subSchema) {
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
|
|
29091
|
-
|
|
29105
|
+
var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSchema) {
|
|
29106
|
+
var realFlow = option(flow).map(function (f) {
|
|
29107
|
+
return f.map(function (v) {
|
|
29108
|
+
return v.flow || v;
|
|
29109
|
+
});
|
|
29110
|
+
}).map(arrayFlatten).getOrElse(Object.keys(subSchema));
|
|
29111
|
+
return Object.entries(subSchema).filter(function (_ref2) {
|
|
29112
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
29113
|
+
key = _ref3[0];
|
|
29114
|
+
|
|
29115
|
+
return realFlow.includes(key);
|
|
29116
|
+
}).reduce(function (acc, _ref4) {
|
|
29117
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
29118
|
+
key = _ref5[0],
|
|
29119
|
+
step = _ref5[1];
|
|
29092
29120
|
|
|
29093
29121
|
var v;
|
|
29094
29122
|
if (obj) v = obj[key];
|
|
29095
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29123
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29096
29124
|
|
|
29097
29125
|
if (step.array && !step.render) {
|
|
29098
29126
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29100,12 +29128,12 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, subSchema) {
|
|
|
29100
29128
|
value: value
|
|
29101
29129
|
};
|
|
29102
29130
|
})));
|
|
29103
|
-
} else if (
|
|
29104
|
-
var _subSchema$key;
|
|
29131
|
+
} else if (_typeof$1(v) === 'object' && !(v instanceof Date) && !Array.isArray(v)) {
|
|
29132
|
+
var _subSchema$key, _subSchema$key2;
|
|
29105
29133
|
|
|
29106
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanInputArray(v, defaultValues, (
|
|
29134
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanInputArray(v, defaultValues, (_subSchema$key = subSchema[key]) === null || _subSchema$key === void 0 ? void 0 : _subSchema$key.flow, ((_subSchema$key2 = subSchema[key]) === null || _subSchema$key2 === void 0 ? void 0 : _subSchema$key2.schema) || {})));
|
|
29107
29135
|
} else {
|
|
29108
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29136
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29109
29137
|
}
|
|
29110
29138
|
}, obj);
|
|
29111
29139
|
};
|
|
@@ -29125,17 +29153,17 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29125
29153
|
}).getOrElse(false);
|
|
29126
29154
|
|
|
29127
29155
|
if (isArray) {
|
|
29128
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v.map(function (
|
|
29129
|
-
var value =
|
|
29156
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v.map(function (_ref6) {
|
|
29157
|
+
var value = _ref6.value;
|
|
29130
29158
|
return value;
|
|
29131
29159
|
})));
|
|
29132
29160
|
}
|
|
29133
29161
|
|
|
29134
29162
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29135
29163
|
} else if (!!v && _typeof$1(v) === 'object' && !(v instanceof Date && !Array.isArray(v))) {
|
|
29136
|
-
var _subSchema$
|
|
29164
|
+
var _subSchema$key3;
|
|
29137
29165
|
|
|
29138
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanOutputArray(v, ((_subSchema$
|
|
29166
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanOutputArray(v, ((_subSchema$key3 = subSchema[key]) === null || _subSchema$key3 === void 0 ? void 0 : _subSchema$key3.schema) || {})));
|
|
29139
29167
|
} else {
|
|
29140
29168
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29141
29169
|
}
|
|
@@ -29153,20 +29181,54 @@ var validate = function validate(flow, schema, value) {
|
|
|
29153
29181
|
abortEarly: false
|
|
29154
29182
|
});
|
|
29155
29183
|
};
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
onSubmit =
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29184
|
+
|
|
29185
|
+
var Watcher = function Watcher(_ref7) {
|
|
29186
|
+
var options = _ref7.options,
|
|
29187
|
+
control = _ref7.control,
|
|
29188
|
+
schema = _ref7.schema,
|
|
29189
|
+
onSubmit = _ref7.onSubmit,
|
|
29190
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29191
|
+
_ref7.getValues;
|
|
29192
|
+
_ref7.watch;
|
|
29193
|
+
var data = useWatch({
|
|
29194
|
+
control: control
|
|
29195
|
+
});
|
|
29196
|
+
var prev = usePrevious(data);
|
|
29197
|
+
useEffect(function () {
|
|
29198
|
+
if (!!options.autosubmit) {
|
|
29199
|
+
if (!deepEqual(data, prev)) handleSubmit(function () {
|
|
29200
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29201
|
+
})();
|
|
29202
|
+
}
|
|
29203
|
+
}, [data]);
|
|
29204
|
+
|
|
29205
|
+
if (options.watch) {
|
|
29206
|
+
if (typeof options.watch === 'function') {
|
|
29207
|
+
options.watch(cleanOutputArray(data, schema));
|
|
29208
|
+
} else {
|
|
29209
|
+
console.group('react-form watch');
|
|
29210
|
+
console.log(cleanOutputArray(data, schema));
|
|
29211
|
+
console.groupEnd();
|
|
29212
|
+
}
|
|
29213
|
+
}
|
|
29214
|
+
|
|
29215
|
+
return null;
|
|
29216
|
+
};
|
|
29217
|
+
|
|
29218
|
+
var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
29219
|
+
var schema = _ref8.schema,
|
|
29220
|
+
flow = _ref8.flow,
|
|
29221
|
+
value = _ref8.value,
|
|
29222
|
+
inputWrapper = _ref8.inputWrapper,
|
|
29223
|
+
onSubmit = _ref8.onSubmit,
|
|
29224
|
+
_ref8$onError = _ref8.onError,
|
|
29225
|
+
onError = _ref8$onError === void 0 ? function () {} : _ref8$onError,
|
|
29226
|
+
footer = _ref8.footer,
|
|
29227
|
+
_ref8$style = _ref8.style,
|
|
29228
|
+
style = _ref8$style === void 0 ? {} : _ref8$style,
|
|
29229
|
+
className = _ref8.className,
|
|
29230
|
+
_ref8$options = _ref8.options,
|
|
29231
|
+
options = _ref8$options === void 0 ? {} : _ref8$options;
|
|
29170
29232
|
var classes = useCustomStyle(style);
|
|
29171
29233
|
var formFlow = flow || Object.keys(schema);
|
|
29172
29234
|
|
|
@@ -29185,7 +29247,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29185
29247
|
});
|
|
29186
29248
|
};
|
|
29187
29249
|
|
|
29188
|
-
var defaultValues = getDefaultValues(formFlow, schema); //FIXME: get real schema through the switch
|
|
29250
|
+
var defaultValues = getDefaultValues(formFlow, schema, value); //FIXME: get real schema through the switch
|
|
29189
29251
|
|
|
29190
29252
|
var _resolver = function resolver(rawData) {
|
|
29191
29253
|
var _getShapeAndDependenc2 = getShapeAndDependencies(formFlow, schema, [], rawData),
|
|
@@ -29200,50 +29262,49 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29200
29262
|
resolver: function resolver(data, context, options) {
|
|
29201
29263
|
return yupResolver(_resolver(data))(data, context, options);
|
|
29202
29264
|
},
|
|
29203
|
-
defaultValues: cleanInputArray(value, defaultValues, schema),
|
|
29204
29265
|
shouldFocusError: false,
|
|
29205
29266
|
mode: 'onChange'
|
|
29206
29267
|
});
|
|
29268
|
+
|
|
29269
|
+
var _useState = useState(false),
|
|
29270
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29271
|
+
initialReseted = _useState2[0],
|
|
29272
|
+
setReset = _useState2[1];
|
|
29273
|
+
|
|
29274
|
+
useEffect(function () {
|
|
29275
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29276
|
+
|
|
29277
|
+
setReset(true);
|
|
29278
|
+
}, [_reset]);
|
|
29279
|
+
useEffect(function () {
|
|
29280
|
+
initialReseted && trigger();
|
|
29281
|
+
}, [trigger, initialReseted]);
|
|
29207
29282
|
var _handleSubmit = methods.handleSubmit,
|
|
29208
29283
|
_methods$formState = methods.formState,
|
|
29209
29284
|
errors = _methods$formState.errors,
|
|
29210
29285
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29211
29286
|
_reset = methods.reset,
|
|
29212
|
-
watch = methods.watch,
|
|
29213
29287
|
trigger = methods.trigger,
|
|
29214
|
-
getValues = methods.getValues
|
|
29215
|
-
|
|
29216
|
-
|
|
29217
|
-
|
|
29218
|
-
useEffect(function () {
|
|
29219
|
-
if (value) {
|
|
29220
|
-
_reset(cleanInputArray(value, defaultValues, schema));
|
|
29221
|
-
}
|
|
29222
|
-
}, [value, _reset]);
|
|
29223
|
-
useEffect(function () {
|
|
29224
|
-
_reset(cleanInputArray(value, defaultValues, schema));
|
|
29225
|
-
}, [schema]);
|
|
29226
|
-
var data = watch();
|
|
29227
|
-
var prevData = usePrevious(data);
|
|
29288
|
+
getValues = methods.getValues,
|
|
29289
|
+
watch = methods.watch;
|
|
29290
|
+
var prev = usePrevious(value);
|
|
29291
|
+
var prevSchema = usePrevious(schema);
|
|
29228
29292
|
useEffect(function () {
|
|
29229
|
-
|
|
29230
|
-
|
|
29231
|
-
_handleSubmit(function (data) {
|
|
29232
|
-
var clean = cleanOutputArray(data, schema);
|
|
29233
|
-
onSubmit(clean);
|
|
29234
|
-
}, onError)();
|
|
29293
|
+
if (!deepEqual(value, prev) || !deepEqual(schema, prevSchema)) {
|
|
29294
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29235
29295
|
}
|
|
29236
|
-
}, [
|
|
29296
|
+
}, [value, schema]);
|
|
29237
29297
|
|
|
29238
|
-
|
|
29239
|
-
if (typeof
|
|
29240
|
-
|
|
29298
|
+
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29299
|
+
if (typeof prop === 'function') {
|
|
29300
|
+
return prop({
|
|
29301
|
+
rawValues: getValues(),
|
|
29302
|
+
value: getValues(entry)
|
|
29303
|
+
});
|
|
29241
29304
|
} else {
|
|
29242
|
-
|
|
29243
|
-
console.log(watch());
|
|
29244
|
-
console.groupEnd();
|
|
29305
|
+
return prop;
|
|
29245
29306
|
}
|
|
29246
|
-
}
|
|
29307
|
+
};
|
|
29247
29308
|
|
|
29248
29309
|
useImperativeHandle(ref, function () {
|
|
29249
29310
|
return {
|
|
@@ -29253,26 +29314,18 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29253
29314
|
onSubmit(clean);
|
|
29254
29315
|
}, onError)();
|
|
29255
29316
|
},
|
|
29256
|
-
rawData: function rawData() {
|
|
29257
|
-
return cleanOutputArray(data, schema);
|
|
29258
|
-
},
|
|
29259
29317
|
trigger: trigger,
|
|
29260
29318
|
methods: methods
|
|
29261
29319
|
};
|
|
29262
29320
|
});
|
|
29263
|
-
|
|
29264
|
-
|
|
29265
|
-
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
return prop;
|
|
29272
|
-
}
|
|
29273
|
-
};
|
|
29274
|
-
|
|
29275
|
-
return /*#__PURE__*/React.createElement(FormProvider, methods, /*#__PURE__*/React.createElement("form", {
|
|
29321
|
+
return /*#__PURE__*/React.createElement(FormProvider, methods, /*#__PURE__*/React.createElement(Watcher, {
|
|
29322
|
+
options: options,
|
|
29323
|
+
control: methods.control,
|
|
29324
|
+
schema: schema,
|
|
29325
|
+
onSubmit: onSubmit,
|
|
29326
|
+
handleSubmit: _handleSubmit,
|
|
29327
|
+
watch: methods.watch
|
|
29328
|
+
}), /*#__PURE__*/React.createElement("form", {
|
|
29276
29329
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29277
29330
|
onSubmit: _handleSubmit(function (data) {
|
|
29278
29331
|
var clean = cleanOutputArray(data, schema);
|
|
@@ -29373,17 +29426,18 @@ var Footer = function Footer(props) {
|
|
|
29373
29426
|
}, ((_props$actions8 = props.actions) === null || _props$actions8 === void 0 ? void 0 : (_props$actions8$submi = _props$actions8.submit) === null || _props$actions8$submi === void 0 ? void 0 : _props$actions8$submi.label) || 'Save'));
|
|
29374
29427
|
};
|
|
29375
29428
|
|
|
29376
|
-
var Step = function Step(
|
|
29377
|
-
var entry =
|
|
29378
|
-
realEntry =
|
|
29379
|
-
step =
|
|
29380
|
-
schema =
|
|
29381
|
-
inputWrapper =
|
|
29382
|
-
httpClient =
|
|
29383
|
-
defaultValue =
|
|
29384
|
-
index =
|
|
29385
|
-
functionalProperty =
|
|
29386
|
-
parent =
|
|
29429
|
+
var Step = function Step(_ref9) {
|
|
29430
|
+
var entry = _ref9.entry,
|
|
29431
|
+
realEntry = _ref9.realEntry,
|
|
29432
|
+
step = _ref9.step,
|
|
29433
|
+
schema = _ref9.schema,
|
|
29434
|
+
inputWrapper = _ref9.inputWrapper,
|
|
29435
|
+
httpClient = _ref9.httpClient,
|
|
29436
|
+
defaultValue = _ref9.defaultValue,
|
|
29437
|
+
index = _ref9.index,
|
|
29438
|
+
functionalProperty = _ref9.functionalProperty,
|
|
29439
|
+
parent = _ref9.parent,
|
|
29440
|
+
onAfterChange = _ref9.onAfterChange;
|
|
29387
29441
|
var classes = useCustomStyle();
|
|
29388
29442
|
|
|
29389
29443
|
var _useFormContext2 = useFormContext(),
|
|
@@ -29396,8 +29450,8 @@ var Step = function Step(_ref6) {
|
|
|
29396
29450
|
_useFormContext2.trigger;
|
|
29397
29451
|
var getValues = _useFormContext2.getValues,
|
|
29398
29452
|
_setValue = _useFormContext2.setValue,
|
|
29399
|
-
watch = _useFormContext2.watch
|
|
29400
|
-
|
|
29453
|
+
watch = _useFormContext2.watch;
|
|
29454
|
+
_useFormContext2.register;
|
|
29401
29455
|
|
|
29402
29456
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29403
29457
|
var errored = entry.flow.some(function (step) {
|
|
@@ -29466,6 +29520,29 @@ var Step = function Step(_ref6) {
|
|
|
29466
29520
|
return acc && acc[curr];
|
|
29467
29521
|
}, touchedFields);
|
|
29468
29522
|
var errorDisplayed = !!error && (isSubmitted || isDirty || isTouched);
|
|
29523
|
+
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29524
|
+
|
|
29525
|
+
if (onAfterChangeFunc) {
|
|
29526
|
+
var data = watch();
|
|
29527
|
+
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29528
|
+
return acc && acc[curr];
|
|
29529
|
+
}, data) || {};
|
|
29530
|
+
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29531
|
+
var newData = cleanOutputArray(d, schema);
|
|
29532
|
+
if (!deepEqual(newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29533
|
+
entry: entry,
|
|
29534
|
+
previousValue: currentData,
|
|
29535
|
+
value: getValues(entry),
|
|
29536
|
+
getValue: function getValue(e) {
|
|
29537
|
+
return getValues(e);
|
|
29538
|
+
},
|
|
29539
|
+
rawValues: newData,
|
|
29540
|
+
setValue: _setValue,
|
|
29541
|
+
onChange: function onChange(v) {
|
|
29542
|
+
return _setValue(entry, v);
|
|
29543
|
+
}
|
|
29544
|
+
});
|
|
29545
|
+
}
|
|
29469
29546
|
|
|
29470
29547
|
if (step.array) {
|
|
29471
29548
|
return /*#__PURE__*/React.createElement(CustomizableInput, {
|
|
@@ -29484,13 +29561,13 @@ var Step = function Step(_ref6) {
|
|
|
29484
29561
|
}, /*#__PURE__*/React.createElement(ArrayStep, {
|
|
29485
29562
|
entry: entry,
|
|
29486
29563
|
step: step,
|
|
29487
|
-
defaultValue: step.defaultValue || defaultVal(step.type),
|
|
29488
29564
|
disabled: functionalProperty(entry, step.disabled),
|
|
29489
29565
|
component: function component(props, idx) {
|
|
29490
29566
|
var _props$defaultValue;
|
|
29491
29567
|
|
|
29492
29568
|
return /*#__PURE__*/React.createElement(Step, {
|
|
29493
|
-
entry: "".concat(entry, "
|
|
29569
|
+
entry: "".concat(entry, ".").concat(idx, ".value"),
|
|
29570
|
+
onAfterChange: step.onAfterChange || step.on_after_change,
|
|
29494
29571
|
step: _objectSpread2$1(_objectSpread2$1({}, schema[realEntry || entry]), {}, {
|
|
29495
29572
|
render: step.itemRender,
|
|
29496
29573
|
onChange: undefined,
|
|
@@ -29508,325 +29585,129 @@ var Step = function Step(_ref6) {
|
|
|
29508
29585
|
}));
|
|
29509
29586
|
}
|
|
29510
29587
|
|
|
29511
|
-
var registeredInput = register(entry);
|
|
29512
|
-
|
|
29513
|
-
var inputProps = _objectSpread2$1(_objectSpread2$1({}, registeredInput), {}, {
|
|
29514
|
-
onChange: function onChange(e) {
|
|
29515
|
-
registeredInput.onChange(e);
|
|
29516
|
-
option(step.onChange).map(function (onChange) {
|
|
29517
|
-
return onChange({
|
|
29518
|
-
rawValues: getValues(),
|
|
29519
|
-
value: e.target.value,
|
|
29520
|
-
setValue: _setValue
|
|
29521
|
-
});
|
|
29522
|
-
});
|
|
29523
|
-
}
|
|
29524
|
-
});
|
|
29525
|
-
|
|
29526
29588
|
switch (step.type) {
|
|
29527
29589
|
case type.string:
|
|
29528
29590
|
switch (step.format) {
|
|
29529
29591
|
case format.text:
|
|
29530
|
-
return /*#__PURE__*/React.createElement(
|
|
29531
|
-
render: step.render,
|
|
29532
|
-
field: {
|
|
29533
|
-
parent: parent,
|
|
29534
|
-
setValue: function setValue(key, value) {
|
|
29535
|
-
return _setValue(key, value);
|
|
29536
|
-
},
|
|
29537
|
-
rawValues: getValues(),
|
|
29538
|
-
value: getValues(entry),
|
|
29539
|
-
onChange: function onChange(v) {
|
|
29540
|
-
return _setValue(entry, v);
|
|
29541
|
-
}
|
|
29542
|
-
},
|
|
29543
|
-
error: error
|
|
29544
|
-
}, /*#__PURE__*/React.createElement("textarea", _extends({
|
|
29545
|
-
type: "text",
|
|
29546
|
-
id: entry,
|
|
29547
|
-
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29548
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null
|
|
29549
|
-
}, step.props, {
|
|
29592
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29550
29593
|
defaultValue: defaultValue,
|
|
29551
|
-
|
|
29552
|
-
|
|
29594
|
+
step: step,
|
|
29595
|
+
entry: entry
|
|
29596
|
+
}, /*#__PURE__*/React.createElement("textarea", {
|
|
29597
|
+
type: "text",
|
|
29598
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29599
|
+
}));
|
|
29553
29600
|
|
|
29554
29601
|
case format.code:
|
|
29555
29602
|
case format.singleLineCode:
|
|
29556
29603
|
var Component = step.format === format.code ? CodeInput : SingleLineCode;
|
|
29557
|
-
return /*#__PURE__*/React.createElement(
|
|
29558
|
-
|
|
29559
|
-
|
|
29560
|
-
|
|
29561
|
-
|
|
29562
|
-
|
|
29563
|
-
|
|
29564
|
-
field: _objectSpread2$1({
|
|
29565
|
-
parent: parent,
|
|
29566
|
-
setValue: function setValue(key, value) {
|
|
29567
|
-
return _setValue(key, value);
|
|
29568
|
-
},
|
|
29569
|
-
rawValues: getValues()
|
|
29570
|
-
}, field),
|
|
29571
|
-
error: error
|
|
29572
|
-
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
29573
|
-
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29574
|
-
readOnly: functionalProperty(entry, step.disabled) ? true : false,
|
|
29575
|
-
onChange: function onChange(e) {
|
|
29576
|
-
field.onChange(e);
|
|
29577
|
-
option(step.onChange).map(function (onChange) {
|
|
29578
|
-
return onChange({
|
|
29579
|
-
rawValues: getValues(),
|
|
29580
|
-
value: e,
|
|
29581
|
-
setValue: _setValue
|
|
29582
|
-
});
|
|
29583
|
-
});
|
|
29584
|
-
},
|
|
29585
|
-
value: field.value,
|
|
29586
|
-
defaultValue: defaultValue
|
|
29587
|
-
}, step.props)));
|
|
29588
|
-
}
|
|
29589
|
-
});
|
|
29604
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29605
|
+
defaultValue: defaultValue,
|
|
29606
|
+
step: step,
|
|
29607
|
+
entry: entry
|
|
29608
|
+
}, /*#__PURE__*/React.createElement(Component, {
|
|
29609
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29610
|
+
}));
|
|
29590
29611
|
|
|
29591
29612
|
case format.markdown:
|
|
29592
|
-
return /*#__PURE__*/React.createElement(
|
|
29593
|
-
|
|
29594
|
-
|
|
29595
|
-
|
|
29596
|
-
|
|
29597
|
-
|
|
29598
|
-
|
|
29599
|
-
field: _objectSpread2$1({
|
|
29600
|
-
parent: parent,
|
|
29601
|
-
setValue: function setValue(key, value) {
|
|
29602
|
-
return _setValue(key, value);
|
|
29603
|
-
},
|
|
29604
|
-
rawValues: getValues()
|
|
29605
|
-
}, field),
|
|
29606
|
-
error: error
|
|
29607
|
-
}, /*#__PURE__*/React.createElement(MarkdownInput, _extends({}, step.props, {
|
|
29608
|
-
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29609
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29610
|
-
onChange: function onChange(e) {
|
|
29611
|
-
field.onChange(e);
|
|
29612
|
-
option(step.onChange).map(function (onChange) {
|
|
29613
|
-
return onChange({
|
|
29614
|
-
rawValues: getValues(),
|
|
29615
|
-
value: e,
|
|
29616
|
-
setValue: _setValue
|
|
29617
|
-
});
|
|
29618
|
-
});
|
|
29619
|
-
},
|
|
29620
|
-
value: field.value,
|
|
29621
|
-
defaultValue: defaultValue
|
|
29622
|
-
}, step)));
|
|
29623
|
-
}
|
|
29624
|
-
});
|
|
29613
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29614
|
+
defaultValue: defaultValue,
|
|
29615
|
+
step: step,
|
|
29616
|
+
entry: entry
|
|
29617
|
+
}, /*#__PURE__*/React.createElement(MarkdownInput, {
|
|
29618
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29619
|
+
}));
|
|
29625
29620
|
|
|
29626
29621
|
case format.buttonsSelect:
|
|
29627
29622
|
case format.select:
|
|
29628
|
-
|
|
29629
|
-
|
|
29630
|
-
|
|
29631
|
-
|
|
29632
|
-
|
|
29633
|
-
|
|
29634
|
-
|
|
29635
|
-
|
|
29636
|
-
|
|
29637
|
-
|
|
29638
|
-
|
|
29639
|
-
|
|
29640
|
-
|
|
29641
|
-
|
|
29642
|
-
|
|
29643
|
-
|
|
29644
|
-
|
|
29645
|
-
disabled: functionalProperty(entry, step.disabled),
|
|
29646
|
-
value: field.value,
|
|
29647
|
-
possibleValues: step.options,
|
|
29648
|
-
defaultValue: defaultValue,
|
|
29649
|
-
httpClient: httpClient,
|
|
29650
|
-
onChange: function onChange(value) {
|
|
29651
|
-
field.onChange(value);
|
|
29652
|
-
option(step.onChange).map(function (onChange) {
|
|
29653
|
-
return onChange({
|
|
29654
|
-
rawValues: getValues(),
|
|
29655
|
-
value: value,
|
|
29656
|
-
setValue: _setValue
|
|
29657
|
-
});
|
|
29658
|
-
});
|
|
29659
|
-
}
|
|
29660
|
-
})));
|
|
29661
|
-
}
|
|
29662
|
-
});
|
|
29623
|
+
{
|
|
29624
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29625
|
+
defaultValue: defaultValue,
|
|
29626
|
+
step: step,
|
|
29627
|
+
entry: entry
|
|
29628
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29629
|
+
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29630
|
+
disabled: functionalProperty(entry, step.disabled),
|
|
29631
|
+
possibleValues: step.options,
|
|
29632
|
+
httpClient: httpClient,
|
|
29633
|
+
isMulti: step.isMulti,
|
|
29634
|
+
createOption: step.createOption,
|
|
29635
|
+
transformer: step.transformer,
|
|
29636
|
+
optionsFrom: step.optionsFrom,
|
|
29637
|
+
buttons: step.format === format.buttonsSelect
|
|
29638
|
+
}));
|
|
29639
|
+
}
|
|
29663
29640
|
|
|
29664
29641
|
default:
|
|
29665
|
-
return /*#__PURE__*/React.createElement(
|
|
29666
|
-
render: step.render,
|
|
29667
|
-
field: {
|
|
29668
|
-
parent: parent,
|
|
29669
|
-
setValue: function setValue(key, value) {
|
|
29670
|
-
return _setValue(key, value);
|
|
29671
|
-
},
|
|
29672
|
-
rawValues: getValues(),
|
|
29673
|
-
value: getValues(entry),
|
|
29674
|
-
onChange: function onChange(v) {
|
|
29675
|
-
return _setValue(entry, v, {
|
|
29676
|
-
shouldValidate: true
|
|
29677
|
-
});
|
|
29678
|
-
}
|
|
29679
|
-
},
|
|
29680
|
-
error: error
|
|
29681
|
-
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
29682
|
-
type: step.format || 'text',
|
|
29683
|
-
id: entry,
|
|
29684
|
-
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29685
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29642
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29686
29643
|
defaultValue: defaultValue,
|
|
29687
|
-
|
|
29688
|
-
|
|
29644
|
+
step: step,
|
|
29645
|
+
entry: entry
|
|
29646
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
29647
|
+
type: step.format || 'text',
|
|
29648
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29649
|
+
}));
|
|
29689
29650
|
}
|
|
29690
29651
|
|
|
29691
29652
|
case type.number:
|
|
29692
29653
|
switch (step.format) {
|
|
29693
29654
|
case format.buttonsSelect:
|
|
29694
29655
|
case format.select:
|
|
29695
|
-
return /*#__PURE__*/React.createElement(
|
|
29696
|
-
|
|
29697
|
-
|
|
29698
|
-
|
|
29699
|
-
|
|
29700
|
-
|
|
29701
|
-
|
|
29702
|
-
|
|
29703
|
-
|
|
29704
|
-
|
|
29705
|
-
|
|
29706
|
-
|
|
29707
|
-
|
|
29708
|
-
|
|
29709
|
-
|
|
29710
|
-
}, /*#__PURE__*/React.createElement(SelectInput, _extends({}, step.props, step, {
|
|
29711
|
-
className: classNames(classes.content, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29712
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29713
|
-
onChange: function onChange(e) {
|
|
29714
|
-
field.onChange(e);
|
|
29715
|
-
option(step.onChange).map(function (onChange) {
|
|
29716
|
-
return onChange({
|
|
29717
|
-
rawValues: getValues(),
|
|
29718
|
-
value: e,
|
|
29719
|
-
setValue: _setValue
|
|
29720
|
-
});
|
|
29721
|
-
});
|
|
29722
|
-
},
|
|
29723
|
-
value: field.value,
|
|
29724
|
-
possibleValues: step.options,
|
|
29725
|
-
defaultValue: defaultValue,
|
|
29726
|
-
httpClient: httpClient
|
|
29727
|
-
})));
|
|
29728
|
-
}
|
|
29729
|
-
});
|
|
29656
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29657
|
+
defaultValue: defaultValue,
|
|
29658
|
+
step: step,
|
|
29659
|
+
entry: entry
|
|
29660
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29661
|
+
className: classNames(classes.content, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29662
|
+
possibleValues: step.options,
|
|
29663
|
+
httpClient: httpClient,
|
|
29664
|
+
isMulti: step.isMulti,
|
|
29665
|
+
createOption: step.createOption,
|
|
29666
|
+
onCreateOption: step.onCreateOption,
|
|
29667
|
+
transformer: step.transformer,
|
|
29668
|
+
optionsFrom: step.optionsFrom,
|
|
29669
|
+
buttons: step.format === format.buttonsSelect
|
|
29670
|
+
}));
|
|
29730
29671
|
|
|
29731
29672
|
default:
|
|
29732
|
-
return /*#__PURE__*/React.createElement(
|
|
29733
|
-
|
|
29734
|
-
|
|
29735
|
-
|
|
29736
|
-
|
|
29737
|
-
return _setValue(key, value);
|
|
29738
|
-
},
|
|
29739
|
-
rawValues: getValues(),
|
|
29740
|
-
value: getValues(entry),
|
|
29741
|
-
onChange: function onChange(v) {
|
|
29742
|
-
return _setValue(entry, v);
|
|
29743
|
-
}
|
|
29744
|
-
},
|
|
29745
|
-
error: error
|
|
29746
|
-
}, /*#__PURE__*/React.createElement("input", _extends({}, step.props, {
|
|
29673
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29674
|
+
defaultValue: defaultValue,
|
|
29675
|
+
step: step,
|
|
29676
|
+
entry: entry
|
|
29677
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
29747
29678
|
type: step.format || 'number',
|
|
29748
|
-
|
|
29749
|
-
|
|
29750
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29751
|
-
name: entry,
|
|
29752
|
-
placeholder: step.placeholder,
|
|
29753
|
-
defaultValue: defaultValue
|
|
29754
|
-
}, inputProps)));
|
|
29679
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29680
|
+
}));
|
|
29755
29681
|
}
|
|
29756
29682
|
|
|
29757
29683
|
case type.bool:
|
|
29758
|
-
return /*#__PURE__*/React.createElement(
|
|
29759
|
-
|
|
29760
|
-
|
|
29761
|
-
|
|
29762
|
-
|
|
29763
|
-
|
|
29764
|
-
|
|
29765
|
-
field: _objectSpread2$1({
|
|
29766
|
-
parent: parent,
|
|
29767
|
-
setValue: function setValue(key, value) {
|
|
29768
|
-
return _setValue(key, value);
|
|
29769
|
-
},
|
|
29770
|
-
rawValues: getValues()
|
|
29771
|
-
}, field),
|
|
29772
|
-
error: error
|
|
29773
|
-
}, /*#__PURE__*/React.createElement(BooleanInput, _extends({}, step.props, {
|
|
29774
|
-
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29775
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29776
|
-
onChange: function onChange(e) {
|
|
29777
|
-
field.onChange(e);
|
|
29778
|
-
option(step.onChange).map(function (onChange) {
|
|
29779
|
-
return onChange({
|
|
29780
|
-
rawValues: getValues(),
|
|
29781
|
-
value: e,
|
|
29782
|
-
setValue: _setValue
|
|
29783
|
-
});
|
|
29784
|
-
});
|
|
29785
|
-
},
|
|
29786
|
-
value: field.value
|
|
29787
|
-
})));
|
|
29788
|
-
}
|
|
29789
|
-
});
|
|
29684
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29685
|
+
defaultValue: defaultValue,
|
|
29686
|
+
step: step,
|
|
29687
|
+
entry: entry
|
|
29688
|
+
}, /*#__PURE__*/React.createElement(BooleanInput, {
|
|
29689
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29690
|
+
}));
|
|
29790
29691
|
|
|
29791
29692
|
case type.object:
|
|
29792
29693
|
switch (step.format) {
|
|
29793
29694
|
case format.buttonsSelect:
|
|
29794
29695
|
case format.select:
|
|
29795
|
-
return /*#__PURE__*/React.createElement(
|
|
29796
|
-
|
|
29797
|
-
|
|
29798
|
-
|
|
29799
|
-
|
|
29800
|
-
|
|
29801
|
-
|
|
29802
|
-
|
|
29803
|
-
|
|
29804
|
-
|
|
29805
|
-
|
|
29806
|
-
|
|
29807
|
-
|
|
29808
|
-
|
|
29809
|
-
|
|
29810
|
-
error: error
|
|
29811
|
-
}, /*#__PURE__*/React.createElement(SelectInput, _extends({}, step.props, step, {
|
|
29812
|
-
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29813
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29814
|
-
onChange: function onChange(e) {
|
|
29815
|
-
field.onChange(e);
|
|
29816
|
-
option(step.onChange).map(function (onChange) {
|
|
29817
|
-
return onChange({
|
|
29818
|
-
rawValues: getValues(),
|
|
29819
|
-
value: e,
|
|
29820
|
-
setValue: _setValue
|
|
29821
|
-
});
|
|
29822
|
-
});
|
|
29823
|
-
},
|
|
29824
|
-
value: field.value,
|
|
29825
|
-
possibleValues: step.options,
|
|
29826
|
-
httpClient: httpClient
|
|
29827
|
-
})));
|
|
29828
|
-
}
|
|
29829
|
-
});
|
|
29696
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29697
|
+
defaultValue: defaultValue,
|
|
29698
|
+
step: step,
|
|
29699
|
+
entry: entry
|
|
29700
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29701
|
+
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29702
|
+
possibleValues: step.options,
|
|
29703
|
+
httpClient: httpClient,
|
|
29704
|
+
isMulti: step.isMulti,
|
|
29705
|
+
createOption: step.createOption,
|
|
29706
|
+
onCreateOption: step.onCreateOption,
|
|
29707
|
+
transformer: step.transformer,
|
|
29708
|
+
optionsFrom: step.optionsFrom,
|
|
29709
|
+
buttons: step.format === format.buttonsSelect
|
|
29710
|
+
}));
|
|
29830
29711
|
|
|
29831
29712
|
case format.form:
|
|
29832
29713
|
//todo: disabled ?
|
|
@@ -29862,35 +29743,20 @@ var Step = function Step(_ref6) {
|
|
|
29862
29743
|
}));
|
|
29863
29744
|
|
|
29864
29745
|
case format.code:
|
|
29865
|
-
return /*#__PURE__*/React.createElement(
|
|
29866
|
-
|
|
29867
|
-
|
|
29868
|
-
|
|
29869
|
-
|
|
29870
|
-
return /*#__PURE__*/React.createElement(
|
|
29871
|
-
render: step.render,
|
|
29872
|
-
field: _objectSpread2$1({
|
|
29873
|
-
parent: parent,
|
|
29874
|
-
setValue: function setValue(key, value) {
|
|
29875
|
-
return _setValue(key, value);
|
|
29876
|
-
},
|
|
29877
|
-
rawValues: getValues()
|
|
29878
|
-
}, field),
|
|
29879
|
-
error: error
|
|
29880
|
-
}, /*#__PURE__*/React.createElement(CodeInput, _extends({}, step.props, step, {
|
|
29746
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29747
|
+
defaultValue: defaultValue,
|
|
29748
|
+
step: step,
|
|
29749
|
+
entry: entry,
|
|
29750
|
+
component: function component(field, props) {
|
|
29751
|
+
return /*#__PURE__*/React.createElement(CodeInput, _extends({}, props, {
|
|
29881
29752
|
className: classNames(_defineProperty$1({}, classes.input__invalid, error)),
|
|
29882
|
-
readOnly: functionalProperty(entry, step.disabled) ? true : false,
|
|
29883
29753
|
onChange: function onChange(e) {
|
|
29884
29754
|
var v;
|
|
29885
29755
|
|
|
29886
29756
|
try {
|
|
29887
29757
|
v = JSON.parse(e);
|
|
29888
29758
|
} catch (err) {
|
|
29889
|
-
|
|
29890
|
-
type: 'manual',
|
|
29891
|
-
message: err
|
|
29892
|
-
});
|
|
29893
|
-
v = {};
|
|
29759
|
+
v = e;
|
|
29894
29760
|
}
|
|
29895
29761
|
|
|
29896
29762
|
field.onChange(v);
|
|
@@ -29902,105 +29768,51 @@ var Step = function Step(_ref6) {
|
|
|
29902
29768
|
});
|
|
29903
29769
|
});
|
|
29904
29770
|
},
|
|
29905
|
-
value: _typeof$1(field.value) === 'object' ? JSON.stringify(field.value, null, 2) : field.value
|
|
29906
|
-
|
|
29907
|
-
})));
|
|
29771
|
+
value: field.value === null ? null : _typeof$1(field.value) === 'object' ? JSON.stringify(field.value, null, 2) : field.value
|
|
29772
|
+
}));
|
|
29908
29773
|
}
|
|
29909
29774
|
});
|
|
29910
29775
|
|
|
29911
29776
|
default:
|
|
29912
|
-
return /*#__PURE__*/React.createElement(
|
|
29913
|
-
|
|
29914
|
-
|
|
29915
|
-
|
|
29916
|
-
|
|
29917
|
-
|
|
29918
|
-
|
|
29919
|
-
|
|
29920
|
-
field: _objectSpread2$1({
|
|
29921
|
-
parent: parent,
|
|
29922
|
-
setValue: function setValue(key, value) {
|
|
29923
|
-
return _setValue(key, value);
|
|
29924
|
-
},
|
|
29925
|
-
rawValues: getValues()
|
|
29926
|
-
}, field),
|
|
29927
|
-
error: error
|
|
29928
|
-
}, /*#__PURE__*/React.createElement(ObjectInput, _extends({}, step.props, step, {
|
|
29929
|
-
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29930
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29931
|
-
onChange: function onChange(e) {
|
|
29932
|
-
field.onChange(e);
|
|
29933
|
-
option(step.onChange).map(function (onChange) {
|
|
29934
|
-
return onChange({
|
|
29935
|
-
rawValues: getValues(),
|
|
29936
|
-
value: e,
|
|
29937
|
-
setValue: _setValue
|
|
29938
|
-
});
|
|
29939
|
-
});
|
|
29940
|
-
},
|
|
29941
|
-
value: field.value,
|
|
29942
|
-
possibleValues: step.options
|
|
29943
|
-
})));
|
|
29944
|
-
}
|
|
29945
|
-
});
|
|
29777
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29778
|
+
defaultValue: defaultValue,
|
|
29779
|
+
step: step,
|
|
29780
|
+
entry: entry
|
|
29781
|
+
}, /*#__PURE__*/React.createElement(ObjectInput, {
|
|
29782
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29783
|
+
possibleValues: step.options
|
|
29784
|
+
}));
|
|
29946
29785
|
}
|
|
29947
29786
|
|
|
29948
29787
|
case type.date:
|
|
29949
|
-
return /*#__PURE__*/React.createElement(
|
|
29950
|
-
|
|
29951
|
-
|
|
29952
|
-
|
|
29953
|
-
|
|
29954
|
-
|
|
29955
|
-
|
|
29956
|
-
|
|
29957
|
-
field: _objectSpread2$1({
|
|
29958
|
-
parent: parent,
|
|
29959
|
-
setValue: function setValue(key, value) {
|
|
29960
|
-
return _setValue(key, value);
|
|
29961
|
-
},
|
|
29962
|
-
rawValues: getValues()
|
|
29963
|
-
}, field),
|
|
29964
|
-
error: error
|
|
29965
|
-
}, /*#__PURE__*/React.createElement(DatePicker, _extends({}, step.props, {
|
|
29966
|
-
id: "datePicker-1",
|
|
29967
|
-
className: classNames(classes.datepicker, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29968
|
-
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29969
|
-
value: field.value,
|
|
29970
|
-
onChange: function onChange(e) {
|
|
29971
|
-
field.onChange(e);
|
|
29972
|
-
option(step.onChange).map(function (onChange) {
|
|
29973
|
-
return onChange({
|
|
29974
|
-
rawValues: getValues(),
|
|
29975
|
-
value: e,
|
|
29976
|
-
setValue: _setValue
|
|
29977
|
-
});
|
|
29978
|
-
});
|
|
29979
|
-
},
|
|
29980
|
-
formatStyle: "large"
|
|
29981
|
-
})));
|
|
29982
|
-
}
|
|
29983
|
-
});
|
|
29788
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29789
|
+
defaultValue: defaultValue,
|
|
29790
|
+
step: step,
|
|
29791
|
+
entry: entry
|
|
29792
|
+
}, /*#__PURE__*/React.createElement(DatePicker, {
|
|
29793
|
+
className: classNames(classes.datepicker, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29794
|
+
formatStyle: "large"
|
|
29795
|
+
}));
|
|
29984
29796
|
|
|
29985
29797
|
case type.file:
|
|
29986
29798
|
return /*#__PURE__*/React.createElement(Controller, {
|
|
29987
29799
|
name: entry,
|
|
29988
29800
|
control: control,
|
|
29989
|
-
render: function render(
|
|
29990
|
-
var field =
|
|
29991
|
-
|
|
29992
|
-
var FileInput = function FileInput(_ref17) {
|
|
29993
|
-
var onChange = _ref17.onChange;
|
|
29801
|
+
render: function render(_ref10) {
|
|
29802
|
+
var field = _ref10.field;
|
|
29994
29803
|
|
|
29995
|
-
|
|
29996
|
-
|
|
29997
|
-
uploading = _useState2[0],
|
|
29998
|
-
setUploading = _useState2[1];
|
|
29804
|
+
var FileInput = function FileInput(_ref11) {
|
|
29805
|
+
var onChange = _ref11.onChange;
|
|
29999
29806
|
|
|
30000
|
-
var _useState3 = useState(
|
|
29807
|
+
var _useState3 = useState(false),
|
|
30001
29808
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
30002
|
-
|
|
30003
|
-
|
|
29809
|
+
uploading = _useState4[0],
|
|
29810
|
+
setUploading = _useState4[1];
|
|
29811
|
+
|
|
29812
|
+
var _useState5 = useState(undefined),
|
|
29813
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29814
|
+
input = _useState6[0],
|
|
29815
|
+
setInput = _useState6[1];
|
|
30004
29816
|
|
|
30005
29817
|
var setFiles = function setFiles(e) {
|
|
30006
29818
|
var files = e.target.files;
|
|
@@ -30038,28 +29850,11 @@ var Step = function Step(_ref6) {
|
|
|
30038
29850
|
}).join(" , ")));
|
|
30039
29851
|
};
|
|
30040
29852
|
|
|
30041
|
-
return /*#__PURE__*/React.createElement(
|
|
30042
|
-
|
|
30043
|
-
|
|
30044
|
-
|
|
30045
|
-
|
|
30046
|
-
return _setValue(key, value);
|
|
30047
|
-
},
|
|
30048
|
-
rawValues: getValues()
|
|
30049
|
-
}, field),
|
|
30050
|
-
error: error
|
|
30051
|
-
}, /*#__PURE__*/React.createElement(FileInput, {
|
|
30052
|
-
onChange: function onChange(e) {
|
|
30053
|
-
field.onChange(e);
|
|
30054
|
-
option(step.onChange).map(function (onChange) {
|
|
30055
|
-
return onChange({
|
|
30056
|
-
rawValues: getValues(),
|
|
30057
|
-
value: e,
|
|
30058
|
-
setValue: _setValue
|
|
30059
|
-
});
|
|
30060
|
-
});
|
|
30061
|
-
}
|
|
30062
|
-
}));
|
|
29853
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29854
|
+
defaultValue: defaultValue,
|
|
29855
|
+
step: step,
|
|
29856
|
+
entry: entry
|
|
29857
|
+
}, /*#__PURE__*/React.createElement(FileInput, null));
|
|
30063
29858
|
}
|
|
30064
29859
|
});
|
|
30065
29860
|
|
|
@@ -30068,18 +29863,17 @@ var Step = function Step(_ref6) {
|
|
|
30068
29863
|
}
|
|
30069
29864
|
};
|
|
30070
29865
|
|
|
30071
|
-
var ArrayStep = function ArrayStep(
|
|
30072
|
-
var entry =
|
|
30073
|
-
step =
|
|
30074
|
-
component =
|
|
30075
|
-
disabled =
|
|
29866
|
+
var ArrayStep = function ArrayStep(_ref12) {
|
|
29867
|
+
var entry = _ref12.entry,
|
|
29868
|
+
step = _ref12.step,
|
|
29869
|
+
component = _ref12.component,
|
|
29870
|
+
disabled = _ref12.disabled;
|
|
30076
29871
|
var classes = useCustomStyle();
|
|
30077
29872
|
|
|
30078
29873
|
var _useFormContext3 = useFormContext(),
|
|
30079
29874
|
getValues = _useFormContext3.getValues,
|
|
30080
|
-
setValue = _useFormContext3.setValue
|
|
30081
|
-
_useFormContext3.
|
|
30082
|
-
var control = _useFormContext3.control,
|
|
29875
|
+
setValue = _useFormContext3.setValue,
|
|
29876
|
+
control = _useFormContext3.control,
|
|
30083
29877
|
trigger = _useFormContext3.trigger,
|
|
30084
29878
|
formState = _useFormContext3.formState;
|
|
30085
29879
|
|
|
@@ -30097,15 +29891,11 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30097
29891
|
|
|
30098
29892
|
var _useFieldArray = useFieldArray({
|
|
30099
29893
|
control: control,
|
|
30100
|
-
|
|
30101
|
-
name: entry // unique name for your Field Array
|
|
30102
|
-
// keyName: "id", default to "id", you can change the key name
|
|
30103
|
-
|
|
29894
|
+
name: entry
|
|
30104
29895
|
}),
|
|
30105
29896
|
fields = _useFieldArray.fields,
|
|
30106
29897
|
append = _useFieldArray.append,
|
|
30107
29898
|
remove = _useFieldArray.remove;
|
|
30108
|
-
_useFieldArray.update;
|
|
30109
29899
|
|
|
30110
29900
|
return /*#__PURE__*/React.createElement(React.Fragment, null, fields.map(function (field, idx) {
|
|
30111
29901
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -30115,11 +29905,15 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30115
29905
|
style: {
|
|
30116
29906
|
position: 'relative'
|
|
30117
29907
|
}
|
|
29908
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
29909
|
+
style: {
|
|
29910
|
+
width: '95%'
|
|
29911
|
+
}
|
|
30118
29912
|
}, component(_objectSpread2$1(_objectSpread2$1({
|
|
30119
29913
|
key: field.id
|
|
30120
29914
|
}, field), {}, {
|
|
30121
29915
|
defaultValue: values[idx]
|
|
30122
|
-
}), idx), /*#__PURE__*/React.createElement("button", {
|
|
29916
|
+
}), idx)), /*#__PURE__*/React.createElement("button", {
|
|
30123
29917
|
type: "button",
|
|
30124
29918
|
style: {
|
|
30125
29919
|
position: 'absolute',
|
|
@@ -30142,7 +29936,7 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30142
29936
|
className: classNames(classes.btn, classes.btn_blue, classes.btn_sm, classes.mt_5, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
30143
29937
|
onClick: function onClick() {
|
|
30144
29938
|
append({
|
|
30145
|
-
value: step.addableDefaultValue || defaultVal(
|
|
29939
|
+
value: step.addableDefaultValue || defaultVal(null)
|
|
30146
29940
|
});
|
|
30147
29941
|
trigger(entry);
|
|
30148
29942
|
option(step.onChange).map(function (onChange) {
|
|
@@ -30159,37 +29953,38 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30159
29953
|
}, error.message)));
|
|
30160
29954
|
};
|
|
30161
29955
|
|
|
30162
|
-
var NestedForm = function NestedForm(
|
|
29956
|
+
var NestedForm = function NestedForm(_ref13) {
|
|
30163
29957
|
var _classNames16;
|
|
30164
29958
|
|
|
30165
|
-
var schema =
|
|
30166
|
-
flow =
|
|
30167
|
-
parent =
|
|
30168
|
-
inputWrapper =
|
|
30169
|
-
maybeCustomHttpClient =
|
|
30170
|
-
errorDisplayed =
|
|
30171
|
-
value =
|
|
30172
|
-
step =
|
|
30173
|
-
functionalProperty =
|
|
30174
|
-
index =
|
|
29959
|
+
var schema = _ref13.schema,
|
|
29960
|
+
flow = _ref13.flow,
|
|
29961
|
+
parent = _ref13.parent,
|
|
29962
|
+
inputWrapper = _ref13.inputWrapper,
|
|
29963
|
+
maybeCustomHttpClient = _ref13.maybeCustomHttpClient,
|
|
29964
|
+
errorDisplayed = _ref13.errorDisplayed,
|
|
29965
|
+
value = _ref13.value,
|
|
29966
|
+
step = _ref13.step,
|
|
29967
|
+
functionalProperty = _ref13.functionalProperty,
|
|
29968
|
+
index = _ref13.index;
|
|
30175
29969
|
|
|
30176
29970
|
var _useFormContext4 = useFormContext(),
|
|
30177
29971
|
getValues = _useFormContext4.getValues,
|
|
30178
29972
|
setValue = _useFormContext4.setValue,
|
|
30179
|
-
watch = _useFormContext4.watch
|
|
30180
|
-
|
|
29973
|
+
watch = _useFormContext4.watch;
|
|
29974
|
+
_useFormContext4.trigger;
|
|
30181
29975
|
_useFormContext4.formState;
|
|
30182
29976
|
|
|
30183
|
-
var
|
|
30184
|
-
|
|
30185
|
-
collapsed =
|
|
30186
|
-
setCollapsed =
|
|
29977
|
+
var _useState7 = useState(!!step.collapsed),
|
|
29978
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
29979
|
+
collapsed = _useState8[0],
|
|
29980
|
+
setCollapsed = _useState8[1];
|
|
29981
|
+
|
|
29982
|
+
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
29983
|
+
// const v = getValues(parent);
|
|
29984
|
+
// useEffect(() => {
|
|
29985
|
+
// trigger(parent)
|
|
29986
|
+
// }, [JSON.stringify(v)])
|
|
30187
29987
|
|
|
30188
|
-
var classes = useCustomStyle();
|
|
30189
|
-
var v = getValues(parent);
|
|
30190
|
-
useEffect(function () {
|
|
30191
|
-
trigger(parent);
|
|
30192
|
-
}, [JSON.stringify(v)]);
|
|
30193
29988
|
var schemaAndFlow = option(step.conditionalSchema).map(function (condiSchema) {
|
|
30194
29989
|
var ref = option(condiSchema.ref).map(function (ref) {
|
|
30195
29990
|
return getValues(ref);
|
|
@@ -30214,8 +30009,8 @@ var NestedForm = function NestedForm(_ref19) {
|
|
|
30214
30009
|
});
|
|
30215
30010
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30216
30011
|
useEffect(function () {
|
|
30217
|
-
if (!!prevSchema &&
|
|
30218
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30012
|
+
if (!!prevSchema && !deepEqual(prevSchema, schemaAndFlow.schema)) {
|
|
30013
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30219
30014
|
setValue(parent, def, {
|
|
30220
30015
|
shouldValidate: false
|
|
30221
30016
|
});
|
|
@@ -30281,10 +30076,10 @@ var NestedForm = function NestedForm(_ref19) {
|
|
|
30281
30076
|
onClick: function onClick() {
|
|
30282
30077
|
return setCollapsed(!collapsed);
|
|
30283
30078
|
}
|
|
30284
|
-
}), computedSandF.map(function (
|
|
30285
|
-
var step =
|
|
30286
|
-
visibleStep =
|
|
30287
|
-
entry =
|
|
30079
|
+
}), computedSandF.map(function (_ref14, idx) {
|
|
30080
|
+
var step = _ref14.step,
|
|
30081
|
+
visibleStep = _ref14.visibleStep,
|
|
30082
|
+
entry = _ref14.entry;
|
|
30288
30083
|
|
|
30289
30084
|
if (!step && typeof entry === 'string') {
|
|
30290
30085
|
console.error("no step found for the entry \"".concat(entry, "\" in the given schema. Your form might not work properly. Please fix it"));
|