@king-design/vue 3.1.4 → 3.1.6

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.
@@ -160,7 +160,7 @@ describe('Cascader', function () {
160
160
  }, _callee5);
161
161
  })));
162
162
  it('filter', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
163
- var _mount5, instance, element, input, dropdown, dropdown1;
163
+ var _mount5, instance, element, input, dropdown, dropdown1, _getElements2, _dropdown1, _dropdown2, _dropdown3;
164
164
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
165
165
  while (1) switch (_context6.prev = _context6.next) {
166
166
  case 0:
@@ -207,7 +207,16 @@ describe('Cascader', function () {
207
207
  return wait();
208
208
  case 34:
209
209
  expect(instance.get('value')).to.eql(['hunan', 'yueyang', 'yueyanglou']);
210
- case 35:
210
+ // show again to test the position
211
+ input.click();
212
+ _context6.next = 38;
213
+ return wait();
214
+ case 38:
215
+ _getElements2 = getElements('.k-cascader-menu'), _dropdown1 = _getElements2[0], _dropdown2 = _getElements2[1], _dropdown3 = _getElements2[2];
216
+ expect(_dropdown1.style.top).not.eql('0px');
217
+ expect(_dropdown2.style.top).not.eql('0px');
218
+ expect(_dropdown3.style.top).not.eql('0px');
219
+ case 42:
211
220
  case "end":
212
221
  return _context6.stop();
213
222
  }
@@ -234,7 +243,7 @@ describe('Cascader', function () {
234
243
  }, _callee7);
235
244
  })));
236
245
  it('duplicated sub data', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
237
- var Demo, _mount7, instance, element, _getElements2, dropdown1, dropdown2, _dropdown1$querySelec4, item1, item2, _dropdown2$querySelec3, item21, dropdown3, _dropdown3$querySelec2, item31;
246
+ var Demo, _mount7, instance, element, _getElements3, dropdown1, dropdown2, _dropdown1$querySelec4, item1, item2, _dropdown2$querySelec3, item21, dropdown3, _dropdown3$querySelec2, item31;
238
247
  return _regeneratorRuntime.wrap(function _callee8$(_context9) {
239
248
  while (1) switch (_context9.prev = _context9.next) {
240
249
  case 0:
@@ -278,7 +287,7 @@ describe('Cascader', function () {
278
287
  _context9.next = 6;
279
288
  return wait();
280
289
  case 6:
281
- _getElements2 = getElements('.k-cascader-menu'), dropdown1 = _getElements2[0], dropdown2 = _getElements2[1];
290
+ _getElements3 = getElements('.k-cascader-menu'), dropdown1 = _getElements3[0], dropdown2 = _getElements3[1];
282
291
  _dropdown1$querySelec4 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec4[0], item2 = _dropdown1$querySelec4[1];
283
292
  expect(item1.classList.contains('k-selected')).to.be.true;
284
293
  expect(item2.classList.contains('k-selected')).to.be.false;
@@ -370,4 +379,58 @@ describe('Cascader', function () {
370
379
  }
371
380
  }, _callee9);
372
381
  })));
382
+ it('should select correct value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
383
+ var Demo, _mount9, instance, element, _getElements4, dropdown1, dropdown2, _dropdown1$querySelec6, item1, item2;
384
+ return _regeneratorRuntime.wrap(function _callee10$(_context13) {
385
+ while (1) switch (_context13.prev = _context13.next) {
386
+ case 0:
387
+ Demo = /*#__PURE__*/function (_Component3) {
388
+ _inheritsLoose(Demo, _Component3);
389
+ function Demo() {
390
+ var _context12;
391
+ var _this3;
392
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
393
+ args[_key3] = arguments[_key3];
394
+ }
395
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
396
+ _this3.Cascader = Cascader;
397
+ return _this3;
398
+ }
399
+ Demo.defaults = function defaults() {
400
+ return {
401
+ value: ['beijing', 'haidian'],
402
+ data: [{
403
+ value: 'beijing',
404
+ label: '北京',
405
+ children: [{
406
+ value: 'haidian',
407
+ label: '海淀区'
408
+ }]
409
+ }, {
410
+ value: 'hunan',
411
+ label: '湖南'
412
+ }]
413
+ };
414
+ };
415
+ return Demo;
416
+ }(Component);
417
+ Demo.template = "\n const {Cascader} = this;\n <Cascader data={this.get('data')} v-model=\"value\" />\n ";
418
+ _mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
419
+ dispatchEvent(element, 'click');
420
+ _context13.next = 6;
421
+ return wait();
422
+ case 6:
423
+ _getElements4 = getElements('.k-cascader-menu'), dropdown1 = _getElements4[0], dropdown2 = _getElements4[1];
424
+ _dropdown1$querySelec6 = dropdown1.querySelectorAll(':scope > .k-dropdown-item'), item1 = _dropdown1$querySelec6[0], item2 = _dropdown1$querySelec6[1];
425
+ dispatchEvent(item2, 'click');
426
+ _context13.next = 11;
427
+ return wait();
428
+ case 11:
429
+ expect(instance.get('value')).to.eql(['hunan']);
430
+ case 12:
431
+ case "end":
432
+ return _context13.stop();
433
+ }
434
+ }, _callee10);
435
+ })));
373
436
  });
@@ -74,7 +74,7 @@ export function useValue() {
74
74
  // maybe the showedValue has the leaf value when we set it on show menu,
75
75
  // if we select by clicking, the showedValue has not the leaf value,
76
76
  // no matter which case, we set the last value by level
77
- var newValue = _sliceInstanceProperty(_context4 = showedValue.value).call(_context4, 0);
77
+ var newValue = _sliceInstanceProperty(_context4 = showedValue.value).call(_context4, 0, level);
78
78
  newValue[level] = value;
79
79
  setValue(newValue);
80
80
  }
@@ -801,22 +801,27 @@ describe('Datepicker', function () {
801
801
  first = calendar1.querySelectorAll('.k-calendar-item')[17];
802
802
  second = calendar2.querySelectorAll('.k-calendar-item')[17];
803
803
  first.click();
804
+ // should stay at date panel
805
+ _context21.next = 12;
806
+ return wait();
807
+ case 12:
808
+ expect(calendar1.querySelector('.k-days')).be.exist;
804
809
  second.click();
805
- _context21.next = 13;
810
+ _context21.next = 16;
806
811
  return wait();
807
- case 13:
812
+ case 16:
808
813
  dispatchEvent(calendar1.querySelector('.k-scroll-select-wrapper .k-active').nextElementSibling, 'click');
809
814
  dispatchEvent(calendar2.querySelector('.k-scroll-select-wrapper .k-active').previousElementSibling, 'click');
810
815
  content.querySelector('.k-datepicker-footer .k-btn').click();
811
- _context21.next = 18;
816
+ _context21.next = 21;
812
817
  return wait();
813
- case 18:
818
+ case 21:
814
819
  value2 = instance.get('time');
815
820
  expect(value2).have.lengthOf(2);
816
821
  expect(_mapInstanceProperty(value2).call(value2, function (item) {
817
822
  return item.split(' ')[1];
818
823
  })).eql(['01:00:00', '22:59:59']);
819
- case 21:
824
+ case 24:
820
825
  case "end":
821
826
  return _context21.stop();
822
827
  }
@@ -61,7 +61,15 @@ export function useValue(formats, disabled, panel) {
61
61
  }
62
62
  setValue(_value, false);
63
63
  if (type === 'datetime') {
64
- panel.changePanel(PanelTypes.Time, flag);
64
+ if (range) {
65
+ // only change to time panel after selected start and end date
66
+ if (_value.length === 2) {
67
+ panel.changePanel(PanelTypes.Time, PanelFlags.Start);
68
+ panel.changePanel(PanelTypes.Time, PanelFlags.End);
69
+ }
70
+ } else {
71
+ panel.changePanel(PanelTypes.Time, flag);
72
+ }
65
73
  } else if (!multiple && (!range || _value.length === 2)) {
66
74
  instance.hide();
67
75
  }
@@ -9,6 +9,7 @@ import { useTransition } from './useTransition';
9
9
  import { useMenuKeyboard } from './useKeyboard';
10
10
  import { useMouseOutsidable } from '../../hooks/useMouseOutsidable';
11
11
  import { useConfigContext } from '../config';
12
+ import { usePositionForDropdownMenu } from './usePosition';
12
13
  export var DROPDOWN_MENU = 'DropdownMenu';
13
14
  export var DropdownMenu = /*#__PURE__*/function (_Component) {
14
15
  _inheritsLoose(DropdownMenu, _Component);
@@ -32,6 +33,7 @@ export var DropdownMenu = /*#__PURE__*/function (_Component) {
32
33
  _proto.init = function init() {
33
34
  provide(DROPDOWN_MENU, this);
34
35
  useMouseOutsidable(this.elementRef);
36
+ usePositionForDropdownMenu();
35
37
  }
36
38
  // no matter what the trigger is, we should show menu when enter into it.
37
39
  ;
@@ -6,3 +6,4 @@ export declare function usePosition(): {
6
6
  value: boolean;
7
7
  };
8
8
  };
9
+ export declare function usePositionForDropdownMenu(): void;
@@ -1,5 +1,5 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
- import { useInstance, findDomFromVNode } from 'intact-vue-next';
2
+ import { useInstance, findDomFromVNode, onBeforeUnmount } from 'intact-vue-next';
3
3
  import { position } from '../position';
4
4
  import { noop, isObject, isFunction } from 'intact-shared';
5
5
  import { isEqualObject } from '../utils';
@@ -112,4 +112,15 @@ export function usePosition() {
112
112
  handle: handle,
113
113
  positioned: positioned
114
114
  };
115
+ }
116
+ export function usePositionForDropdownMenu() {
117
+ var instance = useInstance();
118
+ /**
119
+ * Meybe the DropdownMenu has changed by specified key
120
+ * so, we must reset the positioned.value beforeUnmount
121
+ * #956
122
+ */
123
+ onBeforeUnmount(function () {
124
+ instance.dropdown.positionHook.positioned.value = false;
125
+ });
115
126
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * don't trigger focusout event when layer is showing,
3
- * only trigger focusout when it hidden to make FormItem to validate it
3
+ * only trigger focusout when it is hidden to make FormItem to validate it
4
4
  * #449
5
5
  */
6
6
  export declare function useFocusout(): {
@@ -2,7 +2,7 @@ import _Object$assign from "@babel/runtime-corejs3/core-js/object/assign";
2
2
  import { useInstance, createRef } from 'intact-vue-next';
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
  export function useFocusout() {
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.4
2
+ * @king-design v3.1.6
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -60,7 +60,7 @@ export * from './components/tree';
60
60
  export * from './components/treeSelect';
61
61
  export * from './components/upload';
62
62
  export * from './components/wave';
63
- export declare const version = "3.1.4";
63
+ export declare const version = "3.1.6";
64
64
 
65
65
 
66
66
  export {normalize} from 'intact-vue-next';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @king-design v3.1.4
2
+ * @king-design v3.1.6
3
3
  *
4
4
  * Copyright (c) Kingsoft Cloud
5
5
  * Released under the MIT License
@@ -61,7 +61,7 @@ export * from './components/tree';
61
61
  export * from './components/treeSelect';
62
62
  export * from './components/upload';
63
63
  export * from './components/wave';
64
- export var version = '3.1.4';
64
+ export var version = '3.1.6';
65
65
  /* generate end */
66
66
 
67
67
  export {normalize} from 'intact-vue-next';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/vue",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "King-Design UI components for Vue3.0.",
5
5
  "keywords": [
6
6
  "component",
@@ -37,7 +37,7 @@
37
37
  "@emotion/css": "^11.5.0",
38
38
  "dayjs": "^1.10.7",
39
39
  "enquire.js": "^2.1.6",
40
- "intact-vue-next": "3.0.26",
40
+ "intact-vue-next": "3.0.29",
41
41
  "monaco-editor": "^0.26.1",
42
42
  "mxgraphx": "^4.0.7",
43
43
  "resize-observer-polyfill": "^1.5.1",