@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/esm/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { v4 } from 'uuid';
|
|
|
10
10
|
import { createUseStyles } from 'react-jss';
|
|
11
11
|
import CreatableSelect from 'react-select/creatable';
|
|
12
12
|
import Select from 'react-select';
|
|
13
|
+
import deepEqual from 'fast-deep-equal';
|
|
13
14
|
import showdown from 'showdown';
|
|
14
15
|
import '@fortawesome/fontawesome-free/css/all.css';
|
|
15
16
|
import 'highlight.js/styles/monokai.css';
|
|
@@ -181,29 +182,6 @@ var _maxSize = function maxSize(ref) {
|
|
|
181
182
|
};
|
|
182
183
|
}; //mixed
|
|
183
184
|
|
|
184
|
-
var _nullable = function nullable() {
|
|
185
|
-
return function (r) {
|
|
186
|
-
return r.nullable().optional().transform(function (v) {
|
|
187
|
-
var _r$describe = r.describe(),
|
|
188
|
-
type = _r$describe.type;
|
|
189
|
-
|
|
190
|
-
switch (type) {
|
|
191
|
-
case 'string':
|
|
192
|
-
case 'number':
|
|
193
|
-
return (v || '').toString().length <= 0 ? null : v;
|
|
194
|
-
|
|
195
|
-
case 'object':
|
|
196
|
-
return Object.keys(v || {}).length === 0 ? null : v;
|
|
197
|
-
|
|
198
|
-
default:
|
|
199
|
-
return v;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return v;
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
185
|
var _test = function test(name) {
|
|
208
186
|
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Test failed';
|
|
209
187
|
var test = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -241,9 +219,9 @@ var _oneOf = function oneOf(arrayOfValues) {
|
|
|
241
219
|
var _blacklist = function blacklist(arrayOfValues) {
|
|
242
220
|
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "This value can't include the following values ".concat(arrayOfValues.join(', '));
|
|
243
221
|
return function (r) {
|
|
244
|
-
return r.test('blacklist'
|
|
222
|
+
return r.test('blacklist', message, function (value) {
|
|
245
223
|
return !arrayOfValues.some(function (f) {
|
|
246
|
-
return value.includes(f);
|
|
224
|
+
return (value || '').includes(f);
|
|
247
225
|
});
|
|
248
226
|
});
|
|
249
227
|
};
|
|
@@ -375,9 +353,6 @@ var jsonConstraints = {
|
|
|
375
353
|
},
|
|
376
354
|
ref: function ref(val) {
|
|
377
355
|
return _ref21(val.ref);
|
|
378
|
-
},
|
|
379
|
-
nullable: function nullable() {
|
|
380
|
-
return _nullable();
|
|
381
356
|
}
|
|
382
357
|
};
|
|
383
358
|
|
|
@@ -399,7 +374,6 @@ var constraints = /*#__PURE__*/Object.freeze({
|
|
|
399
374
|
supportedFormat: _supportedFormat,
|
|
400
375
|
unsupportedFormat: _unsupportedFormat,
|
|
401
376
|
maxSize: _maxSize,
|
|
402
|
-
nullable: _nullable,
|
|
403
377
|
test: _test,
|
|
404
378
|
when: _when,
|
|
405
379
|
oneOf: _oneOf,
|
|
@@ -668,6 +642,9 @@ var style = (_style = {
|
|
|
668
642
|
d_none: {
|
|
669
643
|
display: "none"
|
|
670
644
|
},
|
|
645
|
+
flexWrap: {
|
|
646
|
+
flexWrap: 'wrap'
|
|
647
|
+
},
|
|
671
648
|
flex: {
|
|
672
649
|
display: "flex"
|
|
673
650
|
},
|
|
@@ -765,6 +742,15 @@ var style = (_style = {
|
|
|
765
742
|
border: "1px solid green",
|
|
766
743
|
justifyContent: "flex-end"
|
|
767
744
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
745
|
+
width: "35px",
|
|
746
|
+
height: "22px",
|
|
747
|
+
borderRadius: "20px",
|
|
748
|
+
display: "flex",
|
|
749
|
+
marginTop: "10px",
|
|
750
|
+
backgroundColor: "#dc3545",
|
|
751
|
+
border: "1px solid #dc3545",
|
|
752
|
+
justifyContent: "flex-start"
|
|
753
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
768
754
|
width: "35px",
|
|
769
755
|
height: "22px",
|
|
770
756
|
borderRadius: "20px",
|
|
@@ -780,6 +766,14 @@ var style = (_style = {
|
|
|
780
766
|
width: "20px",
|
|
781
767
|
height: "20px"
|
|
782
768
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
769
|
+
backgroundColor: "#fff",
|
|
770
|
+
borderRadius: "20px",
|
|
771
|
+
cursor: "pointer",
|
|
772
|
+
width: "20px",
|
|
773
|
+
height: "20px",
|
|
774
|
+
border: "1px solid #dfdfdf",
|
|
775
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
776
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
783
777
|
backgroundColor: "#fff",
|
|
784
778
|
borderRadius: "20px",
|
|
785
779
|
cursor: "pointer",
|
|
@@ -798,7 +792,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
798
792
|
return classes;
|
|
799
793
|
};
|
|
800
794
|
|
|
801
|
-
var BooleanInput = function
|
|
795
|
+
var BooleanInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
802
796
|
var _classNames;
|
|
803
797
|
|
|
804
798
|
var onChange = _ref.onChange,
|
|
@@ -821,15 +815,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
821
815
|
}
|
|
822
816
|
}, /*#__PURE__*/React.createElement("div", {
|
|
823
817
|
className: classNames(classes.switch_button_on)
|
|
824
|
-
})), !value && /*#__PURE__*/React.createElement("div", {
|
|
818
|
+
})), !value && value !== null && /*#__PURE__*/React.createElement("div", {
|
|
825
819
|
className: classNames(classes.content_switch_button_off),
|
|
826
820
|
onClick: function onClick() {
|
|
827
821
|
return handleClick(true);
|
|
828
822
|
}
|
|
829
823
|
}, /*#__PURE__*/React.createElement("div", {
|
|
830
824
|
className: classNames(classes.switch_button_off)
|
|
825
|
+
})), value === null && /*#__PURE__*/React.createElement("div", {
|
|
826
|
+
className: classNames(classes.content_switch_button_null),
|
|
827
|
+
onClick: function onClick() {
|
|
828
|
+
return handleClick(true);
|
|
829
|
+
}
|
|
830
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
831
|
+
className: classNames(classes.switch_button_null)
|
|
831
832
|
})));
|
|
832
|
-
};
|
|
833
|
+
});
|
|
833
834
|
|
|
834
835
|
var Collapse = function Collapse(props) {
|
|
835
836
|
var _classNames4;
|
|
@@ -920,38 +921,6 @@ var None = {
|
|
|
920
921
|
}
|
|
921
922
|
};
|
|
922
923
|
|
|
923
|
-
var deepEqual = function deepEqual(obj1, obj2) {
|
|
924
|
-
if (obj1 === obj2) return true;
|
|
925
|
-
|
|
926
|
-
if (_typeof$1(obj1) !== 'object' || _typeof$1(obj2) !== 'object' || obj1 == null || obj2 == null) {
|
|
927
|
-
return false;
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
var keysA = Object.keys(obj1);
|
|
931
|
-
var keysB = Object.keys(obj2);
|
|
932
|
-
|
|
933
|
-
if (keysA.length !== keysB.length) {
|
|
934
|
-
return false;
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
var result = true;
|
|
938
|
-
keysA.forEach(function (key) {
|
|
939
|
-
if (!keysB.includes(key)) {
|
|
940
|
-
result = false;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
if (typeof obj1[key] === 'function' || typeof obj2[key] === 'function') {
|
|
944
|
-
if (obj1[key].toString() !== obj2[key].toString()) {
|
|
945
|
-
result = false;
|
|
946
|
-
}
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
if (!deepEqual(obj1[key], obj2[key])) {
|
|
950
|
-
result = false;
|
|
951
|
-
}
|
|
952
|
-
});
|
|
953
|
-
return result;
|
|
954
|
-
};
|
|
955
924
|
var isPromise = function isPromise(value) {
|
|
956
925
|
return Boolean(value && typeof value.then === 'function');
|
|
957
926
|
};
|
|
@@ -967,7 +936,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
967
936
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
968
937
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
969
938
|
|
|
970
|
-
if (value === null) {
|
|
939
|
+
if (value === null || !value) {
|
|
971
940
|
return null;
|
|
972
941
|
}
|
|
973
942
|
|
|
@@ -995,7 +964,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
995
964
|
});
|
|
996
965
|
};
|
|
997
966
|
|
|
998
|
-
var SelectInput = function
|
|
967
|
+
var SelectInput = /*#__PURE__*/React.forwardRef(function (props, _) {
|
|
999
968
|
var classes = useCustomStyle();
|
|
1000
969
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
1001
970
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1102,7 +1071,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1102
1071
|
display: 'flex'
|
|
1103
1072
|
}
|
|
1104
1073
|
}, values.map(function (v, idx) {
|
|
1105
|
-
var active = props.isMulti ? value.includes(v) : v.value === value.value;
|
|
1074
|
+
var active = !!value && (props.isMulti ? value.includes(v) : v.value === value.value);
|
|
1106
1075
|
return /*#__PURE__*/React.createElement("button", {
|
|
1107
1076
|
key: idx,
|
|
1108
1077
|
type: "button",
|
|
@@ -1150,7 +1119,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1150
1119
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1151
1120
|
}));
|
|
1152
1121
|
}
|
|
1153
|
-
};
|
|
1122
|
+
});
|
|
1154
1123
|
|
|
1155
1124
|
var ObjectInput = function ObjectInput(props) {
|
|
1156
1125
|
var _useState = useState(),
|
|
@@ -23657,7 +23626,7 @@ const Emoji = {
|
|
|
23657
23626
|
}]
|
|
23658
23627
|
};
|
|
23659
23628
|
|
|
23660
|
-
const data
|
|
23629
|
+
const data = /*@__PURE__*/defineLanguageFacet({ block: { open: "<!--", close: "-->" } });
|
|
23661
23630
|
const commonmark = /*@__PURE__*/parser.configure({
|
|
23662
23631
|
props: [
|
|
23663
23632
|
/*@__PURE__*/styleTags({
|
|
@@ -23693,12 +23662,12 @@ const commonmark = /*@__PURE__*/parser.configure({
|
|
|
23693
23662
|
Document: () => null
|
|
23694
23663
|
}),
|
|
23695
23664
|
/*@__PURE__*/languageDataProp.add({
|
|
23696
|
-
Document: data
|
|
23665
|
+
Document: data
|
|
23697
23666
|
})
|
|
23698
23667
|
]
|
|
23699
23668
|
});
|
|
23700
23669
|
function mkLang(parser) {
|
|
23701
|
-
return new Language(data
|
|
23670
|
+
return new Language(data, parser, parser.nodeSet.types.find(t => t.name == "Document"));
|
|
23702
23671
|
}
|
|
23703
23672
|
/**
|
|
23704
23673
|
Language support for strict CommonMark.
|
|
@@ -28537,7 +28506,7 @@ function CodeInput(_ref) {
|
|
|
28537
28506
|
changes: {
|
|
28538
28507
|
from: 0,
|
|
28539
28508
|
to: editor.state.doc.length,
|
|
28540
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28509
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28541
28510
|
}
|
|
28542
28511
|
});
|
|
28543
28512
|
}, [value]);
|
|
@@ -28546,67 +28515,6 @@ function CodeInput(_ref) {
|
|
|
28546
28515
|
});
|
|
28547
28516
|
}
|
|
28548
28517
|
|
|
28549
|
-
window.hljs = window.hljs || hljs;
|
|
28550
|
-
|
|
28551
|
-
var DaikokuExtension = function DaikokuExtension() {
|
|
28552
|
-
// @ref: []()
|
|
28553
|
-
var refextension = {
|
|
28554
|
-
type: 'lang',
|
|
28555
|
-
regex: /@ref:\[(.*)\]\((.*)\)/g,
|
|
28556
|
-
replace: function replace(expression, title, docId) {
|
|
28557
|
-
var path = window.location.pathname;
|
|
28558
|
-
var rawParts = path.split('/');
|
|
28559
|
-
rawParts.shift();
|
|
28560
|
-
var parts = rawParts.splice(0, 5);
|
|
28561
|
-
var teamId = parts[1];
|
|
28562
|
-
var apiId = parts[3];
|
|
28563
|
-
var versionId = parts[4];
|
|
28564
|
-
return "<a href=\"/".concat(teamId, "/").concat(apiId, "/").concat(versionId, "/documentation/").concat(docId, "\">").concat(title, "</a>");
|
|
28565
|
-
}
|
|
28566
|
-
}; // @@@
|
|
28567
|
-
|
|
28568
|
-
var tripleArobase = {
|
|
28569
|
-
type: 'lang',
|
|
28570
|
-
regex: /@@@/g,
|
|
28571
|
-
replace: function replace() {
|
|
28572
|
-
return '</div>';
|
|
28573
|
-
}
|
|
28574
|
-
}; // @@@warning
|
|
28575
|
-
|
|
28576
|
-
var warningExtension = {
|
|
28577
|
-
type: 'lang',
|
|
28578
|
-
regex: /@@@ warning/g,
|
|
28579
|
-
replace: function replace() {
|
|
28580
|
-
return '<div class="note note-warning">';
|
|
28581
|
-
}
|
|
28582
|
-
}; // @@@warning { title = }
|
|
28583
|
-
|
|
28584
|
-
var warningTitleExtension = {
|
|
28585
|
-
type: 'lang',
|
|
28586
|
-
regex: /@@@ warning \{ title='(.*)' \}/g,
|
|
28587
|
-
replace: function replace(expr, title) {
|
|
28588
|
-
return "<div class=\"note note-warning\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28589
|
-
}
|
|
28590
|
-
}; // @@@note
|
|
28591
|
-
|
|
28592
|
-
var noteExtension = {
|
|
28593
|
-
type: 'lang',
|
|
28594
|
-
regex: /@@@ note/g,
|
|
28595
|
-
replace: function replace() {
|
|
28596
|
-
return '<div class="note">';
|
|
28597
|
-
}
|
|
28598
|
-
}; // @@@note { title = }
|
|
28599
|
-
|
|
28600
|
-
var noteTitleExtension = {
|
|
28601
|
-
type: 'lang',
|
|
28602
|
-
regex: /@@@ note \{ title='(.*)' \}/g,
|
|
28603
|
-
replace: function replace(expr, title) {
|
|
28604
|
-
return "<div class=\"note\"><div class=\"note-title\">".concat(title, "</div>");
|
|
28605
|
-
}
|
|
28606
|
-
};
|
|
28607
|
-
return [refextension, warningTitleExtension, noteTitleExtension, warningExtension, noteExtension, tripleArobase];
|
|
28608
|
-
};
|
|
28609
|
-
|
|
28610
28518
|
var converter = new showdown.Converter({
|
|
28611
28519
|
omitExtraWLInCodeBlocks: true,
|
|
28612
28520
|
ghCompatibleHeaderId: true,
|
|
@@ -28617,20 +28525,15 @@ var converter = new showdown.Converter({
|
|
|
28617
28525
|
requireSpaceBeforeHeadingText: true,
|
|
28618
28526
|
ghMentions: true,
|
|
28619
28527
|
emoji: true,
|
|
28620
|
-
ghMentionsLink: '/{u}'
|
|
28621
|
-
extensions: [DaikokuExtension]
|
|
28528
|
+
ghMentionsLink: '/{u}'
|
|
28622
28529
|
});
|
|
28623
28530
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28624
|
-
var _useState = useState(
|
|
28531
|
+
var _useState = useState(props.preview),
|
|
28625
28532
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28626
28533
|
preview = _useState2[0],
|
|
28627
28534
|
setPreview = _useState2[1];
|
|
28628
28535
|
|
|
28629
|
-
var
|
|
28630
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28631
|
-
editor = _useState4[0];
|
|
28632
|
-
_useState4[1];
|
|
28633
|
-
|
|
28536
|
+
var ref = useRef();
|
|
28634
28537
|
useEffect(function () {
|
|
28635
28538
|
if (preview) {
|
|
28636
28539
|
showPreview();
|
|
@@ -28639,162 +28542,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28639
28542
|
var commands = [{
|
|
28640
28543
|
name: 'Add header',
|
|
28641
28544
|
icon: 'heading',
|
|
28642
|
-
inject: function inject() {
|
|
28643
|
-
|
|
28644
|
-
|
|
28545
|
+
inject: function inject(range) {
|
|
28546
|
+
return !range ? '#' : [{
|
|
28547
|
+
from: range.from,
|
|
28548
|
+
insert: "# "
|
|
28549
|
+
}];
|
|
28645
28550
|
}
|
|
28646
28551
|
}, {
|
|
28647
28552
|
name: 'Add bold text',
|
|
28648
28553
|
icon: 'bold',
|
|
28649
|
-
inject: function inject() {
|
|
28650
|
-
|
|
28651
|
-
|
|
28554
|
+
inject: function inject(range) {
|
|
28555
|
+
return !range ? '** **' : [{
|
|
28556
|
+
from: range.from,
|
|
28557
|
+
insert: "**"
|
|
28558
|
+
}, {
|
|
28559
|
+
from: range.to,
|
|
28560
|
+
insert: '**'
|
|
28561
|
+
}];
|
|
28652
28562
|
}
|
|
28653
28563
|
}, {
|
|
28654
28564
|
name: 'Add italic text',
|
|
28655
28565
|
icon: 'italic',
|
|
28656
|
-
inject: function inject() {
|
|
28657
|
-
|
|
28658
|
-
|
|
28566
|
+
inject: function inject(range) {
|
|
28567
|
+
return !range ? '* *' : [{
|
|
28568
|
+
from: range.from,
|
|
28569
|
+
insert: '*'
|
|
28570
|
+
}, {
|
|
28571
|
+
from: range.to,
|
|
28572
|
+
insert: '*'
|
|
28573
|
+
}];
|
|
28659
28574
|
}
|
|
28660
28575
|
}, {
|
|
28661
28576
|
name: 'Add strikethrough text',
|
|
28662
28577
|
icon: 'strikethrough',
|
|
28663
|
-
inject: function inject() {
|
|
28664
|
-
|
|
28665
|
-
|
|
28578
|
+
inject: function inject(range) {
|
|
28579
|
+
return !range ? '~~ ~~' : [{
|
|
28580
|
+
from: range.from,
|
|
28581
|
+
insert: '~~'
|
|
28582
|
+
}, {
|
|
28583
|
+
from: range.to,
|
|
28584
|
+
insert: '~~'
|
|
28585
|
+
}];
|
|
28666
28586
|
}
|
|
28667
28587
|
}, {
|
|
28668
28588
|
name: 'Add link',
|
|
28669
28589
|
icon: 'link',
|
|
28670
|
-
inject: function inject() {
|
|
28671
|
-
|
|
28672
|
-
|
|
28590
|
+
inject: function inject(range) {
|
|
28591
|
+
return !range ? '[ ](url)' : [{
|
|
28592
|
+
from: range.from,
|
|
28593
|
+
insert: '['
|
|
28594
|
+
}, {
|
|
28595
|
+
from: range.to,
|
|
28596
|
+
insert: '](url)'
|
|
28597
|
+
}];
|
|
28673
28598
|
}
|
|
28674
28599
|
}, {
|
|
28675
28600
|
name: 'Add code',
|
|
28676
28601
|
icon: 'code',
|
|
28677
|
-
inject: function inject() {
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28682
|
-
|
|
28683
|
-
|
|
28684
|
-
|
|
28685
|
-
});
|
|
28602
|
+
inject: function inject(range) {
|
|
28603
|
+
return !range ? '```\n\n```\n' : [{
|
|
28604
|
+
from: range.from,
|
|
28605
|
+
insert: '```\n'
|
|
28606
|
+
}, {
|
|
28607
|
+
from: range.to,
|
|
28608
|
+
insert: '\n```\n'
|
|
28609
|
+
}];
|
|
28686
28610
|
}
|
|
28687
28611
|
}, {
|
|
28688
28612
|
name: 'Add quotes',
|
|
28689
28613
|
icon: 'quote-right',
|
|
28690
|
-
inject: function inject() {
|
|
28691
|
-
|
|
28692
|
-
|
|
28614
|
+
inject: function inject(range) {
|
|
28615
|
+
return !range ? '> ' : [{
|
|
28616
|
+
from: range.from,
|
|
28617
|
+
insert: '> '
|
|
28618
|
+
}];
|
|
28693
28619
|
}
|
|
28694
28620
|
}, {
|
|
28695
28621
|
name: 'Add image',
|
|
28696
28622
|
icon: 'image',
|
|
28697
|
-
inject: function inject() {
|
|
28698
|
-
|
|
28699
|
-
|
|
28623
|
+
inject: function inject(range) {
|
|
28624
|
+
return !range ? '' : [{
|
|
28625
|
+
from: range.from,
|
|
28626
|
+
insert: ''
|
|
28630
|
+
}];
|
|
28700
28631
|
}
|
|
28701
28632
|
}, {
|
|
28702
28633
|
name: 'Add unordered list',
|
|
28703
28634
|
icon: 'list-ul',
|
|
28704
|
-
inject: function inject() {
|
|
28705
|
-
|
|
28706
|
-
|
|
28635
|
+
inject: function inject(range) {
|
|
28636
|
+
return !range ? '* ' : [{
|
|
28637
|
+
from: range.from,
|
|
28638
|
+
insert: '* '
|
|
28639
|
+
}];
|
|
28707
28640
|
}
|
|
28708
28641
|
}, {
|
|
28709
28642
|
name: 'Add ordered list',
|
|
28710
28643
|
icon: 'list-ol',
|
|
28711
|
-
inject: function inject() {
|
|
28712
|
-
|
|
28713
|
-
|
|
28644
|
+
inject: function inject(range) {
|
|
28645
|
+
return !range ? '1. ' : [{
|
|
28646
|
+
from: range.from,
|
|
28647
|
+
insert: '1. '
|
|
28648
|
+
}];
|
|
28714
28649
|
}
|
|
28715
28650
|
}, {
|
|
28716
28651
|
name: 'Add check list',
|
|
28717
28652
|
icon: 'tasks',
|
|
28718
|
-
inject: function inject() {
|
|
28719
|
-
|
|
28720
|
-
|
|
28721
|
-
|
|
28722
|
-
|
|
28723
|
-
name: 'Page ref',
|
|
28724
|
-
icon: 'book',
|
|
28725
|
-
inject: function inject() {
|
|
28726
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28727
|
-
return "@ref:[".concat(selected, "](team/api/doc)");
|
|
28728
|
-
}
|
|
28729
|
-
}, {
|
|
28730
|
-
name: 'Warning',
|
|
28731
|
-
icon: 'exclamation-triangle',
|
|
28732
|
-
inject: function inject() {
|
|
28733
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28734
|
-
return "@@@ warning\n".concat(selected, "\n@@@\n");
|
|
28735
|
-
},
|
|
28736
|
-
move: function move(pos, setPos) {
|
|
28737
|
-
return setPos({
|
|
28738
|
-
column: 0,
|
|
28739
|
-
row: pos.row - 2
|
|
28740
|
-
});
|
|
28741
|
-
}
|
|
28742
|
-
}, {
|
|
28743
|
-
name: 'Warning with title',
|
|
28744
|
-
icon: 'exclamation-circle',
|
|
28745
|
-
inject: function inject() {
|
|
28746
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28747
|
-
return "@@@ warning { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28748
|
-
},
|
|
28749
|
-
move: function move(pos, setPos) {
|
|
28750
|
-
return setPos({
|
|
28751
|
-
column: 0,
|
|
28752
|
-
row: pos.row - 2
|
|
28753
|
-
});
|
|
28754
|
-
}
|
|
28755
|
-
}, {
|
|
28756
|
-
name: 'Note',
|
|
28757
|
-
icon: 'sticky-note',
|
|
28758
|
-
inject: function inject() {
|
|
28759
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28760
|
-
return "@@@ note\n".concat(selected, "\n@@@\n");
|
|
28761
|
-
},
|
|
28762
|
-
move: function move(pos, setPos) {
|
|
28763
|
-
return setPos({
|
|
28764
|
-
column: 0,
|
|
28765
|
-
row: pos.row - 2
|
|
28766
|
-
});
|
|
28767
|
-
}
|
|
28768
|
-
}, {
|
|
28769
|
-
name: 'Note with title',
|
|
28770
|
-
icon: 'clipboard',
|
|
28771
|
-
inject: function inject() {
|
|
28772
|
-
var selected = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ' ';
|
|
28773
|
-
return "@@@ note { title='A nice title' }\n".concat(selected, "\n@@@\n");
|
|
28774
|
-
},
|
|
28775
|
-
move: function move(pos, setPos) {
|
|
28776
|
-
return setPos({
|
|
28777
|
-
column: 0,
|
|
28778
|
-
row: pos.row - 2
|
|
28779
|
-
});
|
|
28780
|
-
}
|
|
28781
|
-
}, {
|
|
28782
|
-
name: 'Lorem Ipsum',
|
|
28783
|
-
icon: 'feather-alt',
|
|
28784
|
-
inject: function inject() {
|
|
28785
|
-
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.';
|
|
28786
|
-
}
|
|
28787
|
-
}, {
|
|
28788
|
-
name: 'Long Lorem Ipsum',
|
|
28789
|
-
icon: 'feather',
|
|
28790
|
-
inject: function inject() {
|
|
28791
|
-
return "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus gravida convallis leo et aliquet. Aenean venenatis, elit et dignissim scelerisque, urna dui mollis nunc, id eleifend velit sem et ante. Quisque pharetra sed tellus id finibus. In quis porta libero. Nunc egestas eros elementum lacinia blandit. Donec nisi lacus, tristique vel blandit in, sodales eget lacus. Phasellus ultrices magna vel odio vestibulum, a rhoncus nunc ornare. Sed laoreet finibus arcu vitae aliquam. Aliquam quis ex dui.\n\nCras ut ultrices quam. Nulla eu purus sed turpis consequat sodales. Aenean vitae efficitur velit, vel accumsan felis. Curabitur aliquam odio dictum urna convallis faucibus. Vivamus eu dignissim lorem. Donec sed hendrerit massa. Suspendisse volutpat, nisi at fringilla consequat, eros lacus aliquam metus, eu convallis nulla mauris quis lacus. Aliquam ultricies, mi eget feugiat vestibulum, enim nunc eleifend nisi, nec tincidunt turpis elit id diam. Nunc placerat accumsan tincidunt. Nulla ut interdum dui. Praesent venenatis cursus aliquet. Nunc pretium rutrum felis nec pharetra.\n\nVivamus sapien ligula, hendrerit a libero vitae, convallis maximus massa. Praesent ante leo, fermentum vitae libero finibus, blandit porttitor risus. Nulla ac hendrerit turpis. Sed varius velit at libero feugiat luctus. Nunc rhoncus sem dolor, nec euismod justo rhoncus vitae. Vivamus finibus nulla a purus vestibulum sagittis. Maecenas maximus orci at est lobortis, nec facilisis erat rhoncus. Sed tempus leo et est dictum lobortis. Vestibulum rhoncus, nisl ut porta sollicitudin, arcu urna egestas arcu, eget efficitur neque ipsum ut felis. Ut commodo purus quis turpis tempus tincidunt. Donec id hendrerit eros. Vestibulum vitae justo consectetur, egestas nisi ac, eleifend odio.\n\nDonec id mi cursus, volutpat dolor sed, bibendum sapien. Etiam vitae mauris sit amet urna semper tempus vel non metus. Integer sed ligula diam. Aenean molestie ultrices libero eget suscipit. Phasellus maximus euismod eros ut scelerisque. Ut quis tempus metus. Sed mollis volutpat velit eget pellentesque. Integer hendrerit ultricies massa eu tincidunt. Quisque at cursus augue. Sed diam odio, molestie sed dictum eget, efficitur nec nulla. Nullam vulputate posuere nunc nec laoreet. Integer varius sed erat vitae cursus. Vivamus auctor augue enim, a fringilla mauris molestie eget.\n\nProin vehicula ligula vel enim euismod, sed congue mi egestas. Nullam varius ut felis eu fringilla. Quisque sodales tortor nec justo tristique, sit amet consequat mi tincidunt. Suspendisse porttitor laoreet velit, non gravida nibh cursus at. Pellentesque faucibus, tellus in dapibus viverra, dolor mi dignissim tortor, id convallis ipsum lorem id nisl. Sed id nisi felis. Aliquam in ullamcorper ipsum, vel consequat magna. Donec nec mollis lacus, a euismod elit.";
|
|
28653
|
+
inject: function inject(range) {
|
|
28654
|
+
return !range ? '* [ ] ' : [{
|
|
28655
|
+
from: range.from,
|
|
28656
|
+
insert: '* [ ] '
|
|
28657
|
+
}];
|
|
28792
28658
|
}
|
|
28793
28659
|
}];
|
|
28794
28660
|
|
|
28795
28661
|
var showPreview = function showPreview() {
|
|
28796
|
-
|
|
28797
|
-
|
|
28662
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28663
|
+
|
|
28664
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28665
|
+
return hljs.highlightElement(block);
|
|
28798
28666
|
});
|
|
28799
28667
|
};
|
|
28800
28668
|
|
|
@@ -28812,21 +28680,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28812
28680
|
title: command.name,
|
|
28813
28681
|
key: "toolbar-btn-".concat(idx),
|
|
28814
28682
|
onClick: function onClick() {
|
|
28815
|
-
var
|
|
28816
|
-
|
|
28817
|
-
if (
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
return
|
|
28826
|
-
|
|
28683
|
+
var editor = ref.current;
|
|
28684
|
+
var selections = editor.state.selection.ranges;
|
|
28685
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28686
|
+
changes: {
|
|
28687
|
+
from: 0,
|
|
28688
|
+
to: editor.state.doc.length,
|
|
28689
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28690
|
+
}
|
|
28691
|
+
});else {
|
|
28692
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28693
|
+
return {
|
|
28694
|
+
changes: command.inject(range),
|
|
28695
|
+
range: range
|
|
28696
|
+
};
|
|
28697
|
+
}));
|
|
28827
28698
|
}
|
|
28828
|
-
|
|
28829
|
-
editor.focus();
|
|
28830
28699
|
}
|
|
28831
28700
|
}, /*#__PURE__*/React.createElement("i", {
|
|
28832
28701
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28837,7 +28706,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28837
28706
|
var classes = useCustomStyle();
|
|
28838
28707
|
return /*#__PURE__*/React.createElement("div", {
|
|
28839
28708
|
className: classNames(props.className)
|
|
28840
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
28709
|
+
}, !props.readOnly && /*#__PURE__*/React.createElement("div", {
|
|
28841
28710
|
style: {
|
|
28842
28711
|
marginBottom: 10
|
|
28843
28712
|
}
|
|
@@ -28862,9 +28731,13 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28862
28731
|
return setPreview(true);
|
|
28863
28732
|
}
|
|
28864
28733
|
}, "Preview"))), /*#__PURE__*/React.createElement("div", {
|
|
28865
|
-
className: classNames(classes.flex)
|
|
28866
|
-
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput,
|
|
28867
|
-
|
|
28734
|
+
className: classNames(classes.flex, classes.flexWrap)
|
|
28735
|
+
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput, _extends({}, props, {
|
|
28736
|
+
setRef: function setRef(e) {
|
|
28737
|
+
return ref.current = e;
|
|
28738
|
+
}
|
|
28739
|
+
})), preview && /*#__PURE__*/React.createElement("div", {
|
|
28740
|
+
className: "preview",
|
|
28868
28741
|
dangerouslySetInnerHTML: {
|
|
28869
28742
|
__html: converter.makeHtml(props.value)
|
|
28870
28743
|
}
|
|
@@ -28913,17 +28786,17 @@ function SingleLineCode(_ref) {
|
|
|
28913
28786
|
|
|
28914
28787
|
var _resolvers;
|
|
28915
28788
|
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28916
|
-
return yup.string().typeError(typeErrorMessage || 'Value must be a string');
|
|
28789
|
+
return yup.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28917
28790
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28918
|
-
return yup.number().transform(function (v) {
|
|
28791
|
+
return yup.number().nullable().optional().transform(function (v) {
|
|
28919
28792
|
return isNaN(v) ? null : v;
|
|
28920
28793
|
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28921
28794
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28922
|
-
return yup.bool();
|
|
28795
|
+
return yup.bool().nullable().optional();
|
|
28923
28796
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28924
|
-
return yup.object();
|
|
28797
|
+
return yup.object().nullable().optional();
|
|
28925
28798
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28926
|
-
return yup.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28799
|
+
return yup.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28927
28800
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28928
28801
|
return yup.mixed();
|
|
28929
28802
|
}), _resolvers);
|
|
@@ -28950,6 +28823,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28950
28823
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28951
28824
|
}, arrayResolver);
|
|
28952
28825
|
} else if (props.type === type.object && props.schema) {
|
|
28826
|
+
if (!Object.keys(props.schema).length) {
|
|
28827
|
+
return yup.object();
|
|
28828
|
+
}
|
|
28829
|
+
|
|
28953
28830
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28954
28831
|
|
|
28955
28832
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -29000,11 +28877,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
29000
28877
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
29001
28878
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
29002
28879
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28880
|
+
|
|
28881
|
+
if (!Object.keys(schema).length) {
|
|
28882
|
+
return {
|
|
28883
|
+
shape: yup.object().shape({}),
|
|
28884
|
+
dependencies: dependencies
|
|
28885
|
+
};
|
|
28886
|
+
}
|
|
28887
|
+
|
|
29003
28888
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
29004
28889
|
if (_typeof$1(key) === 'object') {
|
|
29005
28890
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
29006
28891
|
}
|
|
29007
28892
|
|
|
28893
|
+
if (!schema[key]) {
|
|
28894
|
+
return resolvers;
|
|
28895
|
+
}
|
|
28896
|
+
|
|
29008
28897
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
29009
28898
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
29010
28899
|
}, {});
|
|
@@ -29014,7 +28903,8 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
29014
28903
|
};
|
|
29015
28904
|
};
|
|
29016
28905
|
|
|
29017
|
-
var CustomizableInput$1 = function
|
|
28906
|
+
var CustomizableInput$1 = /*#__PURE__*/React.memo(function (props) {
|
|
28907
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
29018
28908
|
if (props.render) {
|
|
29019
28909
|
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
29020
28910
|
error: props.error
|
|
@@ -29022,8 +28912,9 @@ var CustomizableInput$1 = function CustomizableInput(props) {
|
|
|
29022
28912
|
}
|
|
29023
28913
|
|
|
29024
28914
|
return props.children;
|
|
29025
|
-
}
|
|
29026
|
-
|
|
28915
|
+
}, function (prev, next) {
|
|
28916
|
+
return prev.field.value === next.field.value;
|
|
28917
|
+
});
|
|
29027
28918
|
var ControlledInput = function ControlledInput(_ref) {
|
|
29028
28919
|
var defaultValue = _ref.defaultValue,
|
|
29029
28920
|
step = _ref.step,
|
|
@@ -29058,22 +28949,36 @@ var ControlledInput = function ControlledInput(_ref) {
|
|
|
29058
28949
|
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29059
28950
|
placeholder: step.placeholder,
|
|
29060
28951
|
onChange: function onChange(e) {
|
|
29061
|
-
|
|
28952
|
+
var value = function () {
|
|
28953
|
+
if (!e) {
|
|
28954
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28955
|
+
return e;
|
|
28956
|
+
} else {
|
|
28957
|
+
return null;
|
|
28958
|
+
}
|
|
28959
|
+
} else if (e.target) {
|
|
28960
|
+
return e.target.value || null;
|
|
28961
|
+
} else {
|
|
28962
|
+
return e;
|
|
28963
|
+
}
|
|
28964
|
+
}();
|
|
28965
|
+
|
|
28966
|
+
console.log(entry, value, getValues());
|
|
28967
|
+
field.onChange(value);
|
|
29062
28968
|
option(step.onChange).map(function (onChange) {
|
|
29063
28969
|
return onChange({
|
|
29064
28970
|
rawValues: getValues(),
|
|
29065
|
-
value:
|
|
28971
|
+
value: value,
|
|
29066
28972
|
setValue: _setValue
|
|
29067
28973
|
});
|
|
29068
28974
|
});
|
|
29069
28975
|
},
|
|
29070
|
-
value: field.value
|
|
28976
|
+
value: field.value
|
|
29071
28977
|
});
|
|
29072
28978
|
|
|
29073
28979
|
var error = entry.split('.').reduce(function (acc, curr) {
|
|
29074
28980
|
return acc && acc[curr];
|
|
29075
28981
|
}, errors);
|
|
29076
|
-
console.log("render controlled input " + entry);
|
|
29077
28982
|
return /*#__PURE__*/React.createElement(CustomizableInput$1, {
|
|
29078
28983
|
render: step.render,
|
|
29079
28984
|
field: _objectSpread2$1({
|
|
@@ -29093,7 +28998,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
29093
28998
|
var ref = useRef(); // Store current value in ref
|
|
29094
28999
|
|
|
29095
29000
|
useEffect(function () {
|
|
29096
|
-
ref.current = value
|
|
29001
|
+
ref.current = value;
|
|
29097
29002
|
}, [value]); // Only re-run if value changes
|
|
29098
29003
|
// Return previous value (happens before update in useEffect above)
|
|
29099
29004
|
|
|
@@ -29178,14 +29083,14 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29178
29083
|
return props.children;
|
|
29179
29084
|
};
|
|
29180
29085
|
|
|
29181
|
-
var defaultVal = function defaultVal(value,
|
|
29086
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29182
29087
|
if (!!defaultValue) return defaultValue;
|
|
29183
29088
|
if (!!array) return [];
|
|
29184
29089
|
return value;
|
|
29185
29090
|
};
|
|
29186
29091
|
|
|
29187
29092
|
var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
29188
|
-
return flow.reduce(function (acc, key) {
|
|
29093
|
+
return (flow || []).reduce(function (acc, key) {
|
|
29189
29094
|
if (_typeof$1(key) === 'object') {
|
|
29190
29095
|
return _objectSpread2$1(_objectSpread2$1({}, acc), getDefaultValues(key.flow, schema, value));
|
|
29191
29096
|
}
|
|
@@ -29196,7 +29101,7 @@ var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
|
29196
29101
|
return acc;
|
|
29197
29102
|
}
|
|
29198
29103
|
|
|
29199
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.
|
|
29104
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29200
29105
|
}, {});
|
|
29201
29106
|
};
|
|
29202
29107
|
|
|
@@ -29218,7 +29123,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29218
29123
|
|
|
29219
29124
|
var v;
|
|
29220
29125
|
if (obj) v = obj[key];
|
|
29221
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29126
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29222
29127
|
|
|
29223
29128
|
if (step.array && !step.render) {
|
|
29224
29129
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29231,7 +29136,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29231
29136
|
|
|
29232
29137
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanInputArray(v, defaultValues, (_subSchema$key = subSchema[key]) === null || _subSchema$key === void 0 ? void 0 : _subSchema$key.flow, ((_subSchema$key2 = subSchema[key]) === null || _subSchema$key2 === void 0 ? void 0 : _subSchema$key2.schema) || {})));
|
|
29233
29138
|
} else {
|
|
29234
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29139
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29235
29140
|
}
|
|
29236
29141
|
}, obj);
|
|
29237
29142
|
};
|
|
@@ -29263,7 +29168,7 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29263
29168
|
|
|
29264
29169
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanOutputArray(v, ((_subSchema$key3 = subSchema[key]) === null || _subSchema$key3 === void 0 ? void 0 : _subSchema$key3.schema) || {})));
|
|
29265
29170
|
} else {
|
|
29266
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v
|
|
29171
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29267
29172
|
}
|
|
29268
29173
|
}, {});
|
|
29269
29174
|
};
|
|
@@ -29283,10 +29188,22 @@ var validate = function validate(flow, schema, value) {
|
|
|
29283
29188
|
var Watcher = function Watcher(_ref7) {
|
|
29284
29189
|
var options = _ref7.options,
|
|
29285
29190
|
control = _ref7.control,
|
|
29286
|
-
schema = _ref7.schema
|
|
29191
|
+
schema = _ref7.schema,
|
|
29192
|
+
onSubmit = _ref7.onSubmit,
|
|
29193
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29194
|
+
_ref7.getValues;
|
|
29195
|
+
_ref7.watch;
|
|
29287
29196
|
var data = useWatch({
|
|
29288
29197
|
control: control
|
|
29289
29198
|
});
|
|
29199
|
+
var prev = usePrevious(data);
|
|
29200
|
+
useEffect(function () {
|
|
29201
|
+
if (!!options.autosubmit) {
|
|
29202
|
+
if (!deepEqual(data, prev)) handleSubmit(function () {
|
|
29203
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29204
|
+
})();
|
|
29205
|
+
}
|
|
29206
|
+
}, [data]);
|
|
29290
29207
|
|
|
29291
29208
|
if (options.watch) {
|
|
29292
29209
|
if (typeof options.watch === 'function') {
|
|
@@ -29348,38 +29265,38 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29348
29265
|
resolver: function resolver(data, context, options) {
|
|
29349
29266
|
return yupResolver(_resolver(data))(data, context, options);
|
|
29350
29267
|
},
|
|
29351
|
-
defaultValues: cleanInputArray(value, defaultValues, flow, schema),
|
|
29352
29268
|
shouldFocusError: false,
|
|
29353
|
-
mode: '
|
|
29354
|
-
|
|
29269
|
+
mode: 'onChange'
|
|
29355
29270
|
});
|
|
29271
|
+
|
|
29272
|
+
var _useState = useState(false),
|
|
29273
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29274
|
+
initialReseted = _useState2[0],
|
|
29275
|
+
setReset = _useState2[1];
|
|
29276
|
+
|
|
29277
|
+
useEffect(function () {
|
|
29278
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29279
|
+
|
|
29280
|
+
setReset(true);
|
|
29281
|
+
}, [_reset]);
|
|
29282
|
+
useEffect(function () {
|
|
29283
|
+
initialReseted && trigger();
|
|
29284
|
+
}, [trigger, initialReseted]);
|
|
29356
29285
|
var _handleSubmit = methods.handleSubmit,
|
|
29357
29286
|
_methods$formState = methods.formState,
|
|
29358
29287
|
errors = _methods$formState.errors,
|
|
29359
29288
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29360
29289
|
_reset = methods.reset,
|
|
29361
29290
|
trigger = methods.trigger,
|
|
29362
|
-
getValues = methods.getValues
|
|
29291
|
+
getValues = methods.getValues,
|
|
29292
|
+
watch = methods.watch;
|
|
29293
|
+
var prev = usePrevious(value);
|
|
29294
|
+
var prevSchema = usePrevious(schema);
|
|
29363
29295
|
useEffect(function () {
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
|
|
29367
|
-
|
|
29368
|
-
console.log('re-render cauz value/reset changed');
|
|
29369
|
-
|
|
29370
|
-
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29371
|
-
}, [value, _reset]);
|
|
29372
|
-
useEffect(function () {
|
|
29373
|
-
console.log('re-render cauz schema changed');
|
|
29374
|
-
|
|
29375
|
-
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29376
|
-
}, [schema]);
|
|
29377
|
-
|
|
29378
|
-
if (!!options.autosubmit) {
|
|
29379
|
-
_handleSubmit(function (data) {
|
|
29380
|
-
return onSubmit(cleanOutputArray(data, schema));
|
|
29381
|
-
}, onError)();
|
|
29382
|
-
}
|
|
29296
|
+
if (!deepEqual(value, prev) || !deepEqual(schema, prevSchema)) {
|
|
29297
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29298
|
+
}
|
|
29299
|
+
}, [value, schema]);
|
|
29383
29300
|
|
|
29384
29301
|
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29385
29302
|
if (typeof prop === 'function') {
|
|
@@ -29400,9 +29317,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29400
29317
|
onSubmit(clean);
|
|
29401
29318
|
}, onError)();
|
|
29402
29319
|
},
|
|
29403
|
-
rawData: function rawData() {
|
|
29404
|
-
return cleanOutputArray(data, schema);
|
|
29405
|
-
},
|
|
29406
29320
|
trigger: trigger,
|
|
29407
29321
|
methods: methods
|
|
29408
29322
|
};
|
|
@@ -29410,7 +29324,10 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29410
29324
|
return /*#__PURE__*/React.createElement(FormProvider, methods, /*#__PURE__*/React.createElement(Watcher, {
|
|
29411
29325
|
options: options,
|
|
29412
29326
|
control: methods.control,
|
|
29413
|
-
schema: schema
|
|
29327
|
+
schema: schema,
|
|
29328
|
+
onSubmit: onSubmit,
|
|
29329
|
+
handleSubmit: _handleSubmit,
|
|
29330
|
+
watch: methods.watch
|
|
29414
29331
|
}), /*#__PURE__*/React.createElement("form", {
|
|
29415
29332
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29416
29333
|
onSubmit: _handleSubmit(function (data) {
|
|
@@ -29433,8 +29350,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29433
29350
|
}).map(function (visible) {
|
|
29434
29351
|
switch (_typeof$1(visible)) {
|
|
29435
29352
|
case 'object':
|
|
29436
|
-
console.log('watch from visibleStep');
|
|
29437
|
-
|
|
29438
29353
|
var _value = watch(step.visible.ref);
|
|
29439
29354
|
|
|
29440
29355
|
return option(step.visible.test).map(function (test) {
|
|
@@ -29541,8 +29456,6 @@ var Step = function Step(_ref9) {
|
|
|
29541
29456
|
watch = _useFormContext2.watch;
|
|
29542
29457
|
_useFormContext2.register;
|
|
29543
29458
|
|
|
29544
|
-
console.log("re-render : " + entry);
|
|
29545
|
-
|
|
29546
29459
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29547
29460
|
var errored = entry.flow.some(function (step) {
|
|
29548
29461
|
return !!errors[step] && (dirtyFields[step] || touchedFields[step]);
|
|
@@ -29565,7 +29478,6 @@ var Step = function Step(_ref9) {
|
|
|
29565
29478
|
}).map(function (visible) {
|
|
29566
29479
|
switch (_typeof$1(visible)) {
|
|
29567
29480
|
case 'object':
|
|
29568
|
-
console.log("watch of collapse");
|
|
29569
29481
|
var value = watch(visible.ref);
|
|
29570
29482
|
return option(visible.test).map(function (test) {
|
|
29571
29483
|
return test(value, index);
|
|
@@ -29614,14 +29526,13 @@ var Step = function Step(_ref9) {
|
|
|
29614
29526
|
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29615
29527
|
|
|
29616
29528
|
if (onAfterChangeFunc) {
|
|
29617
|
-
var
|
|
29618
|
-
|
|
29529
|
+
var data = watch();
|
|
29619
29530
|
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29620
29531
|
return acc && acc[curr];
|
|
29621
|
-
},
|
|
29532
|
+
}, data) || {};
|
|
29622
29533
|
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29623
29534
|
var newData = cleanOutputArray(d, schema);
|
|
29624
|
-
if (!deepEqual(newData, currentData)) onAfterChangeFunc({
|
|
29535
|
+
if (!deepEqual(newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29625
29536
|
entry: entry,
|
|
29626
29537
|
previousValue: currentData,
|
|
29627
29538
|
value: getValues(entry),
|
|
@@ -29653,7 +29564,6 @@ var Step = function Step(_ref9) {
|
|
|
29653
29564
|
}, /*#__PURE__*/React.createElement(ArrayStep, {
|
|
29654
29565
|
entry: entry,
|
|
29655
29566
|
step: step,
|
|
29656
|
-
defaultValue: step.defaultValue || null,
|
|
29657
29567
|
disabled: functionalProperty(entry, step.disabled),
|
|
29658
29568
|
component: function component(props, idx) {
|
|
29659
29569
|
var _props$defaultValue;
|
|
@@ -29894,15 +29804,15 @@ var Step = function Step(_ref9) {
|
|
|
29894
29804
|
var FileInput = function FileInput(_ref11) {
|
|
29895
29805
|
var onChange = _ref11.onChange;
|
|
29896
29806
|
|
|
29897
|
-
var
|
|
29898
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
29899
|
-
uploading = _useState2[0],
|
|
29900
|
-
setUploading = _useState2[1];
|
|
29901
|
-
|
|
29902
|
-
var _useState3 = useState(undefined),
|
|
29807
|
+
var _useState3 = useState(false),
|
|
29903
29808
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29904
|
-
|
|
29905
|
-
|
|
29809
|
+
uploading = _useState4[0],
|
|
29810
|
+
setUploading = _useState4[1];
|
|
29811
|
+
|
|
29812
|
+
var _useState5 = useState(undefined),
|
|
29813
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
29814
|
+
input = _useState6[0],
|
|
29815
|
+
setInput = _useState6[1];
|
|
29906
29816
|
|
|
29907
29817
|
var setFiles = function setFiles(e) {
|
|
29908
29818
|
var files = e.target.files;
|
|
@@ -29981,10 +29891,7 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
29981
29891
|
|
|
29982
29892
|
var _useFieldArray = useFieldArray({
|
|
29983
29893
|
control: control,
|
|
29984
|
-
|
|
29985
|
-
name: entry // unique name for your Field Array
|
|
29986
|
-
// keyName: "id", default to "id", you can change the key name
|
|
29987
|
-
|
|
29894
|
+
name: entry
|
|
29988
29895
|
}),
|
|
29989
29896
|
fields = _useFieldArray.fields,
|
|
29990
29897
|
append = _useFieldArray.append,
|
|
@@ -30028,10 +29935,11 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
30028
29935
|
type: "button",
|
|
30029
29936
|
className: classNames(classes.btn, classes.btn_blue, classes.btn_sm, classes.mt_5, _defineProperty$1({}, classes.input__invalid, errorDisplayed)),
|
|
30030
29937
|
onClick: function onClick() {
|
|
29938
|
+
var newValue = cleanInputArray({}, getValues(entry), step.flow, step.schema);
|
|
30031
29939
|
append({
|
|
30032
|
-
value: step.addableDefaultValue || defaultVal(
|
|
30033
|
-
});
|
|
30034
|
-
|
|
29940
|
+
value: step.addableDefaultValue || (newValue ? newValue : defaultVal())
|
|
29941
|
+
}); // trigger(entry);
|
|
29942
|
+
|
|
30035
29943
|
option(step.onChange).map(function (onChange) {
|
|
30036
29944
|
return onChange({
|
|
30037
29945
|
rawValues: getValues(),
|
|
@@ -30067,10 +29975,10 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30067
29975
|
_useFormContext4.trigger;
|
|
30068
29976
|
_useFormContext4.formState;
|
|
30069
29977
|
|
|
30070
|
-
var
|
|
30071
|
-
|
|
30072
|
-
collapsed =
|
|
30073
|
-
setCollapsed =
|
|
29978
|
+
var _useState7 = useState(!!step.collapsed),
|
|
29979
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
29980
|
+
collapsed = _useState8[0],
|
|
29981
|
+
setCollapsed = _useState8[1];
|
|
30074
29982
|
|
|
30075
29983
|
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
30076
29984
|
// const v = getValues(parent);
|
|
@@ -30103,7 +30011,7 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30103
30011
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30104
30012
|
useEffect(function () {
|
|
30105
30013
|
if (!!prevSchema && !deepEqual(prevSchema, schemaAndFlow.schema)) {
|
|
30106
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30014
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30107
30015
|
setValue(parent, def, {
|
|
30108
30016
|
shouldValidate: false
|
|
30109
30017
|
});
|