@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.
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { InputFieldProps } from '../InputTypes';
3
3
  export interface StackedInputProps extends InputFieldProps {
4
4
  isRequired?: boolean;
5
- allowDefault?: boolean;
6
5
  leftElement?: React.ReactNode;
7
6
  rightElement?: React.ReactNode;
8
7
  variant?: string;
@@ -7,6 +7,7 @@ export interface StackedMultiSelectProps extends ReactSelectFieldProps {
7
7
  setError: UseFormSetError<FieldValues>;
8
8
  clearErrors: UseFormClearErrors<FieldValues>;
9
9
  control: Control<FieldValues, any>;
10
+ loadingOptions?: boolean;
10
11
  }
11
12
  /**
12
13
  * A functional React component utilized to render the `StackedMultiSelect` component.
@@ -8,6 +8,7 @@ export interface StackedSelectProps extends StackedInputProps {
8
8
  setValue: UseFormSetValue<FieldValues>;
9
9
  control: Control<FieldValues, any>;
10
10
  handleOnChange: (value?: string) => void;
11
+ loadingOptions?: boolean;
11
12
  }
12
13
  /**
13
14
  * A functional React component utilized to render the `StackedSelect` component.
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import { TextareaFieldProps } from '../InputTypes';
3
3
  export interface StackedTextareaProps extends TextareaFieldProps {
4
4
  isRequired?: boolean;
5
- allowDefault?: boolean;
6
5
  variant: string;
7
6
  label?: string;
8
7
  }
@@ -7,6 +7,7 @@ export interface DropdownProps {
7
7
  position: 'top' | 'bottom';
8
8
  optionIndex?: number | null;
9
9
  children?: React.ReactNode;
10
+ loading?: boolean;
10
11
  }
11
12
  /**
12
13
  * A functional React component utilized to render the `Dropdown` component
@@ -21,13 +21,13 @@ export interface InputProps<T extends FieldValues = FieldValues> extends Validat
21
21
  setError: UseFormSetError<T>;
22
22
  clearErrors: UseFormClearErrors<T>;
23
23
  leftElement?: React.ReactNode;
24
- allowDefault?: boolean;
25
24
  rightElement?: React.ReactNode;
26
25
  variant?: string;
27
26
  separators?: string[];
27
+ loadingOptions?: boolean;
28
28
  }
29
29
  /**
30
30
  * A functional React component utilized to render the `Input` component. Utilizes a switch statement
31
31
  * to render the correct input based on the `inputType`.
32
32
  */
33
- export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, allowDefault, variant, onChange, setValue, setError, clearErrors, separators, }: InputProps<T>): React.JSX.Element;
33
+ export declare function Input<T extends FieldValues>({ inputType, label, ariaLabel, className, placeholder, name, helperText, options, tooltipText, isInvalid, errorText, isRequired, maxLength, defaultValue, fullOptions, control, disabled, rightElement, leftElement, variant, onChange, setValue, setError, clearErrors, separators, loadingOptions, }: InputProps<T>): React.JSX.Element;
@@ -20,7 +20,6 @@ export interface SelectNativeProps<T extends FieldValues> extends ValidationProp
20
20
  setValue: UseFormSetValue<T>;
21
21
  setError: UseFormSetError<T>;
22
22
  clearErrors: UseFormClearErrors<T>;
23
- allowDefault?: boolean;
24
23
  }
25
24
  /**
26
25
  * A functional React component utilized to render the `SelectNative` component.
@@ -814,7 +814,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
814
814
  return target;
815
815
  }
816
816
 
817
- var _excluded = ["type", "isRequired", "rightElement", "leftElement", "defaultValue", "allowDefault", "variant", "label"];
817
+ var _excluded = ["type", "isRequired", "rightElement", "leftElement", "defaultValue", "variant", "label"];
818
818
  /**
819
819
  * A functional React component utilized to render the `StackedInput` component.
820
820
  */
@@ -825,7 +825,6 @@ var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref)
825
825
  rightElement = _ref2.rightElement,
826
826
  leftElement = _ref2.leftElement,
827
827
  defaultValue = _ref2.defaultValue,
828
- allowDefault = _ref2.allowDefault,
829
828
  variant = _ref2.variant,
830
829
  label = _ref2.label,
831
830
  props = _objectWithoutPropertiesLoose(_ref2, _excluded);
@@ -838,13 +837,7 @@ var StackedInput = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref)
838
837
  ref: _ref,
839
838
  defaultValue: defaultValue,
840
839
  fontSize: isMobile ? '17px' : '13px',
841
- variant: variant,
842
- onKeyDown: function onKeyDown(e) {
843
- if (e.key === 'Enter' && !allowDefault) {
844
- e.stopPropagation();
845
- e.preventDefault();
846
- }
847
- }
840
+ variant: variant
848
841
  })), rightElement && rightElement);
849
842
  });
850
843
 
@@ -880,9 +873,29 @@ var Dropdown = function Dropdown(_ref) {
880
873
  dropdownRef = _ref.dropdownRef,
881
874
  position = _ref.position,
882
875
  optionIndex = _ref.optionIndex,
883
- children = _ref.children;
876
+ children = _ref.children,
877
+ _ref$loading = _ref.loading,
878
+ loading = _ref$loading === void 0 ? false : _ref$loading;
884
879
  var DropdownContent = React.useMemo(function () {
885
- if (!options || options.length === 0) {
880
+ if (loading) {
881
+ return /*#__PURE__*/React__default.createElement(react.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(react.Flex, {
891
+ alignItems: "center"
892
+ }, "Loading", /*#__PURE__*/React__default.createElement(react.Spinner, {
893
+ size: "xs",
894
+ opacity: 0.5,
895
+ ml: 2
896
+ })));
897
+ }
898
+ if (!loading && (!options || options.length === 0)) {
886
899
  return /*#__PURE__*/React__default.createElement(react.Box, {
887
900
  borderRadius: "inherit",
888
901
  fontSize: "13px",
@@ -1028,7 +1041,7 @@ var Dropdown$1 = function Dropdown(_ref) {
1028
1041
  });
1029
1042
  };
1030
1043
 
1031
- var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions"];
1044
+ var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions", "loadingOptions"];
1032
1045
  /**
1033
1046
  * A functional React component utilized to render the `StackedSelect` component.
1034
1047
  */
@@ -1042,6 +1055,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1042
1055
  disabled = _ref2.disabled,
1043
1056
  value = _ref2.value,
1044
1057
  fullOptions = _ref2.fullOptions,
1058
+ loadingOptions = _ref2.loadingOptions,
1045
1059
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
1046
1060
  var dropdownRef = React.useRef(null);
1047
1061
  var dropdownMenuRef = React.useRef(null);
@@ -1095,27 +1109,27 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1095
1109
  setSearchValue('');
1096
1110
  };
1097
1111
  var handleOnKeyDown = function handleOnKeyDown(e) {
1098
- var initialOptionIndex = options[0].value === 'section_header' ? 1 : 0;
1112
+ var initialOptionIndex = filteredOptions.length && filteredOptions[0].value === 'section_header' ? 1 : 0;
1099
1113
  if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1100
1114
  setIsFocussed(true);
1101
1115
  return setOptionIndex(initialOptionIndex);
1102
1116
  }
1103
- if (isFocussed) {
1117
+ if (isFocussed && filteredOptions.length > 0) {
1104
1118
  if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
1105
1119
  return setOptionIndex(initialOptionIndex);
1106
1120
  }
1107
1121
  if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
1108
1122
  var _dropdownMenuRef$curr;
1109
- 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;
1110
1124
  setOptionIndex(optionIndex - incrementValue);
1111
1125
  return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
1112
1126
  top: optionIndex * 24,
1113
1127
  behavior: 'smooth'
1114
1128
  });
1115
1129
  }
1116
- if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < options.length) {
1130
+ if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < filteredOptions.length) {
1117
1131
  var _dropdownMenuRef$curr2;
1118
- 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;
1119
1133
  setOptionIndex(optionIndex + _incrementValue);
1120
1134
  return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
1121
1135
  top: optionIndex * 24,
@@ -1123,7 +1137,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1123
1137
  });
1124
1138
  }
1125
1139
  if (e.key === 'Enter' && optionIndex !== null) {
1126
- var option = options.find(function (_, idx) {
1140
+ var option = filteredOptions.find(function (_, idx) {
1127
1141
  return optionIndex === idx;
1128
1142
  });
1129
1143
  if (!option) return;
@@ -1161,12 +1175,11 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1161
1175
  }, [options, searchValue]);
1162
1176
  var handleInput = function handleInput(e) {
1163
1177
  var _filteredOptions$;
1164
- 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;
1165
1179
  setOptionIndex(initialOptionIndex);
1166
1180
  var value = e.target.value;
1167
1181
  setSearchValue(value);
1168
1182
  };
1169
- console.log(searchValue);
1170
1183
  return /*#__PURE__*/React__default.createElement(react.Box, {
1171
1184
  ref: dropdownRef,
1172
1185
  position: "relative"
@@ -1177,7 +1190,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1177
1190
  onClick: function onClick() {
1178
1191
  return setIsFocussed(!isFocussed);
1179
1192
  },
1180
- cursor: isFocussed ? 'select' : 'pointer',
1193
+ cursor: isFocussed ? 'default' : 'pointer',
1194
+ color: loadingOptions ? 'transparent' : 'inital',
1181
1195
  fontSize: "13px",
1182
1196
  value: isFocussed ? searchValue : selectedOption,
1183
1197
  autoComplete: "off",
@@ -1196,17 +1210,17 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
1196
1210
  dropdownRef: dropdownMenuRef,
1197
1211
  onSelectItem: handleOnSelectItem,
1198
1212
  options: filteredOptions,
1199
- optionIndex: optionIndex
1213
+ optionIndex: optionIndex,
1214
+ loading: loadingOptions
1200
1215
  }));
1201
1216
  });
1202
1217
 
1203
- var _excluded$2 = ["isRequired", "allowDefault", "variant", "label"];
1218
+ var _excluded$2 = ["isRequired", "variant", "label"];
1204
1219
  /**
1205
1220
  * A functional React component utilized to render the `StackedTextarea` component.
1206
1221
  */
1207
1222
  var StackedTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref) {
1208
- var allowDefault = _ref2.allowDefault,
1209
- variant = _ref2.variant,
1223
+ var variant = _ref2.variant,
1210
1224
  label = _ref2.label,
1211
1225
  props = _objectWithoutPropertiesLoose(_ref2, _excluded$2);
1212
1226
  var isMobile = variant === 'mobile';
@@ -1216,26 +1230,14 @@ var StackedTextarea = /*#__PURE__*/React__default.forwardRef(function (_ref2, _r
1216
1230
  }, props, {
1217
1231
  variant: variant,
1218
1232
  fontSize: "17px",
1219
- placeholder: label != null ? label : '',
1220
- onKeyDown: function onKeyDown(e) {
1221
- if (e.key === 'Enter' && !allowDefault) {
1222
- e.stopPropagation();
1223
- e.preventDefault();
1224
- }
1225
- }
1233
+ placeholder: label != null ? label : ''
1226
1234
  })));
1227
1235
  }
1228
1236
  return /*#__PURE__*/React__default.createElement(react.Textarea, Object.assign({
1229
1237
  ref: _ref
1230
1238
  }, props, {
1231
1239
  variant: variant,
1232
- fontSize: "13px",
1233
- onKeyDown: function onKeyDown(e) {
1234
- if (e.key === 'Enter' && !allowDefault) {
1235
- e.stopPropagation();
1236
- e.preventDefault();
1237
- }
1238
- }
1240
+ fontSize: "13px"
1239
1241
  }));
1240
1242
  });
1241
1243
 
@@ -1314,7 +1316,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1314
1316
  control = _ref2.control,
1315
1317
  name = _ref2.name,
1316
1318
  placeholder = _ref2.placeholder,
1317
- disabled = _ref2.disabled;
1319
+ disabled = _ref2.disabled,
1320
+ loadingOptions = _ref2.loadingOptions;
1318
1321
  var watchedValue = reactHookForm.useWatch({
1319
1322
  control: control,
1320
1323
  name: name
@@ -1499,7 +1502,6 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1499
1502
  }, [localOptions, searchValue]);
1500
1503
  var handleInput = function handleInput(e) {
1501
1504
  var _filteredOptions$;
1502
- console.log(e);
1503
1505
  var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
1504
1506
  setOptionIndex(initialOptionIndex);
1505
1507
  var value = e.target.value;
@@ -1588,10 +1590,12 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
1588
1590
  },
1589
1591
  options: filteredOptions,
1590
1592
  position: position,
1591
- optionIndex: optionIndex
1593
+ optionIndex: optionIndex,
1594
+ loading: loadingOptions
1592
1595
  }, /*#__PURE__*/React__default.createElement(react.Input, {
1593
1596
  value: searchValue,
1594
- onChange: handleInput
1597
+ onChange: handleInput,
1598
+ disabled: loadingOptions
1595
1599
  })));
1596
1600
  });
1597
1601
 
@@ -1927,14 +1931,15 @@ function Input(_ref) {
1927
1931
  disabled = _ref.disabled,
1928
1932
  rightElement = _ref.rightElement,
1929
1933
  leftElement = _ref.leftElement,
1930
- allowDefault = _ref.allowDefault,
1931
1934
  _ref$variant = _ref.variant,
1932
1935
  variant = _ref$variant === void 0 ? 'default' : _ref$variant,
1933
1936
  onChange = _ref.onChange,
1934
1937
  setValue = _ref.setValue,
1935
1938
  setError = _ref.setError,
1936
1939
  clearErrors = _ref.clearErrors,
1937
- separators = _ref.separators;
1940
+ separators = _ref.separators,
1941
+ _ref$loadingOptions = _ref.loadingOptions,
1942
+ loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions;
1938
1943
  function selectedInputField(onChange, onBlur, ref, value) {
1939
1944
  switch (inputType) {
1940
1945
  case 'text':
@@ -1955,7 +1960,6 @@ function Input(_ref) {
1955
1960
  disabled: disabled,
1956
1961
  defaultValue: defaultValue,
1957
1962
  value: value,
1958
- allowDefault: allowDefault,
1959
1963
  variant: variant,
1960
1964
  label: label
1961
1965
  });
@@ -1989,7 +1993,8 @@ function Input(_ref) {
1989
1993
  value: value,
1990
1994
  defaultValue: defaultValue,
1991
1995
  placeholder: placeholder,
1992
- fullOptions: fullOptions
1996
+ fullOptions: fullOptions,
1997
+ loadingOptions: loadingOptions
1993
1998
  });
1994
1999
  case 'textarea':
1995
2000
  return /*#__PURE__*/React__default.createElement(StackedTextarea, {
@@ -2040,7 +2045,8 @@ function Input(_ref) {
2040
2045
  control: control,
2041
2046
  setError: setError,
2042
2047
  clearErrors: clearErrors,
2043
- placeholder: placeholder
2048
+ placeholder: placeholder,
2049
+ loadingOptions: loadingOptions
2044
2050
  });
2045
2051
  case 'pilled-text':
2046
2052
  return /*#__PURE__*/React__default.createElement(StackedPilledInput, {