@king-design/react 2.0.17-beta.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/__snapshots__/React Demos.md +210 -94
- package/__tests__/components/cascader.spec.tsx +53 -0
- package/components/cascader/index.d.ts +22 -11
- package/components/cascader/index.js +9 -12
- package/components/cascader/index.spec.js +81 -0
- package/components/cascader/index.vdt.js +10 -8
- package/components/cascader/useFields.d.ts +2 -0
- package/components/cascader/useFields.js +18 -0
- package/components/cascader/useFilterable.d.ts +2 -1
- package/components/cascader/useFilterable.js +17 -6
- package/components/cascader/useLabel.d.ts +2 -1
- package/components/cascader/useLabel.js +4 -4
- package/components/cascader/useLoad.d.ts +2 -1
- package/components/cascader/useLoad.js +9 -7
- package/components/colorpicker/index.d.ts +2 -0
- package/components/colorpicker/index.js +7 -2
- package/components/colorpicker/index.vdt.js +3 -6
- package/components/dialog/index.spec.js +2 -2
- package/components/dropdown/dropdown.d.ts +6 -5
- package/components/dropdown/dropdown.js +40 -69
- package/components/dropdown/index.spec.js +96 -17
- package/components/dropdown/item.d.ts +1 -1
- package/components/dropdown/item.js +19 -7
- package/components/dropdown/usePosition.js +11 -2
- package/components/editable/index.d.ts +1 -0
- package/components/editable/index.js +20 -6
- package/components/editable/index.vdt.js +2 -1
- package/components/input/index.d.ts +10 -2
- package/components/input/index.js +10 -3
- package/components/input/index.spec.js +169 -1
- package/components/input/index.vdt.js +26 -7
- package/components/input/styles.js +8 -3
- package/components/input/useAutoRows.d.ts +2 -0
- package/components/input/useAutoRows.js +79 -0
- package/components/input/useAutoWidth.js +13 -3
- package/components/input/useShowPassword.d.ts +7 -0
- package/components/input/useShowPassword.js +31 -0
- package/components/menu/index.spec.js +26 -15
- package/components/menu/item.d.ts +2 -0
- package/components/menu/item.js +5 -0
- package/components/pagination/index.js +2 -1
- package/components/pagination/index.spec.js +51 -4
- package/components/portal.d.ts +6 -2
- package/components/portal.js +4 -3
- package/components/position.js +2 -1
- package/components/select/base.d.ts +2 -1
- package/components/select/base.js +3 -1
- package/components/select/base.vdt.js +3 -1
- package/components/table/cell.js +1 -6
- package/components/table/index.spec.js +130 -19
- package/components/table/row.d.ts +1 -1
- package/components/table/row.js +2 -1
- package/components/table/styles.js +1 -1
- package/components/table/table.d.ts +15 -0
- package/components/table/table.js +16 -7
- package/components/table/table.vdt.js +20 -6
- package/components/table/useChecked.d.ts +3 -2
- package/components/table/useChecked.js +23 -12
- package/components/table/useDisableRow.d.ts +2 -1
- package/components/table/useDisableRow.js +4 -4
- package/components/table/useDraggable.d.ts +3 -2
- package/components/table/useDraggable.js +11 -8
- package/components/table/useGroup.js +3 -0
- package/components/table/useMerge.d.ts +2 -1
- package/components/table/useMerge.js +5 -4
- package/components/table/usePagination.d.ts +8 -0
- package/components/table/usePagination.js +81 -0
- package/components/table/useTree.d.ts +2 -1
- package/components/table/useTree.js +3 -4
- package/components/tooltip/content.d.ts +1 -0
- package/components/tooltip/content.js +18 -1
- package/components/tooltip/content.vdt.js +3 -1
- package/components/tooltip/index.spec.js +117 -10
- package/components/tooltip/styles.d.ts +22 -0
- package/components/tooltip/styles.js +1 -1
- package/components/tooltip/tooltip.d.ts +1 -0
- package/components/tooltip/tooltip.js +11 -0
- package/components/virtual.d.ts +8 -0
- package/components/virtual.js +126 -0
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/package.json +2 -2
- package/styles/fonts/ionicons.js +1 -1
- package/yarn-error.log +544 -0
|
@@ -3,14 +3,15 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
3
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
4
4
|
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
5
5
|
import { __decorate } from "tslib";
|
|
6
|
-
import { Component, createVNode as h,
|
|
7
|
-
import { bind,
|
|
8
|
-
import {
|
|
6
|
+
import { Component, createVNode as h, provide, inject, findDomFromVNode, nextTick } from 'intact-react';
|
|
7
|
+
import { bind, getRestProps } from '../utils';
|
|
8
|
+
import { noop } from 'intact-shared';
|
|
9
9
|
import { cx } from '@emotion/css';
|
|
10
10
|
import { useDocumentClick, containsOrEqual } from '../../hooks/useDocumentClick';
|
|
11
11
|
import { Portal } from '../portal';
|
|
12
12
|
import { useShowHideEvents } from '../../hooks/useShowHideEvents';
|
|
13
13
|
import { usePosition } from './usePosition';
|
|
14
|
+
import { Virtual } from '../virtual';
|
|
14
15
|
export var DROPDOWN = 'Dropdown';
|
|
15
16
|
export var ROOT_DROPDOWN = 'RootDropdown';
|
|
16
17
|
var typeDefs = {
|
|
@@ -20,13 +21,13 @@ var typeDefs = {
|
|
|
20
21
|
position: [Object, 'left', 'bottom', 'right', 'top'],
|
|
21
22
|
// Event is undefined in NodeJs
|
|
22
23
|
of: ['self', 'parent', typeof Event === 'undefined' ? undefined : Event],
|
|
23
|
-
container: [String, Function]
|
|
24
|
+
container: [String, Function],
|
|
25
|
+
collison: ['none', 'fit', 'flip', 'flipfit', Array]
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
var defaults = function defaults() {
|
|
27
29
|
return {
|
|
28
30
|
trigger: 'hover',
|
|
29
|
-
position: {},
|
|
30
31
|
of: 'self'
|
|
31
32
|
};
|
|
32
33
|
};
|
|
@@ -37,6 +38,8 @@ var events = {
|
|
|
37
38
|
hide: true,
|
|
38
39
|
mouseenter: true,
|
|
39
40
|
mouseleave: true,
|
|
41
|
+
click: true,
|
|
42
|
+
contextmenu: true,
|
|
40
43
|
positioned: true
|
|
41
44
|
};
|
|
42
45
|
export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
@@ -58,7 +61,6 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
58
61
|
_this.showedDropdown = null;
|
|
59
62
|
_this.positionHook = usePosition();
|
|
60
63
|
_this.timer = undefined;
|
|
61
|
-
_this.triggerProps = null;
|
|
62
64
|
return _this;
|
|
63
65
|
}
|
|
64
66
|
|
|
@@ -96,7 +98,13 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
96
98
|
|
|
97
99
|
if (this.get('disabled')) return;
|
|
98
100
|
clearTimeout(this.timer);
|
|
99
|
-
this.set('value', true);
|
|
101
|
+
this.set('value', true); // should show parent dropdown
|
|
102
|
+
|
|
103
|
+
var parentDropdown = this.dropdown;
|
|
104
|
+
|
|
105
|
+
if (parentDropdown) {
|
|
106
|
+
parentDropdown.show();
|
|
107
|
+
}
|
|
100
108
|
|
|
101
109
|
if (shouldFocus) {
|
|
102
110
|
nextTick(function () {
|
|
@@ -114,10 +122,16 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
114
122
|
|
|
115
123
|
if (this.get('disabled')) return;
|
|
116
124
|
if (!this.get('value')) return;
|
|
125
|
+
var showedDropdown = this.showedDropdown;
|
|
126
|
+
|
|
127
|
+
if (showedDropdown) {
|
|
128
|
+
showedDropdown.hide(immediately);
|
|
129
|
+
}
|
|
117
130
|
|
|
118
131
|
if (immediately) {
|
|
119
132
|
this.set('value', false);
|
|
120
133
|
} else {
|
|
134
|
+
clearTimeout(this.timer);
|
|
121
135
|
this.timer = window.setTimeout(function () {
|
|
122
136
|
_this4.set('value', false);
|
|
123
137
|
}, 200);
|
|
@@ -137,23 +151,24 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
137
151
|
};
|
|
138
152
|
|
|
139
153
|
_proto.onEnter = function onEnter(e) {
|
|
140
|
-
this.callOriginalCallback(e.type === 'click' ? 'ev-click' : 'ev-mouseenter', e);
|
|
141
154
|
this.show();
|
|
155
|
+
this.trigger(e.type, e);
|
|
142
156
|
};
|
|
143
157
|
|
|
144
158
|
_proto.onContextMenu = function onContextMenu(e) {
|
|
145
|
-
this.callOriginalCallback('ev-contextmenu', e);
|
|
146
159
|
e.preventDefault();
|
|
147
160
|
this.set('of', e);
|
|
148
161
|
this.show();
|
|
162
|
+
this.trigger('contextmenu', e);
|
|
149
163
|
};
|
|
150
164
|
|
|
151
165
|
_proto.onLeave = function onLeave(e) {
|
|
152
|
-
this.callOriginalCallback('ev-mouseleave', e);
|
|
153
166
|
this.hide();
|
|
167
|
+
this.trigger(e.type, e);
|
|
154
168
|
};
|
|
155
169
|
|
|
156
|
-
_proto.initEventCallbacks = function initEventCallbacks(
|
|
170
|
+
_proto.initEventCallbacks = function initEventCallbacks() {
|
|
171
|
+
var trigger = this.get('trigger');
|
|
157
172
|
var props = {};
|
|
158
173
|
|
|
159
174
|
switch (trigger) {
|
|
@@ -180,51 +195,6 @@ export var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
180
195
|
return props;
|
|
181
196
|
};
|
|
182
197
|
|
|
183
|
-
_proto.callOriginalCallback = function callOriginalCallback(name, e) {
|
|
184
|
-
var callback = this.triggerProps[name];
|
|
185
|
-
var callbackOnDropdown = this.get(name);
|
|
186
|
-
if (isFunction(callback)) callback(e);
|
|
187
|
-
if (isFunction(callbackOnDropdown)) callbackOnDropdown(e);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
_proto.normalizeTriggerProps = function normalizeTriggerProps(props) {
|
|
191
|
-
// if use kpc in react or vue, normalize props by Wrapper.props.vnode;
|
|
192
|
-
var vnode = props.vnode;
|
|
193
|
-
if (!vnode) return props; // maybe we render the intact component in react slot property, in this case
|
|
194
|
-
// the $isReact is false. so use the vnode $$typeof field as gauge
|
|
195
|
-
|
|
196
|
-
if (vnode.$$typeof || this.$isVueNext) {
|
|
197
|
-
var _props = vnode.props;
|
|
198
|
-
if (!_props) return props;
|
|
199
|
-
return {
|
|
200
|
-
vnode: vnode,
|
|
201
|
-
'ev-click': _props.onClick,
|
|
202
|
-
'ev-mouseenter': _props.onMouseEnter,
|
|
203
|
-
'ev-mouseleave': _props.onMouseLeave,
|
|
204
|
-
'ev-contextmenu': _props.onContextMenu,
|
|
205
|
-
className: _props.className || _props.class
|
|
206
|
-
/* vue-next */
|
|
207
|
-
|
|
208
|
-
};
|
|
209
|
-
} else if (this.$isVue) {
|
|
210
|
-
var data = vnode.data;
|
|
211
|
-
var on = data && data.on || EMPTY_OBJ;
|
|
212
|
-
var ret = {
|
|
213
|
-
vnode: vnode
|
|
214
|
-
};
|
|
215
|
-
['click', 'mouseenter', 'mouseleave', 'contextmenu'].forEach(function (event) {
|
|
216
|
-
var method = on[event];
|
|
217
|
-
|
|
218
|
-
if (method) {
|
|
219
|
-
ret["ev-" + event] = method;
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
return ret;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return props;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
198
|
return Dropdown;
|
|
229
199
|
}(Component);
|
|
230
200
|
Dropdown.$doubleVNodes = true;
|
|
@@ -254,21 +224,22 @@ Dropdown.template = function () {
|
|
|
254
224
|
var _children = children,
|
|
255
225
|
trigger = _children[0],
|
|
256
226
|
menu = _children[1];
|
|
257
|
-
var
|
|
258
|
-
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
});
|
|
267
|
-
clonedTrigger.className = className;
|
|
227
|
+
var props = this.initEventCallbacks();
|
|
228
|
+
|
|
229
|
+
var _this$get = this.get(),
|
|
230
|
+
className = _this$get.className,
|
|
231
|
+
value = _this$get.value,
|
|
232
|
+
container = _this$get.container;
|
|
233
|
+
|
|
234
|
+
className = cx((_cx = {
|
|
235
|
+
'k-dropdown-open': value
|
|
236
|
+
}, _cx[className] = !!className, _cx));
|
|
268
237
|
this.menuVNode = menu;
|
|
269
|
-
return [
|
|
238
|
+
return [h(Virtual, _extends({}, props, getRestProps(this), {
|
|
239
|
+
className: className
|
|
240
|
+
}), trigger), h(Portal, {
|
|
270
241
|
children: menu,
|
|
271
|
-
container:
|
|
242
|
+
container: container
|
|
272
243
|
})];
|
|
273
244
|
};
|
|
274
245
|
|
|
@@ -8,6 +8,7 @@ import { Dropdown, DropdownMenu, DropdownItem } from '../dropdown';
|
|
|
8
8
|
import BasicDemo from '~/components/dropdown/demos/basic';
|
|
9
9
|
import NestedDemo from '~/components/dropdown/demos/nested';
|
|
10
10
|
import ContextMenuDemo from '~/components/dropdown/demos/contextmenu';
|
|
11
|
+
import TooltipDemo from '~/components/dropdown/demos/tooltip';
|
|
11
12
|
describe('Dropdown', function () {
|
|
12
13
|
afterEach(function (done) {
|
|
13
14
|
unmount();
|
|
@@ -113,42 +114,61 @@ describe('Dropdown', function () {
|
|
|
113
114
|
}, _callee2);
|
|
114
115
|
})));
|
|
115
116
|
it('nested dropdown', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
116
|
-
var _mount3, instance, element, dropdown, _dropdown$querySelect, hoverItem, clickItem, clickSubDropdown, hoverSubDropdown;
|
|
117
|
+
var _mount3, instance, element, dropdown, _dropdown$querySelect, hoverItem, clickItem, clickSubDropdown, hoverSubDropdown, _hoverSubDropdown$que, hoverItem1, hoverSubDropdown1, _hoverSubDropdown1$qu, hoverItem2, hoverSubDropdown2;
|
|
117
118
|
|
|
118
119
|
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
|
|
119
120
|
while (1) {
|
|
120
121
|
switch (_context4.prev = _context4.next) {
|
|
121
122
|
case 0:
|
|
123
|
+
this.timeout(0);
|
|
122
124
|
_mount3 = mount(NestedDemo), instance = _mount3[0], element = _mount3[1];
|
|
123
125
|
element.firstElementChild.click();
|
|
124
|
-
_context4.next =
|
|
126
|
+
_context4.next = 5;
|
|
125
127
|
return wait();
|
|
126
128
|
|
|
127
|
-
case
|
|
129
|
+
case 5:
|
|
128
130
|
dropdown = getElement('.k-dropdown-menu');
|
|
129
131
|
_dropdown$querySelect = dropdown.querySelectorAll(':scope > .k-dropdown-item'), hoverItem = _dropdown$querySelect[3], clickItem = _dropdown$querySelect[4];
|
|
130
132
|
clickItem.click();
|
|
131
|
-
_context4.next =
|
|
133
|
+
_context4.next = 10;
|
|
132
134
|
return wait(500);
|
|
133
135
|
|
|
134
|
-
case
|
|
136
|
+
case 10:
|
|
135
137
|
clickSubDropdown = getElement('.k-dropdown-menu');
|
|
136
138
|
expect(clickSubDropdown.innerHTML).to.matchSnapshot(); // should hide last sub-dropdown and show next
|
|
137
139
|
|
|
138
140
|
dispatchEvent(hoverItem, 'mouseenter');
|
|
139
|
-
_context4.next =
|
|
141
|
+
_context4.next = 15;
|
|
140
142
|
return wait(500);
|
|
141
143
|
|
|
142
|
-
case
|
|
144
|
+
case 15:
|
|
143
145
|
hoverSubDropdown = getElement('.k-dropdown-menu');
|
|
144
146
|
expect(hoverSubDropdown.innerHTML).to.matchSnapshot();
|
|
147
|
+
_hoverSubDropdown$que = hoverSubDropdown.querySelectorAll('.k-dropdown-item'), hoverItem1 = _hoverSubDropdown$que[0];
|
|
148
|
+
dispatchEvent(hoverItem, 'mouseleave');
|
|
149
|
+
dispatchEvent(hoverItem1, 'mouseenter');
|
|
150
|
+
_context4.next = 22;
|
|
151
|
+
return wait(500);
|
|
145
152
|
|
|
146
|
-
case
|
|
153
|
+
case 22:
|
|
154
|
+
hoverSubDropdown1 = getElement('.k-dropdown-menu');
|
|
155
|
+
expect(hoverSubDropdown1.textContent).to.eql('item 1item 2');
|
|
156
|
+
_hoverSubDropdown1$qu = hoverSubDropdown1.querySelectorAll('.k-dropdown-item'), hoverItem2 = _hoverSubDropdown1$qu[0];
|
|
157
|
+
dispatchEvent(hoverItem1, 'mouseleave');
|
|
158
|
+
dispatchEvent(hoverItem2, 'mouseenter');
|
|
159
|
+
_context4.next = 29;
|
|
160
|
+
return wait(1000);
|
|
161
|
+
|
|
162
|
+
case 29:
|
|
163
|
+
hoverSubDropdown2 = getElement('.k-dropdown-menu');
|
|
164
|
+
expect(hoverSubDropdown2 === hoverSubDropdown1).to.be.true;
|
|
165
|
+
|
|
166
|
+
case 31:
|
|
147
167
|
case "end":
|
|
148
168
|
return _context4.stop();
|
|
149
169
|
}
|
|
150
170
|
}
|
|
151
|
-
}, _callee3);
|
|
171
|
+
}, _callee3, this);
|
|
152
172
|
})));
|
|
153
173
|
it('hide on click document', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
154
174
|
var _mount4, instance, element;
|
|
@@ -483,7 +503,7 @@ describe('Dropdown', function () {
|
|
|
483
503
|
}
|
|
484
504
|
}, _callee9);
|
|
485
505
|
})));
|
|
486
|
-
it('trigger
|
|
506
|
+
it('focus trigger type', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
487
507
|
var Demo, _mount9, instance;
|
|
488
508
|
|
|
489
509
|
return _regeneratorRuntime.wrap(function _callee10$(_context14) {
|
|
@@ -506,39 +526,98 @@ describe('Dropdown', function () {
|
|
|
506
526
|
_this4.Dropdown = Dropdown;
|
|
507
527
|
_this4.DropdownItem = DropdownItem;
|
|
508
528
|
_this4.DropdownMenu = DropdownMenu;
|
|
529
|
+
_this4.onFocus = sinon.spy(function (e) {
|
|
530
|
+
return console.log(e);
|
|
531
|
+
});
|
|
509
532
|
return _this4;
|
|
510
533
|
}
|
|
511
534
|
|
|
512
535
|
return Demo;
|
|
513
536
|
}(Component);
|
|
514
537
|
|
|
515
|
-
Demo.template = "\n const {Dropdown, DropdownMenu, DropdownItem} = this;\n <div>\n <Dropdown trigger=\"focus\">\n <input ref=\"trigger\" />\n <DropdownMenu>\n <DropdownItem>test1</DropdownItem>\n <DropdownItem>test2</DropdownItem>\n </DropdownMenu>\n </Dropdown>\n </div>\n ";
|
|
538
|
+
Demo.template = "\n const {Dropdown, DropdownMenu, DropdownItem} = this;\n <div>\n <Dropdown trigger=\"focus\">\n <input ref=\"trigger\" ev-focusin={this.onFocus} />\n <DropdownMenu>\n <DropdownItem>test1</DropdownItem>\n <DropdownItem>test2</DropdownItem>\n </DropdownMenu>\n </Dropdown>\n </div>\n ";
|
|
516
539
|
_mount9 = mount(Demo), instance = _mount9[0];
|
|
517
540
|
dispatchEvent(instance.refs.trigger, 'focusin');
|
|
518
541
|
_context14.next = 6;
|
|
519
542
|
return wait(500);
|
|
520
543
|
|
|
521
544
|
case 6:
|
|
522
|
-
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
545
|
+
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
546
|
+
expect(instance.onFocus.callCount).to.eql(1); // clicking anywhere should not hide menu
|
|
523
547
|
|
|
524
548
|
dispatchEvent(document, 'click');
|
|
525
|
-
_context14.next =
|
|
549
|
+
_context14.next = 11;
|
|
526
550
|
return wait(500);
|
|
527
551
|
|
|
528
|
-
case
|
|
552
|
+
case 11:
|
|
529
553
|
expect(getElement('.k-dropdown-menu')).to.be.exist;
|
|
530
554
|
dispatchEvent(instance.refs.trigger, 'focusout');
|
|
531
|
-
_context14.next =
|
|
555
|
+
_context14.next = 15;
|
|
532
556
|
return wait(700);
|
|
533
557
|
|
|
534
|
-
case
|
|
558
|
+
case 15:
|
|
535
559
|
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
536
560
|
|
|
537
|
-
case
|
|
561
|
+
case 16:
|
|
538
562
|
case "end":
|
|
539
563
|
return _context14.stop();
|
|
540
564
|
}
|
|
541
565
|
}
|
|
542
566
|
}, _callee10);
|
|
543
567
|
})));
|
|
568
|
+
it('wrap by tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
569
|
+
var _mount10, instance, element, dropdown, _dropdown$querySelect4, item1, item2, item3, item4;
|
|
570
|
+
|
|
571
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context15) {
|
|
572
|
+
while (1) {
|
|
573
|
+
switch (_context15.prev = _context15.next) {
|
|
574
|
+
case 0:
|
|
575
|
+
_mount10 = mount(TooltipDemo), instance = _mount10[0], element = _mount10[1];
|
|
576
|
+
dispatchEvent(element.firstChild, 'mouseenter');
|
|
577
|
+
_context15.next = 4;
|
|
578
|
+
return wait();
|
|
579
|
+
|
|
580
|
+
case 4:
|
|
581
|
+
dropdown = getElement('.k-dropdown-menu');
|
|
582
|
+
_dropdown$querySelect4 = dropdown.querySelectorAll('.k-dropdown-item'), item1 = _dropdown$querySelect4[0], item2 = _dropdown$querySelect4[1], item3 = _dropdown$querySelect4[2], item4 = _dropdown$querySelect4[3];
|
|
583
|
+
dispatchEvent(item1, 'mouseenter');
|
|
584
|
+
_context15.next = 9;
|
|
585
|
+
return wait();
|
|
586
|
+
|
|
587
|
+
case 9:
|
|
588
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('item 1');
|
|
589
|
+
dispatchEvent(item1, 'mouseleave');
|
|
590
|
+
dispatchEvent(item3, 'mouseenter');
|
|
591
|
+
_context15.next = 14;
|
|
592
|
+
return wait();
|
|
593
|
+
|
|
594
|
+
case 14:
|
|
595
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('disabled');
|
|
596
|
+
dispatchEvent(item3, 'mouseleave');
|
|
597
|
+
dispatchEvent(item4, 'mouseenter');
|
|
598
|
+
_context15.next = 19;
|
|
599
|
+
return wait();
|
|
600
|
+
|
|
601
|
+
case 19:
|
|
602
|
+
expect(getElement('.k-tooltip-content').textContent).to.eql('This is a nested Dropdown.');
|
|
603
|
+
dispatchEvent(item4, 'click');
|
|
604
|
+
_context15.next = 23;
|
|
605
|
+
return wait();
|
|
606
|
+
|
|
607
|
+
case 23:
|
|
608
|
+
expect(getElement('.k-dropdown-menu').textContent).to.eql('item 1item 2');
|
|
609
|
+
dispatchEvent(item4, 'mouseleave');
|
|
610
|
+
_context15.next = 27;
|
|
611
|
+
return wait(800);
|
|
612
|
+
|
|
613
|
+
case 27:
|
|
614
|
+
expect(getElement('.k-dropdown-menu')).to.not.be.exist;
|
|
615
|
+
|
|
616
|
+
case 28:
|
|
617
|
+
case "end":
|
|
618
|
+
return _context15.stop();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}, _callee11);
|
|
622
|
+
})));
|
|
544
623
|
});
|
|
@@ -5,8 +5,9 @@ import { Component, inject } from 'intact-react';
|
|
|
5
5
|
import template from './item.vdt';
|
|
6
6
|
import { bind } from '../utils';
|
|
7
7
|
import { useItemKeyboard } from './useKeyboard';
|
|
8
|
-
import {
|
|
8
|
+
import { DROPDOWN } from './dropdown';
|
|
9
9
|
import { DROPDOWN_MENU } from './menu';
|
|
10
|
+
import { Dropdown as ExportDropdown, DropdownMenu as ExportDropdownMenu } from '.';
|
|
10
11
|
var typeDefs = {
|
|
11
12
|
disabled: Boolean,
|
|
12
13
|
hideOnSelect: Boolean,
|
|
@@ -49,7 +50,9 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
_proto.select = function select() {
|
|
52
|
-
if (this.parentDropdown) return;
|
|
53
|
+
if (this.parentDropdown) return; // trigger select event firstly for Cascader update values
|
|
54
|
+
|
|
55
|
+
this.trigger('select');
|
|
53
56
|
|
|
54
57
|
if (this.get('hideOnSelect')) {
|
|
55
58
|
// hide all dropdowns
|
|
@@ -59,16 +62,25 @@ export var DropdownItem = /*#__PURE__*/function (_Component) {
|
|
|
59
62
|
dropdown.hide(true);
|
|
60
63
|
} while (dropdown = dropdown.dropdown);
|
|
61
64
|
}
|
|
62
|
-
|
|
63
|
-
this.trigger('select');
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
_proto.hasSubMenu = function hasSubMenu() {
|
|
67
|
-
//
|
|
68
|
+
// wrapped by Dropdown rather than DropdownMenu
|
|
68
69
|
var parent = this.$senior;
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
while (parent) {
|
|
72
|
+
// Tooltip extends Dropdown, it's also a instance of Dropdown
|
|
73
|
+
// so use constructor to detect
|
|
74
|
+
// if (parent instanceof DropdownMenu) {
|
|
75
|
+
if (parent.constructor === ExportDropdownMenu) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (parent.constructor === ExportDropdown) {
|
|
80
|
+
return parent;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
parent = parent.$senior;
|
|
72
84
|
}
|
|
73
85
|
};
|
|
74
86
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
+
import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
|
|
2
3
|
import { useInstance, findDomFromVNode } from 'intact-react';
|
|
3
4
|
import { position } from '../position';
|
|
4
5
|
import { noop } from 'intact-shared';
|
|
6
|
+
import { isObject } from 'intact-shared';
|
|
5
7
|
export function usePosition() {
|
|
6
8
|
var instance = useInstance();
|
|
7
9
|
var positioned = {
|
|
@@ -13,7 +15,13 @@ export function usePosition() {
|
|
|
13
15
|
}
|
|
14
16
|
});
|
|
15
17
|
['of', 'position'].forEach(function (item) {
|
|
16
|
-
instance.watch(item, function () {
|
|
18
|
+
instance.watch(item, function (newValue, oldValue) {
|
|
19
|
+
// return if object is the same
|
|
20
|
+
if (isObject(newValue) && isObject(oldValue) && // is not event object
|
|
21
|
+
!(newValue instanceof Event) && _JSON$stringify(newValue) === _JSON$stringify(oldValue)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
if (instance.get('value')) {
|
|
18
26
|
handle(noop);
|
|
19
27
|
}
|
|
@@ -60,7 +68,8 @@ export function usePosition() {
|
|
|
60
68
|
|
|
61
69
|
position(findDomFromVNode(instance.menuVNode, true), _extends({
|
|
62
70
|
my: 'left top+8',
|
|
63
|
-
at: 'left bottom'
|
|
71
|
+
at: 'left bottom',
|
|
72
|
+
collision: instance.get('collison')
|
|
64
73
|
}, pos, {
|
|
65
74
|
of: ofElement,
|
|
66
75
|
using: function using(_feedback) {
|
|
@@ -2,7 +2,7 @@ import _inheritsLoose from "@babel/runtime-corejs3/helpers/inheritsLoose";
|
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
|
|
3
3
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
4
4
|
import { __decorate } from "tslib";
|
|
5
|
-
import { Component, createRef
|
|
5
|
+
import { Component, createRef } from 'intact-react';
|
|
6
6
|
import template from './index.vdt';
|
|
7
7
|
import { _$ } from '../../i18n';
|
|
8
8
|
import { bind } from '../utils';
|
|
@@ -49,12 +49,24 @@ export var Editable = /*#__PURE__*/function (_Component) {
|
|
|
49
49
|
var _proto = Editable.prototype;
|
|
50
50
|
|
|
51
51
|
_proto.edit = function edit() {
|
|
52
|
-
var _this2 = this;
|
|
53
|
-
|
|
54
52
|
this.set('editing', true);
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Intact will update in nextTick, but Vue will call
|
|
55
|
+
* call updated method in nextTick of this nextTick
|
|
56
|
+
* so we should do it after two nextTicks
|
|
57
|
+
* https://github.com/ksc-fe/kpc/issues/847
|
|
58
|
+
*
|
|
59
|
+
* use binding this.select to Input $mounted event instead
|
|
60
|
+
*/
|
|
61
|
+
// nextTick(() => {
|
|
62
|
+
// nextTick(() => {
|
|
63
|
+
// this.inputRef.value!.select();
|
|
64
|
+
// });
|
|
65
|
+
// });
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
_proto.select = function select() {
|
|
69
|
+
this.inputRef.value.select();
|
|
58
70
|
};
|
|
59
71
|
|
|
60
72
|
_proto.onBlur = function onBlur(e) {
|
|
@@ -124,6 +136,8 @@ Editable.events = events;
|
|
|
124
136
|
|
|
125
137
|
__decorate([bind], Editable.prototype, "edit", null);
|
|
126
138
|
|
|
139
|
+
__decorate([bind], Editable.prototype, "select", null);
|
|
140
|
+
|
|
127
141
|
__decorate([bind], Editable.prototype, "onBlur", null);
|
|
128
142
|
|
|
129
143
|
__decorate([bind], Editable.prototype, "onKeydown", null);
|
|
@@ -40,7 +40,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
40
40
|
'ev-blur': this.onBlur,
|
|
41
41
|
'ev-keydown': this.onKeydown,
|
|
42
42
|
'ref': this.inputRef,
|
|
43
|
-
'frozenOnInput': true
|
|
43
|
+
'frozenOnInput': true,
|
|
44
|
+
'ev-$mounted': this.select
|
|
44
45
|
}, null, this.inputRef), 0, 'c-ellipsis')]);
|
|
45
46
|
}
|
|
46
47
|
;
|
|
@@ -2,7 +2,7 @@ import { Component, TypeDefs } from 'intact-react';
|
|
|
2
2
|
import { Sizes } from '../../styles/utils';
|
|
3
3
|
import { CommonInputHTMLAttributes, Events } from '../types';
|
|
4
4
|
export * from './search';
|
|
5
|
-
declare type HTMLInputTypes = 'textarea' | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | (string & {});
|
|
5
|
+
export declare type HTMLInputTypes = 'textarea' | 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week' | (string & {});
|
|
6
6
|
interface InputHTMLAttributes extends CommonInputHTMLAttributes {
|
|
7
7
|
pattern?: string;
|
|
8
8
|
dirname?: string;
|
|
@@ -20,7 +20,7 @@ export interface InputProps<V extends Value = Value> extends InputHTMLAttributes
|
|
|
20
20
|
clearable?: boolean;
|
|
21
21
|
disabled?: boolean;
|
|
22
22
|
size?: Sizes;
|
|
23
|
-
rows?: string | number;
|
|
23
|
+
rows?: string | number | 'auto' | AutoRows;
|
|
24
24
|
autoWidth?: boolean;
|
|
25
25
|
fluid?: boolean;
|
|
26
26
|
width?: number | string;
|
|
@@ -28,7 +28,13 @@ export interface InputProps<V extends Value = Value> extends InputHTMLAttributes
|
|
|
28
28
|
frozenOnInput?: boolean;
|
|
29
29
|
inline?: boolean;
|
|
30
30
|
waveDisabled?: boolean;
|
|
31
|
+
resize?: 'none' | 'vertical' | 'horizontal' | 'both';
|
|
32
|
+
showPassword?: boolean;
|
|
31
33
|
}
|
|
34
|
+
export declare type AutoRows = {
|
|
35
|
+
min?: number;
|
|
36
|
+
max?: number;
|
|
37
|
+
};
|
|
32
38
|
export interface InputEvents {
|
|
33
39
|
clear: [MouseEvent];
|
|
34
40
|
focus: [FocusEvent];
|
|
@@ -49,6 +55,8 @@ export declare class Input<V extends Value = Value> extends Component<InputProps
|
|
|
49
55
|
private inputRef;
|
|
50
56
|
private autoWidth;
|
|
51
57
|
private frozen;
|
|
58
|
+
private autoRows;
|
|
59
|
+
private showPassword;
|
|
52
60
|
focus(): void;
|
|
53
61
|
blur(): void;
|
|
54
62
|
select(): void;
|
|
@@ -7,6 +7,8 @@ import template from './index.vdt';
|
|
|
7
7
|
import { bind } from '../utils';
|
|
8
8
|
import { useAutoWidth } from './useAutoWidth';
|
|
9
9
|
import { useFrozen } from './useFrozen';
|
|
10
|
+
import { useAutoRows } from './useAutoRows';
|
|
11
|
+
import { useShowPassword } from './useShowPassword';
|
|
10
12
|
export * from './search';
|
|
11
13
|
var typeDefs = {
|
|
12
14
|
type: String,
|
|
@@ -17,21 +19,24 @@ var typeDefs = {
|
|
|
17
19
|
clearable: Boolean,
|
|
18
20
|
disabled: Boolean,
|
|
19
21
|
size: sizes,
|
|
20
|
-
rows: [String, Number],
|
|
22
|
+
rows: [String, Number, 'auto', Object],
|
|
21
23
|
autoWidth: Boolean,
|
|
22
24
|
fluid: Boolean,
|
|
23
25
|
width: [Number, String],
|
|
24
26
|
stackClearIcon: Boolean,
|
|
25
27
|
frozenOnInput: Boolean,
|
|
26
28
|
inline: Boolean,
|
|
27
|
-
waveDisabled: Boolean
|
|
29
|
+
waveDisabled: Boolean,
|
|
30
|
+
resize: ['none', 'vertical', 'horizontal', 'both'],
|
|
31
|
+
showPassword: Boolean
|
|
28
32
|
};
|
|
29
33
|
|
|
30
34
|
var defaults = function defaults() {
|
|
31
35
|
return {
|
|
32
36
|
type: 'text',
|
|
33
37
|
size: 'default',
|
|
34
|
-
rows: 2
|
|
38
|
+
rows: 2,
|
|
39
|
+
resize: 'vertical'
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -57,6 +62,8 @@ export var Input = /*#__PURE__*/function (_Component) {
|
|
|
57
62
|
_this.inputRef = createRef();
|
|
58
63
|
_this.autoWidth = useAutoWidth();
|
|
59
64
|
_this.frozen = useFrozen();
|
|
65
|
+
_this.autoRows = useAutoRows(_this.inputRef);
|
|
66
|
+
_this.showPassword = useShowPassword();
|
|
60
67
|
return _this;
|
|
61
68
|
}
|
|
62
69
|
|