@canlooks/can-ui 0.0.144 → 0.0.145
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/app/appActionSheet.js +42 -41
- package/dist/cjs/components/app/appDialog.js +31 -32
- package/dist/cjs/components/form/formItem.js +1 -1
- package/dist/cjs/components/snackbarBase/snackbarBase.js +1 -1
- package/dist/cjs/components/upload/upload.js +1 -1
- package/dist/cjs/utils/utils.d.ts +2 -8
- package/dist/cjs/utils/utils.js +4 -19
- package/dist/esm/components/app/appActionSheet.js +38 -37
- package/dist/esm/components/app/appDialog.js +27 -28
- package/dist/esm/components/form/formItem.js +2 -2
- package/dist/esm/components/snackbarBase/snackbarBase.js +2 -2
- package/dist/esm/components/upload/upload.js +2 -2
- package/dist/esm/utils/utils.d.ts +2 -8
- package/dist/esm/utils/utils.js +3 -17
- package/documentation/dist/assets/index-DyrGMYuH.js +1 -1
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppActionSheet = exports.AppActionSheetMethods = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const actionSheet_1 = require("../actionSheet");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
7
9
|
class AppActionSheetMethods {
|
|
8
10
|
async confirm() {
|
|
9
11
|
}
|
|
@@ -11,47 +13,46 @@ class AppActionSheetMethods {
|
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
15
|
exports.AppActionSheetMethods = AppActionSheetMethods;
|
|
14
|
-
exports.AppActionSheet = (0,
|
|
15
|
-
const [stacks, setStacks] = (0,
|
|
16
|
-
const defineMethods = (type) =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
exports.AppActionSheet = (0, react_2.memo)(({ methods }) => {
|
|
17
|
+
const [stacks, setStacks] = (0, react_2.useState)([]);
|
|
18
|
+
const defineMethods = (type) => {
|
|
19
|
+
return (params, ...args) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
const props = typeof params !== 'object' || (0, react_2.isValidElement)(params)
|
|
22
|
+
? { title: params }
|
|
23
|
+
: params;
|
|
24
|
+
const key = (0, utils_1.getRandomId)();
|
|
25
|
+
setStacks(o => [
|
|
26
|
+
...o,
|
|
27
|
+
{
|
|
28
|
+
...props,
|
|
29
|
+
key,
|
|
30
|
+
type,
|
|
31
|
+
onAction(action) {
|
|
32
|
+
props?.onAction?.(action, ...args);
|
|
33
|
+
resolve(action);
|
|
34
|
+
},
|
|
35
|
+
onConfirm() {
|
|
36
|
+
props?.onConfirm?.(...args);
|
|
37
|
+
resolve(void 0);
|
|
38
|
+
},
|
|
39
|
+
onCancel(e) {
|
|
40
|
+
props?.onCancel?.(e);
|
|
41
|
+
reject();
|
|
42
|
+
},
|
|
43
|
+
onClosed() {
|
|
44
|
+
props?.onClosed?.();
|
|
45
|
+
setStacks(stacks => stacks.filter(stack => stack.key !== key));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
};
|
|
47
52
|
methods.confirm = defineMethods('confirm');
|
|
48
53
|
methods.open = defineMethods('open');
|
|
49
|
-
return stacks.map(
|
|
54
|
+
return stacks.map(p => (0, react_1.createElement)(AppActionSheetStack, { ...p, key: p.key }));
|
|
50
55
|
});
|
|
51
|
-
const AppActionSheetStack = (0,
|
|
52
|
-
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(actionSheet_1.ActionSheet, { showConfirm: type === 'confirm', ...props, open: open, onClose: reason => {
|
|
54
|
-
props.onClose?.(reason);
|
|
55
|
-
setOpen(false);
|
|
56
|
-
} }));
|
|
56
|
+
const AppActionSheetStack = (0, react_2.memo)(({ type, ...props }) => {
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(actionSheet_1.ActionSheet, { showConfirm: type === 'confirm', defaultOpen: true, ...props }));
|
|
57
58
|
});
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppDialog = exports.AppDialogMethods = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const dialog_1 = require("../dialog");
|
|
7
8
|
const status_1 = require("../status");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
8
10
|
class AppDialogMethods {
|
|
9
11
|
async info(props, ...args) {
|
|
10
12
|
}
|
|
@@ -18,33 +20,34 @@ class AppDialogMethods {
|
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
exports.AppDialogMethods = AppDialogMethods;
|
|
21
|
-
exports.AppDialog = (0,
|
|
22
|
-
const [stacks, setStacks] = (0,
|
|
23
|
+
exports.AppDialog = (0, react_2.memo)(({ methods }) => {
|
|
24
|
+
const [stacks, setStacks] = (0, react_2.useState)([]);
|
|
23
25
|
const defineMethod = (type) => {
|
|
24
26
|
return (props, ...args) => {
|
|
25
27
|
return new Promise((resolve, reject) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
const key = (0, utils_1.getRandomId)();
|
|
29
|
+
setStacks(o => {
|
|
30
|
+
return [
|
|
31
|
+
...o,
|
|
32
|
+
{
|
|
33
|
+
...props,
|
|
34
|
+
key,
|
|
35
|
+
type,
|
|
36
|
+
onConfirm: async () => {
|
|
37
|
+
await props.onConfirm?.(...args);
|
|
38
|
+
resolve();
|
|
39
|
+
},
|
|
40
|
+
onCancel: () => {
|
|
41
|
+
props.onCancel?.(...args);
|
|
42
|
+
reject();
|
|
43
|
+
},
|
|
44
|
+
onClosed: () => {
|
|
45
|
+
props.onClosed?.();
|
|
46
|
+
setStacks(stacks => stacks.filter(stack => stack.key !== key));
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
];
|
|
50
|
+
});
|
|
48
51
|
});
|
|
49
52
|
};
|
|
50
53
|
};
|
|
@@ -53,14 +56,10 @@ exports.AppDialog = (0, react_1.memo)(({ methods }) => {
|
|
|
53
56
|
methods.warning = defineMethod('warning');
|
|
54
57
|
methods.error = defineMethod('error');
|
|
55
58
|
methods.confirm = defineMethod('confirm');
|
|
56
|
-
return stacks.map(
|
|
57
|
-
return (0,
|
|
59
|
+
return stacks.map(p => {
|
|
60
|
+
return (0, react_1.createElement)(AppDialogStack, { ...p, key: p.key });
|
|
58
61
|
});
|
|
59
62
|
});
|
|
60
|
-
const AppDialogStack = (0,
|
|
61
|
-
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)(dialog_1.Dialog, { width: 360, maskClosable: false, icon: (0, jsx_runtime_1.jsx)(status_1.StatusIcon, { status: type }), showCancel: type === 'confirm', showClose: false, confirmText: type === 'confirm' ? void 0 : '知道了', ...props, open: open, onClose: reason => {
|
|
63
|
-
props.onClose?.(reason);
|
|
64
|
-
setOpen(false);
|
|
65
|
-
}, children: content }));
|
|
63
|
+
const AppDialogStack = (0, react_2.memo)(({ type, content, ...props }) => {
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)(dialog_1.Dialog, { width: 360, maskClosable: false, icon: (0, jsx_runtime_1.jsx)(status_1.StatusIcon, { status: type }), showCancel: type === 'confirm', showClose: false, confirmText: type === 'confirm' ? void 0 : '知道了', defaultOpen: true, ...props, children: content }));
|
|
66
65
|
});
|
|
@@ -137,7 +137,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
137
137
|
}, [rules, required]);
|
|
138
138
|
const [randomKey] = (0, utils_1.useDerivedState)(prev => {
|
|
139
139
|
// fieldValue变为undefined时,需要更新key以强制重渲染组件
|
|
140
|
-
return !prev || typeof fieldValue === 'undefined' ? (0, utils_1.
|
|
140
|
+
return !prev || typeof fieldValue === 'undefined' ? (0, utils_1.getRandomId)() : prev;
|
|
141
141
|
}, [fieldValue]);
|
|
142
142
|
const renderedChildren = (0, react_1.useMemo)(() => {
|
|
143
143
|
if (typeof children === 'function') {
|
|
@@ -47,7 +47,7 @@ exports.SnackbarBase = (0, react_2.memo)(({ methods, useTo, max = useTo === 'mes
|
|
|
47
47
|
: { content: props };
|
|
48
48
|
const { placement = useTo === 'message' ? 'top' : 'topRight', duration = useTo === 'message' ? 3000 : 5000, ...restProps } = propsObject;
|
|
49
49
|
const index = placementToIndex[placement];
|
|
50
|
-
let id = (0, utils_1.
|
|
50
|
+
let id = (0, utils_1.getRandomId)();
|
|
51
51
|
const onCloseButtonClick = () => {
|
|
52
52
|
!isUnmounted.current && setStacks(o => {
|
|
53
53
|
o[index] = o[index].filter(s => s.id !== id);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Ref, ReactNode, ElementType, ComponentProps } from 'react';
|
|
2
2
|
import { Id, Obj } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param namespace
|
|
4
|
+
* 获取UUID
|
|
6
5
|
*/
|
|
7
|
-
export declare function
|
|
8
|
-
/**
|
|
9
|
-
* 获取任意长度由随机字母组成的ID
|
|
10
|
-
* @param length
|
|
11
|
-
*/
|
|
12
|
-
export declare function getShortID(length?: number): string;
|
|
6
|
+
export declare function getRandomId(): `${string}-${string}-${string}-${string}-${string}`;
|
|
13
7
|
/**
|
|
14
8
|
* 拼接元素的类名
|
|
15
9
|
* @param classes
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.getShortID = getShortID;
|
|
3
|
+
exports.getRandomId = getRandomId;
|
|
5
4
|
exports.clsx = clsx;
|
|
6
5
|
exports.humpToSegmented = humpToSegmented;
|
|
7
6
|
exports.toArray = toArray;
|
|
@@ -26,24 +25,10 @@ exports.queryDeep = queryDeep;
|
|
|
26
25
|
exports.filterProperties = filterProperties;
|
|
27
26
|
exports.mergeComponentProps = mergeComponentProps;
|
|
28
27
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param namespace
|
|
28
|
+
* 获取UUID
|
|
31
29
|
*/
|
|
32
|
-
function
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
const randomIdAlphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
|
|
36
|
-
/**
|
|
37
|
-
* 获取任意长度由随机字母组成的ID
|
|
38
|
-
* @param length
|
|
39
|
-
*/
|
|
40
|
-
function getShortID(length = 8) {
|
|
41
|
-
const { length: alphabetLength } = randomIdAlphabet;
|
|
42
|
-
let id = '';
|
|
43
|
-
while (length--) {
|
|
44
|
-
id += randomIdAlphabet[Math.floor(Math.random() * alphabetLength)];
|
|
45
|
-
}
|
|
46
|
-
return id;
|
|
30
|
+
function getRandomId() {
|
|
31
|
+
return crypto.randomUUID();
|
|
47
32
|
}
|
|
48
33
|
/**
|
|
49
34
|
* 拼接元素的类名
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
2
3
|
import { isValidElement, memo, useState } from 'react';
|
|
3
4
|
import { ActionSheet } from '../actionSheet';
|
|
5
|
+
import { getRandomId } from '../../utils';
|
|
4
6
|
export class AppActionSheetMethods {
|
|
5
7
|
async confirm() {
|
|
6
8
|
}
|
|
@@ -9,45 +11,44 @@ export class AppActionSheetMethods {
|
|
|
9
11
|
}
|
|
10
12
|
export const AppActionSheet = memo(({ methods }) => {
|
|
11
13
|
const [stacks, setStacks] = useState([]);
|
|
12
|
-
const defineMethods = (type) =>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
const defineMethods = (type) => {
|
|
15
|
+
return (params, ...args) => {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const props = typeof params !== 'object' || isValidElement(params)
|
|
18
|
+
? { title: params }
|
|
19
|
+
: params;
|
|
20
|
+
const key = getRandomId();
|
|
21
|
+
setStacks(o => [
|
|
22
|
+
...o,
|
|
23
|
+
{
|
|
24
|
+
...props,
|
|
25
|
+
key,
|
|
26
|
+
type,
|
|
27
|
+
onAction(action) {
|
|
28
|
+
props?.onAction?.(action, ...args);
|
|
29
|
+
resolve(action);
|
|
30
|
+
},
|
|
31
|
+
onConfirm() {
|
|
32
|
+
props?.onConfirm?.(...args);
|
|
33
|
+
resolve(void 0);
|
|
34
|
+
},
|
|
35
|
+
onCancel(e) {
|
|
36
|
+
props?.onCancel?.(e);
|
|
37
|
+
reject();
|
|
38
|
+
},
|
|
39
|
+
onClosed() {
|
|
40
|
+
props?.onClosed?.();
|
|
41
|
+
setStacks(stacks => stacks.filter(stack => stack.key !== key));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
};
|
|
43
48
|
methods.confirm = defineMethods('confirm');
|
|
44
49
|
methods.open = defineMethods('open');
|
|
45
|
-
return stacks.map(
|
|
50
|
+
return stacks.map(p => _createElement(AppActionSheetStack, { ...p, key: p.key }));
|
|
46
51
|
});
|
|
47
52
|
const AppActionSheetStack = memo(({ type, ...props }) => {
|
|
48
|
-
|
|
49
|
-
return (_jsx(ActionSheet, { showConfirm: type === 'confirm', ...props, open: open, onClose: reason => {
|
|
50
|
-
props.onClose?.(reason);
|
|
51
|
-
setOpen(false);
|
|
52
|
-
} }));
|
|
53
|
+
return (_jsx(ActionSheet, { showConfirm: type === 'confirm', defaultOpen: true, ...props }));
|
|
53
54
|
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
2
3
|
import { memo, useState } from 'react';
|
|
3
4
|
import { Dialog } from '../dialog';
|
|
4
5
|
import { StatusIcon } from '../status';
|
|
6
|
+
import { getRandomId } from '../../utils';
|
|
5
7
|
export class AppDialogMethods {
|
|
6
8
|
async info(props, ...args) {
|
|
7
9
|
}
|
|
@@ -19,28 +21,29 @@ export const AppDialog = memo(({ methods }) => {
|
|
|
19
21
|
const defineMethod = (type) => {
|
|
20
22
|
return (props, ...args) => {
|
|
21
23
|
return new Promise((resolve, reject) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
const key = getRandomId();
|
|
25
|
+
setStacks(o => {
|
|
26
|
+
return [
|
|
27
|
+
...o,
|
|
28
|
+
{
|
|
29
|
+
...props,
|
|
30
|
+
key,
|
|
31
|
+
type,
|
|
32
|
+
onConfirm: async () => {
|
|
33
|
+
await props.onConfirm?.(...args);
|
|
34
|
+
resolve();
|
|
35
|
+
},
|
|
36
|
+
onCancel: () => {
|
|
37
|
+
props.onCancel?.(...args);
|
|
38
|
+
reject();
|
|
39
|
+
},
|
|
40
|
+
onClosed: () => {
|
|
41
|
+
props.onClosed?.();
|
|
42
|
+
setStacks(stacks => stacks.filter(stack => stack.key !== key));
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
];
|
|
46
|
+
});
|
|
44
47
|
});
|
|
45
48
|
};
|
|
46
49
|
};
|
|
@@ -49,14 +52,10 @@ export const AppDialog = memo(({ methods }) => {
|
|
|
49
52
|
methods.warning = defineMethod('warning');
|
|
50
53
|
methods.error = defineMethod('error');
|
|
51
54
|
methods.confirm = defineMethod('confirm');
|
|
52
|
-
return stacks.map(
|
|
53
|
-
return
|
|
55
|
+
return stacks.map(p => {
|
|
56
|
+
return _createElement(AppDialogStack, { ...p, key: p.key });
|
|
54
57
|
});
|
|
55
58
|
});
|
|
56
59
|
const AppDialogStack = memo(({ type, content, ...props }) => {
|
|
57
|
-
|
|
58
|
-
return (_jsx(Dialog, { width: 360, maskClosable: false, icon: _jsx(StatusIcon, { status: type }), showCancel: type === 'confirm', showClose: false, confirmText: type === 'confirm' ? void 0 : '知道了', ...props, open: open, onClose: reason => {
|
|
59
|
-
props.onClose?.(reason);
|
|
60
|
-
setOpen(false);
|
|
61
|
-
}, children: content }));
|
|
60
|
+
return (_jsx(Dialog, { width: 360, maskClosable: false, icon: _jsx(StatusIcon, { status: type }), showCancel: type === 'confirm', showClose: false, confirmText: type === 'confirm' ? void 0 : '知道了', defaultOpen: true, ...props, children: content }));
|
|
62
61
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { cloneElement, isValidElement, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
3
3
|
import { useFormContext, useFormStyleContext, useFormValueContext } from './form';
|
|
4
|
-
import { clsx, getValueOnChange, queryDeep, stringifyField, useDerivedState, toArray,
|
|
4
|
+
import { clsx, getValueOnChange, queryDeep, stringifyField, useDerivedState, toArray, getRandomId, isUnset, useStrictMemo } from '../../utils';
|
|
5
5
|
import { DescriptionItem } from '../descriptions';
|
|
6
6
|
import { classes } from './form.style';
|
|
7
7
|
import { Collapse } from '../transitionBase';
|
|
@@ -134,7 +134,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
134
134
|
}, [rules, required]);
|
|
135
135
|
const [randomKey] = useDerivedState(prev => {
|
|
136
136
|
// fieldValue变为undefined时,需要更新key以强制重渲染组件
|
|
137
|
-
return !prev || typeof fieldValue === 'undefined' ?
|
|
137
|
+
return !prev || typeof fieldValue === 'undefined' ? getRandomId() : prev;
|
|
138
138
|
}, [fieldValue]);
|
|
139
139
|
const renderedChildren = useMemo(() => {
|
|
140
140
|
if (typeof children === 'function') {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
2
2
|
import { createElement as _createElement } from "@emotion/react";
|
|
3
3
|
import { isValidElement, memo, useRef, useState } from 'react';
|
|
4
4
|
import { Collapse, Slide } from '../transitionBase';
|
|
5
|
-
import { clsx,
|
|
5
|
+
import { clsx, getRandomId, useColor, useContainer, useUnmounted } from '../../utils';
|
|
6
6
|
import { classes, style } from './snackbarBase.style';
|
|
7
7
|
import { TransitionGroup } from 'react-transition-group';
|
|
8
8
|
import { StatusIcon, statusMapToIconDefinition } from '../status';
|
|
@@ -43,7 +43,7 @@ export const SnackbarBase = memo(({ methods, useTo, max = useTo === 'message' ?
|
|
|
43
43
|
: { content: props };
|
|
44
44
|
const { placement = useTo === 'message' ? 'top' : 'topRight', duration = useTo === 'message' ? 3000 : 5000, ...restProps } = propsObject;
|
|
45
45
|
const index = placementToIndex[placement];
|
|
46
|
-
let id =
|
|
46
|
+
let id = getRandomId();
|
|
47
47
|
const onCloseButtonClick = () => {
|
|
48
48
|
!isUnmounted.current && setStacks(o => {
|
|
49
49
|
o[index] = o[index].filter(s => s.id !== id);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { memo, useImperativeHandle, useRef } from 'react';
|
|
3
3
|
import { classes, style } from './upload.style';
|
|
4
|
-
import { clsx,
|
|
4
|
+
import { clsx, getRandomId, onDndDragEnd, useControlled, useDndSensors, mergeComponentProps } from '../../utils';
|
|
5
5
|
import { Button } from '../button';
|
|
6
6
|
import { FileItem } from './fileItem';
|
|
7
7
|
import { TransitionGroup } from 'react-transition-group';
|
|
@@ -17,7 +17,7 @@ import { faUpload } from '@fortawesome/free-solid-svg-icons/faUpload';
|
|
|
17
17
|
const markFileId = (files) => {
|
|
18
18
|
if (files) {
|
|
19
19
|
for (const file of files) {
|
|
20
|
-
file.id ||=
|
|
20
|
+
file.id ||= getRandomId();
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { Ref, ReactNode, ElementType, ComponentProps } from 'react';
|
|
2
2
|
import { Id, Obj } from '../types';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param namespace
|
|
4
|
+
* 获取UUID
|
|
6
5
|
*/
|
|
7
|
-
export declare function
|
|
8
|
-
/**
|
|
9
|
-
* 获取任意长度由随机字母组成的ID
|
|
10
|
-
* @param length
|
|
11
|
-
*/
|
|
12
|
-
export declare function getShortID(length?: number): string;
|
|
6
|
+
export declare function getRandomId(): `${string}-${string}-${string}-${string}-${string}`;
|
|
13
7
|
/**
|
|
14
8
|
* 拼接元素的类名
|
|
15
9
|
* @param classes
|
package/dist/esm/utils/utils.js
CHANGED
|
@@ -1,22 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @param namespace
|
|
2
|
+
* 获取UUID
|
|
4
3
|
*/
|
|
5
|
-
export function
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
const randomIdAlphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';
|
|
9
|
-
/**
|
|
10
|
-
* 获取任意长度由随机字母组成的ID
|
|
11
|
-
* @param length
|
|
12
|
-
*/
|
|
13
|
-
export function getShortID(length = 8) {
|
|
14
|
-
const { length: alphabetLength } = randomIdAlphabet;
|
|
15
|
-
let id = '';
|
|
16
|
-
while (length--) {
|
|
17
|
-
id += randomIdAlphabet[Math.floor(Math.random() * alphabetLength)];
|
|
18
|
-
}
|
|
19
|
-
return id;
|
|
4
|
+
export function getRandomId() {
|
|
5
|
+
return crypto.randomUUID();
|
|
20
6
|
}
|
|
21
7
|
/**
|
|
22
8
|
* 拼接元素的类名
|
|
@@ -7334,7 +7334,7 @@ If it declares any Font Awesome CSS pseudo-elements, they will not be rendered a
|
|
|
7334
7334
|
flex-wrap: wrap;
|
|
7335
7335
|
column-gap: var(--waterfall-column-gap);
|
|
7336
7336
|
}
|
|
7337
|
-
`)}const fUt=({ref:a,onLoad:u,child:_})=>{const g=Te.useRef(null);Te.useEffect(()=>{const E=g.current;if(!E)throw Error("Children of <Waterfall> must expose 'ref' prop");const w=E.querySelectorAll("img");if(!w.length){u();return}Promise.all([...w].map(R=>{if(!R.complete)return new Promise(z=>{R.addEventListener("load",z,{once:!0})})})).then(()=>u())});const v=Te.useCallback(gd(_.props.ref,g,a),[_.props.ref,a]);return Te.cloneElement(_,{ref:v,className:ca(Wrt.item,_.props.className),style:{width:"calc((100% - var(--waterfall-column-gap) * (var(--waterfall-columnCount) - 1)) / var(--waterfall-columnCount))",paddingBottom:"var(--waterfall-row-gap)",..._.props.style}})},_Ut=({columnCount:a={xs:4},gap:u=0,columnGap:_,rowGap:g,...v})=>{a=pE(a),u=pE(u),_=pE(_)??u,g=pE(g)??u;const E=vce(a),w=Te.useRef(null),R=Te.useRef([]);R.current=[];const z=()=>{const j=Array(E.current).fill(0);R.current.forEach(Se=>{const ie=j.indexOf(Math.min(...j));j[ie]+=Se.offsetHeight,Se.style.order=ie+""}),w.current.style.height=Math.max(...j)+1+"px"},$=Te.useRef(void 0);$.current||=new ResizeObserver(z);const Z=[];return Te.useLayoutEffect(()=>{Promise.all(Z).then(()=>{R.current.forEach(j=>$.current.observe(j))})}),XCe(z,[E.current]),iU(()=>{},()=>{$.current.disconnect()}),we("div",{...v,ref:gd(w,v.ref),css:uUt({columnCount:a,columnGap:_,rowGap:g}),className:ca(Wrt.root,v.className),children:Te.Children.map(v.children,j=>{if(!Te.isValidElement(j))throw Error("Children of <Waterfall> must be element");let Se;return Z.push(new Promise(ie=>Se=ie)),we(fUt,{ref:ie=>{ie&&R.current.push(ie)},child:j,onLoad:Se})})})},qrt=Object.freeze(Object.defineProperty({__proto__:null,Accordion:rBt,ActionSheet:Bnt,Alert:$we,AnchorList:Unt,App:Oz,Autocomplete:PBt,Avatar:Zoe,AvatarGroup:Znt,Backdrop:hnt,Badge:LBt,BottomNavigation:BBt,BottomNavigationItem:Knt,Boundary:nrt,Breadcrumb:rrt,Bubble:fU,BubbleConfirm:irt,Button:qo,CONTROL_COLUMN_KEY:Xoe,Calendar:srt,Card:cjt,Cascade:pjt,Checkbox:x6,CheckboxBase:Awe,CheckboxBaseGroup:wwe,CheckboxGroup:pnt,ClickAway:Swe,Collapse:ax,ColorPicker:_rt,ContextMenu:yjt,Counter:Tjt,Curd:$ce,CurdDialog:yrt,CurdFilterable:Gwe,CurdResizable:mrt,DEFAULT_DARK:Wet,DEFAULT_LIGHT:Jet,DataGrid:KN,DateTimePicker:Trt,DateTimeRangePicker:Xjt,Deferred:Qjt,DescriptionItem:Mce,Descriptions:Mwe,Dialog:GY,Divider:YY,Draggable:Vnt,Drawer:ezt,DropArea:rAe,Dropdown:nzt,ErrorBoundary:VEe,Fade:awe,Flex:Jh,Form:t8,FormDialog:rzt,FormItem:aD,FormRelatable:wnt,Gallery:Xwe,Grid:Lce,GridItem:Lwe,Grow:swe,Highlight:Pce,Icon:ds,Image:Qwe,ImageItem:krt,InnerApp:Qnt,Input:hw,InputBase:UF,Loading:qY,LoadingIndicator:GO,LoadingMask:ynt,Menu:aMt,MenuItem:rb,Modal:Vwe,Option:hMt,OptionsBase:uU,OverlayBase:jce,Pagination:JF,PaginationCounter:Pwe,PaginationJumper:Iwe,PaginationPager:vwe,PaginationSizer:Dwe,Palette:frt,PickerDialog:hrt,Pinchable:xrt,Placeholder:lU,Popper:gw,PopperContext:Twe,Progress:Fce,Radio:Rce,RadioGroup:unt,Rating:Szt,Resizable:kzt,Scrollbar:Czt,Segmented:Vce,Select:Nwe,SelectedList:grt,SelectionContext:Sce,SerialInput:Nzt,Skeleton:rx,SkeletonCard:jnt,SkeletonTable:znt,SlidableActions:Art,SlidableActionsAction:Zwe,Slide:xce,Slider:Koe,SnackbarBase:Wwe,SnackbarBaseItem:Wnt,SnackbarBaseMethods:Jwe,SortableItem:ece,Status:mBt,StatusIcon:Uce,Step:Kwe,Stepper:Irt,Switch:Mzt,Table:ZO,TableContainer:Rwe,TableRow:Tnt,Tabs:tAe,Tag:Ewe,TdCell:Goe,Textarea:ont,ThCell:Yoe,ThemeContext:HCe,ThemeProvider:Het,Timeline:Mrt,Timer:vrt,ToggleButton:qzt,Tooltip:fy,TouchRipple:Yzt,Transfer:Qzt,TransitionBase:oU,TransportStyle:Oce,Tree:nAe,TreeNode:Jce,TreeSelect:XEe,Typography:Pu,Upload:Jrt,Waterfall:_Ut,arrayShallowEqual:FCe,cloneDeep:Hz,cloneRef:gd,clsx:ca,colorTransfer:aU,columnsToFilterItem:Rnt,columnsToFormItem:Fnt,cubicBezier:p6,defaultBreakpoints:$Ce,defaultDarkTheme:VCe,defaultFontFamily:$et,defaultLightTheme:mce,defaultMonospaceFontFamily:Vet,defineClasses:T7t,defineCss:Mo,defineInnerClasses:ms,definePrefix:ZCe,defineTheme:JCe,edgeBounce:$oe,filterProperties:jCe,findPredecessor:MCe,fixInputNumber:Uoe,getEasyID:Fet,getPromiseState:Met,
|
|
7337
|
+
`)}const fUt=({ref:a,onLoad:u,child:_})=>{const g=Te.useRef(null);Te.useEffect(()=>{const E=g.current;if(!E)throw Error("Children of <Waterfall> must expose 'ref' prop");const w=E.querySelectorAll("img");if(!w.length){u();return}Promise.all([...w].map(R=>{if(!R.complete)return new Promise(z=>{R.addEventListener("load",z,{once:!0})})})).then(()=>u())});const v=Te.useCallback(gd(_.props.ref,g,a),[_.props.ref,a]);return Te.cloneElement(_,{ref:v,className:ca(Wrt.item,_.props.className),style:{width:"calc((100% - var(--waterfall-column-gap) * (var(--waterfall-columnCount) - 1)) / var(--waterfall-columnCount))",paddingBottom:"var(--waterfall-row-gap)",..._.props.style}})},_Ut=({columnCount:a={xs:4},gap:u=0,columnGap:_,rowGap:g,...v})=>{a=pE(a),u=pE(u),_=pE(_)??u,g=pE(g)??u;const E=vce(a),w=Te.useRef(null),R=Te.useRef([]);R.current=[];const z=()=>{const j=Array(E.current).fill(0);R.current.forEach(Se=>{const ie=j.indexOf(Math.min(...j));j[ie]+=Se.offsetHeight,Se.style.order=ie+""}),w.current.style.height=Math.max(...j)+1+"px"},$=Te.useRef(void 0);$.current||=new ResizeObserver(z);const Z=[];return Te.useLayoutEffect(()=>{Promise.all(Z).then(()=>{R.current.forEach(j=>$.current.observe(j))})}),XCe(z,[E.current]),iU(()=>{},()=>{$.current.disconnect()}),we("div",{...v,ref:gd(w,v.ref),css:uUt({columnCount:a,columnGap:_,rowGap:g}),className:ca(Wrt.root,v.className),children:Te.Children.map(v.children,j=>{if(!Te.isValidElement(j))throw Error("Children of <Waterfall> must be element");let Se;return Z.push(new Promise(ie=>Se=ie)),we(fUt,{ref:ie=>{ie&&R.current.push(ie)},child:j,onLoad:Se})})})},qrt=Object.freeze(Object.defineProperty({__proto__:null,Accordion:rBt,ActionSheet:Bnt,Alert:$we,AnchorList:Unt,App:Oz,Autocomplete:PBt,Avatar:Zoe,AvatarGroup:Znt,Backdrop:hnt,Badge:LBt,BottomNavigation:BBt,BottomNavigationItem:Knt,Boundary:nrt,Breadcrumb:rrt,Bubble:fU,BubbleConfirm:irt,Button:qo,CONTROL_COLUMN_KEY:Xoe,Calendar:srt,Card:cjt,Cascade:pjt,Checkbox:x6,CheckboxBase:Awe,CheckboxBaseGroup:wwe,CheckboxGroup:pnt,ClickAway:Swe,Collapse:ax,ColorPicker:_rt,ContextMenu:yjt,Counter:Tjt,Curd:$ce,CurdDialog:yrt,CurdFilterable:Gwe,CurdResizable:mrt,DEFAULT_DARK:Wet,DEFAULT_LIGHT:Jet,DataGrid:KN,DateTimePicker:Trt,DateTimeRangePicker:Xjt,Deferred:Qjt,DescriptionItem:Mce,Descriptions:Mwe,Dialog:GY,Divider:YY,Draggable:Vnt,Drawer:ezt,DropArea:rAe,Dropdown:nzt,ErrorBoundary:VEe,Fade:awe,Flex:Jh,Form:t8,FormDialog:rzt,FormItem:aD,FormRelatable:wnt,Gallery:Xwe,Grid:Lce,GridItem:Lwe,Grow:swe,Highlight:Pce,Icon:ds,Image:Qwe,ImageItem:krt,InnerApp:Qnt,Input:hw,InputBase:UF,Loading:qY,LoadingIndicator:GO,LoadingMask:ynt,Menu:aMt,MenuItem:rb,Modal:Vwe,Option:hMt,OptionsBase:uU,OverlayBase:jce,Pagination:JF,PaginationCounter:Pwe,PaginationJumper:Iwe,PaginationPager:vwe,PaginationSizer:Dwe,Palette:frt,PickerDialog:hrt,Pinchable:xrt,Placeholder:lU,Popper:gw,PopperContext:Twe,Progress:Fce,Radio:Rce,RadioGroup:unt,Rating:Szt,Resizable:kzt,Scrollbar:Czt,Segmented:Vce,Select:Nwe,SelectedList:grt,SelectionContext:Sce,SerialInput:Nzt,Skeleton:rx,SkeletonCard:jnt,SkeletonTable:znt,SlidableActions:Art,SlidableActionsAction:Zwe,Slide:xce,Slider:Koe,SnackbarBase:Wwe,SnackbarBaseItem:Wnt,SnackbarBaseMethods:Jwe,SortableItem:ece,Status:mBt,StatusIcon:Uce,Step:Kwe,Stepper:Irt,Switch:Mzt,Table:ZO,TableContainer:Rwe,TableRow:Tnt,Tabs:tAe,Tag:Ewe,TdCell:Goe,Textarea:ont,ThCell:Yoe,ThemeContext:HCe,ThemeProvider:Het,Timeline:Mrt,Timer:vrt,ToggleButton:qzt,Tooltip:fy,TouchRipple:Yzt,Transfer:Qzt,TransitionBase:oU,TransportStyle:Oce,Tree:nAe,TreeNode:Jce,TreeSelect:XEe,Typography:Pu,Upload:Jrt,Waterfall:_Ut,arrayShallowEqual:FCe,cloneDeep:Hz,cloneRef:gd,clsx:ca,colorTransfer:aU,columnsToFilterItem:Rnt,columnsToFormItem:Fnt,cubicBezier:p6,defaultBreakpoints:$Ce,defaultDarkTheme:VCe,defaultFontFamily:$et,defaultLightTheme:mce,defaultMonospaceFontFamily:Vet,defineClasses:T7t,defineCss:Mo,defineInnerClasses:ms,definePrefix:ZCe,defineTheme:JCe,edgeBounce:$oe,filterProperties:jCe,findPredecessor:MCe,fixInputNumber:Uoe,getEasyID:Fet,getPromiseState:Met,getRandomId:RCe,getTheme:yEe,getValueOnChange:pEe,humpToSegmented:SY,imagePreset:Noe,isChildOf:LCe,isElementOverflowed:_Ee,isNoValue:dce,isPromise:Let,isSelected:qO,isUnset:gu,joinNodes:zoe,listenAllPredecessorsScroll:BCe,mergeComponentProps:su,mergeDeep:TY,nextTick:r7t,onDndDragEnd:UCe,onTreeNodeSort:i7t,overlayBaseTransitionDuration:Uwe,queryDeep:HN,range:ex,registerTheme:qCe,renderCell:zwe,responsiveStyles:KCe,responsiveVariables:jY,restoreThemeDefinition:qet,setDefaultColumnKey:Bce,sortTreeNodes:k7t,statusMapToIconDefinition:zce,stringifyField:jz,themeMap:WCe,toArray:nb,toResponsiveValue:pE,useAppContext:Xnt,useAvatarStyle:qwe,useBoundaryContext:VBt,useCascadeContext:urt,useCheckboxBaseGroupContext:_nt,useColor:Im,useColumnMap:jwe,useContainer:BY,useControlled:dc,useCss:__,useCurdColumns:Mnt,useDataGridColumns:Ont,useDataGridContext:Pnt,useDateTimePickerContext:Srt,useDerivedState:k0,useDescriptionsContext:Cnt,useDndSensors:zCe,useDraggable:dw,useEscapeClosable:QCe,useExternalClass:iU,useFlatSelection:sU,useForceUpdate:GCe,useFormContext:e8,useFormStyleContext:Bwe,useFormValueContext:_U,useGesture:gce,useKeyboard:hce,useLoading:pw,useMenuContext:mnt,useMounted:b7t,usePaginationContext:HY,usePinchable:S7t,usePopperContext:$F,useResponsiveValue:vce,useScrollToTarget:xwe,useSelection:bce,useSelectionContext:KO,useSlidableActionsContext:wrt,useStatusColor:ewe,useStepperContext:Drt,useStrictEffect:YCe,useStrictMemo:Get,useSync:am,useSyncState:HO,useTabsContext:eAe,useTheme:Jl,useTimelineContext:Lrt,useTouchSpread:yce,useTransferContext:jrt,useTreeContext:$rt,useTreeSearch:Yet,useUnmounted:MY,useUpdateEffect:XCe,zIndex:b6},Symbol.toStringTag,{value:"Module"})),pUt=Mo(({mode:a})=>Ji`
|
|
7338
7338
|
html, body {
|
|
7339
7339
|
margin: 0;
|
|
7340
7340
|
}
|