@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
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pinchable = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const pinchable_style_1 = require("./pinchable.style");
|
|
8
|
+
exports.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 }) => {
|
|
9
|
+
(0, react_1.useImperativeHandle)(ref, () => {
|
|
10
|
+
if (wrapperRef.current) {
|
|
11
|
+
wrapperRef.current.zoomIn = () => {
|
|
12
|
+
zoomFn(innerScale.current * 1.5);
|
|
13
|
+
};
|
|
14
|
+
wrapperRef.current.zoomOut = () => {
|
|
15
|
+
zoomFn(innerScale.current * .5);
|
|
16
|
+
};
|
|
17
|
+
wrapperRef.current.zoomTo = zoomFn;
|
|
18
|
+
wrapperRef.current.rotate =
|
|
19
|
+
wrapperRef.current.rotateLeft = () => {
|
|
20
|
+
rotateFn(innerRotate.current - 90);
|
|
21
|
+
};
|
|
22
|
+
wrapperRef.current.rotateRight = () => {
|
|
23
|
+
rotateFn(innerRotate.current + 90);
|
|
24
|
+
};
|
|
25
|
+
wrapperRef.current.reset = resetAll;
|
|
26
|
+
}
|
|
27
|
+
return wrapperRef.current;
|
|
28
|
+
});
|
|
29
|
+
const wrapperRef = (0, react_1.useRef)(null);
|
|
30
|
+
const contentRef = (0, react_1.useRef)(null);
|
|
31
|
+
const [innerScale, setInnerScale] = (0, utils_1.useControlled)(defaultScale, scale, onScaleChange);
|
|
32
|
+
const [innerTranslate, setInnerTranslate] = (0, utils_1.useControlled)(defaultTranslate, translate, onTranslateChange);
|
|
33
|
+
const [innerRotate, setInnerRotate] = (0, utils_1.useControlled)(defaultRotate, rotate, onRotateChange);
|
|
34
|
+
const { draggableHandles, pinchableHandles } = (0, utils_1.useGesture)({
|
|
35
|
+
...gestureOptions,
|
|
36
|
+
pinchable: true,
|
|
37
|
+
onDragStart(info) {
|
|
38
|
+
gestureOptions?.onDragStart?.(info);
|
|
39
|
+
return [...innerTranslate.current];
|
|
40
|
+
},
|
|
41
|
+
onDrag(info, e) {
|
|
42
|
+
gestureOptions?.onDrag?.(info, e);
|
|
43
|
+
const { diff: [dx, dy], data: [startX, startY] } = info;
|
|
44
|
+
setInnerTranslate(translateLimitFn(startX + dx, startY + dy));
|
|
45
|
+
},
|
|
46
|
+
onPinchStart(info) {
|
|
47
|
+
gestureOptions?.onPinchStart?.(info);
|
|
48
|
+
const { startSpacing, startMiddle: [sx, sy] } = info;
|
|
49
|
+
const { x, y, width, height } = contentRef.current.getBoundingClientRect();
|
|
50
|
+
const startDiagonal = Math.sqrt(width ** 2 + height ** 2);
|
|
51
|
+
return {
|
|
52
|
+
startScale: innerScale.current,
|
|
53
|
+
startTranslate: [...innerTranslate.current],
|
|
54
|
+
middlePosition: [
|
|
55
|
+
(sx - x - width / 2) / width,
|
|
56
|
+
(sy - y - height / 2) / height
|
|
57
|
+
],
|
|
58
|
+
startDiagonal,
|
|
59
|
+
rectRatio: width / height,
|
|
60
|
+
spacingRatio: startSpacing / startDiagonal
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
onPinch(info) {
|
|
64
|
+
gestureOptions?.onPinch?.(info);
|
|
65
|
+
const { currentSpacing, diffSpacing, diffMiddle: [dx, dy], data: { spacingRatio, startDiagonal, startScale, rectRatio, startTranslate, middlePosition } } = info;
|
|
66
|
+
const targetDiagonal = currentSpacing / spacingRatio;
|
|
67
|
+
const targetScale = targetDiagonal / startDiagonal;
|
|
68
|
+
const newScale = (0, utils_1.range)(startScale * targetScale, ...scaleLimit);
|
|
69
|
+
setInnerScale(newScale);
|
|
70
|
+
const diffDiagonal = diffSpacing / spacingRatio;
|
|
71
|
+
const diffH = diffDiagonal / Math.sqrt(rectRatio ** 2 + 1);
|
|
72
|
+
const diffW = diffH * rectRatio;
|
|
73
|
+
const newX = startTranslate[0] - diffW * middlePosition[0] + dx;
|
|
74
|
+
const newY = startTranslate[1] - diffH * middlePosition[1] + dy;
|
|
75
|
+
setInnerTranslate(translateLimitFn(newX, newY, newScale));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!children) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const translateLimitFn = (x, y, scale = innerScale.current, deg = innerRotate.current) => {
|
|
82
|
+
if (translateLimit) {
|
|
83
|
+
return translateLimit(x, y, scale);
|
|
84
|
+
}
|
|
85
|
+
const { clientWidth: wrapperWidth, clientHeight: wrapperHeight } = wrapperRef.current;
|
|
86
|
+
const { offsetWidth, offsetHeight } = contentRef.current;
|
|
87
|
+
const isRotated = deg % 180 !== 0;
|
|
88
|
+
const contentWidth = (isRotated ? offsetHeight : offsetWidth) * scale;
|
|
89
|
+
const contentHeight = (isRotated ? offsetWidth : offsetHeight) * scale;
|
|
90
|
+
const limitX = contentWidth > wrapperWidth ? (contentWidth - wrapperWidth) / 2 : 0;
|
|
91
|
+
const limitY = contentHeight > wrapperHeight ? (contentHeight - wrapperHeight) / 2 : 0;
|
|
92
|
+
return [
|
|
93
|
+
(0, utils_1.range)(x, -limitX, limitX),
|
|
94
|
+
(0, utils_1.range)(y, -limitY, limitY)
|
|
95
|
+
];
|
|
96
|
+
};
|
|
97
|
+
const childrenProps = children.props;
|
|
98
|
+
const allowTransition = () => {
|
|
99
|
+
contentRef.current && (contentRef.current.dataset.transition = 'true');
|
|
100
|
+
};
|
|
101
|
+
const zoomFn = (targetScale, originX, originY) => {
|
|
102
|
+
allowTransition();
|
|
103
|
+
const content = contentRef.current;
|
|
104
|
+
const newScale = (0, utils_1.range)(targetScale, ...scaleLimit);
|
|
105
|
+
const newWidth = content.offsetWidth * newScale;
|
|
106
|
+
const newHeight = content.offsetHeight * newScale;
|
|
107
|
+
if (typeof originX === 'undefined' || typeof originY === 'undefined') {
|
|
108
|
+
const { x, y, width, height } = wrapperRef.current.getBoundingClientRect();
|
|
109
|
+
originX = x + (width / 2);
|
|
110
|
+
originY = y + (height / 2);
|
|
111
|
+
}
|
|
112
|
+
const { x, y, width, height } = contentRef.current.getBoundingClientRect();
|
|
113
|
+
const diffW = newWidth - width;
|
|
114
|
+
const diffH = newHeight - height;
|
|
115
|
+
const positionX = (originX - x - width / 2) / width;
|
|
116
|
+
const positionY = (originY - y - height / 2) / height;
|
|
117
|
+
const newX = innerTranslate.current[0] - diffW * positionX;
|
|
118
|
+
const newY = innerTranslate.current[1] - diffH * positionY;
|
|
119
|
+
setInnerScale(newScale);
|
|
120
|
+
setInnerTranslate(translateLimitFn(newX, newY, newScale));
|
|
121
|
+
};
|
|
122
|
+
const resetZoom = (transition = true) => {
|
|
123
|
+
transition && allowTransition();
|
|
124
|
+
setInnerScale((0, utils_1.range)(1, ...scaleLimit));
|
|
125
|
+
setInnerTranslate([0, 0]);
|
|
126
|
+
};
|
|
127
|
+
const rotateFn = (deg) => {
|
|
128
|
+
allowTransition();
|
|
129
|
+
setInnerRotate(deg);
|
|
130
|
+
setInnerTranslate(translateLimitFn(...innerTranslate.current, innerScale.current, deg));
|
|
131
|
+
};
|
|
132
|
+
const resetAll = (transition = true) => {
|
|
133
|
+
transition && allowTransition();
|
|
134
|
+
resetZoom(false);
|
|
135
|
+
setInnerRotate(0);
|
|
136
|
+
};
|
|
137
|
+
const doubleClickHandler = (e) => {
|
|
138
|
+
childrenProps.onDoubleClick?.(e);
|
|
139
|
+
if (innerScale.current < 1.5) {
|
|
140
|
+
zoomFn(3, e.clientX, e.clientY);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
resetZoom();
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
return ((0, jsx_runtime_1.jsx)(Component, { ...props, ref: wrapperRef, css: pinchable_style_1.style, className: (0, utils_1.clsx)(pinchable_style_1.classes.root, props.className), ...pinchableHandles, children: (0, react_1.cloneElement)(children, {
|
|
147
|
+
ref: (0, utils_1.cloneRef)(contentRef, childrenProps.ref),
|
|
148
|
+
className: (0, utils_1.clsx)(pinchable_style_1.classes.content, childrenProps.className),
|
|
149
|
+
style: {
|
|
150
|
+
...childrenProps?.style,
|
|
151
|
+
scale: innerScale.current,
|
|
152
|
+
translate: `${innerTranslate.current[0]}px ${innerTranslate.current[1]}px`,
|
|
153
|
+
rotate: innerRotate.current + 'deg',
|
|
154
|
+
transformOrigin: 'center'
|
|
155
|
+
},
|
|
156
|
+
...draggableHandles,
|
|
157
|
+
onDoubleClick: doubleClickHandler,
|
|
158
|
+
onTransitionEnd: e => e.currentTarget.dataset.transition = 'false'
|
|
159
|
+
}) }));
|
|
160
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.style = exports.classes = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
exports.classes = (0, utils_1.defineClasses)('pinchable', [
|
|
7
|
+
'content'
|
|
8
|
+
]);
|
|
9
|
+
exports.style = (0, utils_1.defineCss)(({ easing }) => (0, react_1.css) `
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
|
|
14
|
+
&, .${exports.classes.content} {
|
|
15
|
+
touch-action: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.${exports.classes.content}[data-transition=true] {
|
|
19
|
+
transition: all .25s ${easing.easeOut};
|
|
20
|
+
}
|
|
21
|
+
`);
|
|
@@ -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>;
|
|
@@ -8,7 +8,7 @@ const rating_style_1 = require("./rating.style");
|
|
|
8
8
|
const theme_1 = require("../theme");
|
|
9
9
|
const __1 = require("../..");
|
|
10
10
|
const faStar_1 = require("@fortawesome/free-solid-svg-icons/faStar");
|
|
11
|
-
exports.Rating = (0, react_1.memo)(({ color = '#FFCC00', size, count = 5, renderStar = (0, jsx_runtime_1.jsx)(__1.Icon, { icon: faStar_1.faStar }), allowHalf, highlightSelectedOnly, defaultValue = 0, value, onChange, readOnly, disabled, ...props }) => {
|
|
11
|
+
exports.Rating = (0, react_1.memo)(({ color = '#FFCC00', size, count = 5, renderStar = (0, jsx_runtime_1.jsx)(__1.Icon, { icon: faStar_1.faStar }), allowHalf, highlightSelectedOnly = false, defaultValue = 0, value, onChange, readOnly, disabled, ...props }) => {
|
|
12
12
|
const theme = (0, theme_1.useTheme)();
|
|
13
13
|
size ??= theme.size;
|
|
14
14
|
const [innerValue, setInnerValue] = (0, utils_1.useControlled)(defaultValue, value, onChange);
|
|
@@ -43,9 +43,7 @@ exports.Rating = (0, react_1.memo)(({ color = '#FFCC00', size, count = 5, render
|
|
|
43
43
|
const isHalf = !highlightSelectedOnly && isActive && index > refer - 1;
|
|
44
44
|
return ((0, jsx_runtime_1.jsxs)("div", { className: rating_style_1.classes.star, children: [characterIsFunction
|
|
45
45
|
? renderStar({ index })
|
|
46
|
-
:
|
|
47
|
-
? (0, react_1.cloneElement)(renderStar, { index })
|
|
48
|
-
: renderStar, isActive && (characterIsFunction
|
|
46
|
+
: renderStar, isActive && (characterIsFunction
|
|
49
47
|
? renderStar({
|
|
50
48
|
index,
|
|
51
49
|
active: true,
|
|
@@ -53,7 +51,6 @@ exports.Rating = (0, react_1.memo)(({ color = '#FFCC00', size, count = 5, render
|
|
|
53
51
|
})
|
|
54
52
|
: (0, react_1.isValidElement)(renderStar)
|
|
55
53
|
? (0, react_1.cloneElement)(renderStar, {
|
|
56
|
-
index,
|
|
57
54
|
'data-active': true,
|
|
58
55
|
'data-half': isHalf
|
|
59
56
|
})
|
|
@@ -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'];
|
|
@@ -31,7 +31,7 @@ const handleAlias = {
|
|
|
31
31
|
bottomRight: 'br',
|
|
32
32
|
rightBottom: 'br'
|
|
33
33
|
};
|
|
34
|
-
exports.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,
|
|
34
|
+
exports.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 }) => {
|
|
35
35
|
const abbrHandles = (0, react_1.useMemo)(() => {
|
|
36
36
|
return [...(0, utils_1.toArray)(handles).map(h => handleAlias[h])];
|
|
37
37
|
}, [handles]);
|
|
@@ -40,10 +40,10 @@ exports.Resizable = (({ component: Component = 'div', slots = {}, slotProps = {}
|
|
|
40
40
|
const [innerHeight, setInnerHeight] = (0, utils_1.useControlled)(defaultHeight, height);
|
|
41
41
|
const [dragStartState, setDragStartState] = (0, react_1.useState)();
|
|
42
42
|
const syncProps = (0, utils_1.useSync)({ onResize, onResizeEnd });
|
|
43
|
-
const
|
|
44
|
-
...
|
|
43
|
+
const draggableHandles = (0, utils_1.useDraggable)({
|
|
44
|
+
...gestureOptions,
|
|
45
45
|
onDragStart(e) {
|
|
46
|
-
|
|
46
|
+
gestureOptions?.onDragStart?.(e);
|
|
47
47
|
const handleType = e.currentTarget.dataset.handle;
|
|
48
48
|
setDragStartState({
|
|
49
49
|
width: innerRef.current.offsetWidth,
|
|
@@ -57,24 +57,24 @@ exports.Resizable = (({ component: Component = 'div', slots = {}, slotProps = {}
|
|
|
57
57
|
document.body.style.cursor = resizable_style_1.handleCursors[handleType] || '';
|
|
58
58
|
},
|
|
59
59
|
onDrag(info, e) {
|
|
60
|
-
|
|
61
|
-
let {
|
|
60
|
+
gestureOptions?.onDrag?.(info, e);
|
|
61
|
+
let { diff: [dx, dy] } = info;
|
|
62
62
|
const { width, height, includeT, includeB, includeL, includeR } = dragStartState;
|
|
63
63
|
if (includeL) {
|
|
64
|
-
|
|
64
|
+
dx *= -1;
|
|
65
65
|
}
|
|
66
66
|
if (includeT) {
|
|
67
|
-
|
|
67
|
+
dy *= -1;
|
|
68
68
|
}
|
|
69
69
|
if (includeL || includeR) {
|
|
70
|
-
setInnerWidth(width +
|
|
70
|
+
setInnerWidth(width + dx);
|
|
71
71
|
}
|
|
72
72
|
if (includeT || includeB) {
|
|
73
|
-
setInnerHeight(height +
|
|
73
|
+
setInnerHeight(height + dy);
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
onDragEnd(info) {
|
|
77
|
-
|
|
77
|
+
gestureOptions?.onDragEnd?.(info);
|
|
78
78
|
setDragStartState(void 0);
|
|
79
79
|
document.body.style.cursor = '';
|
|
80
80
|
syncProps.current?.onResizeEnd?.(innerRef.current.offsetWidth, innerRef.current.offsetHeight);
|
|
@@ -90,5 +90,5 @@ exports.Resizable = (({ component: Component = 'div', slots = {}, slotProps = {}
|
|
|
90
90
|
maxHeight,
|
|
91
91
|
...typeof innerWidth.current === 'number' && { width: innerWidth.current },
|
|
92
92
|
...typeof innerHeight.current === 'number' && { height: innerHeight.current }
|
|
93
|
-
}, children: [(0, jsx_runtime_1.jsx)(Container, { ...containerProps, className: (0, utils_1.clsx)(resizable_style_1.classes.container, containerProps?.className), children: props.children }), abbrHandles.map(h => (0, jsx_runtime_1.jsx)("div", { className: h.length === 1 ? resizable_style_1.classes.edge : resizable_style_1.classes.corner, "data-handle": h, "data-dragging": dragStartState?.handleType === h, ...
|
|
93
|
+
}, children: [(0, jsx_runtime_1.jsx)(Container, { ...containerProps, className: (0, utils_1.clsx)(resizable_style_1.classes.container, containerProps?.className), children: props.children }), abbrHandles.map(h => (0, jsx_runtime_1.jsx)("div", { className: h.length === 1 ? resizable_style_1.classes.edge : resizable_style_1.classes.corner, "data-handle": h, "data-dragging": dragStartState?.handleType === h, ...draggableHandles }, h))] }));
|
|
94
94
|
});
|
|
@@ -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>;
|
|
@@ -73,7 +73,7 @@ exports.Scrollbar = (({ component: Component = 'div', variant = 'contain', autoH
|
|
|
73
73
|
thumbYRef.current.style.top = top + 'px';
|
|
74
74
|
scrollerRef.current.scrollTop = top / verticalInfo.current.scrollRatio;
|
|
75
75
|
};
|
|
76
|
-
const draggableHandleY = (0, utils_1.
|
|
76
|
+
const draggableHandleY = (0, utils_1.useDraggable)({
|
|
77
77
|
onDragStart(e) {
|
|
78
78
|
e.stopPropagation();
|
|
79
79
|
containerRef.current.dataset.dragging = thumbYRef.current.dataset.dragging = 'true';
|
|
@@ -82,8 +82,8 @@ exports.Scrollbar = (({ component: Component = 'div', variant = 'contain', autoH
|
|
|
82
82
|
}
|
|
83
83
|
return parseInt(thumbYRef.current.style.top || '0');
|
|
84
84
|
},
|
|
85
|
-
onDrag({
|
|
86
|
-
updateScrollTop(
|
|
85
|
+
onDrag({ diff: [, dy], data }) {
|
|
86
|
+
updateScrollTop(data + dy);
|
|
87
87
|
},
|
|
88
88
|
onDragEnd() {
|
|
89
89
|
containerRef.current.dataset.dragging = thumbYRef.current.dataset.dragging = 'false';
|
|
@@ -94,7 +94,7 @@ exports.Scrollbar = (({ component: Component = 'div', variant = 'contain', autoH
|
|
|
94
94
|
thumbXRef.current.style.left = left + 'px';
|
|
95
95
|
scrollerRef.current.scrollLeft = left / horizontalInfo.current.scrollRatio;
|
|
96
96
|
};
|
|
97
|
-
const draggableHandleX = (0, utils_1.
|
|
97
|
+
const draggableHandleX = (0, utils_1.useDraggable)({
|
|
98
98
|
onDragStart(e) {
|
|
99
99
|
containerRef.current.dataset.dragging = thumbXRef.current.dataset.dragging = 'true';
|
|
100
100
|
e.stopPropagation();
|
|
@@ -103,8 +103,8 @@ exports.Scrollbar = (({ component: Component = 'div', variant = 'contain', autoH
|
|
|
103
103
|
}
|
|
104
104
|
return parseInt(thumbXRef.current.style.left || '0');
|
|
105
105
|
},
|
|
106
|
-
onDrag({
|
|
107
|
-
updateScrollLeft(
|
|
106
|
+
onDrag({ diff: [dx], data }) {
|
|
107
|
+
updateScrollLeft(data + dx);
|
|
108
108
|
},
|
|
109
109
|
onDragEnd() {
|
|
110
110
|
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>;
|
|
@@ -12,7 +12,7 @@ function SelectedItem({ value, index, itemProps, onClose, ...collapseProps }) {
|
|
|
12
12
|
const [loading, requestFn] = (0, utils_1.useLoading)(async () => {
|
|
13
13
|
itemProps && setAlertProps(await itemProps(value, index));
|
|
14
14
|
});
|
|
15
|
-
(0, react_1.useMemo)(requestFn, []);
|
|
15
|
+
(0, react_1.useMemo)(requestFn, []).then();
|
|
16
16
|
const closeHandler = (e) => {
|
|
17
17
|
alertProps.current?.onClose?.(e);
|
|
18
18
|
onClose?.(value, index);
|
|
@@ -9,7 +9,7 @@ exports.classes = (0, utils_1.defineInnerClasses)('selected-list', [
|
|
|
9
9
|
'optionWrap'
|
|
10
10
|
]);
|
|
11
11
|
exports.style = (0, utils_1.defineCss)(({ spacing }) => (0, react_1.css) `
|
|
12
|
-
.${exports.classes.
|
|
12
|
+
.${exports.classes.optionWrap} {
|
|
13
13
|
margin-bottom: ${spacing[3]}px;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -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;
|
|
@@ -8,16 +8,12 @@ const clickAway_1 = require("../clickAway");
|
|
|
8
8
|
const slidableActions_style_1 = require("./slidableActions.style");
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const slidableActionsAction_1 = require("./slidableActionsAction");
|
|
11
|
-
const
|
|
12
|
-
const SlidableActionsContext = (0, react_1.createContext)({
|
|
13
|
-
actionsContainer: [],
|
|
14
|
-
translate: 0,
|
|
15
|
-
maxDistance: 0
|
|
16
|
-
});
|
|
11
|
+
const bounceBezier = (0, utils_1.cubicBezier)(0, 0, 0, 1);
|
|
12
|
+
const SlidableActionsContext = (0, react_1.createContext)({});
|
|
17
13
|
function useSlidableActionsContext() {
|
|
18
14
|
return (0, react_1.useContext)(SlidableActionsContext);
|
|
19
15
|
}
|
|
20
|
-
exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate =
|
|
16
|
+
exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate = 12, bounceDragDistance = 240, effectiveSpeed = 450, leftActions, rightActions, autoReturn = true, disabled, gestureOptions, ...props }) => {
|
|
21
17
|
const leftActionsContainer = (0, react_1.useRef)([]);
|
|
22
18
|
const rightActionsContainer = (0, react_1.useRef)([]);
|
|
23
19
|
const [distanceRange, setDistanceRange] = (0, utils_1.useSyncState)([0, 0]);
|
|
@@ -35,37 +31,37 @@ exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate = 24, boun
|
|
|
35
31
|
const [translate, setTranslate] = (0, react_1.useState)(0);
|
|
36
32
|
const [dragging, setDragging] = (0, react_1.useState)(false);
|
|
37
33
|
const startTranslate = (0, react_1.useRef)(0);
|
|
38
|
-
const
|
|
39
|
-
...
|
|
34
|
+
const draggableHandles = (0, utils_1.useDraggable)({
|
|
35
|
+
...gestureOptions,
|
|
40
36
|
disabled,
|
|
41
|
-
|
|
37
|
+
preventNativeTouchMove: true,
|
|
42
38
|
onDragStart(e) {
|
|
43
|
-
|
|
39
|
+
gestureOptions?.onDragStart?.(e);
|
|
44
40
|
setDragging(true);
|
|
45
41
|
startTranslate.current = translate;
|
|
46
42
|
getDistanceRange();
|
|
47
43
|
},
|
|
48
44
|
onDrag(info, e) {
|
|
49
|
-
|
|
45
|
+
gestureOptions?.onDrag?.(info, e);
|
|
50
46
|
const [min, max] = distanceRange.current;
|
|
51
47
|
const bounceMin = min < 0 ? min - bounceDragDistance : min;
|
|
52
48
|
const bounceMax = max > 0 ? max + bounceDragDistance : max;
|
|
53
|
-
let newTranslate = (0, utils_1.range)(startTranslate.current + info.
|
|
49
|
+
let newTranslate = (0, utils_1.range)(startTranslate.current + info.diff[0], bounceMin, bounceMax);
|
|
54
50
|
// 拖拽超过正常距离,模拟弹性
|
|
55
51
|
if (newTranslate < min) {
|
|
56
|
-
newTranslate = min -
|
|
52
|
+
newTranslate = min - bounceBezier(-(newTranslate - min) / bounceDragDistance) * bounceElementTranslate;
|
|
57
53
|
}
|
|
58
54
|
else if (newTranslate > max) {
|
|
59
|
-
newTranslate = max +
|
|
55
|
+
newTranslate = max + bounceBezier((newTranslate - max) / bounceDragDistance) * bounceElementTranslate;
|
|
60
56
|
}
|
|
61
57
|
setTranslate(newTranslate);
|
|
62
58
|
},
|
|
63
59
|
onDragEnd(info) {
|
|
64
|
-
|
|
60
|
+
gestureOptions?.onDragEnd?.(info);
|
|
65
61
|
setDragging(false);
|
|
66
62
|
const start = startTranslate.current;
|
|
67
63
|
const [min, max] = distanceRange.current;
|
|
68
|
-
const isSpeedSatisfied = () => effectiveSpeed && info.
|
|
64
|
+
const isSpeedSatisfied = () => effectiveSpeed && info.speed[0] * 1000 >= effectiveSpeed;
|
|
69
65
|
// 拖拽距离达到一半,或者满足速度要求
|
|
70
66
|
if (start < 0) {
|
|
71
67
|
if (translate > start && (translate >= min / 2 || isSpeedSatisfied())) {
|
|
@@ -86,14 +82,14 @@ exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate = 24, boun
|
|
|
86
82
|
else {
|
|
87
83
|
// 原本在中间
|
|
88
84
|
if (translate < min / 2 || translate > max / 2 || isSpeedSatisfied()) {
|
|
89
|
-
return setTranslate(info.
|
|
85
|
+
return setTranslate(info.diff[0] > 0 ? max : min);
|
|
90
86
|
}
|
|
91
87
|
}
|
|
92
88
|
// 未满足条件,返回原位
|
|
93
89
|
setTranslate(startTranslate.current);
|
|
94
90
|
},
|
|
95
91
|
onDragCancel(info) {
|
|
96
|
-
|
|
92
|
+
gestureOptions?.onDragCancel?.(info);
|
|
97
93
|
setDragging(false);
|
|
98
94
|
const [min, max] = distanceRange.current;
|
|
99
95
|
translate < min / 2 && translate > max / 2
|
|
@@ -101,7 +97,7 @@ exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate = 24, boun
|
|
|
101
97
|
: setTranslate(0);
|
|
102
98
|
}
|
|
103
99
|
});
|
|
104
|
-
const
|
|
100
|
+
const resetTranslate = () => {
|
|
105
101
|
translate && setTranslate(0);
|
|
106
102
|
};
|
|
107
103
|
const renderActions = (actions) => {
|
|
@@ -116,16 +112,16 @@ exports.SlidableActions = (0, react_1.memo)(({ bounceElementTranslate = 24, boun
|
|
|
116
112
|
: child;
|
|
117
113
|
});
|
|
118
114
|
};
|
|
119
|
-
return ((0, jsx_runtime_1.jsx)(clickAway_1.ClickAway, { eventType: "pointerdown", onClickAway:
|
|
115
|
+
return ((0, jsx_runtime_1.jsx)(clickAway_1.ClickAway, { eventType: "pointerdown", onClickAway: resetTranslate, children: (0, jsx_runtime_1.jsxs)("div", { ...props, css: slidableActions_style_1.style, className: (0, utils_1.clsx)(slidableActions_style_1.classes.root, props.className), "data-dragging": dragging, children: [(0, jsx_runtime_1.jsx)("div", { className: slidableActions_style_1.classes.content, ...draggableHandles, style: { translate: `${translate}px 0` }, children: props.children }), (0, jsx_runtime_1.jsxs)("div", { className: slidableActions_style_1.classes.actions, children: [(0, jsx_runtime_1.jsx)(SlidableActionsContext, { value: (0, react_1.useMemo)(() => ({
|
|
120
116
|
actionsContainer: leftActionsContainer.current,
|
|
121
|
-
translate,
|
|
117
|
+
translate, resetTranslate, autoReturn,
|
|
122
118
|
maxDistance: distanceRange.current[1]
|
|
123
|
-
}), [translate, distanceRange.current]), children: (0, jsx_runtime_1.jsx)("div", { className: slidableActions_style_1.classes.actionsLeft, children: !!leftActions &&
|
|
119
|
+
}), [translate, distanceRange.current, autoReturn]), children: (0, jsx_runtime_1.jsx)("div", { className: slidableActions_style_1.classes.actionsLeft, children: !!leftActions &&
|
|
124
120
|
renderActions(leftActions) }) }), (0, jsx_runtime_1.jsx)(SlidableActionsContext, { value: (0, react_1.useMemo)(() => ({
|
|
125
121
|
actionsContainer: rightActionsContainer.current,
|
|
126
|
-
translate,
|
|
122
|
+
translate, resetTranslate, autoReturn,
|
|
127
123
|
maxDistance: -distanceRange.current[0]
|
|
128
|
-
}), [translate, distanceRange.current]), children: (0, jsx_runtime_1.jsx)("div", { className: slidableActions_style_1.classes.actionsRight, children: !!rightActions &&
|
|
124
|
+
}), [translate, distanceRange.current, autoReturn]), children: (0, jsx_runtime_1.jsx)("div", { className: slidableActions_style_1.classes.actionsRight, children: !!rightActions &&
|
|
129
125
|
renderActions(rightActions) }) })] })] }) }));
|
|
130
126
|
});
|
|
131
127
|
exports.SlidableActions.Action = slidableActionsAction_1.SlidableActionsAction;
|