@xqmsg/ui-core 0.25.0 → 0.26.0

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.
@@ -1266,9 +1266,12 @@ var Close = function Close(_ref) {
1266
1266
  return /*#__PURE__*/React__default.createElement(Memo$7, {
1267
1267
  width: boxSize,
1268
1268
  height: boxSize,
1269
- flexBasis: boxSize,
1270
1269
  onClick: onClick,
1271
- cursor: "pointer"
1270
+ cursor: "pointer",
1271
+ style: {
1272
+ flexBasis: boxSize,
1273
+ cursor: 'pointer'
1274
+ }
1272
1275
  });
1273
1276
  };
1274
1277
 
@@ -1283,36 +1286,53 @@ var Token = function Token(_ref) {
1283
1286
  _ref$showClose = _ref.showClose,
1284
1287
  showClose = _ref$showClose === void 0 ? true : _ref$showClose,
1285
1288
  _ref$maxWidth = _ref.maxWidth,
1286
- maxWidth = _ref$maxWidth === void 0 ? 'auto' : _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;
1287
1296
  return /*#__PURE__*/React__default.createElement(Flex, {
1288
1297
  key: label,
1289
- borderRadius: 'full',
1298
+ borderRadius: 'md',
1290
1299
  backgroundColor: "#7676801F",
1291
1300
  alignItems: "center",
1292
1301
  width: "fit-content",
1293
1302
  w: "auto",
1294
1303
  maxWidth: maxWidth,
1295
- h: isMobile ? '18px' : '16px',
1296
- pl: "6px",
1297
- pr: "2px",
1304
+ h: '18px',
1305
+ px: "4px",
1298
1306
  py: "2px",
1299
- position: "relative"
1307
+ pr: showClose ? closeBoxPadding : '4px',
1308
+ position: "relative",
1309
+ cursor: "default"
1300
1310
  }, /*#__PURE__*/React__default.createElement(Text$2, {
1301
1311
  whiteSpace: "nowrap",
1302
1312
  wordBreak: "break-word",
1303
1313
  color: colors.label.primary.light,
1304
1314
  fontSize: isMobile ? '17px' : '13px',
1305
- pr: "4px",
1315
+ lineHeight: "1.5",
1316
+ pr: "2px",
1306
1317
  maxWidth: maxWidth,
1307
1318
  overflow: "hidden",
1308
1319
  textOverflow: "ellipsis"
1309
1320
  }, truncate(label.trim(), {
1310
1321
  length: truncateLength,
1311
1322
  omission: '...'
1312
- })), showClose && /*#__PURE__*/React__default.createElement(Close, {
1313
- 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",
1314
1334
  onClick: onDelete
1315
- }));
1335
+ })));
1316
1336
  };
1317
1337
 
1318
1338
  /**
@@ -1692,18 +1712,50 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1692
1712
  shouldDirty: true
1693
1713
  });
1694
1714
  }
1695
- if (!localValue.trim().length && lastestFormValueToArray.length) {
1696
- if (e.key === 'Backspace' && tokenIndex !== null) {
1697
- setLocalValue(lastestFormValueToArray[tokenIndex].substring(0, lastestFormValueToArray[tokenIndex].length));
1698
- var _filteredUniqueValues2 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (value) {
1699
- 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;
1700
1748
  })));
1701
- setValue(name, _filteredUniqueValues2.toString(), {
1749
+ setValue(name, _filteredUniqueValues4.toString(), {
1702
1750
  shouldValidate: true,
1703
1751
  shouldDirty: true
1704
1752
  });
1705
- return setTokenIndex(null);
1753
+ setTokenIndex(null);
1754
+ e.preventDefault();
1755
+ return;
1706
1756
  }
1757
+ }
1758
+ if (!localValue.trim().length && lastestFormValueToArray.length) {
1707
1759
  if (e.key === 'ArrowLeft') {
1708
1760
  if (tokenIndex === 0) return;
1709
1761
  if (!tokenIndex) {
@@ -1789,6 +1841,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1789
1841
  onClick: function onClick() {
1790
1842
  if (isFocussed && tokenIndex !== null) {
1791
1843
  setTokenIndex(null);
1844
+ } else if (!scrollMode) {
1845
+ setIsFocussed(true);
1792
1846
  }
1793
1847
  if (!disabled) {
1794
1848
  var _inputRef$current;
@@ -1806,7 +1860,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1806
1860
  overflowX: scrollMode ? 'scroll' : 'hidden',
1807
1861
  flexWrap: scrollMode ? 'nowrap' : 'wrap',
1808
1862
  overflowY: "hidden",
1809
- maxWidth: isFocussed ? '80%' : '100%',
1863
+ width: scrollMode ? 'auto' : '100%',
1864
+ maxWidth: isFocussed && scrollMode ? '80%' : '100%',
1810
1865
  style: {
1811
1866
  scrollbarWidth: 'none' /* Firefox */,
1812
1867
  msOverflowStyle: 'none'
@@ -1817,24 +1872,30 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1817
1872
  }
1818
1873
  },
1819
1874
  ref: scrollRef,
1820
- zIndex: 99,
1821
1875
  onKeyDown: onHandleKeyDown
1822
1876
  }, lastestFormValueToArray.length ? lastestFormValueToArray.map(function (label, index) {
1823
1877
  return /*#__PURE__*/React__default.createElement(Box, {
1824
1878
  key: index,
1825
- mr: "4px",
1879
+ mr: "2px",
1826
1880
  border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
1827
- borderRadius: "full",
1828
- onClick: function onClick() {
1829
- return setTokenIndex(index);
1881
+ borderRadius: "md",
1882
+ onClick: function onClick(e) {
1883
+ e.stopPropagation();
1884
+ // Don't change selection if clicking on already selected token
1885
+ if (tokenIndex === index) {
1886
+ return;
1887
+ }
1888
+ setTokenIndex(index);
1830
1889
  },
1831
1890
  width: scrollMode ? '100%' : 'auto',
1832
1891
  maxWidth: '100%',
1833
- id: name + "_token_" + index
1892
+ id: name + "_token_" + index,
1893
+ cursor: "default"
1834
1894
  }, /*#__PURE__*/React__default.createElement(Token, {
1835
1895
  maxWidth: '100%',
1836
1896
  label: label,
1837
- showClose: !isFocussed || tokenIndex === index,
1897
+ showClose: true,
1898
+ isSelected: tokenIndex === index,
1838
1899
  onDelete: function onDelete(e) {
1839
1900
  e.stopPropagation();
1840
1901
  e.preventDefault();
@@ -1845,10 +1906,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1845
1906
  }));
1846
1907
  }) : null, !lastestFormValueToArray.length && !isFocussed ? /*#__PURE__*/React__default.createElement(Text$2, {
1847
1908
  color: colors.label.secondary.light,
1848
- fontSize: isMobile ? '17px' : '13px'
1849
- }, placeholder) : null), !disabled && /*#__PURE__*/React__default.createElement(Flex, {
1909
+ fontSize: isMobile ? '17px' : '13px',
1910
+ pointerEvents: "none"
1911
+ }, placeholder) : null, !disabled && !scrollMode && /*#__PURE__*/React__default.createElement(Flex, {
1850
1912
  flex: 1,
1851
- minWidth: isFocussed && !tokenIndex ? '20%' : 0
1913
+ minWidth: isFocussed && !tokenIndex ? 'auto' : '100px'
1852
1914
  }, /*#__PURE__*/React__default.createElement(Input$2, {
1853
1915
  onKeyDown: onHandleKeyDown,
1854
1916
  type: "text",
@@ -1867,9 +1929,33 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1867
1929
  onFocus: function onFocus() {
1868
1930
  return setIsFocussed(true);
1869
1931
  },
1870
- onBlur: function onBlur() {
1871
- setIsFocussed(false);
1872
- return setTokenIndex(null);
1932
+ fontSize: isMobile ? '17px' : '13px',
1933
+ lineHeight: 1.5,
1934
+ placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
1935
+ variant: variant,
1936
+ style: isMobile ? {
1937
+ border: 'none'
1938
+ } : undefined
1939
+ }))), !disabled && scrollMode && /*#__PURE__*/React__default.createElement(Flex, {
1940
+ flex: 1,
1941
+ minWidth: isFocussed && !tokenIndex ? '20%' : 0
1942
+ }, /*#__PURE__*/React__default.createElement(Input$2, {
1943
+ onKeyDown: onHandleKeyDown,
1944
+ type: "text",
1945
+ padding: 0,
1946
+ alignContent: "flex-start",
1947
+ "float": "right",
1948
+ border: "none",
1949
+ height: "auto",
1950
+ color: tokenIndex !== null ? 'transparent' : colors.label.primary,
1951
+ _focus: {
1952
+ boxShadow: 'none !important'
1953
+ },
1954
+ value: localValue,
1955
+ onChange: handleOnChange,
1956
+ ref: inputRef,
1957
+ onFocus: function onFocus() {
1958
+ return setIsFocussed(true);
1873
1959
  },
1874
1960
  placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
1875
1961
  variant: variant,