@infomaximum/ui-kit 0.19.0 → 0.20.0
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/BaseSelect/BaseSelect.d.ts +1 -1
- package/dist/components/BaseSelect/BaseSelect.js +21 -12
- package/dist/components/BaseSelect/BaseSelect.tokens.d.ts +1 -0
- package/dist/components/BaseSelect/BaseSelect.tokens.js +1 -0
- package/dist/components/BaseSelect/BaseSelect.types.d.ts +5 -2
- package/dist/components/BaseSelect/components/SelectOptionList/SelectOptionList.d.ts +1 -1
- package/dist/components/BaseSelect/components/SelectOptionList/SelectOptionList.js +6 -6
- package/dist/components/BaseSelect/components/SelectOptionList/SelectOptionList.types.d.ts +1 -0
- package/dist/components/BaseSelect/hooks/useDefaultCurrentValue.js +2 -1
- package/dist/components/BaseTooltip/BaseTooltip.js +38 -56
- package/dist/components/BaseTooltip/BaseTooltip.types.d.ts +1 -1
- package/dist/components/BaseTooltip/BaseTooltip.utils.d.ts +1 -3
- package/dist/components/BaseTooltip/BaseTooltip.utils.js +2 -32
- package/dist/components/BaseTooltip/hooks/useCustomFloating.d.ts +2 -1
- package/dist/components/BaseTooltip/hooks/useCustomFloating.js +9 -7
- package/dist/components/BaseTooltip/hooks/useShowTooltipController.d.ts +1 -2
- package/dist/components/BaseTooltip/hooks/useShowTooltipController.js +42 -57
- package/dist/components/Collapse/Collapse.js +1 -1
- package/dist/components/Dropdown/Dropdown.types.d.ts +1 -0
- package/dist/components/Dropdown/components/SubMenu/SubMenu.js +7 -3
- package/dist/components/InternalPicker/styles/DatePanel.styles.d.ts +596 -596
- package/dist/components/InternalPicker/styles/Popup.styles.d.ts +593 -593
- package/dist/components/NewDropdown/NewDropdown.d.ts +2 -0
- package/dist/components/NewDropdown/NewDropdown.js +180 -0
- package/dist/components/NewDropdown/NewDropdown.styles.d.ts +10 -0
- package/dist/components/NewDropdown/NewDropdown.styles.js +11 -0
- package/dist/components/NewDropdown/NewDropdown.tokens.d.ts +18 -0
- package/dist/components/NewDropdown/NewDropdown.tokens.js +14 -0
- package/dist/components/NewDropdown/NewDropdown.types.d.ts +132 -0
- package/dist/components/NewDropdown/NewDropdown.utils.d.ts +26 -0
- package/dist/components/NewDropdown/NewDropdown.utils.js +55 -0
- package/dist/components/NewDropdown/components/Divider/Divider.d.ts +2 -0
- package/dist/components/NewDropdown/components/Divider/Divider.js +21 -0
- package/dist/components/NewDropdown/components/Divider/Divider.styles.d.ts +10 -0
- package/dist/components/NewDropdown/components/Divider/Divider.styles.js +12 -0
- package/dist/components/NewDropdown/components/Divider/index.d.ts +1 -0
- package/dist/components/NewDropdown/components/GroupItem/GroupItem.d.ts +3 -0
- package/dist/components/NewDropdown/components/GroupItem/GroupItem.js +33 -0
- package/dist/components/NewDropdown/components/GroupItem/GroupItem.styles.d.ts +29 -0
- package/dist/components/NewDropdown/components/GroupItem/GroupItem.styles.js +31 -0
- package/dist/components/NewDropdown/components/GroupItem/GroupItem.types.d.ts +5 -0
- package/dist/components/NewDropdown/components/GroupItem/index.d.ts +1 -0
- package/dist/components/NewDropdown/components/Menu/Menu.d.ts +3 -0
- package/dist/components/NewDropdown/components/Menu/Menu.js +33 -0
- package/dist/components/NewDropdown/components/Menu/Menu.styles.d.ts +2 -0
- package/dist/components/NewDropdown/components/Menu/Menu.styles.js +8 -0
- package/dist/components/NewDropdown/components/Menu/Menu.types.d.ts +11 -0
- package/dist/components/NewDropdown/components/Menu/index.d.ts +1 -0
- package/dist/components/NewDropdown/components/MenuItem/MenuItem.d.ts +3 -0
- package/dist/components/NewDropdown/components/MenuItem/MenuItem.js +75 -0
- package/dist/components/NewDropdown/components/MenuItem/MenuItem.styles.d.ts +42 -0
- package/dist/components/NewDropdown/components/MenuItem/MenuItem.styles.js +67 -0
- package/dist/components/NewDropdown/components/MenuItem/MenuItem.types.d.ts +5 -0
- package/dist/components/NewDropdown/components/MenuItem/index.d.ts +1 -0
- package/dist/components/NewDropdown/components/SubMenuItem/SubMenuItem.d.ts +3 -0
- package/dist/components/NewDropdown/components/SubMenuItem/SubMenuItem.js +170 -0
- package/dist/components/NewDropdown/components/SubMenuItem/SubMenuItem.styles.d.ts +13 -0
- package/dist/components/NewDropdown/components/SubMenuItem/SubMenuItem.styles.js +15 -0
- package/dist/components/NewDropdown/components/SubMenuItem/SubMenuItem.types.d.ts +5 -0
- package/dist/components/NewDropdown/components/SubMenuItem/index.d.ts +1 -0
- package/dist/components/NewDropdown/contexts/NewDropdownContext.d.ts +9 -0
- package/dist/components/NewDropdown/contexts/NewDropdownContext.js +8 -0
- package/dist/components/NewDropdown/contexts/NewDropdownNavigationContext.d.ts +11 -0
- package/dist/components/NewDropdown/contexts/NewDropdownNavigationContext.js +8 -0
- package/dist/components/NewDropdown/hooks/useContextMenu/index.d.ts +2 -0
- package/dist/components/NewDropdown/hooks/useContextMenu/useContextMenu.d.ts +9 -0
- package/dist/components/NewDropdown/hooks/useContextMenu/useContextMenu.js +38 -0
- package/dist/components/NewDropdown/hooks/useContextMenu/useContextMenu.types.d.ts +7 -0
- package/dist/components/NewDropdown/hooks/useNewDropdownTokens/index.d.ts +1 -0
- package/dist/components/NewDropdown/hooks/useNewDropdownTokens/useNewDropdownTokens.d.ts +7 -0
- package/dist/components/NewDropdown/hooks/useNewDropdownTokens/useNewDropdownTokens.js +14 -0
- package/dist/components/NewDropdown/hooks/useNewDropdownTokens/useNewDropdownTokens.types.d.ts +6 -0
- package/dist/components/NewDropdown/index.d.ts +2 -0
- package/dist/components/Segmented/Segmented.js +1 -1
- package/dist/components/Select/Select.d.ts +9 -1
- package/dist/components/Select/Select.js +53 -28
- package/dist/components/Select/Select.types.d.ts +5 -1
- package/dist/components/Select/Select.utils.d.ts +10 -1
- package/dist/components/Select/Select.utils.js +110 -7
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.d.ts +5 -0
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.js +68 -0
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.styles.d.ts +28 -0
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.styles.js +34 -0
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.types.d.ts +21 -0
- package/dist/components/Select/components/SelectGroupOption/SelectGroupOption.types.js +7 -0
- package/dist/components/Select/components/SelectOption/SelectOption.d.ts +3 -2
- package/dist/components/Select/components/SelectOption/SelectOption.js +25 -15
- package/dist/components/Select/components/SelectOption/SelectOption.styles.d.ts +16 -2
- package/dist/components/Select/components/SelectOption/SelectOption.styles.js +18 -2
- package/dist/components/Select/components/SelectOption/SelectOption.types.d.ts +5 -0
- package/dist/components/Select/contexts/DepthContext.d.ts +3 -0
- package/dist/components/Select/contexts/DepthContext.js +9 -0
- package/dist/components/Select/contexts/SelectRenderContext.d.ts +11 -0
- package/dist/components/Select/contexts/SelectRenderContext.js +7 -0
- package/dist/components/Select/forStories/dataForExamples.d.ts +65 -3
- package/dist/components/Select/hooks/useElementSizesController.d.ts +5 -0
- package/dist/components/Select/hooks/useElementSizesController.js +17 -0
- package/dist/components/Select/hooks/useKeyControl.d.ts +4 -4
- package/dist/components/Select/hooks/useKeyControl.js +15 -10
- package/dist/components/Slider/components/SliderHandleTooltip/SliderHandleTooltip.js +1 -1
- package/dist/components/Slider/components/SliderInternal/SliderInternal.js +1 -1
- package/dist/components/Table/features/tableRowSelection/hooks/useTableRowSelection/useTableRowSelection.js +1 -1
- package/dist/components/Table/hooks/useTableVisualParamsChange/utils.d.ts +1 -1
- package/dist/components/Tabs/Tabs.utils.d.ts +2 -2
- package/dist/components/Tabs/Tabs.utils.js +11 -24
- package/dist/components/Tabs/components/TabBar/TabBar.js +8 -7
- package/dist/components/Tabs/components/TabItem/TabItem.js +7 -5
- package/dist/components/Tabs/components/TabItem/TabItem.styles.d.ts +1 -1
- package/dist/components/Tabs/components/TabItem/TabItem.types.d.ts +1 -0
- package/dist/components/Tabs/hooks/useMoreTabsController.d.ts +2 -1
- package/dist/components/Tabs/hooks/useMoreTabsController.js +10 -6
- package/dist/components/TreeSelect/TreeSelect.js +8 -3
- package/dist/components/TreeSelect/components/TreeSelectOption/TreeSelectOption.types.d.ts +1 -0
- package/dist/components/TreeSelect/hooks/useKeyControl.d.ts +2 -2
- package/dist/components/TreeSelect/hooks/useKeyControl.js +9 -8
- package/dist/hooks/useInputModeDetector/index.d.ts +2 -0
- package/dist/hooks/useInputModeDetector/useInputModeDetector.d.ts +13 -0
- package/dist/hooks/useInputModeDetector/useInputModeDetector.js +50 -0
- package/dist/hooks/useInputModeDetector/useInputModeDetector.types.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElementProps, FloatingRootContext } from '@floating-ui/react';
|
|
2
|
+
import { UseContextMenuProps } from './useContextMenu.types';
|
|
3
|
+
/**
|
|
4
|
+
* Открывает плавающий элемент по событию contextmenu (правый клик)
|
|
5
|
+
* на reference-элементе, размещая его в точке курсора и подавляя
|
|
6
|
+
* нативное контекстное меню. Подмешивается в `useInteractions`
|
|
7
|
+
* наравне со штатными хуками floating-ui (useClick, useHover, useDismiss).
|
|
8
|
+
*/
|
|
9
|
+
export declare const useContextMenu: (context: FloatingRootContext, props?: UseContextMenuProps) => ElementProps;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
const useContextMenu = (context, props = {}) => {
|
|
3
|
+
const {
|
|
4
|
+
onOpenChange,
|
|
5
|
+
refs,
|
|
6
|
+
elements: {
|
|
7
|
+
domReference
|
|
8
|
+
}
|
|
9
|
+
} = context;
|
|
10
|
+
const {
|
|
11
|
+
enabled = true
|
|
12
|
+
} = props;
|
|
13
|
+
const reference = useMemo(() => ({
|
|
14
|
+
onContextMenu(event) {
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
refs.setPositionReference({
|
|
17
|
+
contextElement: domReference ?? void 0,
|
|
18
|
+
getBoundingClientRect: () => ({
|
|
19
|
+
width: 0,
|
|
20
|
+
height: 0,
|
|
21
|
+
x: event.clientX,
|
|
22
|
+
y: event.clientY,
|
|
23
|
+
top: event.clientY,
|
|
24
|
+
right: event.clientX,
|
|
25
|
+
bottom: event.clientY,
|
|
26
|
+
left: event.clientX
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
onOpenChange(true, event.nativeEvent, "click");
|
|
30
|
+
}
|
|
31
|
+
}), [onOpenChange, refs, domReference]);
|
|
32
|
+
return useMemo(() => enabled ? {
|
|
33
|
+
reference
|
|
34
|
+
} : {}, [enabled, reference]);
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
useContextMenu
|
|
38
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useNewDropdownTokens } from './useNewDropdownTokens';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseNewDropdownTokensResult } from './useNewDropdownTokens.types';
|
|
2
|
+
/**
|
|
3
|
+
* Возвращает theme + component-tokens NewDropdown одним вызовом.
|
|
4
|
+
* Используется во всех подкомпонентах меню, чтобы не повторять связку
|
|
5
|
+
* useTheme + useComponentTokens + getNewDropdownTokens(theme).
|
|
6
|
+
*/
|
|
7
|
+
export declare const useNewDropdownTokens: () => UseNewDropdownTokensResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { getNewDropdownTokens } from "../../NewDropdown.tokens.js";
|
|
2
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
3
|
+
import { useComponentTokens } from "../../../ConfigProvider/hooks/useComponentTokens/useComponentTokens.js";
|
|
4
|
+
const useNewDropdownTokens = () => {
|
|
5
|
+
const theme = useTheme();
|
|
6
|
+
const tokens = useComponentTokens("NewDropdown", getNewDropdownTokens(theme));
|
|
7
|
+
return {
|
|
8
|
+
theme,
|
|
9
|
+
tokens
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
useNewDropdownTokens
|
|
14
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { memo, useId, useMemo, useCallback } from "react";
|
|
3
|
+
import { useControlledState } from "../../hooks/useControlledState/useControlledState.js";
|
|
3
4
|
import { SegmentedItem } from "./components/SegmentedItem/SegmentedItem.js";
|
|
4
5
|
import { getSegmentedTokens } from "./Segmented.tokens.js";
|
|
5
6
|
import { normalizeOption } from "./Segmented.utils.js";
|
|
6
7
|
import { getSegmentedStyle, segmentedGroupStyle } from "./Segmented.styles.js";
|
|
7
8
|
import { useTheme } from "../../hooks/useTheme/useTheme.js";
|
|
8
|
-
import { useControlledState } from "../../hooks/useControlledState/useControlledState.js";
|
|
9
9
|
const SegmentedComponent = (props) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const defaultName = useId();
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { SelectProps } from './Select.types';
|
|
2
|
+
import { SelectOptionInterface } from './components/SelectOption/SelectOption.types';
|
|
2
3
|
export declare const Select: import('react').ForwardRefExoticComponent<SelectProps & {
|
|
3
4
|
children?: import('react').ReactNode | undefined;
|
|
4
|
-
} & import('react').RefAttributes<HTMLElement
|
|
5
|
+
} & import('react').RefAttributes<HTMLElement>> & {
|
|
6
|
+
Option: import('react').NamedExoticComponent<import('./components/SelectOption/SelectOption.types').SelectOptionProps> & {
|
|
7
|
+
_selectType: "option";
|
|
8
|
+
};
|
|
9
|
+
OptGroup: (<Option extends SelectOptionInterface>(props: import('./components/SelectGroupOption/SelectGroupOption.types').SelectGroupOptionProps<Option>) => import("@emotion/react/jsx-runtime").JSX.Element | null) & {
|
|
10
|
+
_selectType: "group";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -1,26 +1,42 @@
|
|
|
1
1
|
import { jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo, useCallback } from "react";
|
|
2
|
+
import { memo, useMemo, useRef, useCallback } from "react";
|
|
3
3
|
import { withThemeProvider } from "../../hocs/withThemeProvider.js";
|
|
4
4
|
import { BaseSelect } from "../BaseSelect/BaseSelect.js";
|
|
5
5
|
import { SelectOption } from "./components/SelectOption/SelectOption.js";
|
|
6
|
+
import { SelectGroupOption } from "./components/SelectGroupOption/SelectGroupOption.js";
|
|
7
|
+
import { isGroupOption } from "./components/SelectGroupOption/SelectGroupOption.types.js";
|
|
6
8
|
import { isFunction } from "lodash-es";
|
|
7
|
-
import { isKeyOfObject } from "../BaseSelect/BaseSelect.utils.js";
|
|
8
9
|
import { useKeyControl } from "./hooks/useKeyControl.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
import { useElementSizesController } from "./hooks/useElementSizesController.js";
|
|
11
|
+
import { childrenToOptions, getOptionsForMap, filterSelectOptions } from "./Select.utils.js";
|
|
12
|
+
import { SelectRenderContext } from "./contexts/SelectRenderContext.js";
|
|
13
|
+
const EMPTY_OPTIONS = [];
|
|
14
|
+
const SelectComponent = (props) => {
|
|
15
|
+
const {
|
|
16
|
+
options = EMPTY_OPTIONS,
|
|
17
|
+
children,
|
|
18
|
+
filterOption = true,
|
|
19
|
+
optionFilterProp = "label",
|
|
20
|
+
styles,
|
|
21
|
+
optionRender,
|
|
22
|
+
onDropdownVisibleChange,
|
|
23
|
+
onChange,
|
|
24
|
+
onSearch,
|
|
25
|
+
...otherProps
|
|
26
|
+
} = props;
|
|
27
|
+
const derivedOptions = useMemo(() => options.length > 0 ? options : childrenToOptions(children), [options, children]);
|
|
20
28
|
const optionsMap = useMemo(() => {
|
|
21
|
-
const optionList =
|
|
29
|
+
const optionList = getOptionsForMap(derivedOptions);
|
|
22
30
|
return new Map(optionList);
|
|
23
|
-
}, [
|
|
31
|
+
}, [derivedOptions]);
|
|
32
|
+
const filteredOptionsRef = useRef(derivedOptions);
|
|
33
|
+
const {
|
|
34
|
+
getElementSize,
|
|
35
|
+
changeElementSize
|
|
36
|
+
} = useElementSizesController();
|
|
37
|
+
const handleFilteredOptionsChange = useCallback((filtered) => {
|
|
38
|
+
filteredOptionsRef.current = filtered;
|
|
39
|
+
}, []);
|
|
24
40
|
const {
|
|
25
41
|
currentSelectingIndex,
|
|
26
42
|
onKeyControl,
|
|
@@ -28,11 +44,14 @@ const SelectComponent = memo(({
|
|
|
28
44
|
handleChange,
|
|
29
45
|
handleSearch,
|
|
30
46
|
getCurrentSelectingValue
|
|
31
|
-
} = useKeyControl(
|
|
47
|
+
} = useKeyControl(filteredOptionsRef, optionsMap, onDropdownVisibleChange, onChange, onSearch);
|
|
32
48
|
const getOptionByValue = useCallback((value) => {
|
|
33
49
|
return optionsMap.get(value);
|
|
34
50
|
}, [optionsMap]);
|
|
35
51
|
const renderDropdownItem = useCallback((option, index) => {
|
|
52
|
+
if (isGroupOption(option)) {
|
|
53
|
+
return /* @__PURE__ */ jsx(SelectGroupOption, { ...option, index, onResize: changeElementSize }, option.groupKey);
|
|
54
|
+
}
|
|
36
55
|
if (isFunction(optionRender)) {
|
|
37
56
|
return optionRender({
|
|
38
57
|
option,
|
|
@@ -40,24 +59,30 @@ const SelectComponent = memo(({
|
|
|
40
59
|
});
|
|
41
60
|
}
|
|
42
61
|
return /* @__PURE__ */ jsx(SelectOption, { ...option, styles: styles == null ? void 0 : styles.optionStyles });
|
|
43
|
-
}, [optionRender, styles == null ? void 0 : styles.optionStyles]);
|
|
62
|
+
}, [changeElementSize, optionRender, styles == null ? void 0 : styles.optionStyles]);
|
|
44
63
|
const filterOptions = useCallback((options2, filterValue) => {
|
|
45
64
|
if (!filterOption) {
|
|
46
65
|
return [...options2];
|
|
47
66
|
}
|
|
48
|
-
return options2
|
|
49
|
-
var _a;
|
|
50
|
-
if (isFunction(filterOption)) {
|
|
51
|
-
return filterOption(filterValue, option);
|
|
52
|
-
}
|
|
53
|
-
const optionFilterValue = isKeyOfObject(option, optionFilterProp) ? ((_a = option[optionFilterProp]) == null ? void 0 : _a.toString()) ?? "" : "";
|
|
54
|
-
return optionFilterValue.toLowerCase().includes(filterValue.toLowerCase().trim());
|
|
55
|
-
});
|
|
67
|
+
return filterSelectOptions(options2, filterValue, optionFilterProp, isFunction(filterOption) ? filterOption : true);
|
|
56
68
|
}, [filterOption, optionFilterProp]);
|
|
57
|
-
const virtualizerEstimateSize = useCallback(() =>
|
|
58
|
-
|
|
69
|
+
const virtualizerEstimateSize = useCallback((index) => getElementSize(index), [getElementSize]);
|
|
70
|
+
const getItemKey = useCallback((option) => {
|
|
71
|
+
if (isGroupOption(option)) {
|
|
72
|
+
return option.groupKey;
|
|
73
|
+
}
|
|
74
|
+
return option.value.toString();
|
|
75
|
+
}, []);
|
|
76
|
+
const renderContextValue = useMemo(() => ({
|
|
77
|
+
optionRender,
|
|
78
|
+
optionStyles: styles == null ? void 0 : styles.optionStyles
|
|
79
|
+
}), [optionRender, styles == null ? void 0 : styles.optionStyles]);
|
|
80
|
+
return /* @__PURE__ */ jsx(SelectRenderContext.Provider, { value: renderContextValue, children: /* @__PURE__ */ jsx(BaseSelect, { ...otherProps, options: derivedOptions, getOptionByValue, renderDropdownItem, filterOptions, filterOption, virtualizerEstimateSize, onDropdownVisibleChange: handleDropdownVisibleChange, onChange: handleChange, onSearch: handleSearch, onKeyControl, currentSelectingIndex, getCurrentSelectingValue, onFilteredOptionsChange: handleFilteredOptionsChange, getItemKey, styles: styles == null ? void 0 : styles.baseSelectStyles }) });
|
|
81
|
+
};
|
|
82
|
+
const Select = Object.assign(withThemeProvider(memo(SelectComponent)), {
|
|
83
|
+
Option: SelectOption,
|
|
84
|
+
OptGroup: SelectGroupOption
|
|
59
85
|
});
|
|
60
|
-
const Select = withThemeProvider(SelectComponent);
|
|
61
86
|
export {
|
|
62
87
|
Select
|
|
63
88
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { SelectOptionInterface, SelectOptionStyles } from './components/SelectOption/SelectOption.types';
|
|
2
2
|
import { BaseSelectProps, BaseSelectStyles } from '../BaseSelect/BaseSelect.types';
|
|
3
|
+
import { GroupOption } from './components/SelectGroupOption/SelectGroupOption.types';
|
|
4
|
+
import { PropsWithChildren } from 'react';
|
|
3
5
|
export interface SelectStyles {
|
|
4
6
|
baseSelectStyles?: BaseSelectStyles;
|
|
5
7
|
optionStyles?: SelectOptionStyles;
|
|
6
8
|
}
|
|
7
9
|
export type SelectOptionValue = string | number;
|
|
8
|
-
export
|
|
10
|
+
export type SelectOption = GroupOption<SelectOptionInterface> | SelectOptionInterface;
|
|
11
|
+
export interface SelectProps extends PropsWithChildren<Omit<BaseSelectProps<SelectOption, SelectOptionValue>, "renderDropdownItem" | "filterOptions" | "getOptionByValue" | "virtualizerEstimateSize" | "onKeyControl" | "currentSelectingIndex" | "getCurrentSelectingValue" | "styles">> {
|
|
12
|
+
options?: SelectOption[];
|
|
9
13
|
styles?: SelectStyles;
|
|
10
14
|
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { GroupOption } from './components/SelectGroupOption/SelectGroupOption.types';
|
|
1
3
|
import { SelectOptionInterface } from './components/SelectOption/SelectOption.types';
|
|
2
|
-
|
|
4
|
+
import { SelectOption, SelectOptionValue } from './Select.types';
|
|
5
|
+
export declare const SELECT_OPTION_TYPE: "option";
|
|
6
|
+
export declare const SELECT_GROUP_OPTION_TYPE: "group";
|
|
7
|
+
export declare const childrenToOptions: (children: ReactNode) => SelectOption[];
|
|
8
|
+
export declare const getNextOption: (currentIndex: number, flattenedKeys: (SelectOptionValue | string)[], optionsMap: Map<SelectOptionValue, SelectOptionInterface>, isDecrement?: boolean) => number | null;
|
|
9
|
+
export declare const getOptionsForMap: <Option extends SelectOptionInterface>(options: (GroupOption<Option> | Option)[]) => [Option["value"], Option][];
|
|
10
|
+
export declare const filterSelectOptions: (options: SelectOption[], filterValue: string, optionFilterProp: string, filterOption: ((inputValue: string, option: SelectOptionInterface) => boolean) | true) => SelectOption[];
|
|
11
|
+
export declare const flattenSelectOptionValues: (options: SelectOption[]) => (SelectOptionValue | string)[];
|
|
@@ -1,14 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
import { Children, isValidElement } from "react";
|
|
2
|
+
import { isGroupOption } from "./components/SelectGroupOption/SelectGroupOption.types.js";
|
|
3
|
+
import { isKeyOfObject } from "../BaseSelect/BaseSelect.utils.js";
|
|
4
|
+
const SELECT_OPTION_TYPE = "option";
|
|
5
|
+
const SELECT_GROUP_OPTION_TYPE = "group";
|
|
6
|
+
const getSelectElementType = (type) => {
|
|
7
|
+
if (type === null || typeof type !== "function" && typeof type !== "object") {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
return type._selectType;
|
|
11
|
+
};
|
|
12
|
+
const childrenToOptions = (children) => Children.toArray(children).reduce((acc, child) => {
|
|
13
|
+
if (!isValidElement(child)) {
|
|
14
|
+
return acc;
|
|
15
|
+
}
|
|
16
|
+
const elementType = getSelectElementType(child.type);
|
|
17
|
+
if (elementType === SELECT_OPTION_TYPE) {
|
|
18
|
+
return [...acc, child.props];
|
|
19
|
+
}
|
|
20
|
+
if (elementType === SELECT_GROUP_OPTION_TYPE) {
|
|
21
|
+
const {
|
|
22
|
+
children: groupChildren,
|
|
23
|
+
index: _index,
|
|
24
|
+
onResize: _onResize,
|
|
25
|
+
styles: _styles,
|
|
26
|
+
...rest
|
|
27
|
+
} = child.props;
|
|
28
|
+
const nestedOptions = groupChildren ? childrenToOptions(groupChildren) : rest.options ?? [];
|
|
29
|
+
return [...acc, {
|
|
30
|
+
...rest,
|
|
31
|
+
options: nestedOptions
|
|
32
|
+
}];
|
|
33
|
+
}
|
|
34
|
+
return acc;
|
|
35
|
+
}, []);
|
|
36
|
+
const getNextOption = (currentIndex, flattenedKeys, optionsMap, isDecrement = false) => {
|
|
2
37
|
const nextIndex = isDecrement ? currentIndex - 1 : currentIndex + 1;
|
|
3
|
-
if (nextIndex < 0 || nextIndex >=
|
|
38
|
+
if (nextIndex < 0 || nextIndex >= flattenedKeys.length) {
|
|
4
39
|
return null;
|
|
5
40
|
}
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
41
|
+
const nextKey = flattenedKeys[nextIndex];
|
|
42
|
+
const nextOption = optionsMap.get(nextKey);
|
|
43
|
+
if (!nextOption || nextOption.disabled) {
|
|
44
|
+
return getNextOption(nextIndex, flattenedKeys, optionsMap, isDecrement);
|
|
9
45
|
}
|
|
10
|
-
return
|
|
46
|
+
return nextIndex;
|
|
47
|
+
};
|
|
48
|
+
const getOptionsForMap = (options) => {
|
|
49
|
+
const result = [];
|
|
50
|
+
const visit = (opts) => {
|
|
51
|
+
for (const option of opts) {
|
|
52
|
+
if (isGroupOption(option)) {
|
|
53
|
+
visit(option.options ?? []);
|
|
54
|
+
} else {
|
|
55
|
+
result.push([option.value, option]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
visit(options);
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
const checkSelectOption = (option, filterValue, optionFilterProp, filterOption) => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
const normalizedFilterValue = filterValue.toLowerCase().trim();
|
|
65
|
+
if (isGroupOption(option)) {
|
|
66
|
+
const groupFilterValue = isKeyOfObject(option, optionFilterProp) ? ((_a = option[optionFilterProp]) == null ? void 0 : _a.toString().toLowerCase()) ?? "" : "";
|
|
67
|
+
if (groupFilterValue.includes(normalizedFilterValue)) {
|
|
68
|
+
return option;
|
|
69
|
+
}
|
|
70
|
+
const filteredOptions = filterSelectOptions(option.options ?? [], filterValue, optionFilterProp, filterOption);
|
|
71
|
+
if (filteredOptions.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...option,
|
|
76
|
+
options: filteredOptions
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (filterOption !== true) {
|
|
80
|
+
return filterOption(filterValue, option) ? option : null;
|
|
81
|
+
}
|
|
82
|
+
const optionFilterValue = isKeyOfObject(option, optionFilterProp) ? ((_b = option[optionFilterProp]) == null ? void 0 : _b.toString()) ?? "" : "";
|
|
83
|
+
return optionFilterValue.toLowerCase().includes(normalizedFilterValue) ? option : null;
|
|
84
|
+
};
|
|
85
|
+
const filterSelectOptions = (options, filterValue, optionFilterProp, filterOption) => {
|
|
86
|
+
return options.reduce((acc, option) => {
|
|
87
|
+
const result = checkSelectOption(option, filterValue, optionFilterProp, filterOption);
|
|
88
|
+
if (result === null) {
|
|
89
|
+
return acc;
|
|
90
|
+
}
|
|
91
|
+
return [...acc, result];
|
|
92
|
+
}, []);
|
|
93
|
+
};
|
|
94
|
+
const flattenSelectOptionValues = (options) => {
|
|
95
|
+
const result = [];
|
|
96
|
+
const visit = (opts) => {
|
|
97
|
+
for (const option of opts) {
|
|
98
|
+
if (isGroupOption(option)) {
|
|
99
|
+
result.push(option.groupKey);
|
|
100
|
+
visit(option.options ?? []);
|
|
101
|
+
} else {
|
|
102
|
+
result.push(option.value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
visit(options);
|
|
107
|
+
return result;
|
|
11
108
|
};
|
|
12
109
|
export {
|
|
13
|
-
|
|
110
|
+
SELECT_GROUP_OPTION_TYPE,
|
|
111
|
+
SELECT_OPTION_TYPE,
|
|
112
|
+
childrenToOptions,
|
|
113
|
+
filterSelectOptions,
|
|
114
|
+
flattenSelectOptionValues,
|
|
115
|
+
getNextOption,
|
|
116
|
+
getOptionsForMap
|
|
14
117
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { SelectOptionInterface } from '../SelectOption/SelectOption.types';
|
|
2
|
+
import { SelectGroupOptionProps } from './SelectGroupOption.types';
|
|
3
|
+
export declare const SelectGroupOption: (<Option extends SelectOptionInterface>(props: SelectGroupOptionProps<Option>) => import("@emotion/react/jsx-runtime").JSX.Element | null) & {
|
|
4
|
+
_selectType: "group";
|
|
5
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx, jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement } from "@emotion/react";
|
|
3
|
+
import { memo, useRef, useMemo } from "react";
|
|
4
|
+
import { isGroupOption } from "./SelectGroupOption.types.js";
|
|
5
|
+
import { SelectOption } from "../SelectOption/SelectOption.js";
|
|
6
|
+
import { selectGroupOptionStyle } from "./SelectGroupOption.styles.js";
|
|
7
|
+
import { useResizeObserver } from "../../../../hooks/useResizeObserver.js";
|
|
8
|
+
import { isFunction, isNil, isUndefined } from "lodash-es";
|
|
9
|
+
import { SELECT_GROUP_OPTION_TYPE } from "../../Select.utils.js";
|
|
10
|
+
import { useDepth, DepthContext } from "../../contexts/DepthContext.js";
|
|
11
|
+
import { useSelectRenderContext } from "../../contexts/SelectRenderContext.js";
|
|
12
|
+
import { useTheme } from "../../../../hooks/useTheme/useTheme.js";
|
|
13
|
+
const SelectGroupOptionComponent = (props) => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const {
|
|
16
|
+
label,
|
|
17
|
+
options,
|
|
18
|
+
children,
|
|
19
|
+
title,
|
|
20
|
+
className,
|
|
21
|
+
index,
|
|
22
|
+
onResize,
|
|
23
|
+
styles
|
|
24
|
+
} = props;
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const depth = useDepth();
|
|
27
|
+
const wrapperRef = useRef(null);
|
|
28
|
+
const {
|
|
29
|
+
optionRender,
|
|
30
|
+
optionStyles
|
|
31
|
+
} = useSelectRenderContext();
|
|
32
|
+
useResizeObserver(wrapperRef, (entries) => {
|
|
33
|
+
if (index === void 0 || !onResize) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
onResize(index, entries[0].contentRect.height);
|
|
37
|
+
});
|
|
38
|
+
const selectOptions = useMemo(() => {
|
|
39
|
+
return options == null ? void 0 : options.reduce((acc, option, localIndex) => {
|
|
40
|
+
if (isGroupOption(option)) {
|
|
41
|
+
const element2 = /* @__PURE__ */ jsx(SelectGroupOptionComponent, { ...option }, option.groupKey);
|
|
42
|
+
return [...acc, element2];
|
|
43
|
+
}
|
|
44
|
+
if (isFunction(optionRender)) {
|
|
45
|
+
const element2 = optionRender({
|
|
46
|
+
option,
|
|
47
|
+
index: localIndex
|
|
48
|
+
});
|
|
49
|
+
return [...acc, element2];
|
|
50
|
+
}
|
|
51
|
+
const element = /* @__PURE__ */ createElement(SelectOption, { ...option, key: option.value, styles: optionStyles });
|
|
52
|
+
return [...acc, element];
|
|
53
|
+
}, []);
|
|
54
|
+
}, [optionRender, optionStyles, options]);
|
|
55
|
+
if (isNil(children) && (isUndefined(selectOptions) || selectOptions.length === 0)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, css: [selectGroupOptionStyle.wrapper, (_a = styles == null ? void 0 : styles.wrapper) == null ? void 0 : _a.call(styles, theme), process.env.NODE_ENV === "production" ? "" : ";label:SelectGroupOptionComponent;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2VsZWN0L2NvbXBvbmVudHMvU2VsZWN0R3JvdXBPcHRpb24vU2VsZWN0R3JvdXBPcHRpb24udHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXdETSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l0L3NyYy9jb21wb25lbnRzL1NlbGVjdC9jb21wb25lbnRzL1NlbGVjdEdyb3VwT3B0aW9uL1NlbGVjdEdyb3VwT3B0aW9uLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IG1lbW8sIHVzZU1lbW8sIHVzZVJlZiwgdHlwZSBSZWFjdE5vZGUgfSBmcm9t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HRoICsgMX0+XG4gICAgICAgIDxkaXYgY3NzPXtbc2VsZWN0R3JvdXBPcHRpb25TdHlsZS5vcHRpb25zLCBzdHlsZXM/Lm9wdGlvbnM/Lih0aGVtZSldfT5cbiAgICAgICAgICB7c2VsZWN0T3B0aW9ucyA/PyBjaGlsZHJlbn1cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L0RlcHRoQ29udGV4dC5Qcm92aWRlcj5cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG5cbmV4cG9ydCBjb25zdCBTZWxlY3RHcm91cE9wdGlvbiA9IE9iamVjdC5hc3NpZ24oXG4gIG1lbW8oU2VsZWN0R3JvdXBPcHRpb25Db21wb25lbnQpIGFzIHR5cGVvZiBTZWxlY3RHcm91cE9wdGlvbkNvbXBvbmVudCxcbiAgeyBfc2VsZWN0VHlwZTogU0VMRUNUX0dST1VQX09QVElPTl9UWVBFIH1cbik7XG4iXX0= */"], className, children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", { title, css: [selectGroupOptionStyle.getLabel(depth)(theme), (_b = styles == null ? void 0 : styles.label) == null ? void 0 : _b.call(styles, theme), process.env.NODE_ENV === "production" ? "" : ";label:SelectGroupOptionComponent;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2VsZWN0L2NvbXBvbmVudHMvU2VsZWN0R3JvdXBPcHRpb24vU2VsZWN0R3JvdXBPcHRpb24udHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZEUSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l0L3NyYy9jb21wb25lbnRzL1NlbGVjdC9jb21wb25lbnRzL1NlbGVjdEdyb3VwT3B0aW9uL1NlbGVjdEdyb3VwT3B0aW9uLnRzeCIsInNvdXJjZX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AgICB7bGFiZWx9XG4gICAgICA8L2Rpdj5cbiAgICAgIDxEZXB0aENvbnRleHQuUHJvdmlkZXIgdmFsdWU9e2RlcHRoICsgMX0+XG4gICAgICAgIDxkaXYgY3NzPXtbc2VsZWN0R3JvdXBPcHRpb25TdHlsZS5vcHRpb25zLCBzdHlsZXM/Lm9wdGlvbnM/Lih0aGVtZSldfT5cbiAgICAgICAgICB7c2VsZWN0T3B0aW9ucyA/PyBjaGlsZHJlbn1cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L0RlcHRoQ29udGV4dC5Qcm92aWRlcj5cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG5cbmV4cG9ydCBjb25zdCBTZWxlY3RHcm91cE9wdGlvbiA9IE9iamVjdC5hc3NpZ24oXG4gIG1lbW8oU2VsZWN0R3JvdXBPcHRpb25Db21wb25lbnQpIGFzIHR5cGVvZiBTZWxlY3RHcm91cE9wdGlvbkNvbXBvbmVudCxcbiAgeyBfc2VsZWN0VHlwZTogU0VMRUNUX0dST1VQX09QVElPTl9UWVBFIH1cbik7XG4iXX0= */"], children: label }),
|
|
60
|
+
/* @__PURE__ */ jsx(DepthContext.Provider, { value: depth + 1, children: /* @__PURE__ */ jsx("div", { css: [selectGroupOptionStyle.options, (_c = styles == null ? void 0 : styles.options) == null ? void 0 : _c.call(styles, theme), process.env.NODE_ENV === "production" ? "" : ";label:SelectGroupOptionComponent;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9idWlsZHMvZnJvbnRlbmQvbGlicy91aS1raXQvc3JjL2NvbXBvbmVudHMvU2VsZWN0L2NvbXBvbmVudHMvU2VsZWN0R3JvdXBPcHRpb24vU2VsZWN0R3JvdXBPcHRpb24udHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWtFYSIsImZpbGUiOiIvYnVpbGRzL2Zyb250ZW5kL2xpYnMvdWkta2l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tzZWxlY3RHcm91cE9wdGlvblN0eWxlLmdldExhYmVsKGRlcHRoKSh0aGVtZSksIHN0eWxlcz8ubGFiZWw/Lih0aGVtZSldfVxuICAgICAgPlxuICAgICAgICB7bGFiZWx9XG4gICAgICA8L2Rpdj5cbiAgICAgIDxEZXB0aENvbnRleHQuUHJvdmlkZXIgdmFsdWU9e2RlcHRoICsgMX0+XG4gICAgICAgIDxkaXYgY3NzPXtbc2VsZWN0R3JvdXBPcHRpb25TdHlsZS5vcHRpb25zLCBzdHlsZXM/Lm9wdGlvbnM/Lih0aGVtZSldfT5cbiAgICAgICAgICB7c2VsZWN0T3B0aW9ucyA/PyBjaGlsZHJlbn1cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L0RlcHRoQ29udGV4dC5Qcm92aWRlcj5cbiAgICA8L2Rpdj5cbiAgKTtcbn07XG5cbmV4cG9ydCBjb25zdCBTZWxlY3RHcm91cE9wdGlvbiA9IE9iamVjdC5hc3NpZ24oXG4gIG1lbW8oU2VsZWN0R3JvdXBPcHRpb25Db21wb25lbnQpIGFzIHR5cGVvZiBTZWxlY3RHcm91cE9wdGlvbkNvbXBvbmVudCxcbiAgeyBfc2VsZWN0VHlwZTogU0VMRUNUX0dST1VQX09QVElPTl9UWVBFIH1cbik7XG4iXX0= */"], children: selectOptions ?? children }) })
|
|
61
|
+
] });
|
|
62
|
+
};
|
|
63
|
+
const SelectGroupOption = Object.assign(memo(SelectGroupOptionComponent), {
|
|
64
|
+
_selectType: SELECT_GROUP_OPTION_TYPE
|
|
65
|
+
});
|
|
66
|
+
export {
|
|
67
|
+
SelectGroupOption
|
|
68
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Theme } from 'themes';
|
|
2
|
+
export declare const selectGroupOptionStyle: {
|
|
3
|
+
wrapper: {
|
|
4
|
+
width: string;
|
|
5
|
+
};
|
|
6
|
+
getLabel: (depth: number) => (theme: Theme) => {
|
|
7
|
+
readonly color: "#8C8C8C";
|
|
8
|
+
readonly overflow: "hidden";
|
|
9
|
+
readonly whiteSpace: "nowrap";
|
|
10
|
+
readonly textOverflow: "ellipsis";
|
|
11
|
+
readonly fontFamily: "Roboto";
|
|
12
|
+
readonly fontSize: 14;
|
|
13
|
+
readonly lineHeight: "20px";
|
|
14
|
+
readonly display: "flex";
|
|
15
|
+
readonly alignItems: "center";
|
|
16
|
+
readonly width: "100%";
|
|
17
|
+
readonly paddingTop: 4;
|
|
18
|
+
readonly paddingRight: 8;
|
|
19
|
+
readonly paddingBottom: 4;
|
|
20
|
+
readonly paddingLeft: number;
|
|
21
|
+
readonly height: number;
|
|
22
|
+
readonly boxSizing: "border-box";
|
|
23
|
+
};
|
|
24
|
+
options: {
|
|
25
|
+
readonly display: "flex";
|
|
26
|
+
readonly flexDirection: "column";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getSelectTokens } from "../../../BaseSelect/BaseSelect.tokens.js";
|
|
2
|
+
import { DEPTH_PADDING_INCREMENT } from "../../contexts/DepthContext.js";
|
|
3
|
+
const selectGroupOptionStyle = {
|
|
4
|
+
wrapper: {
|
|
5
|
+
width: "100%"
|
|
6
|
+
},
|
|
7
|
+
getLabel: (depth) => (theme) => {
|
|
8
|
+
const selectTokens = getSelectTokens(theme);
|
|
9
|
+
const verticalPadding = theme.paddingXS;
|
|
10
|
+
return {
|
|
11
|
+
display: "flex",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
width: "100%",
|
|
14
|
+
paddingTop: verticalPadding,
|
|
15
|
+
paddingRight: theme.paddingM,
|
|
16
|
+
paddingBottom: verticalPadding,
|
|
17
|
+
paddingLeft: theme.paddingM + depth * DEPTH_PADDING_INCREMENT,
|
|
18
|
+
height: 20 + verticalPadding * 2,
|
|
19
|
+
boxSizing: "border-box",
|
|
20
|
+
...theme.typography.body2,
|
|
21
|
+
color: selectTokens.selectOptionTextSecondary,
|
|
22
|
+
overflow: "hidden",
|
|
23
|
+
whiteSpace: "nowrap",
|
|
24
|
+
textOverflow: "ellipsis"
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
options: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "column"
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
selectGroupOptionStyle
|
|
34
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Interpolation } from '@emotion/react';
|
|
2
|
+
import { PropsWithChildren, ReactNode } from 'react';
|
|
3
|
+
import { Theme } from 'themes';
|
|
4
|
+
export interface GroupOption<Option> {
|
|
5
|
+
groupKey: string;
|
|
6
|
+
label: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
options?: (GroupOption<Option> | Option)[];
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface SelectGroupOptionProps<Option> extends PropsWithChildren<GroupOption<Option>> {
|
|
13
|
+
index?: number;
|
|
14
|
+
onResize?: (index: number, height: number) => void;
|
|
15
|
+
styles?: {
|
|
16
|
+
wrapper?: (theme: Theme) => Interpolation;
|
|
17
|
+
label?: (theme: Theme) => Interpolation;
|
|
18
|
+
options?: (theme: Theme) => Interpolation;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare const isGroupOption: <Option>(option: GroupOption<Option> | Option) => option is GroupOption<Option>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
1
|
import { SelectOptionProps } from './SelectOption.types';
|
|
3
|
-
export declare const SelectOption:
|
|
2
|
+
export declare const SelectOption: import('react').NamedExoticComponent<SelectOptionProps> & {
|
|
3
|
+
_selectType: "option";
|
|
4
|
+
};
|