@canlooks/can-ui 0.0.67 → 0.0.68
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/anchorList/anchorList.js +26 -20
- package/dist/cjs/components/cascade/cascade.js +2 -2
- package/dist/cjs/components/curd/curdColumnConfig.js +2 -1
- package/dist/cjs/components/dataGrid/dataGrid.js +3 -2
- package/dist/cjs/components/gallery/gallery.js +2 -2
- package/dist/cjs/components/menu/menu.js +2 -2
- package/dist/cjs/components/overlayBase/overlayBase.d.ts +3 -1
- package/dist/cjs/components/overlayBase/overlayBase.js +5 -5
- package/dist/cjs/components/popper/popper.d.ts +3 -1
- package/dist/cjs/components/popper/popper.js +6 -6
- package/dist/cjs/components/progress/progress.js +4 -2
- package/dist/cjs/components/snackbarBase/snackbarBase.d.ts +3 -2
- package/dist/cjs/components/snackbarBase/snackbarBase.js +3 -3
- package/dist/cjs/components/theme/themeVariables.d.ts +1 -0
- package/dist/cjs/components/theme/themeVariables.js +1 -0
- package/dist/cjs/components/touchRipple/index.d.ts +1 -0
- package/dist/cjs/components/touchRipple/index.js +1 -0
- package/dist/cjs/components/touchRipple/touchRipple.d.ts +6 -14
- package/dist/cjs/components/touchRipple/touchRipple.js +54 -39
- package/dist/cjs/components/touchRipple/touchRipple.style.js +25 -27
- package/dist/cjs/components/transfer/transfer.js +2 -2
- package/dist/cjs/components/transfer/transferPanel.js +2 -1
- package/dist/cjs/components/upload/upload.js +2 -2
- package/dist/cjs/components/waterfall/waterfallItem.js +1 -1
- package/dist/cjs/utils/hooks.d.ts +8 -0
- package/dist/cjs/utils/hooks.js +22 -0
- package/dist/esm/components/anchorList/anchorList.js +26 -20
- package/dist/esm/components/cascade/cascade.js +2 -2
- package/dist/esm/components/curd/curdColumnConfig.js +2 -1
- package/dist/esm/components/dataGrid/dataGrid.js +3 -2
- package/dist/esm/components/gallery/gallery.js +2 -2
- package/dist/esm/components/menu/menu.js +2 -2
- package/dist/esm/components/overlayBase/overlayBase.d.ts +3 -1
- package/dist/esm/components/overlayBase/overlayBase.js +6 -6
- package/dist/esm/components/popper/popper.d.ts +3 -1
- package/dist/esm/components/popper/popper.js +7 -7
- package/dist/esm/components/progress/progress.js +4 -2
- package/dist/esm/components/snackbarBase/snackbarBase.d.ts +3 -2
- package/dist/esm/components/snackbarBase/snackbarBase.js +4 -4
- package/dist/esm/components/theme/themeVariables.d.ts +1 -0
- package/dist/esm/components/theme/themeVariables.js +1 -0
- package/dist/esm/components/touchRipple/index.d.ts +1 -0
- package/dist/esm/components/touchRipple/index.js +1 -0
- package/dist/esm/components/touchRipple/touchRipple.d.ts +6 -14
- package/dist/esm/components/touchRipple/touchRipple.js +54 -39
- package/dist/esm/components/touchRipple/touchRipple.style.js +25 -27
- package/dist/esm/components/transfer/transfer.js +2 -2
- package/dist/esm/components/transfer/transferPanel.js +2 -1
- package/dist/esm/components/upload/upload.js +2 -2
- package/dist/esm/components/waterfall/waterfallItem.js +2 -2
- package/dist/esm/utils/hooks.d.ts +8 -0
- package/dist/esm/utils/hooks.js +21 -0
- package/package.json +1 -1
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
import { css, keyframes } from '@emotion/react';
|
|
2
1
|
import { defineInnerClasses, useColor, useCss } from '../../utils';
|
|
2
|
+
import { css, keyframes } from '@emotion/react';
|
|
3
|
+
import { zIndex } from '../theme';
|
|
3
4
|
import Color from 'color';
|
|
4
|
-
export const classes = defineInnerClasses('touch-ripple', [
|
|
5
|
+
export const classes = defineInnerClasses('touch-ripple-overlay', [
|
|
5
6
|
'ripple'
|
|
6
7
|
]);
|
|
7
8
|
export function useStyle({ color }) {
|
|
8
9
|
const colorValue = useColor(color);
|
|
9
|
-
return useCss(({ easing }) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return useCss(({ easing }) => css `
|
|
11
|
+
position: absolute;
|
|
12
|
+
inset: 0;
|
|
13
|
+
z-index: ${zIndex.touchRipple};
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
|
|
17
|
+
.${classes.ripple} {
|
|
18
|
+
aspect-ratio: 1;
|
|
19
|
+
border-radius: 50%;
|
|
20
|
+
background-color: ${Color(colorValue).alpha(.1).string()};
|
|
15
21
|
position: absolute;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
translate: -50% -50%;
|
|
24
|
-
background-color: ${bg};
|
|
25
|
-
animation: ${showRippleAnim} .4s ${easing.easeIn} forwards;
|
|
26
|
-
transition: opacity .4s ${easing.easeIn};
|
|
27
|
-
|
|
28
|
-
&[data-leaving=true] {
|
|
29
|
-
opacity: 0;
|
|
30
|
-
}
|
|
22
|
+
scale: 0;
|
|
23
|
+
translate: -50% -50%;
|
|
24
|
+
animation: ${rippleAnim} .4s ${easing.easeOut} forwards;
|
|
25
|
+
transition: opacity .4s ${easing.easeIn};
|
|
26
|
+
|
|
27
|
+
&[data-leaving=true] {
|
|
28
|
+
opacity: 0;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
}
|
|
31
|
+
`, [colorValue]);
|
|
34
32
|
}
|
|
35
|
-
const
|
|
33
|
+
const rippleAnim = keyframes `
|
|
36
34
|
0% {
|
|
37
35
|
scale: 0;
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
|
|
40
38
|
100% {
|
|
41
39
|
scale: 1;
|
|
42
40
|
}
|
|
@@ -12,8 +12,8 @@ export function useTransferContext() {
|
|
|
12
12
|
const { options = [], primaryKey = 'value', value = [], allowSelectAll = true, showHeader = true } = useContext(TransferContext);
|
|
13
13
|
return { options, primaryKey, value, allowSelectAll, showHeader };
|
|
14
14
|
}
|
|
15
|
-
export const Transfer = memo(({ options
|
|
16
|
-
const [innerValue, setInnerValue] = useControlled(defaultValue, value, onChange);
|
|
15
|
+
export const Transfer = memo(({ options, primaryKey = 'value', fullWidth, allowSelectAll = true, showHeader = true, leftTitle = '选项', rightTitle = '已选', renderButtons, defaultValue, value, onChange, ...props }) => {
|
|
16
|
+
const [innerValue, setInnerValue] = useControlled(defaultValue || [], value, onChange);
|
|
17
17
|
const [leftSelected, setLeftSelected] = useState([]);
|
|
18
18
|
const [rightSelected, setRightSelected] = useState([]);
|
|
19
19
|
const toRight = () => {
|
|
@@ -4,7 +4,8 @@ import { classes } from './transfer.style';
|
|
|
4
4
|
import { Checkbox } from '../checkbox';
|
|
5
5
|
import { useTransferContext } from './transfer';
|
|
6
6
|
import { OptionsBase } from '../optionsBase';
|
|
7
|
-
export const TransferPanel = memo(({ title, type = 'left', selectedValue
|
|
7
|
+
export const TransferPanel = memo(({ title, type = 'left', selectedValue, onChange, renderList, renderItem, ...props }) => {
|
|
8
|
+
selectedValue ||= [];
|
|
8
9
|
const { options, primaryKey, value, allowSelectAll, showHeader } = useTransferContext();
|
|
9
10
|
const selfOptions = useMemo(() => {
|
|
10
11
|
const valueSet = new Set(value);
|
|
@@ -21,7 +21,7 @@ const markFileId = (files) => {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
export const Upload = memo(({ inputProps, type = 'file', accept = type === 'image' ? 'image/*' : void 0, max = Infinity, showButton = true, buttonProps, buttonText = '选择文件', variant = 'square', sortable, droppable, defaultValue
|
|
24
|
+
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 }) => {
|
|
25
25
|
const wrapperRef = useRef(null);
|
|
26
26
|
const itemRefs = useRef(new Map());
|
|
27
27
|
useImperativeHandle(props.ref, () => {
|
|
@@ -51,7 +51,7 @@ export const Upload = memo(({ inputProps, type = 'file', accept = type === 'imag
|
|
|
51
51
|
};
|
|
52
52
|
return wrapperRef.current;
|
|
53
53
|
});
|
|
54
|
-
const [innerValue, setInnerValue] = useControlled(defaultValue, value, value => {
|
|
54
|
+
const [innerValue, setInnerValue] = useControlled(defaultValue || [], value, value => {
|
|
55
55
|
markFileId(value);
|
|
56
56
|
onChange?.(value);
|
|
57
57
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { cloneElement, useCallback,
|
|
1
|
+
import { cloneElement, useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { classes } from './waterfall.style';
|
|
3
3
|
import { cloneRef, clsx } from '../../utils';
|
|
4
4
|
export const WaterfallItem = ({ ref, onLoad, child }) => {
|
|
5
5
|
const innerRef = useRef(null);
|
|
6
|
-
|
|
6
|
+
useEffect(() => {
|
|
7
7
|
const el = innerRef.current;
|
|
8
8
|
if (!el) {
|
|
9
9
|
throw Error(`Children of <Waterfall> must expose 'ref' prop`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RefObject, Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { DefineElement } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* 获取渲染前的值
|
|
4
5
|
* @param value
|
|
@@ -48,3 +49,10 @@ export declare function useLoading<A extends any[], R>(fn: (...args: A) => R | P
|
|
|
48
49
|
(...args: A) => Promise<R>,
|
|
49
50
|
Dispatch<SetStateAction<boolean>>
|
|
50
51
|
];
|
|
52
|
+
/**
|
|
53
|
+
* 获取容器元素,通常用于`container`或`effectContainer`属性
|
|
54
|
+
* @param container
|
|
55
|
+
* @param effectContainer
|
|
56
|
+
* @param defaultContainer 默认为`document.body`
|
|
57
|
+
*/
|
|
58
|
+
export declare function useContainer<T extends HTMLElement | null>(container?: DefineElement<T>, effectContainer?: DefineElement<T>, defaultContainer?: T): RefObject<T>;
|
package/dist/esm/utils/hooks.js
CHANGED
|
@@ -113,3 +113,24 @@ export function useLoading(fn, referredLoading = false) {
|
|
|
113
113
|
setLoading
|
|
114
114
|
];
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* 获取容器元素,通常用于`container`或`effectContainer`属性
|
|
118
|
+
* @param container
|
|
119
|
+
* @param effectContainer
|
|
120
|
+
* @param defaultContainer 默认为`document.body`
|
|
121
|
+
*/
|
|
122
|
+
export function useContainer(container, effectContainer, defaultContainer = document.body) {
|
|
123
|
+
const [containerEl, setContainerEl] = useDerivedState(prev => {
|
|
124
|
+
if (container) {
|
|
125
|
+
return typeof container === 'function' ? container() : container;
|
|
126
|
+
}
|
|
127
|
+
return prev || defaultContainer;
|
|
128
|
+
}, [container, defaultContainer]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (effectContainer) {
|
|
131
|
+
const el = typeof effectContainer === 'function' ? effectContainer() : effectContainer;
|
|
132
|
+
setContainerEl(el);
|
|
133
|
+
}
|
|
134
|
+
}, []);
|
|
135
|
+
return containerEl;
|
|
136
|
+
}
|