@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
|
@@ -4,12 +4,12 @@ import { useEventCallback } from '@laser-ui/hooks';
|
|
|
4
4
|
import { scrollTo } from '@laser-ui/utils';
|
|
5
5
|
import { freeze } from 'immer';
|
|
6
6
|
import { isUndefined } from 'lodash';
|
|
7
|
-
import {
|
|
7
|
+
import { useImperativeHandle, useRef, useState } from 'react';
|
|
8
8
|
import dayjs from '../../dayjs';
|
|
9
9
|
const H12 = freeze(['12', ...Array.from({ length: 11 }).map((_, i) => `${i + 1 < 10 ? '0' : ''}${i + 1}`)]);
|
|
10
10
|
const [H24, M60, S60] = [24, 60, 60].map((num) => freeze(Array.from({ length: num }).map((_, i) => `${i < 10 ? '0' : ''}${i}`)));
|
|
11
|
-
export
|
|
12
|
-
const { styled, time: timeProp, format: formatProp, config, inDatePicker = false, onTimeChange } = props;
|
|
11
|
+
export function TimePickerPanel(props) {
|
|
12
|
+
const { ref, styled, time: timeProp, format: formatProp, config, inDatePicker = false, onTimeChange } = props;
|
|
13
13
|
const ulHRef = useRef(null);
|
|
14
14
|
const ulMRef = useRef(null);
|
|
15
15
|
const ulSRef = useRef(null);
|
|
@@ -78,7 +78,12 @@ export const TimePickerPanel = forwardRef((props, ref) => {
|
|
|
78
78
|
useImperativeHandle(ref, () => (t) => {
|
|
79
79
|
updateView(t, undefined, 'instant');
|
|
80
80
|
}, [updateView]);
|
|
81
|
-
return (_jsxs("div", Object.assign({}, styled('time-picker__panel'), { children: [inDatePicker && _jsx("div", Object.assign({}, styled('time-picker__header'), { children: time.format(cols.join(':')) })), cols.includes('HH') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref:
|
|
81
|
+
return (_jsxs("div", Object.assign({}, styled('time-picker__panel'), { children: [inDatePicker && _jsx("div", Object.assign({}, styled('time-picker__header'), { children: time.format(cols.join(':')) })), cols.includes('HH') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref: (instance) => {
|
|
82
|
+
ulHRef.current = instance;
|
|
83
|
+
return () => {
|
|
84
|
+
ulHRef.current = null;
|
|
85
|
+
};
|
|
86
|
+
}, children: (is12Hour ? H12 : H24).map((n) => {
|
|
82
87
|
var _b;
|
|
83
88
|
let hour = Number(n);
|
|
84
89
|
if (is12Hour) {
|
|
@@ -98,7 +103,12 @@ export const TimePickerPanel = forwardRef((props, ref) => {
|
|
|
98
103
|
updateView(newTime, 'hour');
|
|
99
104
|
onTimeChange(newTime);
|
|
100
105
|
} }), n));
|
|
101
|
-
}) }))), cols.includes('mm') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref:
|
|
106
|
+
}) }))), cols.includes('mm') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref: (instance) => {
|
|
107
|
+
ulMRef.current = instance;
|
|
108
|
+
return () => {
|
|
109
|
+
ulMRef.current = null;
|
|
110
|
+
};
|
|
111
|
+
}, children: M60.map((n) => {
|
|
102
112
|
var _b;
|
|
103
113
|
const minute = Number(n);
|
|
104
114
|
const { disabled, hidden } = (_b = config === null || config === void 0 ? void 0 : config('minute', minute)) !== null && _b !== void 0 ? _b : {};
|
|
@@ -110,7 +120,12 @@ export const TimePickerPanel = forwardRef((props, ref) => {
|
|
|
110
120
|
updateView(newTime, 'minute');
|
|
111
121
|
onTimeChange(newTime);
|
|
112
122
|
} }), n));
|
|
113
|
-
}) }))), cols.includes('ss') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref:
|
|
123
|
+
}) }))), cols.includes('ss') && (_jsx("ul", Object.assign({}, styled('time-picker__column'), { ref: (instance) => {
|
|
124
|
+
ulSRef.current = instance;
|
|
125
|
+
return () => {
|
|
126
|
+
ulSRef.current = null;
|
|
127
|
+
};
|
|
128
|
+
}, children: S60.map((n) => {
|
|
114
129
|
var _b;
|
|
115
130
|
const second = Number(n);
|
|
116
131
|
const { disabled, hidden } = (_b = config === null || config === void 0 ? void 0 : config('second', second)) !== null && _b !== void 0 ? _b : {};
|
|
@@ -135,4 +150,4 @@ export const TimePickerPanel = forwardRef((props, ref) => {
|
|
|
135
150
|
setA(A);
|
|
136
151
|
}
|
|
137
152
|
} }), A))) })))] })));
|
|
138
|
-
}
|
|
153
|
+
}
|
package/time-picker/types.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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 TimePickerRef {
|
|
7
7
|
updatePosition: () => void;
|
|
8
8
|
}
|
|
9
9
|
export interface TimePickerProps extends BaseProps<'time-picker' | 'time-picker-popup', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'placeholder'> {
|
|
10
|
+
ref?: React.Ref<TimePickerRef>;
|
|
10
11
|
formControl?: FormControlProvider;
|
|
11
12
|
model?: Date | [Date, Date] | null;
|
|
12
13
|
defaultModel?: Date | [Date, Date] | null;
|
|
@@ -24,8 +25,7 @@ export interface TimePickerProps extends BaseProps<'time-picker' | 'time-picker-
|
|
|
24
25
|
hidden?: boolean;
|
|
25
26
|
};
|
|
26
27
|
escClosable?: boolean;
|
|
27
|
-
|
|
28
|
-
inputRender?: [CloneHTMLElement?, CloneHTMLElement?];
|
|
28
|
+
inputProps?: [React.ComponentPropsWithRef<'input'>?, React.ComponentPropsWithRef<'input'>?];
|
|
29
29
|
onModelChange?: (date: any) => void;
|
|
30
30
|
onVisibleChange?: (visible: boolean) => void;
|
|
31
31
|
onClear?: () => void;
|
package/timeline/Timeline.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TimelineItem, TimelineProps } from './types';
|
|
3
|
-
export declare function Timeline<T extends TimelineItem>(props: TimelineProps<T>):
|
|
3
|
+
export declare function Timeline<T extends TimelineItem>(props: TimelineProps<T>): React.ReactElement | null;
|
package/toast/Toast.d.ts
CHANGED
package/toast/Toast.js
CHANGED
|
@@ -12,22 +12,24 @@ import { useId, useRef } from 'react';
|
|
|
12
12
|
import { CLASSES, TTANSITION_DURING } from './vars';
|
|
13
13
|
import { useComponentProps, useNamespace, useStyled, useTranslation } from '../hooks';
|
|
14
14
|
import { Icon } from '../icon';
|
|
15
|
+
import { LazyLoading } from '../internal/lazy-loading';
|
|
15
16
|
import { Portal } from '../internal/portal';
|
|
16
|
-
import {
|
|
17
|
+
import { CollapseTransition } from '../transition';
|
|
17
18
|
import { mergeCS } from '../utils';
|
|
18
19
|
export function Toast(props) {
|
|
19
|
-
const _a = useComponentProps('Toast', props), { children, styleOverrides, styleProvider, visible, type, placement = 'top', duration = 2, icon, closable = false, escClosable = true, skipFirstTransition = true, destroyAfterClose = true, onClose, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "type", "placement", "duration", "icon", "closable", "escClosable", "skipFirstTransition", "destroyAfterClose", "onClose", "afterVisibleChange"]);
|
|
20
|
+
const _a = useComponentProps('Toast', props), { children, styleOverrides, styleProvider, visible, type, placement = 'top', duration = 2, icon, closable = false, escClosable = true, skipFirstTransition = true, destroyAfterClose = false, lazyLoading = true, onClose, afterVisibleChange } = _a, restProps = __rest(_a, ["children", "styleOverrides", "styleProvider", "visible", "type", "placement", "duration", "icon", "closable", "escClosable", "skipFirstTransition", "destroyAfterClose", "lazyLoading", "onClose", "afterVisibleChange"]);
|
|
20
21
|
const namespace = useNamespace();
|
|
21
22
|
const styled = useStyled(CLASSES, { toast: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.toast }, styleOverrides);
|
|
22
23
|
const { t } = useTranslation();
|
|
23
24
|
const async = useAsync();
|
|
24
25
|
const toastRef = useRef(null);
|
|
25
|
-
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
27
|
+
const clearTid = useRef(() => { });
|
|
26
28
|
const uniqueId = useId();
|
|
27
29
|
const messageId = `${namespace}-toast-content-${uniqueId}`;
|
|
28
30
|
useMount(() => {
|
|
29
31
|
if (duration > 0) {
|
|
30
|
-
|
|
32
|
+
clearTid.current = async.setTimeout(() => {
|
|
31
33
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
32
34
|
}, duration * 1000);
|
|
33
35
|
}
|
|
@@ -47,77 +49,47 @@ export function Toast(props) {
|
|
|
47
49
|
root.appendChild(el);
|
|
48
50
|
}
|
|
49
51
|
return el;
|
|
50
|
-
}, children: _jsx(
|
|
52
|
+
}, children: _jsx(CollapseTransition, { height: 0, enter: visible, name: `${namespace}-toast`, duration: TTANSITION_DURING, skipFirstTransition: skipFirstTransition, onAfterEnter: () => {
|
|
51
53
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
52
|
-
},
|
|
54
|
+
}, onAfterLeave: () => {
|
|
53
55
|
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
54
|
-
}, children: (
|
|
56
|
+
}, children: (transitionRef, leaved) => {
|
|
55
57
|
var _a, _b;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
case 'leaved':
|
|
90
|
-
transitionStyle = { display: 'none' };
|
|
91
|
-
break;
|
|
92
|
-
default:
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
return (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('toast', {
|
|
96
|
-
[`toast--${type}`]: type,
|
|
97
|
-
}), {
|
|
98
|
-
className: restProps.className,
|
|
99
|
-
style: Object.assign(Object.assign({}, restProps.style), transitionStyle),
|
|
100
|
-
}), { ref: toastRef, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : -1, role: (_b = restProps.role) !== null && _b !== void 0 ? _b : 'alert', "aria-describedby": messageId, onMouseEnter: (e) => {
|
|
101
|
-
var _a, _b, _c;
|
|
102
|
-
(_a = restProps.onMouseEnter) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
103
|
-
(_c = (_b = dataRef.current).clearTid) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
104
|
-
}, onMouseLeave: (e) => {
|
|
105
|
-
var _a;
|
|
106
|
-
(_a = restProps.onMouseLeave) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
107
|
-
if (duration > 0) {
|
|
108
|
-
dataRef.current.clearTid = async.setTimeout(() => {
|
|
58
|
+
return (_jsx(LazyLoading, { hidden: leaved, disabled: !lazyLoading, children: leaved && destroyAfterClose ? null : (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('toast', {
|
|
59
|
+
[`toast--${type}`]: type,
|
|
60
|
+
}), {
|
|
61
|
+
className: restProps.className,
|
|
62
|
+
style: Object.assign(Object.assign(Object.assign({}, restProps.style), {
|
|
63
|
+
'--toast-transform': placement === 'top' ? 'translate(0, -70%)' : 'translate(0, 70%)',
|
|
64
|
+
}), (leaved ? { display: 'none' } : undefined)),
|
|
65
|
+
}), { ref: (instance) => {
|
|
66
|
+
toastRef.current = instance;
|
|
67
|
+
transitionRef(instance);
|
|
68
|
+
return () => {
|
|
69
|
+
toastRef.current = null;
|
|
70
|
+
transitionRef(null);
|
|
71
|
+
};
|
|
72
|
+
}, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : -1, role: (_b = restProps.role) !== null && _b !== void 0 ? _b : 'alert', "aria-describedby": messageId, onMouseEnter: (e) => {
|
|
73
|
+
var _a;
|
|
74
|
+
(_a = restProps.onMouseEnter) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
75
|
+
clearTid.current();
|
|
76
|
+
}, onMouseLeave: (e) => {
|
|
77
|
+
var _a;
|
|
78
|
+
(_a = restProps.onMouseLeave) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
79
|
+
if (duration > 0) {
|
|
80
|
+
clearTid.current = async.setTimeout(() => {
|
|
81
|
+
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
82
|
+
}, duration * 1000);
|
|
83
|
+
}
|
|
84
|
+
}, onKeyDown: (e) => {
|
|
85
|
+
var _a;
|
|
86
|
+
(_a = restProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
87
|
+
if (visible && escClosable && e.code === 'Escape') {
|
|
88
|
+
e.stopPropagation();
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
clearTid.current();
|
|
109
91
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, onKeyDown: (e) => {
|
|
113
|
-
var _a, _b, _c;
|
|
114
|
-
(_a = restProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
115
|
-
if (visible && escClosable && e.code === 'Escape') {
|
|
116
|
-
e.stopPropagation();
|
|
117
|
-
e.preventDefault();
|
|
118
|
-
(_c = (_b = dataRef.current).clearTid) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
119
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
120
|
-
}
|
|
121
|
-
}, children: [icon !== false && (!isUndefined(type) || checkNodeExist(icon)) && (_jsx("div", Object.assign({}, styled('toast__icon'), { children: checkNodeExist(icon) ? (icon) : (_jsx(Icon, { children: type === 'success' ? (_jsx(CheckCircleOutlined, {})) : type === 'warning' ? (_jsx(WarningAmberOutlined, {})) : type === 'error' ? (_jsx(HighlightOffOutlined, {})) : (_jsx(InfoOutlined, {})) })) }))), _jsx("div", Object.assign({}, styled('toast__message'), { id: messageId, children: children })), closable && (_jsx("button", Object.assign({}, styled('toast__close'), { "aria-label": t('Close'), onClick: onClose, children: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }) })))] })));
|
|
92
|
+
}
|
|
93
|
+
}, children: [icon !== false && (!isUndefined(type) || checkNodeExist(icon)) && (_jsx("div", Object.assign({}, styled('toast__icon'), { children: checkNodeExist(icon) ? (icon) : (_jsx(Icon, { children: type === 'success' ? (_jsx(CheckCircleOutlined, {})) : type === 'warning' ? (_jsx(WarningAmberOutlined, {})) : type === 'error' ? (_jsx(HighlightOffOutlined, {})) : (_jsx(InfoOutlined, {})) })) }))), _jsx("div", Object.assign({}, styled('toast__message'), { id: messageId, children: children })), closable && (_jsx("button", Object.assign({}, styled('toast__close'), { "aria-label": t('Close'), onClick: onClose, children: _jsx(Icon, { children: _jsx(CloseOutlined, {}) }) })))] }))) }));
|
|
122
94
|
} }) }));
|
|
123
95
|
}
|
package/toast/types.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface ToastProps extends BaseProps<'toast', typeof CLASSES>, React.HT
|
|
|
12
12
|
escClosable?: boolean;
|
|
13
13
|
skipFirstTransition?: boolean;
|
|
14
14
|
destroyAfterClose?: boolean;
|
|
15
|
+
lazyLoading?: boolean;
|
|
15
16
|
onClose?: () => void;
|
|
16
17
|
afterVisibleChange?: (visible: boolean) => void;
|
|
17
18
|
}
|
package/tooltip/Tooltip.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { TooltipProps
|
|
3
|
-
export declare
|
|
2
|
+
import type { TooltipProps } from './types';
|
|
3
|
+
export declare function Tooltip(props: TooltipProps): React.ReactElement | null;
|
package/tooltip/Tooltip.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEventCallback, useRefExtra } from '@laser-ui/hooks';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { isUndefined } from 'lodash';
|
|
5
|
+
import { useId, useImperativeHandle, useRef } from 'react';
|
|
6
6
|
import { CLASSES, TTANSITION_DURING } from './vars';
|
|
7
|
-
import { useComponentProps, useControlled,
|
|
7
|
+
import { useComponentProps, useControlled, useMaxIndex, useNamespace, useStyled } from '../hooks';
|
|
8
|
+
import { LazyLoading } from '../internal/lazy-loading';
|
|
8
9
|
import { Popup } from '../internal/popup';
|
|
9
10
|
import { Portal } from '../internal/portal';
|
|
10
|
-
import { Transition } from '../
|
|
11
|
+
import { Transition } from '../transition';
|
|
11
12
|
import { getPopupPosition, mergeCS } from '../utils';
|
|
12
|
-
export
|
|
13
|
+
export function Tooltip(props) {
|
|
13
14
|
var _a;
|
|
14
|
-
const _b = useComponentProps('Tooltip', props), { children, styleOverrides, styleProvider, title, visible: visibleProp, defaultVisible, trigger = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, skipFirstTransition = true, destroyAfterClose = true, zIndex: zIndexProp, onVisibleChange, afterVisibleChange } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider", "title", "visible", "defaultVisible", "trigger", "placement", "placementFixed", "arrow", "escClosable", "gap", "inWindow", "mouseEnterDelay", "mouseLeaveDelay", "skipFirstTransition", "destroyAfterClose", "zIndex", "onVisibleChange", "afterVisibleChange"]);
|
|
15
|
+
const _b = useComponentProps('Tooltip', props), { ref, children, styleOverrides, styleProvider, title, visible: visibleProp, defaultVisible, trigger = 'hover', placement: placementProp = 'top', placementFixed = false, arrow = true, escClosable = true, gap = 10, inWindow = false, mouseEnterDelay = 150, mouseLeaveDelay = 200, skipFirstTransition = true, destroyAfterClose = false, lazyLoading = true, zIndex: zIndexProp, onVisibleChange, afterVisibleChange } = _b, restProps = __rest(_b, ["ref", "children", "styleOverrides", "styleProvider", "title", "visible", "defaultVisible", "trigger", "placement", "placementFixed", "arrow", "escClosable", "gap", "inWindow", "mouseEnterDelay", "mouseLeaveDelay", "skipFirstTransition", "destroyAfterClose", "lazyLoading", "zIndex", "onVisibleChange", "afterVisibleChange"]);
|
|
15
16
|
const namespace = useNamespace();
|
|
16
17
|
const styled = useStyled(CLASSES, { tooltip: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.tooltip }, styleOverrides);
|
|
17
|
-
const sheet = useJSS();
|
|
18
18
|
const uniqueId = useId();
|
|
19
19
|
const id = (_a = restProps.id) !== null && _a !== void 0 ? _a : `${namespace}-tooltip-${uniqueId}`;
|
|
20
20
|
const triggerRef = useRefExtra(() => document.querySelector(`[aria-describedby="${id}"]`));
|
|
@@ -22,7 +22,6 @@ export const Tooltip = forwardRef((props, ref) => {
|
|
|
22
22
|
const [visible, changeVisible] = useControlled(defaultVisible !== null && defaultVisible !== void 0 ? defaultVisible : false, visibleProp, onVisibleChange);
|
|
23
23
|
const maxZIndex = useMaxIndex(visible);
|
|
24
24
|
const zIndex = !isUndefined(zIndexProp) ? zIndexProp : `calc(var(--${namespace}-zindex-fixed) + ${maxZIndex})`;
|
|
25
|
-
const transformOrigin = useRef();
|
|
26
25
|
const placement = useRef(placementProp);
|
|
27
26
|
const updatePosition = useEventCallback(() => {
|
|
28
27
|
if (visible && triggerRef.current && tooltipRef.current) {
|
|
@@ -33,18 +32,12 @@ export const Tooltip = forwardRef((props, ref) => {
|
|
|
33
32
|
gap,
|
|
34
33
|
inWindow,
|
|
35
34
|
});
|
|
36
|
-
|
|
35
|
+
tooltipRef.current.style.setProperty(`--popup-transform-origin`, position.transformOrigin);
|
|
36
|
+
tooltipRef.current.style.top = position.top + 'px';
|
|
37
|
+
tooltipRef.current.style.left = position.left + 'px';
|
|
37
38
|
tooltipRef.current.classList.toggle(`${namespace}-tooltip--${placement.current}`, false);
|
|
38
39
|
placement.current = position.placement;
|
|
39
40
|
tooltipRef.current.classList.toggle(`${namespace}-tooltip--${placement.current}`, true);
|
|
40
|
-
if (sheet.classes.position) {
|
|
41
|
-
tooltipRef.current.classList.toggle(sheet.classes.position, false);
|
|
42
|
-
}
|
|
43
|
-
sheet.replaceRule('position', {
|
|
44
|
-
top: position.top,
|
|
45
|
-
left: position.left,
|
|
46
|
-
});
|
|
47
|
-
tooltipRef.current.classList.toggle(sheet.classes.position, true);
|
|
48
41
|
}
|
|
49
42
|
});
|
|
50
43
|
useImperativeHandle(ref, () => ({
|
|
@@ -54,61 +47,44 @@ export const Tooltip = forwardRef((props, ref) => {
|
|
|
54
47
|
fn: updatePosition,
|
|
55
48
|
triggerRef,
|
|
56
49
|
popupRef: tooltipRef,
|
|
57
|
-
}, onVisibleChange: changeVisible, children: (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
}, onVisibleChange: changeVisible, children: (popupProps) => (_jsxs(_Fragment, { children: [children(Object.assign(Object.assign({ 'aria-describedby': id }, popupProps.trigger), { onKeyDown: (e) => {
|
|
51
|
+
if (visible) {
|
|
52
|
+
if (escClosable && e.code === 'Escape') {
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
e.preventDefault();
|
|
55
|
+
changeVisible(false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} })), _jsx(Portal, { selector: () => {
|
|
59
|
+
let el = document.getElementById(`${namespace}-tooltip-root`);
|
|
60
|
+
if (!el) {
|
|
61
|
+
el = document.createElement('div');
|
|
62
|
+
el.id = `${namespace}-tooltip-root`;
|
|
63
|
+
document.body.appendChild(el);
|
|
64
|
+
}
|
|
65
|
+
return el;
|
|
66
|
+
}, children: _jsx(Transition, { enter: visible, name: `${namespace}-popup`, duration: TTANSITION_DURING, skipFirstTransition: skipFirstTransition, onSkipEnter: updatePosition, onBeforeEnter: (el) => {
|
|
67
|
+
updatePosition();
|
|
68
|
+
if (el) {
|
|
69
|
+
el.style.setProperty(`--popup-duration`, TTANSITION_DURING.enter + 'ms');
|
|
70
|
+
}
|
|
71
|
+
}, onAfterEnter: () => {
|
|
72
|
+
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
73
|
+
}, onBeforeLeave: (el) => {
|
|
74
|
+
if (el) {
|
|
75
|
+
el.style.setProperty(`--popup-duration`, TTANSITION_DURING.leave + 'ms');
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
transformOrigin: transformOrigin.current,
|
|
92
|
-
};
|
|
93
|
-
break;
|
|
94
|
-
case 'leaving':
|
|
95
|
-
transitionStyle = {
|
|
96
|
-
transform: 'scale(0.3)',
|
|
97
|
-
opacity: 0,
|
|
98
|
-
transition: ['transform', 'opacity'].map((attr) => `${attr} ${TTANSITION_DURING.leave}ms ease-in`).join(', '),
|
|
99
|
-
transformOrigin: transformOrigin.current,
|
|
100
|
-
};
|
|
101
|
-
break;
|
|
102
|
-
case 'leaved':
|
|
103
|
-
transitionStyle = { display: 'none' };
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
return renderPopup(_jsxs("div", Object.assign({}, restProps, mergeCS(styled('tooltip'), {
|
|
109
|
-
className: restProps.className,
|
|
110
|
-
style: Object.assign(Object.assign(Object.assign({}, restProps.style), { zIndex }), transitionStyle),
|
|
111
|
-
}), { ref: tooltipRef, id: id, role: "tooltip", children: [arrow && _jsx("div", Object.assign({}, styled('tooltip__arrow'))), title] })));
|
|
112
|
-
} }) })] }));
|
|
113
|
-
} }));
|
|
114
|
-
});
|
|
77
|
+
}, onAfterLeave: () => {
|
|
78
|
+
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
79
|
+
}, children: (transitionRef, leaved) => (_jsx(LazyLoading, { hidden: leaved, disabled: !lazyLoading, children: leaved && destroyAfterClose ? null : (_jsxs("div", Object.assign({}, restProps, mergeCS(styled('tooltip'), {
|
|
80
|
+
className: restProps.className,
|
|
81
|
+
style: Object.assign(Object.assign(Object.assign(Object.assign({}, restProps.style), { '--popup-scale': 0.3 }), { zIndex }), (leaved ? { display: 'none' } : undefined)),
|
|
82
|
+
}), { ref: (instance) => {
|
|
83
|
+
tooltipRef.current = instance;
|
|
84
|
+
transitionRef(instance);
|
|
85
|
+
return () => {
|
|
86
|
+
tooltipRef.current = null;
|
|
87
|
+
transitionRef(null);
|
|
88
|
+
};
|
|
89
|
+
}, id: id, role: "tooltip" }, popupProps.popup, { children: [arrow && _jsx("div", Object.assign({}, styled('tooltip__arrow'))), title] }))) })) }) })] })) }));
|
|
90
|
+
}
|
package/tooltip/types.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CLASSES } from './vars';
|
|
3
|
-
import type { BaseProps,
|
|
3
|
+
import type { BaseProps, PopupPlacement } from '../types';
|
|
4
4
|
export {};
|
|
5
5
|
export interface TooltipRef {
|
|
6
6
|
updatePosition: () => void;
|
|
7
7
|
}
|
|
8
8
|
export interface TooltipProps extends BaseProps<'tooltip', typeof CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children' | 'title'> {
|
|
9
|
-
|
|
9
|
+
ref?: React.Ref<TooltipRef>;
|
|
10
|
+
children: (props: {
|
|
11
|
+
'aria-describedby': string;
|
|
12
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
13
|
+
onMouseEnter: React.MouseEventHandler<HTMLElement>;
|
|
14
|
+
onMouseLeave: React.MouseEventHandler<HTMLElement>;
|
|
15
|
+
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
|
|
16
|
+
}) => React.ReactNode;
|
|
10
17
|
title: React.ReactNode;
|
|
11
18
|
visible?: boolean;
|
|
12
19
|
defaultVisible?: boolean;
|
|
@@ -21,6 +28,7 @@ export interface TooltipProps extends BaseProps<'tooltip', typeof CLASSES>, Omit
|
|
|
21
28
|
mouseLeaveDelay?: number;
|
|
22
29
|
skipFirstTransition?: boolean;
|
|
23
30
|
destroyAfterClose?: boolean;
|
|
31
|
+
lazyLoading?: boolean;
|
|
24
32
|
zIndex?: number | string;
|
|
25
33
|
onVisibleChange?: (visible: boolean) => void;
|
|
26
34
|
afterVisibleChange?: (visible: boolean) => void;
|
package/transfer/Transfer.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { TransferItem, TransferProps } from './types';
|
|
3
|
-
export declare function Transfer<V extends React.Key, T extends TransferItem<V>>(props: TransferProps<V, T>):
|
|
3
|
+
export declare function Transfer<V extends React.Key, T extends TransferItem<V>>(props: TransferProps<V, T>): React.ReactElement | null;
|
|
@@ -18,4 +18,4 @@ export interface TransferPanelProps<V extends React.Key, T extends TransferItem<
|
|
|
18
18
|
onSearch: (value: string) => void;
|
|
19
19
|
onScrollBottom: () => void;
|
|
20
20
|
}
|
|
21
|
-
export declare function TransferPanel<V extends React.Key, T extends TransferItem<V>>(props: TransferPanelProps<V, T>):
|
|
21
|
+
export declare function TransferPanel<V extends React.Key, T extends TransferItem<V>>(props: TransferPanelProps<V, T>): React.ReactElement | null;
|
|
@@ -5,11 +5,11 @@ import SearchOutlined from '@material-design-icons/svg/outlined/search.svg?react
|
|
|
5
5
|
import { isNumber } from 'lodash';
|
|
6
6
|
import { useCallback, useId, useMemo, useRef } from 'react';
|
|
7
7
|
import { Checkbox } from '../../checkbox';
|
|
8
|
+
import { CircularProgress } from '../../circular-progress';
|
|
8
9
|
import { Empty } from '../../empty';
|
|
9
10
|
import { useTranslation } from '../../hooks';
|
|
10
11
|
import { Icon } from '../../icon';
|
|
11
12
|
import { Input } from '../../input';
|
|
12
|
-
import { CircularProgress } from '../../internal/circular-progress';
|
|
13
13
|
import { VirtualScroll } from '../../virtual-scroll';
|
|
14
14
|
import { IS_SELECTED, NO_MATCH } from '../vars';
|
|
15
15
|
export function TransferPanel(props) {
|
|
@@ -27,7 +27,12 @@ export function TransferPanel(props) {
|
|
|
27
27
|
}), [canSelectedItem, list, virtual]);
|
|
28
28
|
return (_jsxs("div", Object.assign({}, styled('transfer__panel'), { children: [_jsxs("div", Object.assign({}, styled('transfer__header'), { children: [_jsxs(Checkbox, { model: state === true, indeterminate: state === 'mixed', disabled: list.length === 0, onModelChange: (checked) => {
|
|
29
29
|
onAllSelectedChange(checked);
|
|
30
|
-
}, children: [selectedCount, "/", list.length] }), checkNodeExist(title) && _jsx("div", Object.assign({}, styled('transfer__header-title'), { children: title }))] })), searchable && (_jsx("div", Object.assign({}, styled('transfer__search'), { children: _jsx(Input, { style: { display: 'flex' }, placeholder: t('Search'), prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), clearable: true, onModelChange: onSearch }) }))), _jsxs("div", Object.assign({}, styled('transfer__list-container'), { children: [loading && (_jsx("div", Object.assign({}, styled('transfer__loading'), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), _jsx(VirtualScroll, Object.assign({}, vsProps, { ref:
|
|
30
|
+
}, children: [selectedCount, "/", list.length] }), checkNodeExist(title) && _jsx("div", Object.assign({}, styled('transfer__header-title'), { children: title }))] })), searchable && (_jsx("div", Object.assign({}, styled('transfer__search'), { children: _jsx(Input, { style: { display: 'flex' }, placeholder: t('Search'), prefix: _jsx(Icon, { children: _jsx(SearchOutlined, {}) }), clearable: true, onModelChange: onSearch }) }))), _jsxs("div", Object.assign({}, styled('transfer__list-container'), { children: [loading && (_jsx("div", Object.assign({}, styled('transfer__loading'), { children: _jsx(Icon, { children: _jsx(CircularProgress, {}) }) }))), _jsx(VirtualScroll, Object.assign({}, vsProps, { ref: (instance) => {
|
|
31
|
+
vsRef.current = instance;
|
|
32
|
+
return () => {
|
|
33
|
+
vsRef.current = null;
|
|
34
|
+
};
|
|
35
|
+
}, enable: virtual !== false, listSize: 192, listPadding: 0, itemRender: (item, index, props) => (_createElement("li", Object.assign({}, styled('transfer__option', {
|
|
31
36
|
'transfer__option.is-disabled': item.disabled,
|
|
32
37
|
}), props, { key: item.value, id: getItemId(item.value), title: item.label, onClick: () => {
|
|
33
38
|
if (!item.disabled) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { CollapseTransitionProps } from './types';
|
|
3
|
-
export declare function CollapseTransition(props: CollapseTransitionProps):
|
|
3
|
+
export declare function CollapseTransition(props: CollapseTransitionProps): React.ReactElement | null;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { isNumber } from 'lodash';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
import { Transition } from './Transition';
|
|
6
|
+
import { useNamespace } from '../hooks';
|
|
7
|
+
export function CollapseTransition(props) {
|
|
8
|
+
const { children, name, onBeforeEnter, onEnter, onEnterCancelled, onBeforeLeave, onLeave, onLeaveCancelled, width = 0, height } = props, restProps = __rest(props, ["children", "name", "onBeforeEnter", "onEnter", "onEnterCancelled", "onBeforeLeave", "onLeave", "onLeaveCancelled", "width", "height"]);
|
|
9
|
+
const namespace = useNamespace();
|
|
10
|
+
const el = useRef(null);
|
|
11
|
+
const cancelled = useRef(false);
|
|
12
|
+
const offsetWidth = useRef(0);
|
|
13
|
+
const offsetHeight = useRef(0);
|
|
14
|
+
const saveSize = (el) => {
|
|
15
|
+
if (el) {
|
|
16
|
+
offsetWidth.current = el.offsetWidth;
|
|
17
|
+
offsetHeight.current = el.offsetHeight;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const setSize = (el, size) => {
|
|
21
|
+
if (el) {
|
|
22
|
+
if (isNumber(height)) {
|
|
23
|
+
el.style.setProperty(`--${namespace}-collapse-vertical`, size.height + 'px');
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
el.style.setProperty(`--${namespace}-collapse-horizontal`, size.width + 'px');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return (_jsx(Transition, Object.assign({}, restProps, { name: name !== null && name !== void 0 ? name : (isNumber(height) ? `${namespace}-collapse-vertical` : `${namespace}-collapse-horizontal`), onBeforeEnter: (el) => {
|
|
31
|
+
onBeforeEnter === null || onBeforeEnter === void 0 ? void 0 : onBeforeEnter(el);
|
|
32
|
+
if (cancelled.current) {
|
|
33
|
+
setSize(el, { width: offsetWidth.current, height: offsetHeight.current });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
setSize(el, { width, height: height !== null && height !== void 0 ? height : 0 });
|
|
37
|
+
}
|
|
38
|
+
cancelled.current = false;
|
|
39
|
+
saveSize(el);
|
|
40
|
+
}, onEnter: (el) => {
|
|
41
|
+
onEnter === null || onEnter === void 0 ? void 0 : onEnter(el);
|
|
42
|
+
setSize(el, { width: offsetWidth.current, height: offsetHeight.current });
|
|
43
|
+
}, onEnterCancelled: (el) => {
|
|
44
|
+
onEnterCancelled === null || onEnterCancelled === void 0 ? void 0 : onEnterCancelled(el);
|
|
45
|
+
cancelled.current = true;
|
|
46
|
+
saveSize(el);
|
|
47
|
+
}, onBeforeLeave: (el) => {
|
|
48
|
+
onBeforeLeave === null || onBeforeLeave === void 0 ? void 0 : onBeforeLeave(el);
|
|
49
|
+
if (!cancelled.current) {
|
|
50
|
+
saveSize(el);
|
|
51
|
+
}
|
|
52
|
+
setSize(el, { width: offsetWidth.current, height: offsetHeight.current });
|
|
53
|
+
cancelled.current = false;
|
|
54
|
+
}, onLeave: (el) => {
|
|
55
|
+
onLeave === null || onLeave === void 0 ? void 0 : onLeave(el);
|
|
56
|
+
setSize(el, { width, height: height !== null && height !== void 0 ? height : 0 });
|
|
57
|
+
}, onLeaveCancelled: (el) => {
|
|
58
|
+
onLeaveCancelled === null || onLeaveCancelled === void 0 ? void 0 : onLeaveCancelled(el);
|
|
59
|
+
cancelled.current = true;
|
|
60
|
+
saveSize(el);
|
|
61
|
+
}, children: (ref, leaved) => children((instance) => {
|
|
62
|
+
el.current = instance;
|
|
63
|
+
ref(instance);
|
|
64
|
+
}, leaved) })));
|
|
65
|
+
}
|