@xqmsg/ui-core 0.24.3 → 0.24.4

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.
@@ -873,9 +873,29 @@ var Dropdown = function Dropdown(_ref) {
873
873
  dropdownRef = _ref.dropdownRef,
874
874
  position = _ref.position,
875
875
  optionIndex = _ref.optionIndex,
876
- children = _ref.children;
876
+ children = _ref.children,
877
+ _ref$loading = _ref.loading,
878
+ loading = _ref$loading === void 0 ? false : _ref$loading;
877
879
  var DropdownContent = useMemo(function () {
878
- if (!options || options.length === 0) {
880
+ if (loading) {
881
+ return /*#__PURE__*/React__default.createElement(Box, {
882
+ borderRadius: "inherit",
883
+ fontSize: "13px",
884
+ px: "8px",
885
+ py: "4px",
886
+ width: "100%",
887
+ color: colors.label.primary.light,
888
+ bg: "inherit",
889
+ whiteSpace: "nowrap"
890
+ }, /*#__PURE__*/React__default.createElement(Flex, {
891
+ alignItems: "center"
892
+ }, "Loading", /*#__PURE__*/React__default.createElement(Spinner, {
893
+ size: "xs",
894
+ opacity: 0.5,
895
+ ml: 2
896
+ })));
897
+ }
898
+ if (!loading && (!options || options.length === 0)) {
879
899
  return /*#__PURE__*/React__default.createElement(Box, {
880
900
  borderRadius: "inherit",
881
901
  fontSize: "13px",
@@ -1021,7 +1041,7 @@ var Dropdown$1 = function Dropdown(_ref) {
1021
1041
  });
1022
1042
  };
1023
1043
 
1024
- var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions"];
1044
+ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions", "loadingOptions"];
1025
1045
  /**
1026
1046
  * A functional React component utilized to render the `StackedSelect` component.
1027
1047
  */
@@ -1035,6 +1055,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1035
1055
  disabled = _ref2.disabled,
1036
1056
  value = _ref2.value,
1037
1057
  fullOptions = _ref2.fullOptions,
1058
+ loadingOptions = _ref2.loadingOptions,
1038
1059
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
1039
1060
  var dropdownRef = useRef(null);
1040
1061
  var dropdownMenuRef = useRef(null);
@@ -1088,27 +1109,27 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1088
1109
  setSearchValue('');
1089
1110
  };
1090
1111
  var handleOnKeyDown = function handleOnKeyDown(e) {
1091
- var initialOptionIndex = options[0].value === 'section_header' ? 1 : 0;
1112
+ var initialOptionIndex = filteredOptions.length && filteredOptions[0].value === 'section_header' ? 1 : 0;
1092
1113
  if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1093
1114
  setIsFocussed(true);
1094
1115
  return setOptionIndex(initialOptionIndex);
1095
1116
  }
1096
- if (isFocussed) {
1117
+ if (isFocussed && filteredOptions.length > 0) {
1097
1118
  if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1098
1119
  return setOptionIndex(initialOptionIndex);
1099
1120
  }
1100
1121
  if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
1101
1122
  var _dropdownMenuRef$curr;
1102
- var incrementValue = options[optionIndex - 1] && options[optionIndex - 1].value === 'section_header' ? 2 : 1;
1123
+ var incrementValue = filteredOptions[optionIndex - 1] && filteredOptions[optionIndex - 1].value === 'section_header' ? 2 : 1;
1103
1124
  setOptionIndex(optionIndex - incrementValue);
1104
1125
  return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
1105
1126
  top: optionIndex * 24,
1106
1127
  behavior: 'smooth'
1107
1128
  });
1108
1129
  }
1109
- if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < options.length) {
1130
+ if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < filteredOptions.length) {
1110
1131
  var _dropdownMenuRef$curr2;
1111
- var _incrementValue = options[optionIndex + 1] && options[optionIndex + 1].value === 'section_header' ? 2 : 1;
1132
+ var _incrementValue = filteredOptions[optionIndex + 1] && filteredOptions[optionIndex + 1].value === 'section_header' ? 2 : 1;
1112
1133
  setOptionIndex(optionIndex + _incrementValue);
1113
1134
  return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
1114
1135
  top: optionIndex * 24,
@@ -1116,7 +1137,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1116
1137
  });
1117
1138
  }
1118
1139
  if (e.key === 'Enter' && optionIndex !== null) {
1119
- var option = options.find(function (_, idx) {
1140
+ var option = filteredOptions.find(function (_, idx) {
1120
1141
  return optionIndex === idx;
1121
1142
  });
1122
1143
  if (!option) return;
@@ -1154,12 +1175,11 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1154
1175
  }, [options, searchValue]);
1155
1176
  var handleInput = function handleInput(e) {
1156
1177
  var _filteredOptions$;
1157
- var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1178
+ var initialOptionIndex = filteredOptions.length && ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1158
1179
  setOptionIndex(initialOptionIndex);
1159
1180
  var value = e.target.value;
1160
1181
  setSearchValue(value);
1161
1182
  };
1162
- console.log(searchValue);
1163
1183
  return /*#__PURE__*/React__default.createElement(Box, {
1164
1184
  ref: dropdownRef,
1165
1185
  position: "relative"
@@ -1170,7 +1190,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1170
1190
  onClick: function onClick() {
1171
1191
  return setIsFocussed(!isFocussed);
1172
1192
  },
1173
- cursor: isFocussed ? 'select' : 'pointer',
1193
+ cursor: isFocussed ? 'default' : 'pointer',
1194
+ color: loadingOptions ? 'transparent' : 'inital',
1174
1195
  fontSize: "13px",
1175
1196
  value: isFocussed ? searchValue : selectedOption,
1176
1197
  autoComplete: "off",
@@ -1189,7 +1210,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1189
1210
  dropdownRef: dropdownMenuRef,
1190
1211
  onSelectItem: handleOnSelectItem,
1191
1212
  options: filteredOptions,
1192
- optionIndex: optionIndex
1213
+ optionIndex: optionIndex,
1214
+ loading: loadingOptions
1193
1215
  }));
1194
1216
  });
1195
1217
 
@@ -1307,7 +1329,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1307
1329
  control = _ref2.control,
1308
1330
  name = _ref2.name,
1309
1331
  placeholder = _ref2.placeholder,
1310
- disabled = _ref2.disabled;
1332
+ disabled = _ref2.disabled,
1333
+ loadingOptions = _ref2.loadingOptions;
1311
1334
  var watchedValue = useWatch({
1312
1335
  control: control,
1313
1336
  name: name
@@ -1492,7 +1515,6 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1492
1515
  }, [localOptions, searchValue]);
1493
1516
  var handleInput = function handleInput(e) {
1494
1517
  var _filteredOptions$;
1495
- console.log(e);
1496
1518
  var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1497
1519
  setOptionIndex(initialOptionIndex);
1498
1520
  var value = e.target.value;
@@ -1581,10 +1603,12 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1581
1603
  },
1582
1604
  options: filteredOptions,
1583
1605
  position: position,
1584
- optionIndex: optionIndex
1606
+ optionIndex: optionIndex,
1607
+ loading: loadingOptions
1585
1608
  }, /*#__PURE__*/React__default.createElement(Input$2, {
1586
1609
  value: searchValue,
1587
- onChange: handleInput
1610
+ onChange: handleInput,
1611
+ disabled: loadingOptions
1588
1612
  })));
1589
1613
  });
1590
1614
 
@@ -1927,7 +1951,9 @@ function Input(_ref) {
1927
1951
  setValue = _ref.setValue,
1928
1952
  setError = _ref.setError,
1929
1953
  clearErrors = _ref.clearErrors,
1930
- separators = _ref.separators;
1954
+ separators = _ref.separators,
1955
+ _ref$loadingOptions = _ref.loadingOptions,
1956
+ loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions;
1931
1957
  function selectedInputField(onChange, onBlur, ref, value) {
1932
1958
  switch (inputType) {
1933
1959
  case 'text':
@@ -1982,7 +2008,8 @@ function Input(_ref) {
1982
2008
  value: value,
1983
2009
  defaultValue: defaultValue,
1984
2010
  placeholder: placeholder,
1985
- fullOptions: fullOptions
2011
+ fullOptions: fullOptions,
2012
+ loadingOptions: loadingOptions
1986
2013
  });
1987
2014
  case 'textarea':
1988
2015
  return /*#__PURE__*/React__default.createElement(StackedTextarea, {
@@ -2033,7 +2060,8 @@ function Input(_ref) {
2033
2060
  control: control,
2034
2061
  setError: setError,
2035
2062
  clearErrors: clearErrors,
2036
- placeholder: placeholder
2063
+ placeholder: placeholder,
2064
+ loadingOptions: loadingOptions
2037
2065
  });
2038
2066
  case 'pilled-text':
2039
2067
  return /*#__PURE__*/React__default.createElement(StackedPilledInput, {