@king-design/intact 2.1.3 → 2.1.5
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/cascader/index.spec.ts +49 -0
- package/components/cascader/useValue.ts +1 -1
- package/components/dropdown/menu.ts +3 -1
- package/components/dropdown/usePosition.ts +14 -2
- package/components/select/useFocusout.ts +1 -1
- package/es/components/cascader/index.spec.js +82 -5
- package/es/components/cascader/useValue.js +1 -1
- package/es/components/dropdown/menu.js +2 -0
- package/es/components/dropdown/usePosition.d.ts +1 -0
- package/es/components/dropdown/usePosition.js +13 -1
- package/es/components/select/useFocusout.d.ts +1 -1
- package/es/components/select/useFocusout.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/index.ts +2 -2
- package/package.json +4 -4
|
@@ -135,6 +135,14 @@ describe('Cascader', () => {
|
|
|
135
135
|
dropdown1.querySelector<HTMLElement>('.k-dropdown-item')!.click();
|
|
136
136
|
await wait();
|
|
137
137
|
expect(instance.get('value')).to.eql(['hunan', 'yueyang', 'yueyanglou']);
|
|
138
|
+
|
|
139
|
+
// show again to test the position
|
|
140
|
+
input.click();
|
|
141
|
+
await wait();
|
|
142
|
+
const [_dropdown1, _dropdown2, _dropdown3] = getElements('.k-cascader-menu')!;
|
|
143
|
+
expect(_dropdown1.style.top).not.eql('0px');
|
|
144
|
+
expect(_dropdown2.style.top).not.eql('0px');
|
|
145
|
+
expect(_dropdown3.style.top).not.eql('0px');
|
|
138
146
|
});
|
|
139
147
|
|
|
140
148
|
it('no data for init data', async () => {
|
|
@@ -261,4 +269,45 @@ describe('Cascader', () => {
|
|
|
261
269
|
expect(element.innerHTML).to.matchSnapshot();
|
|
262
270
|
expect(instance.get('value')).to.eql(['beijing', 'haidian']);
|
|
263
271
|
});
|
|
272
|
+
|
|
273
|
+
it('should select correct value', async () => {
|
|
274
|
+
class Demo extends Component {
|
|
275
|
+
static template = `
|
|
276
|
+
const {Cascader} = this;
|
|
277
|
+
<Cascader data={this.get('data')} v-model="value" />
|
|
278
|
+
`;
|
|
279
|
+
static defaults() {
|
|
280
|
+
return {
|
|
281
|
+
value: ['beijing', 'haidian'],
|
|
282
|
+
data: [
|
|
283
|
+
{
|
|
284
|
+
value: 'beijing',
|
|
285
|
+
label: '北京',
|
|
286
|
+
children: [
|
|
287
|
+
{
|
|
288
|
+
value: 'haidian',
|
|
289
|
+
label: '海淀区'
|
|
290
|
+
},
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
value: 'hunan',
|
|
295
|
+
label: '湖南',
|
|
296
|
+
},
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
private Cascader = Cascader;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const [instance, element] = mount(Demo);
|
|
304
|
+
dispatchEvent(element, 'click');
|
|
305
|
+
await wait();
|
|
306
|
+
|
|
307
|
+
const [dropdown1, dropdown2] = getElements('.k-cascader-menu');
|
|
308
|
+
const [item1, item2] = dropdown1.querySelectorAll(':scope > .k-dropdown-item');
|
|
309
|
+
dispatchEvent(item2, 'click');
|
|
310
|
+
await wait();
|
|
311
|
+
expect(instance.get('value')).to.eql(['hunan']);
|
|
312
|
+
});
|
|
264
313
|
});
|
|
@@ -80,7 +80,7 @@ export function useValue() {
|
|
|
80
80
|
// maybe the showedValue has the leaf value when we set it on show menu,
|
|
81
81
|
// if we select by clicking, the showedValue has not the leaf value,
|
|
82
82
|
// no matter which case, we set the last value by level
|
|
83
|
-
const newValue = showedValue.value.slice(0);
|
|
83
|
+
const newValue = showedValue.value.slice(0, level);
|
|
84
84
|
newValue[level] = value;
|
|
85
85
|
setValue(newValue);
|
|
86
86
|
}
|
|
@@ -6,6 +6,7 @@ import {useTransition} from './useTransition';
|
|
|
6
6
|
import {useMenuKeyboard} from './useKeyboard';
|
|
7
7
|
import {useMouseOutsidable} from '../../hooks/useMouseOutsidable';
|
|
8
8
|
import {FeedbackCallback} from './usePosition';
|
|
9
|
+
import { usePositionForDropdownMenu } from './usePosition';
|
|
9
10
|
|
|
10
11
|
export interface DropdownMenuProps { }
|
|
11
12
|
export interface DropdownMenuEvents { }
|
|
@@ -29,6 +30,7 @@ export class DropdownMenu<
|
|
|
29
30
|
init() {
|
|
30
31
|
provide(DROPDOWN_MENU, this);
|
|
31
32
|
useMouseOutsidable(this.elementRef);
|
|
33
|
+
usePositionForDropdownMenu();
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
// no matter what the trigger is, we should show menu when enter into it.
|
|
@@ -78,4 +80,4 @@ function useKeyboardForDropdownMenu(dropdown: Dropdown) {
|
|
|
78
80
|
});
|
|
79
81
|
|
|
80
82
|
return {lock};
|
|
81
|
-
}
|
|
83
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {useInstance, findDomFromVNode} from 'intact';
|
|
2
|
-
import type {Dropdown} from './';
|
|
1
|
+
import {useInstance, findDomFromVNode, onBeforeUnmount} from 'intact';
|
|
2
|
+
import type {Dropdown, DropdownMenu} from './';
|
|
3
3
|
import {Options, position, Feedback} from '../position';
|
|
4
4
|
import {noop, isObject, isFunction} from 'intact-shared';
|
|
5
5
|
import { isEqualObject } from '../utils';
|
|
@@ -115,3 +115,15 @@ export function usePosition() {
|
|
|
115
115
|
|
|
116
116
|
return {handle, positioned};
|
|
117
117
|
}
|
|
118
|
+
|
|
119
|
+
export function usePositionForDropdownMenu() {
|
|
120
|
+
const instance = useInstance() as DropdownMenu;
|
|
121
|
+
/**
|
|
122
|
+
* Meybe the DropdownMenu has changed by specified key
|
|
123
|
+
* so, we must reset the positioned.value beforeUnmount
|
|
124
|
+
* #956
|
|
125
|
+
*/
|
|
126
|
+
onBeforeUnmount(() => {
|
|
127
|
+
instance.dropdown.positionHook.positioned.value = false;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
@@ -3,7 +3,7 @@ import {BaseSelect} from './base';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* don't trigger focusout event when layer is showing,
|
|
6
|
-
* only trigger focusout when it hidden to make FormItem to validate it
|
|
6
|
+
* only trigger focusout when it is hidden to make FormItem to validate it
|
|
7
7
|
* #449
|
|
8
8
|
*/
|
|
9
9
|
export function useFocusout() {
|
|
@@ -193,7 +193,7 @@ describe('Cascader', function () {
|
|
|
193
193
|
}, _callee5);
|
|
194
194
|
})));
|
|
195
195
|
it('filter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
196
|
-
var _mount5, instance, element, input, dropdown, dropdown1;
|
|
196
|
+
var _mount5, instance, element, input, dropdown, dropdown1, _getElements2, _dropdown1, _dropdown2, _dropdown3;
|
|
197
197
|
|
|
198
198
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
199
199
|
while (1) {
|
|
@@ -248,9 +248,19 @@ describe('Cascader', function () {
|
|
|
248
248
|
return wait();
|
|
249
249
|
|
|
250
250
|
case 34:
|
|
251
|
-
expect(instance.get('value')).to.eql(['hunan', 'yueyang', 'yueyanglou']);
|
|
251
|
+
expect(instance.get('value')).to.eql(['hunan', 'yueyang', 'yueyanglou']); // show again to test the position
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
input.click();
|
|
254
|
+
_context6.next = 38;
|
|
255
|
+
return wait();
|
|
256
|
+
|
|
257
|
+
case 38:
|
|
258
|
+
_getElements2 = getElements('.k-cascader-menu'), _dropdown1 = _getElements2[0], _dropdown2 = _getElements2[1], _dropdown3 = _getElements2[2];
|
|
259
|
+
expect(_dropdown1.style.top).not.eql('0px');
|
|
260
|
+
expect(_dropdown2.style.top).not.eql('0px');
|
|
261
|
+
expect(_dropdown3.style.top).not.eql('0px');
|
|
262
|
+
|
|
263
|
+
case 42:
|
|
254
264
|
case "end":
|
|
255
265
|
return _context6.stop();
|
|
256
266
|
}
|
|
@@ -283,7 +293,7 @@ describe('Cascader', function () {
|
|
|
283
293
|
}, _callee7);
|
|
284
294
|
})));
|
|
285
295
|
it('duplicated sub data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
286
|
-
var Demo, _mount7, instance, element,
|
|
296
|
+
var Demo, _mount7, instance, element, _getElements3, dropdown1, dropdown2, _dropdown1$querySelec4, item1, item2, _dropdown2$querySelec3, item21, dropdown3, _dropdown3$querySelec2, item31;
|
|
287
297
|
|
|
288
298
|
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
289
299
|
while (1) {
|
|
@@ -337,7 +347,7 @@ describe('Cascader', function () {
|
|
|
337
347
|
return wait();
|
|
338
348
|
|
|
339
349
|
case 6:
|
|
340
|
-
|
|
350
|
+
_getElements3 = getElements('.k-cascader-menu'), dropdown1 = _getElements3[0], dropdown2 = _getElements3[1];
|
|
341
351
|
_dropdown1$querySelec4 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec4[0], item2 = _dropdown1$querySelec4[1];
|
|
342
352
|
expect(item1.classList.contains('k-selected')).to.be.true;
|
|
343
353
|
expect(item2.classList.contains('k-selected')).to.be.false;
|
|
@@ -447,4 +457,71 @@ describe('Cascader', function () {
|
|
|
447
457
|
}
|
|
448
458
|
}, _callee9);
|
|
449
459
|
})));
|
|
460
|
+
it('should select correct value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
|
|
461
|
+
var Demo, _mount9, instance, element, _getElements4, dropdown1, dropdown2, _dropdown1$querySelec6, item1, item2;
|
|
462
|
+
|
|
463
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context13) {
|
|
464
|
+
while (1) {
|
|
465
|
+
switch (_context13.prev = _context13.next) {
|
|
466
|
+
case 0:
|
|
467
|
+
Demo = /*#__PURE__*/function (_Component3) {
|
|
468
|
+
_inheritsLoose(Demo, _Component3);
|
|
469
|
+
|
|
470
|
+
function Demo() {
|
|
471
|
+
var _context12;
|
|
472
|
+
|
|
473
|
+
var _this3;
|
|
474
|
+
|
|
475
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
476
|
+
args[_key3] = arguments[_key3];
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
_this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
|
|
480
|
+
_this3.Cascader = Cascader;
|
|
481
|
+
return _this3;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
Demo.defaults = function defaults() {
|
|
485
|
+
return {
|
|
486
|
+
value: ['beijing', 'haidian'],
|
|
487
|
+
data: [{
|
|
488
|
+
value: 'beijing',
|
|
489
|
+
label: '北京',
|
|
490
|
+
children: [{
|
|
491
|
+
value: 'haidian',
|
|
492
|
+
label: '海淀区'
|
|
493
|
+
}]
|
|
494
|
+
}, {
|
|
495
|
+
value: 'hunan',
|
|
496
|
+
label: '湖南'
|
|
497
|
+
}]
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
return Demo;
|
|
502
|
+
}(Component);
|
|
503
|
+
|
|
504
|
+
Demo.template = "\n const {Cascader} = this;\n <Cascader data={this.get('data')} v-model=\"value\" />\n ";
|
|
505
|
+
_mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
|
|
506
|
+
dispatchEvent(element, 'click');
|
|
507
|
+
_context13.next = 6;
|
|
508
|
+
return wait();
|
|
509
|
+
|
|
510
|
+
case 6:
|
|
511
|
+
_getElements4 = getElements('.k-cascader-menu'), dropdown1 = _getElements4[0], dropdown2 = _getElements4[1];
|
|
512
|
+
_dropdown1$querySelec6 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec6[0], item2 = _dropdown1$querySelec6[1];
|
|
513
|
+
dispatchEvent(item2, 'click');
|
|
514
|
+
_context13.next = 11;
|
|
515
|
+
return wait();
|
|
516
|
+
|
|
517
|
+
case 11:
|
|
518
|
+
expect(instance.get('value')).to.eql(['hunan']);
|
|
519
|
+
|
|
520
|
+
case 12:
|
|
521
|
+
case "end":
|
|
522
|
+
return _context13.stop();
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}, _callee10);
|
|
526
|
+
})));
|
|
450
527
|
});
|
|
@@ -91,7 +91,7 @@ export function useValue() {
|
|
|
91
91
|
// maybe the showedValue has the leaf value when we set it on show menu,
|
|
92
92
|
// if we select by clicking, the showedValue has not the leaf value,
|
|
93
93
|
// no matter which case, we set the last value by level
|
|
94
|
-
var newValue = _sliceInstanceProperty(_context4 = showedValue.value).call(_context4, 0);
|
|
94
|
+
var newValue = _sliceInstanceProperty(_context4 = showedValue.value).call(_context4, 0, level);
|
|
95
95
|
|
|
96
96
|
newValue[level] = value;
|
|
97
97
|
setValue(newValue);
|
|
@@ -8,6 +8,7 @@ import { DROPDOWN } from './dropdown';
|
|
|
8
8
|
import { useTransition } from './useTransition';
|
|
9
9
|
import { useMenuKeyboard } from './useKeyboard';
|
|
10
10
|
import { useMouseOutsidable } from '../../hooks/useMouseOutsidable';
|
|
11
|
+
import { usePositionForDropdownMenu } from './usePosition';
|
|
11
12
|
export var DROPDOWN_MENU = 'DropdownMenu';
|
|
12
13
|
export var DropdownMenu = /*#__PURE__*/function (_Component) {
|
|
13
14
|
_inheritsLoose(DropdownMenu, _Component);
|
|
@@ -36,6 +37,7 @@ export var DropdownMenu = /*#__PURE__*/function (_Component) {
|
|
|
36
37
|
_proto.init = function init() {
|
|
37
38
|
provide(DROPDOWN_MENU, this);
|
|
38
39
|
useMouseOutsidable(this.elementRef);
|
|
40
|
+
usePositionForDropdownMenu();
|
|
39
41
|
} // no matter what the trigger is, we should show menu when enter into it.
|
|
40
42
|
;
|
|
41
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/extends";
|
|
2
|
-
import { useInstance, findDomFromVNode } from 'intact';
|
|
2
|
+
import { useInstance, findDomFromVNode, onBeforeUnmount } from 'intact';
|
|
3
3
|
import { position } from '../position';
|
|
4
4
|
import { noop, isObject, isFunction } from 'intact-shared';
|
|
5
5
|
import { isEqualObject } from '../utils';
|
|
@@ -122,4 +122,16 @@ export function usePosition() {
|
|
|
122
122
|
handle: handle,
|
|
123
123
|
positioned: positioned
|
|
124
124
|
};
|
|
125
|
+
}
|
|
126
|
+
export function usePositionForDropdownMenu() {
|
|
127
|
+
var instance = useInstance();
|
|
128
|
+
/**
|
|
129
|
+
* Meybe the DropdownMenu has changed by specified key
|
|
130
|
+
* so, we must reset the positioned.value beforeUnmount
|
|
131
|
+
* #956
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
onBeforeUnmount(function () {
|
|
135
|
+
instance.dropdown.positionHook.positioned.value = false;
|
|
136
|
+
});
|
|
125
137
|
}
|
|
@@ -2,7 +2,7 @@ import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
|
|
|
2
2
|
import { useInstance, createRef } from 'intact';
|
|
3
3
|
/**
|
|
4
4
|
* don't trigger focusout event when layer is showing,
|
|
5
|
-
* only trigger focusout when it hidden to make FormItem to validate it
|
|
5
|
+
* only trigger focusout when it is hidden to make FormItem to validate it
|
|
6
6
|
* #449
|
|
7
7
|
*/
|
|
8
8
|
|
package/es/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.1.
|
|
2
|
+
* @king-design v2.1.5
|
|
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.1.
|
|
60
|
+
export declare const version = "2.1.5";
|
package/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.1.
|
|
2
|
+
* @king-design v2.1.5
|
|
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.1.
|
|
62
|
+
export var version = '2.1.5';
|
|
63
63
|
/* generate end */
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @king-design v2.1.
|
|
2
|
+
* @king-design v2.1.5
|
|
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.1.
|
|
65
|
+
export const version = '2.1.5';
|
|
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.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "A component library written in Intact for Intact, Vue, React and Angular",
|
|
5
5
|
"main": "es/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"prelease-minor": "lerna version preminor --preid beta --force-publish && npm run _publish -- --tag=beta",
|
|
34
34
|
"prelease-major": "lerna version premajor --preid beta --force-publish && npm run _publish -- --tag=beta",
|
|
35
35
|
"upload:resources": "gulp upload:resources",
|
|
36
|
-
"update:deps": "lerna exec -- yarn --registry=https://registry.npmjs.org"
|
|
36
|
+
"update:deps": "lerna exec -- yarn --registry=https://registry.npmjs.org",
|
|
37
|
+
"proxychains4:deploy:doc": "proxychains4 npx gulp doc:build && npx gulp doc:upload && proxychains4 npx gulp doc:push"
|
|
37
38
|
},
|
|
38
39
|
"repository": {
|
|
39
40
|
"type": "git",
|
|
@@ -117,7 +118,6 @@
|
|
|
117
118
|
"highlight.js": "^10.4.1",
|
|
118
119
|
"history": "^5.0.0",
|
|
119
120
|
"html-webpack-plugin": "5.3.1",
|
|
120
|
-
"intact-react": "^3.0.26",
|
|
121
121
|
"istanbul-instrumenter-loader": "^3.0.0",
|
|
122
122
|
"js-yaml": "^4.1.0",
|
|
123
123
|
"karma": "^6.3.2",
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"dayjs": "^1.10.7",
|
|
180
180
|
"downloadjs": "^1.4.7",
|
|
181
181
|
"enquire.js": "^2.1.6",
|
|
182
|
-
"intact": "^3.0.
|
|
182
|
+
"intact": "^3.0.28",
|
|
183
183
|
"monaco-editor": "^0.26.1",
|
|
184
184
|
"mxgraphx": "^4.0.7",
|
|
185
185
|
"resize-observer-polyfill": "^1.5.1",
|