@pisell/materials 3.0.24 → 3.0.26

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 (73) hide show
  1. package/build/lowcode/assets-daily.json +13 -13
  2. package/build/lowcode/assets-dev.json +4 -4
  3. package/build/lowcode/assets-prod.json +13 -13
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +2 -2
  6. package/build/lowcode/preview.js +142 -142
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +20 -29
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +20 -29
  11. package/dist/umd/materials.min.css +1 -0
  12. package/dist/umd/materials.min.js +1 -0
  13. package/dist/umd/static/DotsSix.57d66266.svg +1 -0
  14. package/dist/umd/static/arrow-left.e542294f.svg +1 -0
  15. package/dist/umd/static/arrow-right.763f03e0.svg +1 -0
  16. package/dist/umd/static/filter-lines.04a54ae9.svg +1 -0
  17. package/dist/umd/static/help-circle.31c9be40.svg +1 -0
  18. package/dist/umd/static/switch-vertical-01.7ebe3ba8.svg +1 -0
  19. package/es/components/Pagination/index.d.ts +1 -1
  20. package/es/components/drag-sort-tree/TreeItem/index.d.ts +19 -0
  21. package/es/components/drag-sort-tree/TreeItem/index.js +192 -0
  22. package/es/components/drag-sort-tree/TreeItem/index.less +66 -0
  23. package/es/components/drag-sort-tree/index.d.ts +5 -0
  24. package/es/components/drag-sort-tree/index.js +115 -0
  25. package/es/components/drag-sort-tree/index.less +4 -0
  26. package/es/components/drag-sort-tree/types.d.ts +24 -0
  27. package/es/components/drag-sort-tree/types.js +1 -0
  28. package/es/components/drawer/index.d.ts +1 -1
  29. package/es/components/drawer/index.js +24 -17
  30. package/es/components/drawer/index.less +31 -0
  31. package/es/components/table/Actions/component/ExportImport/index.js +4 -5
  32. package/es/components/table/BasicTable/index.js +4 -1
  33. package/es/components/table/Table/utils.d.ts +1 -1
  34. package/es/components/tabs/index.d.ts +4 -4
  35. package/es/components/tabs/index.js +10 -9
  36. package/es/index.d.ts +81 -80
  37. package/es/index.js +40 -39
  38. package/es/locales/en-US.d.ts +1 -0
  39. package/es/locales/en-US.js +2 -1
  40. package/es/locales/zh-CN.d.ts +1 -0
  41. package/es/locales/zh-CN.js +2 -1
  42. package/es/locales/zh-TW.d.ts +1 -0
  43. package/es/locales/zh-TW.js +2 -1
  44. package/lib/components/Pagination/index.d.ts +1 -1
  45. package/lib/components/drag-sort-tree/TreeItem/index.d.ts +19 -0
  46. package/lib/components/drag-sort-tree/TreeItem/index.js +214 -0
  47. package/lib/components/drag-sort-tree/TreeItem/index.less +66 -0
  48. package/lib/components/drag-sort-tree/index.d.ts +5 -0
  49. package/lib/components/drag-sort-tree/index.js +130 -0
  50. package/lib/components/drag-sort-tree/index.less +4 -0
  51. package/lib/components/drag-sort-tree/types.d.ts +24 -0
  52. package/lib/components/drag-sort-tree/types.js +17 -0
  53. package/lib/components/drawer/index.d.ts +1 -1
  54. package/lib/components/drawer/index.js +5 -1
  55. package/lib/components/drawer/index.less +31 -0
  56. package/lib/components/table/Actions/component/ExportImport/index.js +5 -5
  57. package/lib/components/table/BasicTable/index.js +1 -1
  58. package/lib/components/table/Table/utils.d.ts +1 -1
  59. package/lib/components/tabs/index.d.ts +4 -4
  60. package/lib/components/tabs/index.js +3 -1
  61. package/lib/index.d.ts +81 -80
  62. package/lib/index.js +3 -0
  63. package/lib/locales/en-US.d.ts +1 -0
  64. package/lib/locales/en-US.js +2 -1
  65. package/lib/locales/zh-CN.d.ts +1 -0
  66. package/lib/locales/zh-CN.js +2 -1
  67. package/lib/locales/zh-TW.d.ts +1 -0
  68. package/lib/locales/zh-TW.js +2 -1
  69. package/lowcode/drag-sort-tree/__screenshots__/drag-sort-tree.png +0 -0
  70. package/lowcode/drag-sort-tree/meta.ts +117 -0
  71. package/lowcode/drag-sort-tree/snippets.ts +57 -0
  72. package/lowcode/tabs/meta.ts +9 -0
  73. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M8 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM8 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 13a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 6a1 1 0 1 0 0-2 1 1 0 0 0 0 2ZM16 20a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.707 4.293a1 1 0 0 1 0 1.414L7.414 11H19a1 1 0 1 1 0 2H7.414l5.293 5.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M11.293 4.293a1 1 0 0 1 1.414 0l7 7a1 1 0 0 1 0 1.414l-7 7a1 1 0 0 1-1.414-1.414L16.586 13H5a1 1 0 1 1 0-2h11.586l-5.293-5.293a1 1 0 0 1 0-1.414Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2 6a1 1 0 0 1 1-1h18a1 1 0 1 1 0 2H3a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h12a1 1 0 1 1 0 2H6a1 1 0 0 1-1-1Zm3 6a1 1 0 0 1 1-1h6a1 1 0 1 1 0 2H9a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM1 12C1 5.925 5.925 1 12 1s11 4.925 11 11-4.925 11-11 11S1 18.075 1 12Zm11.258-3.976a2 2 0 0 0-2.225 1.308 1 1 0 1 1-1.886-.664 4 4 0 0 1 7.773 1.333c0 1.53-1.135 2.54-1.945 3.081a8.044 8.044 0 0 1-1.686.848l-.035.013-.011.003-.004.002h-.002L11.92 13l.316.949a1 1 0 0 1-.633-1.897l.016-.006.074-.027a6.051 6.051 0 0 0 1.172-.6c.69-.46 1.055-.95 1.055-1.419v-.001a2 2 0 0 0-1.662-1.975ZM11 17a1 1 0 0 1 1-1h.01a1 1 0 1 1 0 2H12a1 1 0 0 1-1-1Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.293 3.293a1 1 0 0 1 1.414 0l4 4a1 1 0 0 1-1.414 1.414L8 6.414V20a1 1 0 1 1-2 0V6.414L3.707 8.707a1 1 0 0 1-1.414-1.414l4-4ZM16 17.586V4a1 1 0 1 1 2 0v13.586l2.293-2.293a1 1 0 0 1 1.414 1.414l-4 4a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 1.414-1.414L16 17.586Z"/></svg>
@@ -5,7 +5,7 @@ export declare const paginationConfig: {
5
5
  className: string;
6
6
  defaultCurrent: number;
7
7
  showTotal: (total: number, range: [number, number]) => string;
8
- itemRender: (page: number, type: "page" | "next" | "prev" | "jump-prev" | "jump-next", element: React.ReactNode) => React.ReactNode;
8
+ itemRender: (page: number, type: "next" | "page" | "prev" | "jump-prev" | "jump-next", element: React.ReactNode) => React.ReactNode;
9
9
  responsive: boolean;
10
10
  size: string;
11
11
  };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { ValueProps, SortType } from '../types';
4
+ declare type IdType = string | number;
5
+ declare type TreeItemProps = {
6
+ id: string | number;
7
+ key: string | number;
8
+ item: ValueProps | any;
9
+ depth: number;
10
+ lists: any[];
11
+ childrenProps?: SortType;
12
+ sensors?: any;
13
+ expandedKeys?: IdType[];
14
+ setExpandedKeys?: any;
15
+ onSelectKeys?: (ids: IdType) => void;
16
+ onChange?: (value: any[]) => void;
17
+ };
18
+ declare const TreeItem: (props: TreeItemProps) => React.JSX.Element;
19
+ export default TreeItem;
@@ -0,0 +1,192 @@
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 _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ 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; }
14
+ 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; }
15
+ 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; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
+ 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); }
18
+ import React, { useMemo } from 'react';
19
+ import { useSortable } from '@dnd-kit/sortable';
20
+ import { DndContext } from '@dnd-kit/core';
21
+ import { Tooltip } from 'antd';
22
+ import DotsSix from '@pisell/icon/es/DotsSix';
23
+ import { getText } from "../../../locales";
24
+ import { CSS } from '@dnd-kit/utilities';
25
+ import { EyeOutlined, EyeInvisibleOutlined, WarningOutlined } from '@ant-design/icons';
26
+ import { SortableContext, verticalListSortingStrategy, arrayMove } from '@dnd-kit/sortable';
27
+ import { restrictToVerticalAxis, restrictToParentElement } from '@dnd-kit/modifiers';
28
+ import classNames from 'classnames';
29
+ import "./index.less";
30
+ var prefix = 'pisell-lowcode';
31
+ var TreeItem = function TreeItem(props) {
32
+ var id = props.id,
33
+ item = props.item,
34
+ depth = props.depth,
35
+ sensors = props.sensors,
36
+ childrenProps = props.childrenProps,
37
+ lists = props.lists,
38
+ expandedKeys = props.expandedKeys,
39
+ onChange = props.onChange;
40
+ var _useSortable = useSortable({
41
+ id: id
42
+ }),
43
+ attributes = _useSortable.attributes,
44
+ listeners = _useSortable.listeners,
45
+ setNodeRef = _useSortable.setNodeRef,
46
+ transform = _useSortable.transform,
47
+ transition = _useSortable.transition,
48
+ isDragging = _useSortable.isDragging;
49
+ var style = {
50
+ transform: CSS.Transform.toString(transform && _objectSpread(_objectSpread({}, transform), {}, {
51
+ scaleY: 1
52
+ })),
53
+ transition: transition
54
+ };
55
+ var rowKey = useMemo(function () {
56
+ return (childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.rowKey) || 'id';
57
+ }, [childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.rowKey]);
58
+ var handleDragEnd = function handleDragEnd(event) {
59
+ var active = event.active,
60
+ over = event.over;
61
+ if (!over || !active || !lists.length) return;
62
+ try {
63
+ var _active$id, _over$id;
64
+ var _active$id$split = active === null || active === void 0 ? void 0 : (_active$id = active.id) === null || _active$id === void 0 ? void 0 : _active$id.split('-'),
65
+ _active$id$split2 = _slicedToArray(_active$id$split, 2),
66
+ activeParentId = _active$id$split2[0],
67
+ activeId = _active$id$split2[1];
68
+ var _over$id$split = over === null || over === void 0 ? void 0 : (_over$id = over.id) === null || _over$id === void 0 ? void 0 : _over$id.split('-'),
69
+ _over$id$split2 = _slicedToArray(_over$id$split, 2),
70
+ overParentId = _over$id$split2[0],
71
+ overId = _over$id$split2[1];
72
+ var parentIndex = lists.findIndex(function (item) {
73
+ return item[rowKey] == activeParentId;
74
+ });
75
+ if (activeId !== overId && activeParentId === overParentId && parentIndex !== -1) {
76
+ var activeIndex = item.children.findIndex(function (item) {
77
+ return item[rowKey] == activeId;
78
+ });
79
+ var overIndex = item.children.findIndex(function (item) {
80
+ return item[rowKey] == overId;
81
+ });
82
+
83
+ // 移动数据
84
+ if (activeIndex !== -1 && overIndex !== -1) {
85
+ var _lists$parentIndex;
86
+ var newChildren = arrayMove((_lists$parentIndex = lists[parentIndex]) === null || _lists$parentIndex === void 0 ? void 0 : _lists$parentIndex.children, activeIndex, overIndex);
87
+ var _lists = [].concat(_toConsumableArray(lists.slice(0, parentIndex)), [_objectSpread(_objectSpread({}, lists === null || lists === void 0 ? void 0 : lists[parentIndex]), {}, {
88
+ children: newChildren
89
+ })], _toConsumableArray(lists.slice(parentIndex + 1)));
90
+ onChange && onChange(_toConsumableArray(_lists));
91
+ }
92
+ }
93
+ } catch (error) {}
94
+ };
95
+
96
+ /**
97
+ * @title: 点击切换眼睛
98
+ * @description:
99
+ * @param {any} e
100
+ * @return {*}
101
+ * @Author: WangHan
102
+ * @Date: 2024-07-19 22:43
103
+ */
104
+ var handleShow = function handleShow(e) {
105
+ e.stopPropagation(); // 阻止事件冒泡
106
+ e.preventDefault(); // 阻止默认行为
107
+ var index = lists === null || lists === void 0 ? void 0 : lists.findIndex(function (node) {
108
+ return node[rowKey] === item[rowKey];
109
+ });
110
+ if (index !== -1) {
111
+ lists[index].show = !lists[index].show;
112
+ onChange === null || onChange === void 0 ? void 0 : onChange(_toConsumableArray(lists));
113
+ }
114
+ };
115
+ var onSelect = function onSelect() {
116
+ var _item$children;
117
+ if (depth === 0 && (_item$children = item.children) !== null && _item$children !== void 0 && _item$children.length) {
118
+ var key = item[rowKey];
119
+ (childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.onHiddenChange) && (childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.onHiddenChange(key));
120
+ }
121
+ };
122
+ var renderChildren = useMemo(function () {
123
+ var _item$children2;
124
+ var showChildren = (item === null || item === void 0 ? void 0 : (_item$children2 = item.children) === null || _item$children2 === void 0 ? void 0 : _item$children2.length) > 0 && (expandedKeys === null || expandedKeys === void 0 ? void 0 : expandedKeys.includes(item[rowKey]));
125
+ var _isAvailableTab = (childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.tabKey) === 'available';
126
+ return showChildren && /*#__PURE__*/React.createElement(SortableContext, {
127
+ items: item.children.map(function (child) {
128
+ return "".concat(item[rowKey], "-").concat(child[rowKey]);
129
+ }),
130
+ strategy: verticalListSortingStrategy
131
+ }, item.children.map(function (child) {
132
+ return _isAvailableTab && child !== null && child !== void 0 && child.is_available || !_isAvailableTab ? /*#__PURE__*/React.createElement(TreeItem, {
133
+ id: "".concat(item[rowKey], "-").concat(child[rowKey]),
134
+ key: "".concat(item[rowKey], "-").concat(child[rowKey]),
135
+ item: child,
136
+ lists: lists,
137
+ depth: depth + 1,
138
+ childrenProps: childrenProps
139
+ }) : null;
140
+ }));
141
+ }, [item.children, expandedKeys, rowKey, lists, childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.tabKey, isDragging]);
142
+
143
+ // 右侧图标
144
+ var rightIcon = useMemo(function () {
145
+ // 右侧子级图标
146
+ var hiddenRightIcon = childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.hiddenRightIcon;
147
+ return !hiddenRightIcon ? /*#__PURE__*/React.createElement("div", {
148
+ className: classNames("".concat(prefix, "-drag-sort-tree-icon")),
149
+ onClick: handleShow
150
+ }, item.show ? /*#__PURE__*/React.createElement(EyeOutlined, null) : /*#__PURE__*/React.createElement(EyeInvisibleOutlined, null)) : null;
151
+ }, [childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.hiddenRightIcon, item === null || item === void 0 ? void 0 : item.show, lists]);
152
+
153
+ // 警告图标
154
+ var warningIcon = useMemo(function () {
155
+ var hiddenWarningIcon = childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.hiddenWarningIcon;
156
+ return !hiddenWarningIcon && !(item !== null && item !== void 0 && item.is_available) ? /*#__PURE__*/React.createElement("div", {
157
+ className: classNames("".concat(prefix, "-drag-sort-tree-item-icon"))
158
+ }, /*#__PURE__*/React.createElement(Tooltip, {
159
+ title: getText('drag-sort-tree-unavailable-today-tip'),
160
+ color: "#ffffff",
161
+ overlayInnerStyle: {
162
+ color: '#344054'
163
+ }
164
+ }, /*#__PURE__*/React.createElement(WarningOutlined, {
165
+ style: {
166
+ color: '#FF2020'
167
+ }
168
+ }))) : null;
169
+ }, [childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.hiddenWarningIcon, item === null || item === void 0 ? void 0 : item.is_available]);
170
+ return /*#__PURE__*/React.createElement(DndContext, {
171
+ sensors: sensors,
172
+ modifiers: [restrictToVerticalAxis, restrictToParentElement],
173
+ onDragEnd: handleDragEnd
174
+ }, /*#__PURE__*/React.createElement("div", _extends({
175
+ ref: setNodeRef,
176
+ style: style
177
+ }, attributes, listeners), /*#__PURE__*/React.createElement("div", {
178
+ className: classNames("".concat(prefix, "-drag-sort-tree"), childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.className),
179
+ style: {
180
+ paddingLeft: !depth ? '10px' : "".concat(depth * 40, "px"),
181
+ cursor: isDragging ? 'grabbing' : 'grab'
182
+ },
183
+ onClick: onSelect
184
+ }, /*#__PURE__*/React.createElement("div", {
185
+ className: classNames("".concat(prefix, "-drag-sort-tree-item"))
186
+ }, !(childrenProps !== null && childrenProps !== void 0 && childrenProps.hiddenDraggableIcon) ? /*#__PURE__*/React.createElement(DotsSix, {
187
+ className: classNames("".concat(prefix, "-drag-sort-tree-item-dot-icon"))
188
+ }) : null, /*#__PURE__*/React.createElement("div", {
189
+ className: "".concat(prefix, "-drag-sort-tree-title")
190
+ }, (childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.titleRender) || (item === null || item === void 0 ? void 0 : item.title))), !depth ? rightIcon : warningIcon), renderChildren));
191
+ };
192
+ export default TreeItem;
@@ -0,0 +1,66 @@
1
+ @pisell-prefix: pisell-lowcode;
2
+
3
+ .@{pisell-prefix} {
4
+ &-drag-sort-tree{
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: space-between;
8
+ font-size: 14px;
9
+ touch-action: none !important;
10
+ width: 100%;
11
+ color: #101828;
12
+ padding: 9px 10px;
13
+ height: auto;
14
+ position: relative;
15
+ display: flex;
16
+ &:hover {
17
+ background: #F9FAFB;
18
+ border-radius: 6px;
19
+ }
20
+ }
21
+
22
+ &-drag-sort-tree-item{
23
+ flex: 1;
24
+ }
25
+
26
+ &-drag-sort-tree-item {
27
+ display: flex;
28
+ align-items: center;
29
+ }
30
+
31
+ &-drag-sort-tree &-drag-sort-tree-title {
32
+ margin-left: 10px;
33
+ font-size: 14px;
34
+ line-height: 20px;
35
+ margin-right: 30px;
36
+ }
37
+
38
+ &-drag-sort-tree-icon,
39
+ &-drag-sort-tree-item-icon,
40
+ &-drag-sort-tree-item-dot-icon {
41
+ display: flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+ }
45
+
46
+ &-drag-sort-tree-icon,
47
+ &-drag-sort-tree-item-icon{
48
+ height: 40px;
49
+ width: 40px;
50
+ position: absolute;
51
+ right: 0;
52
+ cursor: pointer;
53
+ }
54
+
55
+ &-drag-sort-tree-icon{
56
+ cursor: pointer;
57
+ }
58
+
59
+ &-drag-sort-tree-item-dot-icon{
60
+ height: 20px;
61
+ width: 20px;
62
+ color: #344054;
63
+ }
64
+ }
65
+
66
+
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ import { SortType } from './types';
4
+ declare const DragSortTree: (props: SortType) => React.JSX.Element;
5
+ export default DragSortTree;
@@ -0,0 +1,115 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import React, { useEffect, useState } from 'react';
12
+ import { DndContext, useSensor, useSensors, PointerSensor } from '@dnd-kit/core';
13
+ import { SortableContext, verticalListSortingStrategy, arrayMove } from '@dnd-kit/sortable';
14
+ import TreeItem from "./TreeItem";
15
+ import { restrictToVerticalAxis, restrictToParentElement } from '@dnd-kit/modifiers';
16
+ import "./index.less";
17
+ var DragSortTree = function DragSortTree(props) {
18
+ var value = props.value,
19
+ rowKey = props.rowKey,
20
+ tabKey = props.tabKey,
21
+ hiddenKeys = props.hiddenKeys,
22
+ onChange = props.onChange;
23
+ var _useState = useState(value || []),
24
+ _useState2 = _slicedToArray(_useState, 2),
25
+ items = _useState2[0],
26
+ setItems = _useState2[1];
27
+ var _useState3 = useState([]),
28
+ _useState4 = _slicedToArray(_useState3, 2),
29
+ expandedKeys = _useState4[0],
30
+ setExpandedKeys = _useState4[1];
31
+ useEffect(function () {
32
+ var keys = value === null || value === void 0 ? void 0 : value.map(function (item) {
33
+ return item[rowKey];
34
+ });
35
+ // 过滤需要折叠起来的key
36
+ keys = keys.filter(function (key) {
37
+ return hiddenKeys !== null && hiddenKeys !== void 0 && hiddenKeys.length ? !hiddenKeys.includes(key) : key;
38
+ });
39
+ setExpandedKeys(_toConsumableArray(keys));
40
+ }, [hiddenKeys]);
41
+ useEffect(function () {
42
+ // 防止切换的时候数据不更新,拖拽之后,如果切换tab,需要用更新之后的数据
43
+ setItems(value || []);
44
+ }, [tabKey]);
45
+ var sensors = useSensors(useSensor(PointerSensor, {
46
+ activationConstraint: {
47
+ distance: 5
48
+ }
49
+ }));
50
+ var handleDragStart = function handleDragStart(event) {
51
+ var _active$id, _active$id$split;
52
+ var active = event.active;
53
+ var activeId = active === null || active === void 0 ? void 0 : (_active$id = active.id) === null || _active$id === void 0 ? void 0 : (_active$id$split = _active$id.split('-')) === null || _active$id$split === void 0 ? void 0 : _active$id$split[1];
54
+ var _keys = expandedKeys === null || expandedKeys === void 0 ? void 0 : expandedKeys.filter(function (key) {
55
+ return key != activeId;
56
+ });
57
+ setExpandedKeys(_toConsumableArray(_keys));
58
+ };
59
+ var handleDragEnd = function handleDragEnd(event) {
60
+ var active = event.active,
61
+ over = event.over;
62
+ if (!over || !active) return;
63
+ try {
64
+ var _active$id2, _active$id2$split, _over$id, _over$id$split;
65
+ var activeId = active === null || active === void 0 ? void 0 : (_active$id2 = active.id) === null || _active$id2 === void 0 ? void 0 : (_active$id2$split = _active$id2.split('-')) === null || _active$id2$split === void 0 ? void 0 : _active$id2$split[1];
66
+ var overId = over === null || over === void 0 ? void 0 : (_over$id = over.id) === null || _over$id === void 0 ? void 0 : (_over$id$split = _over$id.split('-')) === null || _over$id$split === void 0 ? void 0 : _over$id$split[1];
67
+ if (activeId !== overId) {
68
+ // 如果没有自动点击折叠则拖动结束再次打开
69
+ if (!(hiddenKeys !== null && hiddenKeys !== void 0 && hiddenKeys.includes(Number(activeId)))) {
70
+ var _keys = [].concat(_toConsumableArray(expandedKeys), [Number(activeId)]);
71
+ setExpandedKeys(_toConsumableArray(_keys));
72
+ }
73
+ var activeIndex = items.findIndex(function (item) {
74
+ return item[rowKey] == activeId;
75
+ });
76
+ var overIndex = items.findIndex(function (item) {
77
+ return item[rowKey] == overId;
78
+ });
79
+ var _lists = arrayMove(items, activeIndex, overIndex);
80
+ handleChange(_lists);
81
+ }
82
+ } catch (error) {}
83
+ };
84
+ var handleChange = function handleChange(value) {
85
+ setItems(value);
86
+ onChange && onChange(value);
87
+ };
88
+ return /*#__PURE__*/React.createElement("div", {
89
+ className: "pisell-lowcode-drag-sort-tree-wrap"
90
+ }, /*#__PURE__*/React.createElement(DndContext, {
91
+ sensors: sensors,
92
+ onDragEnd: handleDragEnd,
93
+ onDragStart: handleDragStart,
94
+ modifiers: [restrictToVerticalAxis, restrictToParentElement]
95
+ }, /*#__PURE__*/React.createElement(SortableContext, {
96
+ items: items.map(function (item) {
97
+ return "0-".concat(item[rowKey]);
98
+ }),
99
+ strategy: verticalListSortingStrategy
100
+ }, items.map(function (item) {
101
+ return /*#__PURE__*/React.createElement(TreeItem, {
102
+ key: "0-".concat(item[rowKey]),
103
+ id: "0-".concat(item[rowKey]),
104
+ item: item,
105
+ depth: 0,
106
+ sensors: sensors,
107
+ childrenProps: props,
108
+ lists: items,
109
+ expandedKeys: expandedKeys,
110
+ setExpandedKeys: setExpandedKeys,
111
+ onChange: handleChange
112
+ });
113
+ }))));
114
+ };
115
+ export default DragSortTree;
@@ -0,0 +1,4 @@
1
+ .pisell-lowcode-drag-sort-tree-wrap{
2
+ overflow-y: auto;
3
+ overflow-x: hidden;
4
+ }
@@ -0,0 +1,24 @@
1
+ /// <reference types="react" />
2
+ declare type IdType = string | number;
3
+ export declare type ValueProps = {
4
+ id: IdType;
5
+ title: string;
6
+ show?: boolean;
7
+ is_available?: boolean;
8
+ type_id?: number;
9
+ children?: ValueProps[];
10
+ };
11
+ export declare type SortType = {
12
+ value: ValueProps[];
13
+ rowKey: string;
14
+ className?: string | Function;
15
+ titleRender?: string | React.ReactElement;
16
+ hiddenDraggableIcon?: boolean;
17
+ hiddenRightIcon?: boolean;
18
+ hiddenWarningIcon?: boolean;
19
+ tabKey?: string;
20
+ hiddenKeys?: IdType[];
21
+ onHiddenChange?: (value: IdType[]) => void;
22
+ onChange?: (value: ValueProps[]) => void;
23
+ };
24
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,3 @@
1
- import "./index.less";
1
+ import './index.less';
2
2
  declare const Drawer: any;
3
3
  export default Drawer;
@@ -1,6 +1,8 @@
1
1
  var _excluded = ["others"];
2
2
  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); }
3
3
  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); }
4
+ 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; }
5
+ 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
6
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
8
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -12,15 +14,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
12
14
  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; }
13
15
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
16
  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); }
15
- import React, { useLayoutEffect, useMemo } from "react";
16
- import { Drawer as OriginalDrawer } from "antd";
17
- import { useControllableValue, useUpdateEffect } from "ahooks";
18
- import classNames from "classnames";
19
- import { isBoolean, isUndefined } from "@pisell/utils";
20
- import XClose from "@pisell/icon/es/XClose";
21
- import Pin02 from "@pisell/icon/es/Pin02";
17
+ import React, { useLayoutEffect, useMemo } from 'react';
18
+ import { Drawer as OriginalDrawer } from 'antd';
19
+ import { useControllableValue, useUpdateEffect } from 'ahooks';
20
+ import classNames from 'classnames';
21
+ import { isBoolean, isUndefined } from '@pisell/utils';
22
+ import XClose from '@pisell/icon/es/XClose';
23
+ import Pin02 from '@pisell/icon/es/Pin02';
22
24
  import "./index.less";
23
- var prefix = "pisell-lowcode-";
25
+ var prefix = 'pisell-lowcode-';
24
26
  var Title = function Title(props) {
25
27
  var placement = props.placement,
26
28
  onClose = props.onClose,
@@ -51,8 +53,8 @@ var Drawer = function Drawer(props) {
51
53
  getContainer = props.getContainer,
52
54
  open = props.open;
53
55
  var _useControllableValue = useControllableValue(props, {
54
- trigger: "onPersistentChange",
55
- valuePropName: "persistent"
56
+ trigger: 'onPersistentChange',
57
+ valuePropName: 'persistent'
56
58
  }),
57
59
  _useControllableValue2 = _slicedToArray(_useControllableValue, 2),
58
60
  persistentState = _useControllableValue2[0],
@@ -60,17 +62,17 @@ var Drawer = function Drawer(props) {
60
62
  var currentDrawerId = props.__id;
61
63
  var storageKey = "drawer-".concat(currentDrawerId);
62
64
  var innerProps = {};
63
- if (props.__designMode === "design") {
65
+ if (props.__designMode === 'design') {
64
66
  // 低代码编辑态中强制显示,将控制权交给引擎侧
65
67
  innerProps.open = true;
66
68
  }
67
69
  useLayoutEffect(function () {
68
70
  if (isBoolean(persistentState) && isUndefined(getContainer) && showPin) {
69
71
  document.body.style.transition = 'all 0.3s';
70
- document.body.style["padding-".concat(placement)] = persistentState && open ? "".concat(width || 378, "px") : "0";
72
+ document.body.style["padding-".concat(placement)] = persistentState && open ? "".concat(width || 378, "px") : '0';
71
73
  }
72
74
  return function () {
73
- document.body.style["padding-".concat(placement)] = "0";
75
+ document.body.style["padding-".concat(placement)] = '0';
74
76
  document.body.style.transition = 'none';
75
77
  };
76
78
  }, [persistentState, width, showPin, placement, open]);
@@ -81,14 +83,14 @@ var Drawer = function Drawer(props) {
81
83
  }, [persistentState, storageKey, showPin]);
82
84
  useLayoutEffect(function () {
83
85
  if (!isBoolean(persistentState) && showPin) {
84
- setPersistentState(localStorage.getItem(storageKey) === "true");
86
+ setPersistentState(localStorage.getItem(storageKey) === 'true');
85
87
  }
86
88
  }, [persistentState, storageKey, showPin]);
87
89
  var otherProps = useMemo(function () {
88
- if (operateMode === "outside") {
90
+ if (operateMode === 'outside') {
89
91
  return {
90
92
  headerStyle: {
91
- border: "none",
93
+ border: 'none',
92
94
  height: 0,
93
95
  padding: 0
94
96
  },
@@ -101,7 +103,12 @@ var Drawer = function Drawer(props) {
101
103
  })
102
104
  };
103
105
  }
104
- return headerStyle;
106
+ return _objectSpread({
107
+ rootClassName: "".concat(prefix, "basic-drawer-root"),
108
+ closeIcon: /*#__PURE__*/React.createElement(XClose, {
109
+ className: "".concat(prefix, "drawer-header-close-icon")
110
+ })
111
+ }, headerStyle);
105
112
  }, [operateMode, placement, onClose, persistentState, setPersistentState]);
106
113
  return /*#__PURE__*/React.createElement(OriginalDrawer, _extends({}, resetProps, innerProps, otherProps, others));
107
114
  };
@@ -1,6 +1,24 @@
1
1
  @pisell-prefix: pisell-lowcode;
2
2
 
3
3
  .@{pisell-prefix} {
4
+ &-drawer-header {
5
+ position: unset !important;
6
+ }
7
+
8
+ &-drawer-header-close-icon {
9
+ position: absolute;
10
+ top: 0;
11
+ bottom: 0;
12
+ left: 0;
13
+ width: 50px;
14
+ cursor: pointer;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ font-size: 20px;
19
+ z-index: 1;
20
+ }
21
+
4
22
  &-drawer-outside-wrap {
5
23
  position: absolute;
6
24
  padding: 10px;
@@ -8,9 +26,11 @@
8
26
  display: flex;
9
27
  flex-direction: column;
10
28
  }
29
+
11
30
  &-drawer-outside-wrap-right {
12
31
  left: -82px;
13
32
  }
33
+
14
34
  &-drawer-outside-action-wrap {
15
35
  width: 56px;
16
36
  height: 56px;
@@ -24,17 +44,28 @@
24
44
  justify-content: center;
25
45
  margin-bottom: 20px;
26
46
  cursor: pointer;
47
+
27
48
  &:hover {
28
49
  background: #e8e8ee;
29
50
  }
51
+
30
52
  .anticon {
31
53
  font-size: 20px;
32
54
  }
33
55
  }
56
+
34
57
  &-drawer-outside-action-wrap:last-child {
35
58
  margin-bottom: 0;
36
59
  }
60
+
37
61
  &-drawer-outside-action-active {
38
62
  background: var(--Primary-200, #E9D7FE) !important;
39
63
  }
40
64
  }
65
+
66
+
67
+ .@{pisell-prefix}-basic-drawer-root {
68
+ .@{pisell-prefix}-drawer-header {
69
+ position: relative !important;
70
+ }
71
+ }