@maif/react-forms 1.0.37-rc.1 → 1.0.40
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 +1 -11
- package/lib/esm/index.js +256 -348
- package/lib/index.js +260 -351
- package/package.json +6 -4
package/lib/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var uuid = require('uuid');
|
|
|
14
14
|
var reactJss = require('react-jss');
|
|
15
15
|
var CreatableSelect = require('react-select/creatable');
|
|
16
16
|
var Select = require('react-select');
|
|
17
|
+
var deepEqual = require('fast-deep-equal');
|
|
17
18
|
var showdown = require('showdown');
|
|
18
19
|
require('@fortawesome/fontawesome-free/css/all.css');
|
|
19
20
|
require('highlight.js/styles/monokai.css');
|
|
@@ -45,6 +46,7 @@ var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
|
45
46
|
var ReactToolTip__default = /*#__PURE__*/_interopDefaultLegacy(ReactToolTip);
|
|
46
47
|
var CreatableSelect__default = /*#__PURE__*/_interopDefaultLegacy(CreatableSelect);
|
|
47
48
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
49
|
+
var deepEqual__default = /*#__PURE__*/_interopDefaultLegacy(deepEqual);
|
|
48
50
|
var showdown__default = /*#__PURE__*/_interopDefaultLegacy(showdown);
|
|
49
51
|
var hljs__default = /*#__PURE__*/_interopDefaultLegacy(hljs);
|
|
50
52
|
|
|
@@ -214,29 +216,6 @@ var _maxSize = function maxSize(ref) {
|
|
|
214
216
|
};
|
|
215
217
|
}; //mixed
|
|
216
218
|
|
|
217
|
-
var _nullable = function nullable() {
|
|
218
|
-
return function (r) {
|
|
219
|
-
return r.nullable().optional().transform(function (v) {
|
|
220
|
-
var _r$describe = r.describe(),
|
|
221
|
-
type = _r$describe.type;
|
|
222
|
-
|
|
223
|
-
switch (type) {
|
|
224
|
-
case 'string':
|
|
225
|
-
case 'number':
|
|
226
|
-
return (v || '').toString().length <= 0 ? null : v;
|
|
227
|
-
|
|
228
|
-
case 'object':
|
|
229
|
-
return Object.keys(v || {}).length === 0 ? null : v;
|
|
230
|
-
|
|
231
|
-
default:
|
|
232
|
-
return v;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return v;
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
|
|
240
219
|
var _test = function test(name) {
|
|
241
220
|
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Test failed';
|
|
242
221
|
var test = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -274,9 +253,9 @@ var _oneOf = function oneOf(arrayOfValues) {
|
|
|
274
253
|
var _blacklist = function blacklist(arrayOfValues) {
|
|
275
254
|
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This value can't include the following values ".concat(arrayOfValues.join(', '));
|
|
276
255
|
return function (r) {
|
|
277
|
-
return r.test('blacklist'
|
|
256
|
+
return r.test('blacklist', message, function (value) {
|
|
278
257
|
return !arrayOfValues.some(function (f) {
|
|
279
|
-
return value.includes(f);
|
|
258
|
+
return (value || '').includes(f);
|
|
280
259
|
});
|
|
281
260
|
});
|
|
282
261
|
};
|
|
@@ -408,9 +387,6 @@ var jsonConstraints = {
|
|
|
408
387
|
},
|
|
409
388
|
ref: function ref(val) {
|
|
410
389
|
return _ref21(val.ref);
|
|
411
|
-
},
|
|
412
|
-
nullable: function nullable() {
|
|
413
|
-
return _nullable();
|
|
414
390
|
}
|
|
415
391
|
};
|
|
416
392
|
|
|
@@ -432,7 +408,6 @@ var constraints = /*#__PURE__*/Object.freeze({
|
|
|
432
408
|
supportedFormat: _supportedFormat,
|
|
433
409
|
unsupportedFormat: _unsupportedFormat,
|
|
434
410
|
maxSize: _maxSize,
|
|
435
|
-
nullable: _nullable,
|
|
436
411
|
test: _test,
|
|
437
412
|
when: _when,
|
|
438
413
|
oneOf: _oneOf,
|
|
@@ -701,6 +676,9 @@ var style = (_style = {
|
|
|
701
676
|
d_none: {
|
|
702
677
|
display: "none"
|
|
703
678
|
},
|
|
679
|
+
flexWrap: {
|
|
680
|
+
flexWrap: 'wrap'
|
|
681
|
+
},
|
|
704
682
|
flex: {
|
|
705
683
|
display: "flex"
|
|
706
684
|
},
|
|
@@ -798,6 +776,15 @@ var style = (_style = {
|
|
|
798
776
|
border: "1px solid green",
|
|
799
777
|
justifyContent: "flex-end"
|
|
800
778
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
779
|
+
width: "35px",
|
|
780
|
+
height: "22px",
|
|
781
|
+
borderRadius: "20px",
|
|
782
|
+
display: "flex",
|
|
783
|
+
marginTop: "10px",
|
|
784
|
+
backgroundColor: "#dc3545",
|
|
785
|
+
border: "1px solid #dc3545",
|
|
786
|
+
justifyContent: "flex-start"
|
|
787
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
801
788
|
width: "35px",
|
|
802
789
|
height: "22px",
|
|
803
790
|
borderRadius: "20px",
|
|
@@ -813,6 +800,14 @@ var style = (_style = {
|
|
|
813
800
|
width: "20px",
|
|
814
801
|
height: "20px"
|
|
815
802
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
803
|
+
backgroundColor: "#fff",
|
|
804
|
+
borderRadius: "20px",
|
|
805
|
+
cursor: "pointer",
|
|
806
|
+
width: "20px",
|
|
807
|
+
height: "20px",
|
|
808
|
+
border: "1px solid #dfdfdf",
|
|
809
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
810
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
816
811
|
backgroundColor: "#fff",
|
|
817
812
|
borderRadius: "20px",
|
|
818
813
|
cursor: "pointer",
|
|
@@ -831,7 +826,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
831
826
|
return classes;
|
|
832
827
|
};
|
|
833
828
|
|
|
834
|
-
var BooleanInput = function
|
|
829
|
+
var BooleanInput = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
835
830
|
var _classNames;
|
|
836
831
|
|
|
837
832
|
var onChange = _ref.onChange,
|
|
@@ -854,15 +849,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
854
849
|
}
|
|
855
850
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
856
851
|
className: classNames__default["default"](classes.switch_button_on)
|
|
857
|
-
})), !value && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
852
|
+
})), !value && value !== null && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
858
853
|
className: classNames__default["default"](classes.content_switch_button_off),
|
|
859
854
|
onClick: function onClick() {
|
|
860
855
|
return handleClick(true);
|
|
861
856
|
}
|
|
862
857
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
863
858
|
className: classNames__default["default"](classes.switch_button_off)
|
|
859
|
+
})), value === null && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
860
|
+
className: classNames__default["default"](classes.content_switch_button_null),
|
|
861
|
+
onClick: function onClick() {
|
|
862
|
+
return handleClick(true);
|
|
863
|
+
}
|
|
864
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
865
|
+
className: classNames__default["default"](classes.switch_button_null)
|
|
864
866
|
})));
|
|
865
|
-
};
|
|
867
|
+
});
|
|
866
868
|
|
|
867
869
|
var Collapse = function Collapse(props) {
|
|
868
870
|
var _classNames4;
|
|
@@ -953,38 +955,6 @@ var None = {
|
|
|
953
955
|
}
|
|
954
956
|
};
|
|
955
957
|
|
|
956
|
-
var deepEqual = function deepEqual(obj1, obj2) {
|
|
957
|
-
if (obj1 === obj2) return true;
|
|
958
|
-
|
|
959
|
-
if (_typeof$1(obj1) !== 'object' || _typeof$1(obj2) !== 'object' || obj1 == null || obj2 == null) {
|
|
960
|
-
return false;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
var keysA = Object.keys(obj1);
|
|
964
|
-
var keysB = Object.keys(obj2);
|
|
965
|
-
|
|
966
|
-
if (keysA.length !== keysB.length) {
|
|
967
|
-
return false;
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
var result = true;
|
|
971
|
-
keysA.forEach(function (key) {
|
|
972
|
-
if (!keysB.includes(key)) {
|
|
973
|
-
result = false;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
if (typeof obj1[key] === 'function' || typeof obj2[key] === 'function') {
|
|
977
|
-
if (obj1[key].toString() !== obj2[key].toString()) {
|
|
978
|
-
result = false;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
if (!deepEqual(obj1[key], obj2[key])) {
|
|
983
|
-
result = false;
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
return result;
|
|
987
|
-
};
|
|
988
958
|
var isPromise = function isPromise(value) {
|
|
989
959
|
return Boolean(value && typeof value.then === 'function');
|
|
990
960
|
};
|
|
@@ -1000,7 +970,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1000
970
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1001
971
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1002
972
|
|
|
1003
|
-
if (value === null) {
|
|
973
|
+
if (value === null || !value) {
|
|
1004
974
|
return null;
|
|
1005
975
|
}
|
|
1006
976
|
|
|
@@ -1016,7 +986,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1016
986
|
}
|
|
1017
987
|
|
|
1018
988
|
var maybeValue = option(possibleValues.find(function (v) {
|
|
1019
|
-
return
|
|
989
|
+
return deepEqual__default["default"](v.value, value);
|
|
1020
990
|
}));
|
|
1021
991
|
return maybeValue.getOrElse({
|
|
1022
992
|
label: maybeValue.map(function (v) {
|
|
@@ -1028,7 +998,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1028
998
|
});
|
|
1029
999
|
};
|
|
1030
1000
|
|
|
1031
|
-
var SelectInput = function
|
|
1001
|
+
var SelectInput = /*#__PURE__*/React__default["default"].forwardRef(function (props, _) {
|
|
1032
1002
|
var classes = useCustomStyle();
|
|
1033
1003
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
1034
1004
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1135,7 +1105,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1135
1105
|
display: 'flex'
|
|
1136
1106
|
}
|
|
1137
1107
|
}, values.map(function (v, idx) {
|
|
1138
|
-
var active = props.isMulti ? value.includes(v) : v.value === value.value;
|
|
1108
|
+
var active = !!value && (props.isMulti ? value.includes(v) : v.value === value.value);
|
|
1139
1109
|
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
1140
1110
|
key: idx,
|
|
1141
1111
|
type: "button",
|
|
@@ -1183,7 +1153,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1183
1153
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1184
1154
|
}));
|
|
1185
1155
|
}
|
|
1186
|
-
};
|
|
1156
|
+
});
|
|
1187
1157
|
|
|
1188
1158
|
var ObjectInput = function ObjectInput(props) {
|
|
1189
1159
|
var _useState = React.useState(),
|
|
@@ -1214,7 +1184,7 @@ var ObjectInput = function ObjectInput(props) {
|
|
|
1214
1184
|
if (item.key) return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, item.key, item.value));
|
|
1215
1185
|
return acc;
|
|
1216
1186
|
}, {});
|
|
1217
|
-
if (!
|
|
1187
|
+
if (!deepEqual__default["default"](newState, previousState)) setInternalState(Object.fromEntries(Object.entries(props.value || {}).map(function (_ref5, idx) {
|
|
1218
1188
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
1219
1189
|
key = _ref6[0],
|
|
1220
1190
|
value = _ref6[1];
|
|
@@ -23690,7 +23660,7 @@ const Emoji = {
|
|
|
23690
23660
|
}]
|
|
23691
23661
|
};
|
|
23692
23662
|
|
|
23693
|
-
const data
|
|
23663
|
+
const data = /*@__PURE__*/defineLanguageFacet({ block: { open: "<!--", close: "-->" } });
|
|
23694
23664
|
const commonmark = /*@__PURE__*/parser.configure({
|
|
23695
23665
|
props: [
|
|
23696
23666
|
/*@__PURE__*/styleTags({
|
|
@@ -23726,12 +23696,12 @@ const commonmark = /*@__PURE__*/parser.configure({
|
|
|
23726
23696
|
Document: () => null
|
|
23727
23697
|
}),
|
|
23728
23698
|
/*@__PURE__*/languageDataProp.add({
|
|
23729
|
-
Document: data
|
|
23699
|
+
Document: data
|
|
23730
23700
|
})
|
|
23731
23701
|
]
|
|
23732
23702
|
});
|
|
23733
23703
|
function mkLang(parser) {
|
|
23734
|
-
return new Language(data
|
|
23704
|
+
return new Language(data, parser, parser.nodeSet.types.find(t => t.name == "Document"));
|
|
23735
23705
|
}
|
|
23736
23706
|
/**
|
|
23737
23707
|
Language support for strict CommonMark.
|
|
@@ -28570,7 +28540,7 @@ function CodeInput(_ref) {
|
|
|
28570
28540
|
changes: {
|
|
28571
28541
|
from: 0,
|
|
28572
28542
|
to: editor.state.doc.length,
|
|
28573
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28543
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28574
28544
|
}
|
|
28575
28545
|
});
|
|
28576
28546
|
}, [value]);
|
|
@@ -28579,67 +28549,6 @@ function CodeInput(_ref) {
|
|
|
28579
28549
|
});
|
|
28580
28550
|
}
|
|
28581
28551
|
|
|
28582
|
-
window.hljs = window.hljs || hljs__default["default"];
|
|
28583
|
-
|
|
28584
|
-
var DaikokuExtension = function DaikokuExtension() {
|
|
28585
|
-
// @ref: []()
|
|
28586
|
-
var refextension = {
|
|
28587
|
-
type: 'lang',
|
|
28588
|
-
regex: /@ref:\[(.*)\]\((.*)\)/g,
|
|
28589
|
-
replace: function replace(expression, title, docId) {
|
|
28590
|
-
var path = window.location.pathname;
|
|
28591
|
-
var rawParts = path.split('/');
|
|
28592
|
-
rawParts.shift();
|
|
28593
|
-
var parts = rawParts.splice(0, 5);
|
|
28594
|
-
var teamId = parts[1];
|
|
28595
|
-
var apiId = parts[3];
|
|
28596
|
-
var versionId = parts[4];
|
|
28597
|
-
return "<a href=\"/".concat(teamId, "/").concat(apiId, "/").concat(versionId, "/documentation/").concat(docId, "\">").concat(title, "</a>");
|
|
28598
|
-
}
|
|
28599
|
-
}; // @@@
|
|
28600
|
-
|
|
28601
|
-
var tripleArobase = {
|
|
28602
|
-
type: 'lang',
|
|
28603
|
-
regex: /@@@/g,
|
|
28604
|
-
replace: function replace() {
|
|
28605
|
-
return '</div>';
|
|
28606
|
-
}
|
|
28607
|
-
}; // @@@warning
|
|
28608
|
-
|
|
28609
|
-
var warningExtension = {
|
|
28610
|
-
type: 'lang',
|
|
28611
|
-
regex: /@@@ warning/g,
|
|
28612
|
-
replace: function replace() {
|
|
28613
|
-
return '<div class="note note-warning">';
|
|
28614
|
-
}
|
|
28615
|
-
}; // @@@warning { title = }
|
|
28616
|
-
|
|
28617
|
-
var warningTitleExtension = {
|
|
28618
|
-
type: 'lang',
|
|
28619
|
-
regex: /@@@ warning \{ title='(.*)' \}/g,
|
|
28620
|
-
replace: function replace(expr, title) {
|
|
28621
|
-
return "<div class=\"note note-warning\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28622
|
-
}
|
|
28623
|
-
}; // @@@note
|
|
28624
|
-
|
|
28625
|
-
var noteExtension = {
|
|
28626
|
-
type: 'lang',
|
|
28627
|
-
regex: /@@@ note/g,
|
|
28628
|
-
replace: function replace() {
|
|
28629
|
-
return '<div class="note">';
|
|
28630
|
-
}
|
|
28631
|
-
}; // @@@note { title = }
|
|
28632
|
-
|
|
28633
|
-
var noteTitleExtension = {
|
|
28634
|
-
type: 'lang',
|
|
28635
|
-
regex: /@@@ note \{ title='(.*)' \}/g,
|
|
28636
|
-
replace: function replace(expr, title) {
|
|
28637
|
-
return "<div class=\"note\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28638
|
-
}
|
|
28639
|
-
};
|
|
28640
|
-
return [refextension, warningTitleExtension, noteTitleExtension, warningExtension, noteExtension, tripleArobase];
|
|
28641
|
-
};
|
|
28642
|
-
|
|
28643
28552
|
var converter = new showdown__default["default"].Converter({
|
|
28644
28553
|
omitExtraWLInCodeBlocks: true,
|
|
28645
28554
|
ghCompatibleHeaderId: true,
|
|
@@ -28650,20 +28559,15 @@ var converter = new showdown__default["default"].Converter({
|
|
|
28650
28559
|
requireSpaceBeforeHeadingText: true,
|
|
28651
28560
|
ghMentions: true,
|
|
28652
28561
|
emoji: true,
|
|
28653
|
-
ghMentionsLink: '/{u}'
|
|
28654
|
-
extensions: [DaikokuExtension]
|
|
28562
|
+
ghMentionsLink: '/{u}'
|
|
28655
28563
|
});
|
|
28656
28564
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28657
|
-
var _useState = React.useState(
|
|
28565
|
+
var _useState = React.useState(props.preview),
|
|
28658
28566
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28659
28567
|
preview = _useState2[0],
|
|
28660
28568
|
setPreview = _useState2[1];
|
|
28661
28569
|
|
|
28662
|
-
var
|
|
28663
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28664
|
-
editor = _useState4[0];
|
|
28665
|
-
_useState4[1];
|
|
28666
|
-
|
|
28570
|
+
var ref = React.useRef();
|
|
28667
28571
|
React.useEffect(function () {
|
|
28668
28572
|
if (preview) {
|
|
28669
28573
|
showPreview();
|
|
@@ -28672,162 +28576,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28672
28576
|
var commands = [{
|
|
28673
28577
|
name: 'Add header',
|
|
28674
28578
|
icon: 'heading',
|
|
28675
|
-
inject: function inject() {
|
|
28676
|
-
|
|
28677
|
-
|
|
28579
|
+
inject: function inject(range) {
|
|
28580
|
+
return !range ? '#' : [{
|
|
28581
|
+
from: range.from,
|
|
28582
|
+
insert: "# "
|
|
28583
|
+
}];
|
|
28678
28584
|
}
|
|
28679
28585
|
}, {
|
|
28680
28586
|
name: 'Add bold text',
|
|
28681
28587
|
icon: 'bold',
|
|
28682
|
-
inject: function inject() {
|
|
28683
|
-
|
|
28684
|
-
|
|
28588
|
+
inject: function inject(range) {
|
|
28589
|
+
return !range ? '** **' : [{
|
|
28590
|
+
from: range.from,
|
|
28591
|
+
insert: "**"
|
|
28592
|
+
}, {
|
|
28593
|
+
from: range.to,
|
|
28594
|
+
insert: '**'
|
|
28595
|
+
}];
|
|
28685
28596
|
}
|
|
28686
28597
|
}, {
|
|
28687
28598
|
name: 'Add italic text',
|
|
28688
28599
|
icon: 'italic',
|
|
28689
|
-
inject: function inject() {
|
|
28690
|
-
|
|
28691
|
-
|
|
28600
|
+
inject: function inject(range) {
|
|
28601
|
+
return !range ? '* *' : [{
|
|
28602
|
+
from: range.from,
|
|
28603
|
+
insert: '*'
|
|
28604
|
+
}, {
|
|
28605
|
+
from: range.to,
|
|
28606
|
+
insert: '*'
|
|
28607
|
+
}];
|
|
28692
28608
|
}
|
|
28693
28609
|
}, {
|
|
28694
28610
|
name: 'Add strikethrough text',
|
|
28695
28611
|
icon: 'strikethrough',
|
|
28696
|
-
inject: function inject() {
|
|
28697
|
-
|
|
28698
|
-
|
|
28612
|
+
inject: function inject(range) {
|
|
28613
|
+
return !range ? '~~ ~~' : [{
|
|
28614
|
+
from: range.from,
|
|
28615
|
+
insert: '~~'
|
|
28616
|
+
}, {
|
|
28617
|
+
from: range.to,
|
|
28618
|
+
insert: '~~'
|
|
28619
|
+
}];
|
|
28699
28620
|
}
|
|
28700
28621
|
}, {
|
|
28701
28622
|
name: 'Add link',
|
|
28702
28623
|
icon: 'link',
|
|
28703
|
-
inject: function inject() {
|
|
28704
|
-
|
|
28705
|
-
|
|
28624
|
+
inject: function inject(range) {
|
|
28625
|
+
return !range ? '[ ](url)' : [{
|
|
28626
|
+
from: range.from,
|
|
28627
|
+
insert: '['
|
|
28628
|
+
}, {
|
|
28629
|
+
from: range.to,
|
|
28630
|
+
insert: '](url)'
|
|
28631
|
+
}];
|
|
28706
28632
|
}
|
|
28707
28633
|
}, {
|
|
28708
28634
|
name: 'Add code',
|
|
28709
28635
|
icon: 'code',
|
|
28710
|
-
inject: function inject() {
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
|
|
28714
|
-
|
|
28715
|
-
|
|
28716
|
-
|
|
28717
|
-
|
|
28718
|
-
});
|
|
28636
|
+
inject: function inject(range) {
|
|
28637
|
+
return !range ? '```\n\n```\n' : [{
|
|
28638
|
+
from: range.from,
|
|
28639
|
+
insert: '```\n'
|
|
28640
|
+
}, {
|
|
28641
|
+
from: range.to,
|
|
28642
|
+
insert: '\n```\n'
|
|
28643
|
+
}];
|
|
28719
28644
|
}
|
|
28720
28645
|
}, {
|
|
28721
28646
|
name: 'Add quotes',
|
|
28722
28647
|
icon: 'quote-right',
|
|
28723
|
-
inject: function inject() {
|
|
28724
|
-
|
|
28725
|
-
|
|
28648
|
+
inject: function inject(range) {
|
|
28649
|
+
return !range ? '> ' : [{
|
|
28650
|
+
from: range.from,
|
|
28651
|
+
insert: '> '
|
|
28652
|
+
}];
|
|
28726
28653
|
}
|
|
28727
28654
|
}, {
|
|
28728
28655
|
name: 'Add image',
|
|
28729
28656
|
icon: 'image',
|
|
28730
|
-
inject: function inject() {
|
|
28731
|
-
|
|
28732
|
-
|
|
28657
|
+
inject: function inject(range) {
|
|
28658
|
+
return !range ? '' : [{
|
|
28659
|
+
from: range.from,
|
|
28660
|
+
insert: ''
|
|
28664
|
+
}];
|
|
28733
28665
|
}
|
|
28734
28666
|
}, {
|
|
28735
28667
|
name: 'Add unordered list',
|
|
28736
28668
|
icon: 'list-ul',
|
|
28737
|
-
inject: function inject() {
|
|
28738
|
-
|
|
28739
|
-
|
|
28669
|
+
inject: function inject(range) {
|
|
28670
|
+
return !range ? '* ' : [{
|
|
28671
|
+
from: range.from,
|
|
28672
|
+
insert: '* '
|
|
28673
|
+
}];
|
|
28740
28674
|
}
|
|
28741
28675
|
}, {
|
|
28742
28676
|
name: 'Add ordered list',
|
|
28743
28677
|
icon: 'list-ol',
|
|
28744
|
-
inject: function inject() {
|
|
28745
|
-
|
|
28746
|
-
|
|
28678
|
+
inject: function inject(range) {
|
|
28679
|
+
return !range ? '1. ' : [{
|
|
28680
|
+
from: range.from,
|
|
28681
|
+
insert: '1. '
|
|
28682
|
+
}];
|
|
28747
28683
|
}
|
|
28748
28684
|
}, {
|
|
28749
28685
|
name: 'Add check list',
|
|
28750
28686
|
icon: 'tasks',
|
|
28751
|
-
inject: function inject() {
|
|
28752
|
-
|
|
28753
|
-
|
|
28754
|
-
|
|
28755
|
-
|
|
28756
|
-
name: 'Page ref',
|
|
28757
|
-
icon: 'book',
|
|
28758
|
-
inject: function inject() {
|
|
28759
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28760
|
-
return "@ref:[".concat(selected, "](team/api/doc)");
|
|
28761
|
-
}
|
|
28762
|
-
}, {
|
|
28763
|
-
name: 'Warning',
|
|
28764
|
-
icon: 'exclamation-triangle',
|
|
28765
|
-
inject: function inject() {
|
|
28766
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28767
|
-
return "@@@ warning\n".concat(selected, "\n@@@\n");
|
|
28768
|
-
},
|
|
28769
|
-
move: function move(pos, setPos) {
|
|
28770
|
-
return setPos({
|
|
28771
|
-
column: 0,
|
|
28772
|
-
row: pos.row - 2
|
|
28773
|
-
});
|
|
28774
|
-
}
|
|
28775
|
-
}, {
|
|
28776
|
-
name: 'Warning with title',
|
|
28777
|
-
icon: 'exclamation-circle',
|
|
28778
|
-
inject: function inject() {
|
|
28779
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28780
|
-
return "@@@ warning { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28781
|
-
},
|
|
28782
|
-
move: function move(pos, setPos) {
|
|
28783
|
-
return setPos({
|
|
28784
|
-
column: 0,
|
|
28785
|
-
row: pos.row - 2
|
|
28786
|
-
});
|
|
28787
|
-
}
|
|
28788
|
-
}, {
|
|
28789
|
-
name: 'Note',
|
|
28790
|
-
icon: 'sticky-note',
|
|
28791
|
-
inject: function inject() {
|
|
28792
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28793
|
-
return "@@@ note\n".concat(selected, "\n@@@\n");
|
|
28794
|
-
},
|
|
28795
|
-
move: function move(pos, setPos) {
|
|
28796
|
-
return setPos({
|
|
28797
|
-
column: 0,
|
|
28798
|
-
row: pos.row - 2
|
|
28799
|
-
});
|
|
28800
|
-
}
|
|
28801
|
-
}, {
|
|
28802
|
-
name: 'Note with title',
|
|
28803
|
-
icon: 'clipboard',
|
|
28804
|
-
inject: function inject() {
|
|
28805
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28806
|
-
return "@@@ note { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28807
|
-
},
|
|
28808
|
-
move: function move(pos, setPos) {
|
|
28809
|
-
return setPos({
|
|
28810
|
-
column: 0,
|
|
28811
|
-
row: pos.row - 2
|
|
28812
|
-
});
|
|
28813
|
-
}
|
|
28814
|
-
}, {
|
|
28815
|
-
name: 'Lorem Ipsum',
|
|
28816
|
-
icon: 'feather-alt',
|
|
28817
|
-
inject: function inject() {
|
|
28818
|
-
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.';
|
|
28819
|
-
}
|
|
28820
|
-
}, {
|
|
28821
|
-
name: 'Long Lorem Ipsum',
|
|
28822
|
-
icon: 'feather',
|
|
28823
|
-
inject: function inject() {
|
|
28824
|
-
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.";
|
|
28687
|
+
inject: function inject(range) {
|
|
28688
|
+
return !range ? '* [ ] ' : [{
|
|
28689
|
+
from: range.from,
|
|
28690
|
+
insert: '* [ ] '
|
|
28691
|
+
}];
|
|
28825
28692
|
}
|
|
28826
28693
|
}];
|
|
28827
28694
|
|
|
28828
28695
|
var showPreview = function showPreview() {
|
|
28829
|
-
|
|
28830
|
-
|
|
28696
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28697
|
+
|
|
28698
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28699
|
+
return hljs__default["default"].highlightElement(block);
|
|
28831
28700
|
});
|
|
28832
28701
|
};
|
|
28833
28702
|
|
|
@@ -28845,21 +28714,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28845
28714
|
title: command.name,
|
|
28846
28715
|
key: "toolbar-btn-".concat(idx),
|
|
28847
28716
|
onClick: function onClick() {
|
|
28848
|
-
var
|
|
28849
|
-
|
|
28850
|
-
if (
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
|
|
28857
|
-
|
|
28858
|
-
return
|
|
28859
|
-
|
|
28717
|
+
var editor = ref.current;
|
|
28718
|
+
var selections = editor.state.selection.ranges;
|
|
28719
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28720
|
+
changes: {
|
|
28721
|
+
from: 0,
|
|
28722
|
+
to: editor.state.doc.length,
|
|
28723
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28724
|
+
}
|
|
28725
|
+
});else {
|
|
28726
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28727
|
+
return {
|
|
28728
|
+
changes: command.inject(range),
|
|
28729
|
+
range: range
|
|
28730
|
+
};
|
|
28731
|
+
}));
|
|
28860
28732
|
}
|
|
28861
|
-
|
|
28862
|
-
editor.focus();
|
|
28863
28733
|
}
|
|
28864
28734
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
28865
28735
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28870,7 +28740,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28870
28740
|
var classes = useCustomStyle();
|
|
28871
28741
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28872
28742
|
className: classNames__default["default"](props.className)
|
|
28873
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28743
|
+
}, !props.readOnly && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28874
28744
|
style: {
|
|
28875
28745
|
marginBottom: 10
|
|
28876
28746
|
}
|
|
@@ -28895,9 +28765,13 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28895
28765
|
return setPreview(true);
|
|
28896
28766
|
}
|
|
28897
28767
|
}, "Preview"))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28898
|
-
className: classNames__default["default"](classes.flex)
|
|
28899
|
-
}, injectButtons())), !preview && /*#__PURE__*/React__default["default"].createElement(CodeInput,
|
|
28900
|
-
|
|
28768
|
+
className: classNames__default["default"](classes.flex, classes.flexWrap)
|
|
28769
|
+
}, injectButtons())), !preview && /*#__PURE__*/React__default["default"].createElement(CodeInput, _extends({}, props, {
|
|
28770
|
+
setRef: function setRef(e) {
|
|
28771
|
+
return ref.current = e;
|
|
28772
|
+
}
|
|
28773
|
+
})), preview && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28774
|
+
className: "preview",
|
|
28901
28775
|
dangerouslySetInnerHTML: {
|
|
28902
28776
|
__html: converter.makeHtml(props.value)
|
|
28903
28777
|
}
|
|
@@ -28946,17 +28820,17 @@ function SingleLineCode(_ref) {
|
|
|
28946
28820
|
|
|
28947
28821
|
var _resolvers;
|
|
28948
28822
|
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28949
|
-
return yup__namespace.string().typeError(typeErrorMessage || 'Value must be a string');
|
|
28823
|
+
return yup__namespace.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28950
28824
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28951
|
-
return yup__namespace.number().transform(function (v) {
|
|
28825
|
+
return yup__namespace.number().nullable().optional().transform(function (v) {
|
|
28952
28826
|
return isNaN(v) ? null : v;
|
|
28953
28827
|
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28954
28828
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28955
|
-
return yup__namespace.bool();
|
|
28829
|
+
return yup__namespace.bool().nullable().optional();
|
|
28956
28830
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28957
|
-
return yup__namespace.object();
|
|
28831
|
+
return yup__namespace.object().nullable().optional();
|
|
28958
28832
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28959
|
-
return yup__namespace.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28833
|
+
return yup__namespace.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28960
28834
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28961
28835
|
return yup__namespace.mixed();
|
|
28962
28836
|
}), _resolvers);
|
|
@@ -28983,6 +28857,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28983
28857
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28984
28858
|
}, arrayResolver);
|
|
28985
28859
|
} else if (props.type === type.object && props.schema) {
|
|
28860
|
+
if (!Object.keys(props.schema).length) {
|
|
28861
|
+
return yup__namespace.object();
|
|
28862
|
+
}
|
|
28863
|
+
|
|
28986
28864
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28987
28865
|
|
|
28988
28866
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -29033,11 +28911,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
29033
28911
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
29034
28912
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
29035
28913
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28914
|
+
|
|
28915
|
+
if (!Object.keys(schema).length) {
|
|
28916
|
+
return {
|
|
28917
|
+
shape: yup__namespace.object().shape({}),
|
|
28918
|
+
dependencies: dependencies
|
|
28919
|
+
};
|
|
28920
|
+
}
|
|
28921
|
+
|
|
29036
28922
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
29037
28923
|
if (_typeof$1(key) === 'object') {
|
|
29038
28924
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
29039
28925
|
}
|
|
29040
28926
|
|
|
28927
|
+
if (!schema[key]) {
|
|
28928
|
+
return resolvers;
|
|
28929
|
+
}
|
|
28930
|
+
|
|
29041
28931
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
29042
28932
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
29043
28933
|
}, {});
|
|
@@ -29047,7 +28937,8 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
29047
28937
|
};
|
|
29048
28938
|
};
|
|
29049
28939
|
|
|
29050
|
-
var CustomizableInput$1 = function
|
|
28940
|
+
var CustomizableInput$1 = /*#__PURE__*/React__default["default"].memo(function (props) {
|
|
28941
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
29051
28942
|
if (props.render) {
|
|
29052
28943
|
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
29053
28944
|
error: props.error
|
|
@@ -29055,8 +28946,9 @@ var CustomizableInput$1 = function CustomizableInput(props) {
|
|
|
29055
28946
|
}
|
|
29056
28947
|
|
|
29057
28948
|
return props.children;
|
|
29058
|
-
}
|
|
29059
|
-
|
|
28949
|
+
}, function (prev, next) {
|
|
28950
|
+
return prev.field.value === next.field.value;
|
|
28951
|
+
});
|
|
29060
28952
|
var ControlledInput = function ControlledInput(_ref) {
|
|
29061
28953
|
var defaultValue = _ref.defaultValue,
|
|
29062
28954
|
step = _ref.step,
|
|
@@ -29091,22 +28983,36 @@ var ControlledInput = function ControlledInput(_ref) {
|
|
|
29091
28983
|
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29092
28984
|
placeholder: step.placeholder,
|
|
29093
28985
|
onChange: function onChange(e) {
|
|
29094
|
-
|
|
28986
|
+
var value = function () {
|
|
28987
|
+
if (!e) {
|
|
28988
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28989
|
+
return e;
|
|
28990
|
+
} else {
|
|
28991
|
+
return null;
|
|
28992
|
+
}
|
|
28993
|
+
} else if (e.target) {
|
|
28994
|
+
return e.target.value || null;
|
|
28995
|
+
} else {
|
|
28996
|
+
return e;
|
|
28997
|
+
}
|
|
28998
|
+
}();
|
|
28999
|
+
|
|
29000
|
+
console.log(entry, value, getValues());
|
|
29001
|
+
field.onChange(value);
|
|
29095
29002
|
option(step.onChange).map(function (onChange) {
|
|
29096
29003
|
return onChange({
|
|
29097
29004
|
rawValues: getValues(),
|
|
29098
|
-
value:
|
|
29005
|
+
value: value,
|
|
29099
29006
|
setValue: _setValue
|
|
29100
29007
|
});
|
|
29101
29008
|
});
|
|
29102
29009
|
},
|
|
29103
|
-
value: field.value
|
|
29010
|
+
value: field.value
|
|
29104
29011
|
});
|
|
29105
29012
|
|
|
29106
29013
|
var error = entry.split('.').reduce(function (acc, curr) {
|
|
29107
29014
|
return acc && acc[curr];
|
|
29108
29015
|
}, errors);
|
|
29109
|
-
console.log("render controlled input " + entry);
|
|
29110
29016
|
return /*#__PURE__*/React__default["default"].createElement(CustomizableInput$1, {
|
|
29111
29017
|
render: step.render,
|
|
29112
29018
|
field: _objectSpread2$1({
|
|
@@ -29126,7 +29032,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
29126
29032
|
var ref = React.useRef(); // Store current value in ref
|
|
29127
29033
|
|
|
29128
29034
|
React.useEffect(function () {
|
|
29129
|
-
ref.current = value
|
|
29035
|
+
ref.current = value;
|
|
29130
29036
|
}, [value]); // Only re-run if value changes
|
|
29131
29037
|
// Return previous value (happens before update in useEffect above)
|
|
29132
29038
|
|
|
@@ -29211,14 +29117,14 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29211
29117
|
return props.children;
|
|
29212
29118
|
};
|
|
29213
29119
|
|
|
29214
|
-
var defaultVal = function defaultVal(value,
|
|
29120
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29215
29121
|
if (!!defaultValue) return defaultValue;
|
|
29216
29122
|
if (!!array) return [];
|
|
29217
29123
|
return value;
|
|
29218
29124
|
};
|
|
29219
29125
|
|
|
29220
29126
|
var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
29221
|
-
return flow.reduce(function (acc, key) {
|
|
29127
|
+
return (flow || []).reduce(function (acc, key) {
|
|
29222
29128
|
if (_typeof$1(key) === 'object') {
|
|
29223
29129
|
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema, value));
|
|
29224
29130
|
}
|
|
@@ -29229,7 +29135,7 @@ var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
|
29229
29135
|
return acc;
|
|
29230
29136
|
}
|
|
29231
29137
|
|
|
29232
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.
|
|
29138
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29233
29139
|
}, {});
|
|
29234
29140
|
};
|
|
29235
29141
|
|
|
@@ -29251,7 +29157,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29251
29157
|
|
|
29252
29158
|
var v;
|
|
29253
29159
|
if (obj) v = obj[key];
|
|
29254
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29160
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29255
29161
|
|
|
29256
29162
|
if (step.array && !step.render) {
|
|
29257
29163
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29264,7 +29170,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29264
29170
|
|
|
29265
29171
|
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) || {})));
|
|
29266
29172
|
} else {
|
|
29267
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29173
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29268
29174
|
}
|
|
29269
29175
|
}, obj);
|
|
29270
29176
|
};
|
|
@@ -29296,7 +29202,7 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29296
29202
|
|
|
29297
29203
|
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) || {})));
|
|
29298
29204
|
} else {
|
|
29299
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v
|
|
29205
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29300
29206
|
}
|
|
29301
29207
|
}, {});
|
|
29302
29208
|
};
|
|
@@ -29316,10 +29222,22 @@ var validate = function validate(flow, schema, value) {
|
|
|
29316
29222
|
var Watcher = function Watcher(_ref7) {
|
|
29317
29223
|
var options = _ref7.options,
|
|
29318
29224
|
control = _ref7.control,
|
|
29319
|
-
schema = _ref7.schema
|
|
29225
|
+
schema = _ref7.schema,
|
|
29226
|
+
onSubmit = _ref7.onSubmit,
|
|
29227
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29228
|
+
_ref7.getValues;
|
|
29229
|
+
_ref7.watch;
|
|
29320
29230
|
var data = reactHookForm.useWatch({
|
|
29321
29231
|
control: control
|
|
29322
29232
|
});
|
|
29233
|
+
var prev = usePrevious(data);
|
|
29234
|
+
React.useEffect(function () {
|
|
29235
|
+
if (!!options.autosubmit) {
|
|
29236
|
+
if (!deepEqual__default["default"](data, prev)) handleSubmit(function () {
|
|
29237
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29238
|
+
})();
|
|
29239
|
+
}
|
|
29240
|
+
}, [data]);
|
|
29323
29241
|
|
|
29324
29242
|
if (options.watch) {
|
|
29325
29243
|
if (typeof options.watch === 'function') {
|
|
@@ -29381,38 +29299,38 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29381
29299
|
resolver: function resolver(data, context, options) {
|
|
29382
29300
|
return yup$1.yupResolver(_resolver(data))(data, context, options);
|
|
29383
29301
|
},
|
|
29384
|
-
defaultValues: cleanInputArray(value, defaultValues, flow, schema),
|
|
29385
29302
|
shouldFocusError: false,
|
|
29386
|
-
mode: '
|
|
29387
|
-
|
|
29303
|
+
mode: 'onChange'
|
|
29388
29304
|
});
|
|
29305
|
+
|
|
29306
|
+
var _useState = React.useState(false),
|
|
29307
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29308
|
+
initialReseted = _useState2[0],
|
|
29309
|
+
setReset = _useState2[1];
|
|
29310
|
+
|
|
29311
|
+
React.useEffect(function () {
|
|
29312
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29313
|
+
|
|
29314
|
+
setReset(true);
|
|
29315
|
+
}, [_reset]);
|
|
29316
|
+
React.useEffect(function () {
|
|
29317
|
+
initialReseted && trigger();
|
|
29318
|
+
}, [trigger, initialReseted]);
|
|
29389
29319
|
var _handleSubmit = methods.handleSubmit,
|
|
29390
29320
|
_methods$formState = methods.formState,
|
|
29391
29321
|
errors = _methods$formState.errors,
|
|
29392
29322
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29393
29323
|
_reset = methods.reset,
|
|
29394
29324
|
trigger = methods.trigger,
|
|
29395
|
-
getValues = methods.getValues
|
|
29325
|
+
getValues = methods.getValues,
|
|
29326
|
+
watch = methods.watch;
|
|
29327
|
+
var prev = usePrevious(value);
|
|
29328
|
+
var prevSchema = usePrevious(schema);
|
|
29396
29329
|
React.useEffect(function () {
|
|
29397
|
-
|
|
29398
|
-
|
|
29399
|
-
|
|
29400
|
-
|
|
29401
|
-
console.log('re-render cauz value/reset changed');
|
|
29402
|
-
|
|
29403
|
-
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29404
|
-
}, [value, _reset]);
|
|
29405
|
-
React.useEffect(function () {
|
|
29406
|
-
console.log('re-render cauz schema changed');
|
|
29407
|
-
|
|
29408
|
-
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29409
|
-
}, [schema]);
|
|
29410
|
-
|
|
29411
|
-
if (!!options.autosubmit) {
|
|
29412
|
-
_handleSubmit(function (data) {
|
|
29413
|
-
return onSubmit(cleanOutputArray(data, schema));
|
|
29414
|
-
}, onError)();
|
|
29415
|
-
}
|
|
29330
|
+
if (!deepEqual__default["default"](value, prev) || !deepEqual__default["default"](schema, prevSchema)) {
|
|
29331
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29332
|
+
}
|
|
29333
|
+
}, [value, schema]);
|
|
29416
29334
|
|
|
29417
29335
|
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29418
29336
|
if (typeof prop === 'function') {
|
|
@@ -29433,9 +29351,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29433
29351
|
onSubmit(clean);
|
|
29434
29352
|
}, onError)();
|
|
29435
29353
|
},
|
|
29436
|
-
rawData: function rawData() {
|
|
29437
|
-
return cleanOutputArray(data, schema);
|
|
29438
|
-
},
|
|
29439
29354
|
trigger: trigger,
|
|
29440
29355
|
methods: methods
|
|
29441
29356
|
};
|
|
@@ -29443,7 +29358,10 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29443
29358
|
return /*#__PURE__*/React__default["default"].createElement(reactHookForm.FormProvider, methods, /*#__PURE__*/React__default["default"].createElement(Watcher, {
|
|
29444
29359
|
options: options,
|
|
29445
29360
|
control: methods.control,
|
|
29446
|
-
schema: schema
|
|
29361
|
+
schema: schema,
|
|
29362
|
+
onSubmit: onSubmit,
|
|
29363
|
+
handleSubmit: _handleSubmit,
|
|
29364
|
+
watch: methods.watch
|
|
29447
29365
|
}), /*#__PURE__*/React__default["default"].createElement("form", {
|
|
29448
29366
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29449
29367
|
onSubmit: _handleSubmit(function (data) {
|
|
@@ -29466,8 +29384,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29466
29384
|
}).map(function (visible) {
|
|
29467
29385
|
switch (_typeof$1(visible)) {
|
|
29468
29386
|
case 'object':
|
|
29469
|
-
console.log('watch from visibleStep');
|
|
29470
|
-
|
|
29471
29387
|
var _value = watch(step.visible.ref);
|
|
29472
29388
|
|
|
29473
29389
|
return option(step.visible.test).map(function (test) {
|
|
@@ -29574,8 +29490,6 @@ var Step = function Step(_ref9) {
|
|
|
29574
29490
|
watch = _useFormContext2.watch;
|
|
29575
29491
|
_useFormContext2.register;
|
|
29576
29492
|
|
|
29577
|
-
console.log("re-render : " + entry);
|
|
29578
|
-
|
|
29579
29493
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29580
29494
|
var errored = entry.flow.some(function (step) {
|
|
29581
29495
|
return !!errors[step] && (dirtyFields[step] || touchedFields[step]);
|
|
@@ -29598,7 +29512,6 @@ var Step = function Step(_ref9) {
|
|
|
29598
29512
|
}).map(function (visible) {
|
|
29599
29513
|
switch (_typeof$1(visible)) {
|
|
29600
29514
|
case 'object':
|
|
29601
|
-
console.log("watch of collapse");
|
|
29602
29515
|
var value = watch(visible.ref);
|
|
29603
29516
|
return option(visible.test).map(function (test) {
|
|
29604
29517
|
return test(value, index);
|
|
@@ -29647,14 +29560,13 @@ var Step = function Step(_ref9) {
|
|
|
29647
29560
|
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29648
29561
|
|
|
29649
29562
|
if (onAfterChangeFunc) {
|
|
29650
|
-
var
|
|
29651
|
-
|
|
29563
|
+
var data = watch();
|
|
29652
29564
|
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29653
29565
|
return acc && acc[curr];
|
|
29654
|
-
},
|
|
29566
|
+
}, data) || {};
|
|
29655
29567
|
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29656
29568
|
var newData = cleanOutputArray(d, schema);
|
|
29657
|
-
if (!
|
|
29569
|
+
if (!deepEqual__default["default"](newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29658
29570
|
entry: entry,
|
|
29659
29571
|
previousValue: currentData,
|
|
29660
29572
|
value: getValues(entry),
|
|
@@ -29686,7 +29598,6 @@ var Step = function Step(_ref9) {
|
|
|
29686
29598
|
}, /*#__PURE__*/React__default["default"].createElement(ArrayStep, {
|
|
29687
29599
|
entry: entry,
|
|
29688
29600
|
step: step,
|
|
29689
|
-
defaultValue: step.defaultValue || null,
|
|
29690
29601
|
disabled: functionalProperty(entry, step.disabled),
|
|
29691
29602
|
component: function component(props, idx) {
|
|
29692
29603
|
var _props$defaultValue;
|
|
@@ -29927,15 +29838,15 @@ var Step = function Step(_ref9) {
|
|
|
29927
29838
|
var FileInput = function FileInput(_ref11) {
|
|
29928
29839
|
var onChange = _ref11.onChange;
|
|
29929
29840
|
|
|
29930
|
-
var
|
|
29931
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29932
|
-
uploading = _useState2[0],
|
|
29933
|
-
setUploading = _useState2[1];
|
|
29934
|
-
|
|
29935
|
-
var _useState3 = React.useState(undefined),
|
|
29841
|
+
var _useState3 = React.useState(false),
|
|
29936
29842
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29937
|
-
|
|
29938
|
-
|
|
29843
|
+
uploading = _useState4[0],
|
|
29844
|
+
setUploading = _useState4[1];
|
|
29845
|
+
|
|
29846
|
+
var _useState5 = React.useState(undefined),
|
|
29847
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29848
|
+
input = _useState6[0],
|
|
29849
|
+
setInput = _useState6[1];
|
|
29939
29850
|
|
|
29940
29851
|
var setFiles = function setFiles(e) {
|
|
29941
29852
|
var files = e.target.files;
|
|
@@ -30014,10 +29925,7 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
30014
29925
|
|
|
30015
29926
|
var _useFieldArray = reactHookForm.useFieldArray({
|
|
30016
29927
|
control: control,
|
|
30017
|
-
|
|
30018
|
-
name: entry // unique name for your Field Array
|
|
30019
|
-
// keyName: "id", default to "id", you can change the key name
|
|
30020
|
-
|
|
29928
|
+
name: entry
|
|
30021
29929
|
}),
|
|
30022
29930
|
fields = _useFieldArray.fields,
|
|
30023
29931
|
append = _useFieldArray.append,
|
|
@@ -30061,10 +29969,11 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
30061
29969
|
type: "button",
|
|
30062
29970
|
className: classNames__default["default"](classes.btn, classes.btn_blue, classes.btn_sm, classes.mt_5, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
30063
29971
|
onClick: function onClick() {
|
|
29972
|
+
var newValue = cleanInputArray({}, getValues(entry), step.flow, step.schema);
|
|
30064
29973
|
append({
|
|
30065
|
-
value: step.addableDefaultValue || defaultVal(
|
|
30066
|
-
});
|
|
30067
|
-
|
|
29974
|
+
value: step.addableDefaultValue || (newValue ? newValue : defaultVal())
|
|
29975
|
+
}); // trigger(entry);
|
|
29976
|
+
|
|
30068
29977
|
option(step.onChange).map(function (onChange) {
|
|
30069
29978
|
return onChange({
|
|
30070
29979
|
rawValues: getValues(),
|
|
@@ -30100,10 +30009,10 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30100
30009
|
_useFormContext4.trigger;
|
|
30101
30010
|
_useFormContext4.formState;
|
|
30102
30011
|
|
|
30103
|
-
var
|
|
30104
|
-
|
|
30105
|
-
collapsed =
|
|
30106
|
-
setCollapsed =
|
|
30012
|
+
var _useState7 = React.useState(!!step.collapsed),
|
|
30013
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
30014
|
+
collapsed = _useState8[0],
|
|
30015
|
+
setCollapsed = _useState8[1];
|
|
30107
30016
|
|
|
30108
30017
|
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
30109
30018
|
// const v = getValues(parent);
|
|
@@ -30135,8 +30044,8 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30135
30044
|
});
|
|
30136
30045
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30137
30046
|
React.useEffect(function () {
|
|
30138
|
-
if (!!prevSchema && !
|
|
30139
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30047
|
+
if (!!prevSchema && !deepEqual__default["default"](prevSchema, schemaAndFlow.schema)) {
|
|
30048
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30140
30049
|
setValue(parent, def, {
|
|
30141
30050
|
shouldValidate: false
|
|
30142
30051
|
});
|