zs_library 0.2.0 → 0.2.1
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/Desktop/ContextMenu/index.d.ts +12 -2
- package/dist/Desktop/ContextMenu/index.js +45 -18
- package/dist/Desktop/Items/GroupItem.js +17 -14
- package/dist/Desktop/Items/Modal/GroupItemModal.d.ts +0 -1
- package/dist/Desktop/Items/Modal/GroupItemModal.js +13 -13
- package/dist/Desktop/Items/SortableItem.d.ts +0 -1
- package/dist/Desktop/Items/SortableItem.js +16 -11
- package/dist/Desktop/Sortable.d.ts +5 -22
- package/dist/Desktop/Sortable.js +33 -29
- package/dist/Desktop/context/config/context.d.ts +44 -0
- package/dist/Desktop/context/config/context.js +36 -0
- package/dist/Desktop/context/config/hooks.d.ts +1 -0
- package/dist/Desktop/context/config/hooks.js +6 -0
- package/dist/Desktop/{context.d.ts → context/state/context.d.ts} +21 -12
- package/dist/Desktop/{context.js → context/state/context.js} +18 -28
- package/dist/Desktop/context/state/hooks.d.ts +1 -0
- package/dist/Desktop/context/state/hooks.js +6 -0
- package/dist/Desktop/index.d.ts +3 -24
- package/dist/Desktop/index.js +24 -6
- package/package.json +1 -1
- package/dist/Desktop/hook.d.ts +0 -1
- package/dist/Desktop/hook.js +0 -6
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortItem } from '../types';
|
|
3
|
+
export interface ContextMenuProps<D, C> {
|
|
4
|
+
showShareButton?: boolean;
|
|
5
|
+
showInfoButton?: boolean;
|
|
6
|
+
showRemoveButton?: boolean;
|
|
7
|
+
showSizeButton?: boolean;
|
|
8
|
+
onShareClick?: (item: SortItem<D, C>) => void;
|
|
9
|
+
onInfoClick?: (item: SortItem<D, C>) => void;
|
|
10
|
+
onRemoveClick?: (item: SortItem<D, C>, remove: (id: string) => void) => void;
|
|
11
|
+
}
|
|
12
|
+
declare const ContextMenu: <D, C>(props: ContextMenuProps<D, C>) => React.JSX.Element;
|
|
3
13
|
export default ContextMenu;
|
|
@@ -19,7 +19,8 @@ import { RiCloseCircleLine, RiInformationLine, RiPencilRuler2Line, RiShareLine }
|
|
|
19
19
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import { configMap } from "../config";
|
|
22
|
-
import {
|
|
22
|
+
import { useSortableConfig } from "../context/config/hooks";
|
|
23
|
+
import { useSortableState } from "../context/state/hooks";
|
|
23
24
|
import SortableUtils from "../utils";
|
|
24
25
|
var itemVariants = {
|
|
25
26
|
menuShow: {
|
|
@@ -43,8 +44,8 @@ var ContextButton = function ContextButton(props) {
|
|
|
43
44
|
var icon = props.icon,
|
|
44
45
|
title = props.title,
|
|
45
46
|
_onClick = props.onClick;
|
|
46
|
-
var
|
|
47
|
-
theme =
|
|
47
|
+
var _useSortableConfig = useSortableConfig(),
|
|
48
|
+
theme = _useSortableConfig.theme;
|
|
48
49
|
var _SortableUtils$getThe = SortableUtils.getTheme(theme),
|
|
49
50
|
light = _SortableUtils$getThe.light,
|
|
50
51
|
dark = _SortableUtils$getThe.dark;
|
|
@@ -64,15 +65,27 @@ var ContextButton = function ContextButton(props) {
|
|
|
64
65
|
className: cx(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-bottom: 0.375rem;\n display: flex;\n justify-content: center;\n "]))))
|
|
65
66
|
}, icon), /*#__PURE__*/React.createElement(motion.div, null, title)));
|
|
66
67
|
};
|
|
67
|
-
var ContextMenu = function ContextMenu() {
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
68
|
+
var ContextMenu = function ContextMenu(props) {
|
|
69
|
+
var _props$showInfoButton = props.showInfoButton,
|
|
70
|
+
showInfoButton = _props$showInfoButton === void 0 ? true : _props$showInfoButton,
|
|
71
|
+
_props$showRemoveButt = props.showRemoveButton,
|
|
72
|
+
showRemoveButton = _props$showRemoveButt === void 0 ? true : _props$showRemoveButt,
|
|
73
|
+
_props$showShareButto = props.showShareButton,
|
|
74
|
+
showShareButton = _props$showShareButto === void 0 ? true : _props$showShareButto,
|
|
75
|
+
_props$showSizeButton = props.showSizeButton,
|
|
76
|
+
showSizeButton = _props$showSizeButton === void 0 ? true : _props$showSizeButton,
|
|
77
|
+
onInfoClick = props.onInfoClick,
|
|
78
|
+
onShareClick = props.onShareClick,
|
|
79
|
+
onRemoveClick = props.onRemoveClick;
|
|
80
|
+
var _useSortableState = useSortableState(),
|
|
81
|
+
contextMenu = _useSortableState.contextMenu,
|
|
82
|
+
setContextMenu = _useSortableState.setContextMenu,
|
|
83
|
+
hideContextMenu = _useSortableState.hideContextMenu,
|
|
84
|
+
setShowInfoItemData = _useSortableState.setShowInfoItemData,
|
|
85
|
+
removeItem = _useSortableState.removeItem,
|
|
86
|
+
updateItemConfig = _useSortableState.updateItemConfig;
|
|
87
|
+
var _useSortableConfig2 = useSortableConfig(),
|
|
88
|
+
theme = _useSortableConfig2.theme;
|
|
76
89
|
var _SortableUtils$getThe2 = SortableUtils.getTheme(theme),
|
|
77
90
|
light = _SortableUtils$getThe2.light,
|
|
78
91
|
dark = _SortableUtils$getThe2.dark;
|
|
@@ -110,7 +123,7 @@ var ContextMenu = function ContextMenu() {
|
|
|
110
123
|
}
|
|
111
124
|
}, /*#__PURE__*/React.createElement(motion.div, {
|
|
112
125
|
className: cx(css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n border-radius: 0.5rem;\n overflow: hidden;\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n @media (prefers-color-scheme: dark) {\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n }\n "])), light.contextMenuBackgroundColor, light.contextMenuShadowColor, dark.contextMenuBackgroundColor, dark.contextMenuShadowColor))
|
|
113
|
-
}, config.allowResize !== false && /*#__PURE__*/React.createElement(motion.ul, {
|
|
126
|
+
}, showSizeButton && config.allowResize !== false && /*#__PURE__*/React.createElement(motion.ul, {
|
|
114
127
|
className: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background-color: white;\n padding: 0.25rem;\n margin: 0;\n "])))
|
|
115
128
|
}, [{
|
|
116
129
|
label: '修改大小',
|
|
@@ -150,30 +163,44 @@ var ContextMenu = function ContextMenu() {
|
|
|
150
163
|
}, it.label);
|
|
151
164
|
})));
|
|
152
165
|
}))), /*#__PURE__*/React.createElement(motion.div, {
|
|
153
|
-
className: cx(css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n @media (prefers-color-scheme: dark) {\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n }\n display: flex;\n margin-top: 0.5rem;\n border-radius: 0.5rem;\n overflow: hidden;\n padding: 0.25rem;\n "])), light.contextMenuBackgroundColor, light.contextMenuShadowColor, dark.contextMenuBackgroundColor, dark.contextMenuShadowColor))
|
|
154
|
-
}, /*#__PURE__*/React.createElement(ContextButton, {
|
|
166
|
+
className: cx(css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n @media (prefers-color-scheme: dark) {\n background-color: ", ";\n box-shadow: 0 0 0.5rem ", ";\n }\n display: flex;\n justify-content: space-around;\n align-items: center;\n margin-top: 0.5rem;\n border-radius: 0.5rem;\n overflow: hidden;\n padding: 0.25rem;\n "])), light.contextMenuBackgroundColor, light.contextMenuShadowColor, dark.contextMenuBackgroundColor, dark.contextMenuShadowColor))
|
|
167
|
+
}, showShareButton && /*#__PURE__*/React.createElement(ContextButton, {
|
|
155
168
|
icon: /*#__PURE__*/React.createElement(RiShareLine, {
|
|
156
169
|
size: 20
|
|
157
170
|
}),
|
|
158
|
-
title: "\u5206\u4EAB"
|
|
159
|
-
|
|
171
|
+
title: "\u5206\u4EAB",
|
|
172
|
+
onClick: function onClick() {
|
|
173
|
+
if (onShareClick) {
|
|
174
|
+
onShareClick(contextMenu.data);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}), showInfoButton && /*#__PURE__*/React.createElement(ContextButton, {
|
|
160
179
|
icon: /*#__PURE__*/React.createElement(RiInformationLine, {
|
|
161
180
|
size: 20
|
|
162
181
|
}),
|
|
163
182
|
title: "\u4FE1\u606F",
|
|
164
183
|
onClick: function onClick() {
|
|
184
|
+
if (onInfoClick) {
|
|
185
|
+
onInfoClick(contextMenu.data);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
165
188
|
setShowInfoItemData(_objectSpread(_objectSpread({}, contextMenu.data), {}, {
|
|
166
189
|
pageX: contextMenu.pageX,
|
|
167
190
|
pageY: contextMenu.pageY
|
|
168
191
|
}));
|
|
169
192
|
hideContextMenu();
|
|
170
193
|
}
|
|
171
|
-
}), /*#__PURE__*/React.createElement(ContextButton, {
|
|
194
|
+
}), showRemoveButton && /*#__PURE__*/React.createElement(ContextButton, {
|
|
172
195
|
icon: /*#__PURE__*/React.createElement(RiCloseCircleLine, {
|
|
173
196
|
size: 20
|
|
174
197
|
}),
|
|
175
198
|
title: "\u79FB\u9664",
|
|
176
199
|
onClick: function onClick() {
|
|
200
|
+
if (onRemoveClick) {
|
|
201
|
+
onRemoveClick(contextMenu.data, removeItem);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
177
204
|
setContextMenu(null);
|
|
178
205
|
removeItem(contextMenu.data.id);
|
|
179
206
|
}
|
|
@@ -11,7 +11,8 @@ import { css, cx } from '@emotion/css';
|
|
|
11
11
|
import { motion } from 'framer-motion';
|
|
12
12
|
import React, { useMemo } from 'react';
|
|
13
13
|
import { ReactSortable } from 'react-sortablejs';
|
|
14
|
-
import {
|
|
14
|
+
import { useSortableConfig } from "../context/config/hooks";
|
|
15
|
+
import { useSortableState } from "../context/state/hooks";
|
|
15
16
|
import SortableUtils from "../utils";
|
|
16
17
|
import SortableItem from "./SortableItem";
|
|
17
18
|
var SortableGroupItem = function SortableGroupItem(props) {
|
|
@@ -22,18 +23,20 @@ var SortableGroupItem = function SortableGroupItem(props) {
|
|
|
22
23
|
itemIndex = props.itemIndex,
|
|
23
24
|
_onClick = props.onClick,
|
|
24
25
|
_props$noLetters = props.noLetters,
|
|
25
|
-
noLetters = _props$noLetters === void 0 ? false : _props$noLetters
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
noLetters = _props$noLetters === void 0 ? false : _props$noLetters;
|
|
27
|
+
var _useSortableState = useSortableState(),
|
|
28
|
+
contextMenuFuns = _useSortableState.contextMenuFuns,
|
|
29
|
+
_setList = _useSortableState.setList,
|
|
30
|
+
setOpenGroupItemData = _useSortableState.setOpenGroupItemData,
|
|
31
|
+
longPressTriggered = _useSortableState.longPressTriggered,
|
|
32
|
+
moveItemId = _useSortableState.moveItemId,
|
|
33
|
+
moveTargetId = _useSortableState.moveTargetId,
|
|
34
|
+
setMoveTargetId = _useSortableState.setMoveTargetId,
|
|
35
|
+
listStatus = _useSortableState.listStatus;
|
|
36
|
+
var _useSortableConfig = useSortableConfig(),
|
|
37
|
+
itemIconBuilder = _useSortableConfig.itemIconBuilder,
|
|
38
|
+
theme = _useSortableConfig.theme,
|
|
39
|
+
contextMenu = _useSortableConfig.contextMenu;
|
|
37
40
|
var _SortableUtils$getThe = SortableUtils.getTheme(theme),
|
|
38
41
|
light = _SortableUtils$getThe.light,
|
|
39
42
|
dark = _SortableUtils$getThe.dark;
|
|
@@ -143,7 +146,7 @@ var SortableGroupItem = function SortableGroupItem(props) {
|
|
|
143
146
|
setOpenGroupItemData(data);
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
|
-
}, contextMenuFuns(data)), /*#__PURE__*/React.createElement(motion.div, {
|
|
149
|
+
}, contextMenuFuns(data, contextMenu !== false)), /*#__PURE__*/React.createElement(motion.div, {
|
|
147
150
|
className: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 0.375rem;\n "])))
|
|
148
151
|
}, sizedContent(), /*#__PURE__*/React.createElement(ReactSortable, {
|
|
149
152
|
className: cx('sortable-group-item', css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: absolute;\n cursor: pointer;\n left: 0.375rem;\n top: 0.375rem;\n width: calc(100% - 0.75rem);\n height: calc(100% - 0.75rem);\n pointer-events: ", ";\n > * {\n opacity: 0;\n }\n "])), listStatus === null ? 'none' : 'auto')),
|
|
@@ -4,7 +4,6 @@ interface GroupItemModalProps<D, C> {
|
|
|
4
4
|
data: SortItem | null;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onItemClick?: (item: SortItem<D, C>) => void;
|
|
7
|
-
itemIconBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
8
7
|
}
|
|
9
8
|
declare const GroupItemModal: <D, C>(props: GroupItemModalProps<D, C>) => React.JSX.Element;
|
|
10
9
|
export default GroupItemModal;
|
|
@@ -22,7 +22,8 @@ import { css, cx } from '@emotion/css';
|
|
|
22
22
|
import Dialog from 'rc-dialog';
|
|
23
23
|
import React, { useEffect, useState } from 'react';
|
|
24
24
|
import { ReactSortable } from 'react-sortablejs';
|
|
25
|
-
import {
|
|
25
|
+
import { useSortableConfig } from "../../context/config/hooks";
|
|
26
|
+
import { useSortableState } from "../../context/state/hooks";
|
|
26
27
|
import { ghostClass } from "../../style";
|
|
27
28
|
import SortableUtils from "../../utils";
|
|
28
29
|
import SortableItem from "../SortableItem";
|
|
@@ -30,16 +31,16 @@ var GroupItemModal = function GroupItemModal(props) {
|
|
|
30
31
|
var _data$children, _data$children2;
|
|
31
32
|
var data = props.data,
|
|
32
33
|
_onClose = props.onClose,
|
|
33
|
-
onItemClick = props.onItemClick
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
theme =
|
|
34
|
+
onItemClick = props.onItemClick;
|
|
35
|
+
var _useSortableState = useSortableState(),
|
|
36
|
+
list = _useSortableState.list,
|
|
37
|
+
_setList = _useSortableState.setList,
|
|
38
|
+
setListStatus = _useSortableState.setListStatus,
|
|
39
|
+
setMoveItemId = _useSortableState.setMoveItemId,
|
|
40
|
+
setMoveTargetId = _useSortableState.setMoveTargetId,
|
|
41
|
+
updateItem = _useSortableState.updateItem;
|
|
42
|
+
var _useSortableConfig = useSortableConfig(),
|
|
43
|
+
theme = _useSortableConfig.theme;
|
|
43
44
|
var _SortableUtils$getThe = SortableUtils.getTheme(theme),
|
|
44
45
|
light = _SortableUtils$getThe.light,
|
|
45
46
|
dark = _SortableUtils$getThe.dark;
|
|
@@ -151,8 +152,7 @@ var GroupItemModal = function GroupItemModal(props) {
|
|
|
151
152
|
key: item.id,
|
|
152
153
|
data: item,
|
|
153
154
|
itemIndex: index,
|
|
154
|
-
onClick: onItemClick
|
|
155
|
-
itemIconBuilder: itemIconBuilder
|
|
155
|
+
onClick: onItemClick
|
|
156
156
|
});
|
|
157
157
|
}))));
|
|
158
158
|
};
|
|
@@ -11,7 +11,6 @@ export interface SortableItemProps<D, C> {
|
|
|
11
11
|
children?: React.ReactNode;
|
|
12
12
|
parentIds?: (string | number)[];
|
|
13
13
|
childrenLength?: number;
|
|
14
|
-
itemIconBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
15
14
|
}
|
|
16
15
|
export declare const SortableItemDefaultContent: <D, C>(props: SortableItemProps<D, C>) => React.JSX.Element;
|
|
17
16
|
declare const SortableItem: <D, C>(props: SortableItemProps<D, C>) => React.JSX.Element;
|
|
@@ -7,16 +7,19 @@ import RcTooltip from 'rc-tooltip';
|
|
|
7
7
|
import 'rc-tooltip/assets/bootstrap_white.css';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import ContextMenu from "../ContextMenu";
|
|
10
|
-
import {
|
|
10
|
+
import { useSortableConfig } from "../context/config/hooks";
|
|
11
|
+
import { useSortableState } from "../context/state/hooks";
|
|
11
12
|
import SortableUtils from "../utils";
|
|
12
13
|
export var SortableItemDefaultContent = function SortableItemDefaultContent(props) {
|
|
13
14
|
var data = props.data,
|
|
14
15
|
_props$noLetters = props.noLetters,
|
|
15
|
-
noLetters = _props$noLetters === void 0 ? false : _props$noLetters
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
noLetters = _props$noLetters === void 0 ? false : _props$noLetters;
|
|
17
|
+
var _useSortableState = useSortableState(),
|
|
18
|
+
contextMenuFuns = _useSortableState.contextMenuFuns;
|
|
19
|
+
var _useSortableConfig = useSortableConfig(),
|
|
20
|
+
itemIconBuilder = _useSortableConfig.itemIconBuilder,
|
|
21
|
+
theme = _useSortableConfig.theme,
|
|
22
|
+
contextMenu = _useSortableConfig.contextMenu;
|
|
20
23
|
var _SortableUtils$getThe = SortableUtils.getTheme(theme),
|
|
21
24
|
light = _SortableUtils$getThe.light,
|
|
22
25
|
dark = _SortableUtils$getThe.dark;
|
|
@@ -31,7 +34,7 @@ export var SortableItemDefaultContent = function SortableItemDefaultContent(prop
|
|
|
31
34
|
}
|
|
32
35
|
}, /*#__PURE__*/React.createElement("div", _extends({
|
|
33
36
|
className: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n color: ", ";\n @media (prefers-color-scheme: dark) {\n color: ", ";\n }\n "])), light.itemNameColor, dark.itemNameColor)
|
|
34
|
-
}, contextMenuFuns(data)), itemIconBuilder === null || itemIconBuilder === void 0 ? void 0 : itemIconBuilder(data))), /*#__PURE__*/React.createElement(motion.p, {
|
|
37
|
+
}, contextMenuFuns(data, contextMenu !== false)), itemIconBuilder === null || itemIconBuilder === void 0 ? void 0 : itemIconBuilder(data))), /*#__PURE__*/React.createElement(motion.p, {
|
|
35
38
|
className: cx(css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n text-align: center;\n margin-top: 0.25rem;\n margin-bottom: 0;\n color: ", ";\n @media (prefers-color-scheme: dark) {\n color: ", ";\n }\n "])), light.itemNameColor, dark.itemNameColor), noLetters && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: transparent;\n "]))))
|
|
36
39
|
}, name));
|
|
37
40
|
};
|
|
@@ -45,13 +48,15 @@ var SortableItem = function SortableItem(props) {
|
|
|
45
48
|
children = props.children,
|
|
46
49
|
parentIds = props.parentIds,
|
|
47
50
|
childrenLength = props.childrenLength;
|
|
48
|
-
var
|
|
49
|
-
contextMenu =
|
|
50
|
-
setContextMenu =
|
|
51
|
+
var _useSortableState2 = useSortableState(),
|
|
52
|
+
contextMenu = _useSortableState2.contextMenu,
|
|
53
|
+
setContextMenu = _useSortableState2.setContextMenu;
|
|
54
|
+
var _useSortableConfig2 = useSortableConfig(),
|
|
55
|
+
configContextMenu = _useSortableConfig2.contextMenu;
|
|
51
56
|
return /*#__PURE__*/React.createElement(RcTooltip, {
|
|
52
57
|
placement: "bottom",
|
|
53
58
|
overlayClassName: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background-color: transparent;\n .rc-tooltip-inner {\n background-color: transparent;\n padding: 0;\n border: none;\n }\n "]))),
|
|
54
|
-
overlay: /*#__PURE__*/React.createElement(ContextMenu,
|
|
59
|
+
overlay: /*#__PURE__*/React.createElement(ContextMenu, configContextMenu),
|
|
55
60
|
visible: (contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.data.id) === data.id,
|
|
56
61
|
onVisibleChange: function onVisibleChange(visible) {
|
|
57
62
|
if (!visible) {
|
|
@@ -3,15 +3,18 @@ import Slider, { Settings } from 'react-slick';
|
|
|
3
3
|
import 'slick-carousel/slick/slick-theme.css';
|
|
4
4
|
import 'slick-carousel/slick/slick.css';
|
|
5
5
|
import { SortItem } from './types';
|
|
6
|
+
export interface Pagination {
|
|
7
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
8
|
+
}
|
|
6
9
|
export interface SortableProps<D, C> {
|
|
7
10
|
/**
|
|
8
11
|
* className
|
|
9
12
|
*/
|
|
10
13
|
className?: string;
|
|
11
14
|
/**
|
|
12
|
-
*
|
|
15
|
+
* 分页
|
|
13
16
|
*/
|
|
14
|
-
|
|
17
|
+
pagination?: Pagination | false;
|
|
15
18
|
/**
|
|
16
19
|
* slider ref
|
|
17
20
|
*/
|
|
@@ -21,30 +24,10 @@ export interface SortableProps<D, C> {
|
|
|
21
24
|
* @see https://react-slick.neostack.com/docs/api
|
|
22
25
|
*/
|
|
23
26
|
sliderProps?: Omit<Settings, 'appendDots' | 'customPaging'>;
|
|
24
|
-
/**
|
|
25
|
-
* 是否不显示名称
|
|
26
|
-
*/
|
|
27
|
-
noLetters?: boolean;
|
|
28
27
|
/**
|
|
29
28
|
* 点击 item 事件
|
|
30
29
|
*/
|
|
31
30
|
onItemClick?: (item: SortItem<D, C>) => void;
|
|
32
|
-
/**
|
|
33
|
-
* 自定义分页点容器
|
|
34
|
-
*/
|
|
35
|
-
pagingDotsBuilder?: (dots: React.ReactNode) => React.JSX.Element;
|
|
36
|
-
/**
|
|
37
|
-
* 自定义分页点
|
|
38
|
-
*/
|
|
39
|
-
pagingDotBuilder?: (item: SortItem<D, C>, index: number) => React.JSX.Element;
|
|
40
|
-
/**
|
|
41
|
-
* 自定义 item 渲染
|
|
42
|
-
*/
|
|
43
|
-
itemBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
44
|
-
/**
|
|
45
|
-
* 自定义 item 图标渲染
|
|
46
|
-
*/
|
|
47
|
-
itemIconBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
48
31
|
}
|
|
49
32
|
declare const Sortable: <D, C>(props: SortableProps<D, C>) => React.JSX.Element;
|
|
50
33
|
export default Sortable;
|
package/dist/Desktop/Sortable.js
CHANGED
|
@@ -11,40 +11,46 @@ import SortableGroupItem from "./Items/GroupItem";
|
|
|
11
11
|
import GroupItemModal from "./Items/Modal/GroupItemModal";
|
|
12
12
|
import ItemInfoModal from "./Items/Modal/InfoModal";
|
|
13
13
|
import SortableItem from "./Items/SortableItem";
|
|
14
|
-
import {
|
|
14
|
+
import { useSortableConfig } from "./context/config/hooks";
|
|
15
|
+
import { useSortableState } from "./context/state/hooks";
|
|
15
16
|
import { ghostClass } from "./style";
|
|
16
17
|
var Sortable = function Sortable(props) {
|
|
17
|
-
var _props$
|
|
18
|
-
|
|
18
|
+
var _props$pagination = props.pagination,
|
|
19
|
+
pagination = _props$pagination === void 0 ? {
|
|
20
|
+
position: 'bottom'
|
|
21
|
+
} : _props$pagination,
|
|
19
22
|
className = props.className,
|
|
20
|
-
pagingDotBuilder = props.pagingDotBuilder,
|
|
21
|
-
pagingDotsBuilder = props.pagingDotsBuilder,
|
|
22
23
|
sliderProps = props.sliderProps,
|
|
23
24
|
_sliderRef = props.sliderRef,
|
|
24
|
-
onItemClick = props.onItemClick
|
|
25
|
-
noLetters = props.noLetters,
|
|
26
|
-
itemBuilder = props.itemBuilder,
|
|
27
|
-
itemIconBuilder = props.itemIconBuilder;
|
|
25
|
+
onItemClick = props.onItemClick;
|
|
28
26
|
var sliderRef = useRef(null);
|
|
29
27
|
var sliderDotsRef = useRef(null);
|
|
30
|
-
var
|
|
31
|
-
list =
|
|
32
|
-
_setList =
|
|
33
|
-
setListStatus =
|
|
34
|
-
showInfoItemData =
|
|
35
|
-
setShowInfoItemData =
|
|
36
|
-
openGroupItemData =
|
|
37
|
-
setOpenGroupItemData =
|
|
38
|
-
setMoveItemId =
|
|
39
|
-
setMoveTargetId =
|
|
28
|
+
var _useSortableState = useSortableState(),
|
|
29
|
+
list = _useSortableState.list,
|
|
30
|
+
_setList = _useSortableState.setList,
|
|
31
|
+
setListStatus = _useSortableState.setListStatus,
|
|
32
|
+
showInfoItemData = _useSortableState.showInfoItemData,
|
|
33
|
+
setShowInfoItemData = _useSortableState.setShowInfoItemData,
|
|
34
|
+
openGroupItemData = _useSortableState.openGroupItemData,
|
|
35
|
+
setOpenGroupItemData = _useSortableState.setOpenGroupItemData,
|
|
36
|
+
setMoveItemId = _useSortableState.setMoveItemId,
|
|
37
|
+
setMoveTargetId = _useSortableState.setMoveTargetId;
|
|
38
|
+
var _useSortableConfig = useSortableConfig(),
|
|
39
|
+
pagingDotBuilder = _useSortableConfig.pagingDotBuilder,
|
|
40
|
+
pagingDotsBuilder = _useSortableConfig.pagingDotsBuilder,
|
|
41
|
+
itemBuilder = _useSortableConfig.itemBuilder;
|
|
40
42
|
var paginingLocationCss = useMemo(function () {
|
|
43
|
+
var _pagination$position;
|
|
44
|
+
if (pagination === false) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
41
47
|
return {
|
|
42
48
|
top: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n .slick-list {\n order: 1;\n }\n .slick-dots {\n position: static;\n }\n "]))),
|
|
43
49
|
bottom: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .slick-dots {\n position: static;\n }\n "]))),
|
|
44
50
|
left: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n .slick-dots {\n position: absolute;\n width: auto;\n left: 0;\n top: 0;\n bottom: 0;\n transform: translateX(-100%);\n display: flex;\n justify-content: center;\n align-items: center;\n .slick-dots-default {\n flex-direction: column;\n }\n }\n "]))),
|
|
45
51
|
right: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n .slick-dots {\n position: absolute;\n width: auto;\n right: 0;\n top: 0;\n bottom: 0;\n transform: translateX(100%);\n display: flex;\n justify-content: center;\n align-items: center;\n .slick-dots-default {\n flex-direction: column;\n }\n }\n "])))
|
|
46
|
-
}[
|
|
47
|
-
}, [
|
|
52
|
+
}[(_pagination$position = pagination.position) !== null && _pagination$position !== void 0 ? _pagination$position : 'bottom'];
|
|
53
|
+
}, [pagination]);
|
|
48
54
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Slider, _extends({
|
|
49
55
|
arrows: false,
|
|
50
56
|
ref: _sliderRef !== null && _sliderRef !== void 0 ? _sliderRef : sliderRef,
|
|
@@ -69,6 +75,9 @@ var Sortable = function Sortable(props) {
|
|
|
69
75
|
if (pagingDotsBuilder) {
|
|
70
76
|
return pagingDotsBuilder(dots);
|
|
71
77
|
}
|
|
78
|
+
if (pagination === false) {
|
|
79
|
+
return /*#__PURE__*/React.createElement("div", null);
|
|
80
|
+
}
|
|
72
81
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("ul", {
|
|
73
82
|
ref: sliderDotsRef,
|
|
74
83
|
className: cx('slick-dots-default', css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: 0.5rem;\n display: inline-flex;\n justify-content: center;\n align-items: center;\n gap: 0.5rem;\n background-color: rgba(0, 0, 0, 0.1);\n border-radius: 0.5rem;\n .slick-active {\n background-color: rgba(0, 0, 0, 0.3);\n color: white;\n padding: 0.25rem;\n border-radius: 0.25rem;\n }\n li {\n margin: 0;\n width: auto;\n height: auto;\n }\n "]))))
|
|
@@ -129,9 +138,7 @@ var Sortable = function Sortable(props) {
|
|
|
129
138
|
data: item,
|
|
130
139
|
itemIndex: index,
|
|
131
140
|
parentIds: [l.id, item.id],
|
|
132
|
-
onClick: onItemClick
|
|
133
|
-
noLetters: noLetters,
|
|
134
|
-
itemIconBuilder: itemIconBuilder
|
|
141
|
+
onClick: onItemClick
|
|
135
142
|
});
|
|
136
143
|
break;
|
|
137
144
|
default:
|
|
@@ -139,9 +146,7 @@ var Sortable = function Sortable(props) {
|
|
|
139
146
|
key: item.id,
|
|
140
147
|
data: item,
|
|
141
148
|
itemIndex: index,
|
|
142
|
-
onClick: onItemClick
|
|
143
|
-
noLetters: noLetters,
|
|
144
|
-
itemIconBuilder: itemIconBuilder
|
|
149
|
+
onClick: onItemClick
|
|
145
150
|
});
|
|
146
151
|
break;
|
|
147
152
|
}
|
|
@@ -157,8 +162,7 @@ var Sortable = function Sortable(props) {
|
|
|
157
162
|
onClose: function onClose() {
|
|
158
163
|
setOpenGroupItemData(null);
|
|
159
164
|
},
|
|
160
|
-
onItemClick: onItemClick
|
|
161
|
-
itemIconBuilder: itemIconBuilder
|
|
165
|
+
onItemClick: onItemClick
|
|
162
166
|
}));
|
|
163
167
|
};
|
|
164
168
|
export default Sortable;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ContextMenuProps } from '../../ContextMenu';
|
|
3
|
+
import { Theme } from '../../theme';
|
|
4
|
+
import { SortItem } from '../../types';
|
|
5
|
+
/**
|
|
6
|
+
* 需要跨多个组件传递的配置,使用 context 传递
|
|
7
|
+
*/
|
|
8
|
+
export interface SortableConfig<D, C> {
|
|
9
|
+
theme?: Theme;
|
|
10
|
+
/**
|
|
11
|
+
* 是否不显示名称
|
|
12
|
+
*/
|
|
13
|
+
noLetters?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 右键菜单设置
|
|
16
|
+
*/
|
|
17
|
+
contextMenu?: ContextMenuProps<D, C> | ((data: SortItem<D, C>) => ContextMenuProps<D, C> | false) | false;
|
|
18
|
+
/**
|
|
19
|
+
* 自定义分页点容器
|
|
20
|
+
*/
|
|
21
|
+
pagingDotsBuilder?: (dots: React.ReactNode) => React.JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* 自定义分页点
|
|
24
|
+
*/
|
|
25
|
+
pagingDotBuilder?: (item: SortItem<D, C>, index: number) => React.JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* 自定义 item 渲染
|
|
28
|
+
*/
|
|
29
|
+
itemBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* 自定义 item 图标渲染
|
|
32
|
+
*/
|
|
33
|
+
itemIconBuilder?: (item: SortItem<D, C>) => React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* 自定义右键菜单
|
|
36
|
+
*/
|
|
37
|
+
contextMenuBuilder?: (data: SortItem<D, C>) => ContextMenuProps<D, C>;
|
|
38
|
+
}
|
|
39
|
+
export declare const SortableConfigContext: React.Context<SortableConfig<any, any>>;
|
|
40
|
+
export interface SortableConfigProviderProps<D, C> extends Omit<SortableConfig<D, C>, 'theme'> {
|
|
41
|
+
readonly theme?: 'light' | 'dark' | Theme;
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
}
|
|
44
|
+
export declare const SortableConfigProvider: <D, C>(props: SortableConfigProviderProps<D, C>) => React.JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["children", "theme"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
10
|
+
import React, { createContext, useMemo } from 'react';
|
|
11
|
+
import { themeDark, themeLight } from "../../theme";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 需要跨多个组件传递的配置,使用 context 传递
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export var SortableConfigContext = /*#__PURE__*/createContext({});
|
|
18
|
+
export var SortableConfigProvider = function SortableConfigProvider(props) {
|
|
19
|
+
var children = props.children,
|
|
20
|
+
propTheme = props.theme,
|
|
21
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
22
|
+
var theme = useMemo(function () {
|
|
23
|
+
if (propTheme === 'light') {
|
|
24
|
+
return themeLight;
|
|
25
|
+
} else if (propTheme === 'dark') {
|
|
26
|
+
return themeDark;
|
|
27
|
+
} else {
|
|
28
|
+
return propTheme;
|
|
29
|
+
}
|
|
30
|
+
}, [propTheme]);
|
|
31
|
+
return /*#__PURE__*/React.createElement(SortableConfigContext.Provider, {
|
|
32
|
+
value: _objectSpread({
|
|
33
|
+
theme: theme
|
|
34
|
+
}, rest)
|
|
35
|
+
}, children);
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useSortableConfig: () => import("./context").SortableConfig<any, any>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import { SortItem } from './types';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SortItem } from '../../types';
|
|
4
3
|
interface ContextMenu {
|
|
5
4
|
rect: DOMRect;
|
|
6
5
|
data: any;
|
|
@@ -8,14 +7,14 @@ interface ContextMenu {
|
|
|
8
7
|
pageY?: number;
|
|
9
8
|
}
|
|
10
9
|
type ListStatus = 'onMove';
|
|
11
|
-
export interface
|
|
10
|
+
export interface SortableState {
|
|
12
11
|
list: SortItem[];
|
|
13
12
|
setList: any;
|
|
14
13
|
contextMenu: ContextMenu | null;
|
|
15
14
|
setContextMenu: (e: ContextMenu | null) => void;
|
|
16
15
|
listStatus: ListStatus | null;
|
|
17
16
|
setListStatus: (e: ListStatus | null) => void;
|
|
18
|
-
contextMenuFuns: (data: any) => any;
|
|
17
|
+
contextMenuFuns: (data: any, enable: boolean) => any;
|
|
19
18
|
hideContextMenu: () => void;
|
|
20
19
|
/** 点击右键菜单信息数据 */
|
|
21
20
|
showInfoItemData: SortItem | null;
|
|
@@ -34,16 +33,26 @@ export interface SortableContextProps {
|
|
|
34
33
|
/** 当前元素将要移动到的元素id */
|
|
35
34
|
moveTargetId: string | number | null;
|
|
36
35
|
setMoveTargetId: (e: string | number | null) => void;
|
|
37
|
-
theme?: Theme;
|
|
38
36
|
}
|
|
39
|
-
export declare const
|
|
40
|
-
interface
|
|
41
|
-
|
|
37
|
+
export declare const SortableStateContext: React.Context<SortableState>;
|
|
38
|
+
export interface SortableStateProviderProps<D, C> {
|
|
39
|
+
/**
|
|
40
|
+
* 列表数据
|
|
41
|
+
*/
|
|
42
42
|
list?: SortItem<D, C>[];
|
|
43
|
+
/**
|
|
44
|
+
* 列表数据变更事件
|
|
45
|
+
*/
|
|
43
46
|
onChange?: (list: SortItem<D, C>[]) => void;
|
|
47
|
+
/**
|
|
48
|
+
* 本地存储 key
|
|
49
|
+
*/
|
|
44
50
|
readonly storageKey?: string;
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
/**
|
|
52
|
+
* 是否启用缓存
|
|
53
|
+
*/
|
|
54
|
+
enableCaching?: boolean;
|
|
55
|
+
children: React.ReactNode;
|
|
47
56
|
}
|
|
48
|
-
export declare const
|
|
57
|
+
export declare const SortableStateProvider: <D, C>(props: SortableStateProviderProps<D, C>) => React.JSX.Element;
|
|
49
58
|
export {};
|
|
@@ -15,11 +15,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
15
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
17
|
import { useDebounceEffect, useLocalStorageState } from 'ahooks';
|
|
18
|
-
import React, { createContext, useEffect,
|
|
18
|
+
import React, { createContext, useEffect, useRef, useState } from 'react';
|
|
19
19
|
import { v4 as uuidv4 } from 'uuid';
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
export var SortableContext = /*#__PURE__*/createContext({
|
|
20
|
+
import SortableUtils from "../../utils";
|
|
21
|
+
export var SortableStateContext = /*#__PURE__*/createContext({
|
|
23
22
|
list: [],
|
|
24
23
|
setList: function setList() {},
|
|
25
24
|
contextMenu: null,
|
|
@@ -39,19 +38,17 @@ export var SortableContext = /*#__PURE__*/createContext({
|
|
|
39
38
|
moveItemId: null,
|
|
40
39
|
setMoveItemId: function setMoveItemId() {},
|
|
41
40
|
moveTargetId: null,
|
|
42
|
-
setMoveTargetId: function setMoveTargetId() {}
|
|
43
|
-
theme: themeLight
|
|
41
|
+
setMoveTargetId: function setMoveTargetId() {}
|
|
44
42
|
});
|
|
45
|
-
export var
|
|
46
|
-
var children =
|
|
47
|
-
|
|
48
|
-
propList =
|
|
49
|
-
propOnChange =
|
|
50
|
-
|
|
51
|
-
storageKey =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
enableCaching = _ref$enableCaching === void 0 ? true : _ref$enableCaching;
|
|
43
|
+
export var SortableStateProvider = function SortableStateProvider(props) {
|
|
44
|
+
var children = props.children,
|
|
45
|
+
_props$list = props.list,
|
|
46
|
+
propList = _props$list === void 0 ? [] : _props$list,
|
|
47
|
+
propOnChange = props.onChange,
|
|
48
|
+
_props$storageKey = props.storageKey,
|
|
49
|
+
storageKey = _props$storageKey === void 0 ? 'ZS_LIBRARY_DESKTOP_SORTABLE_CONFIG' : _props$storageKey,
|
|
50
|
+
_props$enableCaching = props.enableCaching,
|
|
51
|
+
enableCaching = _props$enableCaching === void 0 ? true : _props$enableCaching;
|
|
55
52
|
var _useState = useState(),
|
|
56
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
57
54
|
contextMenuTimer = _useState2[0],
|
|
@@ -119,6 +116,7 @@ export var SortableProvider = function SortableProvider(_ref) {
|
|
|
119
116
|
clearTimeout(contextMenuTimer);
|
|
120
117
|
};
|
|
121
118
|
var contextMenuFuns = function contextMenuFuns(data) {
|
|
119
|
+
var enable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
122
120
|
var _data$config = data.config,
|
|
123
121
|
config = _data$config === void 0 ? {} : _data$config;
|
|
124
122
|
if (config.allowContextMenu === false) {
|
|
@@ -127,6 +125,7 @@ export var SortableProvider = function SortableProvider(_ref) {
|
|
|
127
125
|
return {
|
|
128
126
|
onMouseDown: function onMouseDown(e) {
|
|
129
127
|
setContextMenuTimer(setTimeout(function () {
|
|
128
|
+
if (!enable) return;
|
|
130
129
|
// 解决闭包导致拖拽时右键菜单不消失的问题
|
|
131
130
|
if (listStatusRef.current !== null) return;
|
|
132
131
|
getItemRectAndSetContextMenu(e, data);
|
|
@@ -144,6 +143,7 @@ export var SortableProvider = function SortableProvider(_ref) {
|
|
|
144
143
|
setContextMenuTimer(undefined);
|
|
145
144
|
},
|
|
146
145
|
onContextMenu: function onContextMenu(e) {
|
|
146
|
+
if (!enable) return;
|
|
147
147
|
e.preventDefault();
|
|
148
148
|
getItemRectAndSetContextMenu(e, data);
|
|
149
149
|
}
|
|
@@ -301,16 +301,7 @@ export var SortableProvider = function SortableProvider(_ref) {
|
|
|
301
301
|
}, [list, enableCaching], {
|
|
302
302
|
wait: 1000
|
|
303
303
|
});
|
|
304
|
-
|
|
305
|
-
if (propTheme === 'light') {
|
|
306
|
-
return themeLight;
|
|
307
|
-
} else if (propTheme === 'dark') {
|
|
308
|
-
return themeDark;
|
|
309
|
-
} else {
|
|
310
|
-
return propTheme;
|
|
311
|
-
}
|
|
312
|
-
}, [propTheme]);
|
|
313
|
-
return /*#__PURE__*/React.createElement(SortableContext.Provider, {
|
|
304
|
+
return /*#__PURE__*/React.createElement(SortableStateContext.Provider, {
|
|
314
305
|
value: {
|
|
315
306
|
list: list,
|
|
316
307
|
setList: _setList,
|
|
@@ -331,8 +322,7 @@ export var SortableProvider = function SortableProvider(_ref) {
|
|
|
331
322
|
moveItemId: moveItemId,
|
|
332
323
|
setMoveItemId: setMoveItemId,
|
|
333
324
|
moveTargetId: moveTargetId,
|
|
334
|
-
setMoveTargetId: setMoveTargetId
|
|
335
|
-
theme: theme
|
|
325
|
+
setMoveTargetId: setMoveTargetId
|
|
336
326
|
}
|
|
337
327
|
}, children);
|
|
338
328
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useSortableState: () => import("./context").SortableState;
|
package/dist/Desktop/index.d.ts
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SortableProps } from './Sortable';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export interface DesktopProps<D = any, C = any> extends SortableProps<D, C> {
|
|
6
|
-
/**
|
|
7
|
-
* 数据源
|
|
8
|
-
*/
|
|
9
|
-
list: SortItem<D, C>[];
|
|
10
|
-
/**
|
|
11
|
-
* onChange 事件,当排序发生变化时触发
|
|
12
|
-
*/
|
|
13
|
-
onChange?: (list: SortItem<D, C>[]) => void;
|
|
14
|
-
/**
|
|
15
|
-
* 本地存储 key
|
|
16
|
-
*/
|
|
17
|
-
readonly storageKey?: string;
|
|
18
|
-
/**
|
|
19
|
-
* 主题配置
|
|
20
|
-
*/
|
|
21
|
-
theme?: 'light' | 'dark' | Theme;
|
|
22
|
-
/**
|
|
23
|
-
* 是否启用缓存
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
enableCaching: boolean;
|
|
3
|
+
import { SortableConfigProviderProps } from './context/config/context';
|
|
4
|
+
import { SortableStateProviderProps } from './context/state/context';
|
|
5
|
+
export interface DesktopProps<D = any, C = any> extends SortableProps<D, C>, Omit<SortableStateProviderProps<D, C>, 'children'>, Omit<SortableConfigProviderProps<D, C>, 'children'> {
|
|
27
6
|
}
|
|
28
7
|
declare const Desktop: <D, C>(props: DesktopProps<D, C>) => React.JSX.Element;
|
|
29
8
|
export default Desktop;
|
package/dist/Desktop/index.js
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
var _excluded = ["list", "onChange", "storageKey", "theme", "
|
|
1
|
+
var _excluded = ["list", "onChange", "storageKey", "enableCaching", "theme", "noLetters", "contextMenu", "contextMenuBuilder", "itemBuilder", "itemIconBuilder", "pagingDotBuilder", "pagingDotsBuilder"];
|
|
2
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
3
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import Sortable from "./Sortable";
|
|
6
|
-
import {
|
|
6
|
+
import { SortableConfigProvider } from "./context/config/context";
|
|
7
|
+
import { SortableStateProvider } from "./context/state/context";
|
|
7
8
|
var Desktop = function Desktop(props) {
|
|
8
9
|
var list = props.list,
|
|
9
10
|
onChange = props.onChange,
|
|
10
11
|
storageKey = props.storageKey,
|
|
11
|
-
theme = props.theme,
|
|
12
12
|
enableCaching = props.enableCaching,
|
|
13
|
+
theme = props.theme,
|
|
14
|
+
noLetters = props.noLetters,
|
|
15
|
+
contextMenu = props.contextMenu,
|
|
16
|
+
contextMenuBuilder = props.contextMenuBuilder,
|
|
17
|
+
itemBuilder = props.itemBuilder,
|
|
18
|
+
itemIconBuilder = props.itemIconBuilder,
|
|
19
|
+
pagingDotBuilder = props.pagingDotBuilder,
|
|
20
|
+
pagingDotsBuilder = props.pagingDotsBuilder,
|
|
13
21
|
rest = _objectWithoutProperties(props, _excluded);
|
|
14
|
-
|
|
15
|
-
theme: theme,
|
|
22
|
+
var state = {
|
|
16
23
|
list: list,
|
|
17
24
|
onChange: onChange,
|
|
18
25
|
storageKey: storageKey,
|
|
19
26
|
enableCaching: enableCaching
|
|
20
|
-
}
|
|
27
|
+
};
|
|
28
|
+
var config = {
|
|
29
|
+
theme: theme,
|
|
30
|
+
noLetters: noLetters,
|
|
31
|
+
contextMenu: contextMenu,
|
|
32
|
+
pagingDotsBuilder: pagingDotsBuilder,
|
|
33
|
+
pagingDotBuilder: pagingDotBuilder,
|
|
34
|
+
itemBuilder: itemBuilder,
|
|
35
|
+
itemIconBuilder: itemIconBuilder,
|
|
36
|
+
contextMenuBuilder: contextMenuBuilder
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/React.createElement(SortableStateProvider, state, /*#__PURE__*/React.createElement(SortableConfigProvider, config, /*#__PURE__*/React.createElement(Sortable, rest)));
|
|
21
39
|
};
|
|
22
40
|
export default Desktop;
|
package/package.json
CHANGED
package/dist/Desktop/hook.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useSortable: () => import("./context").SortableContextProps;
|