@pisell/materials 1.0.606 → 1.0.607

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.
Files changed (107) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +154 -146
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +37 -23
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +38 -24
  11. package/es/components/Pagination/index.d.ts +1 -1
  12. package/es/components/appVersionControl/index.less +3 -0
  13. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -4
  14. package/es/components/dataSourceComponents/fields/index.d.ts +1 -1
  15. package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +3 -0
  16. package/es/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  17. package/es/components/pisellDraggable/components/Action/Action.js +31 -0
  18. package/es/components/pisellDraggable/components/Action/Action.less +50 -0
  19. package/es/components/pisellDraggable/components/Action/index.d.ts +2 -0
  20. package/es/components/pisellDraggable/components/Action/index.js +1 -0
  21. package/es/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  22. package/es/components/pisellDraggable/components/Handle/Handle.js +15 -0
  23. package/es/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  24. package/es/components/pisellDraggable/components/Handle/index.js +1 -0
  25. package/es/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  26. package/es/components/pisellDraggable/components/Remove/Remove.js +17 -0
  27. package/es/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  28. package/es/components/pisellDraggable/components/Remove/index.js +1 -0
  29. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  30. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +51 -0
  31. package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  32. package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +57 -0
  33. package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  34. package/es/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  35. package/es/components/pisellDraggable/components/TreeItem/index.js +2 -0
  36. package/es/components/pisellDraggable/components/index.d.ts +4 -0
  37. package/es/components/pisellDraggable/components/index.js +4 -0
  38. package/es/components/pisellDraggable/index.d.ts +27 -3
  39. package/es/components/pisellDraggable/index.js +380 -2
  40. package/es/components/pisellDraggable/types.d.ts +15 -99
  41. package/es/components/pisellDraggable/utilities.d.ts +17 -0
  42. package/es/components/pisellDraggable/utilities.js +230 -0
  43. package/es/components/pisellModal/components/Information/index.js +0 -1
  44. package/es/components/table/Table/utils.d.ts +1 -1
  45. package/es/components/versionModal/index.js +3 -1
  46. package/es/components/versionModal/index.less +9 -2
  47. package/es/locales/en-US.d.ts +6 -6
  48. package/es/locales/en-US.js +16 -22
  49. package/es/locales/zh-CN.d.ts +6 -6
  50. package/es/locales/zh-CN.js +15 -21
  51. package/es/locales/zh-TW.d.ts +6 -6
  52. package/es/locales/zh-TW.js +17 -23
  53. package/lib/components/Pagination/index.d.ts +1 -1
  54. package/lib/components/appVersionControl/index.less +3 -0
  55. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +4 -4
  56. package/lib/components/dataSourceComponents/fields/index.d.ts +1 -1
  57. package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +3 -0
  58. package/lib/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  59. package/lib/components/pisellDraggable/components/Action/Action.js +60 -0
  60. package/lib/components/pisellDraggable/components/Action/Action.less +50 -0
  61. package/lib/components/pisellDraggable/components/Action/index.d.ts +2 -0
  62. package/lib/components/pisellDraggable/components/Action/index.js +29 -0
  63. package/lib/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  64. package/lib/components/pisellDraggable/components/Handle/Handle.js +54 -0
  65. package/lib/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  66. package/lib/components/pisellDraggable/components/Handle/index.js +29 -0
  67. package/lib/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  68. package/lib/components/pisellDraggable/components/Remove/Remove.js +53 -0
  69. package/lib/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  70. package/lib/components/pisellDraggable/components/Remove/index.js +29 -0
  71. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  72. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +83 -0
  73. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  74. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +93 -0
  75. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  76. package/lib/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  77. package/lib/components/pisellDraggable/components/TreeItem/index.js +32 -0
  78. package/lib/components/pisellDraggable/components/index.d.ts +4 -0
  79. package/lib/components/pisellDraggable/components/index.js +40 -0
  80. package/lib/components/pisellDraggable/index.d.ts +27 -3
  81. package/lib/components/pisellDraggable/index.js +237 -2
  82. package/lib/components/pisellDraggable/types.d.ts +15 -99
  83. package/lib/components/pisellDraggable/utilities.d.ts +17 -0
  84. package/lib/components/pisellDraggable/utilities.js +190 -0
  85. package/lib/components/pisellModal/components/Information/index.js +0 -1
  86. package/lib/components/table/Table/utils.d.ts +1 -1
  87. package/lib/components/versionModal/index.js +1 -1
  88. package/lib/components/versionModal/index.less +9 -2
  89. package/lib/locales/en-US.d.ts +6 -6
  90. package/lib/locales/en-US.js +8 -0
  91. package/lib/locales/zh-CN.d.ts +6 -6
  92. package/lib/locales/zh-CN.js +7 -0
  93. package/lib/locales/zh-TW.d.ts +6 -6
  94. package/lib/locales/zh-TW.js +7 -0
  95. package/lowcode/custom-select/meta.ts +11 -15
  96. package/lowcode/form-item-translation/meta.ts +59 -1
  97. package/package.json +2 -2
  98. package/es/components/pisellDraggable/PisellDraggable.d.ts +0 -18
  99. package/es/components/pisellDraggable/PisellDraggable.js +0 -190
  100. package/es/components/pisellDraggable/PisellDraggable.less +0 -154
  101. package/es/components/pisellDraggable/SortableItem.d.ts +0 -41
  102. package/es/components/pisellDraggable/SortableItem.js +0 -115
  103. package/lib/components/pisellDraggable/PisellDraggable.d.ts +0 -18
  104. package/lib/components/pisellDraggable/PisellDraggable.js +0 -175
  105. package/lib/components/pisellDraggable/PisellDraggable.less +0 -154
  106. package/lib/components/pisellDraggable/SortableItem.d.ts +0 -41
  107. package/lib/components/pisellDraggable/SortableItem.js +0 -127
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDraggable/components/TreeItem/index.ts
20
+ var TreeItem_exports = {};
21
+ __export(TreeItem_exports, {
22
+ SortableTreeItem: () => import_SortableTreeItem.SortableTreeItem,
23
+ TreeItem: () => import_TreeItem.TreeItem
24
+ });
25
+ module.exports = __toCommonJS(TreeItem_exports);
26
+ var import_TreeItem = require("./TreeItem");
27
+ var import_SortableTreeItem = require("./SortableTreeItem");
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ SortableTreeItem,
31
+ TreeItem
32
+ });
@@ -0,0 +1,4 @@
1
+ export { Action } from './Action';
2
+ export { Handle } from './Handle';
3
+ export { Remove } from './Remove';
4
+ export { TreeItem, SortableTreeItem } from './TreeItem';
@@ -0,0 +1,40 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDraggable/components/index.ts
20
+ var components_exports = {};
21
+ __export(components_exports, {
22
+ Action: () => import_Action.Action,
23
+ Handle: () => import_Handle.Handle,
24
+ Remove: () => import_Remove.Remove,
25
+ SortableTreeItem: () => import_TreeItem.SortableTreeItem,
26
+ TreeItem: () => import_TreeItem.TreeItem
27
+ });
28
+ module.exports = __toCommonJS(components_exports);
29
+ var import_Action = require("./Action");
30
+ var import_Handle = require("./Handle");
31
+ var import_Remove = require("./Remove");
32
+ var import_TreeItem = require("./TreeItem");
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ Action,
36
+ Handle,
37
+ Remove,
38
+ SortableTreeItem,
39
+ TreeItem
40
+ });
@@ -1,3 +1,27 @@
1
- import PisellDraggable from './PisellDraggable';
2
- export type { DraggableItem, PisellDraggableProps } from './types';
3
- export default PisellDraggable;
1
+ /**
2
+ * 可拖拽树形组件
3
+ * 基于@dnd-kit库实现,支持拖拽排序、展开折叠、删除等功能
4
+ */
5
+ import React from 'react';
6
+ import type { TreeItem, TreeItems } from './types';
7
+ interface Props {
8
+ /** 是否支持折叠功能 */
9
+ collapsible?: boolean;
10
+ /** 初始树形数据,默认使用 initialItems */
11
+ value?: TreeItems;
12
+ /** 缩进宽度,控制子节点的缩进距离 */
13
+ indentationWidth?: number;
14
+ /** 是否显示拖拽指示器 */
15
+ indicator?: boolean;
16
+ /** 是否支持删除节点功能 */
17
+ removable?: boolean;
18
+ /** 自定义渲染树节点 */
19
+ renderItem?: (item: TreeItem) => React.ReactNode;
20
+ /** 树形数据变化回调 */
21
+ onChange?: (items: TreeItems) => void;
22
+ /** 删除节点前 */
23
+ onRemoveBefore?: (item: TreeItem) => Promise<boolean>;
24
+ }
25
+ export declare function SortableTree({ collapsible, value, indicator, indentationWidth, removable, renderItem, onChange, onRemoveBefore, }: Props): React.JSX.Element;
26
+ declare const Demo: () => React.JSX.Element;
27
+ export default Demo;
@@ -29,8 +29,243 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/components/pisellDraggable/index.tsx
30
30
  var pisellDraggable_exports = {};
31
31
  __export(pisellDraggable_exports, {
32
+ SortableTree: () => SortableTree,
32
33
  default: () => pisellDraggable_default
33
34
  });
34
35
  module.exports = __toCommonJS(pisellDraggable_exports);
35
- var import_PisellDraggable = __toESM(require("./PisellDraggable"));
36
- var pisellDraggable_default = import_PisellDraggable.default;
36
+ var import_core = require("@dnd-kit/core");
37
+ var import_sortable = require("@dnd-kit/sortable");
38
+ var import_react = __toESM(require("react"));
39
+ var import_react_dom = require("react-dom");
40
+ var import_utilities = require("@dnd-kit/utilities");
41
+ var import_components = require("./components");
42
+ var import_utilities2 = require("./utilities");
43
+ var initialItems = [
44
+ {
45
+ id: "Home",
46
+ children: []
47
+ },
48
+ {
49
+ id: "Collections",
50
+ children: [
51
+ { id: "Spring", children: [] },
52
+ { id: "Summer", children: [] },
53
+ { id: "Fall", children: [] },
54
+ { id: "Winter", children: [] }
55
+ ]
56
+ },
57
+ {
58
+ id: "About Us",
59
+ children: []
60
+ },
61
+ {
62
+ id: "My Account",
63
+ children: [
64
+ { id: "Addresses", children: [] },
65
+ { id: "Order History", children: [] }
66
+ ]
67
+ }
68
+ ];
69
+ var measuring = {
70
+ droppable: {
71
+ strategy: import_core.MeasuringStrategy.Always
72
+ }
73
+ };
74
+ var dropAnimationConfig = {
75
+ keyframes({ transform }) {
76
+ return [
77
+ { opacity: 1, transform: import_utilities.CSS.Transform.toString(transform.initial) },
78
+ {
79
+ opacity: 0,
80
+ transform: import_utilities.CSS.Transform.toString({
81
+ ...transform.final,
82
+ x: transform.final.x + 5,
83
+ y: transform.final.y + 5
84
+ })
85
+ }
86
+ ];
87
+ },
88
+ easing: "ease-out",
89
+ sideEffects({ active }) {
90
+ active.node.animate([{ opacity: 0 }, { opacity: 1 }], {
91
+ duration: import_core.defaultDropAnimation.duration,
92
+ easing: import_core.defaultDropAnimation.easing
93
+ });
94
+ }
95
+ };
96
+ function SortableTree({
97
+ collapsible = true,
98
+ value = initialItems,
99
+ indicator = false,
100
+ indentationWidth = 50,
101
+ removable = true,
102
+ renderItem,
103
+ onChange,
104
+ onRemoveBefore
105
+ }) {
106
+ const [items, setItems] = (0, import_react.useState)([]);
107
+ const [activeId, setActiveId] = (0, import_react.useState)(null);
108
+ const [overId, setOverId] = (0, import_react.useState)(null);
109
+ const [offsetLeft, setOffsetLeft] = (0, import_react.useState)(0);
110
+ (0, import_react.useEffect)(() => {
111
+ console.log("初始化", value);
112
+ setItems(value);
113
+ }, [value]);
114
+ const flattenedItems = (0, import_react.useMemo)(() => {
115
+ const flattenedTree = (0, import_utilities2.flattenTree)(items);
116
+ const collapsedItems = flattenedTree.reduce(
117
+ (acc, { children, collapsed, id }) => collapsed && children.length ? [...acc, id] : acc,
118
+ []
119
+ );
120
+ return (0, import_utilities2.removeChildrenOf)(
121
+ flattenedTree,
122
+ activeId != null ? [activeId, ...collapsedItems] : collapsedItems
123
+ );
124
+ }, [activeId, items]);
125
+ const projected = activeId && overId ? (0, import_utilities2.getProjection)(
126
+ flattenedItems,
127
+ activeId,
128
+ overId,
129
+ offsetLeft,
130
+ indentationWidth
131
+ ) : null;
132
+ const sensorContext = (0, import_react.useRef)({
133
+ items: flattenedItems,
134
+ offset: offsetLeft
135
+ });
136
+ const sensors = (0, import_core.useSensors)((0, import_core.useSensor)(import_core.PointerSensor));
137
+ const sortedIds = (0, import_react.useMemo)(
138
+ () => flattenedItems.map(({ id }) => id),
139
+ [flattenedItems]
140
+ );
141
+ const activeItem = activeId ? flattenedItems.find(({ id }) => id === activeId) : null;
142
+ (0, import_react.useEffect)(() => {
143
+ sensorContext.current = {
144
+ items: flattenedItems,
145
+ offset: offsetLeft
146
+ };
147
+ }, [flattenedItems, offsetLeft]);
148
+ (0, import_react.useEffect)(() => {
149
+ document.body.id = "body";
150
+ }, []);
151
+ return /* @__PURE__ */ import_react.default.createElement(
152
+ import_core.DndContext,
153
+ {
154
+ sensors,
155
+ collisionDetection: import_core.closestCenter,
156
+ measuring,
157
+ onDragStart: handleDragStart,
158
+ onDragMove: handleDragMove,
159
+ onDragOver: handleDragOver,
160
+ onDragEnd: handleDragEnd,
161
+ onDragCancel: handleDragCancel
162
+ },
163
+ /* @__PURE__ */ import_react.default.createElement(import_sortable.SortableContext, { items: sortedIds, strategy: import_sortable.verticalListSortingStrategy }, flattenedItems.map((item) => {
164
+ const { id, children, collapsed, depth } = item;
165
+ return /* @__PURE__ */ import_react.default.createElement(
166
+ import_components.SortableTreeItem,
167
+ {
168
+ key: id,
169
+ id,
170
+ item,
171
+ depth: id === activeId && projected ? projected.depth : depth,
172
+ indentationWidth,
173
+ indicator,
174
+ collapsed: Boolean(collapsed && children.length),
175
+ onCollapse: collapsible && children.length ? () => handleCollapse(id) : void 0,
176
+ onRemove: removable ? () => handleRemove(item) : void 0,
177
+ renderItem
178
+ }
179
+ );
180
+ }), (0, import_react_dom.createPortal)(
181
+ /* @__PURE__ */ import_react.default.createElement(
182
+ import_core.DragOverlay,
183
+ {
184
+ dropAnimation: dropAnimationConfig,
185
+ modifiers: indicator ? [adjustTranslate] : void 0
186
+ },
187
+ activeId && activeItem ? /* @__PURE__ */ import_react.default.createElement(
188
+ import_components.SortableTreeItem,
189
+ {
190
+ id: activeId,
191
+ depth: activeItem.depth,
192
+ clone: true,
193
+ childCount: (0, import_utilities2.getChildCount)(items, activeId) + 1,
194
+ item: activeItem,
195
+ indentationWidth,
196
+ renderItem
197
+ }
198
+ ) : null
199
+ ),
200
+ document.body
201
+ ))
202
+ );
203
+ function handleDragStart({ active: { id: activeId2 } }) {
204
+ setActiveId(activeId2);
205
+ setOverId(activeId2);
206
+ document.body.style.setProperty("cursor", "grabbing");
207
+ }
208
+ function handleDragMove({ delta }) {
209
+ setOffsetLeft(delta.x);
210
+ }
211
+ function handleDragOver({ over }) {
212
+ setOverId((over == null ? void 0 : over.id) ?? null);
213
+ }
214
+ function handleDragEnd({ active, over }) {
215
+ resetState();
216
+ if (projected && over) {
217
+ const { depth, parentId } = projected;
218
+ const clonedItems = JSON.parse(
219
+ JSON.stringify((0, import_utilities2.flattenTree)(items))
220
+ );
221
+ const overIndex = clonedItems.findIndex(({ id }) => id === over.id);
222
+ const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);
223
+ const activeTreeItem = clonedItems[activeIndex];
224
+ clonedItems[activeIndex] = { ...activeTreeItem, depth, parentId };
225
+ const sortedItems = (0, import_sortable.arrayMove)(clonedItems, activeIndex, overIndex);
226
+ const newItems = (0, import_utilities2.buildTree)(sortedItems);
227
+ setItems(newItems);
228
+ onChange == null ? void 0 : onChange(newItems);
229
+ }
230
+ }
231
+ function handleDragCancel() {
232
+ resetState();
233
+ }
234
+ function resetState() {
235
+ setOverId(null);
236
+ setActiveId(null);
237
+ setOffsetLeft(0);
238
+ document.body.style.setProperty("cursor", "");
239
+ }
240
+ async function handleRemove(item) {
241
+ if (onRemoveBefore) {
242
+ let res = await (onRemoveBefore == null ? void 0 : onRemoveBefore(item));
243
+ if (!res) {
244
+ return;
245
+ }
246
+ }
247
+ setItems((items2) => (0, import_utilities2.removeItem)(items2, item.id));
248
+ onChange == null ? void 0 : onChange(items);
249
+ }
250
+ function handleCollapse(id) {
251
+ setItems(
252
+ (items2) => (0, import_utilities2.setProperty)(items2, id, "collapsed", (value2) => {
253
+ return !value2;
254
+ })
255
+ );
256
+ }
257
+ }
258
+ var adjustTranslate = ({ transform }) => {
259
+ return {
260
+ ...transform,
261
+ y: transform.y - 25
262
+ };
263
+ };
264
+ var Demo = () => {
265
+ return /* @__PURE__ */ import_react.default.createElement(SortableTree, null);
266
+ };
267
+ var pisellDraggable_default = Demo;
268
+ // Annotate the CommonJS export names for ESM import in node:
269
+ 0 && (module.exports = {
270
+ SortableTree
271
+ });
@@ -1,101 +1,17 @@
1
- import { CSSProperties, ReactNode } from 'react';
2
- /**
3
- * 可拖拽项的数据结构
4
- */
5
- export interface DraggableItem {
6
- /** 唯一标识符 */
7
- id: string | number;
8
- /** 渲染的内容 */
9
- content: ReactNode;
10
- /** 子项列表 */
11
- children?: DraggableItem[];
12
- /** 父项ID */
13
- parentId?: string | number;
14
- /** 排序顺序 */
15
- order?: number;
16
- /** 当前项的层级(从0开始) */
17
- level?: number;
1
+ import type { MutableRefObject } from 'react';
2
+ import type { UniqueIdentifier } from '@dnd-kit/core';
3
+ export interface TreeItem {
4
+ id: UniqueIdentifier;
5
+ children: TreeItem[];
6
+ collapsed?: boolean;
18
7
  }
19
- /**
20
- * PisellDraggable 组件的属性定义
21
- */
22
- export interface PisellDraggableProps {
23
- /** 自定义类名 */
24
- className?: string;
25
- /** 自定义样式 */
26
- style?: CSSProperties;
27
- /** 拖拽项数据列表 */
28
- items: DraggableItem[];
29
- /**
30
- * 布局方向
31
- * - vertical: 垂直排列(默认)
32
- * - horizontal: 水平排列
33
- * - grid: 网格布局
34
- */
35
- direction?: 'horizontal' | 'vertical' | 'grid';
36
- /** 网格布局时的列数(仅在 direction='grid' 时生效) */
37
- columns?: number;
38
- /** 是否允许跨容器拖拽 */
39
- allowCrossContainer?: boolean;
40
- /**
41
- * 拖拽开始时的回调
42
- * @param activeId 被拖拽项的ID
43
- */
44
- onDragStart?: (activeId: string | number) => void;
45
- /**
46
- * 拖拽结束时的回调
47
- * @param result 包含拖拽项和目标项的信息
48
- */
49
- onDragEnd?: (result: {
50
- active: DraggableItem;
51
- over: DraggableItem | null;
52
- }) => void;
53
- /**
54
- * 数据变化时的回调
55
- * @param items 更新后的数据列表
56
- */
57
- onChange?: (items: DraggableItem[]) => void;
58
- /**
59
- * 自定义渲染拖拽项
60
- * @param item 当前项的数据
61
- */
62
- renderItem?: (item: DraggableItem) => ReactNode;
63
- /** 拖拽手柄的自定义类名 */
64
- handleClassName?: string;
65
- /** 容器的自定义样式 */
66
- containerStyle?: CSSProperties;
67
- /** 是否禁用拖拽功能 */
68
- disabled?: boolean;
69
- /** 动画持续时间(毫秒) */
70
- animationDuration?: number;
71
- /**
72
- * 拖动方式
73
- * - handle: 仅通过手柄拖动(默认)
74
- * - item: 整个项目可拖动
75
- */
76
- dragMode?: 'handle' | 'item';
77
- /** 嵌套层级的缩进距离(像素) */
78
- indentDistance?: number;
79
- /**
80
- * 最大嵌套深度
81
- * - 0: 不限制深度(默认)
82
- * - n: 最多允许n层嵌套
83
- */
84
- maxDepth?: number;
85
- /**
86
- * 自定义层级样式
87
- * 可以为不同层级设置不同的样式,key为层级数(从0开始)
88
- */
89
- levelStyles?: Record<number, CSSProperties>;
90
- /** 拖拽手柄的自定义图标 */
91
- handleIcon?: ReactNode;
92
- /**
93
- * 拖拽时的动画曲线
94
- * 支持 CSS transition-timing-function 的所有值
95
- */
96
- animationTiming?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
97
- /** 拖拽时的缩放比例 */
98
- dragScale?: number;
99
- /** 当前嵌套层级(内部使用) */
100
- currentLevel?: number;
8
+ export declare type TreeItems = TreeItem[];
9
+ export interface FlattenedItem extends TreeItem {
10
+ parentId: UniqueIdentifier | null;
11
+ depth: number;
12
+ index: number;
101
13
  }
14
+ export declare type SensorContext = MutableRefObject<{
15
+ items: FlattenedItem[];
16
+ offset: number;
17
+ }>;
@@ -0,0 +1,17 @@
1
+ import type { UniqueIdentifier } from '@dnd-kit/core';
2
+ import type { FlattenedItem, TreeItem, TreeItems } from './types';
3
+ export declare const iOS: boolean;
4
+ export declare function getProjection(items: FlattenedItem[], activeId: UniqueIdentifier, overId: UniqueIdentifier, dragOffset: number, indentationWidth: number): {
5
+ depth: number;
6
+ maxDepth: number;
7
+ minDepth: number;
8
+ parentId: UniqueIdentifier | null;
9
+ };
10
+ export declare function flattenTree(items: TreeItems): FlattenedItem[];
11
+ export declare function buildTree(flattenedItems: FlattenedItem[]): TreeItems;
12
+ export declare function findItem(items: TreeItem[], itemId: UniqueIdentifier): TreeItem | undefined;
13
+ export declare function findItemDeep(items: TreeItems, itemId: UniqueIdentifier): TreeItem | undefined;
14
+ export declare function removeItem(items: TreeItems, id: UniqueIdentifier): TreeItem[];
15
+ export declare function setProperty<T extends keyof TreeItem>(items: TreeItems, id: UniqueIdentifier, property: T, setter: (value: TreeItem[T]) => TreeItem[T]): TreeItem[];
16
+ export declare function getChildCount(items: TreeItems, id: UniqueIdentifier): number;
17
+ export declare function removeChildrenOf(items: FlattenedItem[], ids: UniqueIdentifier[]): FlattenedItem[];
@@ -0,0 +1,190 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/components/pisellDraggable/utilities.ts
20
+ var utilities_exports = {};
21
+ __export(utilities_exports, {
22
+ buildTree: () => buildTree,
23
+ findItem: () => findItem,
24
+ findItemDeep: () => findItemDeep,
25
+ flattenTree: () => flattenTree,
26
+ getChildCount: () => getChildCount,
27
+ getProjection: () => getProjection,
28
+ iOS: () => iOS,
29
+ removeChildrenOf: () => removeChildrenOf,
30
+ removeItem: () => removeItem,
31
+ setProperty: () => setProperty
32
+ });
33
+ module.exports = __toCommonJS(utilities_exports);
34
+ var import_sortable = require("@dnd-kit/sortable");
35
+ var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
36
+ function getDragDepth(offset, indentationWidth) {
37
+ return Math.round(offset / indentationWidth);
38
+ }
39
+ function getProjection(items, activeId, overId, dragOffset, indentationWidth) {
40
+ const overItemIndex = items.findIndex(({ id }) => id === overId);
41
+ const activeItemIndex = items.findIndex(({ id }) => id === activeId);
42
+ const activeItem = items[activeItemIndex];
43
+ const newItems = (0, import_sortable.arrayMove)(items, activeItemIndex, overItemIndex);
44
+ const previousItem = newItems[overItemIndex - 1];
45
+ const nextItem = newItems[overItemIndex + 1];
46
+ const dragDepth = getDragDepth(dragOffset, indentationWidth);
47
+ const projectedDepth = activeItem.depth + dragDepth;
48
+ const maxDepth = getMaxDepth({
49
+ previousItem
50
+ });
51
+ const minDepth = getMinDepth({ nextItem });
52
+ let depth = projectedDepth;
53
+ if (projectedDepth >= maxDepth) {
54
+ depth = maxDepth;
55
+ } else if (projectedDepth < minDepth) {
56
+ depth = minDepth;
57
+ }
58
+ return { depth, maxDepth, minDepth, parentId: getParentId() };
59
+ function getParentId() {
60
+ var _a;
61
+ if (depth === 0 || !previousItem) {
62
+ return null;
63
+ }
64
+ if (depth === previousItem.depth) {
65
+ return previousItem.parentId;
66
+ }
67
+ if (depth > previousItem.depth) {
68
+ return previousItem.id;
69
+ }
70
+ const newParent = (_a = newItems.slice(0, overItemIndex).reverse().find((item) => item.depth === depth)) == null ? void 0 : _a.parentId;
71
+ return newParent ?? null;
72
+ }
73
+ }
74
+ function getMaxDepth({ previousItem }) {
75
+ if (previousItem) {
76
+ return previousItem.depth + 1;
77
+ }
78
+ return 0;
79
+ }
80
+ function getMinDepth({ nextItem }) {
81
+ if (nextItem) {
82
+ return nextItem.depth;
83
+ }
84
+ return 0;
85
+ }
86
+ function flatten(items, parentId = null, depth = 0) {
87
+ return items.reduce((acc, item, index) => {
88
+ return [
89
+ ...acc,
90
+ { ...item, parentId, depth, index },
91
+ ...flatten(item.children, item.id, depth + 1)
92
+ ];
93
+ }, []);
94
+ }
95
+ function flattenTree(items) {
96
+ return flatten(items);
97
+ }
98
+ function buildTree(flattenedItems) {
99
+ const root = { id: "root", children: [] };
100
+ const nodes = { [root.id]: root };
101
+ const items = flattenedItems.map((item) => ({ ...item, children: [] }));
102
+ for (const item of items) {
103
+ const { id, children } = item;
104
+ const parentId = item.parentId ?? root.id;
105
+ const parent = nodes[parentId] ?? findItem(items, parentId);
106
+ nodes[id] = { id, children };
107
+ parent.children.push(item);
108
+ }
109
+ return root.children;
110
+ }
111
+ function findItem(items, itemId) {
112
+ return items.find(({ id }) => id === itemId);
113
+ }
114
+ function findItemDeep(items, itemId) {
115
+ for (const item of items) {
116
+ const { id, children } = item;
117
+ if (id === itemId) {
118
+ return item;
119
+ }
120
+ if (children.length) {
121
+ const child = findItemDeep(children, itemId);
122
+ if (child) {
123
+ return child;
124
+ }
125
+ }
126
+ }
127
+ return void 0;
128
+ }
129
+ function removeItem(items, id) {
130
+ const newItems = [];
131
+ for (const item of items) {
132
+ if (item.id === id) {
133
+ continue;
134
+ }
135
+ if (item.children.length) {
136
+ item.children = removeItem(item.children, id);
137
+ }
138
+ newItems.push(item);
139
+ }
140
+ return newItems;
141
+ }
142
+ function setProperty(items, id, property, setter) {
143
+ for (const item of items) {
144
+ if (item.id === id) {
145
+ item[property] = setter(item[property]);
146
+ continue;
147
+ }
148
+ if (item.children.length) {
149
+ item.children = setProperty(item.children, id, property, setter);
150
+ }
151
+ }
152
+ return [...items];
153
+ }
154
+ function countChildren(items, count = 0) {
155
+ return items.reduce((acc, { children }) => {
156
+ if (children.length) {
157
+ return countChildren(children, acc + 1);
158
+ }
159
+ return acc + 1;
160
+ }, count);
161
+ }
162
+ function getChildCount(items, id) {
163
+ const item = findItemDeep(items, id);
164
+ return item ? countChildren(item.children) : 0;
165
+ }
166
+ function removeChildrenOf(items, ids) {
167
+ const excludeParentIds = [...ids];
168
+ return items.filter((item) => {
169
+ if (item.parentId && excludeParentIds.includes(item.parentId)) {
170
+ if (item.children.length) {
171
+ excludeParentIds.push(item.id);
172
+ }
173
+ return false;
174
+ }
175
+ return true;
176
+ });
177
+ }
178
+ // Annotate the CommonJS export names for ESM import in node:
179
+ 0 && (module.exports = {
180
+ buildTree,
181
+ findItem,
182
+ findItemDeep,
183
+ flattenTree,
184
+ getChildCount,
185
+ getProjection,
186
+ iOS,
187
+ removeChildrenOf,
188
+ removeItem,
189
+ setProperty
190
+ });
@@ -44,7 +44,6 @@ var Information = (props) => {
44
44
  mobileModalHeight: "auto",
45
45
  headerDivider: false,
46
46
  footerDivider,
47
- size: "small",
48
47
  transitionName: "pisell-move-down"
49
48
  },
50
49
  /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-modal-information-title" }, title),