@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/types.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export type Lang = 'en-US' | 'zh-CN';
|
|
|
4
4
|
export type Size = 'small' | 'medium' | 'large';
|
|
5
5
|
export type PopupPlacement = 'top' | 'top-left' | 'top-right' | 'right' | 'right-top' | 'right-bottom' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-top' | 'left-bottom';
|
|
6
6
|
export type VerticalSidePlacement = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
|
|
7
|
-
export type CloneHTMLElement<T extends React.ReactElement = React.ReactElement> = (el: T) => T;
|
|
8
7
|
export interface BaseProps<CR extends string, C extends {
|
|
9
8
|
[index: string]: string;
|
|
10
9
|
}> {
|
|
@@ -19,3 +18,4 @@ export interface BaseProps<CR extends string, C extends {
|
|
|
19
18
|
[K in CR]: string;
|
|
20
19
|
};
|
|
21
20
|
}
|
|
21
|
+
export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[] ? ElementType : never;
|
package/upload/Upload.d.ts
CHANGED
|
@@ -6,9 +6,8 @@ import { UploadList } from './UploadList';
|
|
|
6
6
|
import { UploadPicture } from './UploadPicture';
|
|
7
7
|
import { UploadPictureList } from './UploadPictureList';
|
|
8
8
|
import { UploadPreviewAction } from './UploadPreviewAction';
|
|
9
|
-
declare function UploadFC(props: UploadProps, ref: React.ForwardedRef<HTMLInputElement>): JSX.Element | null;
|
|
10
9
|
export declare const Upload: {
|
|
11
|
-
(props: UploadProps
|
|
10
|
+
(props: UploadProps): React.ReactElement | null;
|
|
12
11
|
Button: typeof UploadButton;
|
|
13
12
|
Action: typeof UploadAction;
|
|
14
13
|
PreviewAction: typeof UploadPreviewAction;
|
|
@@ -16,4 +15,3 @@ export declare const Upload: {
|
|
|
16
15
|
Picture: typeof UploadPicture;
|
|
17
16
|
PictureList: typeof UploadPictureList;
|
|
18
17
|
};
|
|
19
|
-
export {};
|
package/upload/Upload.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEventCallback,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useEventCallback, useUnmount } from '@laser-ui/hooks';
|
|
4
|
+
import { setRef } from '@laser-ui/utils';
|
|
5
|
+
import { isNumber } from 'lodash';
|
|
6
|
+
import { useMemo, useRef } from 'react';
|
|
6
7
|
import { UploadAction } from './UploadAction';
|
|
7
8
|
import { UploadButton } from './UploadButton';
|
|
8
9
|
import { UploadList } from './UploadList';
|
|
@@ -12,18 +13,15 @@ import { UploadPreviewAction } from './UploadPreviewAction';
|
|
|
12
13
|
import { CLASSES, UploadContext } from './vars';
|
|
13
14
|
import { useComponentProps, useControlled, useStyled } from '../hooks';
|
|
14
15
|
import { mergeCS } from '../utils';
|
|
15
|
-
|
|
16
|
+
export const Upload = (props) => {
|
|
16
17
|
var _a;
|
|
17
|
-
const _b = useComponentProps('Upload', props), { children, styleOverrides, styleProvider, formControl, model, defaultModel, request, max, drag = false, customUpload, beforeUpload, onModelChange, onRemove } = _b, restProps = __rest(_b, ["children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "request", "max", "drag", "customUpload", "beforeUpload", "onModelChange", "onRemove"]);
|
|
18
|
+
const _b = useComponentProps('Upload', props), { ref, children, styleOverrides, styleProvider, formControl, model, defaultModel, request, max, drag = false, customUpload, beforeUpload, onModelChange, onRemove } = _b, restProps = __rest(_b, ["ref", "children", "styleOverrides", "styleProvider", "formControl", "model", "defaultModel", "request", "max", "drag", "customUpload", "beforeUpload", "onModelChange", "onRemove"]);
|
|
18
19
|
const styled = useStyled(CLASSES, { upload: styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider.upload, 'upload-list': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-list'] }, styleOverrides);
|
|
19
20
|
const inputRef = useRef(null);
|
|
20
|
-
const
|
|
21
|
-
const dataRef = useRef({
|
|
22
|
-
fileURLs: [],
|
|
23
|
-
});
|
|
21
|
+
const fileURLs = useRef([]);
|
|
24
22
|
const [files, changeFiles] = useControlled(defaultModel !== null && defaultModel !== void 0 ? defaultModel : [], model, undefined, undefined, formControl === null || formControl === void 0 ? void 0 : formControl.control);
|
|
25
23
|
useUnmount(() => {
|
|
26
|
-
|
|
24
|
+
fileURLs.current.forEach((fileURL) => {
|
|
27
25
|
URL.revokeObjectURL(fileURL);
|
|
28
26
|
});
|
|
29
27
|
});
|
|
@@ -41,7 +39,7 @@ function UploadFC(props, ref) {
|
|
|
41
39
|
let uid = ++n;
|
|
42
40
|
const add = (obj) => {
|
|
43
41
|
const fileURL = URL.createObjectURL(file);
|
|
44
|
-
|
|
42
|
+
fileURLs.current.push(fileURL);
|
|
45
43
|
const fileAdded = Object.assign({ uid, name: file.name, url: fileURL, thumbUrl: file.type.startsWith('image') ? fileURL : undefined, originFile: file, response: xhr.response }, obj);
|
|
46
44
|
if (isNumber(max) && files.length + filesAdded.length >= max) {
|
|
47
45
|
if (max === 1) {
|
|
@@ -138,41 +136,6 @@ function UploadFC(props, ref) {
|
|
|
138
136
|
}
|
|
139
137
|
}
|
|
140
138
|
};
|
|
141
|
-
const render = (el) => {
|
|
142
|
-
let dragProps = {};
|
|
143
|
-
if (drag) {
|
|
144
|
-
dragProps = {
|
|
145
|
-
onDragEnter: (e) => {
|
|
146
|
-
var _a, _b;
|
|
147
|
-
(_b = (_a = el.props).onDragEnter) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
148
|
-
e.stopPropagation();
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
},
|
|
151
|
-
onDragOver: (e) => {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
(_b = (_a = el.props).onDragOver) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
154
|
-
e.stopPropagation();
|
|
155
|
-
e.preventDefault();
|
|
156
|
-
},
|
|
157
|
-
onDrop: (e) => {
|
|
158
|
-
var _a, _b;
|
|
159
|
-
(_b = (_a = el.props).onDrop) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
160
|
-
e.stopPropagation();
|
|
161
|
-
e.preventDefault();
|
|
162
|
-
const dt = e.dataTransfer;
|
|
163
|
-
const files = dt.files;
|
|
164
|
-
handleFiles(files);
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
return cloneElement(el, Object.assign(Object.assign({}, dragProps), { onClick: (e) => {
|
|
169
|
-
var _a, _b;
|
|
170
|
-
(_b = (_a = el.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
|
|
171
|
-
if (inputRef.current) {
|
|
172
|
-
inputRef.current.click();
|
|
173
|
-
}
|
|
174
|
-
} }));
|
|
175
|
-
};
|
|
176
139
|
const handleRemove = useEventCallback((file) => {
|
|
177
140
|
onRemove === null || onRemove === void 0 ? void 0 : onRemove(file);
|
|
178
141
|
const newList = changeFiles((draft) => {
|
|
@@ -182,10 +145,39 @@ function UploadFC(props, ref) {
|
|
|
182
145
|
onModelChange === null || onModelChange === void 0 ? void 0 : onModelChange(newList, { type: 'remove', files: [file] });
|
|
183
146
|
});
|
|
184
147
|
const context = useMemo(() => ({ files, onRemove: handleRemove }), [files, handleRemove]);
|
|
185
|
-
return (_jsxs(_Fragment, { children: [_jsx(UploadContext
|
|
148
|
+
return (_jsxs(_Fragment, { children: [_jsx(UploadContext, { value: context, children: children(Object.assign({ onClick: () => {
|
|
149
|
+
if (inputRef.current) {
|
|
150
|
+
inputRef.current.click();
|
|
151
|
+
}
|
|
152
|
+
} }, (drag
|
|
153
|
+
? {
|
|
154
|
+
onDragEnter: (e) => {
|
|
155
|
+
e.stopPropagation();
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
},
|
|
158
|
+
onDragOver: (e) => {
|
|
159
|
+
e.stopPropagation();
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
},
|
|
162
|
+
onDrop: (e) => {
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
const dt = e.dataTransfer;
|
|
166
|
+
const files = dt.files;
|
|
167
|
+
handleFiles(files);
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
: undefined))) }), _jsx("input", Object.assign({}, restProps, mergeCS(styled('upload'), {
|
|
186
171
|
className: restProps.className,
|
|
187
172
|
style: restProps.style,
|
|
188
|
-
}), { ref:
|
|
173
|
+
}), { ref: (instance) => {
|
|
174
|
+
const ret = setRef(ref, instance);
|
|
175
|
+
inputRef.current = instance;
|
|
176
|
+
return () => {
|
|
177
|
+
ret();
|
|
178
|
+
inputRef.current = null;
|
|
179
|
+
};
|
|
180
|
+
}, type: (_a = restProps.type) !== null && _a !== void 0 ? _a : 'file', onChange: (e) => {
|
|
189
181
|
var _a;
|
|
190
182
|
(_a = restProps.onChange) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
191
183
|
const files = e.currentTarget.files;
|
|
@@ -194,8 +186,7 @@ function UploadFC(props, ref) {
|
|
|
194
186
|
}
|
|
195
187
|
e.currentTarget.value = '';
|
|
196
188
|
} }))] }));
|
|
197
|
-
}
|
|
198
|
-
export const Upload = forwardRef(UploadFC);
|
|
189
|
+
};
|
|
199
190
|
Upload.Button = UploadButton;
|
|
200
191
|
Upload.Action = UploadAction;
|
|
201
192
|
Upload.PreviewAction = UploadPreviewAction;
|
package/upload/UploadAction.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { UploadActionProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function UploadAction(props: UploadActionProps): React.ReactElement | null;
|
package/upload/UploadAction.js
CHANGED
|
@@ -4,20 +4,21 @@ import { saveFile } from '@laser-ui/utils';
|
|
|
4
4
|
import DeleteOutlineOutlined from '@material-design-icons/svg/outlined/delete_outline.svg?react';
|
|
5
5
|
import FileDownloadOutlined from '@material-design-icons/svg/outlined/file_download.svg?react';
|
|
6
6
|
import { isUndefined } from 'lodash';
|
|
7
|
-
import {
|
|
8
|
-
import { ACTION_CLASSES } from './vars';
|
|
7
|
+
import { use } from 'react';
|
|
8
|
+
import { ACTION_CLASSES, UploadActionContext } from './vars';
|
|
9
9
|
import { useComponentProps, useStyled, useTranslation } from '../hooks';
|
|
10
10
|
import { Icon } from '../icon';
|
|
11
11
|
import { mergeCS } from '../utils';
|
|
12
|
-
export
|
|
12
|
+
export function UploadAction(props) {
|
|
13
13
|
var _a, _b, _c;
|
|
14
|
-
const _d = useComponentProps('UploadAction', props), { styleOverrides, styleProvider, children, preset, disabled: disabledProp = false
|
|
14
|
+
const _d = useComponentProps('UploadAction', props), { ref, styleOverrides, styleProvider, children, preset, disabled: disabledProp = false } = _d, restProps = __rest(_d, ["ref", "styleOverrides", "styleProvider", "children", "preset", "disabled"]);
|
|
15
15
|
const styled = useStyled(ACTION_CLASSES, { 'upload-action': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-action'] }, styleOverrides);
|
|
16
16
|
const { t } = useTranslation();
|
|
17
|
-
const
|
|
17
|
+
const uploadActionContext = use(UploadActionContext);
|
|
18
|
+
const disabled = preset === 'download' ? disabledProp || isUndefined(uploadActionContext === null || uploadActionContext === void 0 ? void 0 : uploadActionContext.file.url) : disabledProp;
|
|
18
19
|
return (_jsx("div", Object.assign({}, restProps, mergeCS(styled('upload-action', {
|
|
19
20
|
'upload-action.is-disabled': disabled,
|
|
20
|
-
'upload-action--light':
|
|
21
|
+
'upload-action--light': uploadActionContext === null || uploadActionContext === void 0 ? void 0 : uploadActionContext.light,
|
|
21
22
|
}), {
|
|
22
23
|
className: restProps.className,
|
|
23
24
|
style: restProps.style,
|
|
@@ -26,19 +27,21 @@ export const UploadAction = forwardRef((props, ref) => {
|
|
|
26
27
|
: preset === 'remove'
|
|
27
28
|
? t('Upload', 'Remove file')
|
|
28
29
|
: undefined, onClick: (e) => {
|
|
29
|
-
var _a;
|
|
30
|
+
var _a, _b, _c;
|
|
30
31
|
(_a = restProps.onClick) === null || _a === void 0 ? void 0 : _a.call(restProps, e);
|
|
31
32
|
e.stopPropagation();
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
34
|
-
|
|
33
|
+
if (uploadActionContext) {
|
|
34
|
+
if (preset === 'download') {
|
|
35
|
+
if ((_b = uploadActionContext.defaultActions) === null || _b === void 0 ? void 0 : _b.download) {
|
|
36
|
+
uploadActionContext.defaultActions.download(uploadActionContext.file);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
saveFile(uploadActionContext.file.url, uploadActionContext.file.name);
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
|
-
else {
|
|
37
|
-
|
|
42
|
+
else if (preset === 'remove') {
|
|
43
|
+
(_c = uploadActionContext.onRemove) === null || _c === void 0 ? void 0 : _c.call(uploadActionContext);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
else if (preset === 'remove') {
|
|
41
|
-
_onRemove === null || _onRemove === void 0 ? void 0 : _onRemove();
|
|
42
|
-
}
|
|
43
46
|
}, children: children !== null && children !== void 0 ? children : (preset === 'download' ? (_jsx(Icon, { children: _jsx(FileDownloadOutlined, {}) })) : preset === 'remove' ? (_jsx(Icon, { children: _jsx(DeleteOutlineOutlined, {}) })) : null) })));
|
|
44
|
-
}
|
|
47
|
+
}
|
package/upload/UploadButton.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { UploadButtonProps } from './types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare function UploadButton(props: UploadButtonProps): React.ReactElement | null;
|
package/upload/UploadButton.js
CHANGED
|
@@ -2,17 +2,18 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import AddOutlined from '@material-design-icons/svg/outlined/add.svg?react';
|
|
4
4
|
import InsertDriveFileTwoTone from '@material-design-icons/svg/two-tone/insert_drive_file.svg?react';
|
|
5
|
-
import {
|
|
5
|
+
import { has } from 'lodash';
|
|
6
|
+
import { Fragment } from 'react';
|
|
6
7
|
import { UploadAction } from './UploadAction';
|
|
7
8
|
import { UploadPreviewAction } from './UploadPreviewAction';
|
|
8
|
-
import { BUTTON_CLASSES } from './vars';
|
|
9
|
+
import { BUTTON_CLASSES, UploadActionContext } from './vars';
|
|
10
|
+
import { CircularProgress } from '../circular-progress';
|
|
9
11
|
import { useComponentProps, useStyled, useTranslation } from '../hooks';
|
|
10
12
|
import { Icon } from '../icon';
|
|
11
|
-
import { CircularProgress } from '../internal/circular-progress';
|
|
12
13
|
import { mergeCS } from '../utils';
|
|
13
|
-
export
|
|
14
|
+
export function UploadButton(props) {
|
|
14
15
|
var _a;
|
|
15
|
-
const _b = useComponentProps('UploadButton', props), { styleOverrides, styleProvider, file, actions, defaultActions, onRemove } = _b, restProps = __rest(_b, ["styleOverrides", "styleProvider", "file", "actions", "defaultActions", "onRemove"]);
|
|
16
|
+
const _b = useComponentProps('UploadButton', props), { ref, styleOverrides, styleProvider, file, actions, defaultActions, onRemove } = _b, restProps = __rest(_b, ["ref", "styleOverrides", "styleProvider", "file", "actions", "defaultActions", "onRemove"]);
|
|
16
17
|
const styled = useStyled(BUTTON_CLASSES, { 'upload-button': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-button'] }, styleOverrides);
|
|
17
18
|
const { t } = useTranslation();
|
|
18
19
|
const isLoading = file && file.state === 'progress';
|
|
@@ -22,10 +23,13 @@ export const UploadButton = forwardRef((props, ref) => {
|
|
|
22
23
|
}), {
|
|
23
24
|
className: restProps.className,
|
|
24
25
|
style: restProps.style,
|
|
25
|
-
}), { ref: ref, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : (isLoading ? -1 : 0), children: file && file.state !== 'progress' ? (_jsxs(_Fragment, { children: [file.thumbUrl ? (_jsx("img", Object.assign({}, styled('upload-button__thumbnail'), { src: file.thumbUrl, alt: file.name }))) : (_jsxs(_Fragment, { children: [_jsx(Icon, { theme: file.state === 'error' ? 'danger' : 'primary', children: _jsx(InsertDriveFileTwoTone, {}) }), _jsx("div", Object.assign({}, styled('upload-button__name'), { children: file.name }))] })), _jsx("div", Object.assign({}, styled('upload-button__actions'), { children:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
26
|
+
}), { ref: ref, tabIndex: (_a = restProps.tabIndex) !== null && _a !== void 0 ? _a : (isLoading ? -1 : 0), children: file && file.state !== 'progress' ? (_jsxs(_Fragment, { children: [file.thumbUrl ? (_jsx("img", Object.assign({}, styled('upload-button__thumbnail'), { src: file.thumbUrl, alt: file.name }))) : (_jsxs(_Fragment, { children: [_jsx(Icon, { theme: file.state === 'error' ? 'danger' : 'primary', children: _jsx(InsertDriveFileTwoTone, {}) }), _jsx("div", Object.assign({}, styled('upload-button__name'), { children: file.name }))] })), _jsx("div", Object.assign({}, styled('upload-button__actions'), { children: _jsx(UploadActionContext, { value: {
|
|
27
|
+
file,
|
|
28
|
+
defaultActions,
|
|
29
|
+
light: true,
|
|
30
|
+
onRemove,
|
|
31
|
+
}, children: (actions !== null && actions !== void 0 ? actions : [_jsx(UploadPreviewAction, {}), _jsx(UploadAction, { preset: "remove" })]).map((node, index) => {
|
|
32
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
33
|
+
return _jsx(Fragment, { children: action }, id);
|
|
34
|
+
}) }) }))] })) : (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('upload-button__icon'), { children: _jsx(Icon, { children: isLoading ? _jsx(CircularProgress, {}) : _jsx(AddOutlined, {}) }) })), _jsx("div", Object.assign({}, styled('upload-button__text'), { children: t('Upload', isLoading ? 'Uploading' : 'Upload') }))] })) })));
|
|
35
|
+
}
|
package/upload/UploadList.d.ts
CHANGED
package/upload/UploadList.js
CHANGED
|
@@ -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 AttachFileOutlined from '@material-design-icons/svg/outlined/attach_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 { 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 UploadList(props) {
|
|
17
|
-
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const _c = useComponentProps('UploadList', props), { styleOverrides, styleProvider, actions, defaultActions } = _c, restProps = __rest(_c, ["styleOverrides", "styleProvider", "actions", "defaultActions"]);
|
|
18
19
|
const styled = useStyled(LIST_CLASSES, { 'upload-list': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-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-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-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-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-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-list__item', { [`upload-list__item--${file.state}`]: file.state }), { children: [_jsx("div", Object.assign({}, styled('upload-list__icon'), { children: file.state === 'progress' ? (_jsx(Icon, { children: _jsx(CircularProgress, {}) })) : (_jsx(Icon, { rotate: 45, children: _jsx(AttachFileOutlined, {}) })) })), _jsx("a", Object.assign({}, styled('upload-list__link', {
|
|
50
|
+
'upload-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-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-list__progress-wrapper'), { children: isNumber(file.percent) && _jsx(Progress, { percent: file.percent, label: false, lineWidth: 2 }) }))] })) })) }, file.uid))) })) })));
|
|
62
67
|
}
|
package/upload/UploadPicture.js
CHANGED
|
@@ -1,72 +1,66 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, 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 } from 'lodash';
|
|
6
|
-
import {
|
|
4
|
+
import { has, isNumber } from 'lodash';
|
|
5
|
+
import { Fragment, use, useRef } from 'react';
|
|
7
6
|
import { UploadAction } from './UploadAction';
|
|
8
7
|
import { UploadPreviewAction } from './UploadPreviewAction';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { useNextTick } from './hooks';
|
|
9
|
+
import { PICTURE_CLASSES, UploadActionContext, UploadContext } from './vars';
|
|
10
|
+
import { useComponentProps, useNamespace, useStyled, useTranslation } from '../hooks';
|
|
11
11
|
import { Icon } from '../icon';
|
|
12
|
-
import { Transition } from '../internal/transition';
|
|
13
12
|
import { Progress } from '../progress';
|
|
13
|
+
import { Transition } from '../transition';
|
|
14
14
|
import { mergeCS } from '../utils';
|
|
15
15
|
import { TTANSITION_DURING_BASE } from '../vars';
|
|
16
16
|
export function UploadPicture(props) {
|
|
17
|
-
|
|
17
|
+
var _a, _b;
|
|
18
|
+
const _c = useComponentProps('UploadPicture', props), { children, styleOverrides, styleProvider, actions, defaultActions } = _c, restProps = __rest(_c, ["children", "styleOverrides", "styleProvider", "actions", "defaultActions"]);
|
|
19
|
+
const namespace = useNamespace();
|
|
18
20
|
const styled = useStyled(PICTURE_CLASSES, { 'upload-picture': styleProvider === null || styleProvider === void 0 ? void 0 : styleProvider['upload-picture'] }, styleOverrides);
|
|
19
21
|
const { t } = useTranslation();
|
|
20
|
-
const { files, onRemove } =
|
|
22
|
+
const { files: currentFiles, onRemove } = use(UploadContext);
|
|
23
|
+
const files = useRef(currentFiles);
|
|
24
|
+
{
|
|
25
|
+
const newFiles = currentFiles.map((file) => Object.assign({}, file));
|
|
26
|
+
let index = -1;
|
|
27
|
+
for (const file of files.current) {
|
|
28
|
+
index += 1;
|
|
29
|
+
if (file.__removing) {
|
|
30
|
+
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)) {
|
|
31
|
+
newFiles.splice(index, 0, file);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
files.current = newFiles;
|
|
36
|
+
}
|
|
21
37
|
const nextTick = useNextTick();
|
|
22
|
-
const [removeUIDs, setRemoveUIDs] = useImmer([]);
|
|
23
38
|
return (_jsx("ul", Object.assign({}, restProps, mergeCS(styled('upload-picture'), {
|
|
24
39
|
className: restProps.className,
|
|
25
40
|
style: restProps.style,
|
|
26
|
-
}), { children: _jsxs("div", Object.assign({}, styled('upload-picture__row'), { children: [files.map((file, index) => (_jsx(Transition, { enter: !
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
onRemove(file);
|
|
31
|
-
}, children: (state) => {
|
|
32
|
-
let transitionStyle = {};
|
|
33
|
-
switch (state) {
|
|
34
|
-
case 'enter':
|
|
35
|
-
transitionStyle = { transform: 'scale(0)' };
|
|
36
|
-
break;
|
|
37
|
-
case 'entering':
|
|
38
|
-
transitionStyle = {
|
|
39
|
-
transition: ['transform'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-out`).join(', '),
|
|
40
|
-
transformOrigin: 'top left',
|
|
41
|
-
};
|
|
42
|
-
break;
|
|
43
|
-
case 'leaving':
|
|
44
|
-
transitionStyle = {
|
|
45
|
-
transform: 'scale(0)',
|
|
46
|
-
transition: ['transform'].map((attr) => `${attr} ${TTANSITION_DURING_BASE}ms ease-in`).join(', '),
|
|
47
|
-
transformOrigin: 'top left',
|
|
48
|
-
};
|
|
49
|
-
break;
|
|
50
|
-
case 'leaved':
|
|
51
|
-
transitionStyle = { display: 'none' };
|
|
52
|
-
break;
|
|
53
|
-
default:
|
|
54
|
-
break;
|
|
41
|
+
}), { children: _jsxs("div", Object.assign({}, styled('upload-picture__row'), { children: [files.current.map((file, index) => (_jsx(Transition, { enter: !file.__removing, name: `${namespace}-upload-picture`, duration: TTANSITION_DURING_BASE, skipFirstTransition: nextTick.current ? false : true, onAfterLeave: () => {
|
|
42
|
+
const index = files.current.findIndex((f) => f.uid === file.uid);
|
|
43
|
+
if (index !== -1) {
|
|
44
|
+
files.current.splice(index, 1);
|
|
55
45
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
}, children: (transitionRef, leaved) => leaved ? null : (_jsx("div", { ref: (instance) => {
|
|
47
|
+
transitionRef(instance);
|
|
48
|
+
return () => {
|
|
49
|
+
transitionRef(null);
|
|
50
|
+
};
|
|
51
|
+
}, children: _jsx("li", Object.assign({}, styled('upload-picture__item', {
|
|
52
|
+
[`upload-picture__item--${file.state}`]: file.state,
|
|
53
|
+
'upload-picture__item.is-disabled': file && file.state === 'progress',
|
|
54
|
+
}), { children: file.state !== 'progress' ? (_jsxs(_Fragment, { children: [file.thumbUrl ? (_jsx("img", Object.assign({}, styled('upload-picture__thumbnail'), { src: file.thumbUrl, alt: file.name }))) : (_jsxs(_Fragment, { children: [_jsx(Icon, { size: 28, theme: file.state === 'error' ? 'danger' : 'primary', children: _jsx(InsertDriveFileTwoTone, {}) }), _jsx("div", Object.assign({}, styled('upload-picture__name'), { children: file.name }))] })), _jsx("div", Object.assign({}, styled('upload-picture__actions'), { children: _jsx(UploadActionContext, { value: {
|
|
55
|
+
file,
|
|
56
|
+
defaultActions,
|
|
57
|
+
light: true,
|
|
58
|
+
onRemove: () => {
|
|
59
|
+
file.__removing = true;
|
|
60
|
+
onRemove(file);
|
|
69
61
|
},
|
|
70
|
-
}
|
|
71
|
-
|
|
62
|
+
}, children: (actions ? actions(file, index) : [_jsx(UploadPreviewAction, {}), _jsx(UploadAction, { preset: "remove" })]).map((node, index) => {
|
|
63
|
+
const { id, action } = (has(node, ['id', 'action']) ? node : { id: index, action: node });
|
|
64
|
+
return _jsx(Fragment, { children: action }, id);
|
|
65
|
+
}) }) }))] })) : (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({}, styled('upload-picture__progress-text'), { children: t('Upload', 'Uploading') })), isNumber(file.percent) && (_jsx(Progress, { style: { width: '100%' }, percent: file.percent, label: false, lineWidth: 2 }))] })) })) })) }, file.uid))), _jsx("div", { children: children })] })) })));
|
|
72
66
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { UploadPictureListProps } from './types';
|
|
3
|
-
export declare function UploadPictureList(props: UploadPictureListProps):
|
|
3
|
+
export declare function UploadPictureList(props: UploadPictureListProps): React.ReactElement | null;
|