@xqmsg/ui-core 0.15.2 → 0.15.4

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.
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ /**
3
+ * A React component utilized to render the `EmptyTable` component
4
+ */
5
+ export declare const EmptyTable: React.FC;
@@ -11,4 +11,4 @@ export interface TableProps<T extends ReadonlyTableColumns> {
11
11
  /**
12
12
  * A React component utilized to render the `Table` component
13
13
  */
14
- export declare function Table<T extends ReadonlyTableColumns>({ columns, headers, body, placeholder, loading, loadMore, }: TableProps<T>): JSX.Element;
14
+ export declare function Table<T extends ReadonlyTableColumns>({ columns, headers, body, loading, loadMore, }: TableProps<T>): JSX.Element;
@@ -0,0 +1,2 @@
1
+ import { RefObject } from 'react';
2
+ export declare function useOnClickOutside(ref: RefObject<any>, handler: () => void): void;
@@ -531,7 +531,7 @@ var Dropdown = function Dropdown(_ref) {
531
531
  fontSize: "13px",
532
532
  px: "8px",
533
533
  py: "4px",
534
- width: "fit-content",
534
+ width: "100%",
535
535
  color: colors.label.primary.light,
536
536
  _hover: {
537
537
  color: colors.label.primary.dark,
@@ -576,6 +576,32 @@ var useDidMountEffect = function useDidMountEffect(func, deps) {
576
576
  }, deps);
577
577
  };
578
578
 
579
+ function useOnClickOutside(ref, handler) {
580
+ React.useEffect(function () {
581
+ var listener = function listener(event) {
582
+ // Do nothing if clicking ref's element or descendent elements
583
+ if (!ref.current || ref.current.contains(event.target)) {
584
+ return;
585
+ }
586
+
587
+ handler();
588
+ };
589
+
590
+ document.addEventListener('mousedown', listener);
591
+ document.addEventListener('touchstart', listener);
592
+ return function () {
593
+ document.removeEventListener('mousedown', listener);
594
+ document.removeEventListener('touchstart', listener);
595
+ };
596
+ }, // Add ref and handler to effect dependencies
597
+ // It's worth noting that because passed in handler is a new ...
598
+ // ... function on every render that will cause this effect ...
599
+ // ... callback/cleanup to run every render. It's not a big deal ...
600
+ // ... but to optimize you can wrap handler in useCallback before ...
601
+ // ... passing it into this hook.
602
+ [ref, handler]);
603
+ }
604
+
579
605
  var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "value"];
580
606
  /**
581
607
  * A functional React component utilized to render the `StackedSelect` component.
@@ -628,11 +654,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
628
654
  return option.value === value;
629
655
  })) == null ? void 0 : _options$find2.label) != null ? _options$find$label2 : '');
630
656
  }, [value]);
631
- react.useOutsideClick({
632
- ref: dropdownRef,
633
- handler: function handler() {
634
- return setIsFocussed(false);
635
- }
657
+ useOnClickOutside(dropdownRef, function () {
658
+ return setIsFocussed(false);
636
659
  });
637
660
 
638
661
  var handleOnSelectItem = function handleOnSelectItem(option) {
@@ -812,11 +835,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
812
835
  setPosition('bottom');
813
836
  }
814
837
  }, [boundingClientRect]);
815
- react.useOutsideClick({
816
- ref: dropdownRef,
817
- handler: function handler() {
818
- return setIsFocussed(false);
819
- }
838
+ useOnClickOutside(dropdownRef, function () {
839
+ return setIsFocussed(false);
820
840
  }); // gets latest watched form value (common delimited) from RHF state and creates a list
821
841
 
822
842
  React.useEffect(function () {
@@ -1746,6 +1766,58 @@ var TableLoadingRows = function TableLoadingRows(_ref) {
1746
1766
  }));
1747
1767
  };
1748
1768
 
1769
+ /**
1770
+ * A React component utilized to render the `EmptyTable` component
1771
+ */
1772
+
1773
+ var EmptyTable = function EmptyTable() {
1774
+ var getOpacity = function getOpacity(index) {
1775
+ switch (index) {
1776
+ case 1:
1777
+ return 0.7;
1778
+
1779
+ case 3:
1780
+ return 0.6;
1781
+
1782
+ case 5:
1783
+ return 0.5;
1784
+
1785
+ case 7:
1786
+ return 0.4;
1787
+
1788
+ case 9:
1789
+ return 0.3;
1790
+
1791
+ case 11:
1792
+ return 0.2;
1793
+
1794
+ case 13:
1795
+ return 0.1;
1796
+
1797
+ default:
1798
+ return 1;
1799
+ }
1800
+ };
1801
+
1802
+ return /*#__PURE__*/React__default.createElement(react.Table, {
1803
+ variant: "unstyled",
1804
+ width: "100%",
1805
+ style: {
1806
+ borderCollapse: 'separate',
1807
+ borderSpacing: '0px'
1808
+ }
1809
+ }, /*#__PURE__*/React__default.createElement(react.Tbody, null, Array.from({
1810
+ length: 14
1811
+ }, function (_, i) {
1812
+ return i + 1;
1813
+ }).map(function (i) {
1814
+ return /*#__PURE__*/React__default.createElement(react.Tr, null, /*#__PURE__*/React__default.createElement(react.Td, {
1815
+ height: "23px",
1816
+ opacity: getOpacity(i)
1817
+ }));
1818
+ })));
1819
+ };
1820
+
1749
1821
  /**
1750
1822
  * A React component utilized to render the `Table` component
1751
1823
  */
@@ -1754,8 +1826,6 @@ function Table(_ref) {
1754
1826
  var columns = _ref.columns,
1755
1827
  headers = _ref.headers,
1756
1828
  body = _ref.body,
1757
- _ref$placeholder = _ref.placeholder,
1758
- placeholder = _ref$placeholder === void 0 ? 'There is currently no available data' : _ref$placeholder,
1759
1829
  loading = _ref.loading,
1760
1830
  loadMore = _ref.loadMore;
1761
1831
  var columnsAsConst = generateTableColumnsAsConst(columns);
@@ -1764,7 +1834,7 @@ function Table(_ref) {
1764
1834
  overflowX: "auto",
1765
1835
  bg: "white",
1766
1836
  width: "100%"
1767
- }, /*#__PURE__*/React__default.createElement(react.Table, {
1837
+ }, body.length ? /*#__PURE__*/React__default.createElement(react.Table, {
1768
1838
  variant: "unstyled",
1769
1839
  width: "100%",
1770
1840
  style: {
@@ -1789,12 +1859,10 @@ function Table(_ref) {
1789
1859
  React__default.createElement(react.Td, null, row[column])
1790
1860
  );
1791
1861
  }));
1792
- })), !body.length && /*#__PURE__*/React__default.createElement(react.TableCaption, {
1793
- py: 10
1794
- }, placeholder), ' '), loadMore && loading !== undefined && /*#__PURE__*/React__default.createElement(TableLoadingRows, {
1862
+ }))) : /*#__PURE__*/React__default.createElement(EmptyTable, null), loadMore && loading !== undefined && body.length ? /*#__PURE__*/React__default.createElement(TableLoadingRows, {
1795
1863
  isLoading: loading,
1796
1864
  onLoadMore: loadMore
1797
- }));
1865
+ }) : null);
1798
1866
  }
1799
1867
 
1800
1868
  /**