@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.
- package/dist/components/input/components/token/index.d.ts +1 -0
- package/dist/ui-core.cjs.development.js +119 -33
- 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 +119 -33
- 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/Input.stories.tsx +18 -1
- package/src/components/input/StackedPilledInput/index.tsx +105 -21
- package/src/components/input/components/token/index.tsx +25 -6
|
@@ -1273,9 +1273,12 @@ var Close = function Close(_ref) {
|
|
|
1273
1273
|
return /*#__PURE__*/React__default.createElement(Memo$7, {
|
|
1274
1274
|
width: boxSize,
|
|
1275
1275
|
height: boxSize,
|
|
1276
|
-
flexBasis: boxSize,
|
|
1277
1276
|
onClick: onClick,
|
|
1278
|
-
cursor: "pointer"
|
|
1277
|
+
cursor: "pointer",
|
|
1278
|
+
style: {
|
|
1279
|
+
flexBasis: boxSize,
|
|
1280
|
+
cursor: 'pointer'
|
|
1281
|
+
}
|
|
1279
1282
|
});
|
|
1280
1283
|
};
|
|
1281
1284
|
|
|
@@ -1290,36 +1293,53 @@ var Token = function Token(_ref) {
|
|
|
1290
1293
|
_ref$showClose = _ref.showClose,
|
|
1291
1294
|
showClose = _ref$showClose === void 0 ? true : _ref$showClose,
|
|
1292
1295
|
_ref$maxWidth = _ref.maxWidth,
|
|
1293
|
-
maxWidth = _ref$maxWidth === void 0 ? 'auto' : _ref$maxWidth
|
|
1296
|
+
maxWidth = _ref$maxWidth === void 0 ? 'auto' : _ref$maxWidth,
|
|
1297
|
+
_ref$isSelected = _ref.isSelected,
|
|
1298
|
+
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
|
|
1299
|
+
// in pixels
|
|
1300
|
+
var closeBoxSize = isMobile ? 20 : 15;
|
|
1301
|
+
var closeBoxGap = isMobile ? 4 : 2;
|
|
1302
|
+
var closeBoxPadding = closeBoxSize + closeBoxGap;
|
|
1294
1303
|
return /*#__PURE__*/React__default.createElement(react.Flex, {
|
|
1295
1304
|
key: label,
|
|
1296
|
-
borderRadius: '
|
|
1305
|
+
borderRadius: 'md',
|
|
1297
1306
|
backgroundColor: "#7676801F",
|
|
1298
1307
|
alignItems: "center",
|
|
1299
1308
|
width: "fit-content",
|
|
1300
1309
|
w: "auto",
|
|
1301
1310
|
maxWidth: maxWidth,
|
|
1302
|
-
h:
|
|
1303
|
-
|
|
1304
|
-
pr: "2px",
|
|
1311
|
+
h: '18px',
|
|
1312
|
+
px: "4px",
|
|
1305
1313
|
py: "2px",
|
|
1306
|
-
|
|
1314
|
+
pr: showClose ? closeBoxPadding : '4px',
|
|
1315
|
+
position: "relative",
|
|
1316
|
+
cursor: "default"
|
|
1307
1317
|
}, /*#__PURE__*/React__default.createElement(react.Text, {
|
|
1308
1318
|
whiteSpace: "nowrap",
|
|
1309
1319
|
wordBreak: "break-word",
|
|
1310
1320
|
color: colors.label.primary.light,
|
|
1311
1321
|
fontSize: isMobile ? '17px' : '13px',
|
|
1312
|
-
|
|
1322
|
+
lineHeight: "1.5",
|
|
1323
|
+
pr: "2px",
|
|
1313
1324
|
maxWidth: maxWidth,
|
|
1314
1325
|
overflow: "hidden",
|
|
1315
1326
|
textOverflow: "ellipsis"
|
|
1316
1327
|
}, lodash.truncate(label.trim(), {
|
|
1317
1328
|
length: truncateLength,
|
|
1318
1329
|
omission: '...'
|
|
1319
|
-
})), showClose && /*#__PURE__*/React__default.createElement(
|
|
1320
|
-
|
|
1330
|
+
})), showClose && /*#__PURE__*/React__default.createElement(react.Flex, {
|
|
1331
|
+
height: "100%",
|
|
1332
|
+
position: "absolute",
|
|
1333
|
+
top: 0,
|
|
1334
|
+
bottom: 0,
|
|
1335
|
+
right: 0,
|
|
1336
|
+
justifyContent: "center",
|
|
1337
|
+
alignItems: "center",
|
|
1338
|
+
cursor: isSelected ? 'default' : 'pointer'
|
|
1339
|
+
}, /*#__PURE__*/React__default.createElement(Close, {
|
|
1340
|
+
boxSize: closeBoxSize + "px",
|
|
1321
1341
|
onClick: onDelete
|
|
1322
|
-
}));
|
|
1342
|
+
})));
|
|
1323
1343
|
};
|
|
1324
1344
|
|
|
1325
1345
|
/**
|
|
@@ -1699,18 +1719,50 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1699
1719
|
shouldDirty: true
|
|
1700
1720
|
});
|
|
1701
1721
|
}
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1722
|
+
if (e.key === 'Backspace') {
|
|
1723
|
+
// If input is empty and there are tokens
|
|
1724
|
+
if (!localValue.length && lastestFormValueToArray.length) {
|
|
1725
|
+
// If a token is selected, move it to input
|
|
1726
|
+
if (tokenIndex !== null) {
|
|
1727
|
+
setLocalValue(lastestFormValueToArray[tokenIndex].substring(0, lastestFormValueToArray[tokenIndex].length));
|
|
1728
|
+
var _filteredUniqueValues2 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (value) {
|
|
1729
|
+
return value !== lastestFormValueToArray[tokenIndex];
|
|
1730
|
+
})));
|
|
1731
|
+
setValue(name, _filteredUniqueValues2.toString(), {
|
|
1732
|
+
shouldValidate: true,
|
|
1733
|
+
shouldDirty: true
|
|
1734
|
+
});
|
|
1735
|
+
return setTokenIndex(null);
|
|
1736
|
+
} else {
|
|
1737
|
+
// No token selected, move last token to input
|
|
1738
|
+
var lastToken = lastestFormValueToArray[lastestFormValueToArray.length - 1];
|
|
1739
|
+
setLocalValue(lastToken);
|
|
1740
|
+
var _filteredUniqueValues3 = lastestFormValueToArray.slice(0, -1);
|
|
1741
|
+
setValue(name, _filteredUniqueValues3.toString(), {
|
|
1742
|
+
shouldValidate: true,
|
|
1743
|
+
shouldDirty: true
|
|
1744
|
+
});
|
|
1745
|
+
e.preventDefault();
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
if (e.key === 'Delete') {
|
|
1751
|
+
// If a token is selected, remove it completely
|
|
1752
|
+
if (tokenIndex !== null && lastestFormValueToArray.length) {
|
|
1753
|
+
var _filteredUniqueValues4 = Array.from(new Set([].concat(lastestFormValueToArray).filter(function (_, index) {
|
|
1754
|
+
return index !== tokenIndex;
|
|
1707
1755
|
})));
|
|
1708
|
-
setValue(name,
|
|
1756
|
+
setValue(name, _filteredUniqueValues4.toString(), {
|
|
1709
1757
|
shouldValidate: true,
|
|
1710
1758
|
shouldDirty: true
|
|
1711
1759
|
});
|
|
1712
|
-
|
|
1760
|
+
setTokenIndex(null);
|
|
1761
|
+
e.preventDefault();
|
|
1762
|
+
return;
|
|
1713
1763
|
}
|
|
1764
|
+
}
|
|
1765
|
+
if (!localValue.trim().length && lastestFormValueToArray.length) {
|
|
1714
1766
|
if (e.key === 'ArrowLeft') {
|
|
1715
1767
|
if (tokenIndex === 0) return;
|
|
1716
1768
|
if (!tokenIndex) {
|
|
@@ -1796,6 +1848,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1796
1848
|
onClick: function onClick() {
|
|
1797
1849
|
if (isFocussed && tokenIndex !== null) {
|
|
1798
1850
|
setTokenIndex(null);
|
|
1851
|
+
} else if (!scrollMode) {
|
|
1852
|
+
setIsFocussed(true);
|
|
1799
1853
|
}
|
|
1800
1854
|
if (!disabled) {
|
|
1801
1855
|
var _inputRef$current;
|
|
@@ -1813,7 +1867,8 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1813
1867
|
overflowX: scrollMode ? 'scroll' : 'hidden',
|
|
1814
1868
|
flexWrap: scrollMode ? 'nowrap' : 'wrap',
|
|
1815
1869
|
overflowY: "hidden",
|
|
1816
|
-
|
|
1870
|
+
width: scrollMode ? 'auto' : '100%',
|
|
1871
|
+
maxWidth: isFocussed && scrollMode ? '80%' : '100%',
|
|
1817
1872
|
style: {
|
|
1818
1873
|
scrollbarWidth: 'none' /* Firefox */,
|
|
1819
1874
|
msOverflowStyle: 'none'
|
|
@@ -1824,24 +1879,30 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1824
1879
|
}
|
|
1825
1880
|
},
|
|
1826
1881
|
ref: scrollRef,
|
|
1827
|
-
zIndex: 99,
|
|
1828
1882
|
onKeyDown: onHandleKeyDown
|
|
1829
1883
|
}, lastestFormValueToArray.length ? lastestFormValueToArray.map(function (label, index) {
|
|
1830
1884
|
return /*#__PURE__*/React__default.createElement(react.Box, {
|
|
1831
1885
|
key: index,
|
|
1832
|
-
mr: "
|
|
1886
|
+
mr: "2px",
|
|
1833
1887
|
border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
|
|
1834
|
-
borderRadius: "
|
|
1835
|
-
onClick: function onClick() {
|
|
1836
|
-
|
|
1888
|
+
borderRadius: "md",
|
|
1889
|
+
onClick: function onClick(e) {
|
|
1890
|
+
e.stopPropagation();
|
|
1891
|
+
// Don't change selection if clicking on already selected token
|
|
1892
|
+
if (tokenIndex === index) {
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
setTokenIndex(index);
|
|
1837
1896
|
},
|
|
1838
1897
|
width: scrollMode ? '100%' : 'auto',
|
|
1839
1898
|
maxWidth: '100%',
|
|
1840
|
-
id: name + "_token_" + index
|
|
1899
|
+
id: name + "_token_" + index,
|
|
1900
|
+
cursor: "default"
|
|
1841
1901
|
}, /*#__PURE__*/React__default.createElement(Token, {
|
|
1842
1902
|
maxWidth: '100%',
|
|
1843
1903
|
label: label,
|
|
1844
|
-
showClose:
|
|
1904
|
+
showClose: true,
|
|
1905
|
+
isSelected: tokenIndex === index,
|
|
1845
1906
|
onDelete: function onDelete(e) {
|
|
1846
1907
|
e.stopPropagation();
|
|
1847
1908
|
e.preventDefault();
|
|
@@ -1852,10 +1913,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1852
1913
|
}));
|
|
1853
1914
|
}) : null, !lastestFormValueToArray.length && !isFocussed ? /*#__PURE__*/React__default.createElement(react.Text, {
|
|
1854
1915
|
color: colors.label.secondary.light,
|
|
1855
|
-
fontSize: isMobile ? '17px' : '13px'
|
|
1856
|
-
|
|
1916
|
+
fontSize: isMobile ? '17px' : '13px',
|
|
1917
|
+
pointerEvents: "none"
|
|
1918
|
+
}, placeholder) : null, !disabled && !scrollMode && /*#__PURE__*/React__default.createElement(react.Flex, {
|
|
1857
1919
|
flex: 1,
|
|
1858
|
-
minWidth: isFocussed && !tokenIndex ? '
|
|
1920
|
+
minWidth: isFocussed && !tokenIndex ? 'auto' : '100px'
|
|
1859
1921
|
}, /*#__PURE__*/React__default.createElement(react.Input, {
|
|
1860
1922
|
onKeyDown: onHandleKeyDown,
|
|
1861
1923
|
type: "text",
|
|
@@ -1874,9 +1936,33 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1874
1936
|
onFocus: function onFocus() {
|
|
1875
1937
|
return setIsFocussed(true);
|
|
1876
1938
|
},
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1939
|
+
fontSize: isMobile ? '17px' : '13px',
|
|
1940
|
+
lineHeight: 1.5,
|
|
1941
|
+
placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
|
|
1942
|
+
variant: variant,
|
|
1943
|
+
style: isMobile ? {
|
|
1944
|
+
border: 'none'
|
|
1945
|
+
} : undefined
|
|
1946
|
+
}))), !disabled && scrollMode && /*#__PURE__*/React__default.createElement(react.Flex, {
|
|
1947
|
+
flex: 1,
|
|
1948
|
+
minWidth: isFocussed && !tokenIndex ? '20%' : 0
|
|
1949
|
+
}, /*#__PURE__*/React__default.createElement(react.Input, {
|
|
1950
|
+
onKeyDown: onHandleKeyDown,
|
|
1951
|
+
type: "text",
|
|
1952
|
+
padding: 0,
|
|
1953
|
+
alignContent: "flex-start",
|
|
1954
|
+
"float": "right",
|
|
1955
|
+
border: "none",
|
|
1956
|
+
height: "auto",
|
|
1957
|
+
color: tokenIndex !== null ? 'transparent' : colors.label.primary,
|
|
1958
|
+
_focus: {
|
|
1959
|
+
boxShadow: 'none !important'
|
|
1960
|
+
},
|
|
1961
|
+
value: localValue,
|
|
1962
|
+
onChange: handleOnChange,
|
|
1963
|
+
ref: inputRef,
|
|
1964
|
+
onFocus: function onFocus() {
|
|
1965
|
+
return setIsFocussed(true);
|
|
1880
1966
|
},
|
|
1881
1967
|
placeholder: isMobile && label && lastestFormValueToArray.length === 0 ? label : '',
|
|
1882
1968
|
variant: variant,
|