@pisell/materials 1.10.44 → 1.10.46
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/preview.js +1 -1
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +4 -4
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +4 -4
- 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/es/components/pisellToast/squareToast/toast.js +1 -1
- package/es/components/productCard/cartSkuCard/variants/A12/index.js +3 -1
- package/es/components/productCard/cartSkuCard/variants/A12/index.less +11 -0
- package/es/pisell-materials.tw.css +1 -1
- 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/lib/components/pisellToast/squareToast/toast.js +1 -1
- package/lib/components/productCard/cartSkuCard/variants/A12/index.js +3 -1
- package/lib/components/productCard/cartSkuCard/variants/A12/index.less +11 -0
- package/lib/pisell-materials.tw.css +1 -1
- package/package.json +3 -3
|
@@ -1,86 +1,98 @@
|
|
|
1
1
|
import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
|
|
2
|
-
import { arrayMove } from "@dnd-kit/sortable";
|
|
3
2
|
//#region src/components/pisellDraggable/utilities.ts
|
|
4
3
|
const iOS = /iPad|iPhone|iPod/.test(navigator.platform);
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const minDepth = getMinDepth({ nextItem });
|
|
19
|
-
let depth = projectedDepth;
|
|
20
|
-
if (projectedDepth >= maxDepth) depth = maxDepth;
|
|
21
|
-
else if (projectedDepth < minDepth) depth = minDepth;
|
|
22
|
-
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 {
|
|
23
17
|
depth,
|
|
24
|
-
|
|
25
|
-
minDepth,
|
|
26
|
-
parentId: getParentId()
|
|
18
|
+
parentId: previous.id
|
|
27
19
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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];
|
|
35
28
|
}
|
|
29
|
+
return {
|
|
30
|
+
depth,
|
|
31
|
+
parentId: ancestor.parentId
|
|
32
|
+
};
|
|
36
33
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
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
|
+
};
|
|
44
69
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_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(_objectSpread2(_objectSpread2({}, item), {}, {
|
|
51
76
|
parentId,
|
|
52
77
|
depth,
|
|
53
78
|
index
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
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;
|
|
61
85
|
}
|
|
62
86
|
function buildTree(flattenedItems) {
|
|
63
|
-
const root =
|
|
64
|
-
id: "root",
|
|
65
|
-
children: []
|
|
66
|
-
};
|
|
67
|
-
const nodes = { [root.id]: root };
|
|
87
|
+
const root = [];
|
|
68
88
|
const items = flattenedItems.map((item) => _objectSpread2(_objectSpread2({}, item), {}, { children: [] }));
|
|
89
|
+
const nodes = new Map(items.map((item) => [item.id, item]));
|
|
69
90
|
for (const item of items) {
|
|
70
|
-
var
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const parent = (_nodes$parentId = nodes[parentId]) !== null && _nodes$parentId !== void 0 ? _nodes$parentId : findItem(items, parentId);
|
|
74
|
-
nodes[id] = {
|
|
75
|
-
id,
|
|
76
|
-
children
|
|
77
|
-
};
|
|
78
|
-
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);
|
|
79
94
|
}
|
|
80
|
-
return root
|
|
81
|
-
}
|
|
82
|
-
function findItem(items, itemId) {
|
|
83
|
-
return items.find(({ id }) => id === itemId);
|
|
95
|
+
return root;
|
|
84
96
|
}
|
|
85
97
|
function findItemDeep(items, itemId) {
|
|
86
98
|
for (const item of items) {
|
|
@@ -103,15 +115,14 @@ function removeItem(items, id) {
|
|
|
103
115
|
return newItems;
|
|
104
116
|
}
|
|
105
117
|
function setProperty(items, id, property, setter) {
|
|
106
|
-
|
|
118
|
+
const next = items.map((item) => {
|
|
107
119
|
var _item$children3;
|
|
108
|
-
if (item.id === id) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return [...items];
|
|
120
|
+
if (item.id === id) return _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 : _objectSpread2(_objectSpread2({}, item), {}, { children });
|
|
124
|
+
});
|
|
125
|
+
return next.some((item, index) => item !== items[index]) ? next : items;
|
|
115
126
|
}
|
|
116
127
|
function countChildren(items, count = 0) {
|
|
117
128
|
return items.reduce((acc, { children }) => {
|
|
@@ -124,15 +135,15 @@ function getChildCount(items, id) {
|
|
|
124
135
|
return item ? countChildren(item.children) : 0;
|
|
125
136
|
}
|
|
126
137
|
function removeChildrenOf(items, ids) {
|
|
127
|
-
const excludeParentIds =
|
|
138
|
+
const excludeParentIds = new Set(ids);
|
|
128
139
|
return items.filter((item) => {
|
|
129
|
-
if (item.parentId && excludeParentIds.
|
|
140
|
+
if (item.parentId !== null && excludeParentIds.has(item.parentId)) {
|
|
130
141
|
var _item$children4;
|
|
131
|
-
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);
|
|
132
143
|
return false;
|
|
133
144
|
}
|
|
134
145
|
return true;
|
|
135
146
|
});
|
|
136
147
|
}
|
|
137
148
|
//#endregion
|
|
138
|
-
export { buildTree, flattenTree, getChildCount, getProjection, iOS, removeChildrenOf, removeItem, setProperty };
|
|
149
|
+
export { buildTree, createNavigationHitTest, flattenTree, getChildCount, getProjection, iOS, removeChildrenOf, removeItem, setProperty };
|
|
@@ -2,12 +2,13 @@ import { getText } from "../../locales/index.js";
|
|
|
2
2
|
import Button from "../button/index.js";
|
|
3
3
|
import SortableItem from "./components/SortableItem/index.js";
|
|
4
4
|
import { SortableTree } from "../pisellDraggable/index.js";
|
|
5
|
-
import React, { useCallback } from "react";
|
|
5
|
+
import React, { useCallback, useRef } from "react";
|
|
6
6
|
import { PlusOutlined } from "@ant-design/icons";
|
|
7
7
|
import classNames from "classnames";
|
|
8
8
|
import "./PisellDropSort.less";
|
|
9
9
|
//#region src/components/pisellDropSort/PisellDropSort.tsx
|
|
10
|
-
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 }) => {
|
|
10
|
+
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 }) => {
|
|
11
|
+
const dropBoundary = useRef(null);
|
|
11
12
|
const renderItem = useCallback((itemProps, ref) => {
|
|
12
13
|
return /* @__PURE__ */ React.createElement(SortableItem, {
|
|
13
14
|
itemProps,
|
|
@@ -31,14 +32,17 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
31
32
|
allowAddChild,
|
|
32
33
|
allowDelete,
|
|
33
34
|
allowDrag,
|
|
34
|
-
|
|
35
|
+
allowIsShow,
|
|
35
36
|
disabled,
|
|
36
37
|
maxLevel,
|
|
37
38
|
onAdd,
|
|
38
39
|
onDelete,
|
|
39
40
|
showBorder,
|
|
40
41
|
spacing,
|
|
41
|
-
isCustomAction
|
|
42
|
+
isCustomAction,
|
|
43
|
+
propsRenderItem,
|
|
44
|
+
getItemStyle,
|
|
45
|
+
__designMode
|
|
42
46
|
]);
|
|
43
47
|
const handleChange = useCallback((items) => {
|
|
44
48
|
onChange === null || onChange === void 0 || onChange(items);
|
|
@@ -53,6 +57,7 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
53
57
|
onClick: () => onAddRoot === null || onAddRoot === void 0 ? void 0 : onAddRoot(),
|
|
54
58
|
size: "large"
|
|
55
59
|
}, getText("pisell-lowcode-drop-sort-add")))), /* @__PURE__ */ React.createElement("div", {
|
|
60
|
+
ref: dropBoundary,
|
|
56
61
|
className: "pisell-lowcode-drop-sort-container-content",
|
|
57
62
|
style: { gap: spacing !== null && spacing !== void 0 ? spacing : 8 }
|
|
58
63
|
}, value.length === 0 && emptyContent ? emptyContent : /* @__PURE__ */ React.createElement(SortableTree, {
|
|
@@ -64,6 +69,8 @@ const PisellDropSort = ({ value = [], allowDrag = true, allowDelete = true, allo
|
|
|
64
69
|
renderItem,
|
|
65
70
|
onChange: handleChange,
|
|
66
71
|
canDrop,
|
|
72
|
+
dropOnPageAsSibling,
|
|
73
|
+
dropBoundary,
|
|
67
74
|
maxLevel
|
|
68
75
|
})));
|
|
69
76
|
};
|
|
@@ -23,25 +23,27 @@ const _excluded = [
|
|
|
23
23
|
"indentationWidth",
|
|
24
24
|
"handleProps",
|
|
25
25
|
"collapsed",
|
|
26
|
-
"isError"
|
|
26
|
+
"isError",
|
|
27
|
+
"dropPosition"
|
|
27
28
|
];
|
|
28
29
|
const SortableItem = (props) => {
|
|
29
30
|
const { itemProps, render, domRef, allowAddChild, allowDelete, allowDrag, allowIsShow, disabled, onAdd, onDelete, showBorder, spacing, maxLevel, __designMode, isCustomAction, getItemStyle } = props;
|
|
30
|
-
const { item, depth, clone, ghost, indicator, disableSelection, disableInteraction, wrapperRef, style, onCollapse, onRemove, childCount, indentationWidth, handleProps, collapsed, isError } = itemProps, otherProps = _objectWithoutProperties(itemProps, _excluded);
|
|
31
|
+
const { item, depth, clone, ghost, indicator, disableSelection, disableInteraction, wrapperRef, style, onCollapse, onRemove, childCount, indentationWidth, handleProps, collapsed, isError, dropPosition } = itemProps, otherProps = _objectWithoutProperties(itemProps, _excluded);
|
|
31
32
|
const mergedStyle = _objectSpread2(_objectSpread2({}, (getItemStyle === null || getItemStyle === void 0 ? void 0 : getItemStyle(itemProps)) || {}), style);
|
|
32
33
|
if (isError) mergedStyle.backgroundColor = "#FECDCA";
|
|
33
34
|
return /* @__PURE__ */ React.createElement("li", _objectSpread2({
|
|
34
|
-
className: classNames("pisell-lowcode-drop-sort-item", clone && "clone", ghost && "ghost", indicator && "indicator", disableSelection && "disableSelection", disableInteraction && "disableInteraction"),
|
|
35
|
+
className: classNames("pisell-lowcode-drop-sort-item", item.isSection && "pisell-lowcode-drop-sort-item-section", clone && "clone", ghost && "ghost", indicator && "indicator", disableSelection && "disableSelection", disableInteraction && "disableInteraction"),
|
|
35
36
|
ref: wrapperRef,
|
|
37
|
+
"data-drop-position": dropPosition,
|
|
36
38
|
style: { "--spacing": `${indentationWidth * depth}px` }
|
|
37
39
|
}, otherProps), /* @__PURE__ */ React.createElement("div", {
|
|
38
40
|
className: classNames("pisell-lowcode-drop-sort-item-tree-item", {
|
|
39
|
-
"pisell-lowcode-drop-sort-item-tree-item-border": showBorder,
|
|
41
|
+
"pisell-lowcode-drop-sort-item-tree-item-border": showBorder && !item.isSection,
|
|
40
42
|
disabled
|
|
41
43
|
}),
|
|
42
44
|
ref: domRef,
|
|
43
45
|
style: mergedStyle
|
|
44
|
-
}, allowDrag && !disabled && /* @__PURE__ */ React.createElement(Button, _objectSpread2({
|
|
46
|
+
}, allowDrag && !disabled && !item.isSection && /* @__PURE__ */ React.createElement(Button, _objectSpread2({
|
|
45
47
|
icon: /* @__PURE__ */ React.createElement(DotsSix, { className: "pisell-lowcode-drop-sort-item-drag-handle-icon" }),
|
|
46
48
|
type: "text",
|
|
47
49
|
className: "pisell-lowcode-drop-sort-item-button"
|
|
@@ -51,6 +53,7 @@ const SortableItem = (props) => {
|
|
|
51
53
|
className: "pisell-lowcode-drop-sort-item-icon"
|
|
52
54
|
}),
|
|
53
55
|
onClick: onCollapse,
|
|
56
|
+
"aria-expanded": !collapsed,
|
|
54
57
|
type: "text",
|
|
55
58
|
className: classNames("Collapse", collapsed && "collapsed", "pisell-lowcode-drop-sort-item-button")
|
|
56
59
|
}), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-drop-sort-item-content" }, render && render(itemProps)), !isCustomAction && /* @__PURE__ */ React.createElement(React.Fragment, null, !clone && allowAddChild && !disabled && /* @__PURE__ */ React.createElement(Button, {
|
|
@@ -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
|
}
|
|
@@ -12,7 +12,10 @@ import { Dropdown } from "antd";
|
|
|
12
12
|
import classNames from "classnames";
|
|
13
13
|
import "./PisellNavigationMenu.less";
|
|
14
14
|
//#region src/components/pisellNavigationMenu/PisellNavigationMenu.tsx
|
|
15
|
-
const
|
|
15
|
+
const MenuRow = React.memo(function MenuRow({ item, clone, render }) {
|
|
16
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, render(item, clone));
|
|
17
|
+
});
|
|
18
|
+
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 }) => {
|
|
16
19
|
const convertToNavigationItems = (items) => {
|
|
17
20
|
return items.map((item) => ({
|
|
18
21
|
id: String(item.id),
|
|
@@ -22,19 +25,10 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
22
25
|
children: item.children ? convertToNavigationItems(item.children) : []
|
|
23
26
|
}));
|
|
24
27
|
};
|
|
25
|
-
useMemo(() => {
|
|
26
|
-
return [{
|
|
27
|
-
label: getText("pisell-lowcode-navigation-menu-add-sub-menu"),
|
|
28
|
-
key: "add-child"
|
|
29
|
-
}, {
|
|
30
|
-
label: getText("pisell-lowcode-navigation-menu-add-page"),
|
|
31
|
-
key: "add-page"
|
|
32
|
-
}];
|
|
33
|
-
}, []);
|
|
34
28
|
const handleClick = useCallback((key, item) => {
|
|
35
29
|
if (key === "add-child") onAddSubMenu === null || onAddSubMenu === void 0 || onAddSubMenu(item);
|
|
36
30
|
else if (key === "add-page") onAddPage === null || onAddPage === void 0 || onAddPage(item);
|
|
37
|
-
}, []);
|
|
31
|
+
}, [onAddSubMenu, onAddPage]);
|
|
38
32
|
const tagTextMap = useMemo(() => {
|
|
39
33
|
return {
|
|
40
34
|
base: {
|
|
@@ -63,9 +57,9 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
63
57
|
}
|
|
64
58
|
};
|
|
65
59
|
}, []);
|
|
66
|
-
const
|
|
60
|
+
const renderRow = useCallback((item, clone) => {
|
|
67
61
|
var _tagTextMap$group, _tagTextMap$group2, _tagTextMap$subMenu, _tagTextMap$subMenu2, _tagTextMap$custom, _tagTextMap$custom2, _tagTextMap$item$sour, _tagTextMap$item$sour2;
|
|
68
|
-
|
|
62
|
+
if (item.isSection) return /* @__PURE__ */ React.createElement("h3", { className: "pisell-lowcode-navigation-menu-section-title" }, item.title);
|
|
69
63
|
const { allowEdit = true, allowDelete = true, allowAddChild = true, allowAddSubmenu = true, allowAddPage = true, allowIsShow = true } = item;
|
|
70
64
|
const isShowAddButton = item.isGroup && allowAddChild && (allowAddSubmenu || allowAddPage);
|
|
71
65
|
return /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-navigation-menu-item" }, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content" }, item.icon && /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content-icon" }, /* @__PURE__ */ React.createElement(icon_default, { type: item.icon })), /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-navigation-menu-item-content-text" }, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-navigation-menu-item-title" }, item.title, showTitleTags && /* @__PURE__ */ React.createElement(React.Fragment, null, item.isGroup && item.is_top && /* @__PURE__ */ React.createElement(PisellTags, {
|
|
@@ -86,15 +80,18 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
86
80
|
}, ((_tagTextMap$item$sour2 = tagTextMap[item.source]) === null || _tagTextMap$item$sour2 === void 0 ? void 0 : _tagTextMap$item$sour2.text) || ""), !item.isGroup && item.version && /* @__PURE__ */ React.createElement(PisellTags, {
|
|
87
81
|
type: "pill_color",
|
|
88
82
|
color: "success"
|
|
89
|
-
}, "v", item.version)))), /* @__PURE__ */ React.createElement("div", { className: classNames("pisell-lowcode-navigation-menu-item-action-wrap", { "pisell-lowcode-navigation-menu-item-action-wrap-hover": showActionOnHover }) }, allowIsShow && /* @__PURE__ */ React.createElement(Button$1, {
|
|
83
|
+
}, "v", item.version)))), /* @__PURE__ */ React.createElement("div", { className: classNames("pisell-lowcode-navigation-menu-item-action-wrap", { "pisell-lowcode-navigation-menu-item-action-wrap-hover": showActionOnHover }) }, (allowIsShow || item.disableIsShow) && /* @__PURE__ */ React.createElement(Button$1, {
|
|
90
84
|
type: "text",
|
|
85
|
+
disabled: item.disableIsShow,
|
|
86
|
+
"aria-label": item.visibilityLabel,
|
|
87
|
+
title: item.visibilityLabel,
|
|
91
88
|
onClick: () => onIsShow === null || onIsShow === void 0 ? void 0 : onIsShow(item),
|
|
92
89
|
className: "pisell-lowcode-navigation-menu-item-action-button",
|
|
93
90
|
icon: /* @__PURE__ */ React.createElement(icon_default, {
|
|
94
91
|
type: item.is_show === false ? "pisell2-eye-off" : "pisell2-eye",
|
|
95
92
|
className: "pisell-lowcode-navigation-menu-item-action-button-icon"
|
|
96
93
|
})
|
|
97
|
-
}), allowEdit && /* @__PURE__ */ React.createElement(Button$1, {
|
|
94
|
+
}), !clone && (renderItemActions === null || renderItemActions === void 0 ? void 0 : renderItemActions(item)), allowEdit && /* @__PURE__ */ React.createElement(Button$1, {
|
|
98
95
|
type: "text",
|
|
99
96
|
onClick: () => onEdit === null || onEdit === void 0 ? void 0 : onEdit(item),
|
|
100
97
|
className: "pisell-lowcode-navigation-menu-item-action-button",
|
|
@@ -129,7 +126,22 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
129
126
|
className: "pisell-lowcode-navigation-menu-item-action-button-icon"
|
|
130
127
|
})
|
|
131
128
|
})));
|
|
132
|
-
}, [
|
|
129
|
+
}, [
|
|
130
|
+
handleClick,
|
|
131
|
+
hideDescription,
|
|
132
|
+
onDelete,
|
|
133
|
+
onEdit,
|
|
134
|
+
onIsShow,
|
|
135
|
+
renderItemActions,
|
|
136
|
+
showActionOnHover,
|
|
137
|
+
showTitleTags,
|
|
138
|
+
tagTextMap
|
|
139
|
+
]);
|
|
140
|
+
const renderMenuItem = useCallback(({ item, clone }) => /* @__PURE__ */ React.createElement(MenuRow, {
|
|
141
|
+
item,
|
|
142
|
+
clone: Boolean(clone),
|
|
143
|
+
render: renderRow
|
|
144
|
+
}), [renderRow]);
|
|
133
145
|
const handleChange = useCallback((items) => {
|
|
134
146
|
onChange === null || onChange === void 0 || onChange(convertToNavigationItems(items));
|
|
135
147
|
}, [onChange]);
|
|
@@ -148,10 +160,20 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
148
160
|
icon: /* @__PURE__ */ React.createElement(icon_default, { type: "pisell2-plus" }),
|
|
149
161
|
onClick: () => onAddPage === null || onAddPage === void 0 ? void 0 : onAddPage()
|
|
150
162
|
}, getText("pisell-lowcode-navigation-menu-add-page")));
|
|
151
|
-
}, [
|
|
163
|
+
}, [
|
|
164
|
+
propsRightContent,
|
|
165
|
+
onAddPage,
|
|
166
|
+
onAddSubMenu
|
|
167
|
+
]);
|
|
152
168
|
const formatValue = useMemo(() => {
|
|
153
|
-
return formatTree(
|
|
154
|
-
|
|
169
|
+
return formatTree((sections === null || sections === void 0 ? void 0 : sections.length) ? sections.map(({ id, title, items }) => ({
|
|
170
|
+
id,
|
|
171
|
+
title,
|
|
172
|
+
isSection: true,
|
|
173
|
+
isGroup: true,
|
|
174
|
+
children: items
|
|
175
|
+
})) : value, (item) => _objectSpread2(_objectSpread2({}, item), {}, { disabledDrop: !item.isGroup }));
|
|
176
|
+
}, [sections, value]);
|
|
155
177
|
const getItemStyle = useCallback((itemProps) => {
|
|
156
178
|
const { item } = itemProps;
|
|
157
179
|
if (isFunction(propsGetItemStyle)) return (propsGetItemStyle === null || propsGetItemStyle === void 0 ? void 0 : propsGetItemStyle(item)) || {};
|
|
@@ -167,7 +189,7 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
167
189
|
allowIsShow,
|
|
168
190
|
disabled,
|
|
169
191
|
spacing,
|
|
170
|
-
maxLevel,
|
|
192
|
+
maxLevel: maxLevel + Number(Boolean(sections === null || sections === void 0 ? void 0 : sections.length)),
|
|
171
193
|
style,
|
|
172
194
|
className,
|
|
173
195
|
onChange: handleChange,
|
|
@@ -181,7 +203,8 @@ const PisellNavigationMenu = ({ value = [], allowDrag = true, allowDelete = true
|
|
|
181
203
|
maxWidth: 400,
|
|
182
204
|
description: getText("pisell-lowcode-navigation-menu-add-page-tip")
|
|
183
205
|
}),
|
|
184
|
-
canDrop
|
|
206
|
+
canDrop,
|
|
207
|
+
dropOnPageAsSibling: dropOnPageAsSibling || Boolean(sections === null || sections === void 0 ? void 0 : sections.length)
|
|
185
208
|
});
|
|
186
209
|
};
|
|
187
210
|
//#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 };
|
|
@@ -71,6 +71,7 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
71
71
|
const lineTotal = Number((_dataSource$total = dataSource === null || dataSource === void 0 ? void 0 : dataSource.total) !== null && _dataSource$total !== void 0 ? _dataSource$total : 0) * quantity - Number((dataSource === null || dataSource === void 0 ? void 0 : dataSource.totalDifference) || 0);
|
|
72
72
|
const originalTotal = Number((_dataSource$origin_to = dataSource === null || dataSource === void 0 ? void 0 : dataSource.origin_total) !== null && _dataSource$origin_to !== void 0 ? _dataSource$origin_to : 0) * quantity;
|
|
73
73
|
const symbol = dataSource === null || dataSource === void 0 ? void 0 : dataSource.symbol;
|
|
74
|
+
const amountFormatter = typeof (dataSource === null || dataSource === void 0 ? void 0 : dataSource.amountFormatter) === "function" ? dataSource.amountFormatter : void 0;
|
|
74
75
|
const slotContext = useMemo(() => ({
|
|
75
76
|
item: dataSource,
|
|
76
77
|
disabled
|
|
@@ -83,7 +84,8 @@ const A12 = ({ dataSource, isShowImage = true, isShowDelete = false, isShowOrigi
|
|
|
83
84
|
const specifications = (slots === null || slots === void 0 ? void 0 : slots.specifications) ? slots.specifications(_objectSpread2(_objectSpread2({}, slotContext), {}, { defaultSpecifications })) : defaultSpecifications;
|
|
84
85
|
const contentFooter = slots === null || slots === void 0 || (_slots$contentFooter = slots.contentFooter) === null || _slots$contentFooter === void 0 ? void 0 : _slots$contentFooter.call(slots, slotContext);
|
|
85
86
|
const status = slots === null || slots === void 0 || (_slots$status = slots.status) === null || _slots$status === void 0 ? void 0 : _slots$status.call(slots, slotContext);
|
|
86
|
-
const
|
|
87
|
+
const renderAmount = (value) => amountFormatter ? amountFormatter(value, 2) : formatAmount(value, 2, symbol);
|
|
88
|
+
const defaultPrice = /* @__PURE__ */ React.createElement("div", { className: classNames(`${PREFIX}-a12__price`, { [`${PREFIX}-a12__price--formatted`]: Boolean(amountFormatter) }) }, /* @__PURE__ */ React.createElement("strong", null, renderAmount(lineTotal)), isShowOriginalPrice && originalTotal > 0 && originalTotal !== lineTotal ? /* @__PURE__ */ React.createElement("del", null, renderAmount(originalTotal)) : null);
|
|
87
89
|
const defaultEdit = Boolean(isShowEditProduct && onEditProduct) ? /* @__PURE__ */ React.createElement("button", {
|
|
88
90
|
type: "button",
|
|
89
91
|
className: `${PREFIX}-a12__edit`,
|