@maif/react-forms 1.0.18 → 1.0.22
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 -2
- package/dist/react-form.js +1 -1
- package/lib/form.js +98 -31
- package/lib/inputs/Collapse.js +9 -3
- package/lib/inputs/SelectInput.js +3 -2
- package/lib/style.d.ts +19 -0
- package/lib/style.js +15 -1
- package/lib/styleContext.d.ts +1 -1
- package/lib/utils.d.ts +1 -0
- package/lib/utils.js +8 -2
- package/package.json +1 -1
package/lib/form.js
CHANGED
|
@@ -78,6 +78,7 @@ var usePrevious = function usePrevious(value) {
|
|
|
78
78
|
|
|
79
79
|
var BasicWrapper = function BasicWrapper(_ref) {
|
|
80
80
|
var entry = _ref.entry,
|
|
81
|
+
className = _ref.className,
|
|
81
82
|
label = _ref.label,
|
|
82
83
|
error = _ref.error,
|
|
83
84
|
help = _ref.help,
|
|
@@ -101,7 +102,7 @@ var BasicWrapper = function BasicWrapper(_ref) {
|
|
|
101
102
|
}
|
|
102
103
|
|
|
103
104
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
104
|
-
className: "form-group mt-3"
|
|
105
|
+
className: "form-group mt-3 ".concat(className)
|
|
105
106
|
}, label && /*#__PURE__*/_react["default"].createElement("label", {
|
|
106
107
|
className: "form-label d-flex align-content-center",
|
|
107
108
|
htmlFor: entry
|
|
@@ -238,9 +239,9 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
238
239
|
|
|
239
240
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
240
241
|
} else if (!!v && _typeof(v) === 'object') {
|
|
241
|
-
var
|
|
242
|
+
var _subSchema$key;
|
|
242
243
|
|
|
243
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanInputArray(v, ((
|
|
244
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanInputArray(v, ((_subSchema$key = subSchema[key]) === null || _subSchema$key === void 0 ? void 0 : _subSchema$key.schema) || {})));
|
|
244
245
|
} else {
|
|
245
246
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
246
247
|
}
|
|
@@ -269,9 +270,9 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
269
270
|
|
|
270
271
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
271
272
|
} else if (!!v && _typeof(v) === 'object') {
|
|
272
|
-
var
|
|
273
|
+
var _subSchema$key2;
|
|
273
274
|
|
|
274
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanOutputArray(v, ((
|
|
275
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, cleanOutputArray(v, ((_subSchema$key2 = subSchema[key]) === null || _subSchema$key2 === void 0 ? void 0 : _subSchema$key2.schema) || {})));
|
|
275
276
|
} else {
|
|
276
277
|
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, v));
|
|
277
278
|
}
|
|
@@ -282,7 +283,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
282
283
|
resolver: function resolver(data, context, options) {
|
|
283
284
|
return (0, _yup.yupResolver)(_resolver(data))(data, context, options);
|
|
284
285
|
},
|
|
285
|
-
defaultValues: cleanInputArray(value || defaultValues),
|
|
286
|
+
defaultValues: cleanInputArray(value || defaultValues, schema),
|
|
286
287
|
shouldFocusError: !options.autosubmit
|
|
287
288
|
});
|
|
288
289
|
var register = methods.register,
|
|
@@ -296,11 +297,11 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
296
297
|
setValue = methods.setValue;
|
|
297
298
|
(0, _react.useEffect)(function () {
|
|
298
299
|
if (value) {
|
|
299
|
-
_reset(cleanInputArray(value));
|
|
300
|
+
_reset(cleanInputArray(value, schema));
|
|
300
301
|
}
|
|
301
302
|
}, [value, _reset]);
|
|
302
303
|
(0, _react.useEffect)(function () {
|
|
303
|
-
_reset(cleanInputArray(value || defaultValues));
|
|
304
|
+
_reset(cleanInputArray(value || defaultValues, schema));
|
|
304
305
|
}, [schema]);
|
|
305
306
|
var data = watch();
|
|
306
307
|
var prevData = usePrevious(data);
|
|
@@ -308,23 +309,27 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
308
309
|
//todo: with debounce
|
|
309
310
|
if (!!options.autosubmit && JSON.stringify(data) !== JSON.stringify(prevData)) {
|
|
310
311
|
_handleSubmit(function (data) {
|
|
311
|
-
var clean = cleanOutputArray(data);
|
|
312
|
+
var clean = cleanOutputArray(data, schema);
|
|
312
313
|
onSubmit(clean);
|
|
313
314
|
}, onError)();
|
|
314
315
|
}
|
|
315
316
|
}, [data]);
|
|
316
317
|
|
|
317
318
|
if (options.watch) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
if (typeof options.watch === 'function') {
|
|
320
|
+
options.watch(watch());
|
|
321
|
+
} else {
|
|
322
|
+
console.group('react-form watch');
|
|
323
|
+
console.log(watch());
|
|
324
|
+
console.groupEnd();
|
|
325
|
+
}
|
|
321
326
|
}
|
|
322
327
|
|
|
323
328
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
324
329
|
return {
|
|
325
330
|
handleSubmit: function handleSubmit() {
|
|
326
331
|
return _handleSubmit(function (data) {
|
|
327
|
-
var clean = cleanOutputArray(data);
|
|
332
|
+
var clean = cleanOutputArray(data, schema);
|
|
328
333
|
onSubmit(clean);
|
|
329
334
|
}, onError)();
|
|
330
335
|
}
|
|
@@ -333,7 +338,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
333
338
|
return /*#__PURE__*/_react["default"].createElement(_reactHookForm.FormProvider, methods, /*#__PURE__*/_react["default"].createElement("form", {
|
|
334
339
|
className: className || "".concat(classes.pr_15, " ").concat(classes.full_width),
|
|
335
340
|
onSubmit: _handleSubmit(function (data) {
|
|
336
|
-
var clean = cleanOutputArray(data);
|
|
341
|
+
var clean = cleanOutputArray(data, schema);
|
|
337
342
|
onSubmit(clean);
|
|
338
343
|
}, onError)
|
|
339
344
|
}, formFlow.map(function (entry, idx) {
|
|
@@ -393,7 +398,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
393
398
|
return _reset(defaultValues);
|
|
394
399
|
},
|
|
395
400
|
valid: _handleSubmit(function (data) {
|
|
396
|
-
return onSubmit(cleanOutputArray(data));
|
|
401
|
+
return onSubmit(cleanOutputArray(data, schema));
|
|
397
402
|
}, onError),
|
|
398
403
|
actions: options.actions
|
|
399
404
|
})));
|
|
@@ -402,7 +407,7 @@ var Form = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
402
407
|
exports.Form = Form;
|
|
403
408
|
|
|
404
409
|
var Footer = function Footer(props) {
|
|
405
|
-
var _props$actions, _props$actions$submit, _props$actions2, _props$actions2$submi, _props$actions3, _props$actions3$reset, _props$
|
|
410
|
+
var _props$actions, _props$actions$submit, _props$actions2, _props$actions2$submi, _props$actions3, _props$actions3$cance, _props$actions5, _props$actions5$cance, _props$actions6, _props$actions6$reset, _props$actions7, _props$actions7$reset, _props$actions8, _props$actions8$submi;
|
|
406
411
|
|
|
407
412
|
var classes = (0, _styleContext.useCustomStyle)();
|
|
408
413
|
|
|
@@ -416,18 +421,27 @@ var Footer = function Footer(props) {
|
|
|
416
421
|
var isSubmitDisplayed = ((_props$actions = props.actions) === null || _props$actions === void 0 ? void 0 : (_props$actions$submit = _props$actions.submit) === null || _props$actions$submit === void 0 ? void 0 : _props$actions$submit.display) === undefined ? true : !!((_props$actions2 = props.actions) !== null && _props$actions2 !== void 0 && (_props$actions2$submi = _props$actions2.submit) !== null && _props$actions2$submi !== void 0 && _props$actions2$submi.display);
|
|
417
422
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
418
423
|
className: "".concat(classes.flex, " ").concat(classes.jc_end, " ").concat(classes.mt_5)
|
|
419
|
-
}, ((_props$actions3 = props.actions) === null || _props$actions3 === void 0 ? void 0 : (_props$actions3$
|
|
424
|
+
}, ((_props$actions3 = props.actions) === null || _props$actions3 === void 0 ? void 0 : (_props$actions3$cance = _props$actions3.cancel) === null || _props$actions3$cance === void 0 ? void 0 : _props$actions3$cance.display) && /*#__PURE__*/_react["default"].createElement("button", {
|
|
425
|
+
className: "".concat(classes.btn, " ").concat(classes.btn_red),
|
|
426
|
+
type: "button",
|
|
427
|
+
onClick: function onClick() {
|
|
428
|
+
var _props$actions4;
|
|
429
|
+
|
|
430
|
+
return (_props$actions4 = props.actions) === null || _props$actions4 === void 0 ? void 0 : _props$actions4.cancel.action();
|
|
431
|
+
}
|
|
432
|
+
}, ((_props$actions5 = props.actions) === null || _props$actions5 === void 0 ? void 0 : (_props$actions5$cance = _props$actions5.cancel) === null || _props$actions5$cance === void 0 ? void 0 : _props$actions5$cance.label) || 'Cancel'), ((_props$actions6 = props.actions) === null || _props$actions6 === void 0 ? void 0 : (_props$actions6$reset = _props$actions6.reset) === null || _props$actions6$reset === void 0 ? void 0 : _props$actions6$reset.display) && /*#__PURE__*/_react["default"].createElement("button", {
|
|
420
433
|
className: "".concat(classes.btn, " ").concat(classes.btn_red),
|
|
421
434
|
type: "button",
|
|
422
435
|
onClick: props.reset
|
|
423
|
-
}, ((_props$
|
|
436
|
+
}, ((_props$actions7 = props.actions) === null || _props$actions7 === void 0 ? void 0 : (_props$actions7$reset = _props$actions7.reset) === null || _props$actions7$reset === void 0 ? void 0 : _props$actions7$reset.label) || 'Reset'), isSubmitDisplayed && /*#__PURE__*/_react["default"].createElement("button", {
|
|
424
437
|
className: "".concat(classes.btn, " ").concat(classes.btn_green, " ").concat(classes.ml_10),
|
|
425
438
|
type: "submit"
|
|
426
|
-
}, ((_props$
|
|
439
|
+
}, ((_props$actions8 = props.actions) === null || _props$actions8 === void 0 ? void 0 : (_props$actions8$submi = _props$actions8.submit) === null || _props$actions8$submi === void 0 ? void 0 : _props$actions8$submi.label) || 'Save'));
|
|
427
440
|
};
|
|
428
441
|
|
|
429
442
|
var Step = function Step(_ref4) {
|
|
430
443
|
var entry = _ref4.entry,
|
|
444
|
+
realEntry = _ref4.realEntry,
|
|
431
445
|
step = _ref4.step,
|
|
432
446
|
error = _ref4.error,
|
|
433
447
|
errors = _ref4.errors,
|
|
@@ -448,11 +462,9 @@ var Step = function Step(_ref4) {
|
|
|
448
462
|
var errored = entry.flow.some(function (step) {
|
|
449
463
|
return !!errors[step];
|
|
450
464
|
});
|
|
451
|
-
return /*#__PURE__*/_react["default"].createElement(_index.Collapse, {
|
|
452
|
-
label: entry.label,
|
|
453
|
-
collapsed: entry.collapsed,
|
|
465
|
+
return /*#__PURE__*/_react["default"].createElement(_index.Collapse, _extends({}, entry, {
|
|
454
466
|
errored: errored
|
|
455
|
-
}, entry.flow.map(function (en, entryIdx) {
|
|
467
|
+
}), entry.flow.map(function (en, entryIdx) {
|
|
456
468
|
var stp = schema[en];
|
|
457
469
|
var err = _typeof(en) === 'object' ? undefined : en.split('.').reduce(function (object, key) {
|
|
458
470
|
return object && object[key];
|
|
@@ -500,7 +512,7 @@ var Step = function Step(_ref4) {
|
|
|
500
512
|
watch: watch,
|
|
501
513
|
inputWrapper: inputWrapper,
|
|
502
514
|
httpClient: httpClient,
|
|
503
|
-
defaultValue: stp.defaultValue
|
|
515
|
+
defaultValue: stp === null || stp === void 0 ? void 0 : stp.defaultValue
|
|
504
516
|
}));
|
|
505
517
|
}));
|
|
506
518
|
}
|
|
@@ -521,7 +533,7 @@ var Step = function Step(_ref4) {
|
|
|
521
533
|
|
|
522
534
|
return /*#__PURE__*/_react["default"].createElement(Step, {
|
|
523
535
|
entry: "".concat(entry, "[").concat(idx, "].value"),
|
|
524
|
-
step: _objectSpread(_objectSpread({}, schema[entry]), {}, {
|
|
536
|
+
step: _objectSpread(_objectSpread({}, schema[realEntry || entry]), {}, {
|
|
525
537
|
array: false
|
|
526
538
|
}),
|
|
527
539
|
error: error && ((_error$idx = error[idx]) === null || _error$idx === void 0 ? void 0 : _error$idx.value),
|
|
@@ -535,7 +547,7 @@ var Step = function Step(_ref4) {
|
|
|
535
547
|
inputWrapper: inputWrapper,
|
|
536
548
|
httpClient: httpClient,
|
|
537
549
|
defaultValue: props.defaultValue,
|
|
538
|
-
value: props.
|
|
550
|
+
value: props.value,
|
|
539
551
|
index: idx
|
|
540
552
|
});
|
|
541
553
|
}
|
|
@@ -810,7 +822,7 @@ var Step = function Step(_ref4) {
|
|
|
810
822
|
parent: entry,
|
|
811
823
|
inputWrapper: inputWrapper,
|
|
812
824
|
maybeCustomHttpClient: httpClient,
|
|
813
|
-
value: defaultValue,
|
|
825
|
+
value: getValues(entry) || defaultValue,
|
|
814
826
|
error: error,
|
|
815
827
|
index: index
|
|
816
828
|
}));
|
|
@@ -1046,6 +1058,12 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1046
1058
|
watch = _useFormContext.watch; // retrieve all hook methods
|
|
1047
1059
|
|
|
1048
1060
|
|
|
1061
|
+
var _useState5 = (0, _react.useState)(false),
|
|
1062
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1063
|
+
collapsed = _useState6[0],
|
|
1064
|
+
setCollapsed = _useState6[1];
|
|
1065
|
+
|
|
1066
|
+
var classes = (0, _styleContext.useCustomStyle)();
|
|
1049
1067
|
var schemaAndFlow = (0, _Option.option)(step.conditionalSchema).map(function (condiSchema) {
|
|
1050
1068
|
var ref = (0, _Option.option)(condiSchema.ref).map(function (ref) {
|
|
1051
1069
|
return getValues(ref);
|
|
@@ -1070,7 +1088,7 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1070
1088
|
});
|
|
1071
1089
|
var prevSchema = usePrevious(schemaAndFlow.schema);
|
|
1072
1090
|
(0, _react.useEffect)(function () {
|
|
1073
|
-
if (JSON.stringify(prevSchema) !== JSON.stringify(schemaAndFlow.schema)) {
|
|
1091
|
+
if (!!prevSchema && JSON.stringify(prevSchema) !== JSON.stringify(schemaAndFlow.schema)) {
|
|
1074
1092
|
var def = getDefaultValues(schemaAndFlow.flow, schemaAndFlow.schema);
|
|
1075
1093
|
setValue(parent, def, {
|
|
1076
1094
|
shouldValidate: false
|
|
@@ -1080,14 +1098,62 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1080
1098
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
1081
1099
|
style: {
|
|
1082
1100
|
borderLeft: '2px solid lightGray',
|
|
1083
|
-
paddingLeft: '
|
|
1084
|
-
marginBottom: '.5rem'
|
|
1101
|
+
paddingLeft: '1rem',
|
|
1102
|
+
marginBottom: '.5rem',
|
|
1103
|
+
position: 'relative'
|
|
1104
|
+
}
|
|
1105
|
+
}, schemaAndFlow.flow.length > 1 && collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowDown, {
|
|
1106
|
+
size: 30,
|
|
1107
|
+
className: classes.cursor_pointer,
|
|
1108
|
+
style: {
|
|
1109
|
+
position: 'absolute',
|
|
1110
|
+
top: '5px',
|
|
1111
|
+
left: '-16px'
|
|
1112
|
+
},
|
|
1113
|
+
"stroke-width": "3",
|
|
1114
|
+
onClick: function onClick() {
|
|
1115
|
+
return setCollapsed(!collapsed);
|
|
1116
|
+
}
|
|
1117
|
+
}), schemaAndFlow.flow.length > 1 && !collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.ArrowUp, {
|
|
1118
|
+
size: 30,
|
|
1119
|
+
className: classes.cursor_pointer,
|
|
1120
|
+
style: {
|
|
1121
|
+
position: 'absolute',
|
|
1122
|
+
top: '5px',
|
|
1123
|
+
left: '-16px'
|
|
1124
|
+
},
|
|
1125
|
+
"stroke-width": "3",
|
|
1126
|
+
onClick: function onClick() {
|
|
1127
|
+
return setCollapsed(!collapsed);
|
|
1085
1128
|
}
|
|
1086
|
-
}, schemaAndFlow.flow.map(function (entry, idx) {
|
|
1129
|
+
}), schemaAndFlow.flow.map(function (entry, idx) {
|
|
1087
1130
|
var step = schemaAndFlow.schema[entry];
|
|
1088
1131
|
var realError = error && error[entry];
|
|
1132
|
+
var oneVisibleSetup = Object.values(schema).some(function (v) {
|
|
1133
|
+
return !!v.visibleOnCollapse;
|
|
1134
|
+
});
|
|
1135
|
+
var isCollapsed = collapsed && (oneVisibleSetup ? !step.visibleOnCollapse : idx > 0);
|
|
1136
|
+
var visibleStep = (0, _Option.option)(step).map(function (s) {
|
|
1137
|
+
return s.visible;
|
|
1138
|
+
}).map(function (visible) {
|
|
1139
|
+
switch (_typeof(visible)) {
|
|
1140
|
+
case 'object':
|
|
1141
|
+
var _value2 = watch(visible.ref);
|
|
1142
|
+
|
|
1143
|
+
return (0, _Option.option)(visible.test).map(function (test) {
|
|
1144
|
+
return test(_value2);
|
|
1145
|
+
}).getOrElse(_value2);
|
|
1146
|
+
|
|
1147
|
+
case 'boolean':
|
|
1148
|
+
return visible;
|
|
1149
|
+
|
|
1150
|
+
default:
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
}).getOrElse(true);
|
|
1089
1154
|
return /*#__PURE__*/_react["default"].createElement(BasicWrapper, {
|
|
1090
1155
|
key: "".concat(entry, ".").concat(idx),
|
|
1156
|
+
className: (0, _classnames["default"])(_defineProperty({}, classes.display__none, isCollapsed || !visibleStep)),
|
|
1091
1157
|
entry: "".concat(parent, ".").concat(entry),
|
|
1092
1158
|
error: realError,
|
|
1093
1159
|
label: (step === null || step === void 0 ? void 0 : step.label) === null ? null : (step === null || step === void 0 ? void 0 : step.label) || entry,
|
|
@@ -1096,6 +1162,7 @@ var NestedForm = function NestedForm(_ref16) {
|
|
|
1096
1162
|
}, /*#__PURE__*/_react["default"].createElement(Step, {
|
|
1097
1163
|
key: "step.".concat(entry, ".").concat(idx),
|
|
1098
1164
|
entry: "".concat(parent, ".").concat(entry),
|
|
1165
|
+
realEntry: entry,
|
|
1099
1166
|
step: schemaAndFlow.schema[entry],
|
|
1100
1167
|
error: realError,
|
|
1101
1168
|
register: register,
|
package/lib/inputs/Collapse.js
CHANGED
|
@@ -36,6 +36,8 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
36
36
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
37
|
|
|
38
38
|
var Collapse = function Collapse(props) {
|
|
39
|
+
var _classNames4;
|
|
40
|
+
|
|
39
41
|
var _useState = (0, _react.useState)(props.initCollapsed || props.collapsed),
|
|
40
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
43
|
collapsed = _useState2[0],
|
|
@@ -57,10 +59,14 @@ var Collapse = function Collapse(props) {
|
|
|
57
59
|
className: (0, _classnames["default"])(classes.collapse_label, _defineProperty({}, classes.collapse_error, props.errored))
|
|
58
60
|
}, props.label), /*#__PURE__*/_react["default"].createElement("button", {
|
|
59
61
|
type: "button",
|
|
60
|
-
className: (0, _classnames["default"])(classes.btn, _defineProperty({}, classes.collapse_error, props.errored)),
|
|
62
|
+
className: (0, _classnames["default"])(classes.btn, classes.btn_sm, _defineProperty({}, classes.collapse_error, props.errored)),
|
|
61
63
|
onClick: toggle
|
|
62
|
-
}, !!collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.Eye,
|
|
63
|
-
|
|
64
|
+
}, !!collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.Eye, {
|
|
65
|
+
size: 16
|
|
66
|
+
}), !collapsed && /*#__PURE__*/_react["default"].createElement(_reactFeather.EyeOff, {
|
|
67
|
+
size: 16
|
|
68
|
+
}))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
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))
|
|
64
70
|
}, props.children), props.lineEnd && /*#__PURE__*/_react["default"].createElement("hr", null));
|
|
65
71
|
};
|
|
66
72
|
|
|
@@ -118,9 +118,10 @@ var SelectInput = function SelectInput(props) {
|
|
|
118
118
|
|
|
119
119
|
if (cond) {
|
|
120
120
|
setLoading(true);
|
|
121
|
-
|
|
121
|
+
var promise = (0, _utils.isPromise)(props.optionsFrom) ? props.optionsFrom : props.httpClient(props.optionsFrom, 'GET').then(function (r) {
|
|
122
122
|
return r.json();
|
|
123
|
-
})
|
|
123
|
+
});
|
|
124
|
+
promise.then(function (values) {
|
|
124
125
|
return values.map(function (x) {
|
|
125
126
|
return props.transformer ? props.transformer(x) : valueToSelectOption(x, values, props.isMulti, props.transformer);
|
|
126
127
|
});
|
package/lib/style.d.ts
CHANGED
|
@@ -25,6 +25,9 @@ export namespace style {
|
|
|
25
25
|
export { fontSize_1 as fontSize };
|
|
26
26
|
const padding_1: string;
|
|
27
27
|
export { padding_1 as padding };
|
|
28
|
+
export const lineHeight: string;
|
|
29
|
+
const borderRadius_1: string;
|
|
30
|
+
export { borderRadius_1 as borderRadius };
|
|
28
31
|
}
|
|
29
32
|
const btn_group: {
|
|
30
33
|
"& > button:not(:last-child)": {
|
|
@@ -102,6 +105,13 @@ export namespace style {
|
|
|
102
105
|
const marginLeft_1: number;
|
|
103
106
|
export { marginLeft_1 as marginLeft };
|
|
104
107
|
}
|
|
108
|
+
namespace mr_5 {
|
|
109
|
+
const marginRight: number;
|
|
110
|
+
}
|
|
111
|
+
namespace mr_10 {
|
|
112
|
+
const marginRight_1: number;
|
|
113
|
+
export { marginRight_1 as marginRight };
|
|
114
|
+
}
|
|
105
115
|
namespace mt_5 {
|
|
106
116
|
const marginTop: number;
|
|
107
117
|
}
|
|
@@ -197,4 +207,13 @@ export namespace style {
|
|
|
197
207
|
const color_4: string;
|
|
198
208
|
export { color_4 as color };
|
|
199
209
|
}
|
|
210
|
+
namespace display__none {
|
|
211
|
+
const display_3: string;
|
|
212
|
+
export { display_3 as display };
|
|
213
|
+
}
|
|
214
|
+
const collapse__inline: {
|
|
215
|
+
"& .form-group+.form-group": {
|
|
216
|
+
marginLeft: string;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
200
219
|
}
|
package/lib/style.js
CHANGED
|
@@ -50,7 +50,9 @@ var style = (_style = {
|
|
|
50
50
|
},
|
|
51
51
|
btn_sm: {
|
|
52
52
|
fontSize: "0.875rem",
|
|
53
|
-
padding: ".25rem .5rem"
|
|
53
|
+
padding: ".25rem .5rem",
|
|
54
|
+
lineHeight: "1.5",
|
|
55
|
+
borderRadius: ".2rem"
|
|
54
56
|
},
|
|
55
57
|
btn_group: {
|
|
56
58
|
"& > button:not(:last-child)": {
|
|
@@ -75,6 +77,12 @@ var style = (_style = {
|
|
|
75
77
|
ml_10: {
|
|
76
78
|
marginLeft: 10
|
|
77
79
|
},
|
|
80
|
+
mr_5: {
|
|
81
|
+
marginRight: 5
|
|
82
|
+
},
|
|
83
|
+
mr_10: {
|
|
84
|
+
marginRight: 10
|
|
85
|
+
},
|
|
78
86
|
mt_5: {
|
|
79
87
|
marginTop: 5
|
|
80
88
|
},
|
|
@@ -149,5 +157,11 @@ var style = (_style = {
|
|
|
149
157
|
marginTop: ".25rem",
|
|
150
158
|
fontSize: "80%",
|
|
151
159
|
color: "#dc3545"
|
|
160
|
+
}), _defineProperty(_style, "display__none", {
|
|
161
|
+
display: "none"
|
|
162
|
+
}), _defineProperty(_style, "collapse__inline", {
|
|
163
|
+
"& .form-group+.form-group": {
|
|
164
|
+
marginLeft: '20px'
|
|
165
|
+
}
|
|
152
166
|
}), _style);
|
|
153
167
|
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" | "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">;
|
|
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">;
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.deepEqual = void 0;
|
|
6
|
+
exports.isPromise = exports.deepEqual = void 0;
|
|
7
7
|
|
|
8
8
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
9
9
|
|
|
@@ -28,4 +28,10 @@ var deepEqual = function deepEqual(a, b) {
|
|
|
28
28
|
return true;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
exports.deepEqual = deepEqual;
|
|
31
|
+
exports.deepEqual = deepEqual;
|
|
32
|
+
|
|
33
|
+
var isPromise = function isPromise(value) {
|
|
34
|
+
return Boolean(value && typeof value.then === 'function');
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.isPromise = isPromise;
|