@pisell/materials 1.0.346 → 1.0.347

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 (36) 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 +4 -4
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +9 -9
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +8 -8
  11. package/es/components/Pagination/index.d.ts +1 -1
  12. package/es/components/drag-sort-tree/TreeItem/index.d.ts +4 -1
  13. package/es/components/drag-sort-tree/TreeItem/index.js +30 -31
  14. package/es/components/drag-sort-tree/TreeItem/index.less +34 -10
  15. package/es/components/drag-sort-tree/index.js +40 -16
  16. package/es/components/drag-sort-tree/types.d.ts +5 -1
  17. package/es/locales/en-US.d.ts +1 -0
  18. package/es/locales/en-US.js +2 -1
  19. package/es/locales/zh-CN.d.ts +1 -0
  20. package/es/locales/zh-CN.js +2 -1
  21. package/es/locales/zh-TW.d.ts +1 -0
  22. package/es/locales/zh-TW.js +2 -1
  23. package/lib/components/Pagination/index.d.ts +1 -1
  24. package/lib/components/drag-sort-tree/TreeItem/index.d.ts +4 -1
  25. package/lib/components/drag-sort-tree/TreeItem/index.js +43 -22
  26. package/lib/components/drag-sort-tree/TreeItem/index.less +34 -10
  27. package/lib/components/drag-sort-tree/index.js +28 -13
  28. package/lib/components/drag-sort-tree/types.d.ts +5 -1
  29. package/lib/locales/en-US.d.ts +1 -0
  30. package/lib/locales/en-US.js +2 -1
  31. package/lib/locales/zh-CN.d.ts +1 -0
  32. package/lib/locales/zh-CN.js +2 -1
  33. package/lib/locales/zh-TW.d.ts +1 -0
  34. package/lib/locales/zh-TW.js +2 -1
  35. package/lowcode/drag-sort-tree/meta.ts +9 -0
  36. package/package.json +3 -3
@@ -38,9 +38,16 @@ var import_sortable = require("@dnd-kit/sortable");
38
38
  var import_TreeItem = __toESM(require("./TreeItem"));
39
39
  var import_modifiers = require("@dnd-kit/modifiers");
40
40
  var DragSortTree = (props) => {
41
- const { value, rowKey, tabKey, onChange } = props;
41
+ const { value, rowKey, tabKey, hiddenKeys, onChange } = props;
42
42
  const [items, setItems] = (0, import_react.useState)(value || []);
43
- const [activeId, setActiveId] = (0, import_react.useState)(null);
43
+ const [expandedKeys, setExpandedKeys] = (0, import_react.useState)([]);
44
+ (0, import_react.useEffect)(() => {
45
+ let keys = value == null ? void 0 : value.map((item) => item[rowKey]);
46
+ keys = keys.filter(
47
+ (key) => (hiddenKeys == null ? void 0 : hiddenKeys.length) ? !hiddenKeys.includes(key) : key
48
+ );
49
+ setExpandedKeys([...keys]);
50
+ }, [hiddenKeys]);
44
51
  (0, import_react.useEffect)(() => {
45
52
  setItems(value || []);
46
53
  }, [tabKey]);
@@ -52,23 +59,30 @@ var DragSortTree = (props) => {
52
59
  })
53
60
  );
54
61
  const handleDragStart = (event) => {
62
+ var _a, _b;
55
63
  const { active } = event;
56
- setActiveId(active == null ? void 0 : active.id);
64
+ const activeId = (_b = (_a = active == null ? void 0 : active.id) == null ? void 0 : _a.split("-")) == null ? void 0 : _b[1];
65
+ const _keys = expandedKeys == null ? void 0 : expandedKeys.filter((key) => key != activeId);
66
+ setExpandedKeys([..._keys]);
57
67
  };
58
68
  const handleDragEnd = (event) => {
69
+ var _a, _b, _c, _d;
59
70
  const { active, over } = event;
60
- setActiveId(null);
61
71
  if (!over || !active)
62
72
  return;
63
73
  try {
64
- const activeId2 = active.id;
65
- const overId = over.id;
66
- if (activeId2 !== overId) {
74
+ let activeId = (_b = (_a = active == null ? void 0 : active.id) == null ? void 0 : _a.split("-")) == null ? void 0 : _b[1];
75
+ let overId = (_d = (_c = over == null ? void 0 : over.id) == null ? void 0 : _c.split("-")) == null ? void 0 : _d[1];
76
+ if (activeId !== overId) {
77
+ if (!(hiddenKeys == null ? void 0 : hiddenKeys.includes(Number(activeId)))) {
78
+ const _keys = [...expandedKeys, Number(activeId)];
79
+ setExpandedKeys([..._keys]);
80
+ }
67
81
  const activeIndex = items.findIndex(
68
- (item) => item[rowKey] === activeId2
82
+ (item) => item[rowKey] == activeId
69
83
  );
70
84
  const overIndex = items.findIndex(
71
- (item) => item[rowKey] === overId
85
+ (item) => item[rowKey] == overId
72
86
  );
73
87
  const _lists = (0, import_sortable.arrayMove)(items, activeIndex, overIndex);
74
88
  handleChange(_lists);
@@ -91,20 +105,21 @@ var DragSortTree = (props) => {
91
105
  /* @__PURE__ */ import_react.default.createElement(
92
106
  import_sortable.SortableContext,
93
107
  {
94
- items: items.map((item) => item[rowKey]),
108
+ items: items.map((item) => `0-${item[rowKey]}`),
95
109
  strategy: import_sortable.verticalListSortingStrategy
96
110
  },
97
111
  items.map((item) => /* @__PURE__ */ import_react.default.createElement(
98
112
  import_TreeItem.default,
99
113
  {
100
- key: item[rowKey],
101
- id: item[rowKey],
114
+ key: `0-${item[rowKey]}`,
115
+ id: `0-${item[rowKey]}`,
102
116
  item,
103
117
  depth: 0,
104
118
  sensors,
105
- activeId,
106
119
  childrenProps: props,
107
120
  lists: items,
121
+ expandedKeys,
122
+ setExpandedKeys,
108
123
  onChange: handleChange
109
124
  }
110
125
  ))
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
+ declare type IdType = string | number;
2
3
  export declare type ValueProps = {
3
- id: number | string;
4
+ id: IdType;
4
5
  title: string;
5
6
  show?: boolean;
6
7
  is_available?: boolean;
@@ -16,5 +17,8 @@ export declare type SortType = {
16
17
  hiddenRightIcon?: boolean;
17
18
  hiddenWarningIcon?: boolean;
18
19
  tabKey?: string;
20
+ hiddenKeys?: IdType[];
21
+ onHiddenChange?: (value: IdType[]) => void;
19
22
  onChange?: (value: ValueProps[]) => void;
20
23
  };
24
+ export {};
@@ -96,5 +96,6 @@ declare const _default: {
96
96
  'table-action-export-import-log-err-log': string;
97
97
  'table-action-export-import-log-copy': string;
98
98
  'table-action-export-import-table-success-copy': string;
99
+ 'drag-sort-tree-unavailable-today-tip': string;
99
100
  };
100
101
  export default _default;
@@ -123,5 +123,6 @@ var en_US_default = {
123
123
  "table-action-export-import-log-detail-title": "Import Details",
124
124
  "table-action-export-import-log-err-log": "Failure Log",
125
125
  "table-action-export-import-log-copy": "Copy",
126
- "table-action-export-import-table-success-copy": "Copy Success"
126
+ "table-action-export-import-table-success-copy": "Copy Success",
127
+ "drag-sort-tree-unavailable-today-tip": "Unavailable today"
127
128
  };
@@ -96,5 +96,6 @@ declare const _default: {
96
96
  'table-action-export-import-log-err-log': string;
97
97
  'table-action-export-import-log-copy': string;
98
98
  'table-action-export-import-table-success-copy': string;
99
+ 'drag-sort-tree-unavailable-today-tip': string;
99
100
  };
100
101
  export default _default;
@@ -123,5 +123,6 @@ var zh_CN_default = {
123
123
  "table-action-export-import-log-detail-title": "导入详情",
124
124
  "table-action-export-import-log-err-log": "失败日志",
125
125
  "table-action-export-import-log-copy": "复制",
126
- "table-action-export-import-table-success-copy": "复制成功"
126
+ "table-action-export-import-table-success-copy": "复制成功",
127
+ "drag-sort-tree-unavailable-today-tip": "今日不可用"
127
128
  };
@@ -96,5 +96,6 @@ declare const _default: {
96
96
  'table-action-export-import-log-err-log': string;
97
97
  'table-action-export-import-log-copy': string;
98
98
  'table-action-export-import-table-success-copy': string;
99
+ 'drag-sort-tree-unavailable-today-tip': string;
99
100
  };
100
101
  export default _default;
@@ -123,5 +123,6 @@ var zh_TW_default = {
123
123
  "table-action-export-import-log-detail-title": "導入詳情",
124
124
  "table-action-export-import-log-err-log": "失敗日誌",
125
125
  "table-action-export-import-log-copy": "復製",
126
- "table-action-export-import-table-success-copy": "復製成功"
126
+ "table-action-export-import-table-success-copy": "復製成功",
127
+ "drag-sort-tree-unavailable-today-tip": "今日不可用"
127
128
  };
@@ -67,6 +67,11 @@ export default {
67
67
  title: { label: 'tabKey', tip: 'tabKey | 标识当前选中的tab' },
68
68
  propType: 'string',
69
69
  },
70
+ {
71
+ name: "hiddenKeys",
72
+ title: { label: '折叠当前项', tip: 'hiddenKeys | 折叠当前项的keys' },
73
+ propType: 'array',
74
+ },
70
75
  {
71
76
  name: "titleRender",
72
77
  title: { label: '标题', tip: '是否自定义标题内容 | node/func' },
@@ -102,6 +107,10 @@ export default {
102
107
  name: 'onChange',
103
108
  template: 'onChange(value,${extParams}){\n// 排序 改变的回调\n}',
104
109
  },
110
+ {
111
+ name: 'onHiddenChange',
112
+ template: 'onHiddenChange(value,${extParams}){\n// 折叠当前项的回调\n}',
113
+ },
105
114
  ]
106
115
  },
107
116
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.346",
3
+ "version": "1.0.347",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -62,9 +62,9 @@
62
62
  "react-window": "^1.8.10",
63
63
  "react-virtualized-auto-sizer": "^1.0.20",
64
64
  "crypto-js": "^4.2.0",
65
+ "@pisell/utils": "1.0.27",
65
66
  "@pisell/icon": "0.0.10",
66
- "@pisell/date-picker": "1.0.83",
67
- "@pisell/utils": "1.0.27"
67
+ "@pisell/date-picker": "1.0.83"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "^18.0.0",