@xqmsg/ui-core 0.15.1 → 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.
@@ -1024,14 +1024,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1024
1024
  isFocussed = _useState3[0],
1025
1025
  setIsFocussed = _useState3[1];
1026
1026
 
1027
- var _useState4 = React.useState(false),
1028
- shouldSideScroll = _useState4[0],
1029
- setShouldSideScroll = _useState4[1];
1030
-
1031
- var _useState5 = React.useState(''),
1032
- localValue = _useState5[0],
1033
- setLocalValue = _useState5[1]; // gets latest watched form value (common delimited) from RHF state and creates a list
1027
+ var _useState4 = React.useState(''),
1028
+ localValue = _useState4[0],
1029
+ setLocalValue = _useState4[1];
1034
1030
 
1031
+ var latestTokenElement = document.getElementById(name + "_token_" + (lastestFormValueToArray.length - 1)); // gets latest watched form value (common delimited) from RHF state and creates a list
1035
1032
 
1036
1033
  React.useEffect(function () {
1037
1034
  if (watchedValue !== undefined && !watchedValue.length) {
@@ -1039,23 +1036,19 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1039
1036
  }
1040
1037
 
1041
1038
  if (watchedValue !== undefined && watchedValue != null && watchedValue.length) {
1042
- if (shouldSideScroll) {
1043
- var _scrollRef$current;
1039
+ setLatestFormValueToArray(watchedValue.split(',').filter(Boolean));
1044
1040
 
1045
- scrollRef.current.scrollTo({
1046
- left: (_scrollRef$current = scrollRef.current) == null ? void 0 : _scrollRef$current.scrollWidth,
1041
+ if (latestTokenElement) {
1042
+ latestTokenElement.scrollIntoView({
1043
+ block: 'end',
1044
+ inline: 'center',
1047
1045
  behavior: 'smooth'
1048
1046
  });
1049
- setShouldSideScroll(false);
1050
1047
  }
1051
-
1052
- setLatestFormValueToArray(watchedValue.split(',').filter(Boolean));
1053
1048
  }
1054
- }, [watchedValue, shouldSideScroll]);
1049
+ }, [latestTokenElement, watchedValue]);
1055
1050
 
1056
1051
  var onHandleKeyDown = function onHandleKeyDown(e) {
1057
- setShouldSideScroll(true);
1058
-
1059
1052
  if (e.key === ' ' || e.key === 'Enter' || e.key === ',' || e.key === 'Tab') {
1060
1053
  if (e.key === 'Enter' && !localValue.trim().length && tokenIndex !== null) {
1061
1054
  setLocalValue(lastestFormValueToArray[tokenIndex]);
@@ -1073,11 +1066,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1073
1066
 
1074
1067
  var filteredUniqueValues = Array.from(new Set([].concat(lastestFormValueToArray, localValue.trim().split(','))));
1075
1068
  setLocalValue('');
1076
- setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
1069
+ return setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
1077
1070
  shouldValidate: true,
1078
1071
  shouldDirty: true
1079
1072
  });
1080
- return setIsFocussed(false);
1081
1073
  }
1082
1074
 
1083
1075
  if (!localValue.trim().length && lastestFormValueToArray.length) {
@@ -1102,9 +1094,15 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1102
1094
  return setTokenIndex(lastestFormValueToArray.length - 1);
1103
1095
  }
1104
1096
 
1105
- return setTokenIndex(function (prevTokenIndex) {
1097
+ setTokenIndex(function (prevTokenIndex) {
1106
1098
  return prevTokenIndex - 1;
1107
1099
  });
1100
+ var tokenElement = document.getElementById(name + "_token_" + tokenIndex);
1101
+ if (!tokenElement || !scrollRef.current) return;
1102
+ return scrollRef.current.scrollBy({
1103
+ left: -1 * tokenElement.getBoundingClientRect().width,
1104
+ behavior: 'smooth'
1105
+ });
1108
1106
  }
1109
1107
 
1110
1108
  if (e.key === 'ArrowRight') {
@@ -1114,9 +1112,17 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1114
1112
  return setTokenIndex(null);
1115
1113
  }
1116
1114
 
1117
- return setTokenIndex(function (prevTokenIndex) {
1115
+ setTokenIndex(function (prevTokenIndex) {
1118
1116
  return prevTokenIndex + 1;
1119
1117
  });
1118
+
1119
+ var _tokenElement = document.getElementById(name + "_token_" + tokenIndex);
1120
+
1121
+ if (!_tokenElement || !scrollRef.current) return;
1122
+ return scrollRef.current.scrollBy({
1123
+ left: _tokenElement.getBoundingClientRect().width,
1124
+ behavior: 'smooth'
1125
+ });
1120
1126
  }
1121
1127
  }
1122
1128
  };
@@ -1135,7 +1141,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1135
1141
  var onBlur = function onBlur() {
1136
1142
  clearErrors(name);
1137
1143
 
1138
- if (localValue.trim()) {
1144
+ if (localValue.trim().length) {
1139
1145
  var filteredUniqueValues = Array.from(new Set([].concat(lastestFormValueToArray, localValue.trim().split(','))));
1140
1146
  setValue(name, filteredUniqueValues.toString().replace(/\s/g, ''), {
1141
1147
  shouldValidate: true,
@@ -1157,7 +1163,6 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1157
1163
  fontSize: "13px",
1158
1164
  border: isFocussed ? '2px solid' : '1px solid',
1159
1165
  borderColor: isFocussed ? colors.border.focus : colors.border["default"],
1160
- py: "5px",
1161
1166
  pl: "8px",
1162
1167
  borderRadius: "4px",
1163
1168
  alignItems: "center",
@@ -1174,11 +1179,11 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1174
1179
  ref: inputWrapperRef,
1175
1180
  h: "26px"
1176
1181
  }, /*#__PURE__*/React__default.createElement(react.Flex, {
1177
- h: "18px",
1182
+ h: "100%",
1178
1183
  alignItems: "center",
1179
- // width="fit-content"
1180
- // maxW="80%"
1181
1184
  overflowX: "scroll",
1185
+ overflowY: "hidden",
1186
+ maxWidth: isFocussed ? '80%' : '100%',
1182
1187
  style: {
1183
1188
  scrollbarWidth: 'none'
1184
1189
  /* Firefox */
@@ -1197,9 +1202,10 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1197
1202
  border: tokenIndex === index ? "1px solid " + colors.border.focus : 'none',
1198
1203
  borderRadius: "full",
1199
1204
  onClick: function onClick() {
1200
- return setTokenIndex(index);
1205
+ return isFocussed && setTokenIndex(index);
1201
1206
  },
1202
- width: "100%"
1207
+ width: "100%",
1208
+ id: name + "_token_" + index
1203
1209
  }, /*#__PURE__*/React__default.createElement(Token, {
1204
1210
  label: label,
1205
1211
  onDelete: function onDelete(e) {
@@ -1212,12 +1218,14 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1212
1218
  color: colors.label.secondary.light,
1213
1219
  fontSize: "13px"
1214
1220
  }, placeholder)), /*#__PURE__*/React__default.createElement(react.Flex, {
1215
- flex: 1
1221
+ flex: 1,
1222
+ minWidth: isFocussed ? '20%' : 0
1216
1223
  }, /*#__PURE__*/React__default.createElement(react.Input, {
1217
1224
  onKeyDown: onHandleKeyDown,
1218
1225
  type: "text",
1219
1226
  padding: 0,
1220
- width: "100%",
1227
+ alignContent: "flex-start",
1228
+ "float": "right",
1221
1229
  border: "none",
1222
1230
  height: "auto",
1223
1231
  color: tokenIndex !== null ? 'transparent' : colors.label.primary,
@@ -1226,7 +1234,7 @@ var StackedPilledInput = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1226
1234
  },
1227
1235
  value: localValue,
1228
1236
  onChange: function onChange(e) {
1229
- return tokenIndex === null && setLocalValue(e.target.value);
1237
+ return tokenIndex === null && setLocalValue(e.target.value.trim().replace(',', '').length ? e.target.value : '');
1230
1238
  },
1231
1239
  ref: inputRef,
1232
1240
  onFocus: function onFocus() {