@pisell/materials 1.0.340 → 1.0.341

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.
@@ -1,14 +1,14 @@
1
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
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); }
3
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
9
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
10
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
11
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
- 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."); }
10
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
13
  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."); }
14
14
  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); }
@@ -53,7 +53,9 @@ var TreeItem = function TreeItem(props) {
53
53
  }
54
54
  }, [activeId]);
55
55
  var style = {
56
- transform: CSS.Transform.toString(transform),
56
+ transform: CSS.Transform.toString(transform && _objectSpread(_objectSpread({}, transform), {}, {
57
+ scaleY: 1
58
+ })),
57
59
  transition: transition
58
60
  };
59
61
  var rowKey = useMemo(function () {
@@ -64,15 +66,15 @@ var TreeItem = function TreeItem(props) {
64
66
  over = event.over;
65
67
  if (!over || !active || !lists.length) return;
66
68
  try {
67
- var _active$rowKey, _over$rowKey;
68
- var _active$rowKey$split = (_active$rowKey = active[rowKey]) === null || _active$rowKey === void 0 ? void 0 : _active$rowKey.split('-'),
69
- _active$rowKey$split2 = _slicedToArray(_active$rowKey$split, 2),
70
- activeParentId = _active$rowKey$split2[0],
71
- _activeId = _active$rowKey$split2[1];
72
- var _over$rowKey$split = (_over$rowKey = over[rowKey]) === null || _over$rowKey === void 0 ? void 0 : _over$rowKey.split('-'),
73
- _over$rowKey$split2 = _slicedToArray(_over$rowKey$split, 2),
74
- overParentId = _over$rowKey$split2[0],
75
- overId = _over$rowKey$split2[1];
69
+ var _active$id, _over$id;
70
+ 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('-'),
71
+ _active$id$split2 = _slicedToArray(_active$id$split, 2),
72
+ activeParentId = _active$id$split2[0],
73
+ _activeId = _active$id$split2[1];
74
+ 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('-'),
75
+ _over$id$split2 = _slicedToArray(_over$id$split, 2),
76
+ overParentId = _over$id$split2[0],
77
+ overId = _over$id$split2[1];
76
78
  var parentIndex = lists.findIndex(function (item) {
77
79
  return item[rowKey] == activeParentId;
78
80
  });
@@ -132,22 +134,25 @@ var TreeItem = function TreeItem(props) {
132
134
  };
133
135
  var renderChildren = useMemo(function () {
134
136
  var _item$children2;
135
- return (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])) && /*#__PURE__*/React.createElement(SortableContext, {
137
+ 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]));
138
+ console.log('showChildren', childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.tabKey);
139
+ var _tabKey = childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.tabKey;
140
+ return showChildren && /*#__PURE__*/React.createElement(SortableContext, {
136
141
  items: item.children.map(function (child) {
137
142
  return "".concat(item[rowKey], "-").concat(child[rowKey]);
138
143
  }),
139
144
  strategy: verticalListSortingStrategy
140
145
  }, item.children.map(function (child) {
141
- return /*#__PURE__*/React.createElement(TreeItem, {
146
+ return _tabKey === 'available' && child !== null && child !== void 0 && child.is_available || !_tabKey ? /*#__PURE__*/React.createElement(TreeItem, {
142
147
  id: "".concat(item[rowKey], "-").concat(child[rowKey]),
143
148
  key: "".concat(item[rowKey], "-").concat(child[rowKey]),
144
149
  item: child,
145
150
  lists: lists,
146
151
  depth: depth + 1,
147
152
  childrenProps: childrenProps
148
- });
153
+ }) : null;
149
154
  }));
150
- }, [item.children, expandedKeys, rowKey, lists]);
155
+ }, [item.children, expandedKeys, rowKey, lists, childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.tabKey]);
151
156
 
152
157
  // 右侧图标
153
158
  var rightIcon = useMemo(function () {
@@ -179,7 +184,7 @@ var TreeItem = function TreeItem(props) {
179
184
  style: style
180
185
  }, attributes, listeners), /*#__PURE__*/React.createElement("div", {
181
186
  style: {
182
- paddingLeft: "".concat(depth * 20, "px")
187
+ paddingLeft: !depth ? '8px' : "".concat(depth * 20, "px")
183
188
  },
184
189
  className: classNames("".concat(prefix, "-drag-sort-tree"), childrenProps === null || childrenProps === void 0 ? void 0 : childrenProps.className),
185
190
  onClick: onSelect
@@ -6,9 +6,12 @@
6
6
  align-items: center;
7
7
  justify-content: space-between;
8
8
  font-size: 16px;
9
- padding: 6px;
10
9
  cursor: pointer;
11
10
  touch-action: none !important;
11
+ width: 100%;
12
+ color: #101828;
13
+ height: 40px;
14
+ line-height: 40px;
12
15
  }
13
16
 
14
17
  &-drag-sort-tree:hover {
@@ -22,6 +25,7 @@
22
25
 
23
26
  &-drag-sort-tree &-drag-sort-tree-title {
24
27
  margin-left: 10px;
28
+ font-size: 14px;
25
29
  }
26
30
 
27
31
  &-drag-sort-tree-icon,
@@ -28,17 +28,18 @@ var DragSortTree = function DragSortTree(props) {
28
28
  }));
29
29
  var handleDragStart = function handleDragStart(event) {
30
30
  var active = event.active;
31
- setActiveId(active[rowKey]);
31
+ setActiveId(active === null || active === void 0 ? void 0 : active.id);
32
32
  };
33
33
  var handleDragEnd = function handleDragEnd(event) {
34
34
  var active = event.active,
35
35
  over = event.over;
36
+
36
37
  // 拖拽结束将这个值设置为空,防止第二次拖拽同一个节点,监听不到这个变化
37
38
  setActiveId(null);
38
39
  if (!over || !active) return;
39
40
  try {
40
- var _activeId = active[rowKey];
41
- var overId = over[rowKey];
41
+ var _activeId = active.id;
42
+ var overId = over.id;
42
43
  if (_activeId !== overId) {
43
44
  var activeIndex = items.findIndex(function (item) {
44
45
  return item[rowKey] === _activeId;
@@ -15,5 +15,6 @@ export declare type SortType = {
15
15
  hiddenDraggableIcon?: boolean;
16
16
  hiddenRightIcon?: boolean;
17
17
  hiddenWarningIcon?: boolean;
18
+ tabKey?: string;
18
19
  onChange?: (value: ValueProps[]) => void;
19
20
  };
@@ -52,7 +52,7 @@ var TreeItem = (props) => {
52
52
  }
53
53
  }, [activeId]);
54
54
  const style = {
55
- transform: import_utilities.CSS.Transform.toString(transform),
55
+ transform: import_utilities.CSS.Transform.toString(transform && { ...transform, scaleY: 1 }),
56
56
  transition
57
57
  };
58
58
  const rowKey = (0, import_react.useMemo)(() => {
@@ -64,8 +64,8 @@ var TreeItem = (props) => {
64
64
  if (!over || !active || !lists.length)
65
65
  return;
66
66
  try {
67
- let [activeParentId, activeId2] = (_a = active[rowKey]) == null ? void 0 : _a.split("-");
68
- let [overParentId, overId] = (_b = over[rowKey]) == null ? void 0 : _b.split("-");
67
+ let [activeParentId, activeId2] = (_a = active == null ? void 0 : active.id) == null ? void 0 : _a.split("-");
68
+ let [overParentId, overId] = (_b = over == null ? void 0 : over.id) == null ? void 0 : _b.split("-");
69
69
  const parentIndex = lists.findIndex(
70
70
  (item2) => item2[rowKey] == activeParentId
71
71
  );
@@ -118,7 +118,10 @@ var TreeItem = (props) => {
118
118
  };
119
119
  const renderChildren = (0, import_react.useMemo)(() => {
120
120
  var _a;
121
- return ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) > 0 && (expandedKeys == null ? void 0 : expandedKeys.includes(item[rowKey])) && /* @__PURE__ */ import_react.default.createElement(
121
+ const showChildren = ((_a = item == null ? void 0 : item.children) == null ? void 0 : _a.length) > 0 && (expandedKeys == null ? void 0 : expandedKeys.includes(item[rowKey]));
122
+ console.log("showChildren", childrenProps == null ? void 0 : childrenProps.tabKey);
123
+ const _tabKey = childrenProps == null ? void 0 : childrenProps.tabKey;
124
+ return showChildren && /* @__PURE__ */ import_react.default.createElement(
122
125
  import_sortable2.SortableContext,
123
126
  {
124
127
  items: item.children.map(
@@ -126,19 +129,21 @@ var TreeItem = (props) => {
126
129
  ),
127
130
  strategy: import_sortable2.verticalListSortingStrategy
128
131
  },
129
- item.children.map((child) => /* @__PURE__ */ import_react.default.createElement(
130
- TreeItem,
131
- {
132
- id: `${item[rowKey]}-${child[rowKey]}`,
133
- key: `${item[rowKey]}-${child[rowKey]}`,
134
- item: child,
135
- lists,
136
- depth: depth + 1,
137
- childrenProps
138
- }
139
- ))
132
+ item.children.map(
133
+ (child) => _tabKey === "available" && (child == null ? void 0 : child.is_available) || !_tabKey ? /* @__PURE__ */ import_react.default.createElement(
134
+ TreeItem,
135
+ {
136
+ id: `${item[rowKey]}-${child[rowKey]}`,
137
+ key: `${item[rowKey]}-${child[rowKey]}`,
138
+ item: child,
139
+ lists,
140
+ depth: depth + 1,
141
+ childrenProps
142
+ }
143
+ ) : null
144
+ )
140
145
  );
141
- }, [item.children, expandedKeys, rowKey, lists]);
146
+ }, [item.children, expandedKeys, rowKey, lists, childrenProps == null ? void 0 : childrenProps.tabKey]);
142
147
  const rightIcon = (0, import_react.useMemo)(() => {
143
148
  const hiddenRightIcon = childrenProps == null ? void 0 : childrenProps.hiddenRightIcon;
144
149
  return !hiddenRightIcon ? /* @__PURE__ */ import_react.default.createElement(
@@ -164,7 +169,7 @@ var TreeItem = (props) => {
164
169
  /* @__PURE__ */ import_react.default.createElement("div", { ref: setNodeRef, style, ...attributes, ...listeners }, /* @__PURE__ */ import_react.default.createElement(
165
170
  "div",
166
171
  {
167
- style: { paddingLeft: `${depth * 20}px` },
172
+ style: { paddingLeft: !depth ? "8px" : `${depth * 20}px` },
168
173
  className: (0, import_classnames.default)(
169
174
  `${prefix}-drag-sort-tree`,
170
175
  childrenProps == null ? void 0 : childrenProps.className
@@ -6,9 +6,12 @@
6
6
  align-items: center;
7
7
  justify-content: space-between;
8
8
  font-size: 16px;
9
- padding: 6px;
10
9
  cursor: pointer;
11
10
  touch-action: none !important;
11
+ width: 100%;
12
+ color: #101828;
13
+ height: 40px;
14
+ line-height: 40px;
12
15
  }
13
16
 
14
17
  &-drag-sort-tree:hover {
@@ -22,6 +25,7 @@
22
25
 
23
26
  &-drag-sort-tree &-drag-sort-tree-title {
24
27
  margin-left: 10px;
28
+ font-size: 14px;
25
29
  }
26
30
 
27
31
  &-drag-sort-tree-icon,
@@ -50,7 +50,7 @@ var DragSortTree = (props) => {
50
50
  );
51
51
  const handleDragStart = (event) => {
52
52
  const { active } = event;
53
- setActiveId(active[rowKey]);
53
+ setActiveId(active == null ? void 0 : active.id);
54
54
  };
55
55
  const handleDragEnd = (event) => {
56
56
  const { active, over } = event;
@@ -58,8 +58,8 @@ var DragSortTree = (props) => {
58
58
  if (!over || !active)
59
59
  return;
60
60
  try {
61
- const activeId2 = active[rowKey];
62
- const overId = over[rowKey];
61
+ const activeId2 = active.id;
62
+ const overId = over.id;
63
63
  if (activeId2 !== overId) {
64
64
  const activeIndex = items.findIndex(
65
65
  (item) => item[rowKey] === activeId2
@@ -15,5 +15,6 @@ export declare type SortType = {
15
15
  hiddenDraggableIcon?: boolean;
16
16
  hiddenRightIcon?: boolean;
17
17
  hiddenWarningIcon?: boolean;
18
+ tabKey?: string;
18
19
  onChange?: (value: ValueProps[]) => void;
19
20
  };
@@ -62,6 +62,11 @@ export default {
62
62
  },
63
63
  ]
64
64
  },
65
+ {
66
+ name: "tabKey",
67
+ title: { label: 'tabKey', tip: 'tabKey | 标识当前选中的tab' },
68
+ propType: 'string',
69
+ },
65
70
  {
66
71
  name: "titleRender",
67
72
  title: { label: '标题', tip: '是否自定义标题内容 | node/func' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.340",
3
+ "version": "1.0.341",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -63,8 +63,8 @@
63
63
  "react-virtualized-auto-sizer": "^1.0.20",
64
64
  "crypto-js": "^4.2.0",
65
65
  "@pisell/utils": "1.0.27",
66
- "@pisell/icon": "0.0.10",
67
- "@pisell/date-picker": "1.0.82"
66
+ "@pisell/date-picker": "1.0.82",
67
+ "@pisell/icon": "0.0.10"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0",