@maif/react-forms 1.0.36 → 1.0.39
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 +620 -824
- package/lib/index.js +622 -825
- 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 -66
- 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', 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
|
|
|
@@ -632,6 +642,9 @@ var style = (_style = {
|
|
|
632
642
|
d_none: {
|
|
633
643
|
display: "none"
|
|
634
644
|
},
|
|
645
|
+
flexWrap: {
|
|
646
|
+
flexWrap: 'wrap'
|
|
647
|
+
},
|
|
635
648
|
flex: {
|
|
636
649
|
display: "flex"
|
|
637
650
|
},
|
|
@@ -650,6 +663,9 @@ var style = (_style = {
|
|
|
650
663
|
jc_flex_end: {
|
|
651
664
|
justifyContent: "flex-end"
|
|
652
665
|
},
|
|
666
|
+
jc_flex_start: {
|
|
667
|
+
justifyContent: "flex-start"
|
|
668
|
+
},
|
|
653
669
|
ac_center: {
|
|
654
670
|
alignContent: "center"
|
|
655
671
|
},
|
|
@@ -726,6 +742,15 @@ var style = (_style = {
|
|
|
726
742
|
border: "1px solid green",
|
|
727
743
|
justifyContent: "flex-end"
|
|
728
744
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
745
|
+
width: "35px",
|
|
746
|
+
height: "22px",
|
|
747
|
+
borderRadius: "20px",
|
|
748
|
+
display: "flex",
|
|
749
|
+
marginTop: "10px",
|
|
750
|
+
backgroundColor: "#dc3545",
|
|
751
|
+
border: "1px solid #dc3545",
|
|
752
|
+
justifyContent: "flex-start"
|
|
753
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
729
754
|
width: "35px",
|
|
730
755
|
height: "22px",
|
|
731
756
|
borderRadius: "20px",
|
|
@@ -741,6 +766,14 @@ var style = (_style = {
|
|
|
741
766
|
width: "20px",
|
|
742
767
|
height: "20px"
|
|
743
768
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
769
|
+
backgroundColor: "#fff",
|
|
770
|
+
borderRadius: "20px",
|
|
771
|
+
cursor: "pointer",
|
|
772
|
+
width: "20px",
|
|
773
|
+
height: "20px",
|
|
774
|
+
border: "1px solid #dfdfdf",
|
|
775
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
776
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
744
777
|
backgroundColor: "#fff",
|
|
745
778
|
borderRadius: "20px",
|
|
746
779
|
cursor: "pointer",
|
|
@@ -759,7 +792,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
759
792
|
return classes;
|
|
760
793
|
};
|
|
761
794
|
|
|
762
|
-
var BooleanInput = function
|
|
795
|
+
var BooleanInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
763
796
|
var _classNames;
|
|
764
797
|
|
|
765
798
|
var onChange = _ref.onChange,
|
|
@@ -782,15 +815,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
782
815
|
}
|
|
783
816
|
}, /*#__PURE__*/React.createElement("div", {
|
|
784
817
|
className: classNames(classes.switch_button_on)
|
|
785
|
-
})), !value && /*#__PURE__*/React.createElement("div", {
|
|
818
|
+
})), !value && value !== null && /*#__PURE__*/React.createElement("div", {
|
|
786
819
|
className: classNames(classes.content_switch_button_off),
|
|
787
820
|
onClick: function onClick() {
|
|
788
821
|
return handleClick(true);
|
|
789
822
|
}
|
|
790
823
|
}, /*#__PURE__*/React.createElement("div", {
|
|
791
824
|
className: classNames(classes.switch_button_off)
|
|
825
|
+
})), value === null && /*#__PURE__*/React.createElement("div", {
|
|
826
|
+
className: classNames(classes.content_switch_button_null),
|
|
827
|
+
onClick: function onClick() {
|
|
828
|
+
return handleClick(true);
|
|
829
|
+
}
|
|
830
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
831
|
+
className: classNames(classes.switch_button_null)
|
|
792
832
|
})));
|
|
793
|
-
};
|
|
833
|
+
});
|
|
794
834
|
|
|
795
835
|
var Collapse = function Collapse(props) {
|
|
796
836
|
var _classNames4;
|
|
@@ -881,35 +921,22 @@ var None = {
|
|
|
881
921
|
}
|
|
882
922
|
};
|
|
883
923
|
|
|
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
924
|
var isPromise = function isPromise(value) {
|
|
905
925
|
return Boolean(value && typeof value.then === 'function');
|
|
906
926
|
};
|
|
927
|
+
var arrayFlatten = function arrayFlatten(array) {
|
|
928
|
+
if (array.some(Array.isArray)) {
|
|
929
|
+
return arrayFlatten(array.flat());
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
return array;
|
|
933
|
+
};
|
|
907
934
|
|
|
908
935
|
var valueToSelectOption = function valueToSelectOption(value) {
|
|
909
936
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
910
937
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
911
938
|
|
|
912
|
-
if (value === null) {
|
|
939
|
+
if (value === null || !value) {
|
|
913
940
|
return null;
|
|
914
941
|
}
|
|
915
942
|
|
|
@@ -937,7 +964,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
937
964
|
});
|
|
938
965
|
};
|
|
939
966
|
|
|
940
|
-
var SelectInput = function
|
|
967
|
+
var SelectInput = /*#__PURE__*/React.forwardRef(function (props, _) {
|
|
941
968
|
var classes = useCustomStyle();
|
|
942
969
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
943
970
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1038,13 +1065,13 @@ var SelectInput = function SelectInput(props) {
|
|
|
1038
1065
|
return onChange(v);
|
|
1039
1066
|
};
|
|
1040
1067
|
|
|
1041
|
-
if (props.
|
|
1068
|
+
if (props.buttons) {
|
|
1042
1069
|
return /*#__PURE__*/React.createElement("div", {
|
|
1043
1070
|
style: {
|
|
1044
1071
|
display: 'flex'
|
|
1045
1072
|
}
|
|
1046
1073
|
}, values.map(function (v, idx) {
|
|
1047
|
-
var active = props.isMulti ? value.includes(v) : v.value === value.value;
|
|
1074
|
+
var active = !!value && (props.isMulti ? value.includes(v) : v.value === value.value);
|
|
1048
1075
|
return /*#__PURE__*/React.createElement("button", {
|
|
1049
1076
|
key: idx,
|
|
1050
1077
|
type: "button",
|
|
@@ -1081,6 +1108,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1081
1108
|
name: "".concat(props.label, "-search"),
|
|
1082
1109
|
isLoading: loading,
|
|
1083
1110
|
value: value,
|
|
1111
|
+
isClearable: true,
|
|
1084
1112
|
defaultValue: value,
|
|
1085
1113
|
isDisabled: props.disabled,
|
|
1086
1114
|
placeholder: props.placeholder,
|
|
@@ -1091,7 +1119,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1091
1119
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1092
1120
|
}));
|
|
1093
1121
|
}
|
|
1094
|
-
};
|
|
1122
|
+
});
|
|
1095
1123
|
|
|
1096
1124
|
var ObjectInput = function ObjectInput(props) {
|
|
1097
1125
|
var _useState = useState(),
|
|
@@ -28427,7 +28455,7 @@ function Editor(parent, mode, onChange, value) {
|
|
|
28427
28455
|
}
|
|
28428
28456
|
} catch (_) {}
|
|
28429
28457
|
}), EditorView.editable.of(!readOnly)]),
|
|
28430
|
-
doc: _typeof(value) === 'object' ? value.value : value
|
|
28458
|
+
doc: !value ? '' : _typeof(value) === 'object' ? value.value : value
|
|
28431
28459
|
});
|
|
28432
28460
|
return new EditorView({
|
|
28433
28461
|
state: state,
|
|
@@ -28478,7 +28506,7 @@ function CodeInput(_ref) {
|
|
|
28478
28506
|
changes: {
|
|
28479
28507
|
from: 0,
|
|
28480
28508
|
to: editor.state.doc.length,
|
|
28481
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28509
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28482
28510
|
}
|
|
28483
28511
|
});
|
|
28484
28512
|
}, [value]);
|
|
@@ -28487,68 +28515,6 @@ function CodeInput(_ref) {
|
|
|
28487
28515
|
});
|
|
28488
28516
|
}
|
|
28489
28517
|
|
|
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
28518
|
var converter = new showdown.Converter({
|
|
28553
28519
|
omitExtraWLInCodeBlocks: true,
|
|
28554
28520
|
ghCompatibleHeaderId: true,
|
|
@@ -28559,20 +28525,15 @@ var converter = new showdown.Converter({
|
|
|
28559
28525
|
requireSpaceBeforeHeadingText: true,
|
|
28560
28526
|
ghMentions: true,
|
|
28561
28527
|
emoji: true,
|
|
28562
|
-
ghMentionsLink: '/{u}'
|
|
28563
|
-
extensions: [DaikokuExtension]
|
|
28528
|
+
ghMentionsLink: '/{u}'
|
|
28564
28529
|
});
|
|
28565
28530
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28566
|
-
var _useState = useState(
|
|
28531
|
+
var _useState = useState(props.preview),
|
|
28567
28532
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28568
28533
|
preview = _useState2[0],
|
|
28569
28534
|
setPreview = _useState2[1];
|
|
28570
28535
|
|
|
28571
|
-
var
|
|
28572
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28573
|
-
editor = _useState4[0];
|
|
28574
|
-
_useState4[1];
|
|
28575
|
-
|
|
28536
|
+
var ref = useRef();
|
|
28576
28537
|
useEffect(function () {
|
|
28577
28538
|
if (preview) {
|
|
28578
28539
|
showPreview();
|
|
@@ -28581,162 +28542,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28581
28542
|
var commands = [{
|
|
28582
28543
|
name: 'Add header',
|
|
28583
28544
|
icon: 'heading',
|
|
28584
|
-
inject: function inject() {
|
|
28585
|
-
|
|
28586
|
-
|
|
28545
|
+
inject: function inject(range) {
|
|
28546
|
+
return !range ? '#' : [{
|
|
28547
|
+
from: range.from,
|
|
28548
|
+
insert: "# "
|
|
28549
|
+
}];
|
|
28587
28550
|
}
|
|
28588
28551
|
}, {
|
|
28589
28552
|
name: 'Add bold text',
|
|
28590
28553
|
icon: 'bold',
|
|
28591
|
-
inject: function inject() {
|
|
28592
|
-
|
|
28593
|
-
|
|
28554
|
+
inject: function inject(range) {
|
|
28555
|
+
return !range ? '** **' : [{
|
|
28556
|
+
from: range.from,
|
|
28557
|
+
insert: "**"
|
|
28558
|
+
}, {
|
|
28559
|
+
from: range.to,
|
|
28560
|
+
insert: '**'
|
|
28561
|
+
}];
|
|
28594
28562
|
}
|
|
28595
28563
|
}, {
|
|
28596
28564
|
name: 'Add italic text',
|
|
28597
28565
|
icon: 'italic',
|
|
28598
|
-
inject: function inject() {
|
|
28599
|
-
|
|
28600
|
-
|
|
28566
|
+
inject: function inject(range) {
|
|
28567
|
+
return !range ? '* *' : [{
|
|
28568
|
+
from: range.from,
|
|
28569
|
+
insert: '*'
|
|
28570
|
+
}, {
|
|
28571
|
+
from: range.to,
|
|
28572
|
+
insert: '*'
|
|
28573
|
+
}];
|
|
28601
28574
|
}
|
|
28602
28575
|
}, {
|
|
28603
28576
|
name: 'Add strikethrough text',
|
|
28604
28577
|
icon: 'strikethrough',
|
|
28605
|
-
inject: function inject() {
|
|
28606
|
-
|
|
28607
|
-
|
|
28578
|
+
inject: function inject(range) {
|
|
28579
|
+
return !range ? '~~ ~~' : [{
|
|
28580
|
+
from: range.from,
|
|
28581
|
+
insert: '~~'
|
|
28582
|
+
}, {
|
|
28583
|
+
from: range.to,
|
|
28584
|
+
insert: '~~'
|
|
28585
|
+
}];
|
|
28608
28586
|
}
|
|
28609
28587
|
}, {
|
|
28610
28588
|
name: 'Add link',
|
|
28611
28589
|
icon: 'link',
|
|
28612
|
-
inject: function inject() {
|
|
28613
|
-
|
|
28614
|
-
|
|
28590
|
+
inject: function inject(range) {
|
|
28591
|
+
return !range ? '[ ](url)' : [{
|
|
28592
|
+
from: range.from,
|
|
28593
|
+
insert: '['
|
|
28594
|
+
}, {
|
|
28595
|
+
from: range.to,
|
|
28596
|
+
insert: '](url)'
|
|
28597
|
+
}];
|
|
28615
28598
|
}
|
|
28616
28599
|
}, {
|
|
28617
28600
|
name: 'Add code',
|
|
28618
28601
|
icon: 'code',
|
|
28619
|
-
inject: function inject() {
|
|
28620
|
-
|
|
28621
|
-
|
|
28622
|
-
|
|
28623
|
-
|
|
28624
|
-
|
|
28625
|
-
|
|
28626
|
-
|
|
28627
|
-
});
|
|
28602
|
+
inject: function inject(range) {
|
|
28603
|
+
return !range ? '```\n\n```\n' : [{
|
|
28604
|
+
from: range.from,
|
|
28605
|
+
insert: '```\n'
|
|
28606
|
+
}, {
|
|
28607
|
+
from: range.to,
|
|
28608
|
+
insert: '\n```\n'
|
|
28609
|
+
}];
|
|
28628
28610
|
}
|
|
28629
28611
|
}, {
|
|
28630
28612
|
name: 'Add quotes',
|
|
28631
28613
|
icon: 'quote-right',
|
|
28632
|
-
inject: function inject() {
|
|
28633
|
-
|
|
28634
|
-
|
|
28614
|
+
inject: function inject(range) {
|
|
28615
|
+
return !range ? '> ' : [{
|
|
28616
|
+
from: range.from,
|
|
28617
|
+
insert: '> '
|
|
28618
|
+
}];
|
|
28635
28619
|
}
|
|
28636
28620
|
}, {
|
|
28637
28621
|
name: 'Add image',
|
|
28638
28622
|
icon: 'image',
|
|
28639
|
-
inject: function inject() {
|
|
28640
|
-
|
|
28641
|
-
|
|
28623
|
+
inject: function inject(range) {
|
|
28624
|
+
return !range ? '' : [{
|
|
28625
|
+
from: range.from,
|
|
28626
|
+
insert: ''
|
|
28630
|
+
}];
|
|
28642
28631
|
}
|
|
28643
28632
|
}, {
|
|
28644
28633
|
name: 'Add unordered list',
|
|
28645
28634
|
icon: 'list-ul',
|
|
28646
|
-
inject: function inject() {
|
|
28647
|
-
|
|
28648
|
-
|
|
28635
|
+
inject: function inject(range) {
|
|
28636
|
+
return !range ? '* ' : [{
|
|
28637
|
+
from: range.from,
|
|
28638
|
+
insert: '* '
|
|
28639
|
+
}];
|
|
28649
28640
|
}
|
|
28650
28641
|
}, {
|
|
28651
28642
|
name: 'Add ordered list',
|
|
28652
28643
|
icon: 'list-ol',
|
|
28653
|
-
inject: function inject() {
|
|
28654
|
-
|
|
28655
|
-
|
|
28644
|
+
inject: function inject(range) {
|
|
28645
|
+
return !range ? '1. ' : [{
|
|
28646
|
+
from: range.from,
|
|
28647
|
+
insert: '1. '
|
|
28648
|
+
}];
|
|
28656
28649
|
}
|
|
28657
28650
|
}, {
|
|
28658
28651
|
name: 'Add check list',
|
|
28659
28652
|
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.";
|
|
28653
|
+
inject: function inject(range) {
|
|
28654
|
+
return !range ? '* [ ] ' : [{
|
|
28655
|
+
from: range.from,
|
|
28656
|
+
insert: '* [ ] '
|
|
28657
|
+
}];
|
|
28734
28658
|
}
|
|
28735
28659
|
}];
|
|
28736
28660
|
|
|
28737
28661
|
var showPreview = function showPreview() {
|
|
28738
|
-
|
|
28739
|
-
|
|
28662
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28663
|
+
|
|
28664
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28665
|
+
return hljs.highlightElement(block);
|
|
28740
28666
|
});
|
|
28741
28667
|
};
|
|
28742
28668
|
|
|
@@ -28754,21 +28680,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28754
28680
|
title: command.name,
|
|
28755
28681
|
key: "toolbar-btn-".concat(idx),
|
|
28756
28682
|
onClick: function onClick() {
|
|
28757
|
-
var
|
|
28758
|
-
|
|
28759
|
-
if (
|
|
28760
|
-
|
|
28761
|
-
|
|
28762
|
-
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
|
-
|
|
28766
|
-
|
|
28767
|
-
return
|
|
28768
|
-
|
|
28683
|
+
var editor = ref.current;
|
|
28684
|
+
var selections = editor.state.selection.ranges;
|
|
28685
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28686
|
+
changes: {
|
|
28687
|
+
from: 0,
|
|
28688
|
+
to: editor.state.doc.length,
|
|
28689
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28690
|
+
}
|
|
28691
|
+
});else {
|
|
28692
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28693
|
+
return {
|
|
28694
|
+
changes: command.inject(range),
|
|
28695
|
+
range: range
|
|
28696
|
+
};
|
|
28697
|
+
}));
|
|
28769
28698
|
}
|
|
28770
|
-
|
|
28771
|
-
editor.focus();
|
|
28772
28699
|
}
|
|
28773
28700
|
}, /*#__PURE__*/React.createElement("i", {
|
|
28774
28701
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28779,7 +28706,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28779
28706
|
var classes = useCustomStyle();
|
|
28780
28707
|
return /*#__PURE__*/React.createElement("div", {
|
|
28781
28708
|
className: classNames(props.className)
|
|
28782
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
28709
|
+
}, !props.readOnly && /*#__PURE__*/React.createElement("div", {
|
|
28783
28710
|
style: {
|
|
28784
28711
|
marginBottom: 10
|
|
28785
28712
|
}
|
|
@@ -28804,9 +28731,13 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28804
28731
|
return setPreview(true);
|
|
28805
28732
|
}
|
|
28806
28733
|
}, "Preview"))), /*#__PURE__*/React.createElement("div", {
|
|
28807
|
-
className: classNames(classes.flex)
|
|
28808
|
-
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput,
|
|
28809
|
-
|
|
28734
|
+
className: classNames(classes.flex, classes.flexWrap)
|
|
28735
|
+
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput, _extends({}, props, {
|
|
28736
|
+
setRef: function setRef(e) {
|
|
28737
|
+
return ref.current = e;
|
|
28738
|
+
}
|
|
28739
|
+
})), preview && /*#__PURE__*/React.createElement("div", {
|
|
28740
|
+
className: "preview",
|
|
28810
28741
|
dangerouslySetInnerHTML: {
|
|
28811
28742
|
__html: converter.makeHtml(props.value)
|
|
28812
28743
|
}
|
|
@@ -28854,16 +28785,18 @@ function SingleLineCode(_ref) {
|
|
|
28854
28785
|
}
|
|
28855
28786
|
|
|
28856
28787
|
var _resolvers;
|
|
28857
|
-
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function () {
|
|
28858
|
-
return yup.string();
|
|
28788
|
+
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28789
|
+
return yup.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28859
28790
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28860
|
-
return yup.number().
|
|
28791
|
+
return yup.number().nullable().optional().transform(function (v) {
|
|
28792
|
+
return isNaN(v) ? null : v;
|
|
28793
|
+
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28861
28794
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28862
|
-
return yup.bool();
|
|
28795
|
+
return yup.bool().nullable().optional();
|
|
28863
28796
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28864
|
-
return yup.object();
|
|
28797
|
+
return yup.object().nullable().optional();
|
|
28865
28798
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28866
|
-
return yup.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28799
|
+
return yup.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28867
28800
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28868
28801
|
return yup.mixed();
|
|
28869
28802
|
}), _resolvers);
|
|
@@ -28890,6 +28823,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28890
28823
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28891
28824
|
}, arrayResolver);
|
|
28892
28825
|
} else if (props.type === type.object && props.schema) {
|
|
28826
|
+
if (!Object.keys(props.schema).length) {
|
|
28827
|
+
return yup.object();
|
|
28828
|
+
}
|
|
28829
|
+
|
|
28893
28830
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28894
28831
|
|
|
28895
28832
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -28940,11 +28877,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
28940
28877
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
28941
28878
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
28942
28879
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28880
|
+
|
|
28881
|
+
if (!Object.keys(schema).length) {
|
|
28882
|
+
return {
|
|
28883
|
+
shape: yup.object().shape({}),
|
|
28884
|
+
dependencies: dependencies
|
|
28885
|
+
};
|
|
28886
|
+
}
|
|
28887
|
+
|
|
28943
28888
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
28944
28889
|
if (_typeof$1(key) === 'object') {
|
|
28945
28890
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
28946
28891
|
}
|
|
28947
28892
|
|
|
28893
|
+
if (!schema[key]) {
|
|
28894
|
+
return resolvers;
|
|
28895
|
+
}
|
|
28896
|
+
|
|
28948
28897
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
28949
28898
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
28950
28899
|
}, {});
|
|
@@ -28954,13 +28903,102 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
28954
28903
|
};
|
|
28955
28904
|
};
|
|
28956
28905
|
|
|
28906
|
+
var CustomizableInput$1 = /*#__PURE__*/React.memo(function (props) {
|
|
28907
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
28908
|
+
if (props.render) {
|
|
28909
|
+
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
28910
|
+
error: props.error
|
|
28911
|
+
}));
|
|
28912
|
+
}
|
|
28913
|
+
|
|
28914
|
+
return props.children;
|
|
28915
|
+
}, function (prev, next) {
|
|
28916
|
+
return prev.field.value === next.field.value;
|
|
28917
|
+
});
|
|
28918
|
+
var ControlledInput = function ControlledInput(_ref) {
|
|
28919
|
+
var defaultValue = _ref.defaultValue,
|
|
28920
|
+
step = _ref.step,
|
|
28921
|
+
entry = _ref.entry,
|
|
28922
|
+
children = _ref.children,
|
|
28923
|
+
component = _ref.component;
|
|
28924
|
+
|
|
28925
|
+
var _useController = useController({
|
|
28926
|
+
defaultValue: defaultValue || null,
|
|
28927
|
+
name: entry
|
|
28928
|
+
}),
|
|
28929
|
+
field = _useController.field;
|
|
28930
|
+
|
|
28931
|
+
var _useFormContext = useFormContext(),
|
|
28932
|
+
getValues = _useFormContext.getValues,
|
|
28933
|
+
_setValue = _useFormContext.setValue,
|
|
28934
|
+
errors = _useFormContext.formState.errors;
|
|
28935
|
+
|
|
28936
|
+
var functionalProperty = function functionalProperty(entry, prop) {
|
|
28937
|
+
if (typeof prop === 'function') {
|
|
28938
|
+
return prop({
|
|
28939
|
+
rawValues: getValues(),
|
|
28940
|
+
value: getValues(entry)
|
|
28941
|
+
});
|
|
28942
|
+
} else {
|
|
28943
|
+
return prop;
|
|
28944
|
+
}
|
|
28945
|
+
};
|
|
28946
|
+
|
|
28947
|
+
var props = _objectSpread2$1(_objectSpread2$1(_objectSpread2$1({}, field), step.props), {}, {
|
|
28948
|
+
id: entry,
|
|
28949
|
+
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
28950
|
+
placeholder: step.placeholder,
|
|
28951
|
+
onChange: function onChange(e) {
|
|
28952
|
+
var value = function () {
|
|
28953
|
+
if (!e) {
|
|
28954
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28955
|
+
return e;
|
|
28956
|
+
} else {
|
|
28957
|
+
return null;
|
|
28958
|
+
}
|
|
28959
|
+
} else if (e.target) {
|
|
28960
|
+
return e.target.value || null;
|
|
28961
|
+
} else {
|
|
28962
|
+
return e;
|
|
28963
|
+
}
|
|
28964
|
+
}();
|
|
28965
|
+
|
|
28966
|
+
console.log(entry, value, getValues());
|
|
28967
|
+
field.onChange(value);
|
|
28968
|
+
option(step.onChange).map(function (onChange) {
|
|
28969
|
+
return onChange({
|
|
28970
|
+
rawValues: getValues(),
|
|
28971
|
+
value: value,
|
|
28972
|
+
setValue: _setValue
|
|
28973
|
+
});
|
|
28974
|
+
});
|
|
28975
|
+
},
|
|
28976
|
+
value: field.value
|
|
28977
|
+
});
|
|
28978
|
+
|
|
28979
|
+
var error = entry.split('.').reduce(function (acc, curr) {
|
|
28980
|
+
return acc && acc[curr];
|
|
28981
|
+
}, errors);
|
|
28982
|
+
return /*#__PURE__*/React.createElement(CustomizableInput$1, {
|
|
28983
|
+
render: step.render,
|
|
28984
|
+
field: _objectSpread2$1({
|
|
28985
|
+
parent: parent,
|
|
28986
|
+
setValue: function setValue(key, value) {
|
|
28987
|
+
return _setValue(key, value);
|
|
28988
|
+
},
|
|
28989
|
+
rawValues: getValues()
|
|
28990
|
+
}, field),
|
|
28991
|
+
error: error
|
|
28992
|
+
}, component ? component(field, props) : /*#__PURE__*/React.cloneElement(children, _objectSpread2$1({}, props)));
|
|
28993
|
+
};
|
|
28994
|
+
|
|
28957
28995
|
var usePrevious = function usePrevious(value) {
|
|
28958
28996
|
// The ref object is a generic container whose current property is mutable ...
|
|
28959
28997
|
// ... and can hold any value, similar to an instance property on a class
|
|
28960
28998
|
var ref = useRef(); // Store current value in ref
|
|
28961
28999
|
|
|
28962
29000
|
useEffect(function () {
|
|
28963
|
-
ref.current = value
|
|
29001
|
+
ref.current = value;
|
|
28964
29002
|
}, [value]); // Only re-run if value changes
|
|
28965
29003
|
// Return previous value (happens before update in useEffect above)
|
|
28966
29004
|
|
|
@@ -29045,33 +29083,16 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29045
29083
|
return props.children;
|
|
29046
29084
|
};
|
|
29047
29085
|
|
|
29048
|
-
var defaultVal = function defaultVal(
|
|
29086
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29049
29087
|
if (!!defaultValue) return defaultValue;
|
|
29050
29088
|
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
|
-
}
|
|
29089
|
+
return value;
|
|
29069
29090
|
};
|
|
29070
29091
|
|
|
29071
|
-
var getDefaultValues = function getDefaultValues(flow, schema) {
|
|
29072
|
-
return flow.reduce(function (acc, key) {
|
|
29092
|
+
var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
29093
|
+
return (flow || []).reduce(function (acc, key) {
|
|
29073
29094
|
if (_typeof$1(key) === 'object') {
|
|
29074
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema));
|
|
29095
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema, value));
|
|
29075
29096
|
}
|
|
29076
29097
|
|
|
29077
29098
|
var entry = schema[key];
|
|
@@ -29080,19 +29101,29 @@ var getDefaultValues = function getDefaultValues(flow, schema) {
|
|
|
29080
29101
|
return acc;
|
|
29081
29102
|
}
|
|
29082
29103
|
|
|
29083
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(
|
|
29104
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29084
29105
|
}, {});
|
|
29085
29106
|
};
|
|
29086
29107
|
|
|
29087
|
-
var cleanInputArray = function cleanInputArray(obj, defaultValues, subSchema) {
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
|
|
29091
|
-
|
|
29108
|
+
var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSchema) {
|
|
29109
|
+
var realFlow = option(flow).map(function (f) {
|
|
29110
|
+
return f.map(function (v) {
|
|
29111
|
+
return v.flow || v;
|
|
29112
|
+
});
|
|
29113
|
+
}).map(arrayFlatten).getOrElse(Object.keys(subSchema));
|
|
29114
|
+
return Object.entries(subSchema).filter(function (_ref2) {
|
|
29115
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
29116
|
+
key = _ref3[0];
|
|
29117
|
+
|
|
29118
|
+
return realFlow.includes(key);
|
|
29119
|
+
}).reduce(function (acc, _ref4) {
|
|
29120
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
29121
|
+
key = _ref5[0],
|
|
29122
|
+
step = _ref5[1];
|
|
29092
29123
|
|
|
29093
29124
|
var v;
|
|
29094
29125
|
if (obj) v = obj[key];
|
|
29095
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29126
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29096
29127
|
|
|
29097
29128
|
if (step.array && !step.render) {
|
|
29098
29129
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29100,12 +29131,12 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, subSchema) {
|
|
|
29100
29131
|
value: value
|
|
29101
29132
|
};
|
|
29102
29133
|
})));
|
|
29103
|
-
} else if (
|
|
29104
|
-
var _subSchema$key;
|
|
29134
|
+
} else if (_typeof$1(v) === 'object' && !(v instanceof Date) && !Array.isArray(v)) {
|
|
29135
|
+
var _subSchema$key, _subSchema$key2;
|
|
29105
29136
|
|
|
29106
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanInputArray(v, defaultValues, (
|
|
29137
|
+
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
29138
|
} else {
|
|
29108
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29139
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29109
29140
|
}
|
|
29110
29141
|
}, obj);
|
|
29111
29142
|
};
|
|
@@ -29125,17 +29156,17 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29125
29156
|
}).getOrElse(false);
|
|
29126
29157
|
|
|
29127
29158
|
if (isArray) {
|
|
29128
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v.map(function (
|
|
29129
|
-
var value =
|
|
29159
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v.map(function (_ref6) {
|
|
29160
|
+
var value = _ref6.value;
|
|
29130
29161
|
return value;
|
|
29131
29162
|
})));
|
|
29132
29163
|
}
|
|
29133
29164
|
|
|
29134
29165
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29135
29166
|
} else if (!!v && _typeof$1(v) === 'object' && !(v instanceof Date && !Array.isArray(v))) {
|
|
29136
|
-
var _subSchema$
|
|
29167
|
+
var _subSchema$key3;
|
|
29137
29168
|
|
|
29138
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanOutputArray(v, ((_subSchema$
|
|
29169
|
+
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
29170
|
} else {
|
|
29140
29171
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29141
29172
|
}
|
|
@@ -29153,20 +29184,54 @@ var validate = function validate(flow, schema, value) {
|
|
|
29153
29184
|
abortEarly: false
|
|
29154
29185
|
});
|
|
29155
29186
|
};
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
onSubmit =
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29187
|
+
|
|
29188
|
+
var Watcher = function Watcher(_ref7) {
|
|
29189
|
+
var options = _ref7.options,
|
|
29190
|
+
control = _ref7.control,
|
|
29191
|
+
schema = _ref7.schema,
|
|
29192
|
+
onSubmit = _ref7.onSubmit,
|
|
29193
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29194
|
+
_ref7.getValues;
|
|
29195
|
+
_ref7.watch;
|
|
29196
|
+
var data = useWatch({
|
|
29197
|
+
control: control
|
|
29198
|
+
});
|
|
29199
|
+
var prev = usePrevious(data);
|
|
29200
|
+
useEffect(function () {
|
|
29201
|
+
if (!!options.autosubmit) {
|
|
29202
|
+
if (!deepEqual(data, prev)) handleSubmit(function () {
|
|
29203
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29204
|
+
})();
|
|
29205
|
+
}
|
|
29206
|
+
}, [data]);
|
|
29207
|
+
|
|
29208
|
+
if (options.watch) {
|
|
29209
|
+
if (typeof options.watch === 'function') {
|
|
29210
|
+
options.watch(cleanOutputArray(data, schema));
|
|
29211
|
+
} else {
|
|
29212
|
+
console.group('react-form watch');
|
|
29213
|
+
console.log(cleanOutputArray(data, schema));
|
|
29214
|
+
console.groupEnd();
|
|
29215
|
+
}
|
|
29216
|
+
}
|
|
29217
|
+
|
|
29218
|
+
return null;
|
|
29219
|
+
};
|
|
29220
|
+
|
|
29221
|
+
var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
29222
|
+
var schema = _ref8.schema,
|
|
29223
|
+
flow = _ref8.flow,
|
|
29224
|
+
value = _ref8.value,
|
|
29225
|
+
inputWrapper = _ref8.inputWrapper,
|
|
29226
|
+
onSubmit = _ref8.onSubmit,
|
|
29227
|
+
_ref8$onError = _ref8.onError,
|
|
29228
|
+
onError = _ref8$onError === void 0 ? function () {} : _ref8$onError,
|
|
29229
|
+
footer = _ref8.footer,
|
|
29230
|
+
_ref8$style = _ref8.style,
|
|
29231
|
+
style = _ref8$style === void 0 ? {} : _ref8$style,
|
|
29232
|
+
className = _ref8.className,
|
|
29233
|
+
_ref8$options = _ref8.options,
|
|
29234
|
+
options = _ref8$options === void 0 ? {} : _ref8$options;
|
|
29170
29235
|
var classes = useCustomStyle(style);
|
|
29171
29236
|
var formFlow = flow || Object.keys(schema);
|
|
29172
29237
|
|
|
@@ -29185,7 +29250,7 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29185
29250
|
});
|
|
29186
29251
|
};
|
|
29187
29252
|
|
|
29188
|
-
var defaultValues = getDefaultValues(formFlow, schema); //FIXME: get real schema through the switch
|
|
29253
|
+
var defaultValues = getDefaultValues(formFlow, schema, value); //FIXME: get real schema through the switch
|
|
29189
29254
|
|
|
29190
29255
|
var _resolver = function resolver(rawData) {
|
|
29191
29256
|
var _getShapeAndDependenc2 = getShapeAndDependencies(formFlow, schema, [], rawData),
|
|
@@ -29200,50 +29265,49 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29200
29265
|
resolver: function resolver(data, context, options) {
|
|
29201
29266
|
return yupResolver(_resolver(data))(data, context, options);
|
|
29202
29267
|
},
|
|
29203
|
-
defaultValues: cleanInputArray(value, defaultValues, schema),
|
|
29204
29268
|
shouldFocusError: false,
|
|
29205
29269
|
mode: 'onChange'
|
|
29206
29270
|
});
|
|
29271
|
+
|
|
29272
|
+
var _useState = useState(false),
|
|
29273
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29274
|
+
initialReseted = _useState2[0],
|
|
29275
|
+
setReset = _useState2[1];
|
|
29276
|
+
|
|
29277
|
+
useEffect(function () {
|
|
29278
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29279
|
+
|
|
29280
|
+
setReset(true);
|
|
29281
|
+
}, [_reset]);
|
|
29282
|
+
useEffect(function () {
|
|
29283
|
+
initialReseted && trigger();
|
|
29284
|
+
}, [trigger, initialReseted]);
|
|
29207
29285
|
var _handleSubmit = methods.handleSubmit,
|
|
29208
29286
|
_methods$formState = methods.formState,
|
|
29209
29287
|
errors = _methods$formState.errors,
|
|
29210
29288
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29211
29289
|
_reset = methods.reset,
|
|
29212
|
-
watch = methods.watch,
|
|
29213
29290
|
trigger = methods.trigger,
|
|
29214
|
-
getValues = methods.getValues
|
|
29291
|
+
getValues = methods.getValues,
|
|
29292
|
+
watch = methods.watch;
|
|
29293
|
+
var prev = usePrevious(value);
|
|
29294
|
+
var prevSchema = usePrevious(schema);
|
|
29215
29295
|
useEffect(function () {
|
|
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);
|
|
29228
|
-
useEffect(function () {
|
|
29229
|
-
//todo: with debounce
|
|
29230
|
-
if (!!options.autosubmit && JSON.stringify(data) !== JSON.stringify(prevData)) {
|
|
29231
|
-
_handleSubmit(function (data) {
|
|
29232
|
-
var clean = cleanOutputArray(data, schema);
|
|
29233
|
-
onSubmit(clean);
|
|
29234
|
-
}, onError)();
|
|
29296
|
+
if (!deepEqual(value, prev) || !deepEqual(schema, prevSchema)) {
|
|
29297
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29235
29298
|
}
|
|
29236
|
-
}, [
|
|
29299
|
+
}, [value, schema]);
|
|
29237
29300
|
|
|
29238
|
-
|
|
29239
|
-
if (typeof
|
|
29240
|
-
|
|
29301
|
+
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29302
|
+
if (typeof prop === 'function') {
|
|
29303
|
+
return prop({
|
|
29304
|
+
rawValues: getValues(),
|
|
29305
|
+
value: getValues(entry)
|
|
29306
|
+
});
|
|
29241
29307
|
} else {
|
|
29242
|
-
|
|
29243
|
-
console.log(watch());
|
|
29244
|
-
console.groupEnd();
|
|
29308
|
+
return prop;
|
|
29245
29309
|
}
|
|
29246
|
-
}
|
|
29310
|
+
};
|
|
29247
29311
|
|
|
29248
29312
|
useImperativeHandle(ref, function () {
|
|
29249
29313
|
return {
|
|
@@ -29253,26 +29317,18 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref5, ref) {
|
|
|
29253
29317
|
onSubmit(clean);
|
|
29254
29318
|
}, onError)();
|
|
29255
29319
|
},
|
|
29256
|
-
rawData: function rawData() {
|
|
29257
|
-
return cleanOutputArray(data, schema);
|
|
29258
|
-
},
|
|
29259
29320
|
trigger: trigger,
|
|
29260
29321
|
methods: methods
|
|
29261
29322
|
};
|
|
29262
29323
|
});
|
|
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", {
|
|
29324
|
+
return /*#__PURE__*/React.createElement(FormProvider, methods, /*#__PURE__*/React.createElement(Watcher, {
|
|
29325
|
+
options: options,
|
|
29326
|
+
control: methods.control,
|
|
29327
|
+
schema: schema,
|
|
29328
|
+
onSubmit: onSubmit,
|
|
29329
|
+
handleSubmit: _handleSubmit,
|
|
29330
|
+
watch: methods.watch
|
|
29331
|
+
}), /*#__PURE__*/React.createElement("form", {
|
|
29276
29332
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29277
29333
|
onSubmit: _handleSubmit(function (data) {
|
|
29278
29334
|
var clean = cleanOutputArray(data, schema);
|
|
@@ -29373,17 +29429,18 @@ var Footer = function Footer(props) {
|
|
|
29373
29429
|
}, ((_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
29430
|
};
|
|
29375
29431
|
|
|
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 =
|
|
29432
|
+
var Step = function Step(_ref9) {
|
|
29433
|
+
var entry = _ref9.entry,
|
|
29434
|
+
realEntry = _ref9.realEntry,
|
|
29435
|
+
step = _ref9.step,
|
|
29436
|
+
schema = _ref9.schema,
|
|
29437
|
+
inputWrapper = _ref9.inputWrapper,
|
|
29438
|
+
httpClient = _ref9.httpClient,
|
|
29439
|
+
defaultValue = _ref9.defaultValue,
|
|
29440
|
+
index = _ref9.index,
|
|
29441
|
+
functionalProperty = _ref9.functionalProperty,
|
|
29442
|
+
parent = _ref9.parent,
|
|
29443
|
+
onAfterChange = _ref9.onAfterChange;
|
|
29387
29444
|
var classes = useCustomStyle();
|
|
29388
29445
|
|
|
29389
29446
|
var _useFormContext2 = useFormContext(),
|
|
@@ -29396,8 +29453,8 @@ var Step = function Step(_ref6) {
|
|
|
29396
29453
|
_useFormContext2.trigger;
|
|
29397
29454
|
var getValues = _useFormContext2.getValues,
|
|
29398
29455
|
_setValue = _useFormContext2.setValue,
|
|
29399
|
-
watch = _useFormContext2.watch
|
|
29400
|
-
|
|
29456
|
+
watch = _useFormContext2.watch;
|
|
29457
|
+
_useFormContext2.register;
|
|
29401
29458
|
|
|
29402
29459
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29403
29460
|
var errored = entry.flow.some(function (step) {
|
|
@@ -29466,6 +29523,29 @@ var Step = function Step(_ref6) {
|
|
|
29466
29523
|
return acc && acc[curr];
|
|
29467
29524
|
}, touchedFields);
|
|
29468
29525
|
var errorDisplayed = !!error && (isSubmitted || isDirty || isTouched);
|
|
29526
|
+
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29527
|
+
|
|
29528
|
+
if (onAfterChangeFunc) {
|
|
29529
|
+
var data = watch();
|
|
29530
|
+
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29531
|
+
return acc && acc[curr];
|
|
29532
|
+
}, data) || {};
|
|
29533
|
+
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29534
|
+
var newData = cleanOutputArray(d, schema);
|
|
29535
|
+
if (!deepEqual(newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29536
|
+
entry: entry,
|
|
29537
|
+
previousValue: currentData,
|
|
29538
|
+
value: getValues(entry),
|
|
29539
|
+
getValue: function getValue(e) {
|
|
29540
|
+
return getValues(e);
|
|
29541
|
+
},
|
|
29542
|
+
rawValues: newData,
|
|
29543
|
+
setValue: _setValue,
|
|
29544
|
+
onChange: function onChange(v) {
|
|
29545
|
+
return _setValue(entry, v);
|
|
29546
|
+
}
|
|
29547
|
+
});
|
|
29548
|
+
}
|
|
29469
29549
|
|
|
29470
29550
|
if (step.array) {
|
|
29471
29551
|
return /*#__PURE__*/React.createElement(CustomizableInput, {
|
|
@@ -29484,13 +29564,13 @@ var Step = function Step(_ref6) {
|
|
|
29484
29564
|
}, /*#__PURE__*/React.createElement(ArrayStep, {
|
|
29485
29565
|
entry: entry,
|
|
29486
29566
|
step: step,
|
|
29487
|
-
defaultValue: step.defaultValue || defaultVal(step.type),
|
|
29488
29567
|
disabled: functionalProperty(entry, step.disabled),
|
|
29489
29568
|
component: function component(props, idx) {
|
|
29490
29569
|
var _props$defaultValue;
|
|
29491
29570
|
|
|
29492
29571
|
return /*#__PURE__*/React.createElement(Step, {
|
|
29493
|
-
entry: "".concat(entry, "
|
|
29572
|
+
entry: "".concat(entry, ".").concat(idx, ".value"),
|
|
29573
|
+
onAfterChange: step.onAfterChange || step.on_after_change,
|
|
29494
29574
|
step: _objectSpread2$1(_objectSpread2$1({}, schema[realEntry || entry]), {}, {
|
|
29495
29575
|
render: step.itemRender,
|
|
29496
29576
|
onChange: undefined,
|
|
@@ -29508,325 +29588,126 @@ var Step = function Step(_ref6) {
|
|
|
29508
29588
|
}));
|
|
29509
29589
|
}
|
|
29510
29590
|
|
|
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
29591
|
switch (step.type) {
|
|
29527
29592
|
case type.string:
|
|
29528
29593
|
switch (step.format) {
|
|
29529
29594
|
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, {
|
|
29595
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29550
29596
|
defaultValue: defaultValue,
|
|
29551
|
-
|
|
29552
|
-
|
|
29597
|
+
step: step,
|
|
29598
|
+
entry: entry
|
|
29599
|
+
}, /*#__PURE__*/React.createElement("textarea", {
|
|
29600
|
+
type: "text",
|
|
29601
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29602
|
+
}));
|
|
29553
29603
|
|
|
29554
29604
|
case format.code:
|
|
29555
29605
|
case format.singleLineCode:
|
|
29556
29606
|
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
|
-
});
|
|
29607
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29608
|
+
defaultValue: defaultValue,
|
|
29609
|
+
step: step,
|
|
29610
|
+
entry: entry
|
|
29611
|
+
}, /*#__PURE__*/React.createElement(Component, {
|
|
29612
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29613
|
+
}));
|
|
29590
29614
|
|
|
29591
29615
|
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
|
-
});
|
|
29616
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29617
|
+
defaultValue: defaultValue,
|
|
29618
|
+
step: step,
|
|
29619
|
+
entry: entry
|
|
29620
|
+
}, /*#__PURE__*/React.createElement(MarkdownInput, {
|
|
29621
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29622
|
+
}));
|
|
29625
29623
|
|
|
29626
29624
|
case format.buttonsSelect:
|
|
29627
29625
|
case format.select:
|
|
29628
|
-
|
|
29629
|
-
|
|
29630
|
-
|
|
29631
|
-
|
|
29632
|
-
|
|
29633
|
-
|
|
29634
|
-
|
|
29635
|
-
|
|
29636
|
-
|
|
29637
|
-
|
|
29638
|
-
|
|
29639
|
-
|
|
29640
|
-
|
|
29641
|
-
|
|
29642
|
-
|
|
29643
|
-
|
|
29644
|
-
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
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
|
-
});
|
|
29626
|
+
{
|
|
29627
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29628
|
+
defaultValue: defaultValue,
|
|
29629
|
+
step: step,
|
|
29630
|
+
entry: entry
|
|
29631
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29632
|
+
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29633
|
+
disabled: functionalProperty(entry, step.disabled),
|
|
29634
|
+
possibleValues: step.options,
|
|
29635
|
+
httpClient: httpClient,
|
|
29636
|
+
isMulti: step.isMulti,
|
|
29637
|
+
createOption: step.createOption,
|
|
29638
|
+
transformer: step.transformer,
|
|
29639
|
+
buttons: step.format === format.buttonsSelect
|
|
29640
|
+
}));
|
|
29641
|
+
}
|
|
29663
29642
|
|
|
29664
29643
|
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,
|
|
29644
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29686
29645
|
defaultValue: defaultValue,
|
|
29687
|
-
|
|
29688
|
-
|
|
29646
|
+
step: step,
|
|
29647
|
+
entry: entry
|
|
29648
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
29649
|
+
type: step.format || 'text',
|
|
29650
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29651
|
+
}));
|
|
29689
29652
|
}
|
|
29690
29653
|
|
|
29691
29654
|
case type.number:
|
|
29692
29655
|
switch (step.format) {
|
|
29693
29656
|
case format.buttonsSelect:
|
|
29694
29657
|
case format.select:
|
|
29695
|
-
return /*#__PURE__*/React.createElement(
|
|
29696
|
-
|
|
29697
|
-
|
|
29698
|
-
|
|
29699
|
-
|
|
29700
|
-
|
|
29701
|
-
|
|
29702
|
-
|
|
29703
|
-
|
|
29704
|
-
|
|
29705
|
-
|
|
29706
|
-
|
|
29707
|
-
|
|
29708
|
-
|
|
29709
|
-
error: error
|
|
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
|
-
});
|
|
29658
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29659
|
+
defaultValue: defaultValue,
|
|
29660
|
+
step: step,
|
|
29661
|
+
entry: entry
|
|
29662
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29663
|
+
className: classNames(classes.content, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29664
|
+
possibleValues: step.options,
|
|
29665
|
+
httpClient: httpClient,
|
|
29666
|
+
isMulti: step.isMulti,
|
|
29667
|
+
createOption: step.createOption,
|
|
29668
|
+
onCreateOption: step.onCreateOption,
|
|
29669
|
+
transformer: step.transformer,
|
|
29670
|
+
buttons: step.format === format.buttonsSelect
|
|
29671
|
+
}));
|
|
29730
29672
|
|
|
29731
29673
|
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, {
|
|
29674
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29675
|
+
defaultValue: defaultValue,
|
|
29676
|
+
step: step,
|
|
29677
|
+
entry: entry
|
|
29678
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
29747
29679
|
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)));
|
|
29680
|
+
className: classNames(classes.input, _defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29681
|
+
}));
|
|
29755
29682
|
}
|
|
29756
29683
|
|
|
29757
29684
|
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
|
-
});
|
|
29685
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29686
|
+
defaultValue: defaultValue,
|
|
29687
|
+
step: step,
|
|
29688
|
+
entry: entry
|
|
29689
|
+
}, /*#__PURE__*/React.createElement(BooleanInput, {
|
|
29690
|
+
className: classNames(_defineProperty$1({}, classes.input__invalid, errorDisplayed))
|
|
29691
|
+
}));
|
|
29790
29692
|
|
|
29791
29693
|
case type.object:
|
|
29792
29694
|
switch (step.format) {
|
|
29793
29695
|
case format.buttonsSelect:
|
|
29794
29696
|
case format.select:
|
|
29795
|
-
return /*#__PURE__*/React.createElement(
|
|
29796
|
-
|
|
29797
|
-
|
|
29798
|
-
|
|
29799
|
-
|
|
29800
|
-
|
|
29801
|
-
|
|
29802
|
-
|
|
29803
|
-
|
|
29804
|
-
|
|
29805
|
-
|
|
29806
|
-
|
|
29807
|
-
|
|
29808
|
-
|
|
29809
|
-
}, field),
|
|
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
|
-
});
|
|
29697
|
+
return /*#__PURE__*/React.createElement(ControlledInput, {
|
|
29698
|
+
defaultValue: defaultValue,
|
|
29699
|
+
step: step,
|
|
29700
|
+
entry: entry
|
|
29701
|
+
}, /*#__PURE__*/React.createElement(SelectInput, {
|
|
29702
|
+
className: classNames(classes.flex_grow_1, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
29703
|
+
possibleValues: step.options,
|
|
29704
|
+
httpClient: httpClient,
|
|
29705
|
+
isMulti: step.isMulti,
|
|
29706
|
+
createOption: step.createOption,
|
|
29707
|
+
onCreateOption: step.onCreateOption,
|
|
29708
|
+
transformer: step.transformer,
|
|
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',
|
|
@@ -30141,10 +29935,11 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30141
29935
|
type: "button",
|
|
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() {
|
|
29938
|
+
var newValue = cleanInputArray({}, getValues(entry), step.flow, step.schema);
|
|
30144
29939
|
append({
|
|
30145
|
-
value: step.addableDefaultValue || defaultVal(
|
|
30146
|
-
});
|
|
30147
|
-
|
|
29940
|
+
value: step.addableDefaultValue || (newValue ? newValue : defaultVal())
|
|
29941
|
+
}); // trigger(entry);
|
|
29942
|
+
|
|
30148
29943
|
option(step.onChange).map(function (onChange) {
|
|
30149
29944
|
return onChange({
|
|
30150
29945
|
rawValues: getValues(),
|
|
@@ -30159,37 +29954,38 @@ var ArrayStep = function ArrayStep(_ref18) {
|
|
|
30159
29954
|
}, error.message)));
|
|
30160
29955
|
};
|
|
30161
29956
|
|
|
30162
|
-
var NestedForm = function NestedForm(
|
|
29957
|
+
var NestedForm = function NestedForm(_ref13) {
|
|
30163
29958
|
var _classNames16;
|
|
30164
29959
|
|
|
30165
|
-
var schema =
|
|
30166
|
-
flow =
|
|
30167
|
-
parent =
|
|
30168
|
-
inputWrapper =
|
|
30169
|
-
maybeCustomHttpClient =
|
|
30170
|
-
errorDisplayed =
|
|
30171
|
-
value =
|
|
30172
|
-
step =
|
|
30173
|
-
functionalProperty =
|
|
30174
|
-
index =
|
|
29960
|
+
var schema = _ref13.schema,
|
|
29961
|
+
flow = _ref13.flow,
|
|
29962
|
+
parent = _ref13.parent,
|
|
29963
|
+
inputWrapper = _ref13.inputWrapper,
|
|
29964
|
+
maybeCustomHttpClient = _ref13.maybeCustomHttpClient,
|
|
29965
|
+
errorDisplayed = _ref13.errorDisplayed,
|
|
29966
|
+
value = _ref13.value,
|
|
29967
|
+
step = _ref13.step,
|
|
29968
|
+
functionalProperty = _ref13.functionalProperty,
|
|
29969
|
+
index = _ref13.index;
|
|
30175
29970
|
|
|
30176
29971
|
var _useFormContext4 = useFormContext(),
|
|
30177
29972
|
getValues = _useFormContext4.getValues,
|
|
30178
29973
|
setValue = _useFormContext4.setValue,
|
|
30179
|
-
watch = _useFormContext4.watch
|
|
30180
|
-
|
|
29974
|
+
watch = _useFormContext4.watch;
|
|
29975
|
+
_useFormContext4.trigger;
|
|
30181
29976
|
_useFormContext4.formState;
|
|
30182
29977
|
|
|
30183
|
-
var
|
|
30184
|
-
|
|
30185
|
-
collapsed =
|
|
30186
|
-
setCollapsed =
|
|
29978
|
+
var _useState7 = useState(!!step.collapsed),
|
|
29979
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
29980
|
+
collapsed = _useState8[0],
|
|
29981
|
+
setCollapsed = _useState8[1];
|
|
29982
|
+
|
|
29983
|
+
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
29984
|
+
// const v = getValues(parent);
|
|
29985
|
+
// useEffect(() => {
|
|
29986
|
+
// trigger(parent)
|
|
29987
|
+
// }, [JSON.stringify(v)])
|
|
30187
29988
|
|
|
30188
|
-
var classes = useCustomStyle();
|
|
30189
|
-
var v = getValues(parent);
|
|
30190
|
-
useEffect(function () {
|
|
30191
|
-
trigger(parent);
|
|
30192
|
-
}, [JSON.stringify(v)]);
|
|
30193
29989
|
var schemaAndFlow = option(step.conditionalSchema).map(function (condiSchema) {
|
|
30194
29990
|
var ref = option(condiSchema.ref).map(function (ref) {
|
|
30195
29991
|
return getValues(ref);
|
|
@@ -30214,8 +30010,8 @@ var NestedForm = function NestedForm(_ref19) {
|
|
|
30214
30010
|
});
|
|
30215
30011
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30216
30012
|
useEffect(function () {
|
|
30217
|
-
if (!!prevSchema &&
|
|
30218
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30013
|
+
if (!!prevSchema && !deepEqual(prevSchema, schemaAndFlow.schema)) {
|
|
30014
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30219
30015
|
setValue(parent, def, {
|
|
30220
30016
|
shouldValidate: false
|
|
30221
30017
|
});
|
|
@@ -30281,10 +30077,10 @@ var NestedForm = function NestedForm(_ref19) {
|
|
|
30281
30077
|
onClick: function onClick() {
|
|
30282
30078
|
return setCollapsed(!collapsed);
|
|
30283
30079
|
}
|
|
30284
|
-
}), computedSandF.map(function (
|
|
30285
|
-
var step =
|
|
30286
|
-
visibleStep =
|
|
30287
|
-
entry =
|
|
30080
|
+
}), computedSandF.map(function (_ref14, idx) {
|
|
30081
|
+
var step = _ref14.step,
|
|
30082
|
+
visibleStep = _ref14.visibleStep,
|
|
30083
|
+
entry = _ref14.entry;
|
|
30288
30084
|
|
|
30289
30085
|
if (!step && typeof entry === 'string') {
|
|
30290
30086
|
console.error("no step found for the entry \"".concat(entry, "\" in the given schema. Your form might not work properly. Please fix it"));
|