@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.
- package/dist/components/input/StackedMultiSelect/index.d.ts +1 -0
- package/dist/components/input/StackedSelect/index.d.ts +1 -0
- package/dist/components/input/components/dropdown/index.d.ts +1 -0
- package/dist/components/input/index.d.ts +2 -1
- package/dist/ui-core.cjs.development.js +48 -20
- 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 +48 -20
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/input/Input.stories.tsx +9 -0
- package/src/components/input/StackedMultiSelect/index.tsx +296 -284
- package/src/components/input/StackedSelect/index.tsx +19 -11
- package/src/components/input/components/dropdown/index.tsx +23 -2
- package/src/components/input/index.tsx +4 -0
|
@@ -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.
|
|
@@ -25,9 +25,10 @@ export interface InputProps<T extends FieldValues = FieldValues> extends Validat
|
|
|
25
25
|
rightElement?: React.ReactNode;
|
|
26
26
|
variant?: string;
|
|
27
27
|
separators?: string[];
|
|
28
|
+
loadingOptions?: boolean;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* A functional React component utilized to render the `Input` component. Utilizes a switch statement
|
|
31
32
|
* to render the correct input based on the `inputType`.
|
|
32
33
|
*/
|
|
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;
|
|
34
|
+
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, loadingOptions, }: InputProps<T>): React.JSX.Element;
|
|
@@ -880,9 +880,29 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
880
880
|
dropdownRef = _ref.dropdownRef,
|
|
881
881
|
position = _ref.position,
|
|
882
882
|
optionIndex = _ref.optionIndex,
|
|
883
|
-
children = _ref.children
|
|
883
|
+
children = _ref.children,
|
|
884
|
+
_ref$loading = _ref.loading,
|
|
885
|
+
loading = _ref$loading === void 0 ? false : _ref$loading;
|
|
884
886
|
var DropdownContent = React.useMemo(function () {
|
|
885
|
-
if (
|
|
887
|
+
if (loading) {
|
|
888
|
+
return /*#__PURE__*/React__default.createElement(react.Box, {
|
|
889
|
+
borderRadius: "inherit",
|
|
890
|
+
fontSize: "13px",
|
|
891
|
+
px: "8px",
|
|
892
|
+
py: "4px",
|
|
893
|
+
width: "100%",
|
|
894
|
+
color: colors.label.primary.light,
|
|
895
|
+
bg: "inherit",
|
|
896
|
+
whiteSpace: "nowrap"
|
|
897
|
+
}, /*#__PURE__*/React__default.createElement(react.Flex, {
|
|
898
|
+
alignItems: "center"
|
|
899
|
+
}, "Loading", /*#__PURE__*/React__default.createElement(react.Spinner, {
|
|
900
|
+
size: "xs",
|
|
901
|
+
opacity: 0.5,
|
|
902
|
+
ml: 2
|
|
903
|
+
})));
|
|
904
|
+
}
|
|
905
|
+
if (!loading && (!options || options.length === 0)) {
|
|
886
906
|
return /*#__PURE__*/React__default.createElement(react.Box, {
|
|
887
907
|
borderRadius: "inherit",
|
|
888
908
|
fontSize: "13px",
|
|
@@ -1028,7 +1048,7 @@ var Dropdown$1 = function Dropdown(_ref) {
|
|
|
1028
1048
|
});
|
|
1029
1049
|
};
|
|
1030
1050
|
|
|
1031
|
-
var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions"];
|
|
1051
|
+
var _excluded$1 = ["isRequired", "options", "name", "setValue", "handleOnChange", "disabled", "value", "fullOptions", "loadingOptions"];
|
|
1032
1052
|
/**
|
|
1033
1053
|
* A functional React component utilized to render the `StackedSelect` component.
|
|
1034
1054
|
*/
|
|
@@ -1042,6 +1062,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1042
1062
|
disabled = _ref2.disabled,
|
|
1043
1063
|
value = _ref2.value,
|
|
1044
1064
|
fullOptions = _ref2.fullOptions,
|
|
1065
|
+
loadingOptions = _ref2.loadingOptions,
|
|
1045
1066
|
props = _objectWithoutPropertiesLoose(_ref2, _excluded$1);
|
|
1046
1067
|
var dropdownRef = React.useRef(null);
|
|
1047
1068
|
var dropdownMenuRef = React.useRef(null);
|
|
@@ -1095,27 +1116,27 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1095
1116
|
setSearchValue('');
|
|
1096
1117
|
};
|
|
1097
1118
|
var handleOnKeyDown = function handleOnKeyDown(e) {
|
|
1098
|
-
var initialOptionIndex =
|
|
1119
|
+
var initialOptionIndex = filteredOptions.length && filteredOptions[0].value === 'section_header' ? 1 : 0;
|
|
1099
1120
|
if (!isFocussed && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
|
1100
1121
|
setIsFocussed(true);
|
|
1101
1122
|
return setOptionIndex(initialOptionIndex);
|
|
1102
1123
|
}
|
|
1103
|
-
if (isFocussed) {
|
|
1124
|
+
if (isFocussed && filteredOptions.length > 0) {
|
|
1104
1125
|
if (optionIndex === null && (e.key === 'Enter' || e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
|
1105
1126
|
return setOptionIndex(initialOptionIndex);
|
|
1106
1127
|
}
|
|
1107
1128
|
if (e.key === 'ArrowUp' && optionIndex !== null && optionIndex > 0) {
|
|
1108
1129
|
var _dropdownMenuRef$curr;
|
|
1109
|
-
var incrementValue =
|
|
1130
|
+
var incrementValue = filteredOptions[optionIndex - 1] && filteredOptions[optionIndex - 1].value === 'section_header' ? 2 : 1;
|
|
1110
1131
|
setOptionIndex(optionIndex - incrementValue);
|
|
1111
1132
|
return (_dropdownMenuRef$curr = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr.scrollTo({
|
|
1112
1133
|
top: optionIndex * 24,
|
|
1113
1134
|
behavior: 'smooth'
|
|
1114
1135
|
});
|
|
1115
1136
|
}
|
|
1116
|
-
if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex <
|
|
1137
|
+
if (e.key === 'ArrowDown' && optionIndex !== null && optionIndex < filteredOptions.length) {
|
|
1117
1138
|
var _dropdownMenuRef$curr2;
|
|
1118
|
-
var _incrementValue =
|
|
1139
|
+
var _incrementValue = filteredOptions[optionIndex + 1] && filteredOptions[optionIndex + 1].value === 'section_header' ? 2 : 1;
|
|
1119
1140
|
setOptionIndex(optionIndex + _incrementValue);
|
|
1120
1141
|
return (_dropdownMenuRef$curr2 = dropdownMenuRef.current) == null ? void 0 : _dropdownMenuRef$curr2.scrollTo({
|
|
1121
1142
|
top: optionIndex * 24,
|
|
@@ -1123,7 +1144,7 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1123
1144
|
});
|
|
1124
1145
|
}
|
|
1125
1146
|
if (e.key === 'Enter' && optionIndex !== null) {
|
|
1126
|
-
var option =
|
|
1147
|
+
var option = filteredOptions.find(function (_, idx) {
|
|
1127
1148
|
return optionIndex === idx;
|
|
1128
1149
|
});
|
|
1129
1150
|
if (!option) return;
|
|
@@ -1161,12 +1182,11 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1161
1182
|
}, [options, searchValue]);
|
|
1162
1183
|
var handleInput = function handleInput(e) {
|
|
1163
1184
|
var _filteredOptions$;
|
|
1164
|
-
var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
|
|
1185
|
+
var initialOptionIndex = filteredOptions.length && ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
|
|
1165
1186
|
setOptionIndex(initialOptionIndex);
|
|
1166
1187
|
var value = e.target.value;
|
|
1167
1188
|
setSearchValue(value);
|
|
1168
1189
|
};
|
|
1169
|
-
console.log(searchValue);
|
|
1170
1190
|
return /*#__PURE__*/React__default.createElement(react.Box, {
|
|
1171
1191
|
ref: dropdownRef,
|
|
1172
1192
|
position: "relative"
|
|
@@ -1177,7 +1197,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1177
1197
|
onClick: function onClick() {
|
|
1178
1198
|
return setIsFocussed(!isFocussed);
|
|
1179
1199
|
},
|
|
1180
|
-
cursor: isFocussed ? '
|
|
1200
|
+
cursor: isFocussed ? 'default' : 'pointer',
|
|
1201
|
+
color: loadingOptions ? 'transparent' : 'inital',
|
|
1181
1202
|
fontSize: "13px",
|
|
1182
1203
|
value: isFocussed ? searchValue : selectedOption,
|
|
1183
1204
|
autoComplete: "off",
|
|
@@ -1196,7 +1217,8 @@ var StackedSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2, _ref
|
|
|
1196
1217
|
dropdownRef: dropdownMenuRef,
|
|
1197
1218
|
onSelectItem: handleOnSelectItem,
|
|
1198
1219
|
options: filteredOptions,
|
|
1199
|
-
optionIndex: optionIndex
|
|
1220
|
+
optionIndex: optionIndex,
|
|
1221
|
+
loading: loadingOptions
|
|
1200
1222
|
}));
|
|
1201
1223
|
});
|
|
1202
1224
|
|
|
@@ -1314,7 +1336,8 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1314
1336
|
control = _ref2.control,
|
|
1315
1337
|
name = _ref2.name,
|
|
1316
1338
|
placeholder = _ref2.placeholder,
|
|
1317
|
-
disabled = _ref2.disabled
|
|
1339
|
+
disabled = _ref2.disabled,
|
|
1340
|
+
loadingOptions = _ref2.loadingOptions;
|
|
1318
1341
|
var watchedValue = reactHookForm.useWatch({
|
|
1319
1342
|
control: control,
|
|
1320
1343
|
name: name
|
|
@@ -1499,7 +1522,6 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1499
1522
|
}, [localOptions, searchValue]);
|
|
1500
1523
|
var handleInput = function handleInput(e) {
|
|
1501
1524
|
var _filteredOptions$;
|
|
1502
|
-
console.log(e);
|
|
1503
1525
|
var initialOptionIndex = ((_filteredOptions$ = filteredOptions[0]) == null ? void 0 : _filteredOptions$.value) === 'section_header' ? 1 : 0;
|
|
1504
1526
|
setOptionIndex(initialOptionIndex);
|
|
1505
1527
|
var value = e.target.value;
|
|
@@ -1588,10 +1610,12 @@ var StackedMultiSelect = /*#__PURE__*/React__default.forwardRef(function (_ref2,
|
|
|
1588
1610
|
},
|
|
1589
1611
|
options: filteredOptions,
|
|
1590
1612
|
position: position,
|
|
1591
|
-
optionIndex: optionIndex
|
|
1613
|
+
optionIndex: optionIndex,
|
|
1614
|
+
loading: loadingOptions
|
|
1592
1615
|
}, /*#__PURE__*/React__default.createElement(react.Input, {
|
|
1593
1616
|
value: searchValue,
|
|
1594
|
-
onChange: handleInput
|
|
1617
|
+
onChange: handleInput,
|
|
1618
|
+
disabled: loadingOptions
|
|
1595
1619
|
})));
|
|
1596
1620
|
});
|
|
1597
1621
|
|
|
@@ -1934,7 +1958,9 @@ function Input(_ref) {
|
|
|
1934
1958
|
setValue = _ref.setValue,
|
|
1935
1959
|
setError = _ref.setError,
|
|
1936
1960
|
clearErrors = _ref.clearErrors,
|
|
1937
|
-
separators = _ref.separators
|
|
1961
|
+
separators = _ref.separators,
|
|
1962
|
+
_ref$loadingOptions = _ref.loadingOptions,
|
|
1963
|
+
loadingOptions = _ref$loadingOptions === void 0 ? false : _ref$loadingOptions;
|
|
1938
1964
|
function selectedInputField(onChange, onBlur, ref, value) {
|
|
1939
1965
|
switch (inputType) {
|
|
1940
1966
|
case 'text':
|
|
@@ -1989,7 +2015,8 @@ function Input(_ref) {
|
|
|
1989
2015
|
value: value,
|
|
1990
2016
|
defaultValue: defaultValue,
|
|
1991
2017
|
placeholder: placeholder,
|
|
1992
|
-
fullOptions: fullOptions
|
|
2018
|
+
fullOptions: fullOptions,
|
|
2019
|
+
loadingOptions: loadingOptions
|
|
1993
2020
|
});
|
|
1994
2021
|
case 'textarea':
|
|
1995
2022
|
return /*#__PURE__*/React__default.createElement(StackedTextarea, {
|
|
@@ -2040,7 +2067,8 @@ function Input(_ref) {
|
|
|
2040
2067
|
control: control,
|
|
2041
2068
|
setError: setError,
|
|
2042
2069
|
clearErrors: clearErrors,
|
|
2043
|
-
placeholder: placeholder
|
|
2070
|
+
placeholder: placeholder,
|
|
2071
|
+
loadingOptions: loadingOptions
|
|
2044
2072
|
});
|
|
2045
2073
|
case 'pilled-text':
|
|
2046
2074
|
return /*#__PURE__*/React__default.createElement(StackedPilledInput, {
|