@xqmsg/ui-core 0.24.11 → 0.25.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.
@@ -1267,7 +1267,11 @@ var Close = function Close(_ref) {
1267
1267
  width: boxSize,
1268
1268
  height: boxSize,
1269
1269
  onClick: onClick,
1270
- cursor: "pointer"
1270
+ cursor: "pointer",
1271
+ style: {
1272
+ flexBasis: boxSize,
1273
+ cursor: 'pointer'
1274
+ }
1271
1275
  });
1272
1276
  };
1273
1277
 
@@ -1278,31 +1282,57 @@ var Token = function Token(_ref) {
1278
1282
  _ref$isMobile = _ref.isMobile,
1279
1283
  isMobile = _ref$isMobile === void 0 ? false : _ref$isMobile,
1280
1284
  _ref$truncateLength = _ref.truncateLength,
1281
- truncateLength = _ref$truncateLength === void 0 ? 15 : _ref$truncateLength;
1285
+ truncateLength = _ref$truncateLength === void 0 ? 15 : _ref$truncateLength,
1286
+ _ref$showClose = _ref.showClose,
1287
+ showClose = _ref$showClose === void 0 ? true : _ref$showClose,
1288
+ _ref$maxWidth = _ref.maxWidth,
1289
+ maxWidth = _ref$maxWidth === void 0 ? 'auto' : _ref$maxWidth,
1290
+ _ref$isSelected = _ref.isSelected,
1291
+ isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
1292
+ // in pixels
1293
+ var closeBoxSize = isMobile ? 20 : 15;
1294
+ var closeBoxGap = isMobile ? 4 : 2;
1295
+ var closeBoxPadding = closeBoxSize + closeBoxGap;
1282
1296
  return /*#__PURE__*/React__default.createElement(Flex, {
1283
1297
  key: label,
1284
- borderRadius: 'full',
1298
+ borderRadius: 'md',
1285
1299
  backgroundColor: "#7676801F",
1286
1300
  alignItems: "center",
1287
1301
  width: "fit-content",
1288
1302
  w: "auto",
1289
- h: isMobile ? '18px' : '16px',
1290
- pl: "6px",
1291
- pr: "2px",
1303
+ maxWidth: maxWidth,
1304
+ h: '18px',
1305
+ px: "4px",
1292
1306
  py: "2px",
1293
- position: "relative"
1307
+ pr: showClose ? closeBoxPadding : '4px',
1308
+ position: "relative",
1309
+ cursor: "default"
1294
1310
  }, /*#__PURE__*/React__default.createElement(Text$2, {
1295
1311
  whiteSpace: "nowrap",
1312
+ wordBreak: "break-word",
1296
1313
  color: colors.label.primary.light,
1297
1314
  fontSize: isMobile ? '17px' : '13px',
1298
- pr: "4px"
1315
+ lineHeight: isMobile ? '17px' : '13px',
1316
+ pr: "2px",
1317
+ maxWidth: maxWidth,
1318
+ overflow: "hidden",
1319
+ textOverflow: "ellipsis"
1299
1320
  }, truncate(label.trim(), {
1300
1321
  length: truncateLength,
1301
1322
  omission: '...'
1302
- })), /*#__PURE__*/React__default.createElement(Close, {
1303
- boxSize: isMobile ? '17px' : '11px',
1323
+ })), showClose && /*#__PURE__*/React__default.createElement(Flex, {
1324
+ height: "100%",
1325
+ position: "absolute",
1326
+ top: 0,
1327
+ bottom: 0,
1328
+ right: 0,
1329
+ justifyContent: "center",
1330
+ alignItems: "center",
1331
+ cursor: isSelected ? 'default' : 'pointer'
1332
+ }, /*#__PURE__*/React__default.createElement(Close, {
1333
+ boxSize: closeBoxSize + "px",
1304
1334
  onClick: onDelete
1305
- }));
1335
+ })));
1306
1336
  };
1307
1337
 
1308
1338
  /**
@@ -1613,7 +1643,9 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1613
1643
  separators = _ref2$separators === void 0 ? ['Enter', ' ', ',', ';', 'Tab'] : _ref2$separators,
1614
1644
  variant = _ref2.variant,
1615
1645
  label = _ref2.label,
1616
- truncatePillLength = _ref2.truncatePillLength;
1646
+ truncatePillLength = _ref2.truncatePillLength,
1647
+ _ref2$mode = _ref2.mode,
1648
+ mode = _ref2$mode === void 0 ? 'scroll' : _ref2$mode;
1617
1649
  var watchedValue = useWatch({
1618
1650
  control: control,
1619
1651
  name: name
@@ -1634,6 +1666,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1634
1666
  localValue = _useState4[0],
1635
1667
  setLocalValue = _useState4[1];
1636
1668
  var latestTokenElement = document.getElementById(name + "_token_" + (lastestFormValueToArray.length - 1));
1669
+ var scrollMode = mode === 'scroll';
1637
1670
  // gets latest watched form value (common delimited) from RHF state and creates a list
1638
1671
  useEffect(function () {
1639
1672
  if (watchedValue !== undefined && !watchedValue.length) {
@@ -1679,18 +1712,50 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1679
1712
  shouldDirty: true
1680
1713
  });
1681
1714
  }
1682
- if (!localValue.trim().length && lastestFormValueToArray.length) {
1683
- if (e.key === 'Backspace' && tokenIndex !== null) {
1684
- setLocalValue(lastestFormValueToArray[tokenIndex].substring(0, lastestFormValueToArray[tokenIndex].length));
1685
- var _filteredUniqueValues2 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (value) {
1686
- return value !== lastestFormValueToArray[tokenIndex];
1715
+ if (e.key === 'Backspace') {
1716
+ // If input is empty and there are tokens
1717
+ if (!localValue.length && lastestFormValueToArray.length) {
1718
+ // If a token is selected, move it to input
1719
+ if (tokenIndex !== null) {
1720
+ setLocalValue(lastestFormValueToArray[tokenIndex].substring(0, lastestFormValueToArray[tokenIndex].length));
1721
+ var _filteredUniqueValues2 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (value) {
1722
+ return value !== lastestFormValueToArray[tokenIndex];
1723
+ })));
1724
+ setValue(name, _filteredUniqueValues2.toString(), {
1725
+ shouldValidate: true,
1726
+ shouldDirty: true
1727
+ });
1728
+ return setTokenIndex(null);
1729
+ } else {
1730
+ // No token selected, move last token to input
1731
+ var lastToken = lastestFormValueToArray[lastestFormValueToArray.length - 1];
1732
+ setLocalValue(lastToken);
1733
+ var _filteredUniqueValues3 = lastestFormValueToArray.slice(0, -1);
1734
+ setValue(name, _filteredUniqueValues3.toString(), {
1735
+ shouldValidate: true,
1736
+ shouldDirty: true
1737
+ });
1738
+ e.preventDefault();
1739
+ return;
1740
+ }
1741
+ }
1742
+ }
1743
+ if (e.key === 'Delete') {
1744
+ // If a token is selected, remove it completely
1745
+ if (tokenIndex !== null && lastestFormValueToArray.length) {
1746
+ var _filteredUniqueValues4 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (_, index) {
1747
+ return index !== tokenIndex;
1687
1748
  })));
1688
- setValue(name, _filteredUniqueValues2.toString(), {
1749
+ setValue(name, _filteredUniqueValues4.toString(), {
1689
1750
  shouldValidate: true,
1690
1751
  shouldDirty: true
1691
1752
  });
1692
- return setTokenIndex(null);
1753
+ setTokenIndex(null);
1754
+ e.preventDefault();
1755
+ return;
1693
1756
  }
1757
+ }
1758
+ if (!localValue.trim().length && lastestFormValueToArray.length) {
1694
1759
  if (e.key === 'ArrowLeft') {
1695
1760
  if (tokenIndex === 0) return;
1696
1761
  if (!tokenIndex) {
@@ -1785,11 +1850,13 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1785
1850
  bg: disabled ? colors.fill.light.quaternary : '#ffffff',
1786
1851
  cursor: disabled ? 'not-allowed' : 'pointer',
1787
1852
  ref: inputWrapperRef,
1788
- h: isMobile ? '48px' : '26px'
1853
+ h: isMobile ? '48px' : scrollMode ? '26px' : 'auto',
1854
+ minH: isMobile ? '48px' : '26px'
1789
1855
  }, /*#__PURE__*/React__default.createElement(Flex, {
1790
1856
  h: "100%",
1791
1857
  alignItems: "center",
1792
- overflowX: "scroll",
1858
+ overflowX: scrollMode ? 'scroll' : 'hidden',
1859
+ flexWrap: scrollMode ? 'nowrap' : 'wrap',
1793
1860
  overflowY: "hidden",
1794
1861
  maxWidth: isFocussed ? '80%' : '100%',
1795
1862
  style: {
@@ -1802,21 +1869,30 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1802
1869
  }
1803
1870
  },
1804
1871
  ref: scrollRef,
1805
- zIndex: 99,
1806
1872
  onKeyDown: onHandleKeyDown
1807
1873
  }, lastestFormValueToArray.length ? lastestFormValueToArray.map(function (label, index) {
1808
1874
  return /*#__PURE__*/React__default.createElement(Box, {
1809
1875
  key: index,
1810
- mr: "4px",
1876
+ mr: "2px",
1811
1877
  border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
1812
- borderRadius: "full",
1813
- onClick: function onClick() {
1814
- return setTokenIndex(index);
1878
+ borderRadius: "md",
1879
+ onClick: function onClick(e) {
1880
+ e.stopPropagation();
1881
+ // Don't change selection if clicking on already selected token
1882
+ if (tokenIndex === index) {
1883
+ return;
1884
+ }
1885
+ setTokenIndex(index);
1815
1886
  },
1816
- width: "100%",
1817
- id: name + "_token_" + index
1887
+ width: scrollMode ? '100%' : 'auto',
1888
+ maxWidth: '100%',
1889
+ id: name + "_token_" + index,
1890
+ cursor: "default"
1818
1891
  }, /*#__PURE__*/React__default.createElement(Token, {
1892
+ maxWidth: '100%',
1819
1893
  label: label,
1894
+ showClose: true,
1895
+ isSelected: tokenIndex === index,
1820
1896
  onDelete: function onDelete(e) {
1821
1897
  e.stopPropagation();
1822
1898
  e.preventDefault();
@@ -1827,7 +1903,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1827
1903
  }));
1828
1904
  }) : null, !lastestFormValueToArray.length && !isFocussed ? /*#__PURE__*/React__default.createElement(Text$2, {
1829
1905
  color: colors.label.secondary.light,
1830
- fontSize: isMobile ? '17px' : '13px'
1906
+ fontSize: isMobile ? '17px' : '13px',
1907
+ pointerEvents: "none"
1831
1908
  }, placeholder) : null), !disabled && /*#__PURE__*/React__default.createElement(Flex, {
1832
1909
  flex: 1,
1833
1910
  minWidth: isFocussed && !tokenIndex ? '20%' : 0
@@ -1849,10 +1926,6 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1849
1926
  onFocus: function onFocus() {
1850
1927
  return setIsFocussed(true);
1851
1928
  },
1852
- onBlur: function onBlur() {
1853
- setIsFocussed(false);
1854
- return setTokenIndex(null);
1855
- },
1856
1929
  placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
1857
1930
  variant: variant,
1858
1931
  style: isMobile ? {
@@ -1944,7 +2017,9 @@ function Input(_ref) {
1944
2017
  _ref$loadingOptions = _ref.loadingOptions,
1945
2018
  loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions,
1946
2019
  truncatePillLength = _ref.truncatePillLength,
1947
- searchable = _ref.searchable;
2020
+ searchable = _ref.searchable,
2021
+ _ref$overflowMode = _ref.overflowMode,
2022
+ overflowMode = _ref$overflowMode === void 0 ? 'scroll' : _ref$overflowMode;
1948
2023
  function selectedInputField(onChange, onBlur, ref, value) {
1949
2024
  switch (inputType) {
1950
2025
  case 'text':
@@ -2075,7 +2150,8 @@ function Input(_ref) {
2075
2150
  variant: variant,
2076
2151
  label: label,
2077
2152
  separators: separators,
2078
- truncatePillLength: truncatePillLength
2153
+ truncatePillLength: truncatePillLength,
2154
+ mode: overflowMode
2079
2155
  });
2080
2156
  case 'switch':
2081
2157
  return /*#__PURE__*/React__default.createElement(StackedSwitch, {
@@ -3581,7 +3657,10 @@ function SimpleTable(_ref) {
3581
3657
  headers = _ref.headers,
3582
3658
  body = _ref.body,
3583
3659
  loading = _ref.loading,
3584
- loadMore = _ref.loadMore;
3660
+ loadMore = _ref.loadMore,
3661
+ _ref$layout = _ref.layout,
3662
+ layout = _ref$layout === void 0 ? 'auto' : _ref$layout,
3663
+ columnsWidths = _ref.columnsWidths;
3585
3664
  var columnsAsConst = generateTableColumnsAsConst(columns);
3586
3665
  return /*#__PURE__*/React__default.createElement(TableContainer, {
3587
3666
  border: "none",
@@ -3593,20 +3672,18 @@ function SimpleTable(_ref) {
3593
3672
  width: "100%",
3594
3673
  style: {
3595
3674
  borderCollapse: 'separate',
3596
- borderSpacing: '0px'
3675
+ borderSpacing: '0px',
3676
+ tableLayout: layout
3597
3677
  }
3598
- }, headers && /*#__PURE__*/React__default.createElement(Thead, null, /*#__PURE__*/React__default.createElement(Tr, {
3678
+ }, (headers || columnsWidths) && /*#__PURE__*/React__default.createElement(Thead, null, /*#__PURE__*/React__default.createElement(Tr, {
3599
3679
  _odd: {
3600
3680
  bg: colors.label.primary.dark
3601
3681
  }
3602
3682
  }, columnsAsConst.map(function (column, idx) {
3603
- return (
3604
- /*#__PURE__*/
3605
- // @ts-ignore
3606
- React__default.createElement(Th, {
3607
- key: idx
3608
- }, headers[column])
3609
- );
3683
+ return /*#__PURE__*/React__default.createElement(Th, {
3684
+ key: idx,
3685
+ width: columnsWidths == null ? void 0 : columnsWidths[column]
3686
+ }, headers && headers[column]);
3610
3687
  }))), /*#__PURE__*/React__default.createElement(Tbody, null, body.map(function (row, idx) {
3611
3688
  return /*#__PURE__*/React__default.createElement(Tr, {
3612
3689
  key: idx