@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
@@ -167,7 +167,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
167
167
  sort?: SortType | undefined;
168
168
  mode: "" | "localStorage" | "remote";
169
169
  currentViewMode: ModeType;
170
- }) => ("view_mode" | "column_setting" | "order_by" | "group_by" | "gallery_setting" | "filter_setting")[];
170
+ }) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
171
171
  export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
172
172
  export declare const stringify: (obj: Record<string, any>) => string;
173
173
  export {};
@@ -134,7 +134,7 @@ var PublishVersionModal = ({
134
134
  preserve: false,
135
135
  className: "pisell-lowcode-version-modal-form"
136
136
  },
137
- isShowCurrentVersion && /* @__PURE__ */ import_react.default.createElement("p", null, (0, import_locales.getText)("pisell-version-modal-current-version"), ": ", currentVersion),
137
+ isShowCurrentVersion && /* @__PURE__ */ import_react.default.createElement("p", { className: "pisell-lowcode-version-modal-current-version" }, (0, import_locales.getText)("pisell-version-modal-current-version"), ": ", currentVersion),
138
138
  isShowBasedOn && /* @__PURE__ */ import_react.default.createElement(
139
139
  import_antd.Form.Item,
140
140
  {
@@ -1,3 +1,10 @@
1
1
  .pisell-lowcode-version-modal-form {
2
- padding: 24px 0 0 !important;
3
- }
2
+ padding: 16px 0 0 !important;
3
+ }
4
+
5
+ .pisell-lowcode-version-modal-current-version {
6
+ color: var(--Gray-500, #667085);
7
+ font-size: 16px;
8
+ font-weight: 400;
9
+ line-height: 24px; /* 150% */
10
+ }
@@ -190,12 +190,6 @@ declare const _default: {
190
190
  'pisell-version-modal-version-error': string;
191
191
  'pisell-version-modal-version-required': string;
192
192
  'pisell-version-modal-based-on-version': string;
193
- 'pisell-icon-select-outlined': string;
194
- 'pisell-icon-select-filled': string;
195
- 'pisell-icon-select-two-tone': string;
196
- 'pisell-icon-select-iconfont': string;
197
- 'pisell-icon-select-search': string;
198
- 'pisell-icon-select-select': string;
199
193
  'subdomain-error-too-short': string;
200
194
  'subdomain-error-too-long': string;
201
195
  'subdomain-error-pattern': string;
@@ -203,6 +197,12 @@ declare const _default: {
203
197
  'subdomain-error-hyphen-ends': string;
204
198
  'subdomain-error-consecutive-hyphens': string;
205
199
  'subdomain-error-required': string;
200
+ 'pisell-icon-select-outlined': string;
201
+ 'pisell-icon-select-filled': string;
202
+ 'pisell-icon-select-two-tone': string;
203
+ 'pisell-icon-select-iconfont': string;
204
+ 'pisell-icon-select-search': string;
205
+ 'pisell-icon-select-select': string;
206
206
  'pisell-lowcode-app-version-control-live': string;
207
207
  'pisell-lowcode-app-version-control-draft': string;
208
208
  'pisell-lowcode-app-version-control-deprecated': string;
@@ -232,6 +232,14 @@ var en_US_default = {
232
232
  "pisell-version-modal-version-error": "Version number must be greater than the current version",
233
233
  "pisell-version-modal-version-required": "Version number is required",
234
234
  "pisell-version-modal-based-on-version": "Based on version",
235
+ // 子域名校验错误
236
+ "subdomain-error-too-short": "Subdomain must be at least 2 characters long",
237
+ "subdomain-error-too-long": "Subdomain cannot exceed 60 characters",
238
+ "subdomain-error-pattern": "Subdomain can only contain lowercase letters, numbers and hyphens",
239
+ "subdomain-error-numbers-only": "Subdomain cannot contain only numbers",
240
+ "subdomain-error-hyphen-ends": "Subdomain cannot start or end with a hyphen",
241
+ "subdomain-error-consecutive-hyphens": "Subdomain cannot contain consecutive hyphens",
242
+ "subdomain-error-required": "Please enter subdomain",
235
243
  // 图标选择组件
236
244
  "pisell-icon-select-outlined": "Outlined",
237
245
  "pisell-icon-select-filled": "Filled",
@@ -190,18 +190,18 @@ declare const _default: {
190
190
  'pisell-version-modal-version-error': string;
191
191
  'pisell-version-modal-version-required': string;
192
192
  'pisell-version-modal-based-on-version': string;
193
- 'pisell-icon-select-outlined': string;
194
- 'pisell-icon-select-filled': string;
195
- 'pisell-icon-select-two-tone': string;
196
- 'pisell-icon-select-iconfont': string;
197
- 'pisell-icon-select-search': string;
198
- 'pisell-icon-select-select': string;
199
193
  'subdomain-error-too-short': string;
200
194
  'subdomain-error-too-long': string;
201
195
  'subdomain-error-pattern': string;
202
196
  'subdomain-error-numbers-only': string;
203
197
  'subdomain-error-hyphen-ends': string;
204
198
  'subdomain-error-consecutive-hyphens': string;
199
+ 'pisell-icon-select-outlined': string;
200
+ 'pisell-icon-select-filled': string;
201
+ 'pisell-icon-select-two-tone': string;
202
+ 'pisell-icon-select-iconfont': string;
203
+ 'pisell-icon-select-search': string;
204
+ 'pisell-icon-select-select': string;
205
205
  'pisell-lowcode-app-version-control-live': string;
206
206
  'pisell-lowcode-app-version-control-draft': string;
207
207
  'pisell-lowcode-app-version-control-deprecated': string;
@@ -231,6 +231,13 @@ var zh_CN_default = {
231
231
  "pisell-version-modal-version-error": "版本号必须大于当前版本",
232
232
  "pisell-version-modal-version-required": "版本号为必填项",
233
233
  "pisell-version-modal-based-on-version": "基于版本",
234
+ // 子域名校验错误
235
+ "subdomain-error-too-short": "子域名长度不能小于2个字符",
236
+ "subdomain-error-too-long": "子域名长度不能超过60个字符",
237
+ "subdomain-error-pattern": "子域名只能包含小写字母、数字和连字符",
238
+ "subdomain-error-numbers-only": "子域名不能全为数字",
239
+ "subdomain-error-hyphen-ends": "子域名不能以连字符开头或结尾",
240
+ "subdomain-error-consecutive-hyphens": "子域名不能包含连续的连字符",
234
241
  "pisell-icon-select-outlined": "线框风格",
235
242
  "pisell-icon-select-filled": "实底风格",
236
243
  "pisell-icon-select-two-tone": "双色风格",
@@ -189,6 +189,12 @@ declare const _default: {
189
189
  'pisell-version-modal-version-error': string;
190
190
  'pisell-version-modal-version-required': string;
191
191
  'pisell-version-modal-based-on-version': string;
192
+ 'subdomain-error-too-short': string;
193
+ 'subdomain-error-too-long': string;
194
+ 'subdomain-error-pattern': string;
195
+ 'subdomain-error-numbers-only': string;
196
+ 'subdomain-error-hyphen-ends': string;
197
+ 'subdomain-error-consecutive-hyphens': string;
192
198
  'pisell-icon-select-placeholder': string;
193
199
  'pisell-icon-select-outlined': string;
194
200
  'pisell-icon-select-filled': string;
@@ -196,12 +202,6 @@ declare const _default: {
196
202
  'pisell-icon-select-iconfont': string;
197
203
  'pisell-icon-select-search': string;
198
204
  'pisell-icon-select-select': string;
199
- 'subdomain-error-too-short': string;
200
- 'subdomain-error-too-long': string;
201
- 'subdomain-error-pattern': string;
202
- 'subdomain-error-numbers-only': string;
203
- 'subdomain-error-hyphen-ends': string;
204
- 'subdomain-error-consecutive-hyphens': string;
205
205
  'pisell-lowcode-app-version-control-live': string;
206
206
  'pisell-lowcode-app-version-control-draft': string;
207
207
  'pisell-lowcode-app-version-control-deprecated': string;
@@ -231,6 +231,13 @@ var zh_TW_default = {
231
231
  "pisell-version-modal-version-error": "版本號必須大於當前版本",
232
232
  "pisell-version-modal-version-required": "版本號為必填項",
233
233
  "pisell-version-modal-based-on-version": "基於版本",
234
+ // 子域名校验错误
235
+ "subdomain-error-too-short": "子域名長度不能小於2個字符",
236
+ "subdomain-error-too-long": "子域名長度不能超過60個字符",
237
+ "subdomain-error-pattern": "子域名只能包含小寫字母、數字和連字符",
238
+ "subdomain-error-numbers-only": "子域名不能全為數字",
239
+ "subdomain-error-hyphen-ends": "子域名不能以連字符開頭或結尾",
240
+ "subdomain-error-consecutive-hyphens": "子域名不能包含連續的連字符",
234
241
  // 图标选择组件
235
242
  "pisell-icon-select-placeholder": "選擇圖標",
236
243
  "pisell-icon-select-outlined": "線框風格",
@@ -26,9 +26,18 @@ export default {
26
26
  type: 'oneOfType',
27
27
  value: [
28
28
  'string',
29
- { type: 'arrayOf', value: 'string' },
30
29
  'number',
31
- { type: 'arrayOf', value: 'number' },
30
+ ],
31
+ },
32
+ },
33
+ {
34
+ name: 'value',
35
+ title: { label: '当前值', tip: '当前值' },
36
+ propType: {
37
+ type: 'oneOfType',
38
+ value: [
39
+ 'string',
40
+ 'number',
32
41
  ],
33
42
  },
34
43
  },
@@ -56,19 +65,6 @@ export default {
56
65
  'VariableSetter',
57
66
  ],
58
67
  },
59
- {
60
- name: 'value',
61
- title: { label: '当前值', tip: '当前值' },
62
- propType: {
63
- type: 'oneOfType',
64
- value: [
65
- 'string',
66
- { type: 'arrayOf', value: 'string' },
67
- 'number',
68
- { type: 'arrayOf', value: 'number' },
69
- ],
70
- },
71
- },
72
68
  {
73
69
  name: 'options',
74
70
  title: { label: '可选项', tip: '可选项' },
@@ -35,7 +35,65 @@ export default {
35
35
  // generalItemMap['defaultValue'],
36
36
  ]),
37
37
  getFormItemValidateGroup([
38
- generalItemMap['requiredobj'],
38
+ {
39
+ name: 'requiredobj',
40
+ title: {
41
+ label: {
42
+ type: 'i18n',
43
+ 'en-US': 'Required',
44
+ 'zh-CN': '必填',
45
+ },
46
+ tip: {
47
+ type: 'i18n',
48
+ 'en-US': 'Required',
49
+ 'zh-CN': '必填',
50
+ },
51
+ },
52
+ setter: {
53
+ componentName: 'ObjectSetter',
54
+ props: {
55
+ config: {
56
+ items: [
57
+ {
58
+ name: 'required',
59
+ title: {
60
+ type: 'i18n',
61
+ 'en-US': 'Required',
62
+ 'zh-CN': '是否必填',
63
+ },
64
+ propType: 'bool',
65
+ setter: 'BoolSetter',
66
+ isRequired: true,
67
+ extraProps: {
68
+ setValue(target: any, value: boolean) {
69
+ target.parent.setPropValue('transform', {
70
+ type: 'JSExpression',
71
+ value:
72
+ '(value) => Object.values(value || {}).join("")',
73
+ });
74
+ target.node.getProps().setPropValue('required', value);
75
+ },
76
+ },
77
+ },
78
+ {
79
+ name: 'message',
80
+ title: {
81
+ type: 'i18n',
82
+ 'en-US': 'Error message',
83
+ 'zh-CN': '错误信息提示',
84
+ },
85
+ propType: 'string',
86
+ setter: 'PisellI18nSetter',
87
+ },
88
+ ],
89
+ },
90
+ columns: 1,
91
+ forceInline: 1,
92
+ mode: 'popup',
93
+ },
94
+ },
95
+ },
96
+ // generalItemMap['requiredobj'],
39
97
  generalItemMap['minLengthobj'],
40
98
  generalItemMap['maxLengthobj'],
41
99
  generalItemMap['typeobj'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.606",
3
+ "version": "1.0.607",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -69,8 +69,8 @@
69
69
  "libphonenumber-js": "^1.11.17",
70
70
  "swiper": "^8.4.7",
71
71
  "react-barcode": "^1.5.3",
72
- "@pisell/icon": "0.0.10",
73
72
  "@pisell/date-picker": "1.0.115",
73
+ "@pisell/icon": "0.0.10",
74
74
  "@pisell/utils": "1.0.43"
75
75
  },
76
76
  "peerDependencies": {
@@ -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,190 +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 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;
@@ -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
- }