@king-design/intact 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/components/datepicker/index.spec.ts +16 -10
- package/components/dialog/useEscClosable.ts +7 -3
- package/components/portal.ts +20 -50
- package/es/components/datepicker/index.spec.js +28 -22
- package/es/components/dialog/useEscClosable.js +9 -3
- package/es/components/portal.d.ts +1 -0
- package/es/components/portal.js +12 -42
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/packages/kpc-react/__tests__/components/drawer.spec.js +53 -0
- package/es/packages/kpc-react/__tests__/components/dropdown.spec.js +107 -1
- package/es/packages/kpc-react/__tests__/components/{form.spec.d.ts → menu.spec.d.ts} +0 -0
- package/es/packages/kpc-react/__tests__/components/menu.spec.js +76 -0
- package/es/packages/kpc-react/__tests__/components/tooltip.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/{form.spec.js → tooltip.spec.js} +1 -1
- package/index.ts +2 -2
- package/package.json +2 -2
|
@@ -142,32 +142,38 @@ describe('Datepicker', () => {
|
|
|
142
142
|
const [monthValues1, monthValues2]= content.querySelectorAll<HTMLElement>('.k-month-values');
|
|
143
143
|
|
|
144
144
|
nextMonth.click();
|
|
145
|
+
const monthStart = (month + 1) % 12 + 1;
|
|
146
|
+
const yearStart = year + Math.floor((month + 1) / 12);
|
|
147
|
+
const monthEnd = (month + 2) % 12 + 1;
|
|
148
|
+
const yearEnd = year + Math.floor((month + 2) / 12);
|
|
145
149
|
await wait();
|
|
146
|
-
expect(monthValues1.textContent).to.eql(`${
|
|
147
|
-
expect(monthValues2.textContent).to.eql(`${
|
|
150
|
+
expect(monthValues1.textContent).to.eql(`${yearStart}年${monthStart}月`);
|
|
151
|
+
expect(monthValues2.textContent).to.eql(`${yearEnd}年${monthEnd}月`);
|
|
148
152
|
|
|
149
153
|
nextYear.click();
|
|
150
154
|
await wait();
|
|
151
|
-
expect(monthValues1.textContent).to.eql(`${
|
|
152
|
-
expect(monthValues2.textContent).to.eql(`${
|
|
155
|
+
expect(monthValues1.textContent).to.eql(`${yearStart + 1}年${monthStart}月`);
|
|
156
|
+
expect(monthValues2.textContent).to.eql(`${yearEnd + 1}年${monthEnd}月`);
|
|
153
157
|
|
|
154
158
|
const [prevYear] = panel2.querySelectorAll<HTMLElement>('.k-prev');
|
|
155
159
|
prevYear.click();
|
|
156
160
|
await wait();
|
|
157
|
-
expect(monthValues1.textContent).to.eql(`${
|
|
158
|
-
expect(monthValues2.textContent).to.eql(`${
|
|
161
|
+
expect(monthValues1.textContent).to.eql(`${yearStart}年${monthStart}月`);
|
|
162
|
+
expect(monthValues2.textContent).to.eql(`${yearEnd}年${monthEnd}月`);
|
|
159
163
|
|
|
160
164
|
// year panel
|
|
161
165
|
dispatchEvent(monthValues1.firstElementChild!, 'click');
|
|
162
166
|
dispatchEvent(monthValues2.firstElementChild!, 'click');
|
|
163
167
|
await wait();
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
const firstDecadeStart = Math.floor(yearStart / 10) * 10;
|
|
169
|
+
const secondDecadeStart = Math.floor(yearEnd / 10) * 10;
|
|
170
|
+
expect(monthValues1.textContent).to.eql(`${firstDecadeStart}年 - ${firstDecadeStart + 9}年`);
|
|
171
|
+
expect(monthValues1.textContent).to.eql(`${secondDecadeStart}年 - ${secondDecadeStart + 9}年`);
|
|
166
172
|
|
|
167
173
|
nextYear.click();
|
|
168
174
|
await wait();
|
|
169
|
-
expect(monthValues1.textContent).to.eql(`${
|
|
170
|
-
expect(monthValues1.textContent).to.eql(
|
|
175
|
+
expect(monthValues1.textContent).to.eql(`${firstDecadeStart + 10}年 - ${secondDecadeStart + 19}年`);
|
|
176
|
+
expect(monthValues1.textContent).to.eql(`${secondDecadeStart + 10}年 - ${secondDecadeStart + 19}年`);
|
|
171
177
|
});
|
|
172
178
|
|
|
173
179
|
it('range year', async () => {
|
|
@@ -22,13 +22,17 @@ export function useEscClosable() {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
function onHide() {
|
|
25
|
-
|
|
25
|
+
// the order is uncertain in different frameworks
|
|
26
|
+
const index = dialogs.indexOf(instance);
|
|
27
|
+
// const dialog = dialogs.pop();
|
|
26
28
|
// const dialog = dialogs.shift();
|
|
27
29
|
if (process.env.NODE_ENV !== 'production') {
|
|
28
|
-
if (dialog !== instance) {
|
|
29
|
-
|
|
30
|
+
// if (dialog !== instance) {
|
|
31
|
+
if (index === -1) {
|
|
32
|
+
throw new Error('The dialog has handled hide callback. Maybe it is a bug of KPC');
|
|
30
33
|
}
|
|
31
34
|
}
|
|
35
|
+
dialogs.splice(0, index);
|
|
32
36
|
|
|
33
37
|
if (!dialogs.length) {
|
|
34
38
|
document.removeEventListener('keydown', escClose);
|
package/components/portal.ts
CHANGED
|
@@ -6,14 +6,10 @@ import {
|
|
|
6
6
|
createCommentVNode,
|
|
7
7
|
createTextVNode,
|
|
8
8
|
mount,
|
|
9
|
-
removeVNodeDom,
|
|
10
9
|
patch,
|
|
11
10
|
remove,
|
|
12
11
|
TypeDefs,
|
|
13
|
-
provide,
|
|
14
12
|
inject,
|
|
15
|
-
nextTick,
|
|
16
|
-
callAll,
|
|
17
13
|
} from 'intact';
|
|
18
14
|
import {isString} from 'intact-shared';
|
|
19
15
|
import {DIALOG} from './dialog/constants';
|
|
@@ -42,6 +38,7 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
42
38
|
private dialog: Dialog | null = inject(DIALOG, null);
|
|
43
39
|
public mountedQueue?: Function[];
|
|
44
40
|
public mountedDone?: boolean;
|
|
41
|
+
public $isPortal = true;
|
|
45
42
|
|
|
46
43
|
$render(
|
|
47
44
|
lastVNode: VNodeComponentClass<this> | null,
|
|
@@ -50,46 +47,29 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
50
47
|
anchor: IntactDom | null,
|
|
51
48
|
mountedQueue: Function[]
|
|
52
49
|
) {
|
|
50
|
+
/**
|
|
51
|
+
* In React, we cannot render real elements in mountedQueue.
|
|
52
|
+
* Because the rendering time of react element is uncontrollable
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
const nextProps = nextVNode.props!;
|
|
56
|
+
const fakeContainer = document.createDocumentFragment();
|
|
57
|
+
|
|
53
58
|
mountedQueue.push(() => {
|
|
54
|
-
const nextProps = nextVNode.props!;
|
|
55
59
|
const parentDom = this.$lastInput!.dom!.parentElement!;
|
|
56
|
-
/**
|
|
57
|
-
* initialize a new mountedQueue to place the callbacks of sub-components to it,
|
|
58
|
-
* so that we can call them before the sibling components of the Portal
|
|
59
|
-
*/
|
|
60
|
-
const mountedQueue: Function[] = [];
|
|
61
60
|
this.initContainer(nextProps.container, parentDom, anchor);
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Because we render real elements following parent has rendered.
|
|
65
|
-
* In React, the $promises have done. Then we cannot add any promise to it.
|
|
66
|
-
* We should find the parent component who holds the $promises object, and
|
|
67
|
-
* reset it to let remaining element children add promise to it.
|
|
68
|
-
*/
|
|
69
|
-
const parent = getParent(this) as any;
|
|
70
|
-
if (parent) {
|
|
71
|
-
parent.$promises.reset();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
mount(
|
|
75
|
-
nextProps.children as VNode,
|
|
76
|
-
this.container!,
|
|
77
|
-
this,
|
|
78
|
-
this.$SVG,
|
|
79
|
-
null,
|
|
80
|
-
mountedQueue,
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
// in react, we should wait for all promises to resolve
|
|
84
|
-
if (parent) {
|
|
85
|
-
(Component as any).FakePromise.all(parent.$promises).then(() => {
|
|
86
|
-
callAll(mountedQueue);
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
callAll(mountedQueue);
|
|
90
|
-
}
|
|
61
|
+
this.container!.appendChild(fakeContainer);
|
|
91
62
|
});
|
|
92
63
|
|
|
64
|
+
mount(
|
|
65
|
+
nextProps.children as VNode,
|
|
66
|
+
fakeContainer as any,
|
|
67
|
+
this,
|
|
68
|
+
this.$SVG,
|
|
69
|
+
null,
|
|
70
|
+
mountedQueue,
|
|
71
|
+
);
|
|
72
|
+
|
|
93
73
|
super.$render(lastVNode, nextVNode, parentDom, anchor, mountedQueue);
|
|
94
74
|
}
|
|
95
75
|
|
|
@@ -153,7 +133,7 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
153
133
|
if (!this.container) {
|
|
154
134
|
// find the closest dialog if exists
|
|
155
135
|
let tmp;
|
|
156
|
-
if ((tmp = this.dialog) && (tmp = tmp.dialogRef.value)) {
|
|
136
|
+
if ((tmp = this.dialog) && (tmp !== this.$senior) && (tmp = tmp.dialogRef.value)) {
|
|
157
137
|
this.container = tmp;
|
|
158
138
|
} else {
|
|
159
139
|
this.container = document.body;
|
|
@@ -161,13 +141,3 @@ export class Portal<T extends PortalProps = PortalProps> extends Component<T> {
|
|
|
161
141
|
}
|
|
162
142
|
}
|
|
163
143
|
}
|
|
164
|
-
|
|
165
|
-
function getParent($senior: Component): Component | null {
|
|
166
|
-
while ($senior = $senior.$senior as Component) {
|
|
167
|
-
if (($senior as any)._reactInternals) {
|
|
168
|
-
return $senior;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return null;
|
|
172
|
-
}
|
|
173
|
-
|
|
@@ -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';
|
|
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
|
}
|
|
@@ -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/es/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';
|
|
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/es/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,4 +57,4 @@ 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";
|
package/es/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,5 +59,5 @@ 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 */
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import * as ReactDOM from 'react-dom';
|
|
6
6
|
import { Drawer, Card } from '../../';
|
|
7
7
|
import { Component } from 'intact-react';
|
|
8
|
+
import { wait, dispatchEvent } from '../../../../test/utils';
|
|
8
9
|
describe('Drawer', function () {
|
|
9
10
|
it('should render react element correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
10
11
|
var container, Test;
|
|
@@ -43,4 +44,56 @@ describe('Drawer', function () {
|
|
|
43
44
|
}
|
|
44
45
|
}, _callee);
|
|
45
46
|
})));
|
|
47
|
+
it('should handle event correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
48
|
+
var container, click1, click2, _document$querySelect, element1, element2;
|
|
49
|
+
|
|
50
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
51
|
+
while (1) {
|
|
52
|
+
switch (_context2.prev = _context2.next) {
|
|
53
|
+
case 0:
|
|
54
|
+
container = document.createElement('div');
|
|
55
|
+
document.body.appendChild(container);
|
|
56
|
+
click1 = sinon.spy(function () {
|
|
57
|
+
return console.log(1);
|
|
58
|
+
});
|
|
59
|
+
click2 = sinon.spy(function () {
|
|
60
|
+
return console.log(2);
|
|
61
|
+
});
|
|
62
|
+
ReactDOM.render( /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Drawer, {
|
|
63
|
+
value: true,
|
|
64
|
+
title: "1"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: "click",
|
|
67
|
+
onClick: click1
|
|
68
|
+
}, "click")), /*#__PURE__*/React.createElement(Drawer, {
|
|
69
|
+
value: true,
|
|
70
|
+
placement: "left",
|
|
71
|
+
title: "2"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Card, null, /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "click",
|
|
74
|
+
onClick: click2
|
|
75
|
+
}, "click")))), container);
|
|
76
|
+
_document$querySelect = document.querySelectorAll('.click'), element1 = _document$querySelect[0], element2 = _document$querySelect[1];
|
|
77
|
+
dispatchEvent(element1, 'click');
|
|
78
|
+
_context2.next = 9;
|
|
79
|
+
return wait();
|
|
80
|
+
|
|
81
|
+
case 9:
|
|
82
|
+
expect(click1.callCount).to.eql(1);
|
|
83
|
+
dispatchEvent(element2, 'click');
|
|
84
|
+
_context2.next = 13;
|
|
85
|
+
return wait();
|
|
86
|
+
|
|
87
|
+
case 13:
|
|
88
|
+
expect(click2.callCount).to.eql(1);
|
|
89
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
90
|
+
document.body.removeChild(container);
|
|
91
|
+
|
|
92
|
+
case 16:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context2.stop();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}, _callee2);
|
|
98
|
+
})));
|
|
46
99
|
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
3
|
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
4
|
import React, { createRef } from 'react';
|
|
4
5
|
import * as ReactDOM from 'react-dom';
|
|
5
|
-
import { Dropdown, DropdownMenu, DropdownItem } from '../../';
|
|
6
|
+
import { Dropdown, DropdownMenu, DropdownItem, Dialog, Layout } from '../../';
|
|
6
7
|
import { getElement, wait } from '../../../../test/utils';
|
|
8
|
+
import { Component } from 'intact-react';
|
|
7
9
|
describe('Dropdown', function () {
|
|
8
10
|
it('should save original events', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
11
|
var click, container, button;
|
|
@@ -38,4 +40,108 @@ describe('Dropdown', function () {
|
|
|
38
40
|
}
|
|
39
41
|
}, _callee);
|
|
40
42
|
})));
|
|
43
|
+
it('reproduce #764', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
44
|
+
var _mounted, _updated, Demo, FooDialog, Foo, set, Test, container;
|
|
45
|
+
|
|
46
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
47
|
+
while (1) {
|
|
48
|
+
switch (_context2.prev = _context2.next) {
|
|
49
|
+
case 0:
|
|
50
|
+
_mounted = sinon.spy(function () {
|
|
51
|
+
return console.log('mounted');
|
|
52
|
+
});
|
|
53
|
+
_updated = sinon.spy(function () {
|
|
54
|
+
return console.log('updated');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
Demo = /*#__PURE__*/function (_Component) {
|
|
58
|
+
_inheritsLoose(Demo, _Component);
|
|
59
|
+
|
|
60
|
+
function Demo() {
|
|
61
|
+
return _Component.apply(this, arguments) || this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var _proto = Demo.prototype;
|
|
65
|
+
|
|
66
|
+
_proto.mounted = function mounted() {
|
|
67
|
+
_mounted();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
_proto.updated = function updated() {
|
|
71
|
+
_updated();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return Demo;
|
|
75
|
+
}(Component);
|
|
76
|
+
|
|
77
|
+
Demo.template = "<div>demo {this.get('title')}</div>";
|
|
78
|
+
|
|
79
|
+
FooDialog = function FooDialog() {
|
|
80
|
+
var _React$useState = React.useState({
|
|
81
|
+
title: '0'
|
|
82
|
+
}),
|
|
83
|
+
title = _React$useState[0],
|
|
84
|
+
setTitle = _React$useState[1];
|
|
85
|
+
|
|
86
|
+
React.useEffect(function () {
|
|
87
|
+
setTitle({
|
|
88
|
+
title: '1'
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
91
|
+
return /*#__PURE__*/React.createElement(Dialog, {
|
|
92
|
+
title: title.title,
|
|
93
|
+
value: true
|
|
94
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Demo, {
|
|
95
|
+
title: title.title
|
|
96
|
+
})));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
Foo = function Foo(_ref3) {
|
|
100
|
+
var data = _ref3.data;
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(FooDialog, null));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
Test = function Test() {
|
|
105
|
+
var _React$useState2 = React.useState(false),
|
|
106
|
+
isFoo = _React$useState2[0],
|
|
107
|
+
setIsFoo = _React$useState2[1];
|
|
108
|
+
|
|
109
|
+
var _React$useState3 = React.useState([{
|
|
110
|
+
label: 1,
|
|
111
|
+
key: 1
|
|
112
|
+
}]),
|
|
113
|
+
data = _React$useState3[0],
|
|
114
|
+
setData = _React$useState3[1];
|
|
115
|
+
|
|
116
|
+
set = setIsFoo;
|
|
117
|
+
return /*#__PURE__*/React.createElement(Layout, null, /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
onClick: function onClick() {
|
|
119
|
+
return setIsFoo(!isFoo);
|
|
120
|
+
}
|
|
121
|
+
}, "toggle"), isFoo ? /*#__PURE__*/React.createElement(Foo, {
|
|
122
|
+
key: "foo",
|
|
123
|
+
data: data
|
|
124
|
+
}) : /*#__PURE__*/React.createElement("div", null, "test"));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
container = document.createElement('div');
|
|
128
|
+
document.body.appendChild(container);
|
|
129
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Test, null), container);
|
|
130
|
+
set(true);
|
|
131
|
+
_context2.next = 13;
|
|
132
|
+
return wait(0);
|
|
133
|
+
|
|
134
|
+
case 13:
|
|
135
|
+
expect(getElement('.k-dialog')).to.be.exist;
|
|
136
|
+
expect(_mounted.calledBefore(_updated)).to.be.true;
|
|
137
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
138
|
+
document.body.removeChild(container);
|
|
139
|
+
|
|
140
|
+
case 17:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context2.stop();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}, _callee2);
|
|
146
|
+
})));
|
|
41
147
|
});
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
|
+
import * as ReactDOM from 'react-dom';
|
|
5
|
+
import { Menu, MenuItem } from '../../';
|
|
6
|
+
import { getElement, wait } from '../../../../test/utils';
|
|
7
|
+
describe('Menu', function () {
|
|
8
|
+
it('when we collapse menu, all dropdown menus should be hidden', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
|
+
var container, AsideMenu, setCollapse, Test;
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) {
|
|
12
|
+
switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
container = document.createElement('div');
|
|
15
|
+
document.body.appendChild(container);
|
|
16
|
+
|
|
17
|
+
AsideMenu = function AsideMenu(_ref2) {
|
|
18
|
+
var collapse = _ref2.collapse;
|
|
19
|
+
|
|
20
|
+
var _useState = useState(''),
|
|
21
|
+
selectedKey = _useState[0],
|
|
22
|
+
setSelectedKey = _useState[1];
|
|
23
|
+
|
|
24
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
25
|
+
collapse: collapse,
|
|
26
|
+
selectedKey: selectedKey
|
|
27
|
+
}, /*#__PURE__*/React.createElement(MenuItem, {
|
|
28
|
+
key: "1"
|
|
29
|
+
}, "option 1", /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, {
|
|
30
|
+
key: "1-1"
|
|
31
|
+
}, /*#__PURE__*/React.createElement("span", null, "option 1-1")))), /*#__PURE__*/React.createElement(MenuItem, {
|
|
32
|
+
key: "2"
|
|
33
|
+
}, "option 2", /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, {
|
|
34
|
+
key: "2-1"
|
|
35
|
+
}, /*#__PURE__*/React.createElement("span", null, "option 2-1")))), /*#__PURE__*/React.createElement(MenuItem, {
|
|
36
|
+
key: "3"
|
|
37
|
+
}, "option 2", /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, {
|
|
38
|
+
key: "2-1"
|
|
39
|
+
}, /*#__PURE__*/React.createElement("span", null, "option 2-1")), /*#__PURE__*/React.createElement(MenuItem, {
|
|
40
|
+
key: "2-2"
|
|
41
|
+
}, /*#__PURE__*/React.createElement("span", null, "option 2-1")))));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
Test = function Test() {
|
|
45
|
+
var _useState2 = useState(false),
|
|
46
|
+
collapse = _useState2[0],
|
|
47
|
+
_setCollapse = _useState2[1];
|
|
48
|
+
|
|
49
|
+
setCollapse = _setCollapse;
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
onClick: function onClick() {
|
|
52
|
+
return _setCollapse(!collapse);
|
|
53
|
+
}
|
|
54
|
+
}, "click"), /*#__PURE__*/React.createElement(AsideMenu, {
|
|
55
|
+
collapse: collapse
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Test, null), container);
|
|
60
|
+
setCollapse(true);
|
|
61
|
+
_context.next = 8;
|
|
62
|
+
return wait();
|
|
63
|
+
|
|
64
|
+
case 8:
|
|
65
|
+
expect(getElement('.k-dropdown-menu.k-menu')).to.be.not.exist;
|
|
66
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
67
|
+
document.body.removeChild(container);
|
|
68
|
+
|
|
69
|
+
case 11:
|
|
70
|
+
case "end":
|
|
71
|
+
return _context.stop();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}, _callee);
|
|
75
|
+
})));
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import * as ReactDOM from 'react-dom';
|
|
5
5
|
import { Tooltip, Form, FormItem } from '../../';
|
|
6
6
|
import { getElement, wait, dispatchEvent } from '../../../../test/utils';
|
|
7
|
-
describe('
|
|
7
|
+
describe('Tooltip', function () {
|
|
8
8
|
it('should show Tooltip in append slot', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
9
|
var click, container, trigger;
|
|
10
10
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
package/index.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
|
|
@@ -62,6 +62,6 @@ export * from './components/treeSelect';
|
|
|
62
62
|
export * from './components/upload';
|
|
63
63
|
export * from './components/wave';
|
|
64
64
|
|
|
65
|
-
export const version = '2.0.
|
|
65
|
+
export const version = '2.0.9';
|
|
66
66
|
|
|
67
67
|
/* generate end */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@king-design/intact",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.9",
|
|
4
4
|
"description": "A component library written in Intact for Intact, Vue, React and Angular",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"dayjs": "^1.10.7",
|
|
179
179
|
"downloadjs": "^1.4.7",
|
|
180
180
|
"enquire.js": "^2.1.6",
|
|
181
|
-
"intact": "^3.0.
|
|
181
|
+
"intact": "^3.0.10",
|
|
182
182
|
"monaco-editor": "^0.26.1",
|
|
183
183
|
"mxgraphx": "^4.0.7",
|
|
184
184
|
"resize-observer-polyfill": "^1.5.1",
|