@king-design/intact 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/components/datepicker/index.spec.ts +16 -10
- package/components/dialog/base.ts +3 -0
- package/components/dialog/index.md +1 -0
- package/components/dialog/useDraggable.ts +4 -2
- package/components/dialog/useEscClosable.ts +7 -3
- package/components/drawer/index.ts +1 -0
- package/components/portal.ts +30 -54
- package/components/select/base.ts +3 -0
- package/components/select/useBaseLabel.ts +6 -1
- package/dist/fonts/ionicons.eot +0 -0
- package/dist/fonts/ionicons.svg +2230 -0
- package/dist/fonts/ionicons.ttf +0 -0
- package/dist/fonts/ionicons.woff +0 -0
- package/dist/i18n/en-US.js +218 -0
- package/dist/i18n/en-US.min.js +1 -0
- package/dist/kpc.css +3 -0
- package/dist/kpc.js +39860 -0
- package/dist/kpc.min.js +1 -0
- package/dist/kpc.react.js +90483 -0
- package/dist/kpc.react.min.js +1 -0
- package/dist/kpc.vue.js +48096 -0
- package/dist/kpc.vue.min.js +1 -0
- package/dist/ksyun.css +3 -0
- package/es/components/datepicker/index.spec.js +28 -22
- package/es/components/dialog/base.d.ts +1 -0
- package/es/components/dialog/base.js +4 -2
- package/es/components/dialog/useDraggable.js +4 -1
- package/es/components/dialog/useEscClosable.js +9 -3
- package/es/components/drawer/index.js +2 -1
- package/es/components/portal.d.ts +1 -0
- package/es/components/portal.js +22 -48
- package/es/components/select/base.d.ts +1 -0
- package/es/components/select/base.js +1 -0
- package/es/components/select/useBaseLabel.d.ts +1 -0
- package/es/components/select/useBaseLabel.js +5 -1
- package/es/hooks/useDraggable.d.ts +1 -0
- package/es/hooks/useDraggable.js +2 -1
- 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/select.spec.d.ts +1 -0
- package/es/packages/kpc-react/__tests__/components/select.spec.js +64 -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/hooks/useDraggable.ts +4 -1
- package/index.ts +2 -2
- package/package.json +3 -3
|
@@ -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
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';
|
|
|
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';
|
|
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/es/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/es/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,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.10";
|
package/es/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,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.10';
|
|
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 {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { Select, OptionGroup, Option } from '../../';
|
|
6
|
+
import { getElement, wait } from '../../../../test/utils';
|
|
7
|
+
describe('Select', function () {
|
|
8
|
+
it('should conrrectly show value in filterable mode', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
|
+
var container, Test, trigger, dropdown;
|
|
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
|
+
Test = function Test() {
|
|
18
|
+
var _useState = useState(''),
|
|
19
|
+
value = _useState[0],
|
|
20
|
+
setValue = _useState[1];
|
|
21
|
+
|
|
22
|
+
var onChangeValue = function onChangeValue(v) {
|
|
23
|
+
setValue(v != null ? v : '');
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
27
|
+
value: value,
|
|
28
|
+
onChangeValue: onChangeValue,
|
|
29
|
+
card: true,
|
|
30
|
+
filterable: true
|
|
31
|
+
}, /*#__PURE__*/React.createElement(OptionGroup, {
|
|
32
|
+
slotLabel: /*#__PURE__*/React.createElement("div", null, "xxx")
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Option, {
|
|
34
|
+
value: "q"
|
|
35
|
+
}, "Q"), /*#__PURE__*/React.createElement(Option, {
|
|
36
|
+
value: "p"
|
|
37
|
+
}, "P")));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
ReactDOM.render( /*#__PURE__*/React.createElement(Test, null), container);
|
|
41
|
+
trigger = container.querySelector('.k-select');
|
|
42
|
+
trigger.click();
|
|
43
|
+
_context.next = 8;
|
|
44
|
+
return wait();
|
|
45
|
+
|
|
46
|
+
case 8:
|
|
47
|
+
dropdown = getElement('.k-select-menu');
|
|
48
|
+
dropdown.querySelector('.k-dropdown-item').click();
|
|
49
|
+
_context.next = 12;
|
|
50
|
+
return wait();
|
|
51
|
+
|
|
52
|
+
case 12:
|
|
53
|
+
expect(container.querySelector('.k-input-inner').value).to.eql('Q');
|
|
54
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
55
|
+
document.body.removeChild(container);
|
|
56
|
+
|
|
57
|
+
case 15:
|
|
58
|
+
case "end":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, _callee);
|
|
63
|
+
})));
|
|
64
|
+
});
|
|
@@ -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/hooks/useDraggable.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type Options = {
|
|
|
5
5
|
onStart?: (e: MouseEvent) => void,
|
|
6
6
|
onMove: (e: MouseEvent) => void,
|
|
7
7
|
onEnd?: (e?: MouseEvent) => void,
|
|
8
|
+
disable?: () => boolean,
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function useDraggable(options: Options) {
|
|
@@ -12,7 +13,7 @@ export function useDraggable(options: Options) {
|
|
|
12
13
|
|
|
13
14
|
function start(e: MouseEvent) {
|
|
14
15
|
// ignore if it isn't left key
|
|
15
|
-
if (e.which !== 1) return;
|
|
16
|
+
if (e.which !== 1 || options.disable?.()) return;
|
|
16
17
|
|
|
17
18
|
dragging.set(true);
|
|
18
19
|
|
|
@@ -25,6 +26,8 @@ export function useDraggable(options: Options) {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function move(e: MouseEvent) {
|
|
29
|
+
if (options.disable?.()) return;
|
|
30
|
+
|
|
28
31
|
e.preventDefault();
|
|
29
32
|
|
|
30
33
|
if (dragging.value) {
|
package/index.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
|
|
@@ -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.10';
|
|
66
66
|
|
|
67
67
|
/* generate end */
|