@king-design/intact 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.
@@ -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
  }
@@ -533,6 +533,9 @@ describe('Datepicker', () => {
533
533
  const first = calendar1.querySelectorAll('.k-calendar-item')[17] as HTMLElement;
534
534
  const second = calendar2.querySelectorAll('.k-calendar-item')[17] as HTMLElement;
535
535
  first.click();
536
+ // should stay at date panel
537
+ await wait();
538
+ expect(calendar1.querySelector('.k-days')).be.exist;
536
539
  second.click();
537
540
  await wait();
538
541
  dispatchEvent(calendar1.querySelector<HTMLElement>('.k-scroll-select-wrapper .k-active')!.nextElementSibling!, 'click');
@@ -75,7 +75,15 @@ export function useValue(
75
75
  setValue(_value, false);
76
76
 
77
77
  if (type === 'datetime') {
78
- panel.changePanel(PanelTypes.Time, flag);
78
+ if (range) {
79
+ // only change to time panel after selected start and end date
80
+ if ((_value as StateValueRange).length === 2) {
81
+ panel.changePanel(PanelTypes.Time, PanelFlags.Start);
82
+ panel.changePanel(PanelTypes.Time, PanelFlags.End);
83
+ }
84
+ } else {
85
+ panel.changePanel(PanelTypes.Time, flag);
86
+ }
79
87
  } else if (!multiple && (!range || (_value as StateValueRange).length === 2)) {
80
88
  instance.hide();
81
89
  }
@@ -7,6 +7,7 @@ import {useMenuKeyboard} from './useKeyboard';
7
7
  import {useMouseOutsidable} from '../../hooks/useMouseOutsidable';
8
8
  import {FeedbackCallback} from './usePosition';
9
9
  import { useConfigContext } from '../config';
10
+ import { usePositionForDropdownMenu } from './usePosition';
10
11
 
11
12
  export interface DropdownMenuProps { }
12
13
  export interface DropdownMenuEvents { }
@@ -31,6 +32,7 @@ export class DropdownMenu<
31
32
  init() {
32
33
  provide(DROPDOWN_MENU, this);
33
34
  useMouseOutsidable(this.elementRef);
35
+ usePositionForDropdownMenu();
34
36
  }
35
37
 
36
38
  // no matter what the trigger is, we should show menu when enter into it.
@@ -80,4 +82,4 @@ function useKeyboardForDropdownMenu(dropdown: Dropdown) {
80
82
  });
81
83
 
82
84
  return {lock};
83
- }
85
+ }
@@ -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';
@@ -114,3 +114,15 @@ export function usePosition() {
114
114
 
115
115
  return {handle, positioned};
116
116
  }
117
+
118
+ export function usePositionForDropdownMenu() {
119
+ const instance = useInstance() as DropdownMenu;
120
+ /**
121
+ * Meybe the DropdownMenu has changed by specified key
122
+ * so, we must reset the positioned.value beforeUnmount
123
+ * #956
124
+ */
125
+ onBeforeUnmount(() => {
126
+ instance.dropdown.positionHook.positioned.value = false;
127
+ });
128
+ }
@@ -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() {
@@ -9,6 +9,9 @@ order: 30
9
9
  > 需要给Table设置rowKey属性,否则选择的行翻页后依然会保留选中状态,因为不设置key,则使用索引当key,
10
10
  > 只要当前选中的索引在下一页存在,则会依然选中
11
11
 
12
+ > 该功能需要将所有数据一次性传给Table,Table自动做分页处理,对于每次分页单独请求新数据的情况,请不要使用该功能,
13
+ > 而是配合单独的Pagination组件处理
14
+
12
15
  ```vdt
13
16
  import {Table, TableColumn, Switch} from 'kpc';
14
17
 
@@ -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';
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';
@@ -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';
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/es/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,4 +60,4 @@ 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";
package/es/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,5 +61,5 @@ 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 */
@@ -12,10 +12,10 @@ describe('Drawer', function () {
12
12
  container = document.createElement('div');
13
13
  document.body.appendChild(container);
14
14
  });
15
- // afterEach(() => {
16
- // ReactDOM.unmountComponentAtNode(container);
17
- // document.body.removeChild(container);
18
- // });
15
+ afterEach(function () {
16
+ ReactDOM.unmountComponentAtNode(container);
17
+ document.body.removeChild(container);
18
+ });
19
19
  it('should render react element correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
20
20
  var Test, App;
21
21
  return _regeneratorRuntime.wrap(function _callee$(_context) {
package/index.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
@@ -65,6 +65,6 @@ export * from './components/treeSelect';
65
65
  export * from './components/upload';
66
66
  export * from './components/wave';
67
67
 
68
- export const version = '3.1.4';
68
+ export const version = '3.1.6';
69
69
 
70
70
  /* generate end */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@king-design/intact",
3
- "version": "3.1.4",
3
+ "version": "3.1.6",
4
4
  "description": "A component library written in Intact for Intact, Vue, React and Angular",
5
5
  "main": "es/index.js",
6
6
  "engines": {
@@ -120,7 +120,6 @@
120
120
  "highlight.js": "^10.4.1",
121
121
  "history": "^5.0.0",
122
122
  "html-webpack-plugin": "5.3.1",
123
- "intact-react": "^3.0.26",
124
123
  "istanbul-instrumenter-loader": "^3.0.0",
125
124
  "js-yaml": "^4.1.0",
126
125
  "karma": "^6.3.2",
@@ -179,10 +178,9 @@
179
178
  "dependencies": {
180
179
  "@babel/runtime-corejs3": "^7.16.0",
181
180
  "@emotion/css": "^11.5.0",
182
- "@king-design/react": "^3.1.4",
183
181
  "dayjs": "^1.10.7",
184
182
  "enquire.js": "^2.1.6",
185
- "intact": "^3.0.26",
183
+ "intact": "^3.0.29",
186
184
  "monaco-editor": "^0.26.1",
187
185
  "mxgraphx": "^4.0.7",
188
186
  "resize-observer-polyfill": "^1.5.1",