@xqmsg/ui-core 0.15.2 → 0.15.3

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,5 +1,5 @@
1
1
  import React__default, { useMemo, useCallback, useRef, useEffect, useState, memo, forwardRef, createElement } from 'react';
2
- import { Button as Button$2, Image, Alert as Alert$1, AlertDescription, Box, Flex, Text as Text$2, Icon as Icon$1, Spinner, Checkbox, Input as Input$2, InputGroup, 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 } from '@chakra-ui/react';
2
+ import { Button as Button$2, Image, Alert as Alert$1, AlertDescription, Box, Flex, Text as Text$2, Icon as Icon$1, Spinner, Checkbox, Input as Input$2, InputGroup, RadioGroup, Radio, InputRightElement, Textarea as Textarea$1, useOutsideClick, 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 } from '@chakra-ui/react';
3
3
  import { FormProvider, useWatch, Controller } from 'react-hook-form';
4
4
  import { truncate } from 'lodash-es';
5
5
  import { CloseIcon, HamburgerIcon } from '@chakra-ui/icons';
@@ -524,7 +524,7 @@ var Dropdown = function Dropdown(_ref) {
524
524
  fontSize: "13px",
525
525
  px: "8px",
526
526
  py: "4px",
527
- width: "fit-content",
527
+ width: "100%",
528
528
  color: colors.label.primary.light,
529
529
  _hover: {
530
530
  color: colors.label.primary.dark,
@@ -569,6 +569,32 @@ var useDidMountEffect = function useDidMountEffect(func, deps) {
569
569
  }, deps);
570
570
  };
571
571
 
572
+ function useOnClickOutside(ref, handler) {
573
+ useEffect(function () {
574
+ var listener = function listener(event) {
575
+ // Do nothing if clicking ref's element or descendent elements
576
+ if (!ref.current || ref.current.contains(event.target)) {
577
+ return;
578
+ }
579
+
580
+ handler();
581
+ };
582
+
583
+ document.addEventListener('mousedown', listener);
584
+ document.addEventListener('touchstart', listener);
585
+ return function () {
586
+ document.removeEventListener('mousedown', listener);
587
+ document.removeEventListener('touchstart', listener);
588
+ };
589
+ }, // Add ref and handler to effect dependencies
590
+ // It's worth noting that because passed in handler is a new ...
591
+ // ... function on every render that will cause this effect ...
592
+ // ... callback/cleanup to run every render. It's not a big deal ...
593
+ // ... but to optimize you can wrap handler in useCallback before ...
594
+ // ... passing it into this hook.
595
+ [ref, handler]);
596
+ }
597
+
572
598
  var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "value"];
573
599
  /**
574
600
  * A functional React component utilized to render the `StackedSelect` component.
@@ -621,11 +647,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
621
647
  return option.value === value;
622
648
  })) == null ? void 0 : _options$find2.label) != null ? _options$find$label2 : '');
623
649
  }, [value]);
624
- useOutsideClick({
625
- ref: dropdownRef,
626
- handler: function handler() {
627
- return setIsFocussed(false);
628
- }
650
+ useOnClickOutside(dropdownRef, function () {
651
+ return setIsFocussed(false);
629
652
  });
630
653
 
631
654
  var handleOnSelectItem = function handleOnSelectItem(option) {
@@ -805,11 +828,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
805
828
  setPosition('bottom');
806
829
  }
807
830
  }, [boundingClientRect]);
808
- useOutsideClick({
809
- ref: dropdownRef,
810
- handler: function handler() {
811
- return setIsFocussed(false);
812
- }
831
+ useOnClickOutside(dropdownRef, function () {
832
+ return setIsFocussed(false);
813
833
  }); // gets latest watched form value (common delimited) from RHF state and creates a list
814
834
 
815
835
  useEffect(function () {