@maif/react-forms 1.0.20 → 1.0.24
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/.github/workflows/release.yml +1 -1
- package/README.md +5 -0
- package/dist/react-form.js +1 -1
- package/lib/form.js +239 -70
- package/lib/inputs/Collapse.js +1 -1
- package/lib/inputs/SelectInput.js +5 -2
- package/lib/style.d.ts +9 -2
- package/lib/style.js +7 -2
- package/lib/styleContext.d.ts +1 -1
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -41,6 +41,14 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
41
41
|
|
|
42
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
43
|
|
|
44
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
45
|
+
|
|
46
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
47
|
+
|
|
48
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
49
|
+
|
|
50
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
51
|
+
|
|
44
52
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
45
53
|
|
|
46
54
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -165,6 +173,10 @@ var getDefaultValues = function getDefaultValues(flow, schema) {
|
|
|
165
173
|
return flow.reduce(function (acc, key) {
|
|
166
174
|
var entry = schema[key];
|
|
167
175
|
|
|
176
|
+
if (!entry) {
|
|
177
|
+
return acc;
|
|
178
|
+
}
|
|
179
|
+
|
|
168
180
|
if (_typeof(key) === 'object') {
|
|
169
181
|
return _objectSpread(_objectSpread({}, acc), getDefaultValues(key.flow, schema));
|
|
170
182
|
}
|
|
@@ -238,7 +250,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
238
250
|
}
|
|
239
251
|
|
|
240
252
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
241
|
-
} else if (!!v && _typeof(v) === 'object') {
|
|
253
|
+
} else if (!!v && _typeof(v) === 'object' && !(v instanceof Date)) {
|
|
242
254
|
var _subSchema$key;
|
|
243
255
|
|
|
244
256
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanInputArray(v, ((_subSchema$key = subSchema[key]) === null || _subSchema$key === void 0 ? void 0 : _subSchema$key.schema) || {})));
|
|
@@ -269,7 +281,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
272
|
-
} else if (!!v && _typeof(v) === 'object') {
|
|
284
|
+
} else if (!!v && _typeof(v) === 'object' && !(v instanceof Date)) {
|
|
273
285
|
var _subSchema$key2;
|
|
274
286
|
|
|
275
287
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanOutputArray(v, ((_subSchema$key2 = subSchema[key]) === null || _subSchema$key2 === void 0 ? void 0 : _subSchema$key2.schema) || {})));
|
|
@@ -316,9 +328,13 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
316
328
|
}, [data]);
|
|
317
329
|
|
|
318
330
|
if (options.watch) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
331
|
+
if (typeof options.watch === 'function') {
|
|
332
|
+
options.watch(watch());
|
|
333
|
+
} else {
|
|
334
|
+
console.group('react-form watch');
|
|
335
|
+
console.log(watch());
|
|
336
|
+
console.groupEnd();
|
|
337
|
+
}
|
|
322
338
|
}
|
|
323
339
|
|
|
324
340
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
@@ -339,6 +355,12 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
339
355
|
}, onError)
|
|
340
356
|
}, formFlow.map(function (entry, idx) {
|
|
341
357
|
var step = schema[entry];
|
|
358
|
+
|
|
359
|
+
if (!step && typeof entry === 'string') {
|
|
360
|
+
console.error("no step found for the entry \"".concat(entry, "\" in the given schema. Your form might not work properly. Please fix it"));
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
|
|
342
364
|
var error = _typeof(entry) === 'object' ? undefined : entry.split('.').reduce(function (object, key) {
|
|
343
365
|
return object && object[key];
|
|
344
366
|
}, errors);
|
|
@@ -465,6 +487,12 @@ var Step = function Step(_ref4) {
|
|
|
465
487
|
var err = _typeof(en) === 'object' ? undefined : en.split('.').reduce(function (object, key) {
|
|
466
488
|
return object && object[key];
|
|
467
489
|
}, errors);
|
|
490
|
+
|
|
491
|
+
if (!stp && typeof en === 'string') {
|
|
492
|
+
console.error("no step found for the entry \"".concat(en, "\" in the given schema. Your form might not work properly. Please fix it"));
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
|
|
468
496
|
var visibleStep = (0, _Option.option)(stp).map(function (s) {
|
|
469
497
|
return s.visible;
|
|
470
498
|
}).map(function (visible) {
|
|
@@ -489,7 +517,6 @@ var Step = function Step(_ref4) {
|
|
|
489
517
|
|
|
490
518
|
return /*#__PURE__*/_react["default"].createElement(BasicWrapper, {
|
|
491
519
|
key: "collapse-".concat(en, "-").concat(entryIdx),
|
|
492
|
-
className: classes.collapseInline,
|
|
493
520
|
entry: en,
|
|
494
521
|
error: err,
|
|
495
522
|
label: (stp === null || stp === void 0 ? void 0 : stp.label) === null ? null : (stp === null || stp === void 0 ? void 0 : stp.label) || en,
|
|
@@ -509,11 +536,37 @@ var Step = function Step(_ref4) {
|
|
|
509
536
|
watch: watch,
|
|
510
537
|
inputWrapper: inputWrapper,
|
|
511
538
|
httpClient: httpClient,
|
|
512
|
-
defaultValue: stp.defaultValue
|
|
539
|
+
defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue
|
|
513
540
|
}));
|
|
514
541
|
}));
|
|
515
542
|
}
|
|
516
543
|
|
|
544
|
+
var registeredInput = register(entry);
|
|
545
|
+
|
|
546
|
+
var inputProps = _objectSpread(_objectSpread({}, registeredInput), {}, {
|
|
547
|
+
onChange: function onChange(e) {
|
|
548
|
+
registeredInput.onChange(e);
|
|
549
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
550
|
+
return onChange({
|
|
551
|
+
rawValues: getValues(),
|
|
552
|
+
value: e.target.value,
|
|
553
|
+
setValue: _setValue
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
var disabled = function disabled() {
|
|
560
|
+
if (typeof step.disabled === 'function') {
|
|
561
|
+
return step.disabled({
|
|
562
|
+
rawValues: getValues(),
|
|
563
|
+
value: getValues(entry)
|
|
564
|
+
});
|
|
565
|
+
} else {
|
|
566
|
+
return step.disabled;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
|
|
517
570
|
if (step.array) {
|
|
518
571
|
return /*#__PURE__*/_react["default"].createElement(ArrayStep, {
|
|
519
572
|
entry: entry,
|
|
@@ -525,12 +578,15 @@ var Step = function Step(_ref4) {
|
|
|
525
578
|
setValue: _setValue,
|
|
526
579
|
values: getValues(entry),
|
|
527
580
|
defaultValue: step.defaultValue || defaultVal(step.type),
|
|
581
|
+
getValues: getValues,
|
|
582
|
+
disabled: disabled(),
|
|
528
583
|
component: function component(props, idx) {
|
|
529
584
|
var _error$idx;
|
|
530
585
|
|
|
531
586
|
return /*#__PURE__*/_react["default"].createElement(Step, {
|
|
532
587
|
entry: "".concat(entry, "[").concat(idx, "].value"),
|
|
533
588
|
step: _objectSpread(_objectSpread({}, schema[realEntry || entry]), {}, {
|
|
589
|
+
onChange: undefined,
|
|
534
590
|
array: false
|
|
535
591
|
}),
|
|
536
592
|
error: error && ((_error$idx = error[idx]) === null || _error$idx === void 0 ? void 0 : _error$idx.value),
|
|
@@ -572,12 +628,11 @@ var Step = function Step(_ref4) {
|
|
|
572
628
|
type: "text",
|
|
573
629
|
id: entry,
|
|
574
630
|
className: (0, _classnames["default"])(classes.input, _defineProperty({}, classes.input__invalid, error)),
|
|
575
|
-
readOnly:
|
|
631
|
+
readOnly: disabled() ? 'readOnly' : null
|
|
576
632
|
}, step.props, {
|
|
577
|
-
name: entry,
|
|
578
633
|
defaultValue: defaultValue,
|
|
579
634
|
placeholder: step.placeholder
|
|
580
|
-
},
|
|
635
|
+
}, inputProps)));
|
|
581
636
|
|
|
582
637
|
case _format.format.code:
|
|
583
638
|
return /*#__PURE__*/_react["default"].createElement(_reactHookForm.Controller, {
|
|
@@ -596,8 +651,17 @@ var Step = function Step(_ref4) {
|
|
|
596
651
|
error: error
|
|
597
652
|
}, /*#__PURE__*/_react["default"].createElement(_index.CodeInput, _extends({
|
|
598
653
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
599
|
-
readOnly:
|
|
600
|
-
onChange:
|
|
654
|
+
readOnly: disabled() ? true : false,
|
|
655
|
+
onChange: function onChange(e) {
|
|
656
|
+
field.onChange(e);
|
|
657
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
658
|
+
return onChange({
|
|
659
|
+
rawValues: getValues(),
|
|
660
|
+
value: e,
|
|
661
|
+
setValue: _setValue
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
},
|
|
601
665
|
value: field.value,
|
|
602
666
|
defaultValue: defaultValue
|
|
603
667
|
}, step.props)));
|
|
@@ -621,8 +685,17 @@ var Step = function Step(_ref4) {
|
|
|
621
685
|
error: error
|
|
622
686
|
}, /*#__PURE__*/_react["default"].createElement(_index.MarkdownInput, _extends({}, step.props, {
|
|
623
687
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
624
|
-
readOnly:
|
|
625
|
-
onChange:
|
|
688
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
689
|
+
onChange: function onChange(e) {
|
|
690
|
+
field.onChange(e);
|
|
691
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
692
|
+
return onChange({
|
|
693
|
+
rawValues: getValues(),
|
|
694
|
+
value: e,
|
|
695
|
+
setValue: _setValue
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
},
|
|
626
699
|
value: field.value,
|
|
627
700
|
defaultValue: defaultValue
|
|
628
701
|
}, step)));
|
|
@@ -645,15 +718,24 @@ var Step = function Step(_ref4) {
|
|
|
645
718
|
rawValues: getValues()
|
|
646
719
|
}, field),
|
|
647
720
|
error: error
|
|
648
|
-
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, {
|
|
721
|
+
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, step, {
|
|
649
722
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
650
|
-
|
|
651
|
-
onChange: field.onChange,
|
|
723
|
+
disabled: disabled(),
|
|
652
724
|
value: field.value,
|
|
653
725
|
possibleValues: step.options,
|
|
654
726
|
defaultValue: defaultValue,
|
|
655
|
-
httpClient: httpClient
|
|
656
|
-
|
|
727
|
+
httpClient: httpClient,
|
|
728
|
+
onChange: function onChange(value) {
|
|
729
|
+
field.onChange(value);
|
|
730
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
731
|
+
return onChange({
|
|
732
|
+
rawValues: getValues(),
|
|
733
|
+
value: value,
|
|
734
|
+
setValue: _setValue
|
|
735
|
+
});
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
})));
|
|
657
739
|
}
|
|
658
740
|
});
|
|
659
741
|
|
|
@@ -674,14 +756,13 @@ var Step = function Step(_ref4) {
|
|
|
674
756
|
},
|
|
675
757
|
error: error
|
|
676
758
|
}, /*#__PURE__*/_react["default"].createElement("input", _extends({
|
|
677
|
-
// {...step.props}
|
|
678
759
|
type: step.format || 'text',
|
|
679
760
|
id: entry,
|
|
680
761
|
className: (0, _classnames["default"])(classes.input, _defineProperty({}, classes.input__invalid, error)),
|
|
681
|
-
readOnly:
|
|
682
|
-
,
|
|
762
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
763
|
+
defaultValue: defaultValue,
|
|
683
764
|
placeholder: step.placeholder
|
|
684
|
-
},
|
|
765
|
+
}, inputProps)));
|
|
685
766
|
}
|
|
686
767
|
|
|
687
768
|
case _type.type.number:
|
|
@@ -702,15 +783,24 @@ var Step = function Step(_ref4) {
|
|
|
702
783
|
rawValues: getValues()
|
|
703
784
|
}, field),
|
|
704
785
|
error: error
|
|
705
|
-
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, {
|
|
786
|
+
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, step, {
|
|
706
787
|
className: (0, _classnames["default"])(classes.content, _defineProperty({}, classes.input__invalid, error)),
|
|
707
|
-
readOnly:
|
|
708
|
-
onChange:
|
|
788
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
789
|
+
onChange: function onChange(e) {
|
|
790
|
+
field.onChange(e);
|
|
791
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
792
|
+
return onChange({
|
|
793
|
+
rawValues: getValues(),
|
|
794
|
+
value: e,
|
|
795
|
+
setValue: _setValue
|
|
796
|
+
});
|
|
797
|
+
});
|
|
798
|
+
},
|
|
709
799
|
value: field.value,
|
|
710
800
|
possibleValues: step.options,
|
|
711
801
|
defaultValue: defaultValue,
|
|
712
802
|
httpClient: httpClient
|
|
713
|
-
}
|
|
803
|
+
})));
|
|
714
804
|
}
|
|
715
805
|
});
|
|
716
806
|
|
|
@@ -732,11 +822,11 @@ var Step = function Step(_ref4) {
|
|
|
732
822
|
type: step.format || 'number',
|
|
733
823
|
id: entry,
|
|
734
824
|
className: (0, _classnames["default"])(classes.input, _defineProperty({}, classes.input__invalid, error)),
|
|
735
|
-
readOnly:
|
|
825
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
736
826
|
name: entry,
|
|
737
827
|
placeholder: step.placeholder,
|
|
738
828
|
defaultValue: defaultValue
|
|
739
|
-
},
|
|
829
|
+
}, inputProps)));
|
|
740
830
|
}
|
|
741
831
|
|
|
742
832
|
case _type.type.bool:
|
|
@@ -756,8 +846,17 @@ var Step = function Step(_ref4) {
|
|
|
756
846
|
error: error
|
|
757
847
|
}, /*#__PURE__*/_react["default"].createElement(_index.BooleanInput, _extends({}, step.props, {
|
|
758
848
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
759
|
-
readOnly:
|
|
760
|
-
onChange:
|
|
849
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
850
|
+
onChange: function onChange(e) {
|
|
851
|
+
field.onChange(e);
|
|
852
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
853
|
+
return onChange({
|
|
854
|
+
rawValues: getValues(),
|
|
855
|
+
value: e,
|
|
856
|
+
setValue: _setValue
|
|
857
|
+
});
|
|
858
|
+
});
|
|
859
|
+
},
|
|
761
860
|
value: field.value
|
|
762
861
|
})));
|
|
763
862
|
}
|
|
@@ -782,18 +881,28 @@ var Step = function Step(_ref4) {
|
|
|
782
881
|
rawValues: getValues()
|
|
783
882
|
}, field),
|
|
784
883
|
error: error
|
|
785
|
-
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, {
|
|
884
|
+
}, /*#__PURE__*/_react["default"].createElement(_index.SelectInput, _extends({}, step.props, step, {
|
|
786
885
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
787
|
-
readOnly:
|
|
788
|
-
onChange:
|
|
886
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
887
|
+
onChange: function onChange(e) {
|
|
888
|
+
field.onChange(e);
|
|
889
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
890
|
+
return onChange({
|
|
891
|
+
rawValues: getValues(),
|
|
892
|
+
value: e,
|
|
893
|
+
setValue: _setValue
|
|
894
|
+
});
|
|
895
|
+
});
|
|
896
|
+
},
|
|
789
897
|
value: field.value,
|
|
790
898
|
possibleValues: step.options,
|
|
791
899
|
httpClient: httpClient
|
|
792
|
-
}
|
|
900
|
+
})));
|
|
793
901
|
}
|
|
794
902
|
});
|
|
795
903
|
|
|
796
904
|
case _format.format.form:
|
|
905
|
+
//todo: disabled ?
|
|
797
906
|
var flow = (0, _Option.option)(step.flow).getOrElse((0, _Option.option)(step.schema).map(function (s) {
|
|
798
907
|
return Object.keys(s);
|
|
799
908
|
}).getOrNull());
|
|
@@ -840,13 +949,22 @@ var Step = function Step(_ref4) {
|
|
|
840
949
|
rawValues: getValues()
|
|
841
950
|
}, field),
|
|
842
951
|
error: error
|
|
843
|
-
}, /*#__PURE__*/_react["default"].createElement(_index.ObjectInput, _extends({}, step.props, {
|
|
952
|
+
}, /*#__PURE__*/_react["default"].createElement(_index.ObjectInput, _extends({}, step.props, step, {
|
|
844
953
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
845
|
-
readOnly:
|
|
846
|
-
onChange:
|
|
954
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
955
|
+
onChange: function onChange(e) {
|
|
956
|
+
field.onChange(e);
|
|
957
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
958
|
+
return onChange({
|
|
959
|
+
rawValues: getValues(),
|
|
960
|
+
value: e,
|
|
961
|
+
setValue: _setValue
|
|
962
|
+
});
|
|
963
|
+
});
|
|
964
|
+
},
|
|
847
965
|
value: field.value,
|
|
848
966
|
possibleValues: step.options
|
|
849
|
-
}
|
|
967
|
+
})));
|
|
850
968
|
}
|
|
851
969
|
});
|
|
852
970
|
}
|
|
@@ -870,11 +988,19 @@ var Step = function Step(_ref4) {
|
|
|
870
988
|
}, /*#__PURE__*/_react["default"].createElement(_reactRainbowComponents.DatePicker, _extends({}, step.props, {
|
|
871
989
|
id: "datePicker-1",
|
|
872
990
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
873
|
-
readOnly:
|
|
991
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
874
992
|
value: field.value,
|
|
875
|
-
onChange:
|
|
876
|
-
|
|
877
|
-
|
|
993
|
+
onChange: function onChange(e) {
|
|
994
|
+
field.onChange(e);
|
|
995
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
996
|
+
return onChange({
|
|
997
|
+
rawValues: getValues(),
|
|
998
|
+
value: e,
|
|
999
|
+
setValue: _setValue
|
|
1000
|
+
});
|
|
1001
|
+
});
|
|
1002
|
+
},
|
|
1003
|
+
formatStyle: "large"
|
|
878
1004
|
})));
|
|
879
1005
|
}
|
|
880
1006
|
});
|
|
@@ -924,7 +1050,7 @@ var Step = function Step(_ref4) {
|
|
|
924
1050
|
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
925
1051
|
type: "button",
|
|
926
1052
|
className: "".concat(classes.btn, " ").concat(classes.flex, " ").concat(classes.ai_center),
|
|
927
|
-
disabled: uploading,
|
|
1053
|
+
disabled: uploading || disabled(),
|
|
928
1054
|
onClick: trigger
|
|
929
1055
|
}, uploading && /*#__PURE__*/_react["default"].createElement(_reactFeather.Loader, null), !uploading && /*#__PURE__*/_react["default"].createElement(_reactFeather.Upload, null), /*#__PURE__*/_react["default"].createElement("span", {
|
|
930
1056
|
className: "".concat(classes.ml_5)
|
|
@@ -941,7 +1067,16 @@ var Step = function Step(_ref4) {
|
|
|
941
1067
|
}, field),
|
|
942
1068
|
error: error
|
|
943
1069
|
}, /*#__PURE__*/_react["default"].createElement(FileInput, {
|
|
944
|
-
onChange:
|
|
1070
|
+
onChange: function onChange(e) {
|
|
1071
|
+
field.onChange(e);
|
|
1072
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
1073
|
+
return onChange({
|
|
1074
|
+
rawValues: getValues(),
|
|
1075
|
+
value: e,
|
|
1076
|
+
setValue: _setValue
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
},
|
|
945
1080
|
error: error
|
|
946
1081
|
}));
|
|
947
1082
|
}
|
|
@@ -967,10 +1102,10 @@ var Step = function Step(_ref4) {
|
|
|
967
1102
|
type: "file",
|
|
968
1103
|
id: entry,
|
|
969
1104
|
className: (0, _classnames["default"])(classes.input, _defineProperty({}, classes.input__invalid, error)),
|
|
970
|
-
readOnly:
|
|
1105
|
+
readOnly: disabled() ? 'readOnly' : null,
|
|
971
1106
|
name: entry,
|
|
972
1107
|
placeholder: step.placeholder
|
|
973
|
-
},
|
|
1108
|
+
}, inputProps)));
|
|
974
1109
|
|
|
975
1110
|
default:
|
|
976
1111
|
return null;
|
|
@@ -987,7 +1122,9 @@ var ArrayStep = function ArrayStep(_ref15) {
|
|
|
987
1122
|
component = _ref15.component,
|
|
988
1123
|
values = _ref15.values,
|
|
989
1124
|
defaultValue = _ref15.defaultValue,
|
|
990
|
-
setValue = _ref15.setValue
|
|
1125
|
+
setValue = _ref15.setValue,
|
|
1126
|
+
getValues = _ref15.getValues,
|
|
1127
|
+
disabled = _ref15.disabled;
|
|
991
1128
|
var classes = (0, _styleContext.useCustomStyle)();
|
|
992
1129
|
|
|
993
1130
|
var _useFieldArray = (0, _reactHookForm.useFieldArray)({
|
|
@@ -1015,6 +1152,7 @@ var ArrayStep = function ArrayStep(_ref15) {
|
|
|
1015
1152
|
className: "input-group-append"
|
|
1016
1153
|
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
1017
1154
|
className: "btn btn-danger btn-sm",
|
|
1155
|
+
disabled: disabled,
|
|
1018
1156
|
onClick: function onClick() {
|
|
1019
1157
|
remove(idx);
|
|
1020
1158
|
trigger(entry);
|
|
@@ -1025,10 +1163,18 @@ var ArrayStep = function ArrayStep(_ref15) {
|
|
|
1025
1163
|
className: (0, _classnames["default"])("btn btn-info mt-2", _defineProperty({}, classes.input__invalid, error)),
|
|
1026
1164
|
onClick: function onClick() {
|
|
1027
1165
|
append({
|
|
1028
|
-
value: step.addableDefaultValue
|
|
1166
|
+
value: step.addableDefaultValue || defaultVal(step.type)
|
|
1029
1167
|
});
|
|
1030
1168
|
trigger(entry);
|
|
1169
|
+
(0, _Option.option)(step.onChange).map(function (onChange) {
|
|
1170
|
+
return onChange({
|
|
1171
|
+
rawValues: getValues(),
|
|
1172
|
+
value: getValues(entry),
|
|
1173
|
+
setValue: setValue
|
|
1174
|
+
});
|
|
1175
|
+
});
|
|
1031
1176
|
},
|
|
1177
|
+
disabled: disabled,
|
|
1032
1178
|
value: "Add"
|
|
1033
1179
|
}), error && /*#__PURE__*/_react["default"].createElement("div", {
|
|
1034
1180
|
className: "invalid-feedback"
|
|
@@ -1092,14 +1238,38 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1092
1238
|
});
|
|
1093
1239
|
}
|
|
1094
1240
|
}, [prevSchema, schemaAndFlow.schema]);
|
|
1241
|
+
var computedSandF = schemaAndFlow.flow.reduce(function (acc, entry) {
|
|
1242
|
+
var step = schemaAndFlow.schema[entry];
|
|
1243
|
+
var visibleStep = (0, _Option.option)(step).map(function (s) {
|
|
1244
|
+
return s.visible;
|
|
1245
|
+
}).map(function (visible) {
|
|
1246
|
+
switch (_typeof(visible)) {
|
|
1247
|
+
case 'object':
|
|
1248
|
+
var _value2 = watch(visible.ref);
|
|
1249
|
+
|
|
1250
|
+
return (0, _Option.option)(visible.test).map(function (test) {
|
|
1251
|
+
return test(_value2);
|
|
1252
|
+
}).getOrElse(_value2);
|
|
1253
|
+
|
|
1254
|
+
case 'boolean':
|
|
1255
|
+
return visible;
|
|
1256
|
+
|
|
1257
|
+
default:
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
}).getOrElse(true);
|
|
1261
|
+
return [].concat(_toConsumableArray(acc), [{
|
|
1262
|
+
step: step,
|
|
1263
|
+
visibleStep: visibleStep,
|
|
1264
|
+
entry: entry
|
|
1265
|
+
}]);
|
|
1266
|
+
}, []);
|
|
1267
|
+
var bordered = computedSandF.filter(function (x) {
|
|
1268
|
+
return x.visibleStep;
|
|
1269
|
+
}).length <= 1 && step.label === null;
|
|
1095
1270
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
paddingLeft: '1rem',
|
|
1099
|
-
marginBottom: '.5rem',
|
|
1100
|
-
position: 'relative'
|
|
1101
|
-
}
|
|
1102
|
-
}, collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowDown, {
|
|
1271
|
+
className: (0, _classnames["default"])(_defineProperty({}, classes.nestedform__border, bordered))
|
|
1272
|
+
}, !!step.collapsable && schemaAndFlow.flow.length > 1 && collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowDown, {
|
|
1103
1273
|
size: 30,
|
|
1104
1274
|
className: classes.cursor_pointer,
|
|
1105
1275
|
style: {
|
|
@@ -1111,7 +1281,7 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1111
1281
|
onClick: function onClick() {
|
|
1112
1282
|
return setCollapsed(!collapsed);
|
|
1113
1283
|
}
|
|
1114
|
-
}), !collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowUp, {
|
|
1284
|
+
}), !!step.collapsable && schemaAndFlow.flow.length > 1 && !collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowUp, {
|
|
1115
1285
|
size: 30,
|
|
1116
1286
|
className: classes.cursor_pointer,
|
|
1117
1287
|
style: {
|
|
@@ -1119,29 +1289,28 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1119
1289
|
top: '5px',
|
|
1120
1290
|
left: '-16px'
|
|
1121
1291
|
},
|
|
1122
|
-
"
|
|
1292
|
+
"strok-width": "3",
|
|
1123
1293
|
onClick: function onClick() {
|
|
1124
1294
|
return setCollapsed(!collapsed);
|
|
1125
1295
|
}
|
|
1126
|
-
}),
|
|
1127
|
-
var
|
|
1296
|
+
}), computedSandF.map(function (_ref17, idx) {
|
|
1297
|
+
var step = _ref17.step,
|
|
1298
|
+
visibleStep = _ref17.visibleStep,
|
|
1299
|
+
entry = _ref17.entry;
|
|
1300
|
+
|
|
1301
|
+
if (!step && typeof entry === 'string') {
|
|
1302
|
+
console.error("no step found for the entry \"".concat(entry, "\" in the given schema. Your form might not work properly. Please fix it"));
|
|
1303
|
+
return null;
|
|
1304
|
+
}
|
|
1128
1305
|
|
|
1129
|
-
var step = schemaAndFlow.schema[entry];
|
|
1130
1306
|
var realError = error && error[entry];
|
|
1131
|
-
|
|
1132
|
-
schema: schema,
|
|
1133
|
-
entry: entry,
|
|
1134
|
-
result: (0, _Option.option)((_schemaAndFlow$schema = schemaAndFlow.schema) === null || _schemaAndFlow$schema === void 0 ? void 0 : _schemaAndFlow$schema.collapseField).map(function (f) {
|
|
1135
|
-
return f === entry;
|
|
1136
|
-
}).getOrElse(idx > 0)
|
|
1137
|
-
});
|
|
1138
|
-
var oneVisibleSetup = Object.values(schema).some(function (v) {
|
|
1307
|
+
var oneVisibleSetup = Object.values(schemaAndFlow.schema).some(function (v) {
|
|
1139
1308
|
return !!v.visibleOnCollapse;
|
|
1140
1309
|
});
|
|
1141
1310
|
var isCollapsed = collapsed && (oneVisibleSetup ? !step.visibleOnCollapse : idx > 0);
|
|
1142
1311
|
return /*#__PURE__*/_react["default"].createElement(BasicWrapper, {
|
|
1143
1312
|
key: "".concat(entry, ".").concat(idx),
|
|
1144
|
-
className: (0, _classnames["default"])(_defineProperty({}, classes.display__none, isCollapsed)),
|
|
1313
|
+
className: (0, _classnames["default"])(_defineProperty({}, classes.display__none, isCollapsed || !visibleStep)),
|
|
1145
1314
|
entry: "".concat(parent, ".").concat(entry),
|
|
1146
1315
|
error: realError,
|
|
1147
1316
|
label: (step === null || step === void 0 ? void 0 : step.label) === null ? null : (step === null || step === void 0 ? void 0 : step.label) || entry,
|
package/lib/inputs/Collapse.js
CHANGED
|
@@ -66,7 +66,7 @@ var Collapse = function Collapse(props) {
|
|
|
66
66
|
}), !collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.EyeOff, {
|
|
67
67
|
size: 16
|
|
68
68
|
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
69
|
-
className: (0, _classnames["default"])(classes.ml_10, (_classNames4 = {}, _defineProperty(_classNames4, classes.display__none, !!collapsed), _defineProperty(_classNames4, classes.flex, !!props.inline), _classNames4))
|
|
69
|
+
className: (0, _classnames["default"])("".concat(classes.ml_10), (_classNames4 = {}, _defineProperty(_classNames4, classes.display__none, !!collapsed), _defineProperty(_classNames4, classes.flex, !!props.inline), _defineProperty(_classNames4, classes.collapse__inline, !!props.inline), _classNames4))
|
|
70
70
|
}, props.children), props.lineEnd && /*#__PURE__*/_react["default"].createElement("hr", null));
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -189,6 +189,7 @@ var SelectInput = function SelectInput(props) {
|
|
|
189
189
|
return /*#__PURE__*/_react["default"].createElement("button", {
|
|
190
190
|
key: idx,
|
|
191
191
|
type: "button",
|
|
192
|
+
disabled: props.disabled,
|
|
192
193
|
className: (0, _classnames["default"])(props.className, classes.btn, classes.btn_grey, classes.ml_5, {
|
|
193
194
|
active: active
|
|
194
195
|
}),
|
|
@@ -213,7 +214,8 @@ var SelectInput = function SelectInput(props) {
|
|
|
213
214
|
return handleCreate(option, props.onCreateOption);
|
|
214
215
|
},
|
|
215
216
|
classNamePrefix: "react-form-select",
|
|
216
|
-
className: props.className
|
|
217
|
+
className: props.className,
|
|
218
|
+
readOnly: props.disabled ? 'readOnly' : null
|
|
217
219
|
}));
|
|
218
220
|
} else {
|
|
219
221
|
return /*#__PURE__*/_react["default"].createElement(_reactSelect["default"], _extends({}, props, {
|
|
@@ -225,7 +227,8 @@ var SelectInput = function SelectInput(props) {
|
|
|
225
227
|
options: values,
|
|
226
228
|
onChange: onChange,
|
|
227
229
|
classNamePrefix: "react-form-select",
|
|
228
|
-
className: props.className
|
|
230
|
+
className: props.className,
|
|
231
|
+
readOnly: props.disabled ? 'readOnly' : null
|
|
229
232
|
}));
|
|
230
233
|
}
|
|
231
234
|
};
|
package/lib/style.d.ts
CHANGED
|
@@ -211,9 +211,16 @@ export namespace style {
|
|
|
211
211
|
const display_3: string;
|
|
212
212
|
export { display_3 as display };
|
|
213
213
|
}
|
|
214
|
-
const
|
|
215
|
-
"
|
|
214
|
+
const collapse__inline: {
|
|
215
|
+
"& .form-group+.form-group": {
|
|
216
216
|
marginLeft: string;
|
|
217
217
|
};
|
|
218
218
|
};
|
|
219
|
+
namespace nestedform__border {
|
|
220
|
+
export const borderLeft: string;
|
|
221
|
+
export const paddingLeft: string;
|
|
222
|
+
const marginBottom_1: string;
|
|
223
|
+
export { marginBottom_1 as marginBottom };
|
|
224
|
+
export const position: string;
|
|
225
|
+
}
|
|
219
226
|
}
|
package/lib/style.js
CHANGED
|
@@ -159,9 +159,14 @@ var style = (_style = {
|
|
|
159
159
|
color: "#dc3545"
|
|
160
160
|
}), _defineProperty(_style, "display__none", {
|
|
161
161
|
display: "none"
|
|
162
|
-
}), _defineProperty(_style, "
|
|
163
|
-
"
|
|
162
|
+
}), _defineProperty(_style, "collapse__inline", {
|
|
163
|
+
"& .form-group+.form-group": {
|
|
164
164
|
marginLeft: '20px'
|
|
165
165
|
}
|
|
166
|
+
}), _defineProperty(_style, "nestedform__border", {
|
|
167
|
+
borderLeft: '2px solid lightGray',
|
|
168
|
+
paddingLeft: '1rem',
|
|
169
|
+
marginBottom: '.5rem',
|
|
170
|
+
position: 'relative'
|
|
166
171
|
}), _style);
|
|
167
172
|
exports.style = style;
|
package/lib/styleContext.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function useCustomStyle(overrideStyle?: {}): import("jss").Classes<"code" | "flex" | "input" | "btn" | "btn_sm" | "btn_group" | "btn_red" | "btn_green" | "btn_blue" | "btn_grey" | "txt_red" | "ml_5" | "ml_10" | "mr_5" | "mr_10" | "mt_5" | "mt_10" | "mt_20" | "mb_5" | "p_15" | "pr_15" | "full_width" | "d_none" | "flexColumn" | "justifyContentBetween" | "jc_end" | "ac_center" | "ai_center" | "cursor_pointer" | "collapse" | "collapse_label" | "collapse_error" | "datepicker" | "input__boolean__on" | "input__boolean__off" | "input__invalid" | "invalid_feedback" | "display__none" | "
|
|
1
|
+
export function useCustomStyle(overrideStyle?: {}): import("jss").Classes<"code" | "flex" | "input" | "btn" | "btn_sm" | "btn_group" | "btn_red" | "btn_green" | "btn_blue" | "btn_grey" | "txt_red" | "ml_5" | "ml_10" | "mr_5" | "mr_10" | "mt_5" | "mt_10" | "mt_20" | "mb_5" | "p_15" | "pr_15" | "full_width" | "d_none" | "flexColumn" | "justifyContentBetween" | "jc_end" | "ac_center" | "ai_center" | "cursor_pointer" | "collapse" | "collapse_label" | "collapse_error" | "datepicker" | "input__boolean__on" | "input__boolean__off" | "input__invalid" | "invalid_feedback" | "display__none" | "collapse__inline" | "nestedform__border">;
|