@laser-ui/components 1.6.1 → 2.0.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/CHANGELOG.md +10 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +13 -25
- package/accordion/types.d.ts +1 -0
- package/affix/Affix.d.ts +2 -2
- package/affix/Affix.js +27 -32
- package/affix/types.d.ts +7 -2
- package/alert/Alert.d.ts +1 -1
- package/alert/Alert.js +12 -21
- package/anchor/Anchor.d.ts +2 -4
- package/anchor/Anchor.js +34 -26
- package/anchor/types.d.ts +1 -0
- package/avatar/Avatar.d.ts +1 -1
- package/avatar/Avatar.js +9 -3
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +22 -41
- package/badge/BadgeText.js +12 -26
- package/badge/internal/BadgeNumber.d.ts +2 -2
- package/badge/internal/BadgeNumber.js +34 -24
- package/base-input/BaseInput.d.ts +1 -2
- package/base-input/BaseInput.js +4 -4
- package/base-input/types.d.ts +1 -0
- package/breadcrumb/Breadcrumb.d.ts +1 -1
- package/button/Button.d.ts +1 -2
- package/button/Button.js +18 -22
- package/button/types.d.ts +1 -0
- package/card/Card.d.ts +1 -1
- package/card/CardAction.d.ts +1 -1
- package/card/CardAction.js +3 -4
- package/card/CardActions.d.ts +1 -1
- package/card/CardActions.js +7 -3
- package/card/CardContent.d.ts +1 -1
- package/card/CardHeader.d.ts +1 -1
- package/card/types.d.ts +5 -1
- package/cascader/Cascader.d.ts +2 -4
- package/cascader/Cascader.js +217 -214
- package/cascader/internal/CascaderPanel.d.ts +2 -2
- package/cascader/internal/CascaderPanel.js +21 -7
- package/cascader/internal/CascaderSearchPanel.d.ts +2 -2
- package/cascader/internal/CascaderSearchPanel.js +15 -6
- package/cascader/types.d.ts +3 -3
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +4 -5
- package/checkbox/CheckboxGroup.d.ts +1 -1
- package/checkbox/CheckboxGroup.js +8 -7
- package/checkbox/types.d.ts +14 -4
- package/{internal/circular-progress → circular-progress}/CircularProgress.d.ts +1 -1
- package/{internal/circular-progress → circular-progress}/CircularProgress.js +2 -2
- package/compose/Compose.d.ts +1 -1
- package/compose/ComposeItem.d.ts +1 -1
- package/config-provider/ConfigProvider.d.ts +1 -1
- package/config-provider/ConfigProvider.js +3 -3
- package/date-picker/DatePicker.d.ts +2 -2
- package/date-picker/DatePicker.js +116 -98
- package/date-picker/internal/DatePickerPanel.d.ts +2 -1
- package/date-picker/internal/DatePickerPanel.js +4 -4
- package/date-picker/types.d.ts +3 -3
- package/dialog-service.d.ts +9 -6
- package/dialog-service.js +50 -26
- package/drawer/Drawer.d.ts +1 -1
- package/drawer/Drawer.js +83 -92
- package/drawer/DrawerFooter.d.ts +1 -1
- package/drawer/DrawerFooter.js +12 -9
- package/drawer/DrawerHeader.d.ts +1 -1
- package/drawer/DrawerHeader.js +10 -7
- package/drawer/types.d.ts +9 -2
- package/drawer/vars.d.ts +5 -1
- package/drawer/vars.js +1 -1
- package/dropdown/Dropdown.d.ts +2 -4
- package/dropdown/Dropdown.js +83 -104
- package/dropdown/internal/DropdownGroup.d.ts +1 -1
- package/dropdown/internal/DropdownItem.d.ts +1 -1
- package/dropdown/internal/DropdownSub.d.ts +2 -1
- package/dropdown/internal/DropdownSub.js +26 -49
- package/dropdown/types.d.ts +15 -2
- package/empty/Empty.d.ts +1 -1
- package/fab/Fab.d.ts +1 -1
- package/fab/Fab.js +19 -14
- package/fab/FabBacktop.d.ts +1 -1
- package/fab/FabBacktop.js +24 -31
- package/fab/FabButton.d.ts +1 -1
- package/fab/FabButton.js +37 -10
- package/fab/types.d.ts +6 -2
- package/fab/vars.d.ts +14 -0
- package/fab/vars.js +4 -0
- package/form/Form.d.ts +1 -1
- package/form/Form.js +7 -2
- package/form/FormItem.d.ts +1 -1
- package/form/FormItem.js +35 -24
- package/form/internal/FormError.d.ts +3 -2
- package/form/internal/FormError.js +10 -19
- package/hooks/index.d.ts +0 -2
- package/hooks/index.js +0 -2
- package/hooks/useComponentProps.js +2 -2
- package/hooks/useFocusVisible.d.ts +9 -2
- package/hooks/useFocusVisible.js +5 -11
- package/hooks/useLayout.d.ts +2 -2
- package/hooks/useLayout.js +2 -2
- package/hooks/useNamespace.js +2 -2
- package/hooks/useNestedPopup.d.ts +1 -1
- package/hooks/useScopedProps.js +2 -2
- package/hooks/useStyled.js +2 -2
- package/hooks/useTranslation.js +2 -2
- package/icon/Icon.d.ts +1 -1
- package/icon/Icon.js +7 -4
- package/image/Image.d.ts +1 -1
- package/image/Image.js +6 -2
- package/image/ImageAction.d.ts +1 -1
- package/image/ImageAction.js +3 -4
- package/image/ImageLoader.d.ts +1 -1
- package/image/ImagePreview.d.ts +1 -1
- package/image/ImagePreview.js +94 -109
- package/image/types.d.ts +6 -2
- package/input/Input.d.ts +1 -1
- package/input/Input.js +12 -8
- package/input/InputNumber.js +49 -40
- package/input/types.d.ts +3 -5
- package/internal/lazy-loading/LazyLoading.d.ts +3 -0
- package/internal/lazy-loading/LazyLoading.js +9 -0
- package/internal/lazy-loading/index.d.ts +2 -0
- package/internal/lazy-loading/index.js +1 -0
- package/internal/lazy-loading/types.d.ts +7 -0
- package/internal/popup/Popup.d.ts +1 -1
- package/internal/popup/Popup.js +40 -68
- package/internal/popup/types.d.ts +13 -6
- package/internal/portal/Portal.d.ts +1 -1
- package/internal/portal/Portal.js +12 -6
- package/internal/portal/types.d.ts +3 -2
- package/mask/Mask.d.ts +3 -0
- package/mask/Mask.js +31 -0
- package/menu/Menu.d.ts +2 -4
- package/menu/Menu.js +37 -42
- package/menu/internal/MenuGroup.d.ts +1 -1
- package/menu/internal/MenuItem.d.ts +1 -1
- package/menu/internal/MenuItem.js +14 -10
- package/menu/internal/MenuSub.d.ts +2 -1
- package/menu/internal/MenuSub.js +43 -70
- package/menu/types.d.ts +1 -0
- package/modal/Modal.d.ts +1 -1
- package/modal/Modal.js +77 -80
- package/modal/ModalAlert.d.ts +1 -1
- package/modal/ModalFooter.d.ts +1 -1
- package/modal/ModalFooter.js +12 -9
- package/modal/ModalHeader.d.ts +1 -1
- package/modal/ModalHeader.js +10 -7
- package/modal/types.d.ts +9 -2
- package/modal/vars.d.ts +5 -0
- package/modal/vars.js +2 -0
- package/notification/Notification.d.ts +1 -1
- package/notification/Notification.js +44 -71
- package/notification/types.d.ts +1 -0
- package/package.json +2 -2
- package/pagination/Pagination.d.ts +1 -1
- package/pagination/Pagination.js +9 -6
- package/popover/Popover.d.ts +2 -2
- package/popover/Popover.js +82 -118
- package/popover/PopoverFooter.d.ts +1 -1
- package/popover/PopoverFooter.js +12 -9
- package/popover/PopoverHeader.d.ts +1 -1
- package/popover/PopoverHeader.js +10 -7
- package/popover/types.d.ts +18 -4
- package/popover/vars.d.ts +5 -0
- package/popover/vars.js +2 -0
- package/progress/Progress.d.ts +1 -1
- package/radio/Radio.d.ts +1 -1
- package/radio/Radio.js +18 -13
- package/radio/RadioGroup.d.ts +1 -1
- package/radio/RadioGroup.js +12 -7
- package/radio/types.d.ts +16 -4
- package/radio/vars.d.ts +6 -0
- package/radio/vars.js +2 -0
- package/rating/Rating.d.ts +1 -1
- package/rating/internal/RatingStar.d.ts +1 -1
- package/rating/internal/RatingStar.js +23 -21
- package/root/Root.d.ts +1 -1
- package/root/Root.js +1 -1
- package/select/Select.d.ts +2 -4
- package/select/Select.js +245 -243
- package/select/types.d.ts +3 -3
- package/separator/Separator.d.ts +1 -1
- package/skeleton/Skeleton.d.ts +1 -1
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +54 -34
- package/slider/types.d.ts +2 -3
- package/slides/Slides.d.ts +1 -1
- package/slides/Slides.js +8 -3
- package/spinner/Spinner.d.ts +1 -1
- package/spinner/Spinner.js +27 -29
- package/stepper/Stepper.d.ts +1 -1
- package/stepper/Stepper.js +9 -16
- package/switch/Switch.js +33 -24
- package/switch/types.d.ts +2 -3
- package/table/Table.d.ts +1 -1
- package/table/Table.js +14 -10
- package/table/TableEmpty.d.ts +1 -1
- package/table/TableEmpty.js +9 -3
- package/table/TableExpand.d.ts +1 -1
- package/table/TableFilter.d.ts +1 -1
- package/table/TableFilter.js +1 -1
- package/table/TableTd.d.ts +1 -1
- package/table/TableTh.d.ts +1 -1
- package/table/TableThAction.d.ts +1 -1
- package/table/TableThAction.js +3 -4
- package/table/internal/TableCell.d.ts +1 -1
- package/table/internal/TableCell.js +13 -5
- package/table/types.d.ts +9 -2
- package/tabs/Tabs.d.ts +2 -4
- package/tabs/Tabs.js +41 -25
- package/tabs/types.d.ts +1 -0
- package/tag/Tag.d.ts +1 -1
- package/textarea/Textarea.d.ts +1 -1
- package/textarea/Textarea.js +15 -8
- package/textarea/types.d.ts +1 -0
- package/time-picker/TimePicker.d.ts +2 -2
- package/time-picker/TimePicker.js +89 -75
- package/time-picker/internal/TimePickerPanel.d.ts +2 -1
- package/time-picker/internal/TimePickerPanel.js +22 -7
- package/time-picker/types.d.ts +3 -3
- package/timeline/Timeline.d.ts +1 -1
- package/toast/Toast.d.ts +1 -1
- package/toast/Toast.js +44 -72
- package/toast/types.d.ts +1 -0
- package/tooltip/Tooltip.d.ts +2 -2
- package/tooltip/Tooltip.js +50 -74
- package/tooltip/types.d.ts +10 -2
- package/transfer/Transfer.d.ts +1 -1
- package/transfer/internal/TransferPanel.d.ts +1 -1
- package/transfer/internal/TransferPanel.js +7 -2
- package/{internal/transition → transition}/CollapseTransition.d.ts +1 -1
- package/transition/CollapseTransition.js +65 -0
- package/transition/Transition.d.ts +3 -0
- package/transition/Transition.js +148 -0
- package/transition/types.d.ts +29 -0
- package/tree/Tree.d.ts +1 -1
- package/tree/Tree.js +19 -7
- package/tree/internal/TreePanel.d.ts +2 -2
- package/tree/internal/TreePanel.js +32 -26
- package/tree-select/TreeSelect.d.ts +2 -4
- package/tree-select/TreeSelect.js +216 -213
- package/tree-select/internal/TreeSelectSearchPanel.d.ts +2 -2
- package/tree-select/internal/TreeSelectSearchPanel.js +15 -6
- package/tree-select/types.d.ts +3 -3
- package/types.d.ts +1 -1
- package/upload/Upload.d.ts +1 -3
- package/upload/Upload.js +41 -50
- package/upload/UploadAction.d.ts +1 -1
- package/upload/UploadAction.js +19 -16
- package/upload/UploadButton.d.ts +1 -1
- package/upload/UploadButton.js +16 -12
- package/upload/UploadList.d.ts +1 -1
- package/upload/UploadList.js +52 -47
- package/upload/UploadPicture.d.ts +1 -1
- package/upload/UploadPicture.js +47 -53
- package/upload/UploadPictureList.d.ts +1 -1
- package/upload/UploadPictureList.js +52 -47
- package/upload/UploadPreviewAction.d.ts +1 -1
- package/upload/UploadPreviewAction.js +15 -14
- package/upload/hooks.d.ts +2 -0
- package/upload/types.d.ts +27 -6
- package/upload/vars.d.ts +11 -0
- package/upload/vars.js +3 -0
- package/virtual-scroll/VirtualScroll.d.ts +2 -4
- package/virtual-scroll/VirtualScroll.js +13 -21
- package/virtual-scroll/types.d.ts +2 -1
- package/wave/Wave.d.ts +3 -0
- package/{internal/wave → wave}/Wave.js +6 -6
- package/{internal/wave → wave}/types.d.ts +1 -0
- package/wave/types.js +1 -0
- package/LICENSE +0 -21
- package/hooks/useJSS.d.ts +0 -1
- package/hooks/useJSS.js +0 -15
- package/hooks/useNextTick.d.ts +0 -2
- package/internal/mask/Mask.d.ts +0 -3
- package/internal/mask/Mask.js +0 -36
- package/internal/transition/CollapseTransition.js +0 -101
- package/internal/transition/Transition.d.ts +0 -3
- package/internal/transition/Transition.js +0 -87
- package/internal/transition/types.d.ts +0 -33
- package/internal/wave/Wave.d.ts +0 -3
- /package/{internal/circular-progress → circular-progress}/index.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/index.js +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.d.ts +0 -0
- /package/{internal/circular-progress → circular-progress}/vars.js +0 -0
- /package/internal/{mask → lazy-loading}/types.js +0 -0
- /package/{internal/mask → mask}/index.d.ts +0 -0
- /package/{internal/mask → mask}/index.js +0 -0
- /package/{internal/mask → mask}/types.d.ts +0 -0
- /package/{internal/transition → mask}/types.js +0 -0
- /package/{internal/mask → mask}/vars.d.ts +0 -0
- /package/{internal/mask → mask}/vars.js +0 -0
- /package/{internal/transition → transition}/index.d.ts +0 -0
- /package/{internal/transition → transition}/index.js +0 -0
- /package/{internal/wave → transition}/types.js +0 -0
- /package/{hooks/useNextTick.js → upload/hooks.js} +0 -0
- /package/{internal/wave → wave}/index.d.ts +0 -0
- /package/{internal/wave → wave}/index.js +0 -0
- /package/{internal/wave → wave}/vars.d.ts +0 -0
- /package/{internal/wave → wave}/vars.js +0 -0
package/select/Select.js
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
4
|
-
import { useEventCallback,
|
|
5
|
-
import { findNested, scrollIntoViewIfNeeded } from '@laser-ui/utils';
|
|
4
|
+
import { useEventCallback, useResize } from '@laser-ui/hooks';
|
|
5
|
+
import { findNested, scrollIntoViewIfNeeded, setRef } from '@laser-ui/utils';
|
|
6
6
|
import CancelFilled from '@material-design-icons/svg/filled/cancel.svg?react';
|
|
7
7
|
import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
|
|
8
8
|
import CloseOutlined from '@material-design-icons/svg/outlined/close.svg?react';
|
|
9
9
|
import KeyboardArrowDownOutlined from '@material-design-icons/svg/outlined/keyboard_arrow_down.svg?react';
|
|
10
10
|
import SearchOutlined from '@material-design-icons/svg/outlined/search.svg?react';
|
|
11
11
|
import { isNull, isNumber, isUndefined } from 'lodash';
|
|
12
|
-
import {
|
|
12
|
+
import { useCallback, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
13
13
|
import { CLASSES, IS_CREATED } from './vars';
|
|
14
14
|
import { BaseInput } from '../base-input';
|
|
15
15
|
import { Checkbox } from '../checkbox';
|
|
16
|
+
import { CircularProgress } from '../circular-progress';
|
|
16
17
|
import { Dropdown } from '../dropdown';
|
|
17
18
|
import { Empty } from '../empty';
|
|
18
|
-
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible,
|
|
19
|
+
import { useComponentProps, useContainerScrolling, useControlled, useDesign, useFocusVisible, useLayout, useMaxIndex, useNamespace, useScopedProps, useStyled, useTranslation, } from '../hooks';
|
|
19
20
|
import { Icon } from '../icon';
|
|
20
|
-
import { CircularProgress } from '../internal/circular-progress';
|
|
21
21
|
import { Portal } from '../internal/portal';
|
|
22
|
-
import { Transition } from '../internal/transition';
|
|
23
22
|
import { ROOT_DATA } from '../root/vars';
|
|
24
23
|
import { Tag } from '../tag';
|
|
24
|
+
import { Transition } from '../transition';
|
|
25
25
|
import { getVerticalSidePosition, isPrintableCharacter, mergeCS } from '../utils';
|
|
26
26
|
import { TTANSITION_DURING_POPUP, WINDOW_SPACE } from '../vars';
|
|
27
27
|
import { VirtualScroll } from '../virtual-scroll';
|
|
28
|
-
function
|
|
29
|
-
const _a = useComponentProps('Select', props), { styleOverrides, styleProvider, formControl, list: listProp, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, monospaced = true, virtual = false, escClosable = true, customItem, customSelected, customSearch, createItem,
|
|
28
|
+
export function Select(props) {
|
|
29
|
+
const _a = useComponentProps('Select', props), { ref, styleOverrides, styleProvider, formControl, list: listProp, model, defaultModel, visible: visibleProp, defaultVisible, placeholder, multiple = false, searchable = false, searchValue: searchValueProp, defaultSearchValue, clearable: clearableProp = false, loading = false, size: sizeProp, disabled: disabledProp = false, monospaced = true, virtual = false, escClosable = true, customItem, customSelected, customSearch, createItem, inputProps, popupRender, onModelChange, onVisibleChange, onSearch, onClear, onCreateItem, onScrollBottom, afterVisibleChange } = _a, restProps = __rest(_a, ["ref", "styleOverrides", "styleProvider", "formControl", "list", "model", "defaultModel", "visible", "defaultVisible", "placeholder", "multiple", "searchable", "searchValue", "defaultSearchValue", "clearable", "loading", "size", "disabled", "monospaced", "virtual", "escClosable", "customItem", "customSelected", "customSearch", "createItem", "inputProps", "popupRender", "onModelChange", "onVisibleChange", "onSearch", "onClear", "onCreateItem", "onScrollBottom", "afterVisibleChange"]);
|
|
30
30
|
const namespace = useNamespace();
|
|
31
31
|
const styled = useStyled(CLASSES, { select: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.select, 'select-popup': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['select-popup'] }, styleOverrides);
|
|
32
|
-
const sheet = useJSS();
|
|
33
32
|
const { t } = useTranslation();
|
|
34
33
|
const uniqueId = useId();
|
|
35
34
|
const listId = `${namespace}-select-list-${uniqueId}`;
|
|
@@ -39,7 +38,6 @@ function SelectFC(props, ref) {
|
|
|
39
38
|
const popupRef = useRef(null);
|
|
40
39
|
const listRef = useRef(null);
|
|
41
40
|
const inputRef = useRef(null);
|
|
42
|
-
const combineInputRef = useForkRef(inputRef, inputRefProp);
|
|
43
41
|
const vsRef = useRef(null);
|
|
44
42
|
const itemsMap = useMemo(() => {
|
|
45
43
|
const items = new Map();
|
|
@@ -133,7 +131,7 @@ function SelectFC(props, ref) {
|
|
|
133
131
|
return searchList;
|
|
134
132
|
})();
|
|
135
133
|
const list = hasSearch ? searchList : listProp;
|
|
136
|
-
const [focusVisible,
|
|
134
|
+
const [focusVisible, focusVisibleProps] = useFocusVisible((code) => code.startsWith('Arrow') || ['Home', 'End', 'Enter', 'Space'].includes(code));
|
|
137
135
|
const [_itemFocusedWithoutSearch, setItemFocusedWithoutSearch] = useState();
|
|
138
136
|
const itemFocusedWithoutSearch = (() => {
|
|
139
137
|
let itemFocused;
|
|
@@ -173,7 +171,6 @@ function SelectFC(props, ref) {
|
|
|
173
171
|
};
|
|
174
172
|
const maxZIndex = useMaxIndex(visible);
|
|
175
173
|
const zIndex = `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
176
|
-
const transformOrigin = useRef();
|
|
177
174
|
const updatePosition = useEventCallback(() => {
|
|
178
175
|
if (visible && boxRef.current && popupRef.current) {
|
|
179
176
|
if (monospaced) {
|
|
@@ -183,16 +180,12 @@ function SelectFC(props, ref) {
|
|
|
183
180
|
placement: 'bottom',
|
|
184
181
|
inWindow: WINDOW_SPACE,
|
|
185
182
|
});
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
left: position.left,
|
|
193
|
-
width,
|
|
194
|
-
});
|
|
195
|
-
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
183
|
+
popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
|
|
184
|
+
popupRef.current.style.top = position.top + 'px';
|
|
185
|
+
popupRef.current.style.left = position.left + 'px';
|
|
186
|
+
popupRef.current.style.width = width + 'px';
|
|
187
|
+
popupRef.current.style.minWidth = '';
|
|
188
|
+
popupRef.current.style.maxWidth = '';
|
|
196
189
|
}
|
|
197
190
|
else {
|
|
198
191
|
const boxWidth = boxRef.current.offsetWidth;
|
|
@@ -203,17 +196,12 @@ function SelectFC(props, ref) {
|
|
|
203
196
|
placement: 'bottom-left',
|
|
204
197
|
inWindow: WINDOW_SPACE,
|
|
205
198
|
});
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
left: position.left,
|
|
213
|
-
minWidth: Math.min(boxWidth, maxWidth),
|
|
214
|
-
maxWidth,
|
|
215
|
-
});
|
|
216
|
-
popupRef.current.classList.toggle(sheet.classes.position, true);
|
|
199
|
+
popupRef.current.style.setProperty(`--popup-down-transform-origin`, position.transformOrigin);
|
|
200
|
+
popupRef.current.style.top = position.top + 'px';
|
|
201
|
+
popupRef.current.style.left = position.left + 'px';
|
|
202
|
+
popupRef.current.style.width = '';
|
|
203
|
+
popupRef.current.style.minWidth = Math.min(boxWidth, maxWidth) + 'px';
|
|
204
|
+
popupRef.current.style.maxWidth = maxWidth + 'px';
|
|
217
205
|
}
|
|
218
206
|
}
|
|
219
207
|
});
|
|
@@ -229,140 +217,9 @@ function SelectFC(props, ref) {
|
|
|
229
217
|
e.preventDefault();
|
|
230
218
|
}
|
|
231
219
|
};
|
|
232
|
-
const scrollCallback = useRef();
|
|
220
|
+
const scrollCallback = useRef(() => { });
|
|
233
221
|
const inputable = searchable && visible;
|
|
234
222
|
const clearable = clearableProp && hasSelected && !visible && !loading && !disabled;
|
|
235
|
-
const inputNode = focusVisibleWrapper(createElement(searchable ? BaseInput : 'div', Object.assign(Object.assign(Object.assign(Object.assign({}, mergeCS(styled('select__search'), {
|
|
236
|
-
style: {
|
|
237
|
-
opacity: inputable ? undefined : 0,
|
|
238
|
-
zIndex: inputable ? undefined : -1,
|
|
239
|
-
},
|
|
240
|
-
})), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria), { ref: combineInputRef, tabIndex: disabled ? -1 : 0, role: 'combobox', 'aria-haspopup': 'listbox', 'aria-expanded': visible, 'aria-controls': listId, onBlur: () => {
|
|
241
|
-
changeVisible(false);
|
|
242
|
-
}, onKeyDown: (e) => {
|
|
243
|
-
if (e.code === 'Escape') {
|
|
244
|
-
if (visible && escClosable) {
|
|
245
|
-
e.stopPropagation();
|
|
246
|
-
e.preventDefault();
|
|
247
|
-
changeVisible(false);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
const focusItem = (code) => {
|
|
252
|
-
var _a, _b, _c, _d;
|
|
253
|
-
if (listRef.current) {
|
|
254
|
-
let item;
|
|
255
|
-
switch (code) {
|
|
256
|
-
case 'next':
|
|
257
|
-
item = (_a = vsRef.current) === null || _a === void 0 ? void 0 : _a.scrollToStep(listRef.current, 1);
|
|
258
|
-
break;
|
|
259
|
-
case 'prev':
|
|
260
|
-
item = (_b = vsRef.current) === null || _b === void 0 ? void 0 : _b.scrollToStep(listRef.current, -1);
|
|
261
|
-
break;
|
|
262
|
-
case 'first':
|
|
263
|
-
item = (_c = vsRef.current) === null || _c === void 0 ? void 0 : _c.scrollToStart(listRef.current);
|
|
264
|
-
break;
|
|
265
|
-
case 'last':
|
|
266
|
-
item = (_d = vsRef.current) === null || _d === void 0 ? void 0 : _d.scrollToEnd(listRef.current);
|
|
267
|
-
break;
|
|
268
|
-
default:
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
if (item) {
|
|
272
|
-
changeItemFocused(item);
|
|
273
|
-
if (virtual === false) {
|
|
274
|
-
scrollCallback.current = () => {
|
|
275
|
-
const el = document.getElementById(getItemId(item.value));
|
|
276
|
-
if (el) {
|
|
277
|
-
scrollIntoViewIfNeeded(el, listRef.current);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
if (visible) {
|
|
281
|
-
scrollCallback.current();
|
|
282
|
-
scrollCallback.current = undefined;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
if (visible) {
|
|
289
|
-
switch (e.code) {
|
|
290
|
-
case 'ArrowUp': {
|
|
291
|
-
e.preventDefault();
|
|
292
|
-
focusItem('prev');
|
|
293
|
-
break;
|
|
294
|
-
}
|
|
295
|
-
case 'ArrowDown': {
|
|
296
|
-
e.preventDefault();
|
|
297
|
-
focusItem('next');
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
case 'Home': {
|
|
301
|
-
e.preventDefault();
|
|
302
|
-
focusItem('first');
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
case 'End': {
|
|
306
|
-
e.preventDefault();
|
|
307
|
-
focusItem('last');
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
default: {
|
|
311
|
-
if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
|
|
312
|
-
e.preventDefault();
|
|
313
|
-
if (itemFocused) {
|
|
314
|
-
if (itemFocused[IS_CREATED]) {
|
|
315
|
-
handleCreateItem(itemFocused);
|
|
316
|
-
}
|
|
317
|
-
changeSelectedByClick(itemFocused.value);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
|
|
325
|
-
switch (e.code) {
|
|
326
|
-
case 'End':
|
|
327
|
-
case 'ArrowUp': {
|
|
328
|
-
e.preventDefault();
|
|
329
|
-
changeVisible(true);
|
|
330
|
-
focusItem('last');
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
case 'Home':
|
|
334
|
-
case 'ArrowDown': {
|
|
335
|
-
e.preventDefault();
|
|
336
|
-
changeVisible(true);
|
|
337
|
-
focusItem('first');
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
case 'Enter':
|
|
341
|
-
case 'Space': {
|
|
342
|
-
e.preventDefault();
|
|
343
|
-
changeVisible(true);
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
default: {
|
|
347
|
-
if (isPrintableCharacter(e.key)) {
|
|
348
|
-
changeVisible(true);
|
|
349
|
-
}
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
} }), searchable
|
|
356
|
-
? {
|
|
357
|
-
type: 'text',
|
|
358
|
-
value: searchValue,
|
|
359
|
-
autoComplete: 'off',
|
|
360
|
-
disabled,
|
|
361
|
-
onValueChange: (val) => {
|
|
362
|
-
changeSearchValue(val);
|
|
363
|
-
},
|
|
364
|
-
}
|
|
365
|
-
: {})));
|
|
366
223
|
const [selectedNode, suffixNode, selectedLabel] = (() => {
|
|
367
224
|
let selectedNode = null;
|
|
368
225
|
let suffixNode = null;
|
|
@@ -384,7 +241,7 @@ function SelectFC(props, ref) {
|
|
|
384
241
|
})), onClick: (id) => {
|
|
385
242
|
changeSelectedByClick(id);
|
|
386
243
|
return false;
|
|
387
|
-
}, children: _jsx(Tag, { tabIndex: -1, size: size, children: selected.size }) }));
|
|
244
|
+
}, children: (dropdownProps) => (_jsx(Tag, Object.assign({}, dropdownProps, { tabIndex: -1, size: size, children: selected.size }))) }));
|
|
388
245
|
selectedNode = selectedItems.map(({ value, label, item }) => (_jsxs(Tag, { size: size, children: [label, !((item === null || item === void 0 ? void 0 : item.disabled) || disabled) && (_jsx("div", Object.assign({}, styled('select__close'), { role: "button", "aria-label": t('Close'), onClick: (e) => {
|
|
389
246
|
e.stopPropagation();
|
|
390
247
|
changeSelectedByClick(value);
|
|
@@ -413,7 +270,12 @@ function SelectFC(props, ref) {
|
|
|
413
270
|
}), {
|
|
414
271
|
className: restProps.className,
|
|
415
272
|
style: restProps.style,
|
|
416
|
-
}), designProps, { ref:
|
|
273
|
+
}), designProps, { ref: (instance) => {
|
|
274
|
+
boxRef.current = instance;
|
|
275
|
+
return () => {
|
|
276
|
+
boxRef.current = null;
|
|
277
|
+
};
|
|
278
|
+
}, onMouseDown: (e) => {
|
|
417
279
|
var _a;
|
|
418
280
|
(_a = restProps.onMouseDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
419
281
|
preventBlur(e);
|
|
@@ -426,7 +288,157 @@ function SelectFC(props, ref) {
|
|
|
426
288
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
427
289
|
(_b = inputRef.current) === null || _b === void 0 ? void 0 : _b.focus({ preventScroll: true });
|
|
428
290
|
changeVisible((draft) => (searchable ? true : !draft));
|
|
429
|
-
}, children: [_jsxs("div", Object.assign({}, styled('select__container'), { title: selectedLabel, children: [
|
|
291
|
+
}, children: [_jsxs("div", Object.assign({}, styled('select__container'), { title: selectedLabel, children: [(() => {
|
|
292
|
+
const nodeProps = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, inputProps), mergeCS(styled('select__search'), {
|
|
293
|
+
style: {
|
|
294
|
+
opacity: inputable ? undefined : 0,
|
|
295
|
+
zIndex: inputable ? undefined : -1,
|
|
296
|
+
},
|
|
297
|
+
})), formControl === null || formControl === void 0 ? void 0 : formControl.inputAria), { ref: (instance) => {
|
|
298
|
+
inputRef.current = instance;
|
|
299
|
+
const ret = setRef(inputProps === null || inputProps === void 0 ? void 0 : inputProps.ref, instance);
|
|
300
|
+
return () => {
|
|
301
|
+
inputRef.current = null;
|
|
302
|
+
ret();
|
|
303
|
+
};
|
|
304
|
+
}, tabIndex: disabled ? -1 : 0, role: 'combobox', 'aria-haspopup': 'listbox', 'aria-expanded': visible, 'aria-controls': listId, onFocus: (e) => {
|
|
305
|
+
var _a;
|
|
306
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onFocus) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
307
|
+
focusVisibleProps.onFocus(e);
|
|
308
|
+
}, onBlur: (e) => {
|
|
309
|
+
var _a;
|
|
310
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
311
|
+
focusVisibleProps.onBlur(e);
|
|
312
|
+
changeVisible(false);
|
|
313
|
+
}, onKeyDown: (e) => {
|
|
314
|
+
var _a;
|
|
315
|
+
(_a = inputProps === null || inputProps === void 0 ? void 0 : inputProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(inputProps, e);
|
|
316
|
+
focusVisibleProps.onKeyDown(e);
|
|
317
|
+
if (e.code === 'Escape') {
|
|
318
|
+
if (visible && escClosable) {
|
|
319
|
+
e.stopPropagation();
|
|
320
|
+
e.preventDefault();
|
|
321
|
+
changeVisible(false);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
const focusItem = (code) => {
|
|
326
|
+
var _a, _b, _c, _d;
|
|
327
|
+
if (listRef.current) {
|
|
328
|
+
let item;
|
|
329
|
+
switch (code) {
|
|
330
|
+
case 'next':
|
|
331
|
+
item = (_a = vsRef.current) === null || _a === void 0 ? void 0 : _a.scrollToStep(listRef.current, 1);
|
|
332
|
+
break;
|
|
333
|
+
case 'prev':
|
|
334
|
+
item = (_b = vsRef.current) === null || _b === void 0 ? void 0 : _b.scrollToStep(listRef.current, -1);
|
|
335
|
+
break;
|
|
336
|
+
case 'first':
|
|
337
|
+
item = (_c = vsRef.current) === null || _c === void 0 ? void 0 : _c.scrollToStart(listRef.current);
|
|
338
|
+
break;
|
|
339
|
+
case 'last':
|
|
340
|
+
item = (_d = vsRef.current) === null || _d === void 0 ? void 0 : _d.scrollToEnd(listRef.current);
|
|
341
|
+
break;
|
|
342
|
+
default:
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
if (item) {
|
|
346
|
+
changeItemFocused(item);
|
|
347
|
+
if (virtual === false) {
|
|
348
|
+
scrollCallback.current = () => {
|
|
349
|
+
scrollCallback.current = () => { };
|
|
350
|
+
const el = document.getElementById(getItemId(item.value));
|
|
351
|
+
if (el) {
|
|
352
|
+
scrollIntoViewIfNeeded(el, listRef.current);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
if (visible) {
|
|
356
|
+
scrollCallback.current();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
if (visible) {
|
|
363
|
+
switch (e.code) {
|
|
364
|
+
case 'ArrowUp': {
|
|
365
|
+
e.preventDefault();
|
|
366
|
+
focusItem('prev');
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
case 'ArrowDown': {
|
|
370
|
+
e.preventDefault();
|
|
371
|
+
focusItem('next');
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
case 'Home': {
|
|
375
|
+
e.preventDefault();
|
|
376
|
+
focusItem('first');
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
case 'End': {
|
|
380
|
+
e.preventDefault();
|
|
381
|
+
focusItem('last');
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
default: {
|
|
385
|
+
if (e.code === 'Enter' || (e.code === 'Space' && !searchable)) {
|
|
386
|
+
e.preventDefault();
|
|
387
|
+
if (itemFocused) {
|
|
388
|
+
if (itemFocused[IS_CREATED]) {
|
|
389
|
+
handleCreateItem(itemFocused);
|
|
390
|
+
}
|
|
391
|
+
changeSelectedByClick(itemFocused.value);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
else if (!(searchable && ['Home', 'End', 'Enter', 'Space'].includes(e.code))) {
|
|
399
|
+
switch (e.code) {
|
|
400
|
+
case 'End':
|
|
401
|
+
case 'ArrowUp': {
|
|
402
|
+
e.preventDefault();
|
|
403
|
+
changeVisible(true);
|
|
404
|
+
focusItem('last');
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
case 'Home':
|
|
408
|
+
case 'ArrowDown': {
|
|
409
|
+
e.preventDefault();
|
|
410
|
+
changeVisible(true);
|
|
411
|
+
focusItem('first');
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
case 'Enter':
|
|
415
|
+
case 'Space': {
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
changeVisible(true);
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
default: {
|
|
421
|
+
if (isPrintableCharacter(e.key)) {
|
|
422
|
+
changeVisible(true);
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
} }), searchable
|
|
430
|
+
? {
|
|
431
|
+
type: 'text',
|
|
432
|
+
value: searchValue,
|
|
433
|
+
autoComplete: 'off',
|
|
434
|
+
disabled,
|
|
435
|
+
onValueChange: (val) => {
|
|
436
|
+
changeSearchValue(val);
|
|
437
|
+
},
|
|
438
|
+
}
|
|
439
|
+
: {});
|
|
440
|
+
return searchable ? _jsx(BaseInput, Object.assign({}, nodeProps)) : _jsx("div", Object.assign({}, nodeProps));
|
|
441
|
+
})(), !inputable &&
|
|
430
442
|
(hasSelected ? (_jsx("div", Object.assign({}, styled('select__content'), { children: selectedNode }))) : placeholder ? (_jsx("div", Object.assign({}, styled('select__placeholder-wrapper'), { children: _jsx("div", Object.assign({}, styled('select__placeholder'), { children: placeholder })) }))) : null)] })), multiple && (_jsx("div", Object.assign({}, styled('select__multiple-count'), { onClick: (e) => {
|
|
431
443
|
e.stopPropagation();
|
|
432
444
|
}, children: suffixNode }))), clearable && (_jsx("div", Object.assign({}, styled('select__clear'), { role: "button", "aria-label": t('Clear'), onClick: (e) => {
|
|
@@ -448,82 +460,72 @@ function SelectFC(props, ref) {
|
|
|
448
460
|
document.body.appendChild(el);
|
|
449
461
|
}
|
|
450
462
|
return el;
|
|
451
|
-
}, children: _jsx(Transition, { enter: visible,
|
|
452
|
-
var _a;
|
|
463
|
+
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup-down`, duration: TTANSITION_DURING_POPUP, onSkipEnter: () => {
|
|
453
464
|
updatePosition();
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
465
|
+
scrollCallback.current();
|
|
466
|
+
}, onBeforeEnter: () => {
|
|
467
|
+
updatePosition();
|
|
468
|
+
scrollCallback.current();
|
|
469
|
+
}, onAfterEnter: () => {
|
|
457
470
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
458
|
-
},
|
|
471
|
+
}, onAfterLeave: () => {
|
|
459
472
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
460
|
-
}, children: (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
changeItemFocused(item);
|
|
519
|
-
changeSelectedByClick(itemValue);
|
|
520
|
-
} }),
|
|
521
|
-
focusVisible && (itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value) === itemValue && _jsx("div", { className: `${namespace}-focus-outline` }),
|
|
522
|
-
item[IS_CREATED] ? (_jsx("div", Object.assign({}, styled('select__option-prefix'), { children: _jsx(Icon, { theme: "primary", children: _jsx(AddOutlined, {}) }) }))) : multiple ? (_jsx("div", Object.assign({}, styled('select__option-prefix'), { children: _jsx(Checkbox, { model: isSelected, disabled: itemDisabled }) }))) : null,
|
|
523
|
-
_jsx("div", Object.assign({}, styled('select__option-content'), { children: node }))));
|
|
524
|
-
}, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, itemEmptyRender: () => (_jsx("li", Object.assign({}, mergeCS(styled('select__empty'), { style: { paddingLeft: 12 + 8 } }), { children: _jsx("div", Object.assign({}, styled('select__option-content'), { children: t('No data') })) }))), itemInAriaSetsize: (item) => !item.children, placeholder: "li", onScrollEnd: onScrollBottom, children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('select__list'), { ref: listRef, id: listId, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": isUndefined(itemFocused) ? undefined : getItemId(itemFocused.value), onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 0' }, image: Empty.SIMPLE_IMG }) : vsList }))) })))] })));
|
|
525
|
-
return popupRender ? popupRender(el) : el;
|
|
526
|
-
})() })));
|
|
527
|
-
} }) })] }));
|
|
473
|
+
}, children: (transitionRef, leaved) => (_jsx("div", Object.assign({}, mergeCS(styled('select-popup'), {
|
|
474
|
+
style: Object.assign({ zIndex }, (leaved ? { display: 'none' } : undefined)),
|
|
475
|
+
}), { ref: (instance) => {
|
|
476
|
+
popupRef.current = instance;
|
|
477
|
+
transitionRef(instance);
|
|
478
|
+
return () => {
|
|
479
|
+
popupRef.current = null;
|
|
480
|
+
transitionRef(null);
|
|
481
|
+
};
|
|
482
|
+
}, onMouseDown: (e) => {
|
|
483
|
+
preventBlur(e);
|
|
484
|
+
}, onMouseUp: (e) => {
|
|
485
|
+
preventBlur(e);
|
|
486
|
+
}, children: (() => {
|
|
487
|
+
const el = (_jsxs("div", Object.assign({}, styled('select-popup__content'), { children: [loading && (_jsx("div", Object.assign({}, styled('select-popup__loading', {
|
|
488
|
+
'select-popup__loading--empty': list.length === 0,
|
|
489
|
+
}), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), loading && list.length === 0 ? null : (_jsx(VirtualScroll, Object.assign({}, vsProps, { ref: (instance) => {
|
|
490
|
+
vsRef.current = instance;
|
|
491
|
+
return () => {
|
|
492
|
+
vsRef.current = null;
|
|
493
|
+
};
|
|
494
|
+
}, enable: virtual !== false, listSize: 264, listPadding: 4, itemRender: (item, index, props, ancestry, children) => {
|
|
495
|
+
const { label: itemLabel, value: itemValue, disabled: itemDisabled } = item;
|
|
496
|
+
const node = customItem ? customItem(item) : itemLabel;
|
|
497
|
+
if (children) {
|
|
498
|
+
return (_createElement("ul", Object.assign({}, styled('select__option-group'), { key: itemValue, role: "group", "aria-labelledby": getItemId(itemValue) }),
|
|
499
|
+
_createElement("li", Object.assign({}, styled('select__option-group-label'), { key: itemValue, id: getItemId(itemValue), role: "presentation" }),
|
|
500
|
+
_jsx("div", Object.assign({}, styled('select__option-content'), { children: node }))),
|
|
501
|
+
children));
|
|
502
|
+
}
|
|
503
|
+
let isSelected = false;
|
|
504
|
+
if (multiple) {
|
|
505
|
+
isSelected = selected.has(itemValue);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
isSelected = selected === itemValue;
|
|
509
|
+
}
|
|
510
|
+
return (_createElement("li", Object.assign({}, mergeCS(styled('select__option', {
|
|
511
|
+
'select__option.is-selected': !multiple && isSelected,
|
|
512
|
+
'select__option.is-disabled': itemDisabled,
|
|
513
|
+
}), { style: { paddingLeft: ancestry.length === 0 ? undefined : 12 + 8 } }), props, { key: itemValue, id: getItemId(itemValue), title: (item[IS_CREATED] ? t('Create') + ' ' : '') + itemLabel, role: "option", "aria-selected": isSelected, "aria-disabled": itemDisabled, onClick: () => {
|
|
514
|
+
if (item[IS_CREATED]) {
|
|
515
|
+
handleCreateItem(item);
|
|
516
|
+
}
|
|
517
|
+
changeItemFocused(item);
|
|
518
|
+
changeSelectedByClick(itemValue);
|
|
519
|
+
} }),
|
|
520
|
+
focusVisible && (itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value) === itemValue && _jsx("div", { className: `${namespace}-focus-outline` }),
|
|
521
|
+
item[IS_CREATED] ? (_jsx("div", Object.assign({}, styled('select__option-prefix'), { children: _jsx(Icon, { theme: "primary", children: _jsx(AddOutlined, {}) }) }))) : multiple ? (_jsx("div", Object.assign({}, styled('select__option-prefix'), { children: _jsx(Checkbox, { model: isSelected, disabled: itemDisabled }) }))) : null,
|
|
522
|
+
_jsx("div", Object.assign({}, styled('select__option-content'), { children: node }))));
|
|
523
|
+
}, itemFocused: itemFocused === null || itemFocused === void 0 ? void 0 : itemFocused.value, itemEmptyRender: () => (_jsx("li", Object.assign({}, mergeCS(styled('select__empty'), { style: { paddingLeft: 12 + 8 } }), { children: _jsx("div", Object.assign({}, styled('select__option-content'), { children: t('No data') })) }))), itemInAriaSetsize: (item) => !item.children, placeholder: "li", onScrollEnd: onScrollBottom, children: (vsList, onScroll) => (_jsx("ul", Object.assign({}, styled('select__list'), { ref: (instance) => {
|
|
524
|
+
listRef.current = instance;
|
|
525
|
+
return () => {
|
|
526
|
+
listRef.current = null;
|
|
527
|
+
};
|
|
528
|
+
}, id: listId, tabIndex: -1, role: "listbox", "aria-multiselectable": multiple, "aria-activedescendant": isUndefined(itemFocused) ? undefined : getItemId(itemFocused.value), onScroll: onScroll, children: list.length === 0 ? _jsx(Empty, { style: { padding: '12px 0' }, image: Empty.SIMPLE_IMG }) : vsList }))) })))] })));
|
|
529
|
+
return popupRender ? popupRender(el) : el;
|
|
530
|
+
})() }))) }) })] }));
|
|
528
531
|
}
|
|
529
|
-
export const Select = forwardRef(SelectFC);
|
package/select/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
|
-
import type { BaseProps,
|
|
4
|
+
import type { BaseProps, Size } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export interface SelectRef {
|
|
7
7
|
updatePosition: () => void;
|
|
@@ -13,6 +13,7 @@ export interface SelectItem<V extends React.Key> {
|
|
|
13
13
|
children?: SelectItem<V>[];
|
|
14
14
|
}
|
|
15
15
|
export interface SelectProps<V extends React.Key, T extends SelectItem<V>> extends BaseProps<'select' | 'select-popup', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
16
|
+
ref?: React.Ref<SelectRef>;
|
|
16
17
|
formControl?: FormControlProvider;
|
|
17
18
|
list: T[];
|
|
18
19
|
model?: V | null | V[];
|
|
@@ -38,8 +39,7 @@ export interface SelectProps<V extends React.Key, T extends SelectItem<V>> exten
|
|
|
38
39
|
sort?: (a: T, b: T) => number;
|
|
39
40
|
};
|
|
40
41
|
createItem?: (value: string) => T | undefined;
|
|
41
|
-
|
|
42
|
-
inputRender?: CloneHTMLElement;
|
|
42
|
+
inputProps?: React.ComponentPropsWithRef<'input'>;
|
|
43
43
|
popupRender?: (el: React.ReactElement) => React.ReactNode;
|
|
44
44
|
onModelChange?: (value: any, origin: any) => void;
|
|
45
45
|
onVisibleChange?: (visible: boolean) => void;
|
package/separator/Separator.d.ts
CHANGED