@xqmsg/ui-core 0.24.3 → 0.24.5

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.
@@ -807,7 +807,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
807
807
  return target;
808
808
  }
809
809
 
810
- var _excluded = ["type", "isRequired", "rightElement", "leftElement", "defaultValue", "allowDefault", "variant", "label"];
810
+ var _excluded = ["type", "isRequired", "rightElement", "leftElement", "defaultValue", "variant", "label"];
811
811
  /**
812
812
  * A functional React component utilized to render the `StackedInput` component.
813
813
  */
@@ -818,7 +818,6 @@ var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref)
818
818
  rightElement = _ref2.rightElement,
819
819
  leftElement = _ref2.leftElement,
820
820
  defaultValue = _ref2.defaultValue,
821
- allowDefault = _ref2.allowDefault,
822
821
  variant = _ref2.variant,
823
822
  label = _ref2.label,
824
823
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
@@ -831,13 +830,7 @@ var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref)
831
830
  ref: _ref,
832
831
  defaultValue: defaultValue,
833
832
  fontSize: isMobile ? '17px' : '13px',
834
- variant: variant,
835
- onKeyDown: function onKeyDown(e) {
836
- if (e.key === 'Enter' && !allowDefault) {
837
- e.stopPropagation();
838
- e.preventDefault();
839
- }
840
- }
833
+ variant: variant
841
834
  })), rightElement && rightElement);
842
835
  });
843
836
 
@@ -873,9 +866,29 @@ var Dropdown = function Dropdown(_ref) {
873
866
  dropdownRef = _ref.dropdownRef,
874
867
  position = _ref.position,
875
868
  optionIndex = _ref.optionIndex,
876
- children = _ref.children;
869
+ children = _ref.children,
870
+ _ref$loading = _ref.loading,
871
+ loading = _ref$loading === void 0 ? false : _ref$loading;
877
872
  var DropdownContent = useMemo(function () {
878
- if (!options || options.length === 0) {
873
+ if (loading) {
874
+ return /*#__PURE__*/React__default.createElement(Box, {
875
+ borderRadius: "inherit",
876
+ fontSize: "13px",
877
+ px: "8px",
878
+ py: "4px",
879
+ width: "100%",
880
+ color: colors.label.primary.light,
881
+ bg: "inherit",
882
+ whiteSpace: "nowrap"
883
+ }, /*#__PURE__*/React__default.createElement(Flex, {
884
+ alignItems: "center"
885
+ }, "Loading", /*#__PURE__*/React__default.createElement(Spinner, {
886
+ size: "xs",
887
+ opacity: 0.5,
888
+ ml: 2
889
+ })));
890
+ }
891
+ if (!loading && (!options || options.length === 0)) {
879
892
  return /*#__PURE__*/React__default.createElement(Box, {
880
893
  borderRadius: "inherit",
881
894
  fontSize: "13px",
@@ -1021,7 +1034,7 @@ var Dropdown$1 = function Dropdown(_ref) {
1021
1034
  });
1022
1035
  };
1023
1036
 
1024
- var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions"];
1037
+ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions", "loadingOptions"];
1025
1038
  /**
1026
1039
  * A functional React component utilized to render the `StackedSelect` component.
1027
1040
  */
@@ -1035,6 +1048,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1035
1048
  disabled = _ref2.disabled,
1036
1049
  value = _ref2.value,
1037
1050
  fullOptions = _ref2.fullOptions,
1051
+ loadingOptions = _ref2.loadingOptions,
1038
1052
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
1039
1053
  var dropdownRef = useRef(null);
1040
1054
  var dropdownMenuRef = useRef(null);
@@ -1088,27 +1102,27 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1088
1102
  setSearchValue('');
1089
1103
  };
1090
1104
  var handleOnKeyDown = function handleOnKeyDown(e) {
1091
- var initialOptionIndex = options[0].value === 'section_header' ? 1 : 0;
1105
+ var initialOptionIndex = filteredOptions.length && filteredOptions[0].value === 'section_header' ? 1 : 0;
1092
1106
  if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1093
1107
  setIsFocussed(true);
1094
1108
  return setOptionIndex(initialOptionIndex);
1095
1109
  }
1096
- if (isFocussed) {
1110
+ if (isFocussed && filteredOptions.length > 0) {
1097
1111
  if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1098
1112
  return setOptionIndex(initialOptionIndex);
1099
1113
  }
1100
1114
  if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
1101
1115
  var _dropdownMenuRef$curr;
1102
- var incrementValue = options[optionIndex - 1] && options[optionIndex - 1].value === 'section_header' ? 2 : 1;
1116
+ var incrementValue = filteredOptions[optionIndex - 1] && filteredOptions[optionIndex - 1].value === 'section_header' ? 2 : 1;
1103
1117
  setOptionIndex(optionIndex - incrementValue);
1104
1118
  return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
1105
1119
  top: optionIndex * 24,
1106
1120
  behavior: 'smooth'
1107
1121
  });
1108
1122
  }
1109
- if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < options.length) {
1123
+ if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < filteredOptions.length) {
1110
1124
  var _dropdownMenuRef$curr2;
1111
- var _incrementValue = options[optionIndex + 1] && options[optionIndex + 1].value === 'section_header' ? 2 : 1;
1125
+ var _incrementValue = filteredOptions[optionIndex + 1] && filteredOptions[optionIndex + 1].value === 'section_header' ? 2 : 1;
1112
1126
  setOptionIndex(optionIndex + _incrementValue);
1113
1127
  return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
1114
1128
  top: optionIndex * 24,
@@ -1116,7 +1130,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1116
1130
  });
1117
1131
  }
1118
1132
  if (e.key === 'Enter' && optionIndex !== null) {
1119
- var option = options.find(function (_, idx) {
1133
+ var option = filteredOptions.find(function (_, idx) {
1120
1134
  return optionIndex === idx;
1121
1135
  });
1122
1136
  if (!option) return;
@@ -1154,12 +1168,11 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1154
1168
  }, [options, searchValue]);
1155
1169
  var handleInput = function handleInput(e) {
1156
1170
  var _filteredOptions$;
1157
- var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1171
+ var initialOptionIndex = filteredOptions.length && ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1158
1172
  setOptionIndex(initialOptionIndex);
1159
1173
  var value = e.target.value;
1160
1174
  setSearchValue(value);
1161
1175
  };
1162
- console.log(searchValue);
1163
1176
  return /*#__PURE__*/React__default.createElement(Box, {
1164
1177
  ref: dropdownRef,
1165
1178
  position: "relative"
@@ -1170,7 +1183,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1170
1183
  onClick: function onClick() {
1171
1184
  return setIsFocussed(!isFocussed);
1172
1185
  },
1173
- cursor: isFocussed ? 'select' : 'pointer',
1186
+ cursor: isFocussed ? 'default' : 'pointer',
1187
+ color: loadingOptions ? 'transparent' : 'inital',
1174
1188
  fontSize: "13px",
1175
1189
  value: isFocussed ? searchValue : selectedOption,
1176
1190
  autoComplete: "off",
@@ -1189,17 +1203,17 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1189
1203
  dropdownRef: dropdownMenuRef,
1190
1204
  onSelectItem: handleOnSelectItem,
1191
1205
  options: filteredOptions,
1192
- optionIndex: optionIndex
1206
+ optionIndex: optionIndex,
1207
+ loading: loadingOptions
1193
1208
  }));
1194
1209
  });
1195
1210
 
1196
- var _excluded$2 = ["isRequired", "allowDefault", "variant", "label"];
1211
+ var _excluded$2 = ["isRequired", "variant", "label"];
1197
1212
  /**
1198
1213
  * A functional React component utilized to render the `StackedTextarea` component.
1199
1214
  */
1200
1215
  var StackedTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref) {
1201
- var allowDefault = _ref2.allowDefault,
1202
- variant = _ref2.variant,
1216
+ var variant = _ref2.variant,
1203
1217
  label = _ref2.label,
1204
1218
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
1205
1219
  var isMobile = variant === 'mobile';
@@ -1209,26 +1223,14 @@ var StackedTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref2, _r
1209
1223
  }, props, {
1210
1224
  variant: variant,
1211
1225
  fontSize: "17px",
1212
- placeholder: label != null ? label : '',
1213
- onKeyDown: function onKeyDown(e) {
1214
- if (e.key === 'Enter' && !allowDefault) {
1215
- e.stopPropagation();
1216
- e.preventDefault();
1217
- }
1218
- }
1226
+ placeholder: label != null ? label : ''
1219
1227
  })));
1220
1228
  }
1221
1229
  return /*#__PURE__*/React__default.createElement(Textarea$1, Object.assign({
1222
1230
  ref: _ref
1223
1231
  }, props, {
1224
1232
  variant: variant,
1225
- fontSize: "13px",
1226
- onKeyDown: function onKeyDown(e) {
1227
- if (e.key === 'Enter' && !allowDefault) {
1228
- e.stopPropagation();
1229
- e.preventDefault();
1230
- }
1231
- }
1233
+ fontSize: "13px"
1232
1234
  }));
1233
1235
  });
1234
1236
 
@@ -1307,7 +1309,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1307
1309
  control = _ref2.control,
1308
1310
  name = _ref2.name,
1309
1311
  placeholder = _ref2.placeholder,
1310
- disabled = _ref2.disabled;
1312
+ disabled = _ref2.disabled,
1313
+ loadingOptions = _ref2.loadingOptions;
1311
1314
  var watchedValue = useWatch({
1312
1315
  control: control,
1313
1316
  name: name
@@ -1492,7 +1495,6 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1492
1495
  }, [localOptions, searchValue]);
1493
1496
  var handleInput = function handleInput(e) {
1494
1497
  var _filteredOptions$;
1495
- console.log(e);
1496
1498
  var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1497
1499
  setOptionIndex(initialOptionIndex);
1498
1500
  var value = e.target.value;
@@ -1581,10 +1583,12 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1581
1583
  },
1582
1584
  options: filteredOptions,
1583
1585
  position: position,
1584
- optionIndex: optionIndex
1586
+ optionIndex: optionIndex,
1587
+ loading: loadingOptions
1585
1588
  }, /*#__PURE__*/React__default.createElement(Input$2, {
1586
1589
  value: searchValue,
1587
- onChange: handleInput
1590
+ onChange: handleInput,
1591
+ disabled: loadingOptions
1588
1592
  })));
1589
1593
  });
1590
1594
 
@@ -1920,14 +1924,15 @@ function Input(_ref) {
1920
1924
  disabled = _ref.disabled,
1921
1925
  rightElement = _ref.rightElement,
1922
1926
  leftElement = _ref.leftElement,
1923
- allowDefault = _ref.allowDefault,
1924
1927
  _ref$variant = _ref.variant,
1925
1928
  variant = _ref$variant === void 0 ? 'default' : _ref$variant,
1926
1929
  onChange = _ref.onChange,
1927
1930
  setValue = _ref.setValue,
1928
1931
  setError = _ref.setError,
1929
1932
  clearErrors = _ref.clearErrors,
1930
- separators = _ref.separators;
1933
+ separators = _ref.separators,
1934
+ _ref$loadingOptions = _ref.loadingOptions,
1935
+ loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions;
1931
1936
  function selectedInputField(onChange, onBlur, ref, value) {
1932
1937
  switch (inputType) {
1933
1938
  case 'text':
@@ -1948,7 +1953,6 @@ function Input(_ref) {
1948
1953
  disabled: disabled,
1949
1954
  defaultValue: defaultValue,
1950
1955
  value: value,
1951
- allowDefault: allowDefault,
1952
1956
  variant: variant,
1953
1957
  label: label
1954
1958
  });
@@ -1982,7 +1986,8 @@ function Input(_ref) {
1982
1986
  value: value,
1983
1987
  defaultValue: defaultValue,
1984
1988
  placeholder: placeholder,
1985
- fullOptions: fullOptions
1989
+ fullOptions: fullOptions,
1990
+ loadingOptions: loadingOptions
1986
1991
  });
1987
1992
  case 'textarea':
1988
1993
  return /*#__PURE__*/React__default.createElement(StackedTextarea, {
@@ -2033,7 +2038,8 @@ function Input(_ref) {
2033
2038
  control: control,
2034
2039
  setError: setError,
2035
2040
  clearErrors: clearErrors,
2036
- placeholder: placeholder
2041
+ placeholder: placeholder,
2042
+ loadingOptions: loadingOptions
2037
2043
  });
2038
2044
  case 'pilled-text':
2039
2045
  return /*#__PURE__*/React__default.createElement(StackedPilledInput, {