naive-ui 2.21.0 → 2.21.1
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/es/data-table/src/TableParts/Body.js +20 -20
- package/es/dropdown/src/DropdownGroupHeader.js +3 -3
- package/es/dropdown/src/DropdownOption.js +6 -5
- package/es/dropdown/src/utils.d.ts +0 -1
- package/es/dropdown/src/utils.js +0 -10
- package/es/image/src/ImagePreview.d.ts +1 -0
- package/es/image/src/ImagePreview.js +51 -4
- package/es/image/src/interface.d.ts +6 -0
- package/es/image/src/interface.js +1 -0
- package/es/modal/src/Modal.d.ts +1 -1
- package/es/version.d.ts +1 -1
- package/es/version.js +1 -1
- package/lib/data-table/src/TableParts/Body.js +20 -20
- package/lib/dropdown/src/DropdownGroupHeader.js +3 -3
- package/lib/dropdown/src/DropdownOption.js +5 -4
- package/lib/dropdown/src/utils.d.ts +0 -1
- package/lib/dropdown/src/utils.js +1 -12
- package/lib/image/src/ImagePreview.d.ts +1 -0
- package/lib/image/src/ImagePreview.js +51 -4
- package/lib/image/src/interface.d.ts +6 -0
- package/lib/image/src/interface.js +2 -0
- package/lib/modal/src/Modal.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
- package/web-types.json +1 -1
|
@@ -35,7 +35,7 @@ function flatten(rowInfos, expandedRowKeys) {
|
|
|
35
35
|
rowInfos.forEach((rowInfo) => {
|
|
36
36
|
fRows.push(rowInfo);
|
|
37
37
|
const { children } = rowInfo.tmNode;
|
|
38
|
-
if (children) {
|
|
38
|
+
if (children && expandedRowKeys.has(rowInfo.key)) {
|
|
39
39
|
traverse(children);
|
|
40
40
|
}
|
|
41
41
|
});
|
|
@@ -255,10 +255,6 @@ export default defineComponent({
|
|
|
255
255
|
const cordKey = {};
|
|
256
256
|
const { cols, paginatedData, mergedTheme, fixedColumnLeftMap, fixedColumnRightMap, currentPage, rowClassName, mergedSortState, mergedExpandedRowKeySet, componentId, showHeader, hasChildren, firstContentfulColIndex, rowProps, handleMouseenterTable, handleMouseleaveTable, renderExpand, summary, handleCheckboxUpdateChecked, handleUpdateExpanded } = this;
|
|
257
257
|
const { length: colCount } = cols;
|
|
258
|
-
const rowIndexToKey = {};
|
|
259
|
-
paginatedData.forEach(({ tmNode }, rowIndex) => {
|
|
260
|
-
rowIndexToKey[rowIndex] = tmNode.key;
|
|
261
|
-
});
|
|
262
258
|
let mergedData;
|
|
263
259
|
// if there is children in data, we should expand mergedData first
|
|
264
260
|
const mergedPaginationData = hasChildren
|
|
@@ -299,7 +295,25 @@ export default defineComponent({
|
|
|
299
295
|
const indentStyle = hasChildren
|
|
300
296
|
? { width: pxfy(this.indent) }
|
|
301
297
|
: undefined;
|
|
302
|
-
|
|
298
|
+
// Tile the data of the expanded row
|
|
299
|
+
const displayedData = [];
|
|
300
|
+
mergedData.forEach((rowInfo) => {
|
|
301
|
+
if (renderExpand && mergedExpandedRowKeySet.has(rowInfo.key)) {
|
|
302
|
+
displayedData.push(rowInfo, {
|
|
303
|
+
isExpandedRow: true,
|
|
304
|
+
key: rowInfo.key,
|
|
305
|
+
tmNode: rowInfo.tmNode
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
displayedData.push(rowInfo);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
const { length: rowCount } = displayedData;
|
|
313
|
+
const rowIndexToKey = {};
|
|
314
|
+
paginatedData.forEach(({ tmNode }, rowIndex) => {
|
|
315
|
+
rowIndexToKey[rowIndex] = tmNode.key;
|
|
316
|
+
});
|
|
303
317
|
const renderRow = (rowInfo, rowIndex, isVirtual) => {
|
|
304
318
|
if ('isExpandedRow' in rowInfo) {
|
|
305
319
|
const { tmNode: { key, rawNode } } = rowInfo;
|
|
@@ -417,20 +431,6 @@ export default defineComponent({
|
|
|
417
431
|
})));
|
|
418
432
|
return row;
|
|
419
433
|
};
|
|
420
|
-
// Tile the data of the expanded row
|
|
421
|
-
const displayedData = [];
|
|
422
|
-
mergedData.forEach((rowInfo) => {
|
|
423
|
-
if (renderExpand && mergedExpandedRowKeySet.has(rowInfo.key)) {
|
|
424
|
-
displayedData.push(rowInfo, {
|
|
425
|
-
isExpandedRow: true,
|
|
426
|
-
key: rowInfo.key,
|
|
427
|
-
tmNode: rowInfo.tmNode
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
displayedData.push(rowInfo);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
434
|
if (!virtualScroll) {
|
|
435
435
|
return (h("table", { class: `${mergedClsPrefix}-data-table-table`, onMouseleave: handleMouseleaveTable, onMouseenter: handleMouseenterTable, style: {
|
|
436
436
|
tableLayout: this.mergedTableLayout
|
|
@@ -33,17 +33,17 @@ export default defineComponent({
|
|
|
33
33
|
const { rawNode } = this.tmNode;
|
|
34
34
|
return (h("div", { class: `${clsPrefix}-dropdown-option` },
|
|
35
35
|
h("div", { class: `${clsPrefix}-dropdown-option-body ${clsPrefix}-dropdown-option-body--group` },
|
|
36
|
-
h("div", { "
|
|
36
|
+
h("div", { "data-dropdown-option": true, class: [
|
|
37
37
|
`${clsPrefix}-dropdown-option-body__prefix`,
|
|
38
38
|
showIcon && `${clsPrefix}-dropdown-option-body__prefix--show-icon`
|
|
39
39
|
] }, render(rawNode.icon)),
|
|
40
|
-
h("div", { class: `${clsPrefix}-dropdown-option-body__label`, "
|
|
40
|
+
h("div", { class: `${clsPrefix}-dropdown-option-body__label`, "data-dropdown-option": true }, renderLabel
|
|
41
41
|
? renderLabel(rawNode)
|
|
42
42
|
: render((_a = rawNode.title) !== null && _a !== void 0 ? _a : rawNode[this.labelField])),
|
|
43
43
|
h("div", { class: [
|
|
44
44
|
`${clsPrefix}-dropdown-option-body__suffix`,
|
|
45
45
|
hasSubmenu &&
|
|
46
46
|
`${clsPrefix}-dropdown-option-body__suffix--has-submenu`
|
|
47
|
-
], "
|
|
47
|
+
], "data-dropdown-option": true }))));
|
|
48
48
|
}
|
|
49
49
|
});
|
|
@@ -6,7 +6,8 @@ import { render, useDeferredTrue } from '../../_utils';
|
|
|
6
6
|
import { NIcon } from '../../icon';
|
|
7
7
|
import NDropdownMenu, { dropdownMenuInjectionKey } from './DropdownMenu';
|
|
8
8
|
import { dropdownInjectionKey } from './Dropdown';
|
|
9
|
-
import {
|
|
9
|
+
import { isSubmenuNode } from './utils';
|
|
10
|
+
import { happensIn } from 'seemly';
|
|
10
11
|
const dropdownOptionInjectionKey = Symbol('dropdown-option');
|
|
11
12
|
export default defineComponent({
|
|
12
13
|
name: 'DropdownOption',
|
|
@@ -104,7 +105,7 @@ export default defineComponent({
|
|
|
104
105
|
return;
|
|
105
106
|
const { relatedTarget } = e;
|
|
106
107
|
if (relatedTarget &&
|
|
107
|
-
!
|
|
108
|
+
!happensIn({ target: relatedTarget }, 'dropdownOption')) {
|
|
108
109
|
hoverKeyRef.value = null;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -179,15 +180,15 @@ export default defineComponent({
|
|
|
179
180
|
};
|
|
180
181
|
return (h("div", { class: `${clsPrefix}-dropdown-option` },
|
|
181
182
|
h('div', mergeProps(builtinProps, props), [
|
|
182
|
-
h("div", { "
|
|
183
|
+
h("div", { "data-dropdown-option": true, class: [
|
|
183
184
|
`${clsPrefix}-dropdown-option-body__prefix`,
|
|
184
185
|
siblingHasIcon &&
|
|
185
186
|
`${clsPrefix}-dropdown-option-body__prefix--show-icon`
|
|
186
187
|
] }, [renderIcon ? renderIcon(rawNode) : render(rawNode.icon)]),
|
|
187
|
-
h("div", { "
|
|
188
|
+
h("div", { "data-dropdown-option": true, class: `${clsPrefix}-dropdown-option-body__label` }, renderLabel
|
|
188
189
|
? renderLabel(rawNode)
|
|
189
190
|
: render((_a = rawNode[this.labelField]) !== null && _a !== void 0 ? _a : rawNode.title)),
|
|
190
|
-
h("div", { "
|
|
191
|
+
h("div", { "data-dropdown-option": true, class: [
|
|
191
192
|
`${clsPrefix}-dropdown-option-body__suffix`,
|
|
192
193
|
siblingHasSubmenu &&
|
|
193
194
|
`${clsPrefix}-dropdown-option-body__suffix--has-submenu`
|
|
@@ -3,4 +3,3 @@ export declare function isSubmenuNode(rawNode: DropdownMixedOption, childrenFiel
|
|
|
3
3
|
export declare function isGroupNode(rawNode: DropdownMixedOption): boolean;
|
|
4
4
|
export declare function isDividerNode(rawNode: DropdownMixedOption): boolean;
|
|
5
5
|
export declare function isRenderNode(rawNode: DropdownMixedOption): rawNode is DropdownRenderOption;
|
|
6
|
-
export declare function isDropdownOptionRelatedTarget(element: HTMLElement): boolean;
|
package/es/dropdown/src/utils.js
CHANGED
|
@@ -11,13 +11,3 @@ export function isDividerNode(rawNode) {
|
|
|
11
11
|
export function isRenderNode(rawNode) {
|
|
12
12
|
return rawNode.type === 'render';
|
|
13
13
|
}
|
|
14
|
-
export function isDropdownOptionRelatedTarget(element) {
|
|
15
|
-
let currentElement = element;
|
|
16
|
-
while (currentElement !== null) {
|
|
17
|
-
if (currentElement.hasAttribute('__dropdown-option')) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
currentElement = currentElement.parentElement;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
@@ -30,6 +30,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
30
|
handlePreviewDblclick: () => void;
|
|
31
31
|
syncTransformOrigin: () => void;
|
|
32
32
|
handleAfterLeave: () => void;
|
|
33
|
+
handleDragStart: (e: Event) => void;
|
|
33
34
|
zoomIn: () => void;
|
|
34
35
|
zoomOut: () => void;
|
|
35
36
|
rotateCounterclockwise: () => void;
|
|
@@ -65,6 +65,10 @@ export default defineComponent({
|
|
|
65
65
|
let startY = 0;
|
|
66
66
|
let offsetX = 0;
|
|
67
67
|
let offsetY = 0;
|
|
68
|
+
let startOffsetX = 0;
|
|
69
|
+
let startOffsetY = 0;
|
|
70
|
+
let mouseDownClientX = 0;
|
|
71
|
+
let mouseDownClientY = 0;
|
|
68
72
|
let dragging = false;
|
|
69
73
|
function handleMouseMove(e) {
|
|
70
74
|
const { clientX, clientY } = e;
|
|
@@ -72,12 +76,30 @@ export default defineComponent({
|
|
|
72
76
|
offsetY = clientY - startY;
|
|
73
77
|
beforeNextFrameOnce(derivePreviewStyle);
|
|
74
78
|
}
|
|
79
|
+
function getMoveStrategy(opts) {
|
|
80
|
+
const { mouseUpClientX, mouseUpClientY, mouseDownClientX, mouseDownClientY } = opts;
|
|
81
|
+
const deltaHorizontal = mouseDownClientX - mouseUpClientX;
|
|
82
|
+
const deltaVertical = mouseDownClientY - mouseUpClientY;
|
|
83
|
+
let moveVerticalDirection = null;
|
|
84
|
+
let moveHorizontalDirection = null;
|
|
85
|
+
moveVerticalDirection = ('vertical' +
|
|
86
|
+
(deltaVertical > 0 ? 'Top' : 'Bottom'));
|
|
87
|
+
moveHorizontalDirection = ('horizontal' +
|
|
88
|
+
(deltaHorizontal > 0 ? 'Left' : 'Right'));
|
|
89
|
+
return {
|
|
90
|
+
moveVerticalDirection,
|
|
91
|
+
moveHorizontalDirection,
|
|
92
|
+
deltaHorizontal,
|
|
93
|
+
deltaVertical
|
|
94
|
+
};
|
|
95
|
+
}
|
|
75
96
|
// avoid image move outside viewport
|
|
76
|
-
function getDerivedOffset() {
|
|
97
|
+
function getDerivedOffset(moveStrategy) {
|
|
77
98
|
const { value: preview } = previewRef;
|
|
78
99
|
if (!preview)
|
|
79
100
|
return { offsetX: 0, offsetY: 0 };
|
|
80
101
|
const pbox = preview.getBoundingClientRect();
|
|
102
|
+
const { moveVerticalDirection, moveHorizontalDirection, deltaHorizontal, deltaVertical } = moveStrategy || {};
|
|
81
103
|
let nextOffsetX = 0;
|
|
82
104
|
let nextOffsetY = 0;
|
|
83
105
|
if (pbox.width <= window.innerWidth) {
|
|
@@ -89,6 +111,12 @@ export default defineComponent({
|
|
|
89
111
|
else if (pbox.right < window.innerWidth) {
|
|
90
112
|
nextOffsetX = -(pbox.width - window.innerWidth) / 2;
|
|
91
113
|
}
|
|
114
|
+
else if (moveHorizontalDirection === 'horizontalRight') {
|
|
115
|
+
nextOffsetX = Math.min((pbox.width - window.innerWidth) / 2, startOffsetX - (deltaHorizontal !== null && deltaHorizontal !== void 0 ? deltaHorizontal : 0));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
nextOffsetX = Math.max(-((pbox.width - window.innerWidth) / 2), startOffsetX - (deltaHorizontal !== null && deltaHorizontal !== void 0 ? deltaHorizontal : 0));
|
|
119
|
+
}
|
|
92
120
|
if (pbox.height <= window.innerHeight) {
|
|
93
121
|
nextOffsetY = 0;
|
|
94
122
|
}
|
|
@@ -98,16 +126,29 @@ export default defineComponent({
|
|
|
98
126
|
else if (pbox.bottom < window.innerHeight) {
|
|
99
127
|
nextOffsetY = -(pbox.height - window.innerHeight) / 2;
|
|
100
128
|
}
|
|
129
|
+
else if (moveVerticalDirection === 'verticalBottom') {
|
|
130
|
+
nextOffsetY = Math.min((pbox.height - window.innerHeight) / 2, startOffsetY - (deltaVertical !== null && deltaVertical !== void 0 ? deltaVertical : 0));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
nextOffsetY = Math.max(-((pbox.height - window.innerHeight) / 2), startOffsetY - (deltaVertical !== null && deltaVertical !== void 0 ? deltaVertical : 0));
|
|
134
|
+
}
|
|
101
135
|
return {
|
|
102
136
|
offsetX: nextOffsetX,
|
|
103
137
|
offsetY: nextOffsetY
|
|
104
138
|
};
|
|
105
139
|
}
|
|
106
|
-
function handleMouseUp() {
|
|
140
|
+
function handleMouseUp(e) {
|
|
107
141
|
off('mousemove', document, handleMouseMove);
|
|
108
142
|
off('mouseup', document, handleMouseUp);
|
|
143
|
+
const { clientX: mouseUpClientX, clientY: mouseUpClientY } = e;
|
|
109
144
|
dragging = false;
|
|
110
|
-
const
|
|
145
|
+
const moveStrategy = getMoveStrategy({
|
|
146
|
+
mouseUpClientX,
|
|
147
|
+
mouseUpClientY,
|
|
148
|
+
mouseDownClientX,
|
|
149
|
+
mouseDownClientY
|
|
150
|
+
});
|
|
151
|
+
const offset = getDerivedOffset(moveStrategy);
|
|
111
152
|
offsetX = offset.offsetX;
|
|
112
153
|
offsetY = offset.offsetY;
|
|
113
154
|
derivePreviewStyle();
|
|
@@ -117,6 +158,10 @@ export default defineComponent({
|
|
|
117
158
|
dragging = true;
|
|
118
159
|
startX = clientX - offsetX;
|
|
119
160
|
startY = clientY - offsetY;
|
|
161
|
+
startOffsetX = offsetX;
|
|
162
|
+
startOffsetY = offsetY;
|
|
163
|
+
mouseDownClientX = clientX;
|
|
164
|
+
mouseDownClientY = clientY;
|
|
120
165
|
derivePreviewStyle();
|
|
121
166
|
on('mousemove', document, handleMouseMove);
|
|
122
167
|
on('mouseup', document, handleMouseUp);
|
|
@@ -205,6 +250,8 @@ export default defineComponent({
|
|
|
205
250
|
rotate = 0;
|
|
206
251
|
scale = 1;
|
|
207
252
|
displayedRef.value = false;
|
|
253
|
+
}, handleDragStart: (e) => {
|
|
254
|
+
e.preventDefault();
|
|
208
255
|
}, zoomIn,
|
|
209
256
|
zoomOut,
|
|
210
257
|
rotateCounterclockwise,
|
|
@@ -247,7 +294,7 @@ export default defineComponent({
|
|
|
247
294
|
// Maybe it is a bug of vue
|
|
248
295
|
onEnter: this.syncTransformOrigin, onBeforeLeave: this.syncTransformOrigin }, {
|
|
249
296
|
default: () => withDirectives(h("div", { class: `${clsPrefix}-image-preview-wrapper`, ref: "previewWrapperRef" },
|
|
250
|
-
h("img", { draggable: false, onMousedown: this.handlePreviewMousedown, onDblclick: this.handlePreviewDblclick, class: `${clsPrefix}-image-preview`, key: this.previewSrc, src: this.previewSrc, ref: "previewRef" })), [[vShow, this.show]])
|
|
297
|
+
h("img", { draggable: false, onMousedown: this.handlePreviewMousedown, onDblclick: this.handlePreviewDblclick, class: `${clsPrefix}-image-preview`, key: this.previewSrc, src: this.previewSrc, ref: "previewRef", onDragstart: this.handleDragStart })), [[vShow, this.show]])
|
|
251
298
|
})), [[zindexable, { enabled: this.show }]])
|
|
252
299
|
: null
|
|
253
300
|
})));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/modal/src/Modal.d.ts
CHANGED
|
@@ -1796,7 +1796,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1796
1796
|
isMounted: Readonly<import("vue").Ref<boolean>>;
|
|
1797
1797
|
containerRef: import("vue").Ref<HTMLElement | null>;
|
|
1798
1798
|
presetProps: import("vue").ComputedRef<Pick<Readonly<{
|
|
1799
|
-
[x: string & `on${string}`]: undefined;
|
|
1799
|
+
[x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
|
|
1800
1800
|
type: "default" | "error" | "info" | "success" | "warning";
|
|
1801
1801
|
content: string | (() => import("vue").VNodeChild) | undefined;
|
|
1802
1802
|
size: "small" | "medium" | "large" | "huge";
|
package/es/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.21.
|
|
1
|
+
declare const _default: "2.21.1";
|
|
2
2
|
export default _default;
|
package/es/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '2.21.
|
|
1
|
+
export default '2.21.1';
|
|
@@ -40,7 +40,7 @@ function flatten(rowInfos, expandedRowKeys) {
|
|
|
40
40
|
rowInfos.forEach((rowInfo) => {
|
|
41
41
|
fRows.push(rowInfo);
|
|
42
42
|
const { children } = rowInfo.tmNode;
|
|
43
|
-
if (children) {
|
|
43
|
+
if (children && expandedRowKeys.has(rowInfo.key)) {
|
|
44
44
|
traverse(children);
|
|
45
45
|
}
|
|
46
46
|
});
|
|
@@ -260,10 +260,6 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
260
260
|
const cordKey = {};
|
|
261
261
|
const { cols, paginatedData, mergedTheme, fixedColumnLeftMap, fixedColumnRightMap, currentPage, rowClassName, mergedSortState, mergedExpandedRowKeySet, componentId, showHeader, hasChildren, firstContentfulColIndex, rowProps, handleMouseenterTable, handleMouseleaveTable, renderExpand, summary, handleCheckboxUpdateChecked, handleUpdateExpanded } = this;
|
|
262
262
|
const { length: colCount } = cols;
|
|
263
|
-
const rowIndexToKey = {};
|
|
264
|
-
paginatedData.forEach(({ tmNode }, rowIndex) => {
|
|
265
|
-
rowIndexToKey[rowIndex] = tmNode.key;
|
|
266
|
-
});
|
|
267
263
|
let mergedData;
|
|
268
264
|
// if there is children in data, we should expand mergedData first
|
|
269
265
|
const mergedPaginationData = hasChildren
|
|
@@ -304,7 +300,25 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
304
300
|
const indentStyle = hasChildren
|
|
305
301
|
? { width: (0, seemly_1.pxfy)(this.indent) }
|
|
306
302
|
: undefined;
|
|
307
|
-
|
|
303
|
+
// Tile the data of the expanded row
|
|
304
|
+
const displayedData = [];
|
|
305
|
+
mergedData.forEach((rowInfo) => {
|
|
306
|
+
if (renderExpand && mergedExpandedRowKeySet.has(rowInfo.key)) {
|
|
307
|
+
displayedData.push(rowInfo, {
|
|
308
|
+
isExpandedRow: true,
|
|
309
|
+
key: rowInfo.key,
|
|
310
|
+
tmNode: rowInfo.tmNode
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
displayedData.push(rowInfo);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
const { length: rowCount } = displayedData;
|
|
318
|
+
const rowIndexToKey = {};
|
|
319
|
+
paginatedData.forEach(({ tmNode }, rowIndex) => {
|
|
320
|
+
rowIndexToKey[rowIndex] = tmNode.key;
|
|
321
|
+
});
|
|
308
322
|
const renderRow = (rowInfo, rowIndex, isVirtual) => {
|
|
309
323
|
if ('isExpandedRow' in rowInfo) {
|
|
310
324
|
const { tmNode: { key, rawNode } } = rowInfo;
|
|
@@ -422,20 +436,6 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
422
436
|
})));
|
|
423
437
|
return row;
|
|
424
438
|
};
|
|
425
|
-
// Tile the data of the expanded row
|
|
426
|
-
const displayedData = [];
|
|
427
|
-
mergedData.forEach((rowInfo) => {
|
|
428
|
-
if (renderExpand && mergedExpandedRowKeySet.has(rowInfo.key)) {
|
|
429
|
-
displayedData.push(rowInfo, {
|
|
430
|
-
isExpandedRow: true,
|
|
431
|
-
key: rowInfo.key,
|
|
432
|
-
tmNode: rowInfo.tmNode
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
displayedData.push(rowInfo);
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
439
|
if (!virtualScroll) {
|
|
440
440
|
return ((0, vue_1.h)("table", { class: `${mergedClsPrefix}-data-table-table`, onMouseleave: handleMouseleaveTable, onMouseenter: handleMouseenterTable, style: {
|
|
441
441
|
tableLayout: this.mergedTableLayout
|
|
@@ -35,17 +35,17 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
35
35
|
const { rawNode } = this.tmNode;
|
|
36
36
|
return ((0, vue_1.h)("div", { class: `${clsPrefix}-dropdown-option` },
|
|
37
37
|
(0, vue_1.h)("div", { class: `${clsPrefix}-dropdown-option-body ${clsPrefix}-dropdown-option-body--group` },
|
|
38
|
-
(0, vue_1.h)("div", { "
|
|
38
|
+
(0, vue_1.h)("div", { "data-dropdown-option": true, class: [
|
|
39
39
|
`${clsPrefix}-dropdown-option-body__prefix`,
|
|
40
40
|
showIcon && `${clsPrefix}-dropdown-option-body__prefix--show-icon`
|
|
41
41
|
] }, (0, _utils_1.render)(rawNode.icon)),
|
|
42
|
-
(0, vue_1.h)("div", { class: `${clsPrefix}-dropdown-option-body__label`, "
|
|
42
|
+
(0, vue_1.h)("div", { class: `${clsPrefix}-dropdown-option-body__label`, "data-dropdown-option": true }, renderLabel
|
|
43
43
|
? renderLabel(rawNode)
|
|
44
44
|
: (0, _utils_1.render)((_a = rawNode.title) !== null && _a !== void 0 ? _a : rawNode[this.labelField])),
|
|
45
45
|
(0, vue_1.h)("div", { class: [
|
|
46
46
|
`${clsPrefix}-dropdown-option-body__suffix`,
|
|
47
47
|
hasSubmenu &&
|
|
48
48
|
`${clsPrefix}-dropdown-option-body__suffix--has-submenu`
|
|
49
|
-
], "
|
|
49
|
+
], "data-dropdown-option": true }))));
|
|
50
50
|
}
|
|
51
51
|
});
|
|
@@ -28,6 +28,7 @@ const icon_1 = require("../../icon");
|
|
|
28
28
|
const DropdownMenu_1 = __importStar(require("./DropdownMenu"));
|
|
29
29
|
const Dropdown_1 = require("./Dropdown");
|
|
30
30
|
const utils_1 = require("./utils");
|
|
31
|
+
const seemly_1 = require("seemly");
|
|
31
32
|
const dropdownOptionInjectionKey = Symbol('dropdown-option');
|
|
32
33
|
exports.default = (0, vue_1.defineComponent)({
|
|
33
34
|
name: 'DropdownOption',
|
|
@@ -125,7 +126,7 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
125
126
|
return;
|
|
126
127
|
const { relatedTarget } = e;
|
|
127
128
|
if (relatedTarget &&
|
|
128
|
-
!(0,
|
|
129
|
+
!(0, seemly_1.happensIn)({ target: relatedTarget }, 'dropdownOption')) {
|
|
129
130
|
hoverKeyRef.value = null;
|
|
130
131
|
}
|
|
131
132
|
}
|
|
@@ -200,15 +201,15 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
200
201
|
};
|
|
201
202
|
return ((0, vue_1.h)("div", { class: `${clsPrefix}-dropdown-option` },
|
|
202
203
|
(0, vue_1.h)('div', (0, vue_1.mergeProps)(builtinProps, props), [
|
|
203
|
-
(0, vue_1.h)("div", { "
|
|
204
|
+
(0, vue_1.h)("div", { "data-dropdown-option": true, class: [
|
|
204
205
|
`${clsPrefix}-dropdown-option-body__prefix`,
|
|
205
206
|
siblingHasIcon &&
|
|
206
207
|
`${clsPrefix}-dropdown-option-body__prefix--show-icon`
|
|
207
208
|
] }, [renderIcon ? renderIcon(rawNode) : (0, _utils_1.render)(rawNode.icon)]),
|
|
208
|
-
(0, vue_1.h)("div", { "
|
|
209
|
+
(0, vue_1.h)("div", { "data-dropdown-option": true, class: `${clsPrefix}-dropdown-option-body__label` }, renderLabel
|
|
209
210
|
? renderLabel(rawNode)
|
|
210
211
|
: (0, _utils_1.render)((_a = rawNode[this.labelField]) !== null && _a !== void 0 ? _a : rawNode.title)),
|
|
211
|
-
(0, vue_1.h)("div", { "
|
|
212
|
+
(0, vue_1.h)("div", { "data-dropdown-option": true, class: [
|
|
212
213
|
`${clsPrefix}-dropdown-option-body__suffix`,
|
|
213
214
|
siblingHasSubmenu &&
|
|
214
215
|
`${clsPrefix}-dropdown-option-body__suffix--has-submenu`
|
|
@@ -3,4 +3,3 @@ export declare function isSubmenuNode(rawNode: DropdownMixedOption, childrenFiel
|
|
|
3
3
|
export declare function isGroupNode(rawNode: DropdownMixedOption): boolean;
|
|
4
4
|
export declare function isDividerNode(rawNode: DropdownMixedOption): boolean;
|
|
5
5
|
export declare function isRenderNode(rawNode: DropdownMixedOption): rawNode is DropdownRenderOption;
|
|
6
|
-
export declare function isDropdownOptionRelatedTarget(element: HTMLElement): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isRenderNode = exports.isDividerNode = exports.isGroupNode = exports.isSubmenuNode = void 0;
|
|
4
4
|
function isSubmenuNode(rawNode, childrenField) {
|
|
5
5
|
return (rawNode.type === 'submenu' ||
|
|
6
6
|
(rawNode.type === undefined && rawNode[childrenField] !== undefined));
|
|
@@ -18,14 +18,3 @@ function isRenderNode(rawNode) {
|
|
|
18
18
|
return rawNode.type === 'render';
|
|
19
19
|
}
|
|
20
20
|
exports.isRenderNode = isRenderNode;
|
|
21
|
-
function isDropdownOptionRelatedTarget(element) {
|
|
22
|
-
let currentElement = element;
|
|
23
|
-
while (currentElement !== null) {
|
|
24
|
-
if (currentElement.hasAttribute('__dropdown-option')) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
currentElement = currentElement.parentElement;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
exports.isDropdownOptionRelatedTarget = isDropdownOptionRelatedTarget;
|
|
@@ -30,6 +30,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
30
30
|
handlePreviewDblclick: () => void;
|
|
31
31
|
syncTransformOrigin: () => void;
|
|
32
32
|
handleAfterLeave: () => void;
|
|
33
|
+
handleDragStart: (e: Event) => void;
|
|
33
34
|
zoomIn: () => void;
|
|
34
35
|
zoomOut: () => void;
|
|
35
36
|
rotateCounterclockwise: () => void;
|
|
@@ -70,6 +70,10 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
70
70
|
let startY = 0;
|
|
71
71
|
let offsetX = 0;
|
|
72
72
|
let offsetY = 0;
|
|
73
|
+
let startOffsetX = 0;
|
|
74
|
+
let startOffsetY = 0;
|
|
75
|
+
let mouseDownClientX = 0;
|
|
76
|
+
let mouseDownClientY = 0;
|
|
73
77
|
let dragging = false;
|
|
74
78
|
function handleMouseMove(e) {
|
|
75
79
|
const { clientX, clientY } = e;
|
|
@@ -77,12 +81,30 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
77
81
|
offsetY = clientY - startY;
|
|
78
82
|
(0, seemly_1.beforeNextFrameOnce)(derivePreviewStyle);
|
|
79
83
|
}
|
|
84
|
+
function getMoveStrategy(opts) {
|
|
85
|
+
const { mouseUpClientX, mouseUpClientY, mouseDownClientX, mouseDownClientY } = opts;
|
|
86
|
+
const deltaHorizontal = mouseDownClientX - mouseUpClientX;
|
|
87
|
+
const deltaVertical = mouseDownClientY - mouseUpClientY;
|
|
88
|
+
let moveVerticalDirection = null;
|
|
89
|
+
let moveHorizontalDirection = null;
|
|
90
|
+
moveVerticalDirection = ('vertical' +
|
|
91
|
+
(deltaVertical > 0 ? 'Top' : 'Bottom'));
|
|
92
|
+
moveHorizontalDirection = ('horizontal' +
|
|
93
|
+
(deltaHorizontal > 0 ? 'Left' : 'Right'));
|
|
94
|
+
return {
|
|
95
|
+
moveVerticalDirection,
|
|
96
|
+
moveHorizontalDirection,
|
|
97
|
+
deltaHorizontal,
|
|
98
|
+
deltaVertical
|
|
99
|
+
};
|
|
100
|
+
}
|
|
80
101
|
// avoid image move outside viewport
|
|
81
|
-
function getDerivedOffset() {
|
|
102
|
+
function getDerivedOffset(moveStrategy) {
|
|
82
103
|
const { value: preview } = previewRef;
|
|
83
104
|
if (!preview)
|
|
84
105
|
return { offsetX: 0, offsetY: 0 };
|
|
85
106
|
const pbox = preview.getBoundingClientRect();
|
|
107
|
+
const { moveVerticalDirection, moveHorizontalDirection, deltaHorizontal, deltaVertical } = moveStrategy || {};
|
|
86
108
|
let nextOffsetX = 0;
|
|
87
109
|
let nextOffsetY = 0;
|
|
88
110
|
if (pbox.width <= window.innerWidth) {
|
|
@@ -94,6 +116,12 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
94
116
|
else if (pbox.right < window.innerWidth) {
|
|
95
117
|
nextOffsetX = -(pbox.width - window.innerWidth) / 2;
|
|
96
118
|
}
|
|
119
|
+
else if (moveHorizontalDirection === 'horizontalRight') {
|
|
120
|
+
nextOffsetX = Math.min((pbox.width - window.innerWidth) / 2, startOffsetX - (deltaHorizontal !== null && deltaHorizontal !== void 0 ? deltaHorizontal : 0));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
nextOffsetX = Math.max(-((pbox.width - window.innerWidth) / 2), startOffsetX - (deltaHorizontal !== null && deltaHorizontal !== void 0 ? deltaHorizontal : 0));
|
|
124
|
+
}
|
|
97
125
|
if (pbox.height <= window.innerHeight) {
|
|
98
126
|
nextOffsetY = 0;
|
|
99
127
|
}
|
|
@@ -103,16 +131,29 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
103
131
|
else if (pbox.bottom < window.innerHeight) {
|
|
104
132
|
nextOffsetY = -(pbox.height - window.innerHeight) / 2;
|
|
105
133
|
}
|
|
134
|
+
else if (moveVerticalDirection === 'verticalBottom') {
|
|
135
|
+
nextOffsetY = Math.min((pbox.height - window.innerHeight) / 2, startOffsetY - (deltaVertical !== null && deltaVertical !== void 0 ? deltaVertical : 0));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
nextOffsetY = Math.max(-((pbox.height - window.innerHeight) / 2), startOffsetY - (deltaVertical !== null && deltaVertical !== void 0 ? deltaVertical : 0));
|
|
139
|
+
}
|
|
106
140
|
return {
|
|
107
141
|
offsetX: nextOffsetX,
|
|
108
142
|
offsetY: nextOffsetY
|
|
109
143
|
};
|
|
110
144
|
}
|
|
111
|
-
function handleMouseUp() {
|
|
145
|
+
function handleMouseUp(e) {
|
|
112
146
|
(0, evtd_1.off)('mousemove', document, handleMouseMove);
|
|
113
147
|
(0, evtd_1.off)('mouseup', document, handleMouseUp);
|
|
148
|
+
const { clientX: mouseUpClientX, clientY: mouseUpClientY } = e;
|
|
114
149
|
dragging = false;
|
|
115
|
-
const
|
|
150
|
+
const moveStrategy = getMoveStrategy({
|
|
151
|
+
mouseUpClientX,
|
|
152
|
+
mouseUpClientY,
|
|
153
|
+
mouseDownClientX,
|
|
154
|
+
mouseDownClientY
|
|
155
|
+
});
|
|
156
|
+
const offset = getDerivedOffset(moveStrategy);
|
|
116
157
|
offsetX = offset.offsetX;
|
|
117
158
|
offsetY = offset.offsetY;
|
|
118
159
|
derivePreviewStyle();
|
|
@@ -122,6 +163,10 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
122
163
|
dragging = true;
|
|
123
164
|
startX = clientX - offsetX;
|
|
124
165
|
startY = clientY - offsetY;
|
|
166
|
+
startOffsetX = offsetX;
|
|
167
|
+
startOffsetY = offsetY;
|
|
168
|
+
mouseDownClientX = clientX;
|
|
169
|
+
mouseDownClientY = clientY;
|
|
125
170
|
derivePreviewStyle();
|
|
126
171
|
(0, evtd_1.on)('mousemove', document, handleMouseMove);
|
|
127
172
|
(0, evtd_1.on)('mouseup', document, handleMouseUp);
|
|
@@ -210,6 +255,8 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
210
255
|
rotate = 0;
|
|
211
256
|
scale = 1;
|
|
212
257
|
displayedRef.value = false;
|
|
258
|
+
}, handleDragStart: (e) => {
|
|
259
|
+
e.preventDefault();
|
|
213
260
|
}, zoomIn,
|
|
214
261
|
zoomOut,
|
|
215
262
|
rotateCounterclockwise,
|
|
@@ -252,7 +299,7 @@ exports.default = (0, vue_1.defineComponent)({
|
|
|
252
299
|
// Maybe it is a bug of vue
|
|
253
300
|
onEnter: this.syncTransformOrigin, onBeforeLeave: this.syncTransformOrigin }, {
|
|
254
301
|
default: () => (0, vue_1.withDirectives)((0, vue_1.h)("div", { class: `${clsPrefix}-image-preview-wrapper`, ref: "previewWrapperRef" },
|
|
255
|
-
(0, vue_1.h)("img", { draggable: false, onMousedown: this.handlePreviewMousedown, onDblclick: this.handlePreviewDblclick, class: `${clsPrefix}-image-preview`, key: this.previewSrc, src: this.previewSrc, ref: "previewRef" })), [[vue_1.vShow, this.show]])
|
|
302
|
+
(0, vue_1.h)("img", { draggable: false, onMousedown: this.handlePreviewMousedown, onDblclick: this.handlePreviewDblclick, class: `${clsPrefix}-image-preview`, key: this.previewSrc, src: this.previewSrc, ref: "previewRef", onDragstart: this.handleDragStart })), [[vue_1.vShow, this.show]])
|
|
256
303
|
})), [[vdirs_1.zindexable, { enabled: this.show }]])
|
|
257
304
|
: null
|
|
258
305
|
})));
|
package/lib/modal/src/Modal.d.ts
CHANGED
|
@@ -1796,7 +1796,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
1796
1796
|
isMounted: Readonly<import("vue").Ref<boolean>>;
|
|
1797
1797
|
containerRef: import("vue").Ref<HTMLElement | null>;
|
|
1798
1798
|
presetProps: import("vue").ComputedRef<Pick<Readonly<{
|
|
1799
|
-
[x: string & `on${string}`]: undefined;
|
|
1799
|
+
[x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;
|
|
1800
1800
|
type: "default" | "error" | "info" | "success" | "warning";
|
|
1801
1801
|
content: string | (() => import("vue").VNodeChild) | undefined;
|
|
1802
1802
|
size: "small" | "medium" | "large" | "huge";
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "2.21.
|
|
1
|
+
declare const _default: "2.21.1";
|
|
2
2
|
export default _default;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naive-ui",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.1",
|
|
4
4
|
"description": "A Vue 3 Component Library. Fairly Complete, Customizable Themes, Uses TypeScript, Not Too Slow",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@vue/eslint-config-standard": "^6.0.0",
|
|
80
80
|
"@vue/eslint-config-typescript": "^7.0.0",
|
|
81
81
|
"@vue/server-renderer": "^3.2.18",
|
|
82
|
-
"@vue/test-utils": "
|
|
82
|
+
"@vue/test-utils": "2.0.0-rc.16",
|
|
83
83
|
"autoprefixer": "^10.2.6",
|
|
84
84
|
"babel-jest": "^27.0.2",
|
|
85
85
|
"codesandbox": "^2.2.3",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"inquirer": "^8.1.0",
|
|
101
101
|
"jest": "^27.0.4",
|
|
102
102
|
"jest-canvas-mock": "^2.3.1",
|
|
103
|
-
"lint-staged": "^
|
|
103
|
+
"lint-staged": "^11.2.6",
|
|
104
104
|
"marked": "^4.0.4",
|
|
105
105
|
"prettier": "^2.2.1",
|
|
106
106
|
"rimraf": "^3.0.2",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"highlight.js": "^11.0.1",
|
|
129
129
|
"lodash": "^4.17.21",
|
|
130
130
|
"lodash-es": "^4.17.21",
|
|
131
|
-
"seemly": "^0.3.
|
|
131
|
+
"seemly": "^0.3.3",
|
|
132
132
|
"treemate": "^0.3.8",
|
|
133
133
|
"vdirs": "^0.1.4",
|
|
134
134
|
"vfonts": "^0.1.0",
|