@pisell/materials 1.0.605 → 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 (110) 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 +29 -29
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +30 -30
  11. package/es/components/Pagination/index.d.ts +1 -1
  12. package/es/components/appVersionControl/index.less +3 -0
  13. package/es/components/dataSourceComponents/dataSourceForm/utils.js +6 -9
  14. package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +4 -2
  15. package/es/components/dataSourceComponents/fields/index.d.ts +1 -1
  16. package/es/components/dataSourceComponents/provider/variables/VariablesProvider.js +3 -0
  17. package/es/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  18. package/es/components/pisellDraggable/components/Action/Action.js +31 -0
  19. package/es/components/pisellDraggable/components/Action/Action.less +50 -0
  20. package/es/components/pisellDraggable/components/Action/index.d.ts +2 -0
  21. package/es/components/pisellDraggable/components/Action/index.js +1 -0
  22. package/es/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  23. package/es/components/pisellDraggable/components/Handle/Handle.js +15 -0
  24. package/es/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  25. package/es/components/pisellDraggable/components/Handle/index.js +1 -0
  26. package/es/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  27. package/es/components/pisellDraggable/components/Remove/Remove.js +17 -0
  28. package/es/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  29. package/es/components/pisellDraggable/components/Remove/index.js +1 -0
  30. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  31. package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +51 -0
  32. package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  33. package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +57 -0
  34. package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  35. package/es/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  36. package/es/components/pisellDraggable/components/TreeItem/index.js +2 -0
  37. package/es/components/pisellDraggable/components/index.d.ts +4 -0
  38. package/es/components/pisellDraggable/components/index.js +4 -0
  39. package/es/components/pisellDraggable/index.d.ts +27 -3
  40. package/es/components/pisellDraggable/index.js +380 -2
  41. package/es/components/pisellDraggable/types.d.ts +15 -99
  42. package/es/components/pisellDraggable/utilities.d.ts +17 -0
  43. package/es/components/pisellDraggable/utilities.js +230 -0
  44. package/es/components/pisellModal/components/Information/index.js +0 -1
  45. package/es/components/table/Table/utils.d.ts +1 -1
  46. package/es/components/versionModal/index.js +3 -1
  47. package/es/components/versionModal/index.less +9 -2
  48. package/es/locales/en-US.d.ts +6 -6
  49. package/es/locales/en-US.js +16 -22
  50. package/es/locales/zh-CN.d.ts +6 -6
  51. package/es/locales/zh-CN.js +15 -21
  52. package/es/locales/zh-TW.d.ts +6 -6
  53. package/es/locales/zh-TW.js +17 -23
  54. package/lib/components/Pagination/index.d.ts +1 -1
  55. package/lib/components/appVersionControl/index.less +3 -0
  56. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +0 -6
  57. package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +2 -2
  58. package/lib/components/dataSourceComponents/fields/index.d.ts +1 -1
  59. package/lib/components/dataSourceComponents/provider/variables/VariablesProvider.js +3 -0
  60. package/lib/components/pisellDraggable/components/Action/Action.d.ts +10 -0
  61. package/lib/components/pisellDraggable/components/Action/Action.js +60 -0
  62. package/lib/components/pisellDraggable/components/Action/Action.less +50 -0
  63. package/lib/components/pisellDraggable/components/Action/index.d.ts +2 -0
  64. package/lib/components/pisellDraggable/components/Action/index.js +29 -0
  65. package/lib/components/pisellDraggable/components/Handle/Handle.d.ts +3 -0
  66. package/lib/components/pisellDraggable/components/Handle/Handle.js +54 -0
  67. package/lib/components/pisellDraggable/components/Handle/index.d.ts +1 -0
  68. package/lib/components/pisellDraggable/components/Handle/index.js +29 -0
  69. package/lib/components/pisellDraggable/components/Remove/Remove.d.ts +3 -0
  70. package/lib/components/pisellDraggable/components/Remove/Remove.js +53 -0
  71. package/lib/components/pisellDraggable/components/Remove/index.d.ts +1 -0
  72. package/lib/components/pisellDraggable/components/Remove/index.js +29 -0
  73. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.d.ts +8 -0
  74. package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +83 -0
  75. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +21 -0
  76. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +93 -0
  77. package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +128 -0
  78. package/lib/components/pisellDraggable/components/TreeItem/index.d.ts +2 -0
  79. package/lib/components/pisellDraggable/components/TreeItem/index.js +32 -0
  80. package/lib/components/pisellDraggable/components/index.d.ts +4 -0
  81. package/lib/components/pisellDraggable/components/index.js +40 -0
  82. package/lib/components/pisellDraggable/index.d.ts +27 -3
  83. package/lib/components/pisellDraggable/index.js +237 -2
  84. package/lib/components/pisellDraggable/types.d.ts +15 -99
  85. package/lib/components/pisellDraggable/utilities.d.ts +17 -0
  86. package/lib/components/pisellDraggable/utilities.js +190 -0
  87. package/lib/components/pisellModal/components/Information/index.js +0 -1
  88. package/lib/components/table/Table/utils.d.ts +1 -1
  89. package/lib/components/versionModal/index.js +1 -1
  90. package/lib/components/versionModal/index.less +9 -2
  91. package/lib/locales/en-US.d.ts +6 -6
  92. package/lib/locales/en-US.js +8 -0
  93. package/lib/locales/zh-CN.d.ts +6 -6
  94. package/lib/locales/zh-CN.js +7 -0
  95. package/lib/locales/zh-TW.d.ts +6 -6
  96. package/lib/locales/zh-TW.js +7 -0
  97. package/lowcode/custom-select/meta.ts +11 -15
  98. package/lowcode/data-source-menu/meta.ts +1 -1
  99. package/lowcode/form-item-translation/meta.ts +59 -1
  100. package/package.json +1 -1
  101. package/es/components/pisellDraggable/PisellDraggable.d.ts +0 -18
  102. package/es/components/pisellDraggable/PisellDraggable.js +0 -190
  103. package/es/components/pisellDraggable/PisellDraggable.less +0 -154
  104. package/es/components/pisellDraggable/SortableItem.d.ts +0 -41
  105. package/es/components/pisellDraggable/SortableItem.js +0 -115
  106. package/lib/components/pisellDraggable/PisellDraggable.d.ts +0 -18
  107. package/lib/components/pisellDraggable/PisellDraggable.js +0 -175
  108. package/lib/components/pisellDraggable/PisellDraggable.less +0 -154
  109. package/lib/components/pisellDraggable/SortableItem.d.ts +0 -41
  110. package/lib/components/pisellDraggable/SortableItem.js +0 -127
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { DraggableItem } from './types';
3
- /**
4
- * 可排序项组件的属性定义
5
- */
6
- interface SortableItemProps {
7
- /** 项目的唯一标识符 */
8
- id: string | number;
9
- /** 项目数据 */
10
- item: DraggableItem;
11
- /** 自定义渲染函数 */
12
- renderItem?: (item: DraggableItem) => React.ReactNode;
13
- /** 拖拽手柄的自定义类名 */
14
- handleClassName?: string;
15
- /** 动画持续时间(毫秒) */
16
- animationDuration?: number;
17
- /** 拖动方式 */
18
- dragMode?: 'handle' | 'item';
19
- /** 嵌套数据变化的回调函数 */
20
- onNestedChange?: (parentId: string | number, items: DraggableItem[]) => void;
21
- /** 缩进距离(像素) */
22
- indentDistance?: number;
23
- /** 最大嵌套深度 */
24
- maxDepth?: number;
25
- /** 层级样式配置 */
26
- levelStyles?: Record<number, React.CSSProperties>;
27
- /** 拖拽手柄图标 */
28
- handleIcon?: React.ReactNode;
29
- /** 动画曲线 */
30
- animationTiming?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
31
- /** 拖拽时的缩放比例 */
32
- dragScale?: number;
33
- /** 当前嵌套层级 */
34
- currentLevel?: number;
35
- }
36
- /**
37
- * 可排序项组件
38
- * 用于渲染单个可拖拽项,支持嵌套结构和自定义渲染
39
- */
40
- export declare const SortableItem: React.FC<SortableItemProps>;
41
- export {};
@@ -1,115 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- import { useSortable } from '@dnd-kit/sortable';
9
- import { CSS } from '@dnd-kit/utilities';
10
- import React from 'react';
11
- import PisellDraggable from "./PisellDraggable";
12
- /**
13
- * 可排序项组件
14
- * 用于渲染单个可拖拽项,支持嵌套结构和自定义渲染
15
- */
16
- export var SortableItem = function SortableItem(_ref) {
17
- var id = _ref.id,
18
- item = _ref.item,
19
- renderItem = _ref.renderItem,
20
- handleClassName = _ref.handleClassName,
21
- _ref$animationDuratio = _ref.animationDuration,
22
- animationDuration = _ref$animationDuratio === void 0 ? 250 : _ref$animationDuratio,
23
- _ref$dragMode = _ref.dragMode,
24
- dragMode = _ref$dragMode === void 0 ? 'handle' : _ref$dragMode,
25
- onNestedChange = _ref.onNestedChange,
26
- _ref$indentDistance = _ref.indentDistance,
27
- indentDistance = _ref$indentDistance === void 0 ? 24 : _ref$indentDistance,
28
- _ref$maxDepth = _ref.maxDepth,
29
- maxDepth = _ref$maxDepth === void 0 ? 0 : _ref$maxDepth,
30
- _ref$levelStyles = _ref.levelStyles,
31
- levelStyles = _ref$levelStyles === void 0 ? {} : _ref$levelStyles,
32
- _ref$handleIcon = _ref.handleIcon,
33
- handleIcon = _ref$handleIcon === void 0 ? '⋮' : _ref$handleIcon,
34
- _ref$animationTiming = _ref.animationTiming,
35
- animationTiming = _ref$animationTiming === void 0 ? 'ease' : _ref$animationTiming,
36
- _ref$dragScale = _ref.dragScale,
37
- dragScale = _ref$dragScale === void 0 ? 1.02 : _ref$dragScale,
38
- _ref$currentLevel = _ref.currentLevel,
39
- currentLevel = _ref$currentLevel === void 0 ? 0 : _ref$currentLevel;
40
- // 使用 dnd-kit 的 useSortable hook 处理拖拽逻辑
41
- var _useSortable = useSortable({
42
- id: id
43
- }),
44
- attributes = _useSortable.attributes,
45
- listeners = _useSortable.listeners,
46
- setNodeRef = _useSortable.setNodeRef,
47
- transform = _useSortable.transform,
48
- transition = _useSortable.transition,
49
- isDragging = _useSortable.isDragging;
50
-
51
- // 构建样式对象,包含拖拽和动画相关的样式
52
- var style = _objectSpread({
53
- transform: CSS.Transform.toString(transform),
54
- transition: transition,
55
- '--animation-duration': "".concat(animationDuration, "ms"),
56
- '--animation-timing': animationTiming,
57
- '--drag-scale': dragScale,
58
- '--indent-distance': "".concat(indentDistance, "px")
59
- }, levelStyles[currentLevel]);
60
- var itemClassName = "pisellDraggable-item ".concat(isDragging ? 'dragging' : '');
61
-
62
- /**
63
- * 处理嵌套数据的变化
64
- * 如果超过最大深度限制,则不允许更改
65
- */
66
- var handleNestedChange = function handleNestedChange(items) {
67
- if (maxDepth > 0 && currentLevel >= maxDepth - 1) {
68
- return;
69
- }
70
- onNestedChange === null || onNestedChange === void 0 ? void 0 : onNestedChange(id, items);
71
- };
72
-
73
- /**
74
- * 渲染项目内容
75
- * 如果提供了自定义渲染函数,则使用自定义渲染
76
- * 否则使用默认的渲染方式
77
- */
78
- var renderContent = function renderContent() {
79
- if (renderItem) {
80
- return renderItem(item);
81
- }
82
- return /*#__PURE__*/React.createElement(React.Fragment, null, dragMode === 'handle' && /*#__PURE__*/React.createElement("div", _extends({
83
- className: "pisellDraggable-handle ".concat(handleClassName || '')
84
- }, listeners), /*#__PURE__*/React.createElement("span", {
85
- className: "pisellDraggable-handle-icon"
86
- }, handleIcon)), /*#__PURE__*/React.createElement("div", {
87
- className: "pisellDraggable-content"
88
- }, item.content));
89
- };
90
-
91
- // 检查是否有子项且是否可以继续嵌套
92
- var hasChildren = Array.isArray(item.children) && item.children.length > 0;
93
- var canNest = maxDepth === 0 || currentLevel < maxDepth - 1;
94
- return /*#__PURE__*/React.createElement("div", _extends({
95
- ref: setNodeRef,
96
- style: style,
97
- className: itemClassName,
98
- "data-level": currentLevel
99
- }, attributes, dragMode === 'item' ? listeners : {}), renderContent(), hasChildren && canNest && /*#__PURE__*/React.createElement("div", {
100
- className: "pisellDraggable-nested"
101
- }, /*#__PURE__*/React.createElement(PisellDraggable, {
102
- items: item.children,
103
- onChange: handleNestedChange,
104
- dragMode: dragMode,
105
- handleClassName: handleClassName,
106
- animationDuration: animationDuration,
107
- indentDistance: indentDistance,
108
- maxDepth: maxDepth,
109
- levelStyles: levelStyles,
110
- handleIcon: handleIcon,
111
- animationTiming: animationTiming,
112
- dragScale: dragScale,
113
- currentLevel: currentLevel + 1
114
- })));
115
- };
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import './PisellDraggable.less';
3
- import { PisellDraggableProps } from './types';
4
- /**
5
- * PisellDraggable 组件
6
- * 一个功能强大的拖拽排序组件,支持嵌套结构、多种布局方式和自定义样式
7
- *
8
- * 特点:
9
- * 1. 支持垂直、水平和网格布局
10
- * 2. 支持无限层级嵌套
11
- * 3. 支持自定义拖拽手柄和样式
12
- * 4. 支持动画效果和自定义动画
13
- * 5. 支持最大嵌套深度限制
14
- */
15
- declare const PisellDraggable: React.FC<PisellDraggableProps & {
16
- currentLevel?: number;
17
- }>;
18
- export default PisellDraggable;
@@ -1,175 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/components/pisellDraggable/PisellDraggable.tsx
30
- var PisellDraggable_exports = {};
31
- __export(PisellDraggable_exports, {
32
- default: () => PisellDraggable_default
33
- });
34
- module.exports = __toCommonJS(PisellDraggable_exports);
35
- var import_core = require("@dnd-kit/core");
36
- var import_sortable = require("@dnd-kit/sortable");
37
- var import_react = __toESM(require("react"));
38
- var import_PisellDraggable = require("./PisellDraggable.less");
39
- var import_SortableItem = require("./SortableItem");
40
- var PisellDraggable = ({
41
- items,
42
- direction = "vertical",
43
- columns = 3,
44
- allowCrossContainer = false,
45
- onDragStart,
46
- onDragEnd,
47
- onChange,
48
- renderItem,
49
- className,
50
- style,
51
- handleClassName,
52
- containerStyle,
53
- disabled = false,
54
- animationDuration = 250,
55
- dragMode = "handle",
56
- indentDistance = 24,
57
- maxDepth = 0,
58
- levelStyles = {},
59
- handleIcon = "⋮",
60
- animationTiming = "ease",
61
- dragScale = 1.02,
62
- currentLevel = 0
63
- }) => {
64
- const sensors = (0, import_core.useSensors)(
65
- (0, import_core.useSensor)(import_core.PointerSensor),
66
- (0, import_core.useSensor)(import_core.KeyboardSensor, {
67
- coordinateGetter: import_sortable.sortableKeyboardCoordinates
68
- })
69
- );
70
- const sortingStrategy = (0, import_react.useMemo)(() => {
71
- switch (direction) {
72
- case "horizontal":
73
- return import_sortable.horizontalListSortingStrategy;
74
- case "grid":
75
- return import_sortable.rectSortingStrategy;
76
- default:
77
- return import_sortable.verticalListSortingStrategy;
78
- }
79
- }, [direction]);
80
- const containerClassName = (0, import_react.useMemo)(() => {
81
- const baseClass = "pisellDraggable-container";
82
- return `${baseClass} ${direction} ${className || ""} ${disabled ? "disabled" : ""}`.trim();
83
- }, [direction, className, disabled]);
84
- const gridStyle = (0, import_react.useMemo)(() => {
85
- return direction === "grid" ? {
86
- ...containerStyle,
87
- gridTemplateColumns: `repeat(${columns}, 1fr)`
88
- } : containerStyle;
89
- }, [direction, columns, containerStyle]);
90
- const handleDragStart = (0, import_react.useCallback)(
91
- (event) => {
92
- onDragStart == null ? void 0 : onDragStart(event.active.id);
93
- },
94
- [onDragStart]
95
- );
96
- const handleNestedChange = (0, import_react.useCallback)(
97
- (parentId, nestedItems) => {
98
- const updateNestedItems = (items2) => {
99
- return items2.map((item) => {
100
- var _a;
101
- if (item.id === parentId) {
102
- return { ...item, children: nestedItems };
103
- }
104
- if ((_a = item.children) == null ? void 0 : _a.length) {
105
- return { ...item, children: updateNestedItems(item.children) };
106
- }
107
- return item;
108
- });
109
- };
110
- const newItems = updateNestedItems(items);
111
- onChange == null ? void 0 : onChange(newItems);
112
- },
113
- [items, onChange]
114
- );
115
- const handleDragEnd = (0, import_react.useCallback)(
116
- (event) => {
117
- const { active, over } = event;
118
- if (over && active.id !== over.id) {
119
- const oldIndex = items.findIndex((item) => item.id === active.id);
120
- const newIndex = items.findIndex((item) => item.id === over.id);
121
- const newItems = (0, import_sortable.arrayMove)(items, oldIndex, newIndex);
122
- onChange == null ? void 0 : onChange(newItems);
123
- onDragEnd == null ? void 0 : onDragEnd({
124
- active: items[oldIndex],
125
- over: items[newIndex]
126
- });
127
- }
128
- },
129
- [items, onChange, onDragEnd]
130
- );
131
- (0, import_react.useEffect)(() => {
132
- document.body.id = "body";
133
- }, []);
134
- if (disabled || !(items == null ? void 0 : items.length)) {
135
- return null;
136
- }
137
- return /* @__PURE__ */ import_react.default.createElement("div", { className: containerClassName, style: { ...style, ...gridStyle } }, /* @__PURE__ */ import_react.default.createElement(
138
- import_core.DndContext,
139
- {
140
- sensors,
141
- collisionDetection: import_core.closestCenter,
142
- onDragStart: handleDragStart,
143
- onDragEnd: handleDragEnd
144
- },
145
- /* @__PURE__ */ import_react.default.createElement(
146
- import_sortable.SortableContext,
147
- {
148
- items: items.map((item) => item.id),
149
- strategy: sortingStrategy
150
- },
151
- items.map((item) => /* @__PURE__ */ import_react.default.createElement(
152
- import_SortableItem.SortableItem,
153
- {
154
- key: item.id,
155
- id: item.id,
156
- item,
157
- renderItem,
158
- handleClassName,
159
- animationDuration,
160
- dragMode,
161
- onNestedChange: handleNestedChange,
162
- indentDistance,
163
- maxDepth,
164
- levelStyles,
165
- handleIcon,
166
- animationTiming,
167
- dragScale,
168
- currentLevel
169
- }
170
- ))
171
- ),
172
- /* @__PURE__ */ import_react.default.createElement(import_core.DragOverlay, null)
173
- ));
174
- };
175
- var PisellDraggable_default = PisellDraggable;
@@ -1,154 +0,0 @@
1
- /* PisellDraggable 组件样式 */
2
- .pisellDraggable {
3
-
4
- /* 容器样式 */
5
- &-container {
6
- position: relative;
7
-
8
- /* 水平布局 */
9
- &.horizontal {
10
- display: flex;
11
- flex-direction: row;
12
- gap: 8px;
13
- }
14
-
15
- /* 垂直布局 */
16
- &.vertical {
17
- display: flex;
18
- flex-direction: column;
19
- gap: 8px;
20
- }
21
-
22
- /* 网格布局 */
23
- &.grid {
24
- display: grid;
25
- gap: 8px;
26
- }
27
- }
28
-
29
- /* 拖拽项样式 */
30
- &-item {
31
- position: relative;
32
- touch-action: none;
33
- user-select: none;
34
- background: #fff;
35
- border: 1px solid #e8e8e8;
36
- border-radius: 4px;
37
- padding: 12px;
38
- transition: all var(--animation-duration, 250ms) var(--animation-timing, ease);
39
-
40
- /* 拖拽时的样式 */
41
- &.dragging {
42
- opacity: 0.5;
43
- cursor: grabbing;
44
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
45
- transform: scale(var(--drag-scale, 1.02)) !important;
46
- z-index: 1;
47
- }
48
-
49
- /* 非拖拽状态的变换 */
50
- &:not(.dragging) {
51
- transform: translate3d(var(--translate-x, 0), var(--translate-y, 0), 0);
52
- }
53
-
54
- /* 不同层级的背景色 */
55
- &[data-level="0"] {
56
- background: #fff;
57
- }
58
-
59
- &[data-level="1"] {
60
- background: #fafafa;
61
- }
62
-
63
- &[data-level="2"] {
64
- background: #f5f5f5;
65
- }
66
-
67
- &[data-level="3"] {
68
- background: #f0f0f0;
69
- }
70
- }
71
-
72
- /* 拖拽手柄样式 */
73
- &-handle {
74
- cursor: grab;
75
- display: inline-flex;
76
- align-items: center;
77
- justify-content: center;
78
- width: 24px;
79
- height: 24px;
80
- margin-right: 8px;
81
- color: #999;
82
- border-radius: 4px;
83
- transition: all 0.2s;
84
-
85
- /* 悬停效果 */
86
- &:hover {
87
- background: rgba(0, 0, 0, 0.04);
88
- color: #666;
89
- }
90
-
91
- /* 激活状态 */
92
- &:active {
93
- cursor: grabbing;
94
- background: rgba(0, 0, 0, 0.08);
95
- }
96
-
97
- /* 手柄图标 */
98
- &-icon {
99
- font-size: 16px;
100
- line-height: 1;
101
- }
102
- }
103
-
104
- /* 内容区域样式 */
105
- &-content {
106
- display: inline-flex;
107
- align-items: center;
108
- flex: 1;
109
- min-height: 24px;
110
- }
111
-
112
- /* 嵌套容器样式 */
113
- &-nested {
114
- margin-top: 12px;
115
- margin-left: var(--indent-distance, 24px);
116
- border-left: 2px solid #f0f0f0;
117
- padding-left: 12px;
118
- transition: all 0.3s;
119
-
120
- /* 嵌套容器的最小高度 */
121
- .pisellDraggable-container {
122
- min-height: 32px;
123
- }
124
-
125
- /* 悬停时的边线效果 */
126
- &:hover {
127
- border-left-color: #1890ff;
128
- }
129
- }
130
-
131
- /* 拖拽覆盖层样式 */
132
- &-overlay {
133
- position: fixed;
134
- pointer-events: none;
135
- z-index: 1000;
136
- transition: transform 0.15s ease;
137
- opacity: 0.8;
138
- transform: scale(1.05);
139
-
140
- &.dragging {
141
- cursor: grabbing;
142
- }
143
- }
144
-
145
- /* 禁用状态样式 */
146
- &.disabled {
147
- opacity: 0.5;
148
- cursor: not-allowed;
149
-
150
- .pisellDraggable-handle {
151
- cursor: not-allowed;
152
- }
153
- }
154
- }
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import { DraggableItem } from './types';
3
- /**
4
- * 可排序项组件的属性定义
5
- */
6
- interface SortableItemProps {
7
- /** 项目的唯一标识符 */
8
- id: string | number;
9
- /** 项目数据 */
10
- item: DraggableItem;
11
- /** 自定义渲染函数 */
12
- renderItem?: (item: DraggableItem) => React.ReactNode;
13
- /** 拖拽手柄的自定义类名 */
14
- handleClassName?: string;
15
- /** 动画持续时间(毫秒) */
16
- animationDuration?: number;
17
- /** 拖动方式 */
18
- dragMode?: 'handle' | 'item';
19
- /** 嵌套数据变化的回调函数 */
20
- onNestedChange?: (parentId: string | number, items: DraggableItem[]) => void;
21
- /** 缩进距离(像素) */
22
- indentDistance?: number;
23
- /** 最大嵌套深度 */
24
- maxDepth?: number;
25
- /** 层级样式配置 */
26
- levelStyles?: Record<number, React.CSSProperties>;
27
- /** 拖拽手柄图标 */
28
- handleIcon?: React.ReactNode;
29
- /** 动画曲线 */
30
- animationTiming?: 'ease' | 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
31
- /** 拖拽时的缩放比例 */
32
- dragScale?: number;
33
- /** 当前嵌套层级 */
34
- currentLevel?: number;
35
- }
36
- /**
37
- * 可排序项组件
38
- * 用于渲染单个可拖拽项,支持嵌套结构和自定义渲染
39
- */
40
- export declare const SortableItem: React.FC<SortableItemProps>;
41
- export {};
@@ -1,127 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/components/pisellDraggable/SortableItem.tsx
30
- var SortableItem_exports = {};
31
- __export(SortableItem_exports, {
32
- SortableItem: () => SortableItem
33
- });
34
- module.exports = __toCommonJS(SortableItem_exports);
35
- var import_sortable = require("@dnd-kit/sortable");
36
- var import_utilities = require("@dnd-kit/utilities");
37
- var import_react = __toESM(require("react"));
38
- var import_PisellDraggable = __toESM(require("./PisellDraggable"));
39
- var SortableItem = ({
40
- id,
41
- item,
42
- renderItem,
43
- handleClassName,
44
- animationDuration = 250,
45
- dragMode = "handle",
46
- onNestedChange,
47
- indentDistance = 24,
48
- maxDepth = 0,
49
- levelStyles = {},
50
- handleIcon = "⋮",
51
- animationTiming = "ease",
52
- dragScale = 1.02,
53
- currentLevel = 0
54
- }) => {
55
- const {
56
- attributes,
57
- listeners,
58
- setNodeRef,
59
- transform,
60
- transition,
61
- isDragging
62
- } = (0, import_sortable.useSortable)({ id });
63
- const style = {
64
- transform: import_utilities.CSS.Transform.toString(transform),
65
- transition,
66
- "--animation-duration": `${animationDuration}ms`,
67
- "--animation-timing": animationTiming,
68
- "--drag-scale": dragScale,
69
- "--indent-distance": `${indentDistance}px`,
70
- ...levelStyles[currentLevel]
71
- };
72
- const itemClassName = `pisellDraggable-item ${isDragging ? "dragging" : ""}`;
73
- const handleNestedChange = (items) => {
74
- if (maxDepth > 0 && currentLevel >= maxDepth - 1) {
75
- return;
76
- }
77
- onNestedChange == null ? void 0 : onNestedChange(id, items);
78
- };
79
- const renderContent = () => {
80
- if (renderItem) {
81
- return renderItem(item);
82
- }
83
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, dragMode === "handle" && /* @__PURE__ */ import_react.default.createElement(
84
- "div",
85
- {
86
- className: `pisellDraggable-handle ${handleClassName || ""}`,
87
- ...listeners
88
- },
89
- /* @__PURE__ */ import_react.default.createElement("span", { className: "pisellDraggable-handle-icon" }, handleIcon)
90
- ), /* @__PURE__ */ import_react.default.createElement("div", { className: "pisellDraggable-content" }, item.content));
91
- };
92
- const hasChildren = Array.isArray(item.children) && item.children.length > 0;
93
- const canNest = maxDepth === 0 || currentLevel < maxDepth - 1;
94
- return /* @__PURE__ */ import_react.default.createElement(
95
- "div",
96
- {
97
- ref: setNodeRef,
98
- style,
99
- className: itemClassName,
100
- "data-level": currentLevel,
101
- ...attributes,
102
- ...dragMode === "item" ? listeners : {}
103
- },
104
- renderContent(),
105
- hasChildren && canNest && /* @__PURE__ */ import_react.default.createElement("div", { className: "pisellDraggable-nested" }, /* @__PURE__ */ import_react.default.createElement(
106
- import_PisellDraggable.default,
107
- {
108
- items: item.children,
109
- onChange: handleNestedChange,
110
- dragMode,
111
- handleClassName,
112
- animationDuration,
113
- indentDistance,
114
- maxDepth,
115
- levelStyles,
116
- handleIcon,
117
- animationTiming,
118
- dragScale,
119
- currentLevel: currentLevel + 1
120
- }
121
- ))
122
- );
123
- };
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- SortableItem
127
- });