@laser-ui/components 1.6.0 → 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 +16 -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 +95 -110
- 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/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
|
@@ -1,62 +1,67 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useImmer } from '@laser-ui/hooks';
|
|
4
3
|
import InsertDriveFileTwoTone from '@material-design-icons/svg/two-tone/insert_drive_file.svg?react';
|
|
5
|
-
import { isNumber, isUndefined } from 'lodash';
|
|
6
|
-
import {
|
|
4
|
+
import { has, isNumber, isUndefined } from 'lodash';
|
|
5
|
+
import { Fragment, use, useRef } from 'react';
|
|
7
6
|
import { UploadAction } from './UploadAction';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { useNextTick } from './hooks';
|
|
8
|
+
import { PICTURE_LIST_CLASSES, UploadActionContext, UploadContext } from './vars';
|
|
9
|
+
import { CircularProgress } from '../circular-progress';
|
|
10
|
+
import { useComponentProps, useStyled } from '../hooks';
|
|
10
11
|
import { Icon } from '../icon';
|
|
11
|
-
import { CircularProgress } from '../internal/circular-progress';
|
|
12
|
-
import { CollapseTransition } from '../internal/transition';
|
|
13
12
|
import { Progress } from '../progress';
|
|
13
|
+
import { CollapseTransition } from '../transition';
|
|
14
14
|
import { mergeCS } from '../utils';
|
|
15
15
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
16
16
|
export function UploadPictureList(props) {
|
|
17
|
-
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const _c = useComponentProps('UploadPictureList', props), { styleOverrides, styleProvider, actions, defaultActions } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "actions", "defaultActions"]);
|
|
18
19
|
const styled = useStyled(PICTURE_LIST_CLASSES, { 'upload-picture-list': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-picture-list'] }, styleOverrides);
|
|
19
|
-
const { files, onRemove } =
|
|
20
|
+
const { files: currentFiles, onRemove } = use(UploadContext);
|
|
21
|
+
const files = useRef(currentFiles);
|
|
22
|
+
{
|
|
23
|
+
const newFiles = currentFiles.map((file) => Object.assign({}, file));
|
|
24
|
+
let index = -1;
|
|
25
|
+
for (const file of files.current) {
|
|
26
|
+
index += 1;
|
|
27
|
+
if (file.__removing) {
|
|
28
|
+
if (((_a = files.current[index - 1]) === null || _a === void 0 ? void 0 : _a.uid) === ((_b = newFiles[index - 1]) === null || _b === void 0 ? void 0 : _b.uid)) {
|
|
29
|
+
newFiles.splice(index, 0, file);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
files.current = newFiles;
|
|
34
|
+
}
|
|
20
35
|
const nextTick = useNextTick();
|
|
21
|
-
const [removeUIDs, setRemoveUIDs] = useImmer([]);
|
|
22
36
|
return (_jsx("ul", Object.assign({}, restProps, mergeCS(styled('upload-picture-list'), {
|
|
23
37
|
className: restProps.className,
|
|
24
38
|
style: restProps.style,
|
|
25
|
-
}), { children: files.map((file, index) => (_jsx(CollapseTransition, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, children: file.name })), _jsx("div", Object.assign({}, styled('upload-picture-list__actions'), { children: Children.map(actions ? actions(file, index) : [_jsx(UploadAction, { preset: "remove" })], (action) => cloneElement(action, {
|
|
54
|
-
_file: file,
|
|
55
|
-
_defaultActions: defaultActions,
|
|
56
|
-
_onRemove: () => {
|
|
57
|
-
setRemoveUIDs((draft) => {
|
|
58
|
-
draft.push(file.uid);
|
|
59
|
-
});
|
|
60
|
-
},
|
|
61
|
-
})) })), _jsx("div", Object.assign({}, styled('upload-picture-list__progress-wrapper'), { children: isNumber(file.percent) && _jsx(Progress, { percent: file.percent, label: false, lineWidth: 2 }) }))] }))) }, file.uid))) })));
|
|
39
|
+
}), { children: _jsx("div", Object.assign({}, styled('upload-picture-list__row'), { children: files.current.map((file, index) => (_jsx(CollapseTransition, { height: 0, enter: !file.__removing, duration: TTANSITION_DURING_BASE, skipFirstTransition: nextTick.current ? false : true, onAfterLeave: () => {
|
|
40
|
+
const index = files.current.findIndex((f) => f.uid === file.uid);
|
|
41
|
+
if (index !== -1) {
|
|
42
|
+
files.current.splice(index, 1);
|
|
43
|
+
}
|
|
44
|
+
}, children: (transitionRef, leaved) => leaved ? null : (_jsx("div", { ref: (instance) => {
|
|
45
|
+
transitionRef(instance);
|
|
46
|
+
return () => {
|
|
47
|
+
transitionRef(null);
|
|
48
|
+
};
|
|
49
|
+
}, children: _jsxs("li", Object.assign({}, styled('upload-picture-list__item', { [`upload-picture-list__item--${file.state}`]: file.state }), { children: [_jsx("div", Object.assign({}, styled('upload-picture-list__thumbnail'), { children: file.state === 'progress' ? (_jsx(Icon, { size: 28, children: _jsx(CircularProgress, {}) })) : file.thumbUrl ? (_jsx("img", Object.assign({}, styled('upload-picture-list__thumbnail-img'), { src: file.thumbUrl, alt: file.name }))) : (_jsx(Icon, { size: 28, theme: file.state === 'error' ? 'danger' : 'primary', children: _jsx(InsertDriveFileTwoTone, {}) })) })), _jsx("a", Object.assign({}, styled('upload-picture-list__link', {
|
|
50
|
+
'upload-picture-list__link.is-active': file.state === 'load' && !isUndefined(file.url),
|
|
51
|
+
}), { href: file.url, target: "_blank", rel: "noreferrer", title: file.name, onClick: (e) => {
|
|
52
|
+
if (defaultActions && defaultActions.preview) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
defaultActions.preview(file);
|
|
55
|
+
}
|
|
56
|
+
}, children: file.name })), _jsx("div", Object.assign({}, styled('upload-picture-list__actions'), { children: _jsx(UploadActionContext, { value: {
|
|
57
|
+
file,
|
|
58
|
+
defaultActions,
|
|
59
|
+
onRemove: () => {
|
|
60
|
+
file.__removing = true;
|
|
61
|
+
onRemove(file);
|
|
62
|
+
},
|
|
63
|
+
}, children: (actions ? actions(file, index) : [_jsx(UploadAction, { preset: "remove" })]).map((node, index) => {
|
|
64
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
65
|
+
return _jsx(Fragment, { children: action }, id);
|
|
66
|
+
}) }) })), _jsx("div", Object.assign({}, styled('upload-picture-list__progress-wrapper'), { children: isNumber(file.percent) && _jsx(Progress, { percent: file.percent, label: false, lineWidth: 2 }) }))] })) })) }, file.uid))) })) })));
|
|
62
67
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { UploadPreviewActionProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function UploadPreviewAction(props: UploadPreviewActionProps): React.ReactElement | null;
|
|
@@ -2,31 +2,32 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import VisibilityOutlinedIcon from '@material-design-icons/svg/outlined/visibility.svg?react';
|
|
4
4
|
import { isUndefined } from 'lodash';
|
|
5
|
-
import {
|
|
6
|
-
import { ACTION_CLASSES } from './vars';
|
|
5
|
+
import { use } from 'react';
|
|
6
|
+
import { ACTION_CLASSES, UploadActionContext } from './vars';
|
|
7
7
|
import { useComponentProps, useStyled, useTranslation } from '../hooks';
|
|
8
8
|
import { Icon } from '../icon';
|
|
9
9
|
import { mergeCS } from '../utils';
|
|
10
|
-
export
|
|
10
|
+
export function UploadPreviewAction(props) {
|
|
11
11
|
var _a, _b;
|
|
12
|
-
const _c = useComponentProps('UploadPreviewAction', props), { styleOverrides, styleProvider, children, disabled = false,
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
-
_onRemove } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "children", "disabled", "_file", "_defaultActions", "_light", "_onRemove"]);
|
|
12
|
+
const _c = useComponentProps('UploadPreviewAction', props), { ref, styleOverrides, styleProvider, children, disabled = false } = _c, restProps = __rest(_c, ["ref", "styleOverrides", "styleProvider", "children", "disabled"]);
|
|
15
13
|
const styled = useStyled(ACTION_CLASSES, { 'upload-action': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-action'] }, styleOverrides);
|
|
16
14
|
const { t } = useTranslation();
|
|
15
|
+
const uploadActionContext = use(UploadActionContext);
|
|
17
16
|
return (_jsx("a", Object.assign({}, restProps, mergeCS(styled('upload-action', 'upload-action--preview', {
|
|
18
|
-
'upload-action.is-disabled': disabled || isUndefined(
|
|
19
|
-
'upload-action--light':
|
|
17
|
+
'upload-action.is-disabled': disabled || isUndefined(uploadActionContext === null || uploadActionContext === void 0 ? void 0 : uploadActionContext.file.url),
|
|
18
|
+
'upload-action--light': uploadActionContext === null || uploadActionContext === void 0 ? void 0 : uploadActionContext.light,
|
|
20
19
|
}), {
|
|
21
20
|
className: restProps.className,
|
|
22
21
|
style: restProps.style,
|
|
23
|
-
}), { ref: ref, href:
|
|
24
|
-
var _a;
|
|
22
|
+
}), { ref: ref, href: uploadActionContext === null || uploadActionContext === void 0 ? void 0 : uploadActionContext.file.url, target: (_a = restProps['target']) !== null && _a !== void 0 ? _a : '_blank', title: (_b = restProps.title) !== null && _b !== void 0 ? _b : t('Upload', 'Preview file'), onClick: (e) => {
|
|
23
|
+
var _a, _b;
|
|
25
24
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
26
25
|
e.stopPropagation();
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
if (uploadActionContext) {
|
|
27
|
+
if ((_b = uploadActionContext.defaultActions) === null || _b === void 0 ? void 0 : _b.preview) {
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
uploadActionContext.defaultActions.preview(uploadActionContext.file);
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
}, children: children !== null && children !== void 0 ? children : (_jsx(Icon, { children: _jsx(VisibilityOutlinedIcon, {}) })) })));
|
|
32
|
-
}
|
|
33
|
+
}
|
package/upload/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ACTION_CLASSES, BUTTON_CLASSES, CLASSES, LIST_CLASSES, PICTURE_CLASSES, PICTURE_LIST_CLASSES } from './vars';
|
|
3
3
|
import type { FormControlProvider } from '../form/types';
|
|
4
|
-
import type { BaseProps
|
|
4
|
+
import type { BaseProps } from '../types';
|
|
5
5
|
export {};
|
|
6
6
|
export type UploadFileState = 'load' | 'error' | 'progress' | null;
|
|
7
7
|
export interface UploadFile {
|
|
@@ -15,7 +15,13 @@ export interface UploadFile {
|
|
|
15
15
|
response?: any;
|
|
16
16
|
}
|
|
17
17
|
export interface UploadProps extends BaseProps<'upload' | 'upload-list', typeof CLASSES>, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'list'> {
|
|
18
|
-
|
|
18
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
19
|
+
children: (props: {
|
|
20
|
+
onClick: React.MouseEventHandler<HTMLElement>;
|
|
21
|
+
onDragEnter?: React.DragEventHandler<HTMLElement>;
|
|
22
|
+
onDragOver?: React.DragEventHandler<HTMLElement>;
|
|
23
|
+
onDrop?: React.DragEventHandler<HTMLElement>;
|
|
24
|
+
}) => React.ReactNode;
|
|
19
25
|
formControl?: FormControlProvider;
|
|
20
26
|
model?: UploadFile[];
|
|
21
27
|
defaultModel?: UploadFile[];
|
|
@@ -40,8 +46,12 @@ export interface UploadProps extends BaseProps<'upload' | 'upload-list', typeof
|
|
|
40
46
|
onRemove?: (file: UploadFile) => void;
|
|
41
47
|
}
|
|
42
48
|
export interface UploadButtonProps extends BaseProps<'upload-button', typeof BUTTON_CLASSES>, Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
49
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
43
50
|
file?: UploadFile;
|
|
44
|
-
actions?: React.ReactNode
|
|
51
|
+
actions?: (React.ReactNode | {
|
|
52
|
+
id: React.Key;
|
|
53
|
+
action: React.ReactNode;
|
|
54
|
+
})[];
|
|
45
55
|
defaultActions?: {
|
|
46
56
|
preview?: (file: UploadFile) => void;
|
|
47
57
|
download?: (file: UploadFile) => void;
|
|
@@ -49,28 +59,39 @@ export interface UploadButtonProps extends BaseProps<'upload-button', typeof BUT
|
|
|
49
59
|
onRemove?: () => void;
|
|
50
60
|
}
|
|
51
61
|
export interface UploadActionProps extends BaseProps<'upload-action', typeof ACTION_CLASSES>, React.HTMLAttributes<HTMLDivElement> {
|
|
62
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
52
63
|
preset?: 'download' | 'remove';
|
|
53
64
|
disabled?: boolean;
|
|
54
65
|
}
|
|
55
66
|
export interface UploadPreviewActionProps extends BaseProps<'upload-action', typeof ACTION_CLASSES>, React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
67
|
+
ref?: React.Ref<HTMLAnchorElement>;
|
|
56
68
|
disabled?: boolean;
|
|
57
69
|
}
|
|
58
70
|
export interface UploadListProps extends BaseProps<'upload-list', typeof LIST_CLASSES>, Omit<React.HTMLAttributes<HTMLUListElement>, 'children'> {
|
|
59
|
-
actions?: (file: UploadFile, index: number) => React.ReactNode
|
|
71
|
+
actions?: (file: UploadFile, index: number) => (React.ReactNode | {
|
|
72
|
+
id: React.Key;
|
|
73
|
+
action: React.ReactNode;
|
|
74
|
+
})[];
|
|
60
75
|
defaultActions?: {
|
|
61
76
|
preview?: (file: UploadFile) => void;
|
|
62
77
|
download?: (file: UploadFile) => void;
|
|
63
78
|
};
|
|
64
79
|
}
|
|
65
80
|
export interface UploadPictureProps extends BaseProps<'upload-picture', typeof PICTURE_CLASSES>, React.HTMLAttributes<HTMLUListElement> {
|
|
66
|
-
actions?: (file: UploadFile, index: number) => React.ReactNode
|
|
81
|
+
actions?: (file: UploadFile, index: number) => (React.ReactNode | {
|
|
82
|
+
id: React.Key;
|
|
83
|
+
action: React.ReactNode;
|
|
84
|
+
})[];
|
|
67
85
|
defaultActions?: {
|
|
68
86
|
preview?: (file: UploadFile) => void;
|
|
69
87
|
download?: (file: UploadFile) => void;
|
|
70
88
|
};
|
|
71
89
|
}
|
|
72
90
|
export interface UploadPictureListProps extends BaseProps<'upload-picture-list', typeof PICTURE_LIST_CLASSES>, Omit<React.HTMLAttributes<HTMLUListElement>, 'children'> {
|
|
73
|
-
actions?: (file: UploadFile, index: number) => React.ReactNode
|
|
91
|
+
actions?: (file: UploadFile, index: number) => (React.ReactNode | {
|
|
92
|
+
id: React.Key;
|
|
93
|
+
action: React.ReactNode;
|
|
94
|
+
})[];
|
|
74
95
|
defaultActions?: {
|
|
75
96
|
preview?: (file: UploadFile) => void;
|
|
76
97
|
download?: (file: UploadFile) => void;
|
package/upload/vars.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare const ACTION_CLASSES: {
|
|
|
23
23
|
};
|
|
24
24
|
export declare const LIST_CLASSES: {
|
|
25
25
|
'upload-list': string;
|
|
26
|
+
'upload-list__row': string;
|
|
26
27
|
'upload-list__item': string;
|
|
27
28
|
'upload-list__item--load': string;
|
|
28
29
|
'upload-list__item--error': string;
|
|
@@ -48,6 +49,7 @@ export declare const PICTURE_CLASSES: {
|
|
|
48
49
|
};
|
|
49
50
|
export declare const PICTURE_LIST_CLASSES: {
|
|
50
51
|
'upload-picture-list': string;
|
|
52
|
+
'upload-picture-list__row': string;
|
|
51
53
|
'upload-picture-list__item': string;
|
|
52
54
|
'upload-picture-list__item--load': string;
|
|
53
55
|
'upload-picture-list__item--error': string;
|
|
@@ -63,3 +65,12 @@ export declare const UploadContext: import("react").Context<{
|
|
|
63
65
|
files: UploadFile[];
|
|
64
66
|
onRemove: (file: UploadFile) => void;
|
|
65
67
|
}>;
|
|
68
|
+
export declare const UploadActionContext: import("react").Context<{
|
|
69
|
+
file: UploadFile;
|
|
70
|
+
defaultActions?: {
|
|
71
|
+
preview?: ((file: UploadFile) => void) | undefined;
|
|
72
|
+
download?: ((file: UploadFile) => void) | undefined;
|
|
73
|
+
} | undefined;
|
|
74
|
+
light?: boolean | undefined;
|
|
75
|
+
onRemove?: (() => void) | undefined;
|
|
76
|
+
} | undefined>;
|
package/upload/vars.js
CHANGED
|
@@ -22,6 +22,7 @@ export const ACTION_CLASSES = {
|
|
|
22
22
|
};
|
|
23
23
|
export const LIST_CLASSES = {
|
|
24
24
|
'upload-list': '^upload-list',
|
|
25
|
+
'upload-list__row': '^upload-list__row',
|
|
25
26
|
'upload-list__item': '^upload-list__item',
|
|
26
27
|
'upload-list__item--load': '^upload-list__item--load',
|
|
27
28
|
'upload-list__item--error': '^upload-list__item--error',
|
|
@@ -47,6 +48,7 @@ export const PICTURE_CLASSES = {
|
|
|
47
48
|
};
|
|
48
49
|
export const PICTURE_LIST_CLASSES = {
|
|
49
50
|
'upload-picture-list': '^upload-picture-list',
|
|
51
|
+
'upload-picture-list__row': '^upload-picture-list__row',
|
|
50
52
|
'upload-picture-list__item': '^upload-picture-list__item',
|
|
51
53
|
'upload-picture-list__item--load': '^upload-picture-list__item--load',
|
|
52
54
|
'upload-picture-list__item--error': '^upload-picture-list__item--error',
|
|
@@ -63,3 +65,4 @@ export const UploadContext = createContext({
|
|
|
63
65
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
64
66
|
onRemove: () => { },
|
|
65
67
|
});
|
|
68
|
+
export const UploadActionContext = createContext(undefined);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { VirtualScrollProps
|
|
3
|
-
declare function
|
|
4
|
-
export declare const VirtualScroll: <T>(props: VirtualScrollProps<T> & React.RefAttributes<VirtualScrollRef<T>>) => ReturnType<typeof VirtualScrollFC>;
|
|
5
|
-
export {};
|
|
2
|
+
import type { VirtualScrollProps } from './types';
|
|
3
|
+
export declare function VirtualScroll<T>(props: VirtualScrollProps<T>): React.ReactElement | null;
|
|
@@ -2,15 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEventCallback } from '@laser-ui/hooks';
|
|
3
3
|
import { checkScrollEnd } from '@laser-ui/utils';
|
|
4
4
|
import { isBoolean, isNumber, isUndefined, nth } from 'lodash';
|
|
5
|
-
import { Fragment,
|
|
5
|
+
import { Fragment, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
6
6
|
import { EMPTY } from './vars';
|
|
7
7
|
import { useComponentProps } from '../hooks';
|
|
8
|
-
function
|
|
9
|
-
const { children, enable = true, list, listSize, listPadding: listPaddingProp, itemKey, itemRender, itemSize: itemSizeProp, itemEmptySize: itemEmptySizeProp = 0, itemNested, itemEmptyRender, itemExpand, itemFocusable: itemFocusableProp = true, itemFocused, itemInAriaSetsize: itemInAriaSetsizeProp = true, placeholder, horizontal = false, onScrollEnd, } = useComponentProps('VirtualScroll', props);
|
|
8
|
+
export function VirtualScroll(props) {
|
|
9
|
+
const { ref, children, enable = true, list, listSize, listPadding: listPaddingProp, itemKey, itemRender, itemSize: itemSizeProp, itemEmptySize: itemEmptySizeProp = 0, itemNested, itemEmptyRender, itemExpand, itemFocusable: itemFocusableProp = true, itemFocused, itemInAriaSetsize: itemInAriaSetsizeProp = true, placeholder: Placeholder, horizontal = false, onScrollEnd, } = useComponentProps('VirtualScroll', props);
|
|
10
10
|
const listPadding = isNumber(listPaddingProp) ? [listPaddingProp, listPaddingProp] : listPaddingProp;
|
|
11
|
-
const
|
|
12
|
-
listCache: new Map(),
|
|
13
|
-
});
|
|
11
|
+
const listSaved = useRef(new Map());
|
|
14
12
|
const [_scrollPosition, setScrollPosition] = useState(0);
|
|
15
13
|
const itemSize = useMemo(() => (isNumber(itemSizeProp) ? () => itemSizeProp : itemSizeProp), [itemSizeProp]);
|
|
16
14
|
const itemEmptySize = useMemo(() => (isNumber(itemEmptySizeProp) ? () => itemEmptySizeProp : itemEmptySizeProp), [itemEmptySizeProp]);
|
|
@@ -139,10 +137,10 @@ function VirtualScrollFC(props, ref) {
|
|
|
139
137
|
childrenList = getList(nestedData.length === 0 ? [EMPTY] : nestedData, ancestry.concat([item]));
|
|
140
138
|
}
|
|
141
139
|
else {
|
|
142
|
-
childrenList = (_a =
|
|
140
|
+
childrenList = (_a = listSaved.current.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
143
141
|
if (expand) {
|
|
144
142
|
childrenList = getList(nestedData.length === 0 ? [EMPTY] : nestedData, ancestry.concat([item]));
|
|
145
|
-
|
|
143
|
+
listSaved.current.set(key, childrenList);
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
146
|
list.push(itemRender(item, index, {
|
|
@@ -188,30 +186,25 @@ function VirtualScrollFC(props, ref) {
|
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
if (fillSize[0] > 0) {
|
|
191
|
-
list.unshift(
|
|
192
|
-
key: '$$fill-size-0',
|
|
193
|
-
style: {
|
|
189
|
+
list.unshift(_jsx(Placeholder, { style: {
|
|
194
190
|
display: horizontal ? 'inline-block' : 'block',
|
|
195
191
|
overflow: 'hidden',
|
|
196
192
|
width: horizontal ? fillSize[0] : 0,
|
|
197
193
|
height: horizontal ? 0 : fillSize[0],
|
|
198
194
|
flexShrink: 0,
|
|
199
195
|
},
|
|
200
|
-
'aria-hidden': true,
|
|
201
|
-
}));
|
|
196
|
+
'aria-hidden': true }, "$$fill-size-0"));
|
|
202
197
|
}
|
|
198
|
+
_jsx("div", {});
|
|
203
199
|
if (fillSize[1] > 0) {
|
|
204
|
-
list.push(
|
|
205
|
-
key: '$$fill-size-1',
|
|
206
|
-
style: {
|
|
200
|
+
list.push(_jsx(Placeholder, { style: {
|
|
207
201
|
display: horizontal ? 'inline-block' : 'block',
|
|
208
202
|
overflow: 'hidden',
|
|
209
203
|
width: horizontal ? fillSize[1] : 0,
|
|
210
204
|
height: horizontal ? 0 : fillSize[1],
|
|
211
205
|
flexShrink: 0,
|
|
212
206
|
},
|
|
213
|
-
'aria-hidden': true,
|
|
214
|
-
}));
|
|
207
|
+
'aria-hidden': true }, "$$fill-size-1"));
|
|
215
208
|
}
|
|
216
209
|
return list;
|
|
217
210
|
};
|
|
@@ -248,10 +241,10 @@ function VirtualScrollFC(props, ref) {
|
|
|
248
241
|
childrenList = getList(nestedData.length === 0 ? [EMPTY] : nestedData, ancestry.concat([item]));
|
|
249
242
|
}
|
|
250
243
|
else {
|
|
251
|
-
childrenList = (_a =
|
|
244
|
+
childrenList = (_a = listSaved.current.get(key)) !== null && _a !== void 0 ? _a : [];
|
|
252
245
|
if (expand) {
|
|
253
246
|
childrenList = getList(nestedData.length === 0 ? [EMPTY] : nestedData, ancestry.concat([item]));
|
|
254
|
-
|
|
247
|
+
listSaved.current.set(key, childrenList);
|
|
255
248
|
}
|
|
256
249
|
}
|
|
257
250
|
list.push(itemRender(item, index, {
|
|
@@ -427,4 +420,3 @@ function VirtualScrollFC(props, ref) {
|
|
|
427
420
|
}
|
|
428
421
|
});
|
|
429
422
|
}
|
|
430
|
-
export const VirtualScroll = forwardRef(VirtualScrollFC);
|
|
@@ -9,7 +9,8 @@ export interface VirtualScrollRef<T> {
|
|
|
9
9
|
scrollToEnd: (el: HTMLElement) => T | undefined;
|
|
10
10
|
}
|
|
11
11
|
export interface VirtualScrollProps<T> {
|
|
12
|
-
|
|
12
|
+
ref?: React.Ref<VirtualScrollRef<T>>;
|
|
13
|
+
children: (vsList: React.ReactNode, onScroll: React.UIEventHandler<HTMLElement>) => React.ReactElement | null;
|
|
13
14
|
enable?: boolean;
|
|
14
15
|
list: T[];
|
|
15
16
|
listSize: number;
|
package/wave/Wave.d.ts
ADDED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { useEventCallback } from '@laser-ui/hooks';
|
|
4
|
-
import {
|
|
4
|
+
import { useImperativeHandle, useState } from 'react';
|
|
5
5
|
import { CLASSES } from './vars';
|
|
6
|
-
import { useNamespace, useStyled } from '
|
|
7
|
-
import { mergeCS } from '
|
|
8
|
-
export
|
|
9
|
-
const { color } = props, restProps = __rest(props, ["color"]);
|
|
6
|
+
import { useNamespace, useStyled } from '../hooks';
|
|
7
|
+
import { mergeCS } from '../utils';
|
|
8
|
+
export function Wave(props) {
|
|
9
|
+
const { ref, color } = props, restProps = __rest(props, ["ref", "color"]);
|
|
10
10
|
const namespace = useNamespace();
|
|
11
11
|
const styled = useStyled(CLASSES, { wave: undefined });
|
|
12
12
|
const [node, setNode] = useState(null);
|
|
@@ -22,4 +22,4 @@ export const Wave = forwardRef((props, ref) => {
|
|
|
22
22
|
});
|
|
23
23
|
useImperativeHandle(ref, () => wave, [wave]);
|
|
24
24
|
return node;
|
|
25
|
-
}
|
|
25
|
+
}
|
package/wave/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/hooks/useJSS.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useJSS<T extends string | number | symbol>(): import("jss").StyleSheet<T>;
|
package/hooks/useJSS.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { create } from 'jss';
|
|
2
|
-
import preset from 'jss-preset-default';
|
|
3
|
-
import { useEffect, useMemo } from 'react';
|
|
4
|
-
const jss = create();
|
|
5
|
-
jss.setup(preset());
|
|
6
|
-
export function useJSS() {
|
|
7
|
-
const sheet = useMemo(() => jss.createStyleSheet({}), []);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
sheet.attach();
|
|
10
|
-
return () => {
|
|
11
|
-
sheet.detach();
|
|
12
|
-
};
|
|
13
|
-
}, [sheet]);
|
|
14
|
-
return sheet;
|
|
15
|
-
}
|
package/hooks/useNextTick.d.ts
DELETED
package/internal/mask/Mask.d.ts
DELETED
package/internal/mask/Mask.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { CLASSES } from './vars';
|
|
4
|
-
import { useStyled } from '../../hooks';
|
|
5
|
-
import { mergeCS } from '../../utils';
|
|
6
|
-
import { TTANSITION_DURING_FAST } from '../../vars';
|
|
7
|
-
import { Transition } from '../transition';
|
|
8
|
-
export function Mask(props) {
|
|
9
|
-
const { visible, onClose, afterVisibleChange } = props, restProps = __rest(props, ["visible", "onClose", "afterVisibleChange"]);
|
|
10
|
-
const styled = useStyled(CLASSES, { mask: undefined });
|
|
11
|
-
const transitionStyles = {
|
|
12
|
-
enter: { opacity: 0 },
|
|
13
|
-
entering: {
|
|
14
|
-
transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_FAST}ms linear`).join(', '),
|
|
15
|
-
},
|
|
16
|
-
leaving: {
|
|
17
|
-
opacity: 0,
|
|
18
|
-
transition: ['opacity'].map((attr) => `${attr} ${TTANSITION_DURING_FAST}ms linear`).join(', '),
|
|
19
|
-
},
|
|
20
|
-
leaved: { display: 'none' },
|
|
21
|
-
};
|
|
22
|
-
return (_jsx(Transition, { enter: visible, during: TTANSITION_DURING_FAST,
|
|
23
|
-
// TODO: Should it be controllable?
|
|
24
|
-
skipFirstTransition: false, afterEnter: () => {
|
|
25
|
-
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(true);
|
|
26
|
-
}, afterLeave: () => {
|
|
27
|
-
afterVisibleChange === null || afterVisibleChange === void 0 ? void 0 : afterVisibleChange(false);
|
|
28
|
-
}, children: (state) => (_jsx("div", Object.assign({}, restProps, mergeCS(styled('mask'), {
|
|
29
|
-
className: restProps.className,
|
|
30
|
-
style: Object.assign(Object.assign({}, restProps.style), transitionStyles[state]),
|
|
31
|
-
}), { onClick: (e) => {
|
|
32
|
-
var _a;
|
|
33
|
-
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
34
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
35
|
-
} }))) }));
|
|
36
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { isNumber, isUndefined } from 'lodash';
|
|
4
|
-
import { useRef } from 'react';
|
|
5
|
-
import { Transition } from './Transition';
|
|
6
|
-
export function CollapseTransition(props) {
|
|
7
|
-
const { children, originalSize: originalSizeProp, collapsedSize, styles } = props, restProps = __rest(props, ["children", "originalSize", "collapsedSize", "styles"]);
|
|
8
|
-
const dataRef = useRef({
|
|
9
|
-
width: 0,
|
|
10
|
-
height: 0,
|
|
11
|
-
});
|
|
12
|
-
const elRef = useRef(null);
|
|
13
|
-
const isHorizontal = !isUndefined(originalSizeProp.width);
|
|
14
|
-
const getSizeStyle = (val) => (isUndefined(val) ? '' : isNumber(val) ? `${val}px` : val);
|
|
15
|
-
return (_jsx(Transition, Object.assign({}, restProps, { afterRender: () => {
|
|
16
|
-
var _a, _b, _c, _d, _e;
|
|
17
|
-
(_a = restProps.afterRender) === null || _a === void 0 ? void 0 : _a.call(restProps);
|
|
18
|
-
if (elRef.current) {
|
|
19
|
-
if (originalSizeProp.width === 'auto') {
|
|
20
|
-
const cssText = elRef.current.style.cssText;
|
|
21
|
-
elRef.current.style.width = 'auto';
|
|
22
|
-
elRef.current.style.paddingLeft = getSizeStyle((_b = originalSizeProp.padding) === null || _b === void 0 ? void 0 : _b[3]);
|
|
23
|
-
elRef.current.style.paddingRight = getSizeStyle((_c = originalSizeProp.padding) === null || _c === void 0 ? void 0 : _c[1]);
|
|
24
|
-
dataRef.current.width = elRef.current.offsetWidth;
|
|
25
|
-
elRef.current.style.cssText = cssText;
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
27
|
-
elRef.current.offsetTop;
|
|
28
|
-
}
|
|
29
|
-
else if (originalSizeProp.height === 'auto') {
|
|
30
|
-
const cssText = elRef.current.style.cssText;
|
|
31
|
-
elRef.current.style.height = 'auto';
|
|
32
|
-
elRef.current.style.paddingTop = getSizeStyle((_d = originalSizeProp.padding) === null || _d === void 0 ? void 0 : _d[0]);
|
|
33
|
-
elRef.current.style.paddingBottom = getSizeStyle((_e = originalSizeProp.padding) === null || _e === void 0 ? void 0 : _e[2]);
|
|
34
|
-
dataRef.current.height = elRef.current.offsetHeight;
|
|
35
|
-
elRef.current.style.cssText = cssText;
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
37
|
-
elRef.current.offsetTop;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, children: (state) => {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
42
|
-
const transitionStyle = Object.assign({}, styles[state]);
|
|
43
|
-
const originalSize = {
|
|
44
|
-
[isHorizontal ? 'width' : 'height']: isHorizontal
|
|
45
|
-
? originalSizeProp.width === 'auto'
|
|
46
|
-
? dataRef.current.width
|
|
47
|
-
: originalSizeProp.width
|
|
48
|
-
: originalSizeProp.height === 'auto'
|
|
49
|
-
? dataRef.current.height
|
|
50
|
-
: originalSizeProp.height,
|
|
51
|
-
};
|
|
52
|
-
if (!isUndefined(originalSizeProp.padding)) {
|
|
53
|
-
originalSize.padding = originalSizeProp.padding.map((p) => getSizeStyle(p)).join(' ');
|
|
54
|
-
}
|
|
55
|
-
const collapsedStyle = Object.assign({
|
|
56
|
-
[isHorizontal ? 'width' : 'height']: collapsedSize[isHorizontal ? 'width' : 'height'],
|
|
57
|
-
overflow: 'hidden',
|
|
58
|
-
}, isHorizontal
|
|
59
|
-
? {
|
|
60
|
-
paddingLeft: (_b = (_a = collapsedSize.padding) === null || _a === void 0 ? void 0 : _a[3]) !== null && _b !== void 0 ? _b : 0,
|
|
61
|
-
paddingRight: (_d = (_c = collapsedSize.padding) === null || _c === void 0 ? void 0 : _c[1]) !== null && _d !== void 0 ? _d : 0,
|
|
62
|
-
marginLeft: (_f = (_e = collapsedSize.margin) === null || _e === void 0 ? void 0 : _e[3]) !== null && _f !== void 0 ? _f : 0,
|
|
63
|
-
marginRight: (_h = (_g = collapsedSize.margin) === null || _g === void 0 ? void 0 : _g[1]) !== null && _h !== void 0 ? _h : 0,
|
|
64
|
-
}
|
|
65
|
-
: {
|
|
66
|
-
paddingTop: (_k = (_j = collapsedSize.padding) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 0,
|
|
67
|
-
paddingBottom: (_m = (_l = collapsedSize.padding) === null || _l === void 0 ? void 0 : _l[2]) !== null && _m !== void 0 ? _m : 0,
|
|
68
|
-
marginTop: (_p = (_o = collapsedSize.margin) === null || _o === void 0 ? void 0 : _o[0]) !== null && _p !== void 0 ? _p : 0,
|
|
69
|
-
marginBottom: (_r = (_q = collapsedSize.margin) === null || _q === void 0 ? void 0 : _q[2]) !== null && _r !== void 0 ? _r : 0,
|
|
70
|
-
});
|
|
71
|
-
switch (state) {
|
|
72
|
-
case 'enter':
|
|
73
|
-
Object.assign(transitionStyle, collapsedStyle);
|
|
74
|
-
break;
|
|
75
|
-
case 'entering':
|
|
76
|
-
Object.assign(transitionStyle, originalSize, {
|
|
77
|
-
overflow: 'hidden',
|
|
78
|
-
});
|
|
79
|
-
break;
|
|
80
|
-
case 'leave':
|
|
81
|
-
if (elRef.current) {
|
|
82
|
-
originalSize[isHorizontal ? 'width' : 'height'] = elRef.current[isHorizontal ? 'offsetWidth' : 'offsetHeight'];
|
|
83
|
-
}
|
|
84
|
-
Object.assign(transitionStyle, originalSize, {
|
|
85
|
-
overflow: 'hidden',
|
|
86
|
-
});
|
|
87
|
-
break;
|
|
88
|
-
case 'leaving':
|
|
89
|
-
Object.assign(transitionStyle, collapsedStyle);
|
|
90
|
-
break;
|
|
91
|
-
case 'leaved':
|
|
92
|
-
Object.assign(transitionStyle, collapsedStyle, {
|
|
93
|
-
overflow: 'hidden',
|
|
94
|
-
});
|
|
95
|
-
break;
|
|
96
|
-
default:
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
return children(elRef, transitionStyle, state);
|
|
100
|
-
} })));
|
|
101
|
-
}
|