plain-design 1.0.0-beta.13 → 1.0.0-beta.15
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/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.css +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/Application/theme/theme.ts +0 -2
- package/src/packages/components/DropdownOption/index.tsx +3 -3
- package/src/packages/components/TabGroup/TabsInner.tsx +3 -2
- package/src/packages/components/TabGroup/index.tsx +1 -3
- package/src/packages/components/Tree/RenderTreeNode.tsx +1 -0
- package/src/packages/components/TreeCore/createTreeDraggier.tsx +61 -51
- package/src/packages/components/TreeNodeWithMenu/index.tsx +44 -6
- package/src/packages/components/TreeNodeWithMenu/tree-node-with-menu.scss +1 -0
- package/src/packages/components/TreeNodeWithMenu/treeNodeWithMenu.utils.ts +12 -0
- package/src/packages/components/useMessage/Message.tsx +5 -1
- package/src/packages/components/useMessage/message.scss +4 -0
- package/src/packages/entry.tsx +5 -0
- package/src/pages/index/components/normal/DemoTree.tsx +16 -1
package/package.json
CHANGED
@@ -128,9 +128,7 @@ function createOtherVars(prefix: string | null, referenceVariable: (name: string
|
|
128
128
|
'dialog-foot-padding': '8px 16px',
|
129
129
|
'dialog-head-size': '48px',
|
130
130
|
/*---------------------------------------message-------------------------------------------*/
|
131
|
-
'message-padding': '12px 20px',
|
132
131
|
'message-box-shadow': '0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05)',
|
133
|
-
'message-font-size': referenceVariable('font-size-normal'),
|
134
132
|
/*---------------------------------------notice-------------------------------------------*/
|
135
133
|
'notice-padding': '20px 24px',
|
136
134
|
'notice-box-shadow': '0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05)',
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {computed, designComponent, PropType} from "plain-design-composition";
|
1
|
+
import {computed, designComponent, iMouseEvent, PropType} from "plain-design-composition";
|
2
2
|
import {DropdownContextProvider, DropdownOptionContextProvider, DropdownOptionTrigger, iDropdownOptionContext, renderDropdownOption} from "../Dropdown/dropdown.utils";
|
3
3
|
import Icon from "../Icon";
|
4
4
|
import {createCounter} from "plain-utils/utils/createCounter";
|
@@ -18,7 +18,7 @@ export const DropdownOption = designComponent({
|
|
18
18
|
},
|
19
19
|
slots: ['default', 'content'],
|
20
20
|
emits: {
|
21
|
-
onClick: (e:
|
21
|
+
onClick: (e: iMouseEvent) => true,
|
22
22
|
},
|
23
23
|
setup({ props, event: { emit }, slots }) {
|
24
24
|
|
@@ -38,7 +38,7 @@ export const DropdownOption = designComponent({
|
|
38
38
|
};
|
39
39
|
|
40
40
|
const handler = {
|
41
|
-
onClick: (e:
|
41
|
+
onClick: (e: iMouseEvent) => {
|
42
42
|
if (props.disabled || props.readonly) {return;}
|
43
43
|
emit.onClick(e);
|
44
44
|
dropdown.handler.onClickOption(dropdownOptionContext);
|
@@ -1,10 +1,11 @@
|
|
1
|
-
import {designComponent, mergeAttrs, nextTick, PropType, reactive, useStyles, watch} from "plain-design-composition";
|
1
|
+
import {designComponent, mergeAttrs, nextTick, PropType, reactive, RenderNode, useStyles, watch} from "plain-design-composition";
|
2
2
|
import {PlTabComponent} from "../Tab";
|
3
3
|
|
4
4
|
export const TabsInner = designComponent({
|
5
5
|
props: {
|
6
6
|
item: { type: Object as PropType<PlTabComponent>, required: true },
|
7
7
|
active: { type: Boolean },
|
8
|
+
render: { type: Function as PropType<() => RenderNode>, required: true }
|
8
9
|
},
|
9
10
|
slots: ['default'],
|
10
11
|
setup({ props, slots }) {
|
@@ -51,7 +52,7 @@ export const TabsInner = designComponent({
|
|
51
52
|
{ class: 'inner-tab', style: styles.value },
|
52
53
|
props.item.attrs
|
53
54
|
)}>
|
54
|
-
{!!state.init &&
|
55
|
+
{!!state.init && props.render()}
|
55
56
|
</div>
|
56
57
|
)
|
57
58
|
};
|
@@ -101,9 +101,7 @@ export const TabGroup = designComponent({
|
|
101
101
|
const body = (
|
102
102
|
<div className="tabs-body">
|
103
103
|
{[...tabs.value].sort((a, b) => String(a.val).localeCompare(String(b.val))).map((tab, index) => (
|
104
|
-
<TabsInner item={tab.item} key={index} active={tab.active}
|
105
|
-
{tab.item.slots.default()}
|
106
|
-
</TabsInner>
|
104
|
+
<TabsInner item={tab.item} key={index} active={tab.active} render={() => tab.item.slots.default()}/>
|
107
105
|
))}
|
108
106
|
</div>
|
109
107
|
);
|
@@ -90,6 +90,7 @@ export const RenderTreeNode = designComponent({
|
|
90
90
|
*/
|
91
91
|
onClickNodeContent: () => {
|
92
92
|
if (props.treeNode.empty) {return;}
|
93
|
+
if (tree.draggier.value?.isDragging()) {return;}
|
93
94
|
tree.hooks.onClickNodeContent.exec({ treeNode: props.treeNode, el: refs.el! });
|
94
95
|
},
|
95
96
|
/**
|
@@ -15,6 +15,7 @@ import {onParentElementsScroll} from "../../utils/onParentElementsScroll";
|
|
15
15
|
import {addClass} from "plain-utils/dom/addClass";
|
16
16
|
import {iTreeHooks} from "./createTreeHooks";
|
17
17
|
import {ClientZoom} from "../ClientZoom";
|
18
|
+
import {delay} from "plain-utils/utils/delay";
|
18
19
|
|
19
20
|
export function createTreeDraggier(
|
20
21
|
{
|
@@ -109,6 +110,8 @@ export function createTreeDraggier(
|
|
109
110
|
*/
|
110
111
|
const shadowTreeNode = (() => {
|
111
112
|
|
113
|
+
const reactiveState = reactive({ dragging: false, });
|
114
|
+
|
112
115
|
let staticState = null as null | {
|
113
116
|
startNode: iTreeNode, // 拖拽开始的时候节点
|
114
117
|
rowElement: HTMLElement, // 拖拽开始的row对象
|
@@ -233,62 +236,68 @@ export function createTreeDraggier(
|
|
233
236
|
},
|
234
237
|
data: null,
|
235
238
|
};
|
239
|
+
reactiveState.dragging = true;
|
236
240
|
/**
|
237
241
|
* 拖拽结束之后,处理拖拽数据
|
238
242
|
* @author 韦胜健
|
239
243
|
* @date 2023/6/1 21:13
|
240
244
|
*/
|
241
245
|
draggierEffects.push(async () => {
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
246
|
+
await (async () => {
|
247
|
+
if (!!staticState?.data) {
|
248
|
+
const { startNode, } = staticState;
|
249
|
+
const { moveNode, dropType, droppable, isHideDraggier } = staticState.data.move;
|
250
|
+
if (!droppable || isHideDraggier) {
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
const newParentNode = moveNode.parent;
|
254
|
+
const oldParentNode = startNode.parent;
|
255
|
+
const newSiblings = dropType === eTreeDropType.inner ? methods.getReactiveChildrenData(moveNode) : methods.getParentChildrenData(moveNode);
|
256
|
+
const newSiblingsBak = [...newSiblings];
|
257
|
+
const oldSiblings = methods.getParentChildrenData(startNode);
|
258
|
+
const oldSiblingsBak = [...oldSiblings];
|
259
|
+
|
260
|
+
methods.removeSelf(startNode!);
|
261
|
+
switch (dropType) {
|
262
|
+
case eTreeDropType.prev:
|
263
|
+
methods.previousSibling(moveNode!, startNode!);
|
264
|
+
break;
|
265
|
+
case eTreeDropType.inner:
|
266
|
+
methods.unshiftChild(moveNode!, startNode!);
|
267
|
+
await methods.expand(moveNode!);
|
268
|
+
break;
|
269
|
+
case eTreeDropType.next:
|
270
|
+
methods.nextSibling(moveNode!, startNode!);
|
271
|
+
await methods.collapse(moveNode);
|
272
|
+
break;
|
273
|
+
}
|
274
|
+
await nextTick();
|
275
|
+
await Promise.all([
|
276
|
+
methods.refreshCheckStatus(startNode!.parent),
|
277
|
+
methods.refreshCheckStatus(moveNode!.parent)
|
278
|
+
]);
|
279
|
+
await hooks.onDragChange.exec({
|
280
|
+
data: startNode.data,
|
281
|
+
newParent: newParentNode?.data,
|
282
|
+
oldParent: oldParentNode?.data,
|
283
|
+
node: startNode,
|
284
|
+
newParentNode,
|
285
|
+
oldParentNode,
|
286
|
+
newSiblings,
|
287
|
+
oldSiblings,
|
288
|
+
newSiblingsBak,
|
289
|
+
oldSiblingsBak,
|
290
|
+
undo: () => {
|
291
|
+
newSiblings.splice(0, newSiblings.length, ...newSiblingsBak);
|
292
|
+
oldSiblings.splice(0, oldSiblings.length, ...oldSiblingsBak);
|
293
|
+
},
|
294
|
+
});
|
268
295
|
}
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
await hooks.onDragChange.exec({
|
275
|
-
data: startNode.data,
|
276
|
-
newParent: newParentNode?.data,
|
277
|
-
oldParent: oldParentNode?.data,
|
278
|
-
node: startNode,
|
279
|
-
newParentNode,
|
280
|
-
oldParentNode,
|
281
|
-
newSiblings,
|
282
|
-
oldSiblings,
|
283
|
-
newSiblingsBak,
|
284
|
-
oldSiblingsBak,
|
285
|
-
undo: () => {
|
286
|
-
newSiblings.splice(0, newSiblings.length, ...newSiblingsBak);
|
287
|
-
oldSiblings.splice(0, oldSiblings.length, ...oldSiblingsBak);
|
288
|
-
},
|
289
|
-
});
|
290
|
-
}
|
291
|
-
staticState = null;
|
296
|
+
})();
|
297
|
+
delay().then(() => {
|
298
|
+
staticState = null;
|
299
|
+
reactiveState.dragging = false;
|
300
|
+
});
|
292
301
|
});
|
293
302
|
};
|
294
303
|
|
@@ -370,7 +379,7 @@ export function createTreeDraggier(
|
|
370
379
|
indicatorHandler.update();
|
371
380
|
};
|
372
381
|
|
373
|
-
const isDragging = () =>
|
382
|
+
const isDragging = () => reactiveState.dragging;
|
374
383
|
|
375
384
|
const getState = () => staticState;
|
376
385
|
|
@@ -388,7 +397,8 @@ export function createTreeDraggier(
|
|
388
397
|
document.removeEventListener('mouseup', draggierEffects.clear);
|
389
398
|
});
|
390
399
|
},
|
391
|
-
onMousemoveRow: null as null | ((e: iMouseEvent, node: iTreeNode) => void)
|
400
|
+
onMousemoveRow: null as null | ((e: iMouseEvent, node: iTreeNode) => void),
|
401
|
+
isDragging: () => shadowTreeNode.isDragging(),
|
392
402
|
});
|
393
403
|
|
394
404
|
return ret;
|
@@ -1,14 +1,19 @@
|
|
1
|
-
import {cacheComputed, computed, designComponent, getComponentCls, iHTMLDivElement, iMouseEvent, PropType, useClassCache, useRefs} from "plain-design-composition";
|
2
|
-
import Icon from "../Icon";
|
1
|
+
import {cacheComputed, ComponentPropsType, computed, designComponent, getComponentCls, iHTMLDivElement, iMouseEvent, PropType, useClassCache, useRefs} from "plain-design-composition";
|
2
|
+
import {Icon} from "../Icon";
|
3
3
|
import {iTreeNode} from "../TreeCore/createTreeNode";
|
4
4
|
import './tree-node-with-menu.scss';
|
5
|
-
import Tree from "../Tree";
|
5
|
+
import {Tree} from "../Tree";
|
6
6
|
import {useTooltip} from "../useTooltip";
|
7
|
+
import {iTreeNodeWithMenuOption} from "./treeNodeWithMenu.utils";
|
8
|
+
import {Dropdown} from "../Dropdown";
|
9
|
+
import {DropdownOption} from "../DropdownOption";
|
7
10
|
|
8
11
|
export const TreeNodeWithMenu = designComponent({
|
9
12
|
name: 'tree-node-with-menu',
|
10
13
|
props: {
|
11
14
|
treeNode: { type: Object as PropType<iTreeNode>, required: true },
|
15
|
+
dropdownOptions: { type: Array as PropType<iTreeNodeWithMenuOption[]> },
|
16
|
+
dropdownAttrs: { type: Object as PropType<ComponentPropsType<typeof Dropdown>> },
|
12
17
|
},
|
13
18
|
setup({ props }) {
|
14
19
|
|
@@ -25,6 +30,14 @@ export const TreeNodeWithMenu = designComponent({
|
|
25
30
|
}
|
26
31
|
]);
|
27
32
|
|
33
|
+
const dropdownAttrs = computed(() => {
|
34
|
+
return {
|
35
|
+
trigger: 'hover' as const,
|
36
|
+
placement: 'right-start' as const,
|
37
|
+
...props.dropdownAttrs,
|
38
|
+
};
|
39
|
+
});
|
40
|
+
|
28
41
|
const handler = {
|
29
42
|
onMousedownDraggier: computed(() => !tree.draggier.value ? undefined : ((e: iMouseEvent) => {
|
30
43
|
tree.draggier.value!.onMousedownDraggier(e, props.treeNode);
|
@@ -42,9 +55,34 @@ export const TreeNodeWithMenu = designComponent({
|
|
42
55
|
return () => (
|
43
56
|
<div className={classes.value}>
|
44
57
|
<div className="tree-node-with-menu-content" ref={onRef.content}>{props.treeNode.label()}</div>
|
45
|
-
|
46
|
-
|
47
|
-
|
58
|
+
{(() => {
|
59
|
+
let btn = (
|
60
|
+
<div className="tree-node-with-menu-button" onMouseDown={handler.onMousedownDraggier.value}>
|
61
|
+
<Icon icon="pi-drag-dot-vertical"/>
|
62
|
+
</div>
|
63
|
+
);
|
64
|
+
let ret = btn;
|
65
|
+
if (!!props.dropdownOptions?.length && !tree.draggier.value?.isDragging()) {
|
66
|
+
ret = (
|
67
|
+
<Dropdown
|
68
|
+
{...dropdownAttrs.value}
|
69
|
+
v-slots={{
|
70
|
+
default: () => btn,
|
71
|
+
popper: () => (
|
72
|
+
props.dropdownOptions!.map((option, index) => {
|
73
|
+
const { renderDefault, renderContent, ...leftOption } = option;
|
74
|
+
const vSlots = {} as any;
|
75
|
+
if (!!renderDefault) {vSlots.default = () => renderDefault();}
|
76
|
+
if (!!renderContent) {vSlots.content = () => renderContent();}
|
77
|
+
return <DropdownOption key={index} {...leftOption} v-slots={vSlots}/>;
|
78
|
+
})
|
79
|
+
)
|
80
|
+
}}
|
81
|
+
/>
|
82
|
+
);
|
83
|
+
}
|
84
|
+
return ret;
|
85
|
+
})()}
|
48
86
|
</div>
|
49
87
|
);
|
50
88
|
},
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import {iMouseEvent, RenderNode} from "plain-design-composition";
|
2
|
+
|
3
|
+
export interface iTreeNodeWithMenuOption {
|
4
|
+
label?: string,
|
5
|
+
disabled?: boolean,
|
6
|
+
readonly?: boolean,
|
7
|
+
icon?: string,
|
8
|
+
val?: any,
|
9
|
+
onClick?: (e: iMouseEvent) => void
|
10
|
+
renderDefault?: () => RenderNode,
|
11
|
+
renderContent?: () => RenderNode,
|
12
|
+
}
|
@@ -2,6 +2,7 @@ import {designComponent, getComponentCls, iMouseEvent, nextIndex, onMounted, Pro
|
|
2
2
|
import {closeMessageServiceHook, iMessageServiceOption} from "./message.service.utils";
|
3
3
|
import Icon from "../Icon";
|
4
4
|
import './message.scss';
|
5
|
+
import {useStyle} from "../../uses/useStyle";
|
5
6
|
|
6
7
|
export const Message = designComponent({
|
7
8
|
name: 'message-service',
|
@@ -16,9 +17,12 @@ export const Message = designComponent({
|
|
16
17
|
|
17
18
|
onMounted(() => emit.onReady());
|
18
19
|
|
20
|
+
const { styleComputed } = useStyle();
|
21
|
+
|
19
22
|
const classes = useClasses(() => [
|
20
23
|
getComponentCls('message'),
|
21
|
-
`message-status-${props.option.status}
|
24
|
+
`message-status-${props.option.status}`,
|
25
|
+
`message-size-${styleComputed.value.size}`
|
22
26
|
]);
|
23
27
|
const styles = { zIndex: nextIndex() };
|
24
28
|
|
package/src/packages/entry.tsx
CHANGED
@@ -148,6 +148,11 @@ export type {iOvMeta} from './components/$ov/ov.utils';
|
|
148
148
|
export {$configuration} from './components/$configuration';
|
149
149
|
export {createAddressService} from './components/createAddressService';
|
150
150
|
export {createHttp} from './components/createHttp';
|
151
|
+
export type {
|
152
|
+
iHttpRequestConfig,
|
153
|
+
iPlainResponseDataType,
|
154
|
+
iHttpResponseDataType
|
155
|
+
} from './components/createHttp/http.utils';
|
151
156
|
|
152
157
|
export {Address} from './components/Address';
|
153
158
|
export {AddressCascade} from './components/AddressCascade';
|
@@ -8,6 +8,7 @@ import {deepcopy} from 'plain-utils/object/deepcopy';
|
|
8
8
|
import {iTreeProps} from "../../../../packages/components/TreeCore/TreeCore.type";
|
9
9
|
import {iTreeDragChangeData} from "../../../../packages/components/TreeCore/createTreeProps";
|
10
10
|
import {delay} from "plain-utils/utils/delay";
|
11
|
+
import {iTreeNodeWithMenuOption} from "../../../../packages/components/TreeNodeWithMenu/treeNodeWithMenu.utils";
|
11
12
|
|
12
13
|
export const demo1 = designPage(() => {
|
13
14
|
|
@@ -1115,6 +1116,20 @@ export const demoCustomDraggier = designPage(() => {
|
|
1115
1116
|
}
|
1116
1117
|
};
|
1117
1118
|
|
1119
|
+
const getNodeOptions = (treeNode: iTreeNode): iTreeNodeWithMenuOption[] | undefined => {
|
1120
|
+
if (treeNode.level === 0) {
|
1121
|
+
return [
|
1122
|
+
{ label: '新建菜单', onClick: () => {$message(`${treeNode.label()} -> 新建菜单`);} },
|
1123
|
+
{ label: '新建菜单分组', onClick: () => {$message(`${treeNode.label()} -> 新建菜单分组`);} },
|
1124
|
+
];
|
1125
|
+
}
|
1126
|
+
if (treeNode.level === 1) {
|
1127
|
+
return [
|
1128
|
+
{ label: '新建菜单', onClick: () => {$message(`${treeNode.label()} -> 新建菜单`);} },
|
1129
|
+
];
|
1130
|
+
}
|
1131
|
+
};
|
1132
|
+
|
1118
1133
|
return () => (
|
1119
1134
|
<DemoRow title="自定义拖拽节点">
|
1120
1135
|
<ButtonGroup style={{ margin: '4px 0' }}>
|
@@ -1151,7 +1166,7 @@ export const demoCustomDraggier = designPage(() => {
|
|
1151
1166
|
expandOnClickNode
|
1152
1167
|
v-slots={{
|
1153
1168
|
default: ({ treeNode }: { treeNode: iTreeNode }) => (
|
1154
|
-
<TreeNodeWithMenu treeNode={treeNode}/>
|
1169
|
+
<TreeNodeWithMenu treeNode={treeNode} dropdownOptions={getNodeOptions(treeNode)}/>
|
1155
1170
|
)
|
1156
1171
|
}}
|
1157
1172
|
/>
|