@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/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;
|
|
@@ -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,
|
|
@@ -765,6 +739,15 @@ var style = (_style = {
|
|
|
765
739
|
border: "1px solid green",
|
|
766
740
|
justifyContent: "flex-end"
|
|
767
741
|
}), _defineProperty$1(_style, "content_switch_button_off", {
|
|
742
|
+
width: "35px",
|
|
743
|
+
height: "22px",
|
|
744
|
+
borderRadius: "20px",
|
|
745
|
+
display: "flex",
|
|
746
|
+
marginTop: "10px",
|
|
747
|
+
backgroundColor: "#dc3545",
|
|
748
|
+
border: "1px solid #dc3545",
|
|
749
|
+
justifyContent: "flex-start"
|
|
750
|
+
}), _defineProperty$1(_style, "content_switch_button_null", {
|
|
768
751
|
width: "35px",
|
|
769
752
|
height: "22px",
|
|
770
753
|
borderRadius: "20px",
|
|
@@ -780,6 +763,14 @@ var style = (_style = {
|
|
|
780
763
|
width: "20px",
|
|
781
764
|
height: "20px"
|
|
782
765
|
}, _defineProperty$1(_switch_button_on, "backgroundColor", "#fff"), _defineProperty$1(_switch_button_on, "borderRadius", "20px"), _switch_button_on)), _defineProperty$1(_style, "switch_button_off", {
|
|
766
|
+
backgroundColor: "#fff",
|
|
767
|
+
borderRadius: "20px",
|
|
768
|
+
cursor: "pointer",
|
|
769
|
+
width: "20px",
|
|
770
|
+
height: "20px",
|
|
771
|
+
border: "1px solid #dfdfdf",
|
|
772
|
+
boxShadow: "1px 0px 5px 0px rgba(0, 0, 0, 0.3)"
|
|
773
|
+
}), _defineProperty$1(_style, "switch_button_null", {
|
|
783
774
|
backgroundColor: "#fff",
|
|
784
775
|
borderRadius: "20px",
|
|
785
776
|
cursor: "pointer",
|
|
@@ -798,7 +789,7 @@ var useCustomStyle = function useCustomStyle() {
|
|
|
798
789
|
return classes;
|
|
799
790
|
};
|
|
800
791
|
|
|
801
|
-
var BooleanInput = function
|
|
792
|
+
var BooleanInput = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
802
793
|
var _classNames;
|
|
803
794
|
|
|
804
795
|
var onChange = _ref.onChange,
|
|
@@ -821,15 +812,22 @@ var BooleanInput = function BooleanInput(_ref) {
|
|
|
821
812
|
}
|
|
822
813
|
}, /*#__PURE__*/React.createElement("div", {
|
|
823
814
|
className: classNames(classes.switch_button_on)
|
|
824
|
-
})), !value && /*#__PURE__*/React.createElement("div", {
|
|
815
|
+
})), !value && value !== null && /*#__PURE__*/React.createElement("div", {
|
|
825
816
|
className: classNames(classes.content_switch_button_off),
|
|
826
817
|
onClick: function onClick() {
|
|
827
818
|
return handleClick(true);
|
|
828
819
|
}
|
|
829
820
|
}, /*#__PURE__*/React.createElement("div", {
|
|
830
821
|
className: classNames(classes.switch_button_off)
|
|
822
|
+
})), value === null && /*#__PURE__*/React.createElement("div", {
|
|
823
|
+
className: classNames(classes.content_switch_button_null),
|
|
824
|
+
onClick: function onClick() {
|
|
825
|
+
return handleClick(true);
|
|
826
|
+
}
|
|
827
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
828
|
+
className: classNames(classes.switch_button_null)
|
|
831
829
|
})));
|
|
832
|
-
};
|
|
830
|
+
});
|
|
833
831
|
|
|
834
832
|
var Collapse = function Collapse(props) {
|
|
835
833
|
var _classNames4;
|
|
@@ -920,38 +918,6 @@ var None = {
|
|
|
920
918
|
}
|
|
921
919
|
};
|
|
922
920
|
|
|
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
921
|
var isPromise = function isPromise(value) {
|
|
956
922
|
return Boolean(value && typeof value.then === 'function');
|
|
957
923
|
};
|
|
@@ -967,7 +933,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
967
933
|
var possibleValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
968
934
|
var isMulti = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
969
935
|
|
|
970
|
-
if (value === null) {
|
|
936
|
+
if (value === null || !value) {
|
|
971
937
|
return null;
|
|
972
938
|
}
|
|
973
939
|
|
|
@@ -995,7 +961,7 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
995
961
|
});
|
|
996
962
|
};
|
|
997
963
|
|
|
998
|
-
var SelectInput = function
|
|
964
|
+
var SelectInput = /*#__PURE__*/React.forwardRef(function (props, _) {
|
|
999
965
|
var classes = useCustomStyle();
|
|
1000
966
|
var possibleValues = (props.possibleValues || []).map(function (v) {
|
|
1001
967
|
return props.transformer ? typeof props.transformer === 'function' ? props.transformer(v) : {
|
|
@@ -1150,7 +1116,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
1150
1116
|
readOnly: props.disabled ? 'readOnly' : null
|
|
1151
1117
|
}));
|
|
1152
1118
|
}
|
|
1153
|
-
};
|
|
1119
|
+
});
|
|
1154
1120
|
|
|
1155
1121
|
var ObjectInput = function ObjectInput(props) {
|
|
1156
1122
|
var _useState = useState(),
|
|
@@ -23657,7 +23623,7 @@ const Emoji = {
|
|
|
23657
23623
|
}]
|
|
23658
23624
|
};
|
|
23659
23625
|
|
|
23660
|
-
const data
|
|
23626
|
+
const data = /*@__PURE__*/defineLanguageFacet({ block: { open: "<!--", close: "-->" } });
|
|
23661
23627
|
const commonmark = /*@__PURE__*/parser.configure({
|
|
23662
23628
|
props: [
|
|
23663
23629
|
/*@__PURE__*/styleTags({
|
|
@@ -23693,12 +23659,12 @@ const commonmark = /*@__PURE__*/parser.configure({
|
|
|
23693
23659
|
Document: () => null
|
|
23694
23660
|
}),
|
|
23695
23661
|
/*@__PURE__*/languageDataProp.add({
|
|
23696
|
-
Document: data
|
|
23662
|
+
Document: data
|
|
23697
23663
|
})
|
|
23698
23664
|
]
|
|
23699
23665
|
});
|
|
23700
23666
|
function mkLang(parser) {
|
|
23701
|
-
return new Language(data
|
|
23667
|
+
return new Language(data, parser, parser.nodeSet.types.find(t => t.name == "Document"));
|
|
23702
23668
|
}
|
|
23703
23669
|
/**
|
|
23704
23670
|
Language support for strict CommonMark.
|
|
@@ -28537,7 +28503,7 @@ function CodeInput(_ref) {
|
|
|
28537
28503
|
changes: {
|
|
28538
28504
|
from: 0,
|
|
28539
28505
|
to: editor.state.doc.length,
|
|
28540
|
-
insert: _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28506
|
+
insert: value === null ? '' : _typeof$1(value) === 'object' ? JSON.stringify(value, null, 2) : value
|
|
28541
28507
|
}
|
|
28542
28508
|
});
|
|
28543
28509
|
}, [value]);
|
|
@@ -28546,67 +28512,6 @@ function CodeInput(_ref) {
|
|
|
28546
28512
|
});
|
|
28547
28513
|
}
|
|
28548
28514
|
|
|
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
28515
|
var converter = new showdown.Converter({
|
|
28611
28516
|
omitExtraWLInCodeBlocks: true,
|
|
28612
28517
|
ghCompatibleHeaderId: true,
|
|
@@ -28617,20 +28522,15 @@ var converter = new showdown.Converter({
|
|
|
28617
28522
|
requireSpaceBeforeHeadingText: true,
|
|
28618
28523
|
ghMentions: true,
|
|
28619
28524
|
emoji: true,
|
|
28620
|
-
ghMentionsLink: '/{u}'
|
|
28621
|
-
extensions: [DaikokuExtension]
|
|
28525
|
+
ghMentionsLink: '/{u}'
|
|
28622
28526
|
});
|
|
28623
28527
|
var MarkdownInput = function MarkdownInput(props) {
|
|
28624
|
-
var _useState = useState(
|
|
28528
|
+
var _useState = useState(props.preview),
|
|
28625
28529
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28626
28530
|
preview = _useState2[0],
|
|
28627
28531
|
setPreview = _useState2[1];
|
|
28628
28532
|
|
|
28629
|
-
var
|
|
28630
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
28631
|
-
editor = _useState4[0];
|
|
28632
|
-
_useState4[1];
|
|
28633
|
-
|
|
28533
|
+
var ref = useRef();
|
|
28634
28534
|
useEffect(function () {
|
|
28635
28535
|
if (preview) {
|
|
28636
28536
|
showPreview();
|
|
@@ -28639,162 +28539,127 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28639
28539
|
var commands = [{
|
|
28640
28540
|
name: 'Add header',
|
|
28641
28541
|
icon: 'heading',
|
|
28642
|
-
inject: function inject() {
|
|
28643
|
-
|
|
28644
|
-
|
|
28542
|
+
inject: function inject(range) {
|
|
28543
|
+
return !range ? '#' : [{
|
|
28544
|
+
from: range.from,
|
|
28545
|
+
insert: "# "
|
|
28546
|
+
}];
|
|
28645
28547
|
}
|
|
28646
28548
|
}, {
|
|
28647
28549
|
name: 'Add bold text',
|
|
28648
28550
|
icon: 'bold',
|
|
28649
|
-
inject: function inject() {
|
|
28650
|
-
|
|
28651
|
-
|
|
28551
|
+
inject: function inject(range) {
|
|
28552
|
+
return !range ? '** **' : [{
|
|
28553
|
+
from: range.from,
|
|
28554
|
+
insert: "**"
|
|
28555
|
+
}, {
|
|
28556
|
+
from: range.to,
|
|
28557
|
+
insert: '**'
|
|
28558
|
+
}];
|
|
28652
28559
|
}
|
|
28653
28560
|
}, {
|
|
28654
28561
|
name: 'Add italic text',
|
|
28655
28562
|
icon: 'italic',
|
|
28656
|
-
inject: function inject() {
|
|
28657
|
-
|
|
28658
|
-
|
|
28563
|
+
inject: function inject(range) {
|
|
28564
|
+
return !range ? '* *' : [{
|
|
28565
|
+
from: range.from,
|
|
28566
|
+
insert: '*'
|
|
28567
|
+
}, {
|
|
28568
|
+
from: range.to,
|
|
28569
|
+
insert: '*'
|
|
28570
|
+
}];
|
|
28659
28571
|
}
|
|
28660
28572
|
}, {
|
|
28661
28573
|
name: 'Add strikethrough text',
|
|
28662
28574
|
icon: 'strikethrough',
|
|
28663
|
-
inject: function inject() {
|
|
28664
|
-
|
|
28665
|
-
|
|
28575
|
+
inject: function inject(range) {
|
|
28576
|
+
return !range ? '~~ ~~' : [{
|
|
28577
|
+
from: range.from,
|
|
28578
|
+
insert: '~~'
|
|
28579
|
+
}, {
|
|
28580
|
+
from: range.to,
|
|
28581
|
+
insert: '~~'
|
|
28582
|
+
}];
|
|
28666
28583
|
}
|
|
28667
28584
|
}, {
|
|
28668
28585
|
name: 'Add link',
|
|
28669
28586
|
icon: 'link',
|
|
28670
|
-
inject: function inject() {
|
|
28671
|
-
|
|
28672
|
-
|
|
28587
|
+
inject: function inject(range) {
|
|
28588
|
+
return !range ? '[ ](url)' : [{
|
|
28589
|
+
from: range.from,
|
|
28590
|
+
insert: '['
|
|
28591
|
+
}, {
|
|
28592
|
+
from: range.to,
|
|
28593
|
+
insert: '](url)'
|
|
28594
|
+
}];
|
|
28673
28595
|
}
|
|
28674
28596
|
}, {
|
|
28675
28597
|
name: 'Add code',
|
|
28676
28598
|
icon: 'code',
|
|
28677
|
-
inject: function inject() {
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28682
|
-
|
|
28683
|
-
|
|
28684
|
-
|
|
28685
|
-
});
|
|
28599
|
+
inject: function inject(range) {
|
|
28600
|
+
return !range ? '```\n\n```\n' : [{
|
|
28601
|
+
from: range.from,
|
|
28602
|
+
insert: '```\n'
|
|
28603
|
+
}, {
|
|
28604
|
+
from: range.to,
|
|
28605
|
+
insert: '\n```\n'
|
|
28606
|
+
}];
|
|
28686
28607
|
}
|
|
28687
28608
|
}, {
|
|
28688
28609
|
name: 'Add quotes',
|
|
28689
28610
|
icon: 'quote-right',
|
|
28690
|
-
inject: function inject() {
|
|
28691
|
-
|
|
28692
|
-
|
|
28611
|
+
inject: function inject(range) {
|
|
28612
|
+
return !range ? '> ' : [{
|
|
28613
|
+
from: range.from,
|
|
28614
|
+
insert: '> '
|
|
28615
|
+
}];
|
|
28693
28616
|
}
|
|
28694
28617
|
}, {
|
|
28695
28618
|
name: 'Add image',
|
|
28696
28619
|
icon: 'image',
|
|
28697
|
-
inject: function inject() {
|
|
28698
|
-
|
|
28699
|
-
|
|
28620
|
+
inject: function inject(range) {
|
|
28621
|
+
return !range ? '' : [{
|
|
28622
|
+
from: range.from,
|
|
28623
|
+
insert: ''
|
|
28627
|
+
}];
|
|
28700
28628
|
}
|
|
28701
28629
|
}, {
|
|
28702
28630
|
name: 'Add unordered list',
|
|
28703
28631
|
icon: 'list-ul',
|
|
28704
|
-
inject: function inject() {
|
|
28705
|
-
|
|
28706
|
-
|
|
28632
|
+
inject: function inject(range) {
|
|
28633
|
+
return !range ? '* ' : [{
|
|
28634
|
+
from: range.from,
|
|
28635
|
+
insert: '* '
|
|
28636
|
+
}];
|
|
28707
28637
|
}
|
|
28708
28638
|
}, {
|
|
28709
28639
|
name: 'Add ordered list',
|
|
28710
28640
|
icon: 'list-ol',
|
|
28711
|
-
inject: function inject() {
|
|
28712
|
-
|
|
28713
|
-
|
|
28641
|
+
inject: function inject(range) {
|
|
28642
|
+
return !range ? '1. ' : [{
|
|
28643
|
+
from: range.from,
|
|
28644
|
+
insert: '1. '
|
|
28645
|
+
}];
|
|
28714
28646
|
}
|
|
28715
28647
|
}, {
|
|
28716
28648
|
name: 'Add check list',
|
|
28717
28649
|
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.";
|
|
28650
|
+
inject: function inject(range) {
|
|
28651
|
+
return !range ? '* [ ] ' : [{
|
|
28652
|
+
from: range.from,
|
|
28653
|
+
insert: '* [ ] '
|
|
28654
|
+
}];
|
|
28792
28655
|
}
|
|
28793
28656
|
}];
|
|
28794
28657
|
|
|
28795
28658
|
var showPreview = function showPreview() {
|
|
28796
|
-
|
|
28797
|
-
|
|
28659
|
+
var parent = _toConsumableArray$1(document.getElementsByClassName('preview'));
|
|
28660
|
+
|
|
28661
|
+
if (parent.length > 0) _toConsumableArray$1(parent[0].querySelectorAll('pre code')).forEach(function (block) {
|
|
28662
|
+
return hljs.highlightElement(block);
|
|
28798
28663
|
});
|
|
28799
28664
|
};
|
|
28800
28665
|
|
|
@@ -28812,21 +28677,22 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28812
28677
|
title: command.name,
|
|
28813
28678
|
key: "toolbar-btn-".concat(idx),
|
|
28814
28679
|
onClick: function onClick() {
|
|
28815
|
-
var
|
|
28816
|
-
|
|
28817
|
-
if (
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
return
|
|
28826
|
-
|
|
28680
|
+
var editor = ref.current;
|
|
28681
|
+
var selections = editor.state.selection.ranges;
|
|
28682
|
+
if (selections.length === 1 && selections[0].from === selections[0].to) editor.dispatch({
|
|
28683
|
+
changes: {
|
|
28684
|
+
from: 0,
|
|
28685
|
+
to: editor.state.doc.length,
|
|
28686
|
+
insert: editor.state.doc.toString() + command.inject()
|
|
28687
|
+
}
|
|
28688
|
+
});else {
|
|
28689
|
+
editor.dispatch(editor.state.changeByRange(function (range) {
|
|
28690
|
+
return {
|
|
28691
|
+
changes: command.inject(range),
|
|
28692
|
+
range: range
|
|
28693
|
+
};
|
|
28694
|
+
}));
|
|
28827
28695
|
}
|
|
28828
|
-
|
|
28829
|
-
editor.focus();
|
|
28830
28696
|
}
|
|
28831
28697
|
}, /*#__PURE__*/React.createElement("i", {
|
|
28832
28698
|
className: "fas fa-".concat(command.icon)
|
|
@@ -28837,7 +28703,7 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28837
28703
|
var classes = useCustomStyle();
|
|
28838
28704
|
return /*#__PURE__*/React.createElement("div", {
|
|
28839
28705
|
className: classNames(props.className)
|
|
28840
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
28706
|
+
}, !props.readOnly && /*#__PURE__*/React.createElement("div", {
|
|
28841
28707
|
style: {
|
|
28842
28708
|
marginBottom: 10
|
|
28843
28709
|
}
|
|
@@ -28863,8 +28729,12 @@ var MarkdownInput = function MarkdownInput(props) {
|
|
|
28863
28729
|
}
|
|
28864
28730
|
}, "Preview"))), /*#__PURE__*/React.createElement("div", {
|
|
28865
28731
|
className: classNames(classes.flex)
|
|
28866
|
-
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput,
|
|
28867
|
-
|
|
28732
|
+
}, injectButtons())), !preview && /*#__PURE__*/React.createElement(CodeInput, _extends({}, props, {
|
|
28733
|
+
setRef: function setRef(e) {
|
|
28734
|
+
return ref.current = e;
|
|
28735
|
+
}
|
|
28736
|
+
})), preview && /*#__PURE__*/React.createElement("div", {
|
|
28737
|
+
className: "preview",
|
|
28868
28738
|
dangerouslySetInnerHTML: {
|
|
28869
28739
|
__html: converter.makeHtml(props.value)
|
|
28870
28740
|
}
|
|
@@ -28913,17 +28783,17 @@ function SingleLineCode(_ref) {
|
|
|
28913
28783
|
|
|
28914
28784
|
var _resolvers;
|
|
28915
28785
|
var resolvers = (_resolvers = {}, _defineProperty$1(_resolvers, type.string, function (typeErrorMessage) {
|
|
28916
|
-
return yup.string().typeError(typeErrorMessage || 'Value must be a string');
|
|
28786
|
+
return yup.string().nullable().optional().typeError(typeErrorMessage || 'Value must be a string');
|
|
28917
28787
|
}), _defineProperty$1(_resolvers, type.number, function (typeErrorMessage) {
|
|
28918
|
-
return yup.number().transform(function (v) {
|
|
28788
|
+
return yup.number().nullable().optional().transform(function (v) {
|
|
28919
28789
|
return isNaN(v) ? null : v;
|
|
28920
28790
|
}).typeError(typeErrorMessage || 'Value must be a number');
|
|
28921
28791
|
}), _defineProperty$1(_resolvers, type.bool, function () {
|
|
28922
|
-
return yup.bool();
|
|
28792
|
+
return yup.bool().nullable().optional();
|
|
28923
28793
|
}), _defineProperty$1(_resolvers, type.object, function () {
|
|
28924
|
-
return yup.object();
|
|
28794
|
+
return yup.object().nullable().optional();
|
|
28925
28795
|
}), _defineProperty$1(_resolvers, type.date, function (typeErrorMessage) {
|
|
28926
|
-
return yup.date().typeError(typeErrorMessage || 'Value must be a date');
|
|
28796
|
+
return yup.date().nullable().optional().typeError(typeErrorMessage || 'Value must be a date');
|
|
28927
28797
|
}), _defineProperty$1(_resolvers, type.file, function () {
|
|
28928
28798
|
return yup.mixed();
|
|
28929
28799
|
}), _resolvers);
|
|
@@ -28950,6 +28820,10 @@ var buildSubResolver = function buildSubResolver(props, key, dependencies, rawDa
|
|
|
28950
28820
|
return jsonOrFunctionConstraint(constraint, resolver, key, dependencies);
|
|
28951
28821
|
}, arrayResolver);
|
|
28952
28822
|
} else if (props.type === type.object && props.schema) {
|
|
28823
|
+
if (!Object.keys(props.schema).length) {
|
|
28824
|
+
return yup.object();
|
|
28825
|
+
}
|
|
28826
|
+
|
|
28953
28827
|
var _subResolver = getShapeAndDependencies(props.flow || Object.keys(props.schema), props.schema, dependencies, rawData);
|
|
28954
28828
|
|
|
28955
28829
|
return constraints.reduce(function (resolver, constraint) {
|
|
@@ -29000,11 +28874,23 @@ var jsonOrFunctionConstraint = function jsonOrFunctionConstraint(constraint, res
|
|
|
29000
28874
|
var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
29001
28875
|
var dependencies = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
29002
28876
|
var rawData = arguments.length > 3 ? arguments[3] : undefined;
|
|
28877
|
+
|
|
28878
|
+
if (!Object.keys(schema).length) {
|
|
28879
|
+
return {
|
|
28880
|
+
shape: yup.object().shape({}),
|
|
28881
|
+
dependencies: dependencies
|
|
28882
|
+
};
|
|
28883
|
+
}
|
|
28884
|
+
|
|
29003
28885
|
var shape = (flow || Object.keys(schema)).reduce(function (resolvers, key) {
|
|
29004
28886
|
if (_typeof$1(key) === 'object') {
|
|
29005
28887
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), getShapeAndDependencies(key.flow, schema, dependencies, rawData).shape);
|
|
29006
28888
|
}
|
|
29007
28889
|
|
|
28890
|
+
if (!schema[key]) {
|
|
28891
|
+
return resolvers;
|
|
28892
|
+
}
|
|
28893
|
+
|
|
29008
28894
|
var resolver = buildSubResolver(schema[key], key, dependencies, rawData);
|
|
29009
28895
|
return _objectSpread2$1(_objectSpread2$1({}, resolvers), {}, _defineProperty$1({}, key, resolver));
|
|
29010
28896
|
}, {});
|
|
@@ -29014,7 +28900,8 @@ var getShapeAndDependencies = function getShapeAndDependencies(flow, schema) {
|
|
|
29014
28900
|
};
|
|
29015
28901
|
};
|
|
29016
28902
|
|
|
29017
|
-
var CustomizableInput$1 = function
|
|
28903
|
+
var CustomizableInput$1 = /*#__PURE__*/React.memo(function (props) {
|
|
28904
|
+
// console.log("CUSTOMIZABLE_INPUT" + props.field.name)
|
|
29018
28905
|
if (props.render) {
|
|
29019
28906
|
return props.render(_objectSpread2$1(_objectSpread2$1({}, props.field), {}, {
|
|
29020
28907
|
error: props.error
|
|
@@ -29022,8 +28909,9 @@ var CustomizableInput$1 = function CustomizableInput(props) {
|
|
|
29022
28909
|
}
|
|
29023
28910
|
|
|
29024
28911
|
return props.children;
|
|
29025
|
-
}
|
|
29026
|
-
|
|
28912
|
+
}, function (prev, next) {
|
|
28913
|
+
return prev.field.value === next.field.value;
|
|
28914
|
+
});
|
|
29027
28915
|
var ControlledInput = function ControlledInput(_ref) {
|
|
29028
28916
|
var defaultValue = _ref.defaultValue,
|
|
29029
28917
|
step = _ref.step,
|
|
@@ -29058,22 +28946,36 @@ var ControlledInput = function ControlledInput(_ref) {
|
|
|
29058
28946
|
readOnly: functionalProperty(entry, step.disabled) ? 'readOnly' : null,
|
|
29059
28947
|
placeholder: step.placeholder,
|
|
29060
28948
|
onChange: function onChange(e) {
|
|
29061
|
-
|
|
28949
|
+
var value = function () {
|
|
28950
|
+
if (!e) {
|
|
28951
|
+
if (step.type === type.bool || step.type === type.number && field.value === 0) {
|
|
28952
|
+
return e;
|
|
28953
|
+
} else {
|
|
28954
|
+
return null;
|
|
28955
|
+
}
|
|
28956
|
+
} else if (e.target) {
|
|
28957
|
+
return e.target.value || null;
|
|
28958
|
+
} else {
|
|
28959
|
+
return e;
|
|
28960
|
+
}
|
|
28961
|
+
}(); // field.onChange(!e ? null : e.target ? e.target.value || null : e)
|
|
28962
|
+
|
|
28963
|
+
|
|
28964
|
+
field.onChange(value);
|
|
29062
28965
|
option(step.onChange).map(function (onChange) {
|
|
29063
28966
|
return onChange({
|
|
29064
28967
|
rawValues: getValues(),
|
|
29065
|
-
value:
|
|
28968
|
+
value: value,
|
|
29066
28969
|
setValue: _setValue
|
|
29067
28970
|
});
|
|
29068
28971
|
});
|
|
29069
28972
|
},
|
|
29070
|
-
value: field.value
|
|
28973
|
+
value: field.value
|
|
29071
28974
|
});
|
|
29072
28975
|
|
|
29073
28976
|
var error = entry.split('.').reduce(function (acc, curr) {
|
|
29074
28977
|
return acc && acc[curr];
|
|
29075
28978
|
}, errors);
|
|
29076
|
-
console.log("render controlled input " + entry);
|
|
29077
28979
|
return /*#__PURE__*/React.createElement(CustomizableInput$1, {
|
|
29078
28980
|
render: step.render,
|
|
29079
28981
|
field: _objectSpread2$1({
|
|
@@ -29093,7 +28995,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
29093
28995
|
var ref = useRef(); // Store current value in ref
|
|
29094
28996
|
|
|
29095
28997
|
useEffect(function () {
|
|
29096
|
-
ref.current = value
|
|
28998
|
+
ref.current = value;
|
|
29097
28999
|
}, [value]); // Only re-run if value changes
|
|
29098
29000
|
// Return previous value (happens before update in useEffect above)
|
|
29099
29001
|
|
|
@@ -29178,7 +29080,7 @@ var CustomizableInput = function CustomizableInput(props) {
|
|
|
29178
29080
|
return props.children;
|
|
29179
29081
|
};
|
|
29180
29082
|
|
|
29181
|
-
var defaultVal = function defaultVal(value,
|
|
29083
|
+
var defaultVal = function defaultVal(value, array, defaultValue) {
|
|
29182
29084
|
if (!!defaultValue) return defaultValue;
|
|
29183
29085
|
if (!!array) return [];
|
|
29184
29086
|
return value;
|
|
@@ -29196,7 +29098,7 @@ var getDefaultValues = function getDefaultValues(flow, schema, value) {
|
|
|
29196
29098
|
return acc;
|
|
29197
29099
|
}
|
|
29198
29100
|
|
|
29199
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.
|
|
29101
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, defaultVal(value ? value[key] : null, entry.array || entry.isMulti, entry.defaultValue)));
|
|
29200
29102
|
}, {});
|
|
29201
29103
|
};
|
|
29202
29104
|
|
|
@@ -29218,7 +29120,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29218
29120
|
|
|
29219
29121
|
var v;
|
|
29220
29122
|
if (obj) v = obj[key];
|
|
29221
|
-
if (!v && defaultValues) v = defaultValues[key];
|
|
29123
|
+
if ((step.type === type.bool && v === null || step.type !== type.bool && !v) && defaultValues) v = defaultValues[key];
|
|
29222
29124
|
|
|
29223
29125
|
if (step.array && !step.render) {
|
|
29224
29126
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, (v || []).map(function (value) {
|
|
@@ -29231,7 +29133,7 @@ var cleanInputArray = function cleanInputArray(obj, defaultValues, flow, subSche
|
|
|
29231
29133
|
|
|
29232
29134
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanInputArray(v, defaultValues, (_subSchema$key = subSchema[key]) === null || _subSchema$key === void 0 ? void 0 : _subSchema$key.flow, ((_subSchema$key2 = subSchema[key]) === null || _subSchema$key2 === void 0 ? void 0 : _subSchema$key2.schema) || {})));
|
|
29233
29135
|
} else {
|
|
29234
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29136
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v === undefined ? Array.isArray(v) ? [] : step.type === type.object ? {} : null : v));
|
|
29235
29137
|
}
|
|
29236
29138
|
}, obj);
|
|
29237
29139
|
};
|
|
@@ -29263,7 +29165,7 @@ var cleanOutputArray = function cleanOutputArray(obj, subSchema) {
|
|
|
29263
29165
|
|
|
29264
29166
|
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, cleanOutputArray(v, ((_subSchema$key3 = subSchema[key]) === null || _subSchema$key3 === void 0 ? void 0 : _subSchema$key3.schema) || {})));
|
|
29265
29167
|
} else {
|
|
29266
|
-
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v
|
|
29168
|
+
return _objectSpread2$1(_objectSpread2$1({}, acc), {}, _defineProperty$1({}, key, v));
|
|
29267
29169
|
}
|
|
29268
29170
|
}, {});
|
|
29269
29171
|
};
|
|
@@ -29283,10 +29185,22 @@ var validate = function validate(flow, schema, value) {
|
|
|
29283
29185
|
var Watcher = function Watcher(_ref7) {
|
|
29284
29186
|
var options = _ref7.options,
|
|
29285
29187
|
control = _ref7.control,
|
|
29286
|
-
schema = _ref7.schema
|
|
29188
|
+
schema = _ref7.schema,
|
|
29189
|
+
onSubmit = _ref7.onSubmit,
|
|
29190
|
+
handleSubmit = _ref7.handleSubmit;
|
|
29191
|
+
_ref7.getValues;
|
|
29192
|
+
_ref7.watch;
|
|
29287
29193
|
var data = useWatch({
|
|
29288
29194
|
control: control
|
|
29289
29195
|
});
|
|
29196
|
+
var prev = usePrevious(data);
|
|
29197
|
+
useEffect(function () {
|
|
29198
|
+
if (!!options.autosubmit) {
|
|
29199
|
+
if (!deepEqual(data, prev)) handleSubmit(function () {
|
|
29200
|
+
onSubmit(cleanOutputArray(data, schema));
|
|
29201
|
+
})();
|
|
29202
|
+
}
|
|
29203
|
+
}, [data]);
|
|
29290
29204
|
|
|
29291
29205
|
if (options.watch) {
|
|
29292
29206
|
if (typeof options.watch === 'function') {
|
|
@@ -29348,38 +29262,38 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29348
29262
|
resolver: function resolver(data, context, options) {
|
|
29349
29263
|
return yupResolver(_resolver(data))(data, context, options);
|
|
29350
29264
|
},
|
|
29351
|
-
defaultValues: cleanInputArray(value, defaultValues, flow, schema),
|
|
29352
29265
|
shouldFocusError: false,
|
|
29353
|
-
mode: '
|
|
29354
|
-
|
|
29266
|
+
mode: 'onChange'
|
|
29355
29267
|
});
|
|
29268
|
+
|
|
29269
|
+
var _useState = useState(false),
|
|
29270
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
29271
|
+
initialReseted = _useState2[0],
|
|
29272
|
+
setReset = _useState2[1];
|
|
29273
|
+
|
|
29274
|
+
useEffect(function () {
|
|
29275
|
+
_reset(cleanInputArray(value, defaultValues, flow, schema));
|
|
29276
|
+
|
|
29277
|
+
setReset(true);
|
|
29278
|
+
}, [_reset]);
|
|
29279
|
+
useEffect(function () {
|
|
29280
|
+
initialReseted && trigger();
|
|
29281
|
+
}, [trigger, initialReseted]);
|
|
29356
29282
|
var _handleSubmit = methods.handleSubmit,
|
|
29357
29283
|
_methods$formState = methods.formState,
|
|
29358
29284
|
errors = _methods$formState.errors,
|
|
29359
29285
|
dirtyFields = _methods$formState.dirtyFields,
|
|
29360
29286
|
_reset = methods.reset,
|
|
29361
29287
|
trigger = methods.trigger,
|
|
29362
|
-
getValues = methods.getValues
|
|
29288
|
+
getValues = methods.getValues,
|
|
29289
|
+
watch = methods.watch;
|
|
29290
|
+
var prev = usePrevious(value);
|
|
29291
|
+
var prevSchema = usePrevious(schema);
|
|
29363
29292
|
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
|
-
}
|
|
29293
|
+
if (!deepEqual(value, prev) || !deepEqual(schema, prevSchema)) {
|
|
29294
|
+
_reset(_objectSpread2$1({}, cleanInputArray(value, defaultValues, flow, schema)));
|
|
29295
|
+
}
|
|
29296
|
+
}, [value, schema]);
|
|
29383
29297
|
|
|
29384
29298
|
var functionalProperty = function functionalProperty(entry, prop) {
|
|
29385
29299
|
if (typeof prop === 'function') {
|
|
@@ -29400,9 +29314,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29400
29314
|
onSubmit(clean);
|
|
29401
29315
|
}, onError)();
|
|
29402
29316
|
},
|
|
29403
|
-
rawData: function rawData() {
|
|
29404
|
-
return cleanOutputArray(data, schema);
|
|
29405
|
-
},
|
|
29406
29317
|
trigger: trigger,
|
|
29407
29318
|
methods: methods
|
|
29408
29319
|
};
|
|
@@ -29410,7 +29321,10 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29410
29321
|
return /*#__PURE__*/React.createElement(FormProvider, methods, /*#__PURE__*/React.createElement(Watcher, {
|
|
29411
29322
|
options: options,
|
|
29412
29323
|
control: methods.control,
|
|
29413
|
-
schema: schema
|
|
29324
|
+
schema: schema,
|
|
29325
|
+
onSubmit: onSubmit,
|
|
29326
|
+
handleSubmit: _handleSubmit,
|
|
29327
|
+
watch: methods.watch
|
|
29414
29328
|
}), /*#__PURE__*/React.createElement("form", {
|
|
29415
29329
|
className: className || "".concat(classes.pr_15, " ").concat(classes.w_100),
|
|
29416
29330
|
onSubmit: _handleSubmit(function (data) {
|
|
@@ -29433,8 +29347,6 @@ var Form = /*#__PURE__*/React.forwardRef(function (_ref8, ref) {
|
|
|
29433
29347
|
}).map(function (visible) {
|
|
29434
29348
|
switch (_typeof$1(visible)) {
|
|
29435
29349
|
case 'object':
|
|
29436
|
-
console.log('watch from visibleStep');
|
|
29437
|
-
|
|
29438
29350
|
var _value = watch(step.visible.ref);
|
|
29439
29351
|
|
|
29440
29352
|
return option(step.visible.test).map(function (test) {
|
|
@@ -29541,8 +29453,6 @@ var Step = function Step(_ref9) {
|
|
|
29541
29453
|
watch = _useFormContext2.watch;
|
|
29542
29454
|
_useFormContext2.register;
|
|
29543
29455
|
|
|
29544
|
-
console.log("re-render : " + entry);
|
|
29545
|
-
|
|
29546
29456
|
if (entry && _typeof$1(entry) === 'object') {
|
|
29547
29457
|
var errored = entry.flow.some(function (step) {
|
|
29548
29458
|
return !!errors[step] && (dirtyFields[step] || touchedFields[step]);
|
|
@@ -29565,7 +29475,6 @@ var Step = function Step(_ref9) {
|
|
|
29565
29475
|
}).map(function (visible) {
|
|
29566
29476
|
switch (_typeof$1(visible)) {
|
|
29567
29477
|
case 'object':
|
|
29568
|
-
console.log("watch of collapse");
|
|
29569
29478
|
var value = watch(visible.ref);
|
|
29570
29479
|
return option(visible.test).map(function (test) {
|
|
29571
29480
|
return test(value, index);
|
|
@@ -29614,14 +29523,13 @@ var Step = function Step(_ref9) {
|
|
|
29614
29523
|
var onAfterChangeFunc = onAfterChange || step.onAfterChange || step.on_after_change;
|
|
29615
29524
|
|
|
29616
29525
|
if (onAfterChangeFunc) {
|
|
29617
|
-
var
|
|
29618
|
-
|
|
29526
|
+
var data = watch();
|
|
29619
29527
|
var d = entry.replace('[', '.').replace(']', '').split('.').reduce(function (acc, curr) {
|
|
29620
29528
|
return acc && acc[curr];
|
|
29621
|
-
},
|
|
29529
|
+
}, data) || {};
|
|
29622
29530
|
var currentData = usePrevious(cleanOutputArray(d, schema));
|
|
29623
29531
|
var newData = cleanOutputArray(d, schema);
|
|
29624
|
-
if (!deepEqual(newData, currentData)) onAfterChangeFunc({
|
|
29532
|
+
if (!deepEqual(newData, currentData) || newData !== undefined && currentData === undefined) onAfterChangeFunc({
|
|
29625
29533
|
entry: entry,
|
|
29626
29534
|
previousValue: currentData,
|
|
29627
29535
|
value: getValues(entry),
|
|
@@ -29653,7 +29561,6 @@ var Step = function Step(_ref9) {
|
|
|
29653
29561
|
}, /*#__PURE__*/React.createElement(ArrayStep, {
|
|
29654
29562
|
entry: entry,
|
|
29655
29563
|
step: step,
|
|
29656
|
-
defaultValue: step.defaultValue || null,
|
|
29657
29564
|
disabled: functionalProperty(entry, step.disabled),
|
|
29658
29565
|
component: function component(props, idx) {
|
|
29659
29566
|
var _props$defaultValue;
|
|
@@ -29726,6 +29633,7 @@ var Step = function Step(_ref9) {
|
|
|
29726
29633
|
isMulti: step.isMulti,
|
|
29727
29634
|
createOption: step.createOption,
|
|
29728
29635
|
transformer: step.transformer,
|
|
29636
|
+
optionsFrom: step.optionsFrom,
|
|
29729
29637
|
buttons: step.format === format.buttonsSelect
|
|
29730
29638
|
}));
|
|
29731
29639
|
}
|
|
@@ -29757,6 +29665,7 @@ var Step = function Step(_ref9) {
|
|
|
29757
29665
|
createOption: step.createOption,
|
|
29758
29666
|
onCreateOption: step.onCreateOption,
|
|
29759
29667
|
transformer: step.transformer,
|
|
29668
|
+
optionsFrom: step.optionsFrom,
|
|
29760
29669
|
buttons: step.format === format.buttonsSelect
|
|
29761
29670
|
}));
|
|
29762
29671
|
|
|
@@ -29796,6 +29705,7 @@ var Step = function Step(_ref9) {
|
|
|
29796
29705
|
createOption: step.createOption,
|
|
29797
29706
|
onCreateOption: step.onCreateOption,
|
|
29798
29707
|
transformer: step.transformer,
|
|
29708
|
+
optionsFrom: step.optionsFrom,
|
|
29799
29709
|
buttons: step.format === format.buttonsSelect
|
|
29800
29710
|
}));
|
|
29801
29711
|
|
|
@@ -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,
|
|
@@ -30029,7 +29936,7 @@ var ArrayStep = function ArrayStep(_ref12) {
|
|
|
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() {
|
|
30031
29938
|
append({
|
|
30032
|
-
value: step.addableDefaultValue || defaultVal(null
|
|
29939
|
+
value: step.addableDefaultValue || defaultVal(null)
|
|
30033
29940
|
});
|
|
30034
29941
|
trigger(entry);
|
|
30035
29942
|
option(step.onChange).map(function (onChange) {
|
|
@@ -30067,10 +29974,10 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30067
29974
|
_useFormContext4.trigger;
|
|
30068
29975
|
_useFormContext4.formState;
|
|
30069
29976
|
|
|
30070
|
-
var
|
|
30071
|
-
|
|
30072
|
-
collapsed =
|
|
30073
|
-
setCollapsed =
|
|
29977
|
+
var _useState7 = useState(!!step.collapsed),
|
|
29978
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
29979
|
+
collapsed = _useState8[0],
|
|
29980
|
+
setCollapsed = _useState8[1];
|
|
30074
29981
|
|
|
30075
29982
|
var classes = useCustomStyle(); // TODO - voir ce qui se passe et à quoi ça sert
|
|
30076
29983
|
// const v = getValues(parent);
|
|
@@ -30103,7 +30010,7 @@ var NestedForm = function NestedForm(_ref13) {
|
|
|
30103
30010
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
30104
30011
|
useEffect(function () {
|
|
30105
30012
|
if (!!prevSchema && !deepEqual(prevSchema, schemaAndFlow.schema)) {
|
|
30106
|
-
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
30013
|
+
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema, getValues(parent));
|
|
30107
30014
|
setValue(parent, def, {
|
|
30108
30015
|
shouldValidate: false
|
|
30109
30016
|
});
|