@canlooks/can-ui 0.0.41 → 0.0.43
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/alert/alert.style.js +1 -0
- package/dist/cjs/components/checkboxBase/checkboxBase.js +1 -2
- package/dist/cjs/components/checkboxBaseGroup/checkboxBaseGroup.d.ts +0 -2
- package/dist/cjs/components/checkboxBaseGroup/checkboxBaseGroup.js +3 -3
- package/dist/cjs/components/clickAway/clickAway.d.ts +285 -1
- package/dist/cjs/components/clickAway/clickAway.js +1 -2
- package/dist/cjs/components/dataGrid/columnResize.js +5 -5
- package/dist/cjs/components/dataGrid/dataGrid.js +1 -1
- package/dist/cjs/components/dataGrid/dataGridRows.js +3 -1
- package/dist/cjs/components/descriptions/descriptionItem.d.ts +3 -3
- package/dist/cjs/components/draggable/draggable.d.ts +6 -6
- package/dist/cjs/components/draggable/draggable.js +13 -18
- package/dist/cjs/components/{image/imagePreview.d.ts → gallery/gallery.d.ts} +7 -3
- package/dist/cjs/components/gallery/gallery.js +165 -0
- package/dist/{esm/components/image/imagePreview.style.d.ts → cjs/components/gallery/gallery.style.d.ts} +3 -1
- package/dist/cjs/components/{image/imagePreview.style.js → gallery/gallery.style.js} +49 -13
- package/dist/cjs/components/gallery/imageItem.d.ts +14 -0
- package/dist/cjs/components/gallery/imageItem.js +51 -0
- package/dist/cjs/components/gallery/index.d.ts +1 -0
- package/dist/cjs/components/gallery/index.js +4 -0
- package/dist/cjs/components/image/image.d.ts +2 -2
- package/dist/cjs/components/image/image.js +3 -3
- package/dist/cjs/components/image/index.d.ts +0 -1
- package/dist/cjs/components/image/index.js +0 -1
- package/dist/cjs/components/overlayBase/overlayBase.js +1 -1
- package/dist/cjs/components/palette/palette.d.ts +3 -3
- package/dist/cjs/components/palette/palette.js +9 -9
- package/dist/cjs/components/pickerDialog/pickerDialog.style.js +6 -0
- package/dist/cjs/components/pinchable/index.d.ts +1 -0
- package/dist/cjs/components/pinchable/index.js +4 -0
- package/dist/cjs/components/pinchable/pinchable.d.ts +33 -0
- package/dist/cjs/components/pinchable/pinchable.js +160 -0
- package/dist/cjs/components/pinchable/pinchable.style.d.ts +6 -0
- package/dist/cjs/components/pinchable/pinchable.style.js +21 -0
- package/dist/cjs/components/placeholder/placeholder.style.js +1 -0
- package/dist/cjs/components/progress/progress.d.ts +1 -1
- package/dist/cjs/components/rating/rating.d.ts +2 -2
- package/dist/cjs/components/rating/rating.js +2 -5
- package/dist/cjs/components/rating/rating.style.js +1 -2
- package/dist/cjs/components/resizable/resizable.d.ts +2 -2
- package/dist/cjs/components/resizable/resizable.js +12 -12
- package/dist/cjs/components/scrollbar/scrollbar.d.ts +1 -1
- package/dist/cjs/components/scrollbar/scrollbar.js +6 -6
- package/dist/cjs/components/segmented/SegmentedOption.d.ts +1 -1
- package/dist/cjs/components/selectedList/selectedItem.js +1 -1
- package/dist/cjs/components/selectedList/selectedList.style.js +1 -1
- package/dist/cjs/components/skeleton/skeleton.d.ts +1 -1
- package/dist/cjs/components/slidableActions/slidableActions.d.ts +9 -5
- package/dist/cjs/components/slidableActions/slidableActions.js +21 -25
- package/dist/cjs/components/slidableActions/slidableActions.style.d.ts +1 -1
- package/dist/cjs/components/slidableActions/slidableActions.style.js +14 -13
- package/dist/cjs/components/slidableActions/slidableActionsAction.d.ts +4 -2
- package/dist/cjs/components/slidableActions/slidableActionsAction.js +6 -2
- package/dist/cjs/components/slider/slider.d.ts +3 -3
- package/dist/cjs/components/slider/slider.js +8 -8
- package/dist/cjs/components/tabs/tabs.js +1 -1
- package/dist/cjs/components/theme/themeVariables.js +1 -1
- package/dist/cjs/components/upload/itemStatus.d.ts +1 -1
- package/dist/cjs/components/upload/itemStatus.js +3 -0
- package/dist/cjs/components/upload/upload.d.ts +3 -3
- package/dist/cjs/components/upload/upload.js +1 -1
- package/dist/cjs/extensions/documentViewer/documentViewer.js +1 -2
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/utils/dnd.d.ts +0 -42
- package/dist/cjs/utils/dnd.js +0 -121
- package/dist/cjs/utils/gesture.d.ts +69 -0
- package/dist/cjs/utils/gesture.js +250 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/utils/style.js +1 -1
- package/dist/cjs/utils/utils.d.ts +0 -2
- package/dist/cjs/utils/utils.js +0 -2
- package/dist/esm/components/alert/alert.style.js +1 -0
- package/dist/esm/components/checkboxBase/checkboxBase.js +1 -2
- package/dist/esm/components/checkboxBaseGroup/checkboxBaseGroup.d.ts +0 -2
- package/dist/esm/components/checkboxBaseGroup/checkboxBaseGroup.js +4 -4
- package/dist/esm/components/clickAway/clickAway.d.ts +285 -1
- package/dist/esm/components/clickAway/clickAway.js +2 -3
- package/dist/esm/components/dataGrid/columnResize.js +6 -6
- package/dist/esm/components/dataGrid/dataGrid.js +1 -1
- package/dist/esm/components/dataGrid/dataGridRows.js +3 -1
- package/dist/esm/components/descriptions/descriptionItem.d.ts +3 -3
- package/dist/esm/components/draggable/draggable.d.ts +6 -6
- package/dist/esm/components/draggable/draggable.js +14 -19
- package/dist/esm/components/{image/imagePreview.d.ts → gallery/gallery.d.ts} +7 -3
- package/dist/esm/components/gallery/gallery.js +162 -0
- package/dist/{cjs/components/image/imagePreview.style.d.ts → esm/components/gallery/gallery.style.d.ts} +3 -1
- package/dist/esm/components/{image/imagePreview.style.js → gallery/gallery.style.js} +49 -13
- package/dist/esm/components/gallery/imageItem.d.ts +14 -0
- package/dist/esm/components/gallery/imageItem.js +48 -0
- package/dist/esm/components/gallery/index.d.ts +1 -0
- package/dist/esm/components/gallery/index.js +1 -0
- package/dist/esm/components/image/image.d.ts +2 -2
- package/dist/esm/components/image/image.js +3 -3
- package/dist/esm/components/image/index.d.ts +0 -1
- package/dist/esm/components/image/index.js +0 -1
- package/dist/esm/components/overlayBase/overlayBase.js +1 -1
- package/dist/esm/components/palette/palette.d.ts +3 -3
- package/dist/esm/components/palette/palette.js +10 -10
- package/dist/esm/components/pickerDialog/pickerDialog.style.js +6 -0
- package/dist/esm/components/pinchable/index.d.ts +1 -0
- package/dist/esm/components/pinchable/index.js +1 -0
- package/dist/esm/components/pinchable/pinchable.d.ts +33 -0
- package/dist/esm/components/pinchable/pinchable.js +157 -0
- package/dist/esm/components/pinchable/pinchable.style.d.ts +6 -0
- package/dist/esm/components/pinchable/pinchable.style.js +18 -0
- package/dist/esm/components/placeholder/placeholder.style.js +1 -0
- package/dist/esm/components/progress/progress.d.ts +1 -1
- package/dist/esm/components/rating/rating.d.ts +2 -2
- package/dist/esm/components/rating/rating.js +2 -5
- package/dist/esm/components/rating/rating.style.js +1 -2
- package/dist/esm/components/resizable/resizable.d.ts +2 -2
- package/dist/esm/components/resizable/resizable.js +13 -13
- package/dist/esm/components/scrollbar/scrollbar.d.ts +1 -1
- package/dist/esm/components/scrollbar/scrollbar.js +7 -7
- package/dist/esm/components/segmented/SegmentedOption.d.ts +1 -1
- package/dist/esm/components/selectedList/selectedItem.js +1 -1
- package/dist/esm/components/selectedList/selectedList.style.js +1 -1
- package/dist/esm/components/skeleton/skeleton.d.ts +1 -1
- package/dist/esm/components/slidableActions/slidableActions.d.ts +9 -5
- package/dist/esm/components/slidableActions/slidableActions.js +22 -26
- package/dist/esm/components/slidableActions/slidableActions.style.d.ts +1 -1
- package/dist/esm/components/slidableActions/slidableActions.style.js +14 -13
- package/dist/esm/components/slidableActions/slidableActionsAction.d.ts +4 -2
- package/dist/esm/components/slidableActions/slidableActionsAction.js +6 -2
- package/dist/esm/components/slider/slider.d.ts +3 -3
- package/dist/esm/components/slider/slider.js +9 -9
- package/dist/esm/components/tabs/tabs.js +1 -1
- package/dist/esm/components/theme/themeVariables.js +1 -1
- package/dist/esm/components/upload/itemStatus.d.ts +1 -1
- package/dist/esm/components/upload/itemStatus.js +3 -0
- package/dist/esm/components/upload/upload.d.ts +3 -3
- package/dist/esm/components/upload/upload.js +1 -1
- package/dist/esm/extensions/documentViewer/documentViewer.js +2 -3
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/utils/dnd.d.ts +0 -42
- package/dist/esm/utils/dnd.js +0 -120
- package/dist/esm/utils/gesture.d.ts +69 -0
- package/dist/esm/utils/gesture.js +245 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/style.js +1 -1
- package/dist/esm/utils/utils.d.ts +0 -2
- package/dist/esm/utils/utils.js +0 -2
- package/documentation/dist/assets/{index-B6FOULC1.js → index-DXo4Z-bc.js} +1281 -1271
- package/documentation/dist/components/actionSheet.md +3 -3
- package/documentation/dist/components/autocomplete.md +10 -10
- package/documentation/dist/components/breadcrumb.md +1 -1
- package/documentation/dist/components/checkbox.md +24 -1
- package/documentation/dist/components/contextMenu.md +1 -1
- package/documentation/dist/components/counter.md +13 -13
- package/documentation/dist/components/dialog.md +3 -3
- package/documentation/dist/components/formDialog.md +6 -6
- package/documentation/dist/components/image.md +5 -3
- package/documentation/dist/components/menu.md +1 -1
- package/documentation/dist/components/pagination.md +15 -1
- package/documentation/dist/components/pickerDialog.md +56 -0
- package/documentation/dist/components/placeholder.md +30 -0
- package/documentation/dist/components/progress.md +43 -0
- package/documentation/dist/components/radio.md +37 -0
- package/documentation/dist/components/rating.md +35 -0
- package/documentation/dist/components/resizable.md +41 -0
- package/documentation/dist/components/scrollbar.md +31 -0
- package/documentation/dist/components/segmented.md +56 -0
- package/documentation/dist/components/select.md +30 -0
- package/documentation/dist/components/skeleton.md +26 -0
- package/documentation/dist/components/slidableActions.md +53 -0
- package/documentation/dist/guide/globalMethods.md +6 -6
- package/documentation/dist/index.html +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/image/imagePreview.js +0 -63
- package/dist/esm/components/image/imagePreview.js +0 -60
|
@@ -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, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { classes, style } from './palette.style';
|
|
4
|
-
import { clsx, range, useControlled,
|
|
4
|
+
import { clsx, range, useControlled, useDraggable } from '../../utils';
|
|
5
5
|
import { useTheme } from '../theme';
|
|
6
6
|
import { Slider } from '../slider';
|
|
7
7
|
import Color from 'color';
|
|
@@ -18,7 +18,7 @@ const sliderProps = {
|
|
|
18
18
|
tooltipProps: { disabled: true }
|
|
19
19
|
};
|
|
20
20
|
const availableFormat = ['HEX', 'RGB', 'HSL', 'CMYK'];
|
|
21
|
-
export const Palette = memo(({ defaultValue, value, onChange,
|
|
21
|
+
export const Palette = memo(({ defaultValue, value, onChange, gestureOptions, ...props }) => {
|
|
22
22
|
const { colors } = useTheme();
|
|
23
23
|
const [innerValue, setInnerValue] = useControlled(defaultValue ?? Color(colors.primary.main, 'hex'), value, onChange);
|
|
24
24
|
const colorObject = useMemo(() => {
|
|
@@ -48,10 +48,10 @@ export const Palette = memo(({ defaultValue, value, onChange, draggableOptions,
|
|
|
48
48
|
setInnerValue(innerValue.current.black(newTop).saturationv(newLeft).hue(hue));
|
|
49
49
|
return [newLeft, newTop];
|
|
50
50
|
};
|
|
51
|
-
const
|
|
52
|
-
...
|
|
51
|
+
const draggableHandles = useDraggable({
|
|
52
|
+
...gestureOptions,
|
|
53
53
|
onDragStart(e) {
|
|
54
|
-
|
|
54
|
+
gestureOptions?.onDragStart?.(e);
|
|
55
55
|
const paletteWidth = paletteRef.current.clientWidth;
|
|
56
56
|
const paletteHeight = paletteRef.current.clientHeight;
|
|
57
57
|
const { hue } = colorObject;
|
|
@@ -70,9 +70,9 @@ export const Palette = memo(({ defaultValue, value, onChange, draggableOptions,
|
|
|
70
70
|
};
|
|
71
71
|
},
|
|
72
72
|
onDrag(info, e) {
|
|
73
|
-
|
|
74
|
-
const { top, left, paletteWidth, paletteHeight, hue } = info.
|
|
75
|
-
setHandlePosition(left + info.
|
|
73
|
+
gestureOptions?.onDrag?.(info, e);
|
|
74
|
+
const { top, left, paletteWidth, paletteHeight, hue } = info.data;
|
|
75
|
+
setHandlePosition(left + info.diff[0] / paletteWidth * 100, top + info.diff[1] / paletteHeight * 100, hue);
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
const fitHandlePosition = () => {
|
|
@@ -104,10 +104,10 @@ export const Palette = memo(({ defaultValue, value, onChange, draggableOptions,
|
|
|
104
104
|
}
|
|
105
105
|
})(), commonAlphaItem] }));
|
|
106
106
|
};
|
|
107
|
-
return (_jsxs("div", { ...props, css: style, className: clsx(classes.root, props.className), children: [_jsxs("div", { ref: paletteRef, className: classes.main, style: { backgroundImage: `linear-gradient(90deg, #ffffff, ${colorObject.saturated})` }, ...
|
|
107
|
+
return (_jsxs("div", { ...props, css: style, className: clsx(classes.root, props.className), children: [_jsxs("div", { ref: paletteRef, className: classes.main, style: { backgroundImage: `linear-gradient(90deg, #ffffff, ${colorObject.saturated})` }, ...draggableHandles, children: [_jsx("div", { className: classes.mask }), _jsx("div", { className: classes.handle, style: {
|
|
108
108
|
left: handlePosition[0] + '%',
|
|
109
109
|
top: handlePosition[1] + '%'
|
|
110
|
-
}, ...
|
|
110
|
+
}, ...draggableHandles })] }), _jsxs("div", { className: classes.slidersRow, children: [_jsxs("div", { className: classes.sliders, children: [_jsx(Slider, { ...sliderProps, className: classes.hue, value: colorObject.hue / 359 * 100, onChange: hueChangeHandler }), _jsx(Slider, { ...sliderProps, className: classes.alpha, renderRail: (_, railProps) => _jsxs("div", { ...railProps, children: [railProps.children, _jsx("div", { className: classes.alphaMask, style: { backgroundImage: `linear-gradient(90deg, transparent, ${colorObject.saturated})` } })] }), value: colorObject.alpha * 100, onChange: alphaChangeHandler })] }), _jsx("div", { className: classes.preview, children: _jsx("div", { className: classes.previewColor, style: {
|
|
111
111
|
backgroundColor: colorObject.hex,
|
|
112
112
|
opacity: colorObject.alpha
|
|
113
113
|
} }) })] }), _jsxs("div", { className: classes.inputRow, children: [_jsx(Button, { variant: "plain", color: "text", suffix: _jsx(Icon, { icon: faChevronDown }), onClick: formatChangeHandler, children: availableFormat[activeFormat] }), renderInputs()] })] }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { defineInnerClasses, defineCss } from '../../utils';
|
|
3
3
|
import { classes as dividerClasses } from '../divider/divider.style';
|
|
4
|
+
import { classes as alertClasses } from '../alert/alert.style';
|
|
4
5
|
export const classes = defineInnerClasses('picker-dialog', [
|
|
5
6
|
'content',
|
|
6
7
|
'selectedArea',
|
|
@@ -14,6 +15,7 @@ export const style = defineCss(({ spacing }) => css `
|
|
|
14
15
|
max-height: 100%;
|
|
15
16
|
display: flex;
|
|
16
17
|
flex-direction: column;
|
|
18
|
+
gap: ${spacing[3]}px;
|
|
17
19
|
|
|
18
20
|
.${classes.count} {
|
|
19
21
|
b {
|
|
@@ -29,6 +31,10 @@ export const style = defineCss(({ spacing }) => css `
|
|
|
29
31
|
.${classes.list} {
|
|
30
32
|
flex: 1;
|
|
31
33
|
overflow: hidden auto;
|
|
34
|
+
|
|
35
|
+
.${alertClasses.description} {
|
|
36
|
+
margin-top: 0;
|
|
37
|
+
}
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
.${classes.confirm} {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './pinchable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './pinchable';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ElementType, ReactElement, Ref } from 'react';
|
|
2
|
+
import { OverridableProps } from '../../types';
|
|
3
|
+
import { GestureOptions } from '../../utils';
|
|
4
|
+
export interface PinchableRef extends HTMLDivElement {
|
|
5
|
+
zoomIn(): void;
|
|
6
|
+
zoomOut(): void;
|
|
7
|
+
zoomTo(n?: number): void;
|
|
8
|
+
reset(transition?: boolean): void;
|
|
9
|
+
rotateLeft(): void;
|
|
10
|
+
rotateRight(): void;
|
|
11
|
+
rotate(deg: number): void;
|
|
12
|
+
}
|
|
13
|
+
type PinchableOwnProps = {
|
|
14
|
+
ref?: Ref<PinchableRef>;
|
|
15
|
+
gestureOptions?: GestureOptions;
|
|
16
|
+
defaultScale?: number;
|
|
17
|
+
scale?: number;
|
|
18
|
+
onScaleChange?(scale: number): void;
|
|
19
|
+
/** 缩放限制,`scale`非受控模式下有效,默认为1-6 */
|
|
20
|
+
scaleLimit?: [number, number];
|
|
21
|
+
defaultTranslate?: [number, number];
|
|
22
|
+
translate?: [number, number];
|
|
23
|
+
onTranslateChange?(translate: [number, number]): void;
|
|
24
|
+
/** 平移限制,`translate`非受控模式下有效 */
|
|
25
|
+
translateLimit?: (targetX: number, targetY: number, scale: number) => [number, number];
|
|
26
|
+
defaultRotate?: number;
|
|
27
|
+
rotate?: number;
|
|
28
|
+
onRotateChange?(rotate: number): void;
|
|
29
|
+
children?: ReactElement;
|
|
30
|
+
};
|
|
31
|
+
export type PinchableProps<C extends ElementType = 'div'> = OverridableProps<PinchableOwnProps, C>;
|
|
32
|
+
export declare const Pinchable: <C extends ElementType = "div">(props: PinchableProps<C>) => ReactElement;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { cloneElement, useImperativeHandle, useRef } from 'react';
|
|
3
|
+
import { cloneRef, clsx, range, useControlled, useGesture } from '../../utils';
|
|
4
|
+
import { classes, style } from './pinchable.style';
|
|
5
|
+
export const Pinchable = (({ component: Component = 'div', ref, gestureOptions, defaultScale = 1, scale, onScaleChange, scaleLimit = [1, 6], defaultTranslate = [0, 0], translate, onTranslateChange, translateLimit, defaultRotate = 0, rotate, onRotateChange, children, ...props }) => {
|
|
6
|
+
useImperativeHandle(ref, () => {
|
|
7
|
+
if (wrapperRef.current) {
|
|
8
|
+
wrapperRef.current.zoomIn = () => {
|
|
9
|
+
zoomFn(innerScale.current * 1.5);
|
|
10
|
+
};
|
|
11
|
+
wrapperRef.current.zoomOut = () => {
|
|
12
|
+
zoomFn(innerScale.current * .5);
|
|
13
|
+
};
|
|
14
|
+
wrapperRef.current.zoomTo = zoomFn;
|
|
15
|
+
wrapperRef.current.rotate =
|
|
16
|
+
wrapperRef.current.rotateLeft = () => {
|
|
17
|
+
rotateFn(innerRotate.current - 90);
|
|
18
|
+
};
|
|
19
|
+
wrapperRef.current.rotateRight = () => {
|
|
20
|
+
rotateFn(innerRotate.current + 90);
|
|
21
|
+
};
|
|
22
|
+
wrapperRef.current.reset = resetAll;
|
|
23
|
+
}
|
|
24
|
+
return wrapperRef.current;
|
|
25
|
+
});
|
|
26
|
+
const wrapperRef = useRef(null);
|
|
27
|
+
const contentRef = useRef(null);
|
|
28
|
+
const [innerScale, setInnerScale] = useControlled(defaultScale, scale, onScaleChange);
|
|
29
|
+
const [innerTranslate, setInnerTranslate] = useControlled(defaultTranslate, translate, onTranslateChange);
|
|
30
|
+
const [innerRotate, setInnerRotate] = useControlled(defaultRotate, rotate, onRotateChange);
|
|
31
|
+
const { draggableHandles, pinchableHandles } = useGesture({
|
|
32
|
+
...gestureOptions,
|
|
33
|
+
pinchable: true,
|
|
34
|
+
onDragStart(info) {
|
|
35
|
+
gestureOptions?.onDragStart?.(info);
|
|
36
|
+
return [...innerTranslate.current];
|
|
37
|
+
},
|
|
38
|
+
onDrag(info, e) {
|
|
39
|
+
gestureOptions?.onDrag?.(info, e);
|
|
40
|
+
const { diff: [dx, dy], data: [startX, startY] } = info;
|
|
41
|
+
setInnerTranslate(translateLimitFn(startX + dx, startY + dy));
|
|
42
|
+
},
|
|
43
|
+
onPinchStart(info) {
|
|
44
|
+
gestureOptions?.onPinchStart?.(info);
|
|
45
|
+
const { startSpacing, startMiddle: [sx, sy] } = info;
|
|
46
|
+
const { x, y, width, height } = contentRef.current.getBoundingClientRect();
|
|
47
|
+
const startDiagonal = Math.sqrt(width ** 2 + height ** 2);
|
|
48
|
+
return {
|
|
49
|
+
startScale: innerScale.current,
|
|
50
|
+
startTranslate: [...innerTranslate.current],
|
|
51
|
+
middlePosition: [
|
|
52
|
+
(sx - x - width / 2) / width,
|
|
53
|
+
(sy - y - height / 2) / height
|
|
54
|
+
],
|
|
55
|
+
startDiagonal,
|
|
56
|
+
rectRatio: width / height,
|
|
57
|
+
spacingRatio: startSpacing / startDiagonal
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
onPinch(info) {
|
|
61
|
+
gestureOptions?.onPinch?.(info);
|
|
62
|
+
const { currentSpacing, diffSpacing, diffMiddle: [dx, dy], data: { spacingRatio, startDiagonal, startScale, rectRatio, startTranslate, middlePosition } } = info;
|
|
63
|
+
const targetDiagonal = currentSpacing / spacingRatio;
|
|
64
|
+
const targetScale = targetDiagonal / startDiagonal;
|
|
65
|
+
const newScale = range(startScale * targetScale, ...scaleLimit);
|
|
66
|
+
setInnerScale(newScale);
|
|
67
|
+
const diffDiagonal = diffSpacing / spacingRatio;
|
|
68
|
+
const diffH = diffDiagonal / Math.sqrt(rectRatio ** 2 + 1);
|
|
69
|
+
const diffW = diffH * rectRatio;
|
|
70
|
+
const newX = startTranslate[0] - diffW * middlePosition[0] + dx;
|
|
71
|
+
const newY = startTranslate[1] - diffH * middlePosition[1] + dy;
|
|
72
|
+
setInnerTranslate(translateLimitFn(newX, newY, newScale));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (!children) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const translateLimitFn = (x, y, scale = innerScale.current, deg = innerRotate.current) => {
|
|
79
|
+
if (translateLimit) {
|
|
80
|
+
return translateLimit(x, y, scale);
|
|
81
|
+
}
|
|
82
|
+
const { clientWidth: wrapperWidth, clientHeight: wrapperHeight } = wrapperRef.current;
|
|
83
|
+
const { offsetWidth, offsetHeight } = contentRef.current;
|
|
84
|
+
const isRotated = deg % 180 !== 0;
|
|
85
|
+
const contentWidth = (isRotated ? offsetHeight : offsetWidth) * scale;
|
|
86
|
+
const contentHeight = (isRotated ? offsetWidth : offsetHeight) * scale;
|
|
87
|
+
const limitX = contentWidth > wrapperWidth ? (contentWidth - wrapperWidth) / 2 : 0;
|
|
88
|
+
const limitY = contentHeight > wrapperHeight ? (contentHeight - wrapperHeight) / 2 : 0;
|
|
89
|
+
return [
|
|
90
|
+
range(x, -limitX, limitX),
|
|
91
|
+
range(y, -limitY, limitY)
|
|
92
|
+
];
|
|
93
|
+
};
|
|
94
|
+
const childrenProps = children.props;
|
|
95
|
+
const allowTransition = () => {
|
|
96
|
+
contentRef.current && (contentRef.current.dataset.transition = 'true');
|
|
97
|
+
};
|
|
98
|
+
const zoomFn = (targetScale, originX, originY) => {
|
|
99
|
+
allowTransition();
|
|
100
|
+
const content = contentRef.current;
|
|
101
|
+
const newScale = range(targetScale, ...scaleLimit);
|
|
102
|
+
const newWidth = content.offsetWidth * newScale;
|
|
103
|
+
const newHeight = content.offsetHeight * newScale;
|
|
104
|
+
if (typeof originX === 'undefined' || typeof originY === 'undefined') {
|
|
105
|
+
const { x, y, width, height } = wrapperRef.current.getBoundingClientRect();
|
|
106
|
+
originX = x + (width / 2);
|
|
107
|
+
originY = y + (height / 2);
|
|
108
|
+
}
|
|
109
|
+
const { x, y, width, height } = contentRef.current.getBoundingClientRect();
|
|
110
|
+
const diffW = newWidth - width;
|
|
111
|
+
const diffH = newHeight - height;
|
|
112
|
+
const positionX = (originX - x - width / 2) / width;
|
|
113
|
+
const positionY = (originY - y - height / 2) / height;
|
|
114
|
+
const newX = innerTranslate.current[0] - diffW * positionX;
|
|
115
|
+
const newY = innerTranslate.current[1] - diffH * positionY;
|
|
116
|
+
setInnerScale(newScale);
|
|
117
|
+
setInnerTranslate(translateLimitFn(newX, newY, newScale));
|
|
118
|
+
};
|
|
119
|
+
const resetZoom = (transition = true) => {
|
|
120
|
+
transition && allowTransition();
|
|
121
|
+
setInnerScale(range(1, ...scaleLimit));
|
|
122
|
+
setInnerTranslate([0, 0]);
|
|
123
|
+
};
|
|
124
|
+
const rotateFn = (deg) => {
|
|
125
|
+
allowTransition();
|
|
126
|
+
setInnerRotate(deg);
|
|
127
|
+
setInnerTranslate(translateLimitFn(...innerTranslate.current, innerScale.current, deg));
|
|
128
|
+
};
|
|
129
|
+
const resetAll = (transition = true) => {
|
|
130
|
+
transition && allowTransition();
|
|
131
|
+
resetZoom(false);
|
|
132
|
+
setInnerRotate(0);
|
|
133
|
+
};
|
|
134
|
+
const doubleClickHandler = (e) => {
|
|
135
|
+
childrenProps.onDoubleClick?.(e);
|
|
136
|
+
if (innerScale.current < 1.5) {
|
|
137
|
+
zoomFn(3, e.clientX, e.clientY);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
resetZoom();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return (_jsx(Component, { ...props, ref: wrapperRef, css: style, className: clsx(classes.root, props.className), ...pinchableHandles, children: cloneElement(children, {
|
|
144
|
+
ref: cloneRef(contentRef, childrenProps.ref),
|
|
145
|
+
className: clsx(classes.content, childrenProps.className),
|
|
146
|
+
style: {
|
|
147
|
+
...childrenProps?.style,
|
|
148
|
+
scale: innerScale.current,
|
|
149
|
+
translate: `${innerTranslate.current[0]}px ${innerTranslate.current[1]}px`,
|
|
150
|
+
rotate: innerRotate.current + 'deg',
|
|
151
|
+
transformOrigin: 'center'
|
|
152
|
+
},
|
|
153
|
+
...draggableHandles,
|
|
154
|
+
onDoubleClick: doubleClickHandler,
|
|
155
|
+
onTransitionEnd: e => e.currentTarget.dataset.transition = 'false'
|
|
156
|
+
}) }));
|
|
157
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineClasses, defineCss } from '../../utils';
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
export const classes = defineClasses('pinchable', [
|
|
4
|
+
'content'
|
|
5
|
+
]);
|
|
6
|
+
export const style = defineCss(({ easing }) => css `
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
|
|
11
|
+
&, .${classes.content} {
|
|
12
|
+
touch-action: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.${classes.content}[data-transition=true] {
|
|
16
|
+
transition: all .25s ${easing.easeOut};
|
|
17
|
+
}
|
|
18
|
+
`);
|
|
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { ColorPropsValue, DivProps } from '../../types';
|
|
3
3
|
export interface ProgressProps extends DivProps {
|
|
4
4
|
showInfo?: boolean;
|
|
5
|
-
renderInfo?(value
|
|
5
|
+
renderInfo?(value: number): ReactNode;
|
|
6
6
|
color?: ColorPropsValue;
|
|
7
7
|
status?: 'default' | 'processing' | 'success' | 'error';
|
|
8
8
|
variant?: 'linear' | 'circular' | 'gauge';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
import { ColorPropsValue, DivProps, Size } from '../../types';
|
|
3
3
|
export type CharacterProps = {
|
|
4
4
|
index: number;
|
|
@@ -21,4 +21,4 @@ export interface RatingProps extends Omit<DivProps, 'defaultValue' | 'onChange'>
|
|
|
21
21
|
readOnly?: boolean;
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export declare const Rating:
|
|
24
|
+
export declare const Rating: React.MemoExoticComponent<({ color, size, count, renderStar, allowHalf, highlightSelectedOnly, defaultValue, value, onChange, readOnly, disabled, ...props }: RatingProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -5,7 +5,7 @@ import { classes, useStyle } from './rating.style';
|
|
|
5
5
|
import { useTheme } from '../theme';
|
|
6
6
|
import { Icon } from '../..';
|
|
7
7
|
import { faStar } from '@fortawesome/free-solid-svg-icons/faStar';
|
|
8
|
-
export const Rating = memo(({ color = '#FFCC00', size, count = 5, renderStar = _jsx(Icon, { icon: faStar }), allowHalf, highlightSelectedOnly, defaultValue = 0, value, onChange, readOnly, disabled, ...props }) => {
|
|
8
|
+
export const Rating = memo(({ color = '#FFCC00', size, count = 5, renderStar = _jsx(Icon, { icon: faStar }), allowHalf, highlightSelectedOnly = false, defaultValue = 0, value, onChange, readOnly, disabled, ...props }) => {
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
size ??= theme.size;
|
|
11
11
|
const [innerValue, setInnerValue] = useControlled(defaultValue, value, onChange);
|
|
@@ -40,9 +40,7 @@ export const Rating = memo(({ color = '#FFCC00', size, count = 5, renderStar = _
|
|
|
40
40
|
const isHalf = !highlightSelectedOnly && isActive && index > refer - 1;
|
|
41
41
|
return (_jsxs("div", { className: classes.star, children: [characterIsFunction
|
|
42
42
|
? renderStar({ index })
|
|
43
|
-
:
|
|
44
|
-
? cloneElement(renderStar, { index })
|
|
45
|
-
: renderStar, isActive && (characterIsFunction
|
|
43
|
+
: renderStar, isActive && (characterIsFunction
|
|
46
44
|
? renderStar({
|
|
47
45
|
index,
|
|
48
46
|
active: true,
|
|
@@ -50,7 +48,6 @@ export const Rating = memo(({ color = '#FFCC00', size, count = 5, renderStar = _
|
|
|
50
48
|
})
|
|
51
49
|
: isValidElement(renderStar)
|
|
52
50
|
? cloneElement(renderStar, {
|
|
53
|
-
index,
|
|
54
51
|
'data-active': true,
|
|
55
52
|
'data-half': isHalf
|
|
56
53
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CSSProperties, ElementType } from 'react';
|
|
2
2
|
import { ColorPropsValue, DivProps, OverridableComponent, OverridableProps, Placement, SlotsAndProps } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import { GestureOptions } from '../../utils';
|
|
4
4
|
type HandleAbbr = 't' | 'r' | 'b' | 'l' | 'tl' | 'tr' | 'br' | 'bl' | 'lt' | 'rt' | 'lb' | 'rb';
|
|
5
5
|
export type Handle = Placement | HandleAbbr;
|
|
6
6
|
export interface ResizableOwnProps extends SlotsAndProps<{
|
|
@@ -24,7 +24,7 @@ export interface ResizableOwnProps extends SlotsAndProps<{
|
|
|
24
24
|
fixedRatio?: boolean;
|
|
25
25
|
onResize?(width: number, height: number): void;
|
|
26
26
|
onResizeEnd?(width: number, height: number): void;
|
|
27
|
-
|
|
27
|
+
gestureOptions?: GestureOptions;
|
|
28
28
|
/** 受控的尺寸 */
|
|
29
29
|
defaultWidth?: CSSProperties['width'];
|
|
30
30
|
defaultHeight?: CSSProperties['height'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useMemo, useRef, useState } from 'react';
|
|
3
|
-
import { clsx, cloneRef, toArray,
|
|
3
|
+
import { clsx, cloneRef, toArray, useSync, useControlled, useDraggable } from '../../utils';
|
|
4
4
|
import { classes, handleCursors, useStyle } from './resizable.style';
|
|
5
5
|
const handleAlias = {
|
|
6
6
|
t: 't',
|
|
@@ -28,7 +28,7 @@ const handleAlias = {
|
|
|
28
28
|
bottomRight: 'br',
|
|
29
29
|
rightBottom: 'br'
|
|
30
30
|
};
|
|
31
|
-
export const Resizable = (({ component: Component = 'div', slots = {}, slotProps = {}, variant = 'mouse', handles = ['t', 'r', 'b', 'l', 'tl', 'tr', 'br', 'bl'], handleSize = variant === 'mouse' ? 8 : 12, handleColor = 'secondary', handlePosition = 'outside', fixedRatio, onResize, onResizeEnd,
|
|
31
|
+
export const Resizable = (({ component: Component = 'div', slots = {}, slotProps = {}, variant = 'mouse', handles = ['t', 'r', 'b', 'l', 'tl', 'tr', 'br', 'bl'], handleSize = variant === 'mouse' ? 8 : 12, handleColor = 'secondary', handlePosition = 'outside', fixedRatio, onResize, onResizeEnd, gestureOptions, defaultWidth, defaultHeight, width, height, minWidth, minHeight, maxWidth, maxHeight, ...props }) => {
|
|
32
32
|
const abbrHandles = useMemo(() => {
|
|
33
33
|
return [...toArray(handles).map(h => handleAlias[h])];
|
|
34
34
|
}, [handles]);
|
|
@@ -37,10 +37,10 @@ export const Resizable = (({ component: Component = 'div', slots = {}, slotProps
|
|
|
37
37
|
const [innerHeight, setInnerHeight] = useControlled(defaultHeight, height);
|
|
38
38
|
const [dragStartState, setDragStartState] = useState();
|
|
39
39
|
const syncProps = useSync({ onResize, onResizeEnd });
|
|
40
|
-
const
|
|
41
|
-
...
|
|
40
|
+
const draggableHandles = useDraggable({
|
|
41
|
+
...gestureOptions,
|
|
42
42
|
onDragStart(e) {
|
|
43
|
-
|
|
43
|
+
gestureOptions?.onDragStart?.(e);
|
|
44
44
|
const handleType = e.currentTarget.dataset.handle;
|
|
45
45
|
setDragStartState({
|
|
46
46
|
width: innerRef.current.offsetWidth,
|
|
@@ -54,24 +54,24 @@ export const Resizable = (({ component: Component = 'div', slots = {}, slotProps
|
|
|
54
54
|
document.body.style.cursor = handleCursors[handleType] || '';
|
|
55
55
|
},
|
|
56
56
|
onDrag(info, e) {
|
|
57
|
-
|
|
58
|
-
let {
|
|
57
|
+
gestureOptions?.onDrag?.(info, e);
|
|
58
|
+
let { diff: [dx, dy] } = info;
|
|
59
59
|
const { width, height, includeT, includeB, includeL, includeR } = dragStartState;
|
|
60
60
|
if (includeL) {
|
|
61
|
-
|
|
61
|
+
dx *= -1;
|
|
62
62
|
}
|
|
63
63
|
if (includeT) {
|
|
64
|
-
|
|
64
|
+
dy *= -1;
|
|
65
65
|
}
|
|
66
66
|
if (includeL || includeR) {
|
|
67
|
-
setInnerWidth(width +
|
|
67
|
+
setInnerWidth(width + dx);
|
|
68
68
|
}
|
|
69
69
|
if (includeT || includeB) {
|
|
70
|
-
setInnerHeight(height +
|
|
70
|
+
setInnerHeight(height + dy);
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
onDragEnd(info) {
|
|
74
|
-
|
|
74
|
+
gestureOptions?.onDragEnd?.(info);
|
|
75
75
|
setDragStartState(void 0);
|
|
76
76
|
document.body.style.cursor = '';
|
|
77
77
|
syncProps.current?.onResizeEnd?.(innerRef.current.offsetWidth, innerRef.current.offsetHeight);
|
|
@@ -87,5 +87,5 @@ export const Resizable = (({ component: Component = 'div', slots = {}, slotProps
|
|
|
87
87
|
maxHeight,
|
|
88
88
|
...typeof innerWidth.current === 'number' && { width: innerWidth.current },
|
|
89
89
|
...typeof innerHeight.current === 'number' && { height: innerHeight.current }
|
|
90
|
-
}, children: [_jsx(Container, { ...containerProps, className: clsx(classes.container, containerProps?.className), children: props.children }), abbrHandles.map(h => _jsx("div", { className: h.length === 1 ? classes.edge : classes.corner, "data-handle": h, "data-dragging": dragStartState?.handleType === h, ...
|
|
90
|
+
}, children: [_jsx(Container, { ...containerProps, className: clsx(classes.container, containerProps?.className), children: props.children }), abbrHandles.map(h => _jsx("div", { className: h.length === 1 ? classes.edge : classes.corner, "data-handle": h, "data-dragging": dragStartState?.handleType === h, ...draggableHandles }, h))] }));
|
|
91
91
|
});
|
|
@@ -12,7 +12,7 @@ export interface ScrollbarOwnProps extends SlotsAndProps<{
|
|
|
12
12
|
variant?: 'contain' | 'cover';
|
|
13
13
|
/** 是否自动隐藏滚动条,默认为`true` */
|
|
14
14
|
autoHide?: boolean;
|
|
15
|
-
/** 默认为`
|
|
15
|
+
/** 默认为`0.8em` */
|
|
16
16
|
size?: number | string;
|
|
17
17
|
/** 默认的`ref`属性传递至`scroller`元素,外层元素的`ref`需要指定`wrapperRef` */
|
|
18
18
|
wrapperRef?: Ref<HTMLDivElement>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
-
import { clsx, cloneRef,
|
|
3
|
+
import { clsx, cloneRef, useDraggable } from '../../utils';
|
|
4
4
|
import { classes, useStyle } from './scrollbar.style';
|
|
5
5
|
export const Scrollbar = (({ component: Component = 'div', variant = 'contain', autoHide = true, size = '.8em', wrapperRef, onScroll, slots = {}, slotProps = {}, ...props }) => {
|
|
6
6
|
const containerRef = useRef(null);
|
|
@@ -70,7 +70,7 @@ export const Scrollbar = (({ component: Component = 'div', variant = 'contain',
|
|
|
70
70
|
thumbYRef.current.style.top = top + 'px';
|
|
71
71
|
scrollerRef.current.scrollTop = top / verticalInfo.current.scrollRatio;
|
|
72
72
|
};
|
|
73
|
-
const draggableHandleY =
|
|
73
|
+
const draggableHandleY = useDraggable({
|
|
74
74
|
onDragStart(e) {
|
|
75
75
|
e.stopPropagation();
|
|
76
76
|
containerRef.current.dataset.dragging = thumbYRef.current.dataset.dragging = 'true';
|
|
@@ -79,8 +79,8 @@ export const Scrollbar = (({ component: Component = 'div', variant = 'contain',
|
|
|
79
79
|
}
|
|
80
80
|
return parseInt(thumbYRef.current.style.top || '0');
|
|
81
81
|
},
|
|
82
|
-
onDrag({
|
|
83
|
-
updateScrollTop(
|
|
82
|
+
onDrag({ diff: [, dy], data }) {
|
|
83
|
+
updateScrollTop(data + dy);
|
|
84
84
|
},
|
|
85
85
|
onDragEnd() {
|
|
86
86
|
containerRef.current.dataset.dragging = thumbYRef.current.dataset.dragging = 'false';
|
|
@@ -91,7 +91,7 @@ export const Scrollbar = (({ component: Component = 'div', variant = 'contain',
|
|
|
91
91
|
thumbXRef.current.style.left = left + 'px';
|
|
92
92
|
scrollerRef.current.scrollLeft = left / horizontalInfo.current.scrollRatio;
|
|
93
93
|
};
|
|
94
|
-
const draggableHandleX =
|
|
94
|
+
const draggableHandleX = useDraggable({
|
|
95
95
|
onDragStart(e) {
|
|
96
96
|
containerRef.current.dataset.dragging = thumbXRef.current.dataset.dragging = 'true';
|
|
97
97
|
e.stopPropagation();
|
|
@@ -100,8 +100,8 @@ export const Scrollbar = (({ component: Component = 'div', variant = 'contain',
|
|
|
100
100
|
}
|
|
101
101
|
return parseInt(thumbXRef.current.style.left || '0');
|
|
102
102
|
},
|
|
103
|
-
onDrag({
|
|
104
|
-
updateScrollLeft(
|
|
103
|
+
onDrag({ diff: [dx], data }) {
|
|
104
|
+
updateScrollLeft(data + dx);
|
|
105
105
|
},
|
|
106
106
|
onDragEnd() {
|
|
107
107
|
containerRef.current.dataset.dragging = thumbXRef.current.dataset.dragging = 'false';
|
|
@@ -6,6 +6,6 @@ export interface SegmentedOptionProps extends Omit<DivProps, 'prefix'> {
|
|
|
6
6
|
suffix?: ReactNode;
|
|
7
7
|
value?: Id;
|
|
8
8
|
label?: ReactNode;
|
|
9
|
-
disabled?:
|
|
9
|
+
disabled?: boolean;
|
|
10
10
|
}
|
|
11
11
|
export declare const SegmentedOption: import("react").MemoExoticComponent<({ orientation, prefix, suffix, value, label, disabled, ...props }: SegmentedOptionProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
@@ -9,7 +9,7 @@ export function SelectedItem({ value, index, itemProps, onClose, ...collapseProp
|
|
|
9
9
|
const [loading, requestFn] = useLoading(async () => {
|
|
10
10
|
itemProps && setAlertProps(await itemProps(value, index));
|
|
11
11
|
});
|
|
12
|
-
useMemo(requestFn, []);
|
|
12
|
+
useMemo(requestFn, []).then();
|
|
13
13
|
const closeHandler = (e) => {
|
|
14
14
|
alertProps.current?.onClose?.(e);
|
|
15
15
|
onClose?.(value, index);
|
|
@@ -6,7 +6,7 @@ export const classes = defineInnerClasses('selected-list', [
|
|
|
6
6
|
'optionWrap'
|
|
7
7
|
]);
|
|
8
8
|
export const style = defineCss(({ spacing }) => css `
|
|
9
|
-
.${classes.
|
|
9
|
+
.${classes.optionWrap} {
|
|
10
10
|
margin-bottom: ${spacing[3]}px;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -3,7 +3,7 @@ import { DivProps } from '../../types';
|
|
|
3
3
|
type SkeletonSharedProps = {
|
|
4
4
|
/** 默认为`rounded` */
|
|
5
5
|
variant?: 'circular' | 'rectangular' | 'rounded';
|
|
6
|
-
/** 是否播放动画,默认为`
|
|
6
|
+
/** 是否播放动画,默认为`true` */
|
|
7
7
|
animation?: boolean;
|
|
8
8
|
};
|
|
9
9
|
export interface SkeletonProps extends SkeletonSharedProps, DivProps {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { DivProps } from '../../types';
|
|
3
|
-
import {
|
|
3
|
+
import { GestureOptions } from '../../utils';
|
|
4
4
|
import { SlidableActionsAction, SlidableActionsActionProps } from './slidableActionsAction';
|
|
5
5
|
export declare function useSlidableActionsContext(): {
|
|
6
|
-
actionsContainer
|
|
7
|
-
translate
|
|
8
|
-
|
|
6
|
+
actionsContainer?: (HTMLElement | null)[];
|
|
7
|
+
translate?: number;
|
|
8
|
+
resetTranslate?(): void;
|
|
9
|
+
maxDistance?: number;
|
|
10
|
+
autoReturn?: boolean;
|
|
9
11
|
};
|
|
10
12
|
type ActionType = SlidableActionsActionProps | ReactElement;
|
|
11
13
|
export interface SlidableActionsProps extends DivProps {
|
|
@@ -17,8 +19,10 @@ export interface SlidableActionsProps extends DivProps {
|
|
|
17
19
|
effectiveSpeed?: number;
|
|
18
20
|
leftActions?: ActionType | ActionType[];
|
|
19
21
|
rightActions?: ActionType | ActionType[];
|
|
22
|
+
/** 点击action后是否自动归位,默认为`true` */
|
|
23
|
+
autoReturn?: boolean;
|
|
20
24
|
disabled?: boolean;
|
|
21
|
-
|
|
25
|
+
gestureOptions?: GestureOptions;
|
|
22
26
|
}
|
|
23
27
|
export declare const SlidableActions: {
|
|
24
28
|
(props: SlidableActionsProps): ReactElement;
|