@trackunit/react-components 0.1.24 → 0.1.25
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/index.js +6 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2200,6 +2200,7 @@ tu-select__counter
|
|
|
2200
2200
|
* @returns {Partial<SelectComponents<Option, boolean, GroupBase<Option>>> | undefined} components object to override react-select default components
|
|
2201
2201
|
*/
|
|
2202
2202
|
const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEnabled, dataTestId, maxSelectedDisplayCount, dropdownIcon) => {
|
|
2203
|
+
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
2203
2204
|
const customComponents = React.useMemo(() => {
|
|
2204
2205
|
return Object.assign({ ValueContainer: props => {
|
|
2205
2206
|
if (props.isMulti) {
|
|
@@ -2237,18 +2238,19 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
2237
2238
|
}, LoadingIndicator: props => {
|
|
2238
2239
|
return jsx(Spinner, { size: "small", className: tws `mt-1.5 mr-1` });
|
|
2239
2240
|
}, DropdownIndicator: props => {
|
|
2240
|
-
|
|
2241
|
+
const icon = props.selectProps.menuIsOpen ? (jsx(Icon, { name: "ChevronUpIcon", size: "medium" })) : (jsx(Icon, { name: "ChevronDownIcon", size: "medium" }));
|
|
2242
|
+
return props.selectProps.isLoading ? null : (jsx(components.DropdownIndicator, Object.assign({}, props, { children: jsx(StyledIcon, { children: dropdownIcon ? dropdownIcon : icon }) })));
|
|
2241
2243
|
}, IndicatorSeparator: () => null, ClearIndicator: props => {
|
|
2242
2244
|
if (disabled) {
|
|
2243
2245
|
return null;
|
|
2244
2246
|
}
|
|
2245
2247
|
return (jsx(components.ClearIndicator, Object.assign({}, props, { children: jsx(XIcon, Object.assign({ onClick: props.clearValue, "data-testid": `${dataTestId}-XIcon` }, { children: jsx(Icon, { name: "XCircleIcon", size: "medium" }) })) })));
|
|
2246
2248
|
}, Control: props => {
|
|
2247
|
-
return (jsx(components.Control, Object.assign({}, props, {
|
|
2249
|
+
return (jsx(components.Control, Object.assign({}, props, { className: props.isDisabled ? tws `tu-select__control--disabled` : "" })));
|
|
2248
2250
|
}, SingleValue: props => {
|
|
2249
2251
|
return (jsx(components.SingleValue, Object.assign({}, props, { className: props.isDisabled ? tws `tu-select__single-value--disabled` : "" }, { children: jsx("div", Object.assign({ "data-testid": dataTestId + "-singleValue" }, { children: props.children })) })));
|
|
2250
2252
|
}, Menu: props => {
|
|
2251
|
-
return (jsx(components.Menu, Object.assign({}, props, { className: menuIsOpen
|
|
2253
|
+
return (jsx(components.Menu, Object.assign({}, props, { className: props.selectProps.menuIsOpen
|
|
2252
2254
|
? tws `tu-select__menu-list animate-fade-in-fast`
|
|
2253
2255
|
: tws `tu-select__menu-list animate-fade-out-fast` })));
|
|
2254
2256
|
}, Option: props => {
|
|
@@ -2261,7 +2263,7 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
2261
2263
|
return (jsx(components.Option, Object.assign({}, props, { innerProps: Object.assign(Object.assign({}, props.innerProps), { role: "option", onClick: () => { } }) }, { children: props.isMulti ? (jsx(MultiSelectMenuItem, Object.assign({}, componentProps, { disabled: disabled, dataTestId: props.label }))) : (jsx(SingleSelectMenuItem, Object.assign({}, componentProps, { disabled: disabled || props.isDisabled, dataTestId: props.label }))) })));
|
|
2262
2264
|
} }, componentsProps);
|
|
2263
2265
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2264
|
-
}, [componentsProps, disabled,
|
|
2266
|
+
}, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
2265
2267
|
return customComponents;
|
|
2266
2268
|
};
|
|
2267
2269
|
const StyledIcon = tw.div `
|