@king-design/vue 2.0.8 → 2.0.9
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/__tests__/__snapshots__/Vue Next Demos.md +31 -31
- package/components/datepicker/index.spec.js +28 -22
- package/components/dialog/useEscClosable.js +9 -3
- package/components/portal.d.ts +1 -0
- package/components/portal.js +12 -42
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
|
@@ -234,7 +234,7 @@ describe('Datepicker', function () {
|
|
|
234
234
|
}, _callee6);
|
|
235
235
|
})));
|
|
236
236
|
it('range date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
|
|
237
|
-
var _mount6, instance, element, select, content, _content$querySelecto, panel1, panel2, _panel1$querySelector, nextMonth, nextYear, _content$querySelecto2, monthValues1, monthValues2, _panel2$querySelector, prevYear;
|
|
237
|
+
var _mount6, instance, element, select, content, _content$querySelecto, panel1, panel2, _panel1$querySelector, nextMonth, nextYear, _content$querySelecto2, monthValues1, monthValues2, monthStart, yearStart, monthEnd, yearEnd, _panel2$querySelector, prevYear, firstDecadeStart, secondDecadeStart;
|
|
238
238
|
|
|
239
239
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
240
240
|
while (1) {
|
|
@@ -252,45 +252,51 @@ describe('Datepicker', function () {
|
|
|
252
252
|
_panel1$querySelector = panel1.querySelectorAll('.k-next'), nextMonth = _panel1$querySelector[0], nextYear = _panel1$querySelector[1];
|
|
253
253
|
_content$querySelecto2 = content.querySelectorAll('.k-month-values'), monthValues1 = _content$querySelecto2[0], monthValues2 = _content$querySelecto2[1];
|
|
254
254
|
nextMonth.click();
|
|
255
|
-
|
|
255
|
+
monthStart = (month + 1) % 12 + 1;
|
|
256
|
+
yearStart = year + Math.floor((month + 1) / 12);
|
|
257
|
+
monthEnd = (month + 2) % 12 + 1;
|
|
258
|
+
yearEnd = year + Math.floor((month + 2) / 12);
|
|
259
|
+
_context7.next = 16;
|
|
256
260
|
return wait();
|
|
257
261
|
|
|
258
|
-
case
|
|
259
|
-
expect(monthValues1.textContent).to.eql(
|
|
260
|
-
expect(monthValues2.textContent).to.eql(
|
|
262
|
+
case 16:
|
|
263
|
+
expect(monthValues1.textContent).to.eql(yearStart + "\u5E74" + monthStart + "\u6708");
|
|
264
|
+
expect(monthValues2.textContent).to.eql(yearEnd + "\u5E74" + monthEnd + "\u6708");
|
|
261
265
|
nextYear.click();
|
|
262
|
-
_context7.next =
|
|
266
|
+
_context7.next = 21;
|
|
263
267
|
return wait();
|
|
264
268
|
|
|
265
|
-
case
|
|
266
|
-
expect(monthValues1.textContent).to.eql(
|
|
267
|
-
expect(monthValues2.textContent).to.eql(
|
|
269
|
+
case 21:
|
|
270
|
+
expect(monthValues1.textContent).to.eql(yearStart + 1 + "\u5E74" + monthStart + "\u6708");
|
|
271
|
+
expect(monthValues2.textContent).to.eql(yearEnd + 1 + "\u5E74" + monthEnd + "\u6708");
|
|
268
272
|
_panel2$querySelector = panel2.querySelectorAll('.k-prev'), prevYear = _panel2$querySelector[0];
|
|
269
273
|
prevYear.click();
|
|
270
|
-
_context7.next =
|
|
274
|
+
_context7.next = 27;
|
|
271
275
|
return wait();
|
|
272
276
|
|
|
273
|
-
case
|
|
274
|
-
expect(monthValues1.textContent).to.eql(
|
|
275
|
-
expect(monthValues2.textContent).to.eql(
|
|
277
|
+
case 27:
|
|
278
|
+
expect(monthValues1.textContent).to.eql(yearStart + "\u5E74" + monthStart + "\u6708");
|
|
279
|
+
expect(monthValues2.textContent).to.eql(yearEnd + "\u5E74" + monthEnd + "\u6708"); // year panel
|
|
276
280
|
|
|
277
281
|
dispatchEvent(monthValues1.firstElementChild, 'click');
|
|
278
282
|
dispatchEvent(monthValues2.firstElementChild, 'click');
|
|
279
|
-
_context7.next =
|
|
283
|
+
_context7.next = 33;
|
|
280
284
|
return wait();
|
|
281
285
|
|
|
282
|
-
case
|
|
283
|
-
|
|
284
|
-
|
|
286
|
+
case 33:
|
|
287
|
+
firstDecadeStart = Math.floor(yearStart / 10) * 10;
|
|
288
|
+
secondDecadeStart = Math.floor(yearEnd / 10) * 10;
|
|
289
|
+
expect(monthValues1.textContent).to.eql(firstDecadeStart + "\u5E74 - " + (firstDecadeStart + 9) + "\u5E74");
|
|
290
|
+
expect(monthValues1.textContent).to.eql(secondDecadeStart + "\u5E74 - " + (secondDecadeStart + 9) + "\u5E74");
|
|
285
291
|
nextYear.click();
|
|
286
|
-
_context7.next =
|
|
292
|
+
_context7.next = 40;
|
|
287
293
|
return wait();
|
|
288
294
|
|
|
289
|
-
case
|
|
290
|
-
expect(monthValues1.textContent).to.eql(
|
|
291
|
-
expect(monthValues1.textContent).to.eql(
|
|
295
|
+
case 40:
|
|
296
|
+
expect(monthValues1.textContent).to.eql(firstDecadeStart + 10 + "\u5E74 - " + (secondDecadeStart + 19) + "\u5E74");
|
|
297
|
+
expect(monthValues1.textContent).to.eql(secondDecadeStart + 10 + "\u5E74 - " + (secondDecadeStart + 19) + "\u5E74");
|
|
292
298
|
|
|
293
|
-
case
|
|
299
|
+
case 42:
|
|
294
300
|
case "end":
|
|
295
301
|
return _context7.stop();
|
|
296
302
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
1
2
|
import { useInstance, onUnmounted } from 'intact-vue-next';
|
|
2
3
|
import { SHOW, HIDE } from './constants'; // only close the top dialog when press ESC
|
|
3
4
|
|
|
@@ -22,14 +23,19 @@ export function useEscClosable() {
|
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
function onHide() {
|
|
25
|
-
|
|
26
|
+
// the order is uncertain in different frameworks
|
|
27
|
+
var index = dialogs.indexOf(instance); // const dialog = dialogs.pop();
|
|
28
|
+
// const dialog = dialogs.shift();
|
|
26
29
|
|
|
27
30
|
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
-
if (dialog !== instance) {
|
|
29
|
-
|
|
31
|
+
// if (dialog !== instance) {
|
|
32
|
+
if (index === -1) {
|
|
33
|
+
throw new Error('The dialog has handled hide callback. Maybe it is a bug of KPC');
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
_spliceInstanceProperty(dialogs).call(dialogs, 0, index);
|
|
38
|
+
|
|
33
39
|
if (!dialogs.length) {
|
|
34
40
|
document.removeEventListener('keydown', escClose);
|
|
35
41
|
}
|
package/components/portal.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare class Portal<T extends PortalProps = PortalProps> extends Compone
|
|
|
10
10
|
private dialog;
|
|
11
11
|
mountedQueue?: Function[];
|
|
12
12
|
mountedDone?: boolean;
|
|
13
|
+
$isPortal: boolean;
|
|
13
14
|
$render(lastVNode: VNodeComponentClass<this> | null, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[]): void;
|
|
14
15
|
$update(lastVNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this>, parentDom: Element, anchor: IntactDom | null, mountedQueue: Function[], force: boolean): void;
|
|
15
16
|
$unmount(vNode: VNodeComponentClass<this>, nextVNode: VNodeComponentClass<this> | null): void;
|
package/components/portal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
|
-
import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject
|
|
3
|
+
import { Component, createCommentVNode, createTextVNode, mount, patch, remove, inject } from 'intact-vue-next';
|
|
4
4
|
import { isString } from 'intact-shared';
|
|
5
5
|
import { DIALOG } from './dialog/constants';
|
|
6
6
|
var typeDefs = {
|
|
@@ -23,6 +23,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
23
23
|
_this.dialog = inject(DIALOG, null);
|
|
24
24
|
_this.mountedQueue = void 0;
|
|
25
25
|
_this.mountedDone = void 0;
|
|
26
|
+
_this.$isPortal = true;
|
|
26
27
|
return _this;
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -39,41 +40,20 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
39
40
|
_proto.$render = function $render(lastVNode, nextVNode, parentDom, anchor, mountedQueue) {
|
|
40
41
|
var _this2 = this;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* In React, we cannot render real elements in mountedQueue.
|
|
45
|
+
* Because the rendering time of react element is uncontrollable
|
|
46
|
+
*/
|
|
47
|
+
var nextProps = nextVNode.props;
|
|
48
|
+
var fakeContainer = document.createDocumentFragment();
|
|
42
49
|
mountedQueue.push(function () {
|
|
43
|
-
var nextProps = nextVNode.props;
|
|
44
50
|
var parentDom = _this2.$lastInput.dom.parentElement;
|
|
45
|
-
/**
|
|
46
|
-
* initialize a new mountedQueue to place the callbacks of sub-components to it,
|
|
47
|
-
* so that we can call them before the sibling components of the Portal
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
var mountedQueue = [];
|
|
51
51
|
|
|
52
52
|
_this2.initContainer(nextProps.container, parentDom, anchor);
|
|
53
|
-
/**
|
|
54
|
-
* Because we render real elements following parent has rendered.
|
|
55
|
-
* In React, the $promises have done. Then we cannot add any promise to it.
|
|
56
|
-
* We should find the parent component who holds the $promises object, and
|
|
57
|
-
* reset it to let remaining element children add promise to it.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var parent = getParent(_this2);
|
|
62
|
-
|
|
63
|
-
if (parent) {
|
|
64
|
-
parent.$promises.reset();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
mount(nextProps.children, _this2.container, _this2, _this2.$SVG, null, mountedQueue); // in react, we should wait for all promises to resolve
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
Component.FakePromise.all(parent.$promises).then(function () {
|
|
71
|
-
callAll(mountedQueue);
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
callAll(mountedQueue);
|
|
75
|
-
}
|
|
54
|
+
_this2.container.appendChild(fakeContainer);
|
|
76
55
|
});
|
|
56
|
+
mount(nextProps.children, fakeContainer, this, this.$SVG, null, mountedQueue);
|
|
77
57
|
|
|
78
58
|
_Component.prototype.$render.call(this, lastVNode, nextVNode, parentDom, anchor, mountedQueue);
|
|
79
59
|
};
|
|
@@ -119,7 +99,7 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
119
99
|
// find the closest dialog if exists
|
|
120
100
|
var tmp;
|
|
121
101
|
|
|
122
|
-
if ((tmp = this.dialog) && (tmp = tmp.dialogRef.value)) {
|
|
102
|
+
if ((tmp = this.dialog) && tmp !== this.$senior && (tmp = tmp.dialogRef.value)) {
|
|
123
103
|
this.container = tmp;
|
|
124
104
|
} else {
|
|
125
105
|
this.container = document.body;
|
|
@@ -129,14 +109,4 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
129
109
|
|
|
130
110
|
return Portal;
|
|
131
111
|
}(Component);
|
|
132
|
-
Portal.typeDefs = typeDefs;
|
|
133
|
-
|
|
134
|
-
function getParent($senior) {
|
|
135
|
-
while ($senior = $senior.$senior) {
|
|
136
|
-
if ($senior._reactInternals) {
|
|
137
|
-
return $senior;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
112
|
+
Portal.typeDefs = typeDefs;
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Kingsoft Cloud
|
|
5
5
|
* Released under the MIT License
|
|
@@ -57,7 +57,7 @@ export * from './components/tree';
|
|
|
57
57
|
export * from './components/treeSelect';
|
|
58
58
|
export * from './components/upload';
|
|
59
59
|
export * from './components/wave';
|
|
60
|
-
export declare const version = "2.0.
|
|
60
|
+
export declare const version = "2.0.9";
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
export {normalize} from 'intact-vue-next';
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.9
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Kingsoft Cloud
|
|
5
5
|
* Released under the MIT License
|
|
@@ -59,7 +59,7 @@ export * from './components/tree';
|
|
|
59
59
|
export * from './components/treeSelect';
|
|
60
60
|
export * from './components/upload';
|
|
61
61
|
export * from './components/wave';
|
|
62
|
-
export var version = '2.0.
|
|
62
|
+
export var version = '2.0.9';
|
|
63
63
|
/* generate end */
|
|
64
64
|
|
|
65
65
|
export {normalize} from 'intact-vue-next';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@king-design/vue",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "King-Design UI components for Vue3.0.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dayjs": "^1.10.7",
|
|
39
39
|
"downloadjs": "^1.4.7",
|
|
40
40
|
"enquire.js": "^2.1.6",
|
|
41
|
-
"intact-vue-next": "^3.0.
|
|
41
|
+
"intact-vue-next": "^3.0.10",
|
|
42
42
|
"monaco-editor": "^0.26.1",
|
|
43
43
|
"mxgraphx": "^4.0.7",
|
|
44
44
|
"resize-observer-polyfill": "^1.5.1",
|