@king-design/react 2.0.8 → 2.0.10
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__/React Demos.md +33 -33
- package/__tests__/components/drawer.spec.tsx +36 -0
- package/__tests__/components/dropdown.spec.tsx +59 -1
- package/__tests__/components/menu.spec.tsx +58 -0
- package/__tests__/components/select.spec.tsx +44 -0
- package/__tests__/components/{form.spec.tsx → tooltip.spec.tsx} +1 -1
- package/components/datepicker/index.spec.js +28 -22
- package/components/dialog/base.d.ts +1 -0
- package/components/dialog/base.js +4 -2
- package/components/dialog/useDraggable.js +4 -1
- package/components/dialog/useEscClosable.js +9 -3
- package/components/drawer/index.js +2 -1
- package/components/portal.d.ts +1 -0
- package/components/portal.js +22 -48
- package/components/select/base.d.ts +1 -0
- package/components/select/base.js +1 -0
- package/components/select/useBaseLabel.d.ts +1 -0
- package/components/select/useBaseLabel.js +5 -1
- package/hooks/useDraggable.d.ts +1 -0
- package/hooks/useDraggable.js +2 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +2 -2
- package/yarn-error.log +0 -546
|
@@ -2,6 +2,7 @@ import React, {createRef} from 'react';
|
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
3
|
import {Drawer, Card, Button} from '../../';
|
|
4
4
|
import {Component} from 'intact-react';
|
|
5
|
+
import {getElement, wait, dispatchEvent} from '../../../../test/utils';
|
|
5
6
|
|
|
6
7
|
describe('Drawer', () => {
|
|
7
8
|
it('should render react element correctly', async () => {
|
|
@@ -27,4 +28,39 @@ describe('Drawer', () => {
|
|
|
27
28
|
ReactDOM.unmountComponentAtNode(container);
|
|
28
29
|
document.body.removeChild(container);
|
|
29
30
|
});
|
|
31
|
+
|
|
32
|
+
it('should handle event correctly', async () => {
|
|
33
|
+
const container = document.createElement('div');
|
|
34
|
+
document.body.appendChild(container);
|
|
35
|
+
|
|
36
|
+
const click1 = sinon.spy(() => console.log(1));
|
|
37
|
+
const click2 = sinon.spy(() => console.log(2));
|
|
38
|
+
|
|
39
|
+
ReactDOM.render(
|
|
40
|
+
<div>
|
|
41
|
+
<Drawer value={true} title="1">
|
|
42
|
+
<div className="click" onClick={click1}>click</div>
|
|
43
|
+
</Drawer>
|
|
44
|
+
<Drawer value={true} placement="left" title="2">
|
|
45
|
+
<Card>
|
|
46
|
+
<div className="click" onClick={click2}>click</div>
|
|
47
|
+
</Card>
|
|
48
|
+
</Drawer>
|
|
49
|
+
</div>,
|
|
50
|
+
container
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const [element1, element2] = document.querySelectorAll<HTMLElement>('.click');
|
|
54
|
+
|
|
55
|
+
dispatchEvent(element1, 'click');
|
|
56
|
+
await wait();
|
|
57
|
+
expect(click1.callCount).to.eql(1);
|
|
58
|
+
|
|
59
|
+
dispatchEvent(element2, 'click');
|
|
60
|
+
await wait();
|
|
61
|
+
expect(click2.callCount).to.eql(1);
|
|
62
|
+
|
|
63
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
64
|
+
document.body.removeChild(container);
|
|
65
|
+
});
|
|
30
66
|
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, {createRef} from 'react';
|
|
2
2
|
import * as ReactDOM from 'react-dom';
|
|
3
|
-
import {Dropdown, DropdownMenu, DropdownItem} from '../../';
|
|
3
|
+
import {Dropdown, DropdownMenu, DropdownItem, Tree, Dialog, Layout} from '../../';
|
|
4
4
|
import {getElement, wait} from '../../../../test/utils';
|
|
5
|
+
import {Component} from 'intact-react';
|
|
5
6
|
|
|
6
7
|
describe('Dropdown', () => {
|
|
7
8
|
it('should save original events', async () => {
|
|
@@ -32,4 +33,61 @@ describe('Dropdown', () => {
|
|
|
32
33
|
ReactDOM.unmountComponentAtNode(container);
|
|
33
34
|
document.body.removeChild(container);
|
|
34
35
|
});
|
|
36
|
+
|
|
37
|
+
it('reproduce #764', async () => {
|
|
38
|
+
const mounted = sinon.spy(() => console.log('mounted'));
|
|
39
|
+
const updated = sinon.spy(() => console.log('updated'));
|
|
40
|
+
class Demo extends Component<{title: string}> {
|
|
41
|
+
static template = `<div>demo {this.get('title')}</div>`;
|
|
42
|
+
|
|
43
|
+
mounted() {
|
|
44
|
+
mounted();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
updated() {
|
|
48
|
+
updated();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const FooDialog: React.FC = () => {
|
|
52
|
+
const [title, setTitle] = React.useState({title: '0'});
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
setTitle({title: '1'});
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
return <Dialog title={title.title} value={true}>
|
|
58
|
+
<div><Demo title={title.title} /></div>
|
|
59
|
+
</Dialog>
|
|
60
|
+
};
|
|
61
|
+
const Foo: React.FC<{data: any}> = ({data}) => {
|
|
62
|
+
return <div>
|
|
63
|
+
<FooDialog />
|
|
64
|
+
</div>
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
let set: any;
|
|
68
|
+
const Test: React.FC = () => {
|
|
69
|
+
const [isFoo, setIsFoo] = React.useState(false);
|
|
70
|
+
const [data, setData] = React.useState<any>([{label: 1, key: 1}]);
|
|
71
|
+
set = setIsFoo;
|
|
72
|
+
|
|
73
|
+
return <Layout>
|
|
74
|
+
<div onClick={() => setIsFoo(!isFoo)}>toggle</div>
|
|
75
|
+
{isFoo ? <Foo key="foo" data={data} /> : <div>test</div>}
|
|
76
|
+
</Layout>
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const container = document.createElement('div');
|
|
80
|
+
document.body.appendChild(container);
|
|
81
|
+
ReactDOM.render(<Test />, container);
|
|
82
|
+
|
|
83
|
+
set(true);
|
|
84
|
+
|
|
85
|
+
await wait(0)
|
|
86
|
+
|
|
87
|
+
expect(getElement('.k-dialog')).to.be.exist;
|
|
88
|
+
expect(mounted.calledBefore(updated)).to.be.true;
|
|
89
|
+
|
|
90
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
91
|
+
document.body.removeChild(container);
|
|
92
|
+
});
|
|
35
93
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, {createRef, useState, useEffect} from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import {Menu, MenuItem, Layout, Aside} from '../../';
|
|
4
|
+
import {getElement, wait, dispatchEvent} from '../../../../test/utils';
|
|
5
|
+
|
|
6
|
+
describe('Menu', () => {
|
|
7
|
+
it('when we collapse menu, all dropdown menus should be hidden', async () => {
|
|
8
|
+
const container = document.createElement('div');
|
|
9
|
+
document.body.appendChild(container);
|
|
10
|
+
|
|
11
|
+
const AsideMenu = ({collapse}: {collapse: boolean}) => {
|
|
12
|
+
const [selectedKey, setSelectedKey] = useState('');
|
|
13
|
+
|
|
14
|
+
return <Menu collapse={collapse} selectedKey={selectedKey}>
|
|
15
|
+
<MenuItem key="1">
|
|
16
|
+
option 1
|
|
17
|
+
<Menu>
|
|
18
|
+
<MenuItem key="1-1"><span>option 1-1</span></MenuItem>
|
|
19
|
+
</Menu>
|
|
20
|
+
</MenuItem>
|
|
21
|
+
<MenuItem key="2">
|
|
22
|
+
option 2
|
|
23
|
+
<Menu>
|
|
24
|
+
<MenuItem key="2-1"><span>option 2-1</span></MenuItem>
|
|
25
|
+
</Menu>
|
|
26
|
+
</MenuItem>
|
|
27
|
+
<MenuItem key="3">
|
|
28
|
+
option 2
|
|
29
|
+
<Menu>
|
|
30
|
+
<MenuItem key="2-1"><span>option 2-1</span></MenuItem>
|
|
31
|
+
<MenuItem key="2-2"><span>option 2-1</span></MenuItem>
|
|
32
|
+
</Menu>
|
|
33
|
+
</MenuItem>
|
|
34
|
+
</Menu>
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
let setCollapse: any;
|
|
38
|
+
const Test = () => {
|
|
39
|
+
const [collapse, _setCollapse] = useState(false);
|
|
40
|
+
setCollapse = _setCollapse;
|
|
41
|
+
|
|
42
|
+
return <>
|
|
43
|
+
<div onClick={() => _setCollapse(!collapse)}>click</div>
|
|
44
|
+
<AsideMenu collapse={collapse} />
|
|
45
|
+
</>
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ReactDOM.render(<Test />, container);
|
|
49
|
+
|
|
50
|
+
setCollapse!(true);
|
|
51
|
+
|
|
52
|
+
await wait();
|
|
53
|
+
expect(getElement('.k-dropdown-menu.k-menu')).to.be.not.exist;
|
|
54
|
+
|
|
55
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
56
|
+
document.body.removeChild(container);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React, {createRef, useState} from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { Select, OptionGroup, Option } from '../../';
|
|
4
|
+
import {getElement, wait, dispatchEvent} from '../../../../test/utils';
|
|
5
|
+
|
|
6
|
+
describe('Select', () => {
|
|
7
|
+
it('should conrrectly show value in filterable mode', async () => {
|
|
8
|
+
const container = document.createElement('div');
|
|
9
|
+
document.body.appendChild(container);
|
|
10
|
+
|
|
11
|
+
const Test = () => {
|
|
12
|
+
const [value, setValue] = useState('');
|
|
13
|
+
const onChangeValue = (v: string | null | undefined) => {
|
|
14
|
+
setValue(v ?? '');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return <Select
|
|
18
|
+
value={value}
|
|
19
|
+
onChangeValue={onChangeValue}
|
|
20
|
+
card
|
|
21
|
+
filterable
|
|
22
|
+
>
|
|
23
|
+
<OptionGroup slotLabel={<div>xxx</div>}>
|
|
24
|
+
<Option value="q">Q</Option>
|
|
25
|
+
<Option value="p">P</Option>
|
|
26
|
+
</OptionGroup>
|
|
27
|
+
</Select>;
|
|
28
|
+
}
|
|
29
|
+
ReactDOM.render(<Test />, container);
|
|
30
|
+
|
|
31
|
+
const trigger = container.querySelector('.k-select') as HTMLElement;
|
|
32
|
+
trigger.click();
|
|
33
|
+
|
|
34
|
+
await wait();
|
|
35
|
+
const dropdown = getElement('.k-select-menu')!;
|
|
36
|
+
dropdown.querySelector<HTMLElement>('.k-dropdown-item')!.click();
|
|
37
|
+
|
|
38
|
+
await wait();
|
|
39
|
+
expect(container.querySelector<HTMLInputElement>('.k-input-inner')!.value).to.eql('Q');
|
|
40
|
+
|
|
41
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
42
|
+
document.body.removeChild(container);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -3,7 +3,7 @@ import * as ReactDOM from 'react-dom';
|
|
|
3
3
|
import { Tooltip, Form, FormItem } from '../../';
|
|
4
4
|
import {getElement, wait, dispatchEvent} from '../../../../test/utils';
|
|
5
5
|
|
|
6
|
-
describe('
|
|
6
|
+
describe('Tooltip', () => {
|
|
7
7
|
it('should show Tooltip in append slot', async () => {
|
|
8
8
|
const click = sinon.spy(() => console.log(1));
|
|
9
9
|
const container = document.createElement('div');
|
|
@@ -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
|
}
|
|
@@ -30,7 +30,8 @@ var typeDefs = {
|
|
|
30
30
|
terminate: Function,
|
|
31
31
|
escClosable: Boolean,
|
|
32
32
|
width: [String, Number],
|
|
33
|
-
mode: ['destroy', 'hide']
|
|
33
|
+
mode: ['destroy', 'hide'],
|
|
34
|
+
draggable: Boolean
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
var defaults = function defaults() {
|
|
@@ -43,7 +44,8 @@ var defaults = function defaults() {
|
|
|
43
44
|
overlay: true,
|
|
44
45
|
closable: true,
|
|
45
46
|
escClosable: true,
|
|
46
|
-
mode: 'hide'
|
|
47
|
+
mode: 'hide',
|
|
48
|
+
draggable: true
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
1
2
|
import { useInstance, onUnmounted } from 'intact-react';
|
|
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-react';
|
|
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
53
|
|
|
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
|
-
|
|
69
|
-
if (parent) {
|
|
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
|
};
|
|
@@ -117,26 +97,20 @@ export var Portal = /*#__PURE__*/function (_Component) {
|
|
|
117
97
|
|
|
118
98
|
if (!this.container) {
|
|
119
99
|
// find the closest dialog if exists
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
100
|
+
this.container = parentDom.closest('.k-dialog') || document.body;
|
|
101
|
+
/**
|
|
102
|
+
* @FIXME: We cannot get parent ref from sub component in Vue
|
|
103
|
+
*/
|
|
104
|
+
// find the closest dialog if exists
|
|
105
|
+
// let tmp;
|
|
106
|
+
// if ((tmp = this.dialog) && (tmp !== this.$senior) && (tmp = tmp.dialogRef.value)) {
|
|
107
|
+
// this.container = tmp;
|
|
108
|
+
// } else {
|
|
109
|
+
// this.container = document.body;
|
|
110
|
+
// }
|
|
127
111
|
}
|
|
128
112
|
};
|
|
129
113
|
|
|
130
114
|
return Portal;
|
|
131
115
|
}(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
|
-
}
|
|
116
|
+
Portal.typeDefs = typeDefs;
|
|
@@ -35,6 +35,7 @@ export interface BaseSelectBlocks<V> {
|
|
|
35
35
|
suffix: null;
|
|
36
36
|
}
|
|
37
37
|
export declare abstract class BaseSelect<T extends BaseSelectProps<any> = BaseSelectProps<any>, E extends BaseSelectEvents = BaseSelectEvents, B extends BaseSelectBlocks<any> = BaseSelectBlocks<any>> extends Component<T, E, B> {
|
|
38
|
+
static $doubleVNodes: boolean;
|
|
38
39
|
static template: string | import("intact").Template<any>;
|
|
39
40
|
static typeDefs: Required<TypeDefs<BaseSelectProps<any, boolean, any>>>;
|
|
40
41
|
static defaults: () => Partial<BaseSelectProps<any, boolean, any>>;
|
|
@@ -2,6 +2,7 @@ import { Children, Component } from 'intact-react';
|
|
|
2
2
|
declare type BaseLabelProps = {
|
|
3
3
|
value: any;
|
|
4
4
|
multiple: boolean;
|
|
5
|
+
filterable: boolean;
|
|
5
6
|
};
|
|
6
7
|
export declare function useBaseLabel<T, C extends Component<P>, P extends BaseLabelProps>(getChildren: () => T, findLabelFromChildren: (children: T, value: any) => Children): {
|
|
7
8
|
getLabel: () => Children;
|
|
@@ -2,7 +2,7 @@ import _Map from "@babel/runtime-corejs3/core-js/map";
|
|
|
2
2
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
|
|
3
3
|
import { useInstance } from 'intact-react';
|
|
4
4
|
import { isNullOrUndefined, isStringOrNumber } from 'intact-shared';
|
|
5
|
-
import { isEmptyString } from '../utils';
|
|
5
|
+
import { isEmptyString, getTextByChildren } from '../utils';
|
|
6
6
|
export function useBaseLabel(getChildren, findLabelFromChildren) {
|
|
7
7
|
var instance = useInstance();
|
|
8
8
|
var labelMap = new _Map();
|
|
@@ -36,6 +36,10 @@ export function useBaseLabel(getChildren, findLabelFromChildren) {
|
|
|
36
36
|
if (isNullOrUndefined(label)) {
|
|
37
37
|
label = labelMap.get(value);
|
|
38
38
|
} else {
|
|
39
|
+
if (instance.get('filterable')) {
|
|
40
|
+
label = getTextByChildren(label);
|
|
41
|
+
}
|
|
42
|
+
|
|
39
43
|
labelMap.set(value, label);
|
|
40
44
|
}
|
|
41
45
|
|
package/hooks/useDraggable.d.ts
CHANGED
package/hooks/useDraggable.js
CHANGED
|
@@ -5,7 +5,7 @@ export function useDraggable(options) {
|
|
|
5
5
|
|
|
6
6
|
function start(e) {
|
|
7
7
|
// ignore if it isn't left key
|
|
8
|
-
if (e.which !== 1) return;
|
|
8
|
+
if (e.which !== 1 || options.disable != null && options.disable()) return;
|
|
9
9
|
dragging.set(true);
|
|
10
10
|
|
|
11
11
|
if (options.onStart) {
|
|
@@ -17,6 +17,7 @@ export function useDraggable(options) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function move(e) {
|
|
20
|
+
if (options.disable != null && options.disable()) return;
|
|
20
21
|
e.preventDefault();
|
|
21
22
|
|
|
22
23
|
if (dragging.value) {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.10
|
|
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.10";
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
export {normalize} from 'intact-react';
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.0.
|
|
2
|
+
* @king-design v2.0.10
|
|
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.10';
|
|
63
63
|
/* generate end */
|
|
64
64
|
|
|
65
65
|
export {normalize} from 'intact-react';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@king-design/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "King-Design UI components for React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dayjs": "^1.10.7",
|
|
38
38
|
"downloadjs": "^1.4.7",
|
|
39
39
|
"enquire.js": "^2.1.6",
|
|
40
|
-
"intact-react": "3.0.
|
|
40
|
+
"intact-react": "3.0.11",
|
|
41
41
|
"monaco-editor": "^0.26.1",
|
|
42
42
|
"mxgraphx": "^4.0.7",
|
|
43
43
|
"resize-observer-polyfill": "^1.5.1",
|