@maif/react-forms 1.0.12 → 1.0.16
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 +3 -3
- package/dist/react-form.js +1 -1
- package/lib/form.js +35 -9
- package/lib/inputs/CodeInput.js +6 -2
- package/lib/inputs/SelectInput.js +2 -2
- package/lib/style.d.ts +5 -1
- package/lib/style.js +3 -0
- package/lib/styleContext.d.ts +1 -1
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -69,7 +69,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
69
69
|
var ref = (0, _react.useRef)(); // Store current value in ref
|
|
70
70
|
|
|
71
71
|
(0, _react.useEffect)(function () {
|
|
72
|
-
ref.current = value;
|
|
72
|
+
ref.current = JSON.parse(JSON.stringify(value));
|
|
73
73
|
}, [value]); // Only re-run if value changes
|
|
74
74
|
// Return previous value (happens before update in useEffect above)
|
|
75
75
|
|
|
@@ -102,7 +102,7 @@ var BasicWrapper = function BasicWrapper(_ref) {
|
|
|
102
102
|
|
|
103
103
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
104
104
|
className: "form-group mt-3"
|
|
105
|
-
}, /*#__PURE__*/_react["default"].createElement("label", {
|
|
105
|
+
}, label && /*#__PURE__*/_react["default"].createElement("label", {
|
|
106
106
|
className: "form-label d-flex align-content-center",
|
|
107
107
|
htmlFor: entry
|
|
108
108
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
@@ -314,7 +314,9 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
314
314
|
}, [data]);
|
|
315
315
|
|
|
316
316
|
if (options.watch) {
|
|
317
|
+
console.group('react-form watch');
|
|
317
318
|
console.log(watch());
|
|
319
|
+
console.groupEnd();
|
|
318
320
|
}
|
|
319
321
|
|
|
320
322
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
@@ -328,7 +330,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
328
330
|
};
|
|
329
331
|
});
|
|
330
332
|
return /*#__PURE__*/_react["default"].createElement(_reactHookForm.FormProvider, methods, /*#__PURE__*/_react["default"].createElement("form", {
|
|
331
|
-
className: className || classes.pr_15,
|
|
333
|
+
className: className || "".concat(classes.pr_15, " ").concat(classes.full_width),
|
|
332
334
|
onSubmit: _handleSubmit(function (data) {
|
|
333
335
|
var clean = cleanOutputArray(data);
|
|
334
336
|
onSubmit(clean);
|
|
@@ -365,7 +367,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
365
367
|
key: "".concat(entry, "-").concat(idx),
|
|
366
368
|
entry: entry,
|
|
367
369
|
error: error,
|
|
368
|
-
label: (step === null || step === void 0 ? void 0 : step.label) || entry,
|
|
370
|
+
label: (step === null || step === void 0 ? void 0 : step.label) === null ? null : (step === null || step === void 0 ? void 0 : step.label) || entry,
|
|
369
371
|
help: step === null || step === void 0 ? void 0 : step.help,
|
|
370
372
|
render: inputWrapper
|
|
371
373
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
|
@@ -454,11 +456,33 @@ var Step = function Step(_ref4) {
|
|
|
454
456
|
var err = _typeof(en) === 'object' ? undefined : en.split('.').reduce(function (object, key) {
|
|
455
457
|
return object && object[key];
|
|
456
458
|
}, errors);
|
|
459
|
+
var visibleStep = (0, _Option.option)(stp).map(function (s) {
|
|
460
|
+
return s.visible;
|
|
461
|
+
}).map(function (visible) {
|
|
462
|
+
switch (_typeof(visible)) {
|
|
463
|
+
case 'object':
|
|
464
|
+
var value = watch(visible.ref);
|
|
465
|
+
return (0, _Option.option)(visible.test).map(function (test) {
|
|
466
|
+
return test(value);
|
|
467
|
+
}).getOrElse(value);
|
|
468
|
+
|
|
469
|
+
case 'boolean':
|
|
470
|
+
return visible;
|
|
471
|
+
|
|
472
|
+
default:
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
}).getOrElse(true);
|
|
476
|
+
|
|
477
|
+
if (!visibleStep) {
|
|
478
|
+
return null;
|
|
479
|
+
}
|
|
480
|
+
|
|
457
481
|
return /*#__PURE__*/_react["default"].createElement(BasicWrapper, {
|
|
458
482
|
key: "collapse-".concat(en, "-").concat(entryIdx),
|
|
459
483
|
entry: en,
|
|
460
484
|
error: err,
|
|
461
|
-
label: (stp === null || stp === void 0 ? void 0 : stp.label) || en,
|
|
485
|
+
label: (stp === null || stp === void 0 ? void 0 : stp.label) === null ? null : (stp === null || stp === void 0 ? void 0 : stp.label) || en,
|
|
462
486
|
help: stp === null || stp === void 0 ? void 0 : stp.help,
|
|
463
487
|
render: inputWrapper
|
|
464
488
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
|
@@ -473,7 +497,9 @@ var Step = function Step(_ref4) {
|
|
|
473
497
|
getValues: getValues,
|
|
474
498
|
setValue: _setValue,
|
|
475
499
|
watch: watch,
|
|
476
|
-
inputWrapper: inputWrapper
|
|
500
|
+
inputWrapper: inputWrapper,
|
|
501
|
+
httpClient: httpClient,
|
|
502
|
+
defaultValue: stp.defaultValue
|
|
477
503
|
}));
|
|
478
504
|
}));
|
|
479
505
|
}
|
|
@@ -558,13 +584,13 @@ var Step = function Step(_ref4) {
|
|
|
558
584
|
rawValues: getValues()
|
|
559
585
|
}, field),
|
|
560
586
|
error: error
|
|
561
|
-
}, /*#__PURE__*/_react["default"].createElement(_index.CodeInput, _extends({
|
|
587
|
+
}, /*#__PURE__*/_react["default"].createElement(_index.CodeInput, _extends({
|
|
562
588
|
className: (0, _classnames["default"])(_defineProperty({}, classes.input__invalid, error)),
|
|
563
589
|
readOnly: step.disabled ? 'readOnly' : null,
|
|
564
590
|
onChange: field.onChange,
|
|
565
591
|
value: field.value,
|
|
566
592
|
defaultValue: defaultValue
|
|
567
|
-
}, step)));
|
|
593
|
+
}, step.props)));
|
|
568
594
|
}
|
|
569
595
|
});
|
|
570
596
|
|
|
@@ -1063,7 +1089,7 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1063
1089
|
key: "".concat(entry, ".").concat(idx),
|
|
1064
1090
|
entry: "".concat(parent, ".").concat(entry),
|
|
1065
1091
|
error: realError,
|
|
1066
|
-
label: step.label || entry,
|
|
1092
|
+
label: (step === null || step === void 0 ? void 0 : step.label) === null ? null : (step === null || step === void 0 ? void 0 : step.label) || entry,
|
|
1067
1093
|
help: step.help,
|
|
1068
1094
|
render: inputWrapper
|
|
1069
1095
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
package/lib/inputs/CodeInput.js
CHANGED
|
@@ -33,6 +33,8 @@ var _excluded = ["onChange", "value", "className", "readOnly", "theme", "mode"];
|
|
|
33
33
|
|
|
34
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
35
|
|
|
36
|
+
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); }
|
|
37
|
+
|
|
36
38
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
37
39
|
|
|
38
40
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -49,7 +51,7 @@ var CodeInput = function CodeInput(_ref) {
|
|
|
49
51
|
mode = _ref$mode === void 0 ? 'javascript' : _ref$mode,
|
|
50
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
51
53
|
|
|
52
|
-
return /*#__PURE__*/_react["default"].createElement(_reactAce["default"], {
|
|
54
|
+
return /*#__PURE__*/_react["default"].createElement(_reactAce["default"], _extends({
|
|
53
55
|
commands: _extBeautify["default"].commands,
|
|
54
56
|
className: className,
|
|
55
57
|
readOnly: readOnly,
|
|
@@ -79,7 +81,9 @@ var CodeInput = function CodeInput(_ref) {
|
|
|
79
81
|
highlightActiveLine: true,
|
|
80
82
|
enableBasicAutocompletion: true,
|
|
81
83
|
enableLiveAutocompletion: true
|
|
82
|
-
}
|
|
84
|
+
}, props, {
|
|
85
|
+
ref: props.setRef
|
|
86
|
+
}));
|
|
83
87
|
};
|
|
84
88
|
|
|
85
89
|
exports.CodeInput = CodeInput;
|
|
@@ -74,10 +74,10 @@ var valueToSelectOption = function valueToSelectOption(value) {
|
|
|
74
74
|
return maybeValue.getOrElse({
|
|
75
75
|
label: maybeValue.map(function (v) {
|
|
76
76
|
return v.label;
|
|
77
|
-
}).getOrElse(value),
|
|
77
|
+
}).getOrElse((value === null || value === void 0 ? void 0 : value.label) || value),
|
|
78
78
|
value: maybeValue.map(function (v) {
|
|
79
79
|
return v.value;
|
|
80
|
-
}).getOrElse(value)
|
|
80
|
+
}).getOrElse((value === null || value === void 0 ? void 0 : value.value) || value)
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
83
|
|
package/lib/style.d.ts
CHANGED
|
@@ -123,6 +123,9 @@ export namespace style {
|
|
|
123
123
|
namespace pr_15 {
|
|
124
124
|
const paddingRight: number;
|
|
125
125
|
}
|
|
126
|
+
namespace full_width {
|
|
127
|
+
const width: string;
|
|
128
|
+
}
|
|
126
129
|
namespace d_none {
|
|
127
130
|
const display: string;
|
|
128
131
|
}
|
|
@@ -185,7 +188,8 @@ export namespace style {
|
|
|
185
188
|
const borderColor: string;
|
|
186
189
|
}
|
|
187
190
|
namespace invalid_feedback {
|
|
188
|
-
|
|
191
|
+
const width_1: string;
|
|
192
|
+
export { width_1 as width };
|
|
189
193
|
const marginTop_4: string;
|
|
190
194
|
export { marginTop_4 as marginTop };
|
|
191
195
|
const fontSize_2: string;
|
package/lib/style.js
CHANGED
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" | "mt_5" | "mt_10" | "mt_20" | "mb_5" | "p_15" | "pr_15" | "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">;
|
|
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" | "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">;
|