@canlooks/can-ui 0.0.196 → 0.0.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/checkboxBase/checkboxBase.style.js +1 -0
- package/dist/cjs/components/upload/upload.d.ts +2 -1
- package/dist/cjs/components/upload/upload.js +5 -2
- package/dist/esm/components/checkboxBase/checkboxBase.style.js +1 -0
- package/dist/esm/components/upload/upload.d.ts +2 -1
- package/dist/esm/components/upload/upload.js +5 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch, ReactElement, ReactNode, SetStateAction, ComponentProps } from 'react';
|
|
2
2
|
import { DivProps } from '../../types';
|
|
3
3
|
import { ButtonProps } from '../button';
|
|
4
|
-
import { DropArea } from './dropArea';
|
|
4
|
+
import { DropArea, DropAreaProps } from './dropArea';
|
|
5
5
|
export type UploadStatus = 'default' | 'uploading' | 'success' | 'error';
|
|
6
6
|
export interface UploadFile<R = any, A extends any[] = any[]> extends File {
|
|
7
7
|
id: string;
|
|
@@ -31,6 +31,7 @@ export interface UploadProps<R = any, A extends any[] = any[]> extends UploadSha
|
|
|
31
31
|
size?: number;
|
|
32
32
|
/** 是否支持“将文件拖拽到此处” */
|
|
33
33
|
droppable?: boolean;
|
|
34
|
+
dropAreaProps?: DropAreaProps;
|
|
34
35
|
sortable?: boolean;
|
|
35
36
|
defaultValue?: UploadFile<R, A>[];
|
|
36
37
|
value?: UploadFile<R, A>[];
|
|
@@ -23,7 +23,7 @@ const markFileId = (files) => {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
exports.Upload = (0, react_1.memo)(({ inputProps, type = 'file', accept = type === 'image' ? 'image/*' : void 0, max = Infinity, showButton = true, buttonProps, buttonText = '选择文件', variant = 'square', sortable, droppable, defaultValue, value, onChange, onUpload, ...props }) => {
|
|
26
|
+
exports.Upload = (0, react_1.memo)(({ inputProps, type = 'file', accept = type === 'image' ? 'image/*' : void 0, max = Infinity, showButton = true, buttonProps, buttonText = '选择文件', variant = 'square', sortable, droppable, dropAreaProps, defaultValue, value, onChange, onUpload, ...props }) => {
|
|
27
27
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
28
28
|
const itemRefs = (0, react_1.useRef)(new Map());
|
|
29
29
|
(0, react_1.useImperativeHandle)(props.ref, () => {
|
|
@@ -99,7 +99,10 @@ exports.Upload = (0, react_1.memo)(({ inputProps, type = 'file', accept = type =
|
|
|
99
99
|
onChange: inputChangeHandler
|
|
100
100
|
}), "data-hidden": "true" }), (0, jsx_runtime_1.jsx)(react_2.DragDropProvider, { sensors: utils_1.defaultSensors, onDragEnd: dragEndHandler, children: type === 'file'
|
|
101
101
|
? (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [droppable
|
|
102
|
-
? (0, jsx_runtime_1.jsx)(dropArea_1.DropArea, {
|
|
102
|
+
? (0, jsx_runtime_1.jsx)(dropArea_1.DropArea, { ...(0, utils_1.mergeComponentProps)(dropAreaProps, {
|
|
103
|
+
onClick: () => innerInputRef.current.click(),
|
|
104
|
+
onDrop: changeFn
|
|
105
|
+
}) })
|
|
103
106
|
: showButton &&
|
|
104
107
|
(0, jsx_runtime_1.jsx)(button_1.Button, { variant: "outlined", prefix: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: faUpload_1.faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), (0, jsx_runtime_1.jsx)(react_transition_group_1.TransitionGroup, { className: upload_style_1.classes.files, children: innerValue.current.map((file, index) => (0, jsx_runtime_1.jsx)(sortableItem_1.SortableItem, { component: transitionBase_1.Collapse, className: upload_style_1.classes.sortableItem, id: file.id, index: index, disabled: !sortable, children: (0, jsx_runtime_1.jsx)(fileItem_1.FileItem, { ref: r => {
|
|
105
108
|
r
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Dispatch, ReactElement, ReactNode, SetStateAction, ComponentProps } from 'react';
|
|
2
2
|
import { DivProps } from '../../types.js';
|
|
3
3
|
import { ButtonProps } from '../button/index.js';
|
|
4
|
-
import { DropArea } from './dropArea.js';
|
|
4
|
+
import { DropArea, DropAreaProps } from './dropArea.js';
|
|
5
5
|
export type UploadStatus = 'default' | 'uploading' | 'success' | 'error';
|
|
6
6
|
export interface UploadFile<R = any, A extends any[] = any[]> extends File {
|
|
7
7
|
id: string;
|
|
@@ -31,6 +31,7 @@ export interface UploadProps<R = any, A extends any[] = any[]> extends UploadSha
|
|
|
31
31
|
size?: number;
|
|
32
32
|
/** 是否支持“将文件拖拽到此处” */
|
|
33
33
|
droppable?: boolean;
|
|
34
|
+
dropAreaProps?: DropAreaProps;
|
|
34
35
|
sortable?: boolean;
|
|
35
36
|
defaultValue?: UploadFile<R, A>[];
|
|
36
37
|
value?: UploadFile<R, A>[];
|
|
@@ -20,7 +20,7 @@ const markFileId = (files) => {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
export const Upload = memo(({ inputProps, type = 'file', accept = type === 'image' ? 'image/*' : void 0, max = Infinity, showButton = true, buttonProps, buttonText = '选择文件', variant = 'square', sortable, droppable, defaultValue, value, onChange, onUpload, ...props }) => {
|
|
23
|
+
export const Upload = memo(({ inputProps, type = 'file', accept = type === 'image' ? 'image/*' : void 0, max = Infinity, showButton = true, buttonProps, buttonText = '选择文件', variant = 'square', sortable, droppable, dropAreaProps, defaultValue, value, onChange, onUpload, ...props }) => {
|
|
24
24
|
const wrapperRef = useRef(null);
|
|
25
25
|
const itemRefs = useRef(new Map());
|
|
26
26
|
useImperativeHandle(props.ref, () => {
|
|
@@ -96,7 +96,10 @@ export const Upload = memo(({ inputProps, type = 'file', accept = type === 'imag
|
|
|
96
96
|
onChange: inputChangeHandler
|
|
97
97
|
}), "data-hidden": "true" }), _jsx(DragDropProvider, { sensors: defaultSensors, onDragEnd: dragEndHandler, children: type === 'file'
|
|
98
98
|
? _jsxs(_Fragment, { children: [droppable
|
|
99
|
-
? _jsx(DropArea, {
|
|
99
|
+
? _jsx(DropArea, { ...mergeComponentProps(dropAreaProps, {
|
|
100
|
+
onClick: () => innerInputRef.current.click(),
|
|
101
|
+
onDrop: changeFn
|
|
102
|
+
}) })
|
|
100
103
|
: showButton &&
|
|
101
104
|
_jsx(Button, { variant: "outlined", prefix: _jsx(Icon, { icon: faUpload }), ...buttonProps, onClick: buttonClick, children: buttonText }), _jsx(TransitionGroup, { className: classes.files, children: innerValue.current.map((file, index) => _jsx(SortableItem, { component: Collapse, className: classes.sortableItem, id: file.id, index: index, disabled: !sortable, children: _jsx(FileItem, { ref: r => {
|
|
102
105
|
r
|