@xqmsg/ui-core 0.25.0 → 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.
- package/dist/components/input/components/token/index.d.ts +1 -0
- package/dist/ui-core.cjs.development.js +86 -31
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +86 -31
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/icons/close/index.tsx +1 -1
- package/src/components/input/StackedPilledInput/index.tsx +67 -19
- package/src/components/input/components/token/index.tsx +25 -6
package/dist/ui-core.esm.js
CHANGED
|
@@ -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: '
|
|
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:
|
|
1296
|
-
|
|
1297
|
-
pr: "2px",
|
|
1304
|
+
h: '18px',
|
|
1305
|
+
px: "4px",
|
|
1298
1306
|
py: "2px",
|
|
1299
|
-
|
|
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
|
-
|
|
1315
|
+
lineHeight: isMobile ? '17px' : '13px',
|
|
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(
|
|
1313
|
-
|
|
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 (
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
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,
|
|
1749
|
+
setValue(name, _filteredUniqueValues4.toString(), {
|
|
1702
1750
|
shouldValidate: true,
|
|
1703
1751
|
shouldDirty: true
|
|
1704
1752
|
});
|
|
1705
|
-
|
|
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) {
|
|
@@ -1817,24 +1869,30 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1817
1869
|
}
|
|
1818
1870
|
},
|
|
1819
1871
|
ref: scrollRef,
|
|
1820
|
-
zIndex: 99,
|
|
1821
1872
|
onKeyDown: onHandleKeyDown
|
|
1822
1873
|
}, lastestFormValueToArray.length ? lastestFormValueToArray.map(function (label, index) {
|
|
1823
1874
|
return /*#__PURE__*/React__default.createElement(Box, {
|
|
1824
1875
|
key: index,
|
|
1825
|
-
mr: "
|
|
1876
|
+
mr: "2px",
|
|
1826
1877
|
border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
|
|
1827
|
-
borderRadius: "
|
|
1828
|
-
onClick: function onClick() {
|
|
1829
|
-
|
|
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);
|
|
1830
1886
|
},
|
|
1831
1887
|
width: scrollMode ? '100%' : 'auto',
|
|
1832
1888
|
maxWidth: '100%',
|
|
1833
|
-
id: name + "_token_" + index
|
|
1889
|
+
id: name + "_token_" + index,
|
|
1890
|
+
cursor: "default"
|
|
1834
1891
|
}, /*#__PURE__*/React__default.createElement(Token, {
|
|
1835
1892
|
maxWidth: '100%',
|
|
1836
1893
|
label: label,
|
|
1837
|
-
showClose:
|
|
1894
|
+
showClose: true,
|
|
1895
|
+
isSelected: tokenIndex === index,
|
|
1838
1896
|
onDelete: function onDelete(e) {
|
|
1839
1897
|
e.stopPropagation();
|
|
1840
1898
|
e.preventDefault();
|
|
@@ -1845,7 +1903,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1845
1903
|
}));
|
|
1846
1904
|
}) : null, !lastestFormValueToArray.length && !isFocussed ? /*#__PURE__*/React__default.createElement(Text$2, {
|
|
1847
1905
|
color: colors.label.secondary.light,
|
|
1848
|
-
fontSize: isMobile ? '17px' : '13px'
|
|
1906
|
+
fontSize: isMobile ? '17px' : '13px',
|
|
1907
|
+
pointerEvents: "none"
|
|
1849
1908
|
}, placeholder) : null), !disabled && /*#__PURE__*/React__default.createElement(Flex, {
|
|
1850
1909
|
flex: 1,
|
|
1851
1910
|
minWidth: isFocussed && !tokenIndex ? '20%' : 0
|
|
@@ -1867,10 +1926,6 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1867
1926
|
onFocus: function onFocus() {
|
|
1868
1927
|
return setIsFocussed(true);
|
|
1869
1928
|
},
|
|
1870
|
-
onBlur: function onBlur() {
|
|
1871
|
-
setIsFocussed(false);
|
|
1872
|
-
return setTokenIndex(null);
|
|
1873
|
-
},
|
|
1874
1929
|
placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
|
|
1875
1930
|
variant: variant,
|
|
1876
1931
|
style: isMobile ? {
|