@xqmsg/ui-core 0.15.0 → 0.15.2
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/ui-core.cjs.development.js +50 -42
- 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 +50 -42
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/Input.stories.tsx +44 -68
- package/src/components/input/StackedMultiSelect/index.tsx +4 -4
- package/src/components/input/StackedPilledInput/index.tsx +53 -24
- package/src/components/input/StackedSelect/StackedSelect.tsx +4 -2
package/dist/ui-core.esm.js
CHANGED
|
@@ -575,7 +575,7 @@ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange"
|
|
|
575
575
|
*/
|
|
576
576
|
|
|
577
577
|
var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref) {
|
|
578
|
-
var _options$find$label, _options$find;
|
|
578
|
+
var _options$find$label, _options$find, _dropdownRef$current;
|
|
579
579
|
|
|
580
580
|
var isRequired = _ref2.isRequired,
|
|
581
581
|
options = _ref2.options,
|
|
@@ -602,17 +602,18 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
602
602
|
position = _useState3[0],
|
|
603
603
|
setPosition = _useState3[1];
|
|
604
604
|
|
|
605
|
+
var boundingClientRect = (_dropdownRef$current = dropdownRef.current) == null ? void 0 : _dropdownRef$current.getBoundingClientRect();
|
|
605
606
|
useEffect(function () {
|
|
606
|
-
var _dropdownRef$
|
|
607
|
+
var _dropdownRef$current2;
|
|
607
608
|
|
|
608
|
-
var boundingClientRect = (_dropdownRef$
|
|
609
|
+
var boundingClientRect = (_dropdownRef$current2 = dropdownRef.current) == null ? void 0 : _dropdownRef$current2.getBoundingClientRect();
|
|
609
610
|
|
|
610
|
-
if (
|
|
611
|
+
if (window.innerHeight - ((boundingClientRect == null ? void 0 : boundingClientRect.y) + 240) >= 0) {
|
|
611
612
|
setPosition('top');
|
|
612
613
|
} else {
|
|
613
614
|
setPosition('bottom');
|
|
614
615
|
}
|
|
615
|
-
}, [
|
|
616
|
+
}, [boundingClientRect]);
|
|
616
617
|
useDidMountEffect(function () {
|
|
617
618
|
var _options$find$label2, _options$find2;
|
|
618
619
|
|
|
@@ -759,6 +760,8 @@ var Token = function Token(_ref) {
|
|
|
759
760
|
*/
|
|
760
761
|
|
|
761
762
|
var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref) {
|
|
763
|
+
var _dropdownRef$current;
|
|
764
|
+
|
|
762
765
|
var options = _ref2.options,
|
|
763
766
|
setValue = _ref2.setValue,
|
|
764
767
|
control = _ref2.control,
|
|
@@ -794,17 +797,14 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
794
797
|
position = _useState5[0],
|
|
795
798
|
setPosition = _useState5[1];
|
|
796
799
|
|
|
800
|
+
var boundingClientRect = (_dropdownRef$current = dropdownRef.current) == null ? void 0 : _dropdownRef$current.getBoundingClientRect();
|
|
797
801
|
useEffect(function () {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
var boundingClientRect = (_dropdownRef$current = dropdownRef.current) == null ? void 0 : _dropdownRef$current.getBoundingClientRect();
|
|
801
|
-
|
|
802
|
-
if (document.body.clientHeight - ((boundingClientRect == null ? void 0 : boundingClientRect.y) + 240) >= 0) {
|
|
802
|
+
if (window.innerHeight - ((boundingClientRect == null ? void 0 : boundingClientRect.y) + 240) >= 0) {
|
|
803
803
|
setPosition('top');
|
|
804
804
|
} else {
|
|
805
805
|
setPosition('bottom');
|
|
806
806
|
}
|
|
807
|
-
}, [
|
|
807
|
+
}, [boundingClientRect]);
|
|
808
808
|
useOutsideClick({
|
|
809
809
|
ref: dropdownRef,
|
|
810
810
|
handler: function handler() {
|
|
@@ -1017,14 +1017,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1017
1017
|
isFocussed = _useState3[0],
|
|
1018
1018
|
setIsFocussed = _useState3[1];
|
|
1019
1019
|
|
|
1020
|
-
var _useState4 = useState(
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
var _useState5 = useState(''),
|
|
1025
|
-
localValue = _useState5[0],
|
|
1026
|
-
setLocalValue = _useState5[1]; // gets latest watched form value (common delimited) from RHF state and creates a list
|
|
1020
|
+
var _useState4 = useState(''),
|
|
1021
|
+
localValue = _useState4[0],
|
|
1022
|
+
setLocalValue = _useState4[1];
|
|
1027
1023
|
|
|
1024
|
+
var latestTokenElement = document.getElementById(name + "_token_" + (lastestFormValueToArray.length - 1)); // gets latest watched form value (common delimited) from RHF state and creates a list
|
|
1028
1025
|
|
|
1029
1026
|
useEffect(function () {
|
|
1030
1027
|
if (watchedValue !== undefined && !watchedValue.length) {
|
|
@@ -1032,23 +1029,19 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1032
1029
|
}
|
|
1033
1030
|
|
|
1034
1031
|
if (watchedValue !== undefined && watchedValue != null && watchedValue.length) {
|
|
1035
|
-
|
|
1036
|
-
var _scrollRef$current;
|
|
1032
|
+
setLatestFormValueToArray(watchedValue.split(',').filter(Boolean));
|
|
1037
1033
|
|
|
1038
|
-
|
|
1039
|
-
|
|
1034
|
+
if (latestTokenElement) {
|
|
1035
|
+
latestTokenElement.scrollIntoView({
|
|
1036
|
+
block: 'end',
|
|
1037
|
+
inline: 'center',
|
|
1040
1038
|
behavior: 'smooth'
|
|
1041
1039
|
});
|
|
1042
|
-
setShouldSideScroll(false);
|
|
1043
1040
|
}
|
|
1044
|
-
|
|
1045
|
-
setLatestFormValueToArray(watchedValue.split(',').filter(Boolean));
|
|
1046
1041
|
}
|
|
1047
|
-
}, [
|
|
1042
|
+
}, [latestTokenElement, watchedValue]);
|
|
1048
1043
|
|
|
1049
1044
|
var onHandleKeyDown = function onHandleKeyDown(e) {
|
|
1050
|
-
setShouldSideScroll(true);
|
|
1051
|
-
|
|
1052
1045
|
if (e.key === ' ' || e.key === 'Enter' || e.key === ',' || e.key === 'Tab') {
|
|
1053
1046
|
if (e.key === 'Enter' && !localValue.trim().length && tokenIndex !== null) {
|
|
1054
1047
|
setLocalValue(lastestFormValueToArray[tokenIndex]);
|
|
@@ -1066,11 +1059,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1066
1059
|
|
|
1067
1060
|
var filteredUniqueValues = Array.from(new Set([].concat(lastestFormValueToArray, localValue.trim().split(','))));
|
|
1068
1061
|
setLocalValue('');
|
|
1069
|
-
setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
|
|
1062
|
+
return setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
|
|
1070
1063
|
shouldValidate: true,
|
|
1071
1064
|
shouldDirty: true
|
|
1072
1065
|
});
|
|
1073
|
-
return setIsFocussed(false);
|
|
1074
1066
|
}
|
|
1075
1067
|
|
|
1076
1068
|
if (!localValue.trim().length && lastestFormValueToArray.length) {
|
|
@@ -1095,9 +1087,15 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1095
1087
|
return setTokenIndex(lastestFormValueToArray.length - 1);
|
|
1096
1088
|
}
|
|
1097
1089
|
|
|
1098
|
-
|
|
1090
|
+
setTokenIndex(function (prevTokenIndex) {
|
|
1099
1091
|
return prevTokenIndex - 1;
|
|
1100
1092
|
});
|
|
1093
|
+
var tokenElement = document.getElementById(name + "_token_" + tokenIndex);
|
|
1094
|
+
if (!tokenElement || !scrollRef.current) return;
|
|
1095
|
+
return scrollRef.current.scrollBy({
|
|
1096
|
+
left: -1 * tokenElement.getBoundingClientRect().width,
|
|
1097
|
+
behavior: 'smooth'
|
|
1098
|
+
});
|
|
1101
1099
|
}
|
|
1102
1100
|
|
|
1103
1101
|
if (e.key === 'ArrowRight') {
|
|
@@ -1107,9 +1105,17 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1107
1105
|
return setTokenIndex(null);
|
|
1108
1106
|
}
|
|
1109
1107
|
|
|
1110
|
-
|
|
1108
|
+
setTokenIndex(function (prevTokenIndex) {
|
|
1111
1109
|
return prevTokenIndex + 1;
|
|
1112
1110
|
});
|
|
1111
|
+
|
|
1112
|
+
var _tokenElement = document.getElementById(name + "_token_" + tokenIndex);
|
|
1113
|
+
|
|
1114
|
+
if (!_tokenElement || !scrollRef.current) return;
|
|
1115
|
+
return scrollRef.current.scrollBy({
|
|
1116
|
+
left: _tokenElement.getBoundingClientRect().width,
|
|
1117
|
+
behavior: 'smooth'
|
|
1118
|
+
});
|
|
1113
1119
|
}
|
|
1114
1120
|
}
|
|
1115
1121
|
};
|
|
@@ -1128,7 +1134,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1128
1134
|
var onBlur = function onBlur() {
|
|
1129
1135
|
clearErrors(name);
|
|
1130
1136
|
|
|
1131
|
-
if (localValue.trim()) {
|
|
1137
|
+
if (localValue.trim().length) {
|
|
1132
1138
|
var filteredUniqueValues = Array.from(new Set([].concat(lastestFormValueToArray, localValue.trim().split(','))));
|
|
1133
1139
|
setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
|
|
1134
1140
|
shouldValidate: true,
|
|
@@ -1150,7 +1156,6 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1150
1156
|
fontSize: "13px",
|
|
1151
1157
|
border: isFocussed ? '2px solid' : '1px solid',
|
|
1152
1158
|
borderColor: isFocussed ? colors.border.focus : colors.border["default"],
|
|
1153
|
-
py: "5px",
|
|
1154
1159
|
pl: "8px",
|
|
1155
1160
|
borderRadius: "4px",
|
|
1156
1161
|
alignItems: "center",
|
|
@@ -1167,11 +1172,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1167
1172
|
ref: inputWrapperRef,
|
|
1168
1173
|
h: "26px"
|
|
1169
1174
|
}, /*#__PURE__*/React__default.createElement(Flex, {
|
|
1170
|
-
h: "
|
|
1175
|
+
h: "100%",
|
|
1171
1176
|
alignItems: "center",
|
|
1172
|
-
// width="fit-content"
|
|
1173
|
-
// maxW="80%"
|
|
1174
1177
|
overflowX: "scroll",
|
|
1178
|
+
overflowY: "hidden",
|
|
1179
|
+
maxWidth: isFocussed ? '80%' : '100%',
|
|
1175
1180
|
style: {
|
|
1176
1181
|
scrollbarWidth: 'none'
|
|
1177
1182
|
/* Firefox */
|
|
@@ -1190,9 +1195,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1190
1195
|
border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
|
|
1191
1196
|
borderRadius: "full",
|
|
1192
1197
|
onClick: function onClick() {
|
|
1193
|
-
return setTokenIndex(index);
|
|
1198
|
+
return isFocussed && setTokenIndex(index);
|
|
1194
1199
|
},
|
|
1195
|
-
width: "100%"
|
|
1200
|
+
width: "100%",
|
|
1201
|
+
id: name + "_token_" + index
|
|
1196
1202
|
}, /*#__PURE__*/React__default.createElement(Token, {
|
|
1197
1203
|
label: label,
|
|
1198
1204
|
onDelete: function onDelete(e) {
|
|
@@ -1205,12 +1211,14 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1205
1211
|
color: colors.label.secondary.light,
|
|
1206
1212
|
fontSize: "13px"
|
|
1207
1213
|
}, placeholder)), /*#__PURE__*/React__default.createElement(Flex, {
|
|
1208
|
-
flex: 1
|
|
1214
|
+
flex: 1,
|
|
1215
|
+
minWidth: isFocussed ? '20%' : 0
|
|
1209
1216
|
}, /*#__PURE__*/React__default.createElement(Input$2, {
|
|
1210
1217
|
onKeyDown: onHandleKeyDown,
|
|
1211
1218
|
type: "text",
|
|
1212
1219
|
padding: 0,
|
|
1213
|
-
|
|
1220
|
+
alignContent: "flex-start",
|
|
1221
|
+
"float": "right",
|
|
1214
1222
|
border: "none",
|
|
1215
1223
|
height: "auto",
|
|
1216
1224
|
color: tokenIndex !== null ? 'transparent' : colors.label.primary,
|
|
@@ -1219,7 +1227,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1219
1227
|
},
|
|
1220
1228
|
value: localValue,
|
|
1221
1229
|
onChange: function onChange(e) {
|
|
1222
|
-
return tokenIndex === null && setLocalValue(e.target.value);
|
|
1230
|
+
return tokenIndex === null && setLocalValue(e.target.value.trim().replace(',', '').length ? e.target.value : '');
|
|
1223
1231
|
},
|
|
1224
1232
|
ref: inputRef,
|
|
1225
1233
|
onFocus: function onFocus() {
|