@pisell/materials 1.0.598 → 1.0.600

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 (95) 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 +7 -7
  6. package/build/lowcode/preview.js +7 -7
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +30 -30
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +27 -27
  11. package/es/components/appVersionControl/index.js +1 -1
  12. package/es/components/appVersionControl/types.d.ts +1 -1
  13. package/es/components/dataSourceComponents/dataSourceForm/utils.js +4 -12
  14. package/es/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
  15. package/es/components/dataSourceComponents/dataSourceMenu/index.js +19 -0
  16. package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +4 -4
  17. package/es/components/image/avatar.png +0 -0
  18. package/es/components/image/image.png +0 -0
  19. package/es/components/image/index.d.ts +10 -0
  20. package/es/components/image/index.js +25 -0
  21. package/es/components/image/product.png +0 -0
  22. package/es/components/pisellDraggable/PisellDraggable.d.ts +18 -0
  23. package/es/components/pisellDraggable/PisellDraggable.js +190 -0
  24. package/es/components/pisellDraggable/PisellDraggable.less +154 -0
  25. package/es/components/pisellDraggable/SortableItem.d.ts +41 -0
  26. package/es/components/pisellDraggable/SortableItem.js +115 -0
  27. package/es/components/pisellDraggable/index.d.ts +3 -0
  28. package/es/components/pisellDraggable/index.js +2 -0
  29. package/es/components/pisellDraggable/types.d.ts +101 -0
  30. package/es/components/pisellDraggable/types.js +1 -0
  31. package/es/components/pisellLayout/content.d.ts +1 -0
  32. package/es/components/pisellLayout/content.js +19 -2
  33. package/es/components/pisellMenu/PisellMenu.d.ts +5 -0
  34. package/es/components/pisellMenu/PisellMenu.js +55 -0
  35. package/es/components/pisellMenu/PisellMenu.less +53 -0
  36. package/es/components/pisellMenu/index.d.ts +3 -0
  37. package/es/components/pisellMenu/index.js +2 -0
  38. package/es/components/pisellMenu/types.d.ts +30 -0
  39. package/es/components/pisellMenu/types.js +1 -0
  40. package/es/index.d.ts +29 -24
  41. package/es/index.js +29 -25
  42. package/es/locales/zh-TW.js +1 -1
  43. package/es/typings.d.ts +4 -0
  44. package/lib/components/appVersionControl/index.js +1 -1
  45. package/lib/components/appVersionControl/types.d.ts +1 -1
  46. package/lib/components/dataSourceComponents/dataSourceForm/utils.js +1 -14
  47. package/lib/components/dataSourceComponents/dataSourceMenu/index.d.ts +2 -0
  48. package/lib/components/dataSourceComponents/dataSourceMenu/index.js +45 -0
  49. package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +4 -4
  50. package/lib/components/image/avatar.png +0 -0
  51. package/lib/components/image/image.png +0 -0
  52. package/lib/components/image/index.d.ts +10 -0
  53. package/lib/components/image/index.js +59 -0
  54. package/lib/components/image/product.png +0 -0
  55. package/lib/components/pisellDraggable/PisellDraggable.d.ts +18 -0
  56. package/lib/components/pisellDraggable/PisellDraggable.js +175 -0
  57. package/lib/components/pisellDraggable/PisellDraggable.less +154 -0
  58. package/lib/components/pisellDraggable/SortableItem.d.ts +41 -0
  59. package/lib/components/pisellDraggable/SortableItem.js +127 -0
  60. package/lib/components/pisellDraggable/index.d.ts +3 -0
  61. package/lib/components/pisellDraggable/index.js +36 -0
  62. package/lib/components/pisellDraggable/types.d.ts +101 -0
  63. package/lib/components/pisellDraggable/types.js +17 -0
  64. package/lib/components/pisellLayout/content.d.ts +1 -0
  65. package/lib/components/pisellLayout/content.js +9 -1
  66. package/lib/components/pisellMenu/PisellMenu.d.ts +5 -0
  67. package/lib/components/pisellMenu/PisellMenu.js +91 -0
  68. package/lib/components/pisellMenu/PisellMenu.less +53 -0
  69. package/lib/components/pisellMenu/index.d.ts +3 -0
  70. package/lib/components/pisellMenu/index.js +36 -0
  71. package/lib/components/pisellMenu/types.d.ts +30 -0
  72. package/lib/components/pisellMenu/types.js +17 -0
  73. package/lib/index.d.ts +29 -24
  74. package/lib/index.js +34 -24
  75. package/lib/locales/zh-TW.js +1 -1
  76. package/lib/typings.d.ts +4 -0
  77. package/lowcode/_utils/defaultSchema.ts +1 -1
  78. package/lowcode/app-version-control/meta.ts +16 -0
  79. package/lowcode/data-source-menu/meta.ts +115 -0
  80. package/lowcode/form-item-input.mobile/__screenshots__/mobile.png +0 -0
  81. package/lowcode/form-item-input.mobile/meta.ts +15 -1
  82. package/lowcode/form-item-input.mobile/snippets.ts +7 -1
  83. package/lowcode/form-item-input.phone/meta.ts +15 -1
  84. package/lowcode/form-item-input.phone/snippets.ts +6 -0
  85. package/lowcode/form-item-input.subdomain/__screenshots__/subdomain.png +0 -0
  86. package/lowcode/form-item-input.subdomain/meta.ts +17 -1
  87. package/lowcode/form-item-input.subdomain/snippets.ts +1 -1
  88. package/lowcode/image/meta.ts +19 -0
  89. package/lowcode/image/snippets.ts +1 -0
  90. package/lowcode/pisell-content/meta.ts +12 -9
  91. package/lowcode/pisell-draggable/meta.ts +190 -0
  92. package/lowcode/pisell-layout/meta.ts +9 -9
  93. package/lowcode/pisell-menu/meta.ts +112 -0
  94. package/package.json +3 -3
  95. package/lowcode/form-item-input.mobile/__screenshots__/phone.png +0 -0
@@ -84,7 +84,7 @@ var AppVersionControl = function AppVersionControl(props) {
84
84
  setPromoteLoading(true);
85
85
  _context.prev = 1;
86
86
  _context.next = 4;
87
- return onPromoteToLive === null || onPromoteToLive === void 0 ? void 0 : onPromoteToLive(value);
87
+ return onPromoteToLive === null || onPromoteToLive === void 0 ? void 0 : onPromoteToLive(value, currentVersion);
88
88
  case 4:
89
89
  setPromoteToLiveModal(false);
90
90
  _context.next = 10;
@@ -12,7 +12,7 @@ export interface AppVersionControlProps {
12
12
  versions: Version[];
13
13
  onVersionChange: (value: string, version: Version) => void;
14
14
  onCreateVersion: (version: string) => Promise<boolean | undefined>;
15
- onPromoteToLive: (value: string) => Promise<boolean | undefined>;
15
+ onPromoteToLive: (value: string, version: Version) => Promise<boolean | undefined>;
16
16
  allowPublish?: boolean;
17
17
  allowCreate?: boolean;
18
18
  className?: string;
@@ -157,9 +157,6 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
157
157
  }));
158
158
  }
159
159
  if (typeobj && typeobj.enabled) {
160
- console.log('Type validation object:', typeobj);
161
- console.log('Validation enabled:', typeobj.enabled);
162
- console.log('Validation type:', typeobj.type);
163
160
  switch (typeobj.type) {
164
161
  case 'email':
165
162
  rules.push(_objectSpread(_objectSpread({}, typeobj), {}, {
@@ -182,7 +179,6 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
182
179
  try {
183
180
  // 清理输入值,移除空格、括号等字符
184
181
  var _cleanedNumber = value.replace(/\s|\(|\)/g, '');
185
-
186
182
  // 使用 parsePhoneNumberFromString 验证 E.164 格式
187
183
  var parsedNumber = parsePhoneNumberFromString(_cleanedNumber);
188
184
  if (!(parsedNumber !== null && parsedNumber !== void 0 && parsedNumber.isValid())) {
@@ -213,9 +209,11 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
213
209
 
214
210
  // 根据号码前缀判断国家
215
211
  if (_cleanedNumber2.startsWith('+61')) {
216
- // 澳大利亚手机号规则
212
+ // 澳大利亚手机号规则:
213
+ // 1. 以04开头必须是10位数字
214
+ // 2. 以4开头必须是9位数字
217
215
  var numberWithoutPrefix = _cleanedNumber2.slice(3);
218
- if (!/^(04\d{8}|\d{9})$/.test(numberWithoutPrefix)) {
216
+ if (!/^(?:04\d{8}|4\d{8})$/.test(numberWithoutPrefix)) {
219
217
  return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-mobile-message')));
220
218
  }
221
219
  } else if (_cleanedNumber2.startsWith('+86')) {
@@ -244,12 +242,6 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
244
242
  if (!subdomain) {
245
243
  return Promise.resolve();
246
244
  }
247
- if (subdomain.length < 2) {
248
- return Promise.reject(new Error(getText('subdomain-error-too-short')));
249
- }
250
- if (subdomain.length > 60) {
251
- return Promise.reject(new Error(getText('subdomain-error-too-long')));
252
- }
253
245
  if (!/^[a-z0-9-]+$/.test(subdomain)) {
254
246
  return Promise.reject(new Error(getText('subdomain-error-pattern')));
255
247
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,19 @@
1
+ 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); }
2
+ import React, { forwardRef } from 'react';
3
+ import BaseMenu from "../../pisellMenu";
4
+ import useVariables from "../hooks/useVariables";
5
+
6
+ /**
7
+ * @title: 数据源表单组件
8
+ * @description: 基于数据源动态生成表单,支持编辑、查看、禁用三种模式
9
+ */
10
+ var DataSourceMenu = /*#__PURE__*/forwardRef(function (props, ref) {
11
+ var dataSource = props.dataSource;
12
+ var _useVariables = useVariables(),
13
+ parseVariable = _useVariables.parseVariable;
14
+ return /*#__PURE__*/React.createElement(BaseMenu, _extends({}, props, {
15
+ dataSource: parseVariable === null || parseVariable === void 0 ? void 0 : parseVariable(dataSource),
16
+ ref: ref
17
+ }));
18
+ });
19
+ export default DataSourceMenu;
@@ -66,7 +66,7 @@ var Subdomain = function Subdomain(props) {
66
66
  _useState2 = _slicedToArray(_useState, 2),
67
67
  subdomain = _useState2[0],
68
68
  setSubdomain = _useState2[1];
69
- var _useState3 = useState(''),
69
+ var _useState3 = useState('.root-domain.example'),
70
70
  _useState4 = _slicedToArray(_useState3, 2),
71
71
  suffix = _useState4[0],
72
72
  setSuffix = _useState4[1];
@@ -114,13 +114,13 @@ var Subdomain = function Subdomain(props) {
114
114
  var _newSuffix = '';
115
115
  switch (rootDomain) {
116
116
  case 'xzero':
117
- _newSuffix = coreData ? ".".concat(coreData.tenant_domain) : '';
117
+ _newSuffix = coreData ? ".".concat(coreData.tenant_domain) : '.root-domain.example';
118
118
  break;
119
119
  case 'saas':
120
- _newSuffix = tenantData ? ".".concat(tenantData['saas.domain']) : '';
120
+ _newSuffix = tenantData ? ".".concat(tenantData['saas.domain']) : '.root-domain.example';
121
121
  break;
122
122
  default:
123
- _newSuffix = customDomain ? customDomain.startsWith('.') ? customDomain : ".".concat(customDomain) : '';
123
+ _newSuffix = customDomain ? customDomain.startsWith('.') ? customDomain : ".".concat(customDomain) : '.root-domain.example';
124
124
  }
125
125
  setSuffix(_newSuffix);
126
126
  }
Binary file
Binary file
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { ImageProps as AntdImageProps } from 'antd';
3
+ export interface ImageProps extends Omit<AntdImageProps, 'placeholder'> {
4
+ /**
5
+ * 占位图类型
6
+ */
7
+ fallbackType?: 'image' | 'avatar' | 'product';
8
+ }
9
+ declare const Image: React.FC<ImageProps>;
10
+ export default Image;
@@ -0,0 +1,25 @@
1
+ var _excluded = ["fallbackType", "fallback"];
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 _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; }
4
+ 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; }
5
+ import React from 'react';
6
+ import { Image as AntdImage } from 'antd';
7
+ import image from "./image.png";
8
+ import avatar from "./avatar.png";
9
+ import product from "./product.png";
10
+ var defaultFallbackMap = {
11
+ image: image,
12
+ avatar: avatar,
13
+ product: product
14
+ };
15
+ var Image = function Image(_ref) {
16
+ var _ref$fallbackType = _ref.fallbackType,
17
+ fallbackType = _ref$fallbackType === void 0 ? 'image' : _ref$fallbackType,
18
+ fallback = _ref.fallback,
19
+ restProps = _objectWithoutProperties(_ref, _excluded);
20
+ var finalFallback = fallback || defaultFallbackMap[fallbackType];
21
+ return /*#__PURE__*/React.createElement(AntdImage, _extends({}, restProps, {
22
+ fallback: finalFallback
23
+ }));
24
+ };
25
+ export default Image;
Binary file
@@ -0,0 +1,18 @@
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;
@@ -0,0 +1,190 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ 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); }
7
+ import { DndContext, DragOverlay, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
8
+ import { SortableContext, arrayMove, horizontalListSortingStrategy, rectSortingStrategy, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
9
+ import React, { useCallback, useEffect, useMemo } from 'react';
10
+ import "./PisellDraggable.less";
11
+ import { SortableItem } from "./SortableItem";
12
+ /**
13
+ * PisellDraggable 组件
14
+ * 一个功能强大的拖拽排序组件,支持嵌套结构、多种布局方式和自定义样式
15
+ *
16
+ * 特点:
17
+ * 1. 支持垂直、水平和网格布局
18
+ * 2. 支持无限层级嵌套
19
+ * 3. 支持自定义拖拽手柄和样式
20
+ * 4. 支持动画效果和自定义动画
21
+ * 5. 支持最大嵌套深度限制
22
+ */
23
+ var PisellDraggable = function PisellDraggable(_ref) {
24
+ var items = _ref.items,
25
+ _ref$direction = _ref.direction,
26
+ direction = _ref$direction === void 0 ? 'vertical' : _ref$direction,
27
+ _ref$columns = _ref.columns,
28
+ columns = _ref$columns === void 0 ? 3 : _ref$columns,
29
+ _ref$allowCrossContai = _ref.allowCrossContainer,
30
+ allowCrossContainer = _ref$allowCrossContai === void 0 ? false : _ref$allowCrossContai,
31
+ onDragStart = _ref.onDragStart,
32
+ onDragEnd = _ref.onDragEnd,
33
+ onChange = _ref.onChange,
34
+ renderItem = _ref.renderItem,
35
+ className = _ref.className,
36
+ style = _ref.style,
37
+ handleClassName = _ref.handleClassName,
38
+ containerStyle = _ref.containerStyle,
39
+ _ref$disabled = _ref.disabled,
40
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
41
+ _ref$animationDuratio = _ref.animationDuration,
42
+ animationDuration = _ref$animationDuratio === void 0 ? 250 : _ref$animationDuratio,
43
+ _ref$dragMode = _ref.dragMode,
44
+ dragMode = _ref$dragMode === void 0 ? 'handle' : _ref$dragMode,
45
+ _ref$indentDistance = _ref.indentDistance,
46
+ indentDistance = _ref$indentDistance === void 0 ? 24 : _ref$indentDistance,
47
+ _ref$maxDepth = _ref.maxDepth,
48
+ maxDepth = _ref$maxDepth === void 0 ? 0 : _ref$maxDepth,
49
+ _ref$levelStyles = _ref.levelStyles,
50
+ levelStyles = _ref$levelStyles === void 0 ? {} : _ref$levelStyles,
51
+ _ref$handleIcon = _ref.handleIcon,
52
+ handleIcon = _ref$handleIcon === void 0 ? '⋮' : _ref$handleIcon,
53
+ _ref$animationTiming = _ref.animationTiming,
54
+ animationTiming = _ref$animationTiming === void 0 ? 'ease' : _ref$animationTiming,
55
+ _ref$dragScale = _ref.dragScale,
56
+ dragScale = _ref$dragScale === void 0 ? 1.02 : _ref$dragScale,
57
+ _ref$currentLevel = _ref.currentLevel,
58
+ currentLevel = _ref$currentLevel === void 0 ? 0 : _ref$currentLevel;
59
+ // 初始化拖拽传感器
60
+ var sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
61
+ coordinateGetter: sortableKeyboardCoordinates
62
+ }));
63
+
64
+ /**
65
+ * 根据布局方向选择排序策略
66
+ */
67
+ var sortingStrategy = useMemo(function () {
68
+ switch (direction) {
69
+ case 'horizontal':
70
+ return horizontalListSortingStrategy;
71
+ case 'grid':
72
+ return rectSortingStrategy;
73
+ default:
74
+ return verticalListSortingStrategy;
75
+ }
76
+ }, [direction]);
77
+
78
+ /**
79
+ * 构建容器的类名
80
+ */
81
+ var containerClassName = useMemo(function () {
82
+ var baseClass = 'pisellDraggable-container';
83
+ return "".concat(baseClass, " ").concat(direction, " ").concat(className || '', " ").concat(disabled ? 'disabled' : '').trim();
84
+ }, [direction, className, disabled]);
85
+
86
+ /**
87
+ * 构建网格布局的样式
88
+ */
89
+ var gridStyle = useMemo(function () {
90
+ return direction === 'grid' ? _objectSpread(_objectSpread({}, containerStyle), {}, {
91
+ gridTemplateColumns: "repeat(".concat(columns, ", 1fr)")
92
+ }) : containerStyle;
93
+ }, [direction, columns, containerStyle]);
94
+
95
+ /**
96
+ * 处理拖拽开始事件
97
+ */
98
+ var handleDragStart = useCallback(function (event) {
99
+ onDragStart === null || onDragStart === void 0 ? void 0 : onDragStart(event.active.id);
100
+ }, [onDragStart]);
101
+
102
+ /**
103
+ * 处理嵌套数据的变化
104
+ * 递归更新数据树
105
+ */
106
+ var handleNestedChange = useCallback(function (parentId, nestedItems) {
107
+ var updateNestedItems = function updateNestedItems(items) {
108
+ return items.map(function (item) {
109
+ var _item$children;
110
+ if (item.id === parentId) {
111
+ return _objectSpread(_objectSpread({}, item), {}, {
112
+ children: nestedItems
113
+ });
114
+ }
115
+ if ((_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
116
+ return _objectSpread(_objectSpread({}, item), {}, {
117
+ children: updateNestedItems(item.children)
118
+ });
119
+ }
120
+ return item;
121
+ });
122
+ };
123
+ var newItems = updateNestedItems(items);
124
+ onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
125
+ }, [items, onChange]);
126
+
127
+ /**
128
+ * 处理拖拽结束事件
129
+ * 更新数据顺序并触发回调
130
+ */
131
+ var handleDragEnd = useCallback(function (event) {
132
+ var active = event.active,
133
+ over = event.over;
134
+ if (over && active.id !== over.id) {
135
+ var oldIndex = items.findIndex(function (item) {
136
+ return item.id === active.id;
137
+ });
138
+ var newIndex = items.findIndex(function (item) {
139
+ return item.id === over.id;
140
+ });
141
+ var newItems = arrayMove(items, oldIndex, newIndex);
142
+ onChange === null || onChange === void 0 ? void 0 : onChange(newItems);
143
+ onDragEnd === null || onDragEnd === void 0 ? void 0 : onDragEnd({
144
+ active: items[oldIndex],
145
+ over: items[newIndex]
146
+ });
147
+ }
148
+ }, [items, onChange, onDragEnd]);
149
+ useEffect(function () {
150
+ document.body.id = 'body';
151
+ }, []);
152
+
153
+ // 如果禁用或没有数据,返回 null
154
+ if (disabled || !(items !== null && items !== void 0 && items.length)) {
155
+ return null;
156
+ }
157
+ return /*#__PURE__*/React.createElement("div", {
158
+ className: containerClassName,
159
+ style: _objectSpread(_objectSpread({}, style), gridStyle)
160
+ }, /*#__PURE__*/React.createElement(DndContext, {
161
+ sensors: sensors,
162
+ collisionDetection: closestCenter,
163
+ onDragStart: handleDragStart,
164
+ onDragEnd: handleDragEnd
165
+ }, /*#__PURE__*/React.createElement(SortableContext, {
166
+ items: items.map(function (item) {
167
+ return item.id;
168
+ }),
169
+ strategy: sortingStrategy
170
+ }, items.map(function (item) {
171
+ return /*#__PURE__*/React.createElement(SortableItem, {
172
+ key: item.id,
173
+ id: item.id,
174
+ item: item,
175
+ renderItem: renderItem,
176
+ handleClassName: handleClassName,
177
+ animationDuration: animationDuration,
178
+ dragMode: dragMode,
179
+ onNestedChange: handleNestedChange,
180
+ indentDistance: indentDistance,
181
+ maxDepth: maxDepth,
182
+ levelStyles: levelStyles,
183
+ handleIcon: handleIcon,
184
+ animationTiming: animationTiming,
185
+ dragScale: dragScale,
186
+ currentLevel: currentLevel
187
+ });
188
+ })), /*#__PURE__*/React.createElement(DragOverlay, null)));
189
+ };
190
+ export default PisellDraggable;
@@ -0,0 +1,154 @@
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
+ }
@@ -0,0 +1,41 @@
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 {};