@pisell/materials 6.12.104 → 6.12.105
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.
- package/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +2 -2
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +2 -2
- package/es/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +44 -5
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +2 -1
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +5 -2
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.less +4 -2
- package/es/components/pisellDraggable/index.d.ts +3 -1
- package/es/components/pisellDraggable/index.js +287 -207
- package/es/components/pisellDraggable/types.d.ts +3 -1
- package/es/components/pisellDraggable/utilities.js +90 -79
- package/es/components/pisellDropSort/PisellDropSort.js +11 -4
- package/es/components/pisellDropSort/components/SortableItem/index.js +8 -5
- package/es/components/pisellDropSort/components/SortableItem/index.less +22 -0
- package/es/components/pisellDropSort/types.d.ts +1 -0
- package/es/components/pisellNavigationMenu/PisellNavigationMenu.js +44 -21
- package/es/components/pisellNavigationMenu/PisellNavigationMenu.less +7 -0
- package/es/components/pisellNavigationMenu/index.d.ts +1 -1
- package/es/components/pisellNavigationMenu/types.d.ts +15 -2
- package/lib/components/pisellDraggable/components/TreeItem/SortableTreeItem.js +43 -3
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +2 -1
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +5 -2
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.less +4 -2
- package/lib/components/pisellDraggable/index.d.ts +3 -1
- package/lib/components/pisellDraggable/index.js +281 -201
- package/lib/components/pisellDraggable/types.d.ts +3 -1
- package/lib/components/pisellDraggable/utilities.js +90 -79
- package/lib/components/pisellDropSort/PisellDropSort.js +10 -3
- package/lib/components/pisellDropSort/components/SortableItem/index.js +8 -5
- package/lib/components/pisellDropSort/components/SortableItem/index.less +22 -0
- package/lib/components/pisellDropSort/types.d.ts +1 -0
- package/lib/components/pisellNavigationMenu/PisellNavigationMenu.js +44 -21
- package/lib/components/pisellNavigationMenu/PisellNavigationMenu.less +7 -0
- package/lib/components/pisellNavigationMenu/index.d.ts +1 -1
- package/lib/components/pisellNavigationMenu/types.d.ts +15 -2
- package/package.json +1 -1
|
@@ -1,87 +1,98 @@
|
|
|
1
|
-
require("../../_virtual/_rolldown/runtime.js");
|
|
2
1
|
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
3
|
-
let _dnd_kit_sortable = require("@dnd-kit/sortable");
|
|
4
2
|
//#region src/components/pisellDraggable/utilities.ts
|
|
5
3
|
const iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const minDepth = getMinDepth({ nextItem });
|
|
20
|
-
let depth = projectedDepth;
|
|
21
|
-
if (projectedDepth >= maxDepth) depth = maxDepth;
|
|
22
|
-
else if (projectedDepth < minDepth) depth = minDepth;
|
|
23
|
-
return {
|
|
4
|
+
function getProjection(items, indices, activeIndex, overIndex, depthChange) {
|
|
5
|
+
var _next$depth;
|
|
6
|
+
const previous = items[overIndex - (activeIndex < overIndex ? 0 : 1)];
|
|
7
|
+
const next = items[overIndex + (activeIndex > overIndex ? 0 : 1)];
|
|
8
|
+
const requestedDepth = items[activeIndex].depth + depthChange;
|
|
9
|
+
const maxDepth = previous ? previous.depth + 1 : 0;
|
|
10
|
+
const minDepth = (_next$depth = next === null || next === void 0 ? void 0 : next.depth) !== null && _next$depth !== void 0 ? _next$depth : 0;
|
|
11
|
+
const depth = requestedDepth >= maxDepth ? maxDepth : Math.max(requestedDepth, minDepth);
|
|
12
|
+
if (!depth || !previous) return {
|
|
13
|
+
depth,
|
|
14
|
+
parentId: null
|
|
15
|
+
};
|
|
16
|
+
if (depth > previous.depth) return {
|
|
24
17
|
depth,
|
|
25
|
-
|
|
26
|
-
minDepth,
|
|
27
|
-
parentId: getParentId()
|
|
18
|
+
parentId: previous.id
|
|
28
19
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
20
|
+
let ancestor = previous;
|
|
21
|
+
while (ancestor.depth > depth && ancestor.parentId !== null) {
|
|
22
|
+
const parentIndex = indices.get(ancestor.parentId);
|
|
23
|
+
if (parentIndex === void 0) return {
|
|
24
|
+
depth,
|
|
25
|
+
parentId: null
|
|
26
|
+
};
|
|
27
|
+
ancestor = items[parentIndex];
|
|
36
28
|
}
|
|
29
|
+
return {
|
|
30
|
+
depth,
|
|
31
|
+
parentId: ancestor.parentId
|
|
32
|
+
};
|
|
37
33
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
34
|
+
function createNavigationHitTest(sortedIds, nodes) {
|
|
35
|
+
let lastIndex = -1;
|
|
36
|
+
const measure = (index) => {
|
|
37
|
+
var _nodes$get;
|
|
38
|
+
return (_nodes$get = nodes.get(sortedIds[index])) === null || _nodes$get === void 0 ? void 0 : _nodes$get.getBoundingClientRect();
|
|
39
|
+
};
|
|
40
|
+
return ({ x, y }) => {
|
|
41
|
+
let index = lastIndex;
|
|
42
|
+
let rect = measure(index);
|
|
43
|
+
if (!rect || y < rect.top || y > rect.bottom) {
|
|
44
|
+
let low = rect && y > rect.bottom ? index + 1 : 0;
|
|
45
|
+
let high = rect && y < rect.top ? index - 1 : sortedIds.length - 1;
|
|
46
|
+
while (low <= high) {
|
|
47
|
+
index = Math.floor((low + high) / 2);
|
|
48
|
+
rect = measure(index);
|
|
49
|
+
if (!rect) return null;
|
|
50
|
+
if (y < rect.top) high = index - 1;
|
|
51
|
+
else if (y > rect.bottom) low = index + 1;
|
|
52
|
+
else break;
|
|
53
|
+
}
|
|
54
|
+
if (low > high) {
|
|
55
|
+
const previous = measure(high);
|
|
56
|
+
const next = measure(low);
|
|
57
|
+
if (!previous || !next) return null;
|
|
58
|
+
index = y - previous.bottom <= next.top - y ? high : low;
|
|
59
|
+
rect = index === high ? previous : next;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!rect || x < rect.left || x > rect.right) return null;
|
|
63
|
+
lastIndex = index;
|
|
64
|
+
return {
|
|
65
|
+
rowId: sortedIds[index],
|
|
66
|
+
position: y < rect.top + rect.height / 2 ? "before" : "after"
|
|
67
|
+
};
|
|
68
|
+
};
|
|
45
69
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
|
|
70
|
+
function flattenTree(items) {
|
|
71
|
+
const rows = [];
|
|
72
|
+
const visit = (list, parentId, depth) => {
|
|
73
|
+
list.forEach((item, index) => {
|
|
74
|
+
var _item$children;
|
|
75
|
+
rows.push(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
|
|
52
76
|
parentId,
|
|
53
77
|
depth,
|
|
54
78
|
index
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return flatten(items);
|
|
79
|
+
}));
|
|
80
|
+
if ((_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.length) visit(item.children, item.id, depth + 1);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
visit(items, null, 0);
|
|
84
|
+
return rows;
|
|
62
85
|
}
|
|
63
86
|
function buildTree(flattenedItems) {
|
|
64
|
-
const root =
|
|
65
|
-
id: "root",
|
|
66
|
-
children: []
|
|
67
|
-
};
|
|
68
|
-
const nodes = { [root.id]: root };
|
|
87
|
+
const root = [];
|
|
69
88
|
const items = flattenedItems.map((item) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { children: [] }));
|
|
89
|
+
const nodes = new Map(items.map((item) => [item.id, item]));
|
|
70
90
|
for (const item of items) {
|
|
71
|
-
var
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const parent = (_nodes$parentId = nodes[parentId]) !== null && _nodes$parentId !== void 0 ? _nodes$parentId : findItem(items, parentId);
|
|
75
|
-
nodes[id] = {
|
|
76
|
-
id,
|
|
77
|
-
children
|
|
78
|
-
};
|
|
79
|
-
parent.children.push(item);
|
|
91
|
+
var _parent$children;
|
|
92
|
+
const parent = item.parentId === null ? void 0 : nodes.get(item.parentId);
|
|
93
|
+
((_parent$children = parent === null || parent === void 0 ? void 0 : parent.children) !== null && _parent$children !== void 0 ? _parent$children : root).push(item);
|
|
80
94
|
}
|
|
81
|
-
return root
|
|
82
|
-
}
|
|
83
|
-
function findItem(items, itemId) {
|
|
84
|
-
return items.find(({ id }) => id === itemId);
|
|
95
|
+
return root;
|
|
85
96
|
}
|
|
86
97
|
function findItemDeep(items, itemId) {
|
|
87
98
|
for (const item of items) {
|
|
@@ -104,15 +115,14 @@ function removeItem(items, id) {
|
|
|
104
115
|
return newItems;
|
|
105
116
|
}
|
|
106
117
|
function setProperty(items, id, property, setter) {
|
|
107
|
-
|
|
118
|
+
const next = items.map((item) => {
|
|
108
119
|
var _item$children3;
|
|
109
|
-
if (item.id === id) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return [...items];
|
|
120
|
+
if (item.id === id) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { [property]: setter(item[property]) });
|
|
121
|
+
if (!((_item$children3 = item.children) === null || _item$children3 === void 0 ? void 0 : _item$children3.length)) return item;
|
|
122
|
+
const children = setProperty(item.children, id, property, setter);
|
|
123
|
+
return children === item.children ? item : require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { children });
|
|
124
|
+
});
|
|
125
|
+
return next.some((item, index) => item !== items[index]) ? next : items;
|
|
116
126
|
}
|
|
117
127
|
function countChildren(items, count = 0) {
|
|
118
128
|
return items.reduce((acc, { children }) => {
|
|
@@ -125,11 +135,11 @@ function getChildCount(items, id) {
|
|
|
125
135
|
return item ? countChildren(item.children) : 0;
|
|
126
136
|
}
|
|
127
137
|
function removeChildrenOf(items, ids) {
|
|
128
|
-
const excludeParentIds =
|
|
138
|
+
const excludeParentIds = new Set(ids);
|
|
129
139
|
return items.filter((item) => {
|
|
130
|
-
if (item.parentId && excludeParentIds.
|
|
140
|
+
if (item.parentId !== null && excludeParentIds.has(item.parentId)) {
|
|
131
141
|
var _item$children4;
|
|
132
|
-
if ((_item$children4 = item.children) === null || _item$children4 === void 0 ? void 0 : _item$children4.length) excludeParentIds.
|
|
142
|
+
if ((_item$children4 = item.children) === null || _item$children4 === void 0 ? void 0 : _item$children4.length) excludeParentIds.add(item.id);
|
|
133
143
|
return false;
|
|
134
144
|
}
|
|
135
145
|
return true;
|
|
@@ -137,6 +147,7 @@ function removeChildrenOf(items, ids) {
|
|
|
137
147
|
}
|
|
138
148
|
//#endregion
|
|
139
149
|
exports.buildTree = buildTree;
|
|
150
|
+
exports.createNavigationHitTest = createNavigationHitTest;
|
|
140
151
|
exports.flattenTree = flattenTree;
|
|
141
152
|
exports.getChildCount = getChildCount;
|
|
142
153
|
exports.getProjection = getProjection;
|
|
@@ -10,7 +10,8 @@ let classnames = require("classnames");
|
|
|
10
10
|
classnames = require_runtime.__toESM(classnames);
|
|
11
11
|
require("./PisellDropSort.less");
|
|
12
12
|
//#region src/components/pisellDropSort/PisellDropSort.tsx
|
|
13
|
-
const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allowAddChild = true, allowAddRoot = true, allowIsShow = false, disabled = false, spacing = 8, maxLevel = 3, showBorder = true, style, className, onChange, onDelete, onAdd, renderItem: propsRenderItem, leftContent, rightContent, onAddRoot, __designMode, isCustomAction, emptyContent, getItemStyle, canDrop, indentationWidth }) => {
|
|
13
|
+
const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allowAddChild = true, allowAddRoot = true, allowIsShow = false, disabled = false, spacing = 8, maxLevel = 3, showBorder = true, style, className, onChange, onDelete, onAdd, renderItem: propsRenderItem, leftContent, rightContent, onAddRoot, __designMode, isCustomAction, emptyContent, getItemStyle, canDrop, dropOnPageAsSibling, indentationWidth }) => {
|
|
14
|
+
const dropBoundary = (0, react.useRef)(null);
|
|
14
15
|
const renderItem = (0, react.useCallback)((itemProps, ref) => {
|
|
15
16
|
return /* @__PURE__ */ react.default.createElement(require_index$3.default, {
|
|
16
17
|
itemProps,
|
|
@@ -34,14 +35,17 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
34
35
|
allowAddChild,
|
|
35
36
|
allowDelete,
|
|
36
37
|
allowDrag,
|
|
37
|
-
|
|
38
|
+
allowIsShow,
|
|
38
39
|
disabled,
|
|
39
40
|
maxLevel,
|
|
40
41
|
onAdd,
|
|
41
42
|
onDelete,
|
|
42
43
|
showBorder,
|
|
43
44
|
spacing,
|
|
44
|
-
isCustomAction
|
|
45
|
+
isCustomAction,
|
|
46
|
+
propsRenderItem,
|
|
47
|
+
getItemStyle,
|
|
48
|
+
__designMode
|
|
45
49
|
]);
|
|
46
50
|
const handleChange = (0, react.useCallback)((items) => {
|
|
47
51
|
onChange === null || onChange === void 0 || onChange(items);
|
|
@@ -56,6 +60,7 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
56
60
|
onClick: () => onAddRoot === null || onAddRoot === void 0 ? void 0 : onAddRoot(),
|
|
57
61
|
size: "large"
|
|
58
62
|
}, require_index.getText("pisell-lowcode-drop-sort-add")))), /* @__PURE__ */ react.default.createElement("div", {
|
|
63
|
+
ref: dropBoundary,
|
|
59
64
|
className: "pisell-lowcode-drop-sort-container-content",
|
|
60
65
|
style: { gap: spacing !== null && spacing !== void 0 ? spacing : 8 }
|
|
61
66
|
}, value.length === 0 && emptyContent ? emptyContent : /* @__PURE__ */ react.default.createElement(require_index$2.SortableTree, {
|
|
@@ -67,6 +72,8 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
67
72
|
renderItem,
|
|
68
73
|
onChange: handleChange,
|
|
69
74
|
canDrop,
|
|
75
|
+
dropOnPageAsSibling,
|
|
76
|
+
dropBoundary,
|
|
70
77
|
maxLevel
|
|
71
78
|
})));
|
|
72
79
|
};
|
|
@@ -27,25 +27,27 @@ const _excluded = [
|
|
|
27
27
|
"indentationWidth",
|
|
28
28
|
"handleProps",
|
|
29
29
|
"collapsed",
|
|
30
|
-
"isError"
|
|
30
|
+
"isError",
|
|
31
|
+
"dropPosition"
|
|
31
32
|
];
|
|
32
33
|
const SortableItem = (props) => {
|
|
33
34
|
const { itemProps, render, domRef, allowAddChild, allowDelete, allowDrag, allowIsShow, disabled, onAdd, onDelete, showBorder, spacing, maxLevel, __designMode, isCustomAction, getItemStyle } = props;
|
|
34
|
-
const { item, depth, clone, ghost, indicator, disableSelection, disableInteraction, wrapperRef, style, onCollapse, onRemove, childCount, indentationWidth, handleProps, collapsed, isError } = itemProps, otherProps = require_objectWithoutProperties._objectWithoutProperties(itemProps, _excluded);
|
|
35
|
+
const { item, depth, clone, ghost, indicator, disableSelection, disableInteraction, wrapperRef, style, onCollapse, onRemove, childCount, indentationWidth, handleProps, collapsed, isError, dropPosition } = itemProps, otherProps = require_objectWithoutProperties._objectWithoutProperties(itemProps, _excluded);
|
|
35
36
|
const mergedStyle = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (getItemStyle === null || getItemStyle === void 0 ? void 0 : getItemStyle(itemProps)) || {}), style);
|
|
36
37
|
if (isError) mergedStyle.backgroundColor = "#FECDCA";
|
|
37
38
|
return /* @__PURE__ */ react.default.createElement("li", require_objectSpread2._objectSpread2({
|
|
38
|
-
className: (0, classnames.default)("pisell-lowcode-drop-sort-item", clone && "clone", ghost && "ghost", indicator && "indicator", disableSelection && "disableSelection", disableInteraction && "disableInteraction"),
|
|
39
|
+
className: (0, classnames.default)("pisell-lowcode-drop-sort-item", item.isSection && "pisell-lowcode-drop-sort-item-section", clone && "clone", ghost && "ghost", indicator && "indicator", disableSelection && "disableSelection", disableInteraction && "disableInteraction"),
|
|
39
40
|
ref: wrapperRef,
|
|
41
|
+
"data-drop-position": dropPosition,
|
|
40
42
|
style: { "--spacing": `${indentationWidth * depth}px` }
|
|
41
43
|
}, otherProps), /* @__PURE__ */ react.default.createElement("div", {
|
|
42
44
|
className: (0, classnames.default)("pisell-lowcode-drop-sort-item-tree-item", {
|
|
43
|
-
"pisell-lowcode-drop-sort-item-tree-item-border": showBorder,
|
|
45
|
+
"pisell-lowcode-drop-sort-item-tree-item-border": showBorder && !item.isSection,
|
|
44
46
|
disabled
|
|
45
47
|
}),
|
|
46
48
|
ref: domRef,
|
|
47
49
|
style: mergedStyle
|
|
48
|
-
}, allowDrag && !disabled && /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2({
|
|
50
|
+
}, allowDrag && !disabled && !item.isSection && /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2({
|
|
49
51
|
icon: /* @__PURE__ */ react.default.createElement(_pisell_icon_es_DotsSix.default, { className: "pisell-lowcode-drop-sort-item-drag-handle-icon" }),
|
|
50
52
|
type: "text",
|
|
51
53
|
className: "pisell-lowcode-drop-sort-item-button"
|
|
@@ -55,6 +57,7 @@ const SortableItem = (props) => {
|
|
|
55
57
|
className: "pisell-lowcode-drop-sort-item-icon"
|
|
56
58
|
}),
|
|
57
59
|
onClick: onCollapse,
|
|
60
|
+
"aria-expanded": !collapsed,
|
|
58
61
|
type: "text",
|
|
59
62
|
className: (0, classnames.default)("Collapse", collapsed && "collapsed", "pisell-lowcode-drop-sort-item-button")
|
|
60
63
|
}), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-drop-sort-item-content" }, render && render(itemProps)), !isCustomAction && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, !clone && allowAddChild && !disabled && /* @__PURE__ */ react.default.createElement(require_index.default, {
|
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
padding-left: var(--spacing);
|
|
4
4
|
list-style: none;
|
|
5
5
|
|
|
6
|
+
&[data-drop-position='before'] > .pisell-lowcode-drop-sort-item-tree-item::after,
|
|
7
|
+
&[data-drop-position='after'] > .pisell-lowcode-drop-sort-item-tree-item::after {
|
|
8
|
+
position: absolute;
|
|
9
|
+
right: 0;
|
|
10
|
+
left: var(--pisell-drop-sort-line-offset, 0);
|
|
11
|
+
height: 2px;
|
|
12
|
+
border-radius: 2px;
|
|
13
|
+
background: #6941c6;
|
|
14
|
+
content: '';
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&[data-drop-position='before'] > .pisell-lowcode-drop-sort-item-tree-item::after { top: -5px; }
|
|
19
|
+
&[data-drop-position='after'] > .pisell-lowcode-drop-sort-item-tree-item::after { bottom: -5px; }
|
|
20
|
+
&[data-drop-position='inside'] > .pisell-lowcode-drop-sort-item-tree-item {
|
|
21
|
+
box-shadow: inset 0 0 0 2px #6941c6;
|
|
22
|
+
}
|
|
23
|
+
|
|
6
24
|
&.clone {
|
|
7
25
|
display: inline-block;
|
|
8
26
|
pointer-events: none;
|
|
@@ -65,6 +83,10 @@
|
|
|
65
83
|
|
|
66
84
|
}
|
|
67
85
|
|
|
86
|
+
.pisell-lowcode-drop-sort-item-section {
|
|
87
|
+
&:not(:first-child) { margin-top: 12px; }
|
|
88
|
+
}
|
|
89
|
+
|
|
68
90
|
.pisell-lowcode-drop-sort-item-tree-item {
|
|
69
91
|
position: relative;
|
|
70
92
|
display: flex;
|
|
@@ -55,6 +55,7 @@ interface PisellDropSortProps {
|
|
|
55
55
|
getItemStyle?: (itemProps: Props) => React.CSSProperties;
|
|
56
56
|
/** 自定义拖拽判断函数,返回false时阻止拖拽 */
|
|
57
57
|
canDrop?: (dragItem: DropSortItem, dropTarget: DropSortItem, parentId: string | number | null) => boolean;
|
|
58
|
+
dropOnPageAsSibling?: boolean;
|
|
58
59
|
/** 节点缩进宽度 */
|
|
59
60
|
indentationWidth?: number;
|
|
60
61
|
}
|
|
@@ -15,7 +15,10 @@ let classnames = require("classnames");
|
|
|
15
15
|
classnames = require_runtime.__toESM(classnames);
|
|
16
16
|
require("./PisellNavigationMenu.less");
|
|
17
17
|
//#region src/components/pisellNavigationMenu/PisellNavigationMenu.tsx
|
|
18
|
-
const
|
|
18
|
+
const MenuRow = react.default.memo(function MenuRow({ item, clone, render }) {
|
|
19
|
+
return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, render(item, clone));
|
|
20
|
+
});
|
|
21
|
+
const PisellNavigationMenu = ({ value = [], sections, allowDrag = true, allowDelete = true, allowAddChild = true, allowAddRoot = true, allowIsShow = true, disabled = false, spacing = 8, maxLevel = 3, style, className, onChange, onAddSubMenu, onAddPage, onEdit, onDelete, onIsShow, __designMode, title, rightContent: propsRightContent, renderItemActions, getItemStyle: propsGetItemStyle, canDrop, dropOnPageAsSibling, indentationWidth = 24, hideDescription, showActionOnHover, showTitleTags }) => {
|
|
19
22
|
const convertToNavigationItems = (items) => {
|
|
20
23
|
return items.map((item) => ({
|
|
21
24
|
id: String(item.id),
|
|
@@ -25,19 +28,10 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
25
28
|
children: item.children ? convertToNavigationItems(item.children) : []
|
|
26
29
|
}));
|
|
27
30
|
};
|
|
28
|
-
(0, react.useMemo)(() => {
|
|
29
|
-
return [{
|
|
30
|
-
label: require_index.getText("pisell-lowcode-navigation-menu-add-sub-menu"),
|
|
31
|
-
key: "add-child"
|
|
32
|
-
}, {
|
|
33
|
-
label: require_index.getText("pisell-lowcode-navigation-menu-add-page"),
|
|
34
|
-
key: "add-page"
|
|
35
|
-
}];
|
|
36
|
-
}, []);
|
|
37
31
|
const handleClick = (0, react.useCallback)((key, item) => {
|
|
38
32
|
if (key === "add-child") onAddSubMenu === null || onAddSubMenu === void 0 || onAddSubMenu(item);
|
|
39
33
|
else if (key === "add-page") onAddPage === null || onAddPage === void 0 || onAddPage(item);
|
|
40
|
-
}, []);
|
|
34
|
+
}, [onAddSubMenu, onAddPage]);
|
|
41
35
|
const tagTextMap = (0, react.useMemo)(() => {
|
|
42
36
|
return {
|
|
43
37
|
base: {
|
|
@@ -66,9 +60,9 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
66
60
|
}
|
|
67
61
|
};
|
|
68
62
|
}, []);
|
|
69
|
-
const
|
|
63
|
+
const renderRow = (0, react.useCallback)((item, clone) => {
|
|
70
64
|
var _tagTextMap$group, _tagTextMap$group2, _tagTextMap$subMenu, _tagTextMap$subMenu2, _tagTextMap$custom, _tagTextMap$custom2, _tagTextMap$item$sour, _tagTextMap$item$sour2;
|
|
71
|
-
|
|
65
|
+
if (item.isSection) return /* @__PURE__ */ react.default.createElement("h3", { className: "pisell-lowcode-navigation-menu-section-title" }, item.title);
|
|
72
66
|
const { allowEdit = true, allowDelete = true, allowAddChild = true, allowAddSubmenu = true, allowAddPage = true, allowIsShow = true } = item;
|
|
73
67
|
const isShowAddButton = item.isGroup && allowAddChild && (allowAddSubmenu || allowAddPage);
|
|
74
68
|
return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-navigation-menu-item" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content" }, item.icon && /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content-icon" }, /* @__PURE__ */ react.default.createElement(require_index$2.default, { type: item.icon })), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content-text" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode-navigation-menu-item-title" }, item.title, showTitleTags && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, item.isGroup && item.is_top && /* @__PURE__ */ react.default.createElement(require_index$3.default, {
|
|
@@ -89,15 +83,18 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
89
83
|
}, ((_tagTextMap$item$sour2 = tagTextMap[item.source]) === null || _tagTextMap$item$sour2 === void 0 ? void 0 : _tagTextMap$item$sour2.text) || ""), !item.isGroup && item.version && /* @__PURE__ */ react.default.createElement(require_index$3.default, {
|
|
90
84
|
type: "pill_color",
|
|
91
85
|
color: "success"
|
|
92
|
-
}, "v", item.version)))), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-lowcode-navigation-menu-item-action-wrap", { "pisell-lowcode-navigation-menu-item-action-wrap-hover": showActionOnHover }) }, allowIsShow && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
86
|
+
}, "v", item.version)))), /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)("pisell-lowcode-navigation-menu-item-action-wrap", { "pisell-lowcode-navigation-menu-item-action-wrap-hover": showActionOnHover }) }, (allowIsShow || item.disableIsShow) && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
93
87
|
type: "text",
|
|
88
|
+
disabled: item.disableIsShow,
|
|
89
|
+
"aria-label": item.visibilityLabel,
|
|
90
|
+
title: item.visibilityLabel,
|
|
94
91
|
onClick: () => onIsShow === null || onIsShow === void 0 ? void 0 : onIsShow(item),
|
|
95
92
|
className: "pisell-lowcode-navigation-menu-item-action-button",
|
|
96
93
|
icon: /* @__PURE__ */ react.default.createElement(require_index$2.default, {
|
|
97
94
|
type: item.is_show === false ? "pisell2-eye-off" : "pisell2-eye",
|
|
98
95
|
className: "pisell-lowcode-navigation-menu-item-action-button-icon"
|
|
99
96
|
})
|
|
100
|
-
}), allowEdit && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
97
|
+
}), !clone && (renderItemActions === null || renderItemActions === void 0 ? void 0 : renderItemActions(item)), allowEdit && /* @__PURE__ */ react.default.createElement(require_index$1.default, {
|
|
101
98
|
type: "text",
|
|
102
99
|
onClick: () => onEdit === null || onEdit === void 0 ? void 0 : onEdit(item),
|
|
103
100
|
className: "pisell-lowcode-navigation-menu-item-action-button",
|
|
@@ -132,7 +129,22 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
132
129
|
className: "pisell-lowcode-navigation-menu-item-action-button-icon"
|
|
133
130
|
})
|
|
134
131
|
})));
|
|
135
|
-
}, [
|
|
132
|
+
}, [
|
|
133
|
+
handleClick,
|
|
134
|
+
hideDescription,
|
|
135
|
+
onDelete,
|
|
136
|
+
onEdit,
|
|
137
|
+
onIsShow,
|
|
138
|
+
renderItemActions,
|
|
139
|
+
showActionOnHover,
|
|
140
|
+
showTitleTags,
|
|
141
|
+
tagTextMap
|
|
142
|
+
]);
|
|
143
|
+
const renderMenuItem = (0, react.useCallback)(({ item, clone }) => /* @__PURE__ */ react.default.createElement(MenuRow, {
|
|
144
|
+
item,
|
|
145
|
+
clone: Boolean(clone),
|
|
146
|
+
render: renderRow
|
|
147
|
+
}), [renderRow]);
|
|
136
148
|
const handleChange = (0, react.useCallback)((items) => {
|
|
137
149
|
onChange === null || onChange === void 0 || onChange(convertToNavigationItems(items));
|
|
138
150
|
}, [onChange]);
|
|
@@ -151,10 +163,20 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
151
163
|
icon: /* @__PURE__ */ react.default.createElement(require_index$2.default, { type: "pisell2-plus" }),
|
|
152
164
|
onClick: () => onAddPage === null || onAddPage === void 0 ? void 0 : onAddPage()
|
|
153
165
|
}, require_index.getText("pisell-lowcode-navigation-menu-add-page")));
|
|
154
|
-
}, [
|
|
166
|
+
}, [
|
|
167
|
+
propsRightContent,
|
|
168
|
+
onAddPage,
|
|
169
|
+
onAddSubMenu
|
|
170
|
+
]);
|
|
155
171
|
const formatValue = (0, react.useMemo)(() => {
|
|
156
|
-
return require_utils.formatTree(
|
|
157
|
-
|
|
172
|
+
return require_utils.formatTree((sections === null || sections === void 0 ? void 0 : sections.length) ? sections.map(({ id, title, items }) => ({
|
|
173
|
+
id,
|
|
174
|
+
title,
|
|
175
|
+
isSection: true,
|
|
176
|
+
isGroup: true,
|
|
177
|
+
children: items
|
|
178
|
+
})) : value, (item) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { disabledDrop: !item.isGroup }));
|
|
179
|
+
}, [sections, value]);
|
|
158
180
|
const getItemStyle = (0, react.useCallback)((itemProps) => {
|
|
159
181
|
const { item } = itemProps;
|
|
160
182
|
if ((0, _pisell_utils.isFunction)(propsGetItemStyle)) return (propsGetItemStyle === null || propsGetItemStyle === void 0 ? void 0 : propsGetItemStyle(item)) || {};
|
|
@@ -170,7 +192,7 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
170
192
|
allowIsShow,
|
|
171
193
|
disabled,
|
|
172
194
|
spacing,
|
|
173
|
-
maxLevel,
|
|
195
|
+
maxLevel: maxLevel + Number(Boolean(sections === null || sections === void 0 ? void 0 : sections.length)),
|
|
174
196
|
style,
|
|
175
197
|
className,
|
|
176
198
|
onChange: handleChange,
|
|
@@ -184,7 +206,8 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
184
206
|
maxWidth: 400,
|
|
185
207
|
description: require_index.getText("pisell-lowcode-navigation-menu-add-page-tip")
|
|
186
208
|
}),
|
|
187
|
-
canDrop
|
|
209
|
+
canDrop,
|
|
210
|
+
dropOnPageAsSibling: dropOnPageAsSibling || Boolean(sections === null || sections === void 0 ? void 0 : sections.length)
|
|
188
211
|
});
|
|
189
212
|
};
|
|
190
213
|
//#endregion
|
|
@@ -73,6 +73,13 @@
|
|
|
73
73
|
line-height: 24px; /* 150% */
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
.pisell-lowcode-navigation-menu-section-title {
|
|
77
|
+
margin: 0;
|
|
78
|
+
color: var(--Gray-700, #344054);
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
}
|
|
82
|
+
|
|
76
83
|
.pisell-lowcode-navigation-menu-right-content {
|
|
77
84
|
display: flex;
|
|
78
85
|
gap: 8px;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { NavigationMenuItem, PisellNavigationMenuProps } from "./types.js";
|
|
1
|
+
import { NavigationMenuItem, NavigationMenuSection, PisellNavigationMenuProps } from "./types.js";
|
|
2
2
|
import { PisellNavigationMenu } from "./PisellNavigationMenu.js";
|
|
@@ -26,12 +26,22 @@ interface NavigationMenuItem {
|
|
|
26
26
|
allowAddSubmenu?: boolean;
|
|
27
27
|
/** 是否允许添加页面 */
|
|
28
28
|
allowAddPage?: boolean;
|
|
29
|
+
/** Keep the visibility button present while preventing changes. */
|
|
30
|
+
disableIsShow?: boolean;
|
|
31
|
+
visibilityLabel?: string;
|
|
29
32
|
/** 其他属性 */
|
|
30
33
|
[key: string]: any;
|
|
31
34
|
}
|
|
35
|
+
interface NavigationMenuSection {
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
items: NavigationMenuItem[];
|
|
39
|
+
}
|
|
32
40
|
interface PisellNavigationMenuProps {
|
|
33
41
|
/** 导航菜单数据 */
|
|
34
42
|
value: NavigationMenuItem[];
|
|
43
|
+
/** Optional fixed headings that share the same drag context. */
|
|
44
|
+
sections?: readonly NavigationMenuSection[];
|
|
35
45
|
/** 是否允许拖拽排序 */
|
|
36
46
|
allowDrag?: boolean;
|
|
37
47
|
/** 是否允许删除菜单项 */
|
|
@@ -52,7 +62,7 @@ interface PisellNavigationMenuProps {
|
|
|
52
62
|
style?: CSSProperties;
|
|
53
63
|
/** 类名 */
|
|
54
64
|
className?: string;
|
|
55
|
-
/**
|
|
65
|
+
/** 数据变化回调。配置 sections 时,各分区标题作为根节点返回。 */
|
|
56
66
|
onChange?: (items: NavigationMenuItem[]) => void;
|
|
57
67
|
/** 设计模式 */
|
|
58
68
|
__designMode?: string;
|
|
@@ -70,10 +80,13 @@ interface PisellNavigationMenuProps {
|
|
|
70
80
|
leftContent?: React.ReactNode;
|
|
71
81
|
/** 右侧自定义内容 */
|
|
72
82
|
rightContent?: React.ReactNode;
|
|
83
|
+
renderItemActions?: (item: NavigationMenuItem) => React.ReactNode;
|
|
73
84
|
/** 获取item样式 */
|
|
74
85
|
getItemStyle?: (itemProps: Props) => React.CSSProperties;
|
|
75
86
|
/** 自定义拖拽判断函数,返回false时阻止拖拽 */
|
|
76
87
|
canDrop?: (dragItem: NavigationMenuItem, dropTarget: NavigationMenuItem, parentId: string | number | null) => boolean;
|
|
88
|
+
/** Use the target row's upper/lower half to choose the insertion position. */
|
|
89
|
+
dropOnPageAsSibling?: boolean;
|
|
77
90
|
/** 显示隐藏回调 */
|
|
78
91
|
onIsShow?: (item: NavigationMenuItem) => void;
|
|
79
92
|
/** 节点缩进宽度 */
|
|
@@ -86,4 +99,4 @@ interface PisellNavigationMenuProps {
|
|
|
86
99
|
showTitleTags?: boolean;
|
|
87
100
|
}
|
|
88
101
|
//#endregion
|
|
89
|
-
export { NavigationMenuItem, PisellNavigationMenuProps };
|
|
102
|
+
export { NavigationMenuItem, NavigationMenuSection, PisellNavigationMenuProps };
|