@xqmsg/ui-core 0.14.0 → 0.14.1
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/dist/ui-core.cjs.development.js +21 -5
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +22 -6
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/StackedSelect/StackedSelect.tsx +9 -10
- package/src/components/input/index.tsx +143 -160
|
@@ -549,7 +549,14 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
549
549
|
}, DropdownContent);
|
|
550
550
|
};
|
|
551
551
|
|
|
552
|
-
var
|
|
552
|
+
var useDidMountEffect = function useDidMountEffect(func, deps) {
|
|
553
|
+
var didMount = React.useRef(false);
|
|
554
|
+
React.useEffect(function () {
|
|
555
|
+
if (didMount.current) func();else didMount.current = true; // eslint-disable-next-line
|
|
556
|
+
}, deps);
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "value"];
|
|
553
560
|
/**
|
|
554
561
|
* A functional React component utilized to render the `StackedSelect` component.
|
|
555
562
|
*/
|
|
@@ -562,7 +569,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
562
569
|
name = _ref2.name,
|
|
563
570
|
setValue = _ref2.setValue,
|
|
564
571
|
handleOnChange = _ref2.handleOnChange,
|
|
565
|
-
|
|
572
|
+
value = _ref2.value,
|
|
566
573
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
|
|
567
574
|
|
|
568
575
|
var dropdownRef = React.useRef(null);
|
|
@@ -572,11 +579,18 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
572
579
|
setIsFocussed = _useState[1];
|
|
573
580
|
|
|
574
581
|
var _useState2 = React.useState((_options$find$label = (_options$find = options.find(function (option) {
|
|
575
|
-
return option.value ===
|
|
582
|
+
return option.value === value;
|
|
576
583
|
})) == null ? void 0 : _options$find.label) != null ? _options$find$label : ''),
|
|
577
584
|
selectedOption = _useState2[0],
|
|
578
585
|
setSelectedOption = _useState2[1];
|
|
579
586
|
|
|
587
|
+
useDidMountEffect(function () {
|
|
588
|
+
var _options$find$label2, _options$find2;
|
|
589
|
+
|
|
590
|
+
setSelectedOption((_options$find$label2 = (_options$find2 = options.find(function (option) {
|
|
591
|
+
return option.value === value;
|
|
592
|
+
})) == null ? void 0 : _options$find2.label) != null ? _options$find$label2 : '');
|
|
593
|
+
}, [value]);
|
|
580
594
|
react.useOutsideClick({
|
|
581
595
|
ref: dropdownRef,
|
|
582
596
|
handler: function handler() {
|
|
@@ -1075,7 +1089,8 @@ function Input(_ref) {
|
|
|
1075
1089
|
disabled = _ref.disabled,
|
|
1076
1090
|
onChange = _ref.onChange,
|
|
1077
1091
|
setValue = _ref.setValue;
|
|
1078
|
-
|
|
1092
|
+
|
|
1093
|
+
var selectedInputField = function selectedInputField(onChange, onBlur, ref, value) {
|
|
1079
1094
|
switch (inputType) {
|
|
1080
1095
|
case 'text':
|
|
1081
1096
|
return /*#__PURE__*/React__default.createElement(StackedInput, {
|
|
@@ -1203,7 +1218,8 @@ function Input(_ref) {
|
|
|
1203
1218
|
default:
|
|
1204
1219
|
return null;
|
|
1205
1220
|
}
|
|
1206
|
-
}
|
|
1221
|
+
};
|
|
1222
|
+
|
|
1207
1223
|
return /*#__PURE__*/React__default.createElement(reactHookForm.Controller, {
|
|
1208
1224
|
control: control,
|
|
1209
1225
|
name: name,
|