@maif/react-forms 1.0.37-rc.1 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -11
- package/lib/esm/index.js +248 -341
- package/lib/index.js +252 -344
- 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;
|
|
@@ -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,
|
|
@@ -798,6 +773,15 @@ var style = (_style = {
|
|
|
798
773
|
border: "1px solid green",
|
|
799
774
|
justifyContent: "flex-end"
|
|
800
775
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
776
|
+
width: "35px",
|
|
777
|
+
height: "22px",
|
|
778
|
+
borderRadius: "20px",
|
|
779
|
+
display: "flex",
|
|
780
|
+
marginTop: "10px",
|
|
781
|
+
backgroundColor: "#dc3545",
|
|
782
|
+
border: "1px solid #dc3545",
|
|
783
|
+
justifyContent: "flex-start"
|
|
784
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
801
785
|
width: "35px",
|
|
802
786
|
height: "22px",
|
|
803
787
|
borderRadius: "20px",
|
|
@@ -813,6 +797,14 @@ var style = (_style = {
|
|
|
813
797
|
width: "20px",
|
|
814
798
|
height: "20px"
|
|
815
799
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
800
|
+
backgroundColor: "#fff",
|
|
801
|
+
borderRadius: "20px",
|
|
802
|
+
cursor: "pointer",
|
|
803
|
+
width: "20px",
|
|
804
|
+
height: "20px",
|
|
805
|
+
border: "1px solid #dfdfdf",
|
|
806
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
807
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
816
808
|
backgroundColor: "#fff",
|
|
817
809
|
borderRadius: "20px",
|
|
818
810
|
cursor: "pointer",
|
|
@@ -831,7 +823,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
831
823
|
return classes;
|
|
832
824
|
};
|
|
833
825
|
|
|
834
|
-
var BooleanInput = function
|
|
826
|
+
var BooleanInput = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
835
827
|
var _classNames;
|
|
836
828
|
|
|
837
829
|
var onChange = _ref.onChange,
|
|
@@ -854,15 +846,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
854
846
|
}
|
|
855
847
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
856
848
|
className: classNames__default["default"](classes.switch_button_on)
|
|
857
|
-
})), !value && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
849
|
+
})), !value && value !== null && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
858
850
|
className: classNames__default["default"](classes.content_switch_button_off),
|
|
859
851
|
onClick: function onClick() {
|
|
860
852
|
return handleClick(true);
|
|
861
853
|
}
|
|
862
854
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
863
855
|
className: classNames__default["default"](classes.switch_button_off)
|
|
856
|
+
})), value === null && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
857
|
+
className: classNames__default["default"](classes.content_switch_button_null),
|
|
858
|
+
onClick: function onClick() {
|
|
859
|
+
return handleClick(true);
|
|
860
|
+
}
|
|
861
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
862
|
+
className: classNames__default["default"](classes.switch_button_null)
|
|
864
863
|
})));
|
|
865
|
-
};
|
|
864
|
+
});
|
|
866
865
|
|
|
867
866
|
var Collapse = function Collapse(props) {
|
|
868
867
|
var _classNames4;
|
|
@@ -953,38 +952,6 @@ var None = {
|
|
|
953
952
|
}
|
|
954
953
|
};
|
|
955
954
|
|
|
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
955
|
var isPromise = function isPromise(value) {
|
|
989
956
|
return Boolean(value && typeof value.then === 'function');
|
|
990
957
|
};
|
|
@@ -1000,7 +967,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1000
967
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
1001
968
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1002
969
|
|
|
1003
|
-
if (value === null) {
|
|
970
|
+
if (value === null || !value) {
|
|
1004
971
|
return null;
|
|
1005
972
|
}
|
|
1006
973
|
|
|
@@ -1016,7 +983,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1016
983
|
}
|
|
1017
984
|
|
|
1018
985
|
var maybeValue = option(possibleValues.find(function (v) {
|
|
1019
|
-
return
|
|
986
|
+
return deepEqual__default["default"](v.value, value);
|
|
1020
987
|
}));
|
|
1021
988
|
return maybeValue.getOrElse({
|
|
1022
989
|
label: maybeValue.map(function (v) {
|
|
@@ -1028,7 +995,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
1028
995
|
});
|
|
1029
996
|
};
|
|
1030
997
|
|
|
1031
|
-
var SelectInput = function
|
|
998
|
+
var SelectInput = /*#__PURE__*/React__default["default"].forwardRef(function (props, _) {
|
|
1032
999
|
var classes = useCustomStyle();
|
|
1033
1000
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
1034
1001
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1183,7 +1150,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1183
1150
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1184
1151
|
}));
|
|
1185
1152
|
}
|
|
1186
|
-
};
|
|
1153
|
+
});
|
|
1187
1154
|
|
|
1188
1155
|
var ObjectInput = function ObjectInput(props) {
|
|
1189
1156
|
var _useState = React.useState(),
|
|
@@ -1214,7 +1181,7 @@ var ObjectInput = function ObjectInput(props) {
|
|
|
1214
1181
|
if (item.key) return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, item.key, item.value));
|
|
1215
1182
|
return acc;
|
|
1216
1183
|
}, {});
|
|
1217
|
-
if (!
|
|
1184
|
+
if (!deepEqual__default["default"](newState, previousState)) setInternalState(Object.fromEntries(Object.entries(props.value || {}).map(function (_ref5, idx) {
|
|
1218
1185
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
1219
1186
|
key = _ref6[0],
|
|
1220
1187
|
value = _ref6[1];
|
|
@@ -23690,7 +23657,7 @@ const Emoji = {
|
|
|
23690
23657
|
}]
|
|
23691
23658
|
};
|
|
23692
23659
|
|
|
23693
|
-
const data
|
|
23660
|
+
const data = /*@__PURE__*/defineLanguageFacet({ block: { open: "<!--", close: "-->" } });
|
|
23694
23661
|
const commonmark = /*@__PURE__*/parser.configure({
|
|
23695
23662
|
props: [
|
|
23696
23663
|
/*@__PURE__*/styleTags({
|
|
@@ -23726,12 +23693,12 @@ const commonmark = /*@__PURE__*/parser.configure({
|
|
|
23726
23693
|
Document: () => null
|
|
23727
23694
|
}),
|
|
23728
23695
|
/*@__PURE__*/languageDataProp.add({
|
|
23729
|
-
Document: data
|
|
23696
|
+
Document: data
|
|
23730
23697
|
})
|
|
23731
23698
|
]
|
|
23732
23699
|
});
|
|
23733
23700
|
function mkLang(parser) {
|
|
23734
|
-
return new Language(data
|
|
23701
|
+
return new Language(data, parser, parser.nodeSet.types.find(t => t.name == "Document"));
|
|
23735
23702
|
}
|
|
23736
23703
|
/**
|
|
23737
23704
|
Language support for strict CommonMark.
|
|
@@ -28570,7 +28537,7 @@ function CodeInput(_ref) {
|
|
|
28570
28537
|
changes: {
|
|
28571
28538
|
from: 0,
|
|
28572
28539
|
to: editor.state.doc.length,
|
|
28573
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28540
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28574
28541
|
}
|
|
28575
28542
|
});
|
|
28576
28543
|
}, [value]);
|
|
@@ -28579,67 +28546,6 @@ function CodeInput(_ref) {
|
|
|
28579
28546
|
});
|
|
28580
28547
|
}
|
|
28581
28548
|
|
|
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
28549
|
var converter = new showdown__default["default"].Converter({
|
|
28644
28550
|
omitExtraWLInCodeBlocks: true,
|
|
28645
28551
|
ghCompatibleHeaderId: true,
|
|
@@ -28650,20 +28556,15 @@ var converter = new showdown__default["default"].Converter({
|
|
|
28650
28556
|
requireSpaceBeforeHeadingText: true,
|
|
28651
28557
|
ghMentions: true,
|
|
28652
28558
|
emoji: true,
|
|
28653
|
-
ghMentionsLink: '/{u}'
|
|
28654
|
-
extensions: [DaikokuExtension]
|
|
28559
|
+
ghMentionsLink: '/{u}'
|
|
28655
28560
|
});
|
|
28656
28561
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28657
|
-
var _useState = React.useState(
|
|
28562
|
+
var _useState = React.useState(props.preview),
|
|
28658
28563
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28659
28564
|
preview = _useState2[0],
|
|
28660
28565
|
setPreview = _useState2[1];
|
|
28661
28566
|
|
|
28662
|
-
var
|
|
28663
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28664
|
-
editor = _useState4[0];
|
|
28665
|
-
_useState4[1];
|
|
28666
|
-
|
|
28567
|
+
var ref = React.useRef();
|
|
28667
28568
|
React.useEffect(function () {
|
|
28668
28569
|
if (preview) {
|
|
28669
28570
|
showPreview();
|
|
@@ -28672,162 +28573,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28672
28573
|
var commands = [{
|
|
28673
28574
|
name: 'Add header',
|
|
28674
28575
|
icon: 'heading',
|
|
28675
|
-
inject: function inject() {
|
|
28676
|
-
|
|
28677
|
-
|
|
28576
|
+
inject: function inject(range) {
|
|
28577
|
+
return !range ? '#' : [{
|
|
28578
|
+
from: range.from,
|
|
28579
|
+
insert: "# "
|
|
28580
|
+
}];
|
|
28678
28581
|
}
|
|
28679
28582
|
}, {
|
|
28680
28583
|
name: 'Add bold text',
|
|
28681
28584
|
icon: 'bold',
|
|
28682
|
-
inject: function inject() {
|
|
28683
|
-
|
|
28684
|
-
|
|
28585
|
+
inject: function inject(range) {
|
|
28586
|
+
return !range ? '** **' : [{
|
|
28587
|
+
from: range.from,
|
|
28588
|
+
insert: "**"
|
|
28589
|
+
}, {
|
|
28590
|
+
from: range.to,
|
|
28591
|
+
insert: '**'
|
|
28592
|
+
}];
|
|
28685
28593
|
}
|
|
28686
28594
|
}, {
|
|
28687
28595
|
name: 'Add italic text',
|
|
28688
28596
|
icon: 'italic',
|
|
28689
|
-
inject: function inject() {
|
|
28690
|
-
|
|
28691
|
-
|
|
28597
|
+
inject: function inject(range) {
|
|
28598
|
+
return !range ? '* *' : [{
|
|
28599
|
+
from: range.from,
|
|
28600
|
+
insert: '*'
|
|
28601
|
+
}, {
|
|
28602
|
+
from: range.to,
|
|
28603
|
+
insert: '*'
|
|
28604
|
+
}];
|
|
28692
28605
|
}
|
|
28693
28606
|
}, {
|
|
28694
28607
|
name: 'Add strikethrough text',
|
|
28695
28608
|
icon: 'strikethrough',
|
|
28696
|
-
inject: function inject() {
|
|
28697
|
-
|
|
28698
|
-
|
|
28609
|
+
inject: function inject(range) {
|
|
28610
|
+
return !range ? '~~ ~~' : [{
|
|
28611
|
+
from: range.from,
|
|
28612
|
+
insert: '~~'
|
|
28613
|
+
}, {
|
|
28614
|
+
from: range.to,
|
|
28615
|
+
insert: '~~'
|
|
28616
|
+
}];
|
|
28699
28617
|
}
|
|
28700
28618
|
}, {
|
|
28701
28619
|
name: 'Add link',
|
|
28702
28620
|
icon: 'link',
|
|
28703
|
-
inject: function inject() {
|
|
28704
|
-
|
|
28705
|
-
|
|
28621
|
+
inject: function inject(range) {
|
|
28622
|
+
return !range ? '[ ](url)' : [{
|
|
28623
|
+
from: range.from,
|
|
28624
|
+
insert: '['
|
|
28625
|
+
}, {
|
|
28626
|
+
from: range.to,
|
|
28627
|
+
insert: '](url)'
|
|
28628
|
+
}];
|
|
28706
28629
|
}
|
|
28707
28630
|
}, {
|
|
28708
28631
|
name: 'Add code',
|
|
28709
28632
|
icon: 'code',
|
|
28710
|
-
inject: function inject() {
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
|
|
28714
|
-
|
|
28715
|
-
|
|
28716
|
-
|
|
28717
|
-
|
|
28718
|
-
});
|
|
28633
|
+
inject: function inject(range) {
|
|
28634
|
+
return !range ? '```\n\n```\n' : [{
|
|
28635
|
+
from: range.from,
|
|
28636
|
+
insert: '```\n'
|
|
28637
|
+
}, {
|
|
28638
|
+
from: range.to,
|
|
28639
|
+
insert: '\n```\n'
|
|
28640
|
+
}];
|
|
28719
28641
|
}
|
|
28720
28642
|
}, {
|
|
28721
28643
|
name: 'Add quotes',
|
|
28722
28644
|
icon: 'quote-right',
|
|
28723
|
-
inject: function inject() {
|
|
28724
|
-
|
|
28725
|
-
|
|
28645
|
+
inject: function inject(range) {
|
|
28646
|
+
return !range ? '> ' : [{
|
|
28647
|
+
from: range.from,
|
|
28648
|
+
insert: '> '
|
|
28649
|
+
}];
|
|
28726
28650
|
}
|
|
28727
28651
|
}, {
|
|
28728
28652
|
name: 'Add image',
|
|
28729
28653
|
icon: 'image',
|
|
28730
|
-
inject: function inject() {
|
|
28731
|
-
|
|
28732
|
-
|
|
28654
|
+
inject: function inject(range) {
|
|
28655
|
+
return !range ? '' : [{
|
|
28656
|
+
from: range.from,
|
|
28657
|
+
insert: ''
|
|
28661
|
+
}];
|
|
28733
28662
|
}
|
|
28734
28663
|
}, {
|
|
28735
28664
|
name: 'Add unordered list',
|
|
28736
28665
|
icon: 'list-ul',
|
|
28737
|
-
inject: function inject() {
|
|
28738
|
-
|
|
28739
|
-
|
|
28666
|
+
inject: function inject(range) {
|
|
28667
|
+
return !range ? '* ' : [{
|
|
28668
|
+
from: range.from,
|
|
28669
|
+
insert: '* '
|
|
28670
|
+
}];
|
|
28740
28671
|
}
|
|
28741
28672
|
}, {
|
|
28742
28673
|
name: 'Add ordered list',
|
|
28743
28674
|
icon: 'list-ol',
|
|
28744
|
-
inject: function inject() {
|
|
28745
|
-
|
|
28746
|
-
|
|
28675
|
+
inject: function inject(range) {
|
|
28676
|
+
return !range ? '1. ' : [{
|
|
28677
|
+
from: range.from,
|
|
28678
|
+
insert: '1. '
|
|
28679
|
+
}];
|
|
28747
28680
|
}
|
|
28748
28681
|
}, {
|
|
28749
28682
|
name: 'Add check list',
|
|
28750
28683
|
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.";
|
|
28684
|
+
inject: function inject(range) {
|
|
28685
|
+
return !range ? '* [ ] ' : [{
|
|
28686
|
+
from: range.from,
|
|
28687
|
+
insert: '* [ ] '
|
|
28688
|
+
}];
|
|
28825
28689
|
}
|
|
28826
28690
|
}];
|
|
28827
28691
|
|
|
28828
28692
|
var showPreview = function showPreview() {
|
|
28829
|
-
|
|
28830
|
-
|
|
28693
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28694
|
+
|
|
28695
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28696
|
+
return hljs__default["default"].highlightElement(block);
|
|
28831
28697
|
});
|
|
28832
28698
|
};
|
|
28833
28699
|
|
|
@@ -28845,21 +28711,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28845
28711
|
title: command.name,
|
|
28846
28712
|
key: "toolbar-btn-".concat(idx),
|
|
28847
28713
|
onClick: function onClick() {
|
|
28848
|
-
var
|
|
28849
|
-
|
|
28850
|
-
if (
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
|
|
28857
|
-
|
|
28858
|
-
return
|
|
28859
|
-
|
|
28714
|
+
var editor = ref.current;
|
|
28715
|
+
var selections = editor.state.selection.ranges;
|
|
28716
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28717
|
+
changes: {
|
|
28718
|
+
from: 0,
|
|
28719
|
+
to: editor.state.doc.length,
|
|
28720
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28721
|
+
}
|
|
28722
|
+
});else {
|
|
28723
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28724
|
+
return {
|
|
28725
|
+
changes: command.inject(range),
|
|
28726
|
+
range: range
|
|
28727
|
+
};
|
|
28728
|
+
}));
|
|
28860
28729
|
}
|
|
28861
|
-
|
|
28862
|
-
editor.focus();
|
|
28863
28730
|
}
|
|
28864
28731
|
}, /*#__PURE__*/React__default["default"].createElement("i", {
|
|
28865
28732
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28870,7 +28737,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28870
28737
|
var classes = useCustomStyle();
|
|
28871
28738
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28872
28739
|
className: classNames__default["default"](props.className)
|
|
28873
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28740
|
+
}, !props.readOnly && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28874
28741
|
style: {
|
|
28875
28742
|
marginBottom: 10
|
|
28876
28743
|
}
|
|
@@ -28896,8 +28763,12 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28896
28763
|
}
|
|
28897
28764
|
}, "Preview"))), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28898
28765
|
className: classNames__default["default"](classes.flex)
|
|
28899
|
-
}, injectButtons())), !preview && /*#__PURE__*/React__default["default"].createElement(CodeInput,
|
|
28900
|
-
|
|
28766
|
+
}, injectButtons())), !preview && /*#__PURE__*/React__default["default"].createElement(CodeInput, _extends({}, props, {
|
|
28767
|
+
setRef: function setRef(e) {
|
|
28768
|
+
return ref.current = e;
|
|
28769
|
+
}
|
|
28770
|
+
})), preview && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
28771
|
+
className: "preview",
|
|
28901
28772
|
dangerouslySetInnerHTML: {
|
|
28902
28773
|
__html: converter.makeHtml(props.value)
|
|
28903
28774
|
}
|
|
@@ -28946,17 +28817,17 @@ function SingleLineCode(_ref) {
|
|
|
28946
28817
|
|
|
28947
28818
|
var _resolvers;
|
|
28948
28819
|
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28949
|
-
return yup__namespace.string().typeError(typeErrorMessage || 'Value must be a string');
|
|
28820
|
+
return yup__namespace.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28950
28821
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28951
|
-
return yup__namespace.number().transform(function (v) {
|
|
28822
|
+
return yup__namespace.number().nullable().optional().transform(function (v) {
|
|
28952
28823
|
return isNaN(v) ? null : v;
|
|
28953
28824
|
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28954
28825
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28955
|
-
return yup__namespace.bool();
|
|
28826
|
+
return yup__namespace.bool().nullable().optional();
|
|
28956
28827
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28957
|
-
return yup__namespace.object();
|
|
28828
|
+
return yup__namespace.object().nullable().optional();
|
|
28958
28829
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28959
|
-
return yup__namespace.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28830
|
+
return yup__namespace.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28960
28831
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28961
28832
|
return yup__namespace.mixed();
|
|
28962
28833
|
}), _resolvers);
|
|
@@ -28983,6 +28854,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28983
28854
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28984
28855
|
}, arrayResolver);
|
|
28985
28856
|
} else if (props.type === type.object && props.schema) {
|
|
28857
|
+
if (!Object.keys(props.schema).length) {
|
|
28858
|
+
return yup__namespace.object();
|
|
28859
|
+
}
|
|
28860
|
+
|
|
28986
28861
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28987
28862
|
|
|
28988
28863
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -29033,11 +28908,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
29033
28908
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
29034
28909
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
29035
28910
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28911
|
+
|
|
28912
|
+
if (!Object.keys(schema).length) {
|
|
28913
|
+
return {
|
|
28914
|
+
shape: yup__namespace.object().shape({}),
|
|
28915
|
+
dependencies: dependencies
|
|
28916
|
+
};
|
|
28917
|
+
}
|
|
28918
|
+
|
|
29036
28919
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
29037
28920
|
if (_typeof$1(key) === 'object') {
|
|
29038
28921
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
29039
28922
|
}
|
|
29040
28923
|
|
|
28924
|
+
if (!schema[key]) {
|
|
28925
|
+
return resolvers;
|
|
28926
|
+
}
|
|
28927
|
+
|
|
29041
28928
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
29042
28929
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
29043
28930
|
}, {});
|
|
@@ -29047,7 +28934,8 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
29047
28934
|
};
|
|
29048
28935
|
};
|
|
29049
28936
|
|
|
29050
|
-
var CustomizableInput$1 = function
|
|
28937
|
+
var CustomizableInput$1 = /*#__PURE__*/React__default["default"].memo(function (props) {
|
|
28938
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
29051
28939
|
if (props.render) {
|
|
29052
28940
|
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
29053
28941
|
error: props.error
|
|
@@ -29055,8 +28943,9 @@ var CustomizableInput$1 = function CustomizableInput(props) {
|
|
|
29055
28943
|
}
|
|
29056
28944
|
|
|
29057
28945
|
return props.children;
|
|
29058
|
-
}
|
|
29059
|
-
|
|
28946
|
+
}, function (prev, next) {
|
|
28947
|
+
return prev.field.value === next.field.value;
|
|
28948
|
+
});
|
|
29060
28949
|
var ControlledInput = function ControlledInput(_ref) {
|
|
29061
28950
|
var defaultValue = _ref.defaultValue,
|
|
29062
28951
|
step = _ref.step,
|
|
@@ -29091,22 +28980,36 @@ var ControlledInput = function ControlledInput(_ref) {
|
|
|
29091
28980
|
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29092
28981
|
placeholder: step.placeholder,
|
|
29093
28982
|
onChange: function onChange(e) {
|
|
29094
|
-
|
|
28983
|
+
var value = function () {
|
|
28984
|
+
if (!e) {
|
|
28985
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28986
|
+
return e;
|
|
28987
|
+
} else {
|
|
28988
|
+
return null;
|
|
28989
|
+
}
|
|
28990
|
+
} else if (e.target) {
|
|
28991
|
+
return e.target.value || null;
|
|
28992
|
+
} else {
|
|
28993
|
+
return e;
|
|
28994
|
+
}
|
|
28995
|
+
}(); // field.onChange(!e ? null : e.target ? e.target.value || null : e)
|
|
28996
|
+
|
|
28997
|
+
|
|
28998
|
+
field.onChange(value);
|
|
29095
28999
|
option(step.onChange).map(function (onChange) {
|
|
29096
29000
|
return onChange({
|
|
29097
29001
|
rawValues: getValues(),
|
|
29098
|
-
value:
|
|
29002
|
+
value: value,
|
|
29099
29003
|
setValue: _setValue
|
|
29100
29004
|
});
|
|
29101
29005
|
});
|
|
29102
29006
|
},
|
|
29103
|
-
value: field.value
|
|
29007
|
+
value: field.value
|
|
29104
29008
|
});
|
|
29105
29009
|
|
|
29106
29010
|
var error = entry.split('.').reduce(function (acc, curr) {
|
|
29107
29011
|
return acc && acc[curr];
|
|
29108
29012
|
}, errors);
|
|
29109
|
-
console.log("render controlled input " + entry);
|
|
29110
29013
|
return /*#__PURE__*/React__default["default"].createElement(CustomizableInput$1, {
|
|
29111
29014
|
render: step.render,
|
|
29112
29015
|
field: _objectSpread2$1({
|
|
@@ -29126,7 +29029,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
29126
29029
|
var ref = React.useRef(); // Store current value in ref
|
|
29127
29030
|
|
|
29128
29031
|
React.useEffect(function () {
|
|
29129
|
-
ref.current = value
|
|
29032
|
+
ref.current = value;
|
|
29130
29033
|
}, [value]); // Only re-run if value changes
|
|
29131
29034
|
// Return previous value (happens before update in useEffect above)
|
|
29132
29035
|
|
|
@@ -29211,7 +29114,7 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29211
29114
|
return props.children;
|
|
29212
29115
|
};
|
|
29213
29116
|
|
|
29214
|
-
var defaultVal = function defaultVal(value,
|
|
29117
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29215
29118
|
if (!!defaultValue) return defaultValue;
|
|
29216
29119
|
if (!!array) return [];
|
|
29217
29120
|
return value;
|
|
@@ -29229,7 +29132,7 @@ var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
|
29229
29132
|
return acc;
|
|
29230
29133
|
}
|
|
29231
29134
|
|
|
29232
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.
|
|
29135
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29233
29136
|
}, {});
|
|
29234
29137
|
};
|
|
29235
29138
|
|
|
@@ -29251,7 +29154,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29251
29154
|
|
|
29252
29155
|
var v;
|
|
29253
29156
|
if (obj) v = obj[key];
|
|
29254
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29157
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29255
29158
|
|
|
29256
29159
|
if (step.array && !step.render) {
|
|
29257
29160
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29264,7 +29167,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29264
29167
|
|
|
29265
29168
|
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
29169
|
} else {
|
|
29267
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29170
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29268
29171
|
}
|
|
29269
29172
|
}, obj);
|
|
29270
29173
|
};
|
|
@@ -29296,7 +29199,7 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29296
29199
|
|
|
29297
29200
|
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
29201
|
} else {
|
|
29299
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v
|
|
29202
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29300
29203
|
}
|
|
29301
29204
|
}, {});
|
|
29302
29205
|
};
|
|
@@ -29316,10 +29219,22 @@ var validate = function validate(flow, schema, value) {
|
|
|
29316
29219
|
var Watcher = function Watcher(_ref7) {
|
|
29317
29220
|
var options = _ref7.options,
|
|
29318
29221
|
control = _ref7.control,
|
|
29319
|
-
schema = _ref7.schema
|
|
29222
|
+
schema = _ref7.schema,
|
|
29223
|
+
onSubmit = _ref7.onSubmit,
|
|
29224
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29225
|
+
_ref7.getValues;
|
|
29226
|
+
_ref7.watch;
|
|
29320
29227
|
var data = reactHookForm.useWatch({
|
|
29321
29228
|
control: control
|
|
29322
29229
|
});
|
|
29230
|
+
var prev = usePrevious(data);
|
|
29231
|
+
React.useEffect(function () {
|
|
29232
|
+
if (!!options.autosubmit) {
|
|
29233
|
+
if (!deepEqual__default["default"](data, prev)) handleSubmit(function () {
|
|
29234
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29235
|
+
})();
|
|
29236
|
+
}
|
|
29237
|
+
}, [data]);
|
|
29323
29238
|
|
|
29324
29239
|
if (options.watch) {
|
|
29325
29240
|
if (typeof options.watch === 'function') {
|
|
@@ -29381,38 +29296,38 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29381
29296
|
resolver: function resolver(data, context, options) {
|
|
29382
29297
|
return yup$1.yupResolver(_resolver(data))(data, context, options);
|
|
29383
29298
|
},
|
|
29384
|
-
defaultValues: cleanInputArray(value, defaultValues, flow, schema),
|
|
29385
29299
|
shouldFocusError: false,
|
|
29386
|
-
mode: '
|
|
29387
|
-
|
|
29300
|
+
mode: 'onChange'
|
|
29388
29301
|
});
|
|
29302
|
+
|
|
29303
|
+
var _useState = React.useState(false),
|
|
29304
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29305
|
+
initialReseted = _useState2[0],
|
|
29306
|
+
setReset = _useState2[1];
|
|
29307
|
+
|
|
29308
|
+
React.useEffect(function () {
|
|
29309
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29310
|
+
|
|
29311
|
+
setReset(true);
|
|
29312
|
+
}, [_reset]);
|
|
29313
|
+
React.useEffect(function () {
|
|
29314
|
+
initialReseted && trigger();
|
|
29315
|
+
}, [trigger, initialReseted]);
|
|
29389
29316
|
var _handleSubmit = methods.handleSubmit,
|
|
29390
29317
|
_methods$formState = methods.formState,
|
|
29391
29318
|
errors = _methods$formState.errors,
|
|
29392
29319
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29393
29320
|
_reset = methods.reset,
|
|
29394
29321
|
trigger = methods.trigger,
|
|
29395
|
-
getValues = methods.getValues
|
|
29322
|
+
getValues = methods.getValues,
|
|
29323
|
+
watch = methods.watch;
|
|
29324
|
+
var prev = usePrevious(value);
|
|
29325
|
+
var prevSchema = usePrevious(schema);
|
|
29396
29326
|
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
|
-
}
|
|
29327
|
+
if (!deepEqual__default["default"](value, prev) || !deepEqual__default["default"](schema, prevSchema)) {
|
|
29328
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29329
|
+
}
|
|
29330
|
+
}, [value, schema]);
|
|
29416
29331
|
|
|
29417
29332
|
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29418
29333
|
if (typeof prop === 'function') {
|
|
@@ -29433,9 +29348,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29433
29348
|
onSubmit(clean);
|
|
29434
29349
|
}, onError)();
|
|
29435
29350
|
},
|
|
29436
|
-
rawData: function rawData() {
|
|
29437
|
-
return cleanOutputArray(data, schema);
|
|
29438
|
-
},
|
|
29439
29351
|
trigger: trigger,
|
|
29440
29352
|
methods: methods
|
|
29441
29353
|
};
|
|
@@ -29443,7 +29355,10 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29443
29355
|
return /*#__PURE__*/React__default["default"].createElement(reactHookForm.FormProvider, methods, /*#__PURE__*/React__default["default"].createElement(Watcher, {
|
|
29444
29356
|
options: options,
|
|
29445
29357
|
control: methods.control,
|
|
29446
|
-
schema: schema
|
|
29358
|
+
schema: schema,
|
|
29359
|
+
onSubmit: onSubmit,
|
|
29360
|
+
handleSubmit: _handleSubmit,
|
|
29361
|
+
watch: methods.watch
|
|
29447
29362
|
}), /*#__PURE__*/React__default["default"].createElement("form", {
|
|
29448
29363
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29449
29364
|
onSubmit: _handleSubmit(function (data) {
|
|
@@ -29466,8 +29381,6 @@ var Form = /*#__PURE__*/React__default["default"].forwardRef(function (_ref8, re
|
|
|
29466
29381
|
}).map(function (visible) {
|
|
29467
29382
|
switch (_typeof$1(visible)) {
|
|
29468
29383
|
case 'object':
|
|
29469
|
-
console.log('watch from visibleStep');
|
|
29470
|
-
|
|
29471
29384
|
var _value = watch(step.visible.ref);
|
|
29472
29385
|
|
|
29473
29386
|
return option(step.visible.test).map(function (test) {
|
|
@@ -29574,8 +29487,6 @@ var Step = function Step(_ref9) {
|
|
|
29574
29487
|
watch = _useFormContext2.watch;
|
|
29575
29488
|
_useFormContext2.register;
|
|
29576
29489
|
|
|
29577
|
-
console.log("re-render : " + entry);
|
|
29578
|
-
|
|
29579
29490
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29580
29491
|
var errored = entry.flow.some(function (step) {
|
|
29581
29492
|
return !!errors[step] && (dirtyFields[step] || touchedFields[step]);
|
|
@@ -29598,7 +29509,6 @@ var Step = function Step(_ref9) {
|
|
|
29598
29509
|
}).map(function (visible) {
|
|
29599
29510
|
switch (_typeof$1(visible)) {
|
|
29600
29511
|
case 'object':
|
|
29601
|
-
console.log("watch of collapse");
|
|
29602
29512
|
var value = watch(visible.ref);
|
|
29603
29513
|
return option(visible.test).map(function (test) {
|
|
29604
29514
|
return test(value, index);
|
|
@@ -29647,14 +29557,13 @@ var Step = function Step(_ref9) {
|
|
|
29647
29557
|
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29648
29558
|
|
|
29649
29559
|
if (onAfterChangeFunc) {
|
|
29650
|
-
var
|
|
29651
|
-
|
|
29560
|
+
var data = watch();
|
|
29652
29561
|
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29653
29562
|
return acc && acc[curr];
|
|
29654
|
-
},
|
|
29563
|
+
}, data) || {};
|
|
29655
29564
|
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29656
29565
|
var newData = cleanOutputArray(d, schema);
|
|
29657
|
-
if (!
|
|
29566
|
+
if (!deepEqual__default["default"](newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29658
29567
|
entry: entry,
|
|
29659
29568
|
previousValue: currentData,
|
|
29660
29569
|
value: getValues(entry),
|
|
@@ -29686,7 +29595,6 @@ var Step = function Step(_ref9) {
|
|
|
29686
29595
|
}, /*#__PURE__*/React__default["default"].createElement(ArrayStep, {
|
|
29687
29596
|
entry: entry,
|
|
29688
29597
|
step: step,
|
|
29689
|
-
defaultValue: step.defaultValue || null,
|
|
29690
29598
|
disabled: functionalProperty(entry, step.disabled),
|
|
29691
29599
|
component: function component(props, idx) {
|
|
29692
29600
|
var _props$defaultValue;
|
|
@@ -29759,6 +29667,7 @@ var Step = function Step(_ref9) {
|
|
|
29759
29667
|
isMulti: step.isMulti,
|
|
29760
29668
|
createOption: step.createOption,
|
|
29761
29669
|
transformer: step.transformer,
|
|
29670
|
+
optionsFrom: step.optionsFrom,
|
|
29762
29671
|
buttons: step.format === format.buttonsSelect
|
|
29763
29672
|
}));
|
|
29764
29673
|
}
|
|
@@ -29790,6 +29699,7 @@ var Step = function Step(_ref9) {
|
|
|
29790
29699
|
createOption: step.createOption,
|
|
29791
29700
|
onCreateOption: step.onCreateOption,
|
|
29792
29701
|
transformer: step.transformer,
|
|
29702
|
+
optionsFrom: step.optionsFrom,
|
|
29793
29703
|
buttons: step.format === format.buttonsSelect
|
|
29794
29704
|
}));
|
|
29795
29705
|
|
|
@@ -29829,6 +29739,7 @@ var Step = function Step(_ref9) {
|
|
|
29829
29739
|
createOption: step.createOption,
|
|
29830
29740
|
onCreateOption: step.onCreateOption,
|
|
29831
29741
|
transformer: step.transformer,
|
|
29742
|
+
optionsFrom: step.optionsFrom,
|
|
29832
29743
|
buttons: step.format === format.buttonsSelect
|
|
29833
29744
|
}));
|
|
29834
29745
|
|
|
@@ -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,
|
|
@@ -30062,7 +29970,7 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
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() {
|
|
30064
29972
|
append({
|
|
30065
|
-
value: step.addableDefaultValue || defaultVal(null
|
|
29973
|
+
value: step.addableDefaultValue || defaultVal(null)
|
|
30066
29974
|
});
|
|
30067
29975
|
trigger(entry);
|
|
30068
29976
|
option(step.onChange).map(function (onChange) {
|
|
@@ -30100,10 +30008,10 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30100
30008
|
_useFormContext4.trigger;
|
|
30101
30009
|
_useFormContext4.formState;
|
|
30102
30010
|
|
|
30103
|
-
var
|
|
30104
|
-
|
|
30105
|
-
collapsed =
|
|
30106
|
-
setCollapsed =
|
|
30011
|
+
var _useState7 = React.useState(!!step.collapsed),
|
|
30012
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
30013
|
+
collapsed = _useState8[0],
|
|
30014
|
+
setCollapsed = _useState8[1];
|
|
30107
30015
|
|
|
30108
30016
|
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
30109
30017
|
// const v = getValues(parent);
|
|
@@ -30135,8 +30043,8 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30135
30043
|
});
|
|
30136
30044
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30137
30045
|
React.useEffect(function () {
|
|
30138
|
-
if (!!prevSchema && !
|
|
30139
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30046
|
+
if (!!prevSchema && !deepEqual__default["default"](prevSchema, schemaAndFlow.schema)) {
|
|
30047
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30140
30048
|
setValue(parent, def, {
|
|
30141
30049
|
shouldValidate: false
|
|
30142
30050
|
});
|