@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.
@@ -1,4 +1,4 @@
1
- import React__default, { useMemo, useCallback, useRef, useState, useEffect } from 'react';
1
+ import React__default, { useMemo, useCallback, useRef, useEffect, useState } from 'react';
2
2
  import { Image, Alert as Alert$1, AlertDescription, Box, Flex, Button as Button$2, Text as Text$2, Icon as Icon$1, Spinner, InputGroup, Checkbox, Input as Input$2, RadioGroup, Radio, useOutsideClick, InputRightElement, Textarea as Textarea$1, Switch as Switch$1, FormLabel as FormLabel$1, FormControl, FormErrorMessage, FormHelperText, SimpleGrid, useMediaQuery, Grid, GridItem, IconButton, Collapse, TableContainer, Table as Table$2, Thead, Tr, Th, Tbody, Td, TableCaption, Tabs as Tabs$1, TabList, Tab, extendTheme, ChakraProvider } from '@chakra-ui/react';
3
3
  import { FormProvider, useWatch, Controller } from 'react-hook-form';
4
4
  import { CloseIcon as CloseIcon$1, HamburgerIcon } from '@chakra-ui/icons';
@@ -542,7 +542,14 @@ var Dropdown = function Dropdown(_ref) {
542
542
  }, DropdownContent);
543
543
  };
544
544
 
545
- var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "defaultValue"];
545
+ var useDidMountEffect = function useDidMountEffect(func, deps) {
546
+ var didMount = useRef(false);
547
+ useEffect(function () {
548
+ if (didMount.current) func();else didMount.current = true; // eslint-disable-next-line
549
+ }, deps);
550
+ };
551
+
552
+ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "value"];
546
553
  /**
547
554
  * A functional React component utilized to render the `StackedSelect` component.
548
555
  */
@@ -555,7 +562,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
555
562
  name = _ref2.name,
556
563
  setValue = _ref2.setValue,
557
564
  handleOnChange = _ref2.handleOnChange,
558
- defaultValue = _ref2.defaultValue,
565
+ value = _ref2.value,
559
566
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
560
567
 
561
568
  var dropdownRef = useRef(null);
@@ -565,11 +572,18 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
565
572
  setIsFocussed = _useState[1];
566
573
 
567
574
  var _useState2 = useState((_options$find$label = (_options$find = options.find(function (option) {
568
- return option.value === defaultValue;
575
+ return option.value === value;
569
576
  })) == null ? void 0 : _options$find.label) != null ? _options$find$label : ''),
570
577
  selectedOption = _useState2[0],
571
578
  setSelectedOption = _useState2[1];
572
579
 
580
+ useDidMountEffect(function () {
581
+ var _options$find$label2, _options$find2;
582
+
583
+ setSelectedOption((_options$find$label2 = (_options$find2 = options.find(function (option) {
584
+ return option.value === value;
585
+ })) == null ? void 0 : _options$find2.label) != null ? _options$find$label2 : '');
586
+ }, [value]);
573
587
  useOutsideClick({
574
588
  ref: dropdownRef,
575
589
  handler: function handler() {
@@ -1068,7 +1082,8 @@ function Input(_ref) {
1068
1082
  disabled = _ref.disabled,
1069
1083
  onChange = _ref.onChange,
1070
1084
  setValue = _ref.setValue;
1071
- var selectedInputField = useCallback(function (onChange, onBlur, ref, value) {
1085
+
1086
+ var selectedInputField = function selectedInputField(onChange, onBlur, ref, value) {
1072
1087
  switch (inputType) {
1073
1088
  case 'text':
1074
1089
  return /*#__PURE__*/React__default.createElement(StackedInput, {
@@ -1196,7 +1211,8 @@ function Input(_ref) {
1196
1211
  default:
1197
1212
  return null;
1198
1213
  }
1199
- }, [ariaLabel, className, control, defaultValue, disabled, inputType, isInvalid, isRequired, maxLength, name, options, placeholder, setValue]);
1214
+ };
1215
+
1200
1216
  return /*#__PURE__*/React__default.createElement(Controller, {
1201
1217
  control: control,
1202
1218
  name: name,