@king-design/vue 3.6.0-beta.0 → 3.6.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.
Files changed (94) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +115 -51
  2. package/__tests__/components/editable.spec.ts +1 -1
  3. package/__tests__/components/misc.spec.ts +93 -0
  4. package/__tests__/components/table.spec.ts +1 -0
  5. package/components/cascader/index.spec.js +18 -19
  6. package/components/copy/index.spec.js +14 -31
  7. package/components/datepicker/basepicker.d.ts +6 -27
  8. package/components/datepicker/basepicker.js +23 -268
  9. package/components/datepicker/calendar.d.ts +4 -2
  10. package/components/datepicker/dayjs.d.ts +2 -13
  11. package/components/datepicker/helpers.d.ts +3 -2
  12. package/components/datepicker/helpers.js +2 -3
  13. package/components/datepicker/index.d.ts +21 -29
  14. package/components/datepicker/index.js +22 -32
  15. package/components/datepicker/index.spec.js +1277 -484
  16. package/components/datepicker/index.vdt.js +39 -38
  17. package/components/datepicker/shortcuts.d.ts +1 -1
  18. package/components/datepicker/styles.d.ts +7 -2
  19. package/components/datepicker/styles.js +10 -15
  20. package/components/datepicker/useConfirm.d.ts +6 -0
  21. package/components/datepicker/useConfirm.js +65 -0
  22. package/components/datepicker/useDisabled.d.ts +5 -3
  23. package/components/datepicker/useDisabled.js +22 -27
  24. package/components/datepicker/useFormats.d.ts +2 -2
  25. package/components/datepicker/useFormats.js +6 -2
  26. package/components/datepicker/useHighlight.d.ts +14 -0
  27. package/components/datepicker/useHighlight.js +60 -0
  28. package/components/datepicker/useKeyboards.js +2 -1
  29. package/components/datepicker/useMergeRange.d.ts +1 -1
  30. package/components/datepicker/useMergeRange.js +11 -16
  31. package/components/datepicker/useMonths.js +5 -3
  32. package/components/datepicker/usePanel.d.ts +1 -10
  33. package/components/datepicker/usePanel.js +19 -32
  34. package/components/datepicker/useShowDate.d.ts +1 -1
  35. package/components/datepicker/useShowDate.js +15 -40
  36. package/components/datepicker/useStatus.js +33 -16
  37. package/components/datepicker/useValue.d.ts +11 -6
  38. package/components/datepicker/useValue.js +49 -69
  39. package/components/datepicker/useValueBase.d.ts +28 -0
  40. package/components/datepicker/useValueBase.js +280 -0
  41. package/components/datepicker/useYears.js +6 -3
  42. package/components/dropdown/dropdown.d.ts +1 -0
  43. package/components/dropdown/dropdown.js +7 -4
  44. package/components/form/form.d.ts +1 -0
  45. package/components/form/form.js +7 -0
  46. package/components/form/index.spec.js +10 -8
  47. package/components/input/index.d.ts +2 -0
  48. package/components/input/index.js +6 -0
  49. package/components/input/index.spec.js +45 -0
  50. package/components/input/index.vdt.js +4 -3
  51. package/components/input/useAutoWidth.d.ts +2 -0
  52. package/components/input/useAutoWidth.js +19 -1
  53. package/components/menu/index.spec.js +28 -0
  54. package/components/menu/styles.js +2 -2
  55. package/components/scrollSelect/useMouseEvents.js +5 -4
  56. package/components/select/base.d.ts +1 -1
  57. package/components/select/base.js +3 -2
  58. package/components/select/base.vdt.js +4 -3
  59. package/components/select/index.spec.js +346 -218
  60. package/components/select/menu.js +1 -1
  61. package/components/select/option.js +2 -1
  62. package/components/select/select.js +2 -1
  63. package/components/select/styles.d.ts +79 -0
  64. package/components/select/styles.js +1 -0
  65. package/components/select/useCard.d.ts +4 -3
  66. package/components/select/useCard.js +15 -4
  67. package/components/select/useInput.d.ts +1 -1
  68. package/components/select/useInput.js +4 -4
  69. package/components/spinner/index.spec.js +82 -44
  70. package/components/spinner/useValue.js +2 -1
  71. package/components/table/index.spec.js +84 -6
  72. package/components/table/useStickyHeader.js +1 -1
  73. package/components/timepicker/index.spec.js +298 -128
  74. package/components/timepicker/panelPicker.d.ts +21 -16
  75. package/components/timepicker/panelPicker.js +7 -4
  76. package/components/timepicker/panelPicker.vdt.js +5 -9
  77. package/components/timepicker/selectPicker.d.ts +4 -3
  78. package/components/timepicker/styles.js +1 -1
  79. package/components/timepicker/useConfirm.d.ts +6 -0
  80. package/components/timepicker/useConfirm.js +19 -0
  81. package/components/timepicker/useDefaultValue.d.ts +4 -0
  82. package/components/timepicker/useDefaultValue.js +27 -0
  83. package/components/timepicker/useDisabled.d.ts +6 -3
  84. package/components/timepicker/useDisabled.js +13 -4
  85. package/components/timepicker/useFormats.d.ts +1 -1
  86. package/components/timepicker/useValue.d.ts +13 -8
  87. package/components/timepicker/useValue.js +14 -15
  88. package/components/tour/index.spec.js +1 -1
  89. package/index.d.ts +2 -2
  90. package/index.js +2 -2
  91. package/package.json +2 -2
  92. package/yarn-error.log +44 -43
  93. package/components/datepicker/usePosition.d.ts +0 -10
  94. package/components/datepicker/usePosition.js +0 -166
@@ -16,7 +16,7 @@ export var SelectMenu = /*#__PURE__*/function (_Component) {
16
16
  }
17
17
  _this = _Component.call.apply(_Component, _concatInstanceProperty(_context = [this]).call(_context, args)) || this;
18
18
  _this.select = inject(SELECT);
19
- _this.card = useCard(_this.select.label.activeIndices);
19
+ _this.card = useCard(_this.select.label.activeIndices, _this.select.input.keywords);
20
20
  _this.searchable = useSearchable();
21
21
  _this.config = useConfigContext();
22
22
  return _this;
@@ -40,7 +40,8 @@ export var Option = /*#__PURE__*/function (_Component) {
40
40
  select.set('value', this.get('value'));
41
41
  } else {
42
42
  var values = select.get('value');
43
- if (keepKeywords && isCreated && Array.isArray(values) && _includesInstanceProperty(values).call(values, value)) {
43
+ if (!keepKeywords && isCreated && Array.isArray(values) && _includesInstanceProperty(values).call(values, value)) {
44
+ select.resetKeywords();
44
45
  return;
45
46
  }
46
47
  values = toggleArray(values, value);
@@ -23,7 +23,8 @@ var typeDefs = _extends({}, BaseSelect.typeDefs, {
23
23
  });
24
24
  var defaults = function defaults() {
25
25
  return _extends({}, BaseSelect.defaults(), {
26
- labelMap: new _Map()
26
+ labelMap: new _Map(),
27
+ keepKeywords: true
27
28
  });
28
29
  };
29
30
  export var Select = /*#__PURE__*/function (_BaseSelect) {
@@ -1,4 +1,83 @@
1
+ import { Sizes } from '../../styles/utils';
1
2
  import '../../styles/global';
3
+ type SizeStyles = {
4
+ padding: string;
5
+ height: string;
6
+ fontSize: string;
7
+ };
8
+ declare const defaults: {
9
+ readonly transition: string;
10
+ width: string;
11
+ readonly height: string;
12
+ bgColor: string;
13
+ readonly fontSize: string;
14
+ readonly border: string;
15
+ readonly focusBorder: string;
16
+ readonly hoverBorder: string;
17
+ readonly activeColor: string;
18
+ readonly borderRadius: string;
19
+ suffixGap: string;
20
+ clearGap: string;
21
+ readonly placeholderColor: string;
22
+ disabled: {
23
+ readonly color: string;
24
+ readonly bgColor: string;
25
+ readonly borderColor: string;
26
+ };
27
+ group: {
28
+ readonly labelColor: string;
29
+ labelPadding: string;
30
+ };
31
+ card: {
32
+ height: string;
33
+ readonly itemHoverColor: string;
34
+ itemHoverBgColor: string;
35
+ };
36
+ multiple: {
37
+ checkmark: {
38
+ fontSize: string;
39
+ };
40
+ };
41
+ tag: {
42
+ margin: string;
43
+ padding: string;
44
+ readonly borderRadius: string;
45
+ readonly bgColor: string;
46
+ disabledBgColor: string;
47
+ delete: {
48
+ gap: string;
49
+ fontSize: string;
50
+ readonly color: string;
51
+ };
52
+ };
53
+ menuMaxHeight: string;
54
+ empty: {
55
+ padding: string;
56
+ readonly color: string;
57
+ };
58
+ searchable: {
59
+ padding: string;
60
+ headerGap: string;
61
+ readonly border: string;
62
+ header: {
63
+ padding: string;
64
+ gap: string;
65
+ btnPadding: string;
66
+ btnGap: string;
67
+ };
68
+ optionPadding: string;
69
+ footer: {
70
+ padding: string;
71
+ gap: string;
72
+ btnGap: string;
73
+ };
74
+ };
75
+ flat: {
76
+ readonly color: string;
77
+ };
78
+ } & Record<Sizes, SizeStyles>;
79
+ declare let select: typeof defaults;
80
+ export { select };
2
81
  export declare const makeStyles: {
3
82
  (k: string): string;
4
83
  clearCache(): {};
@@ -146,6 +146,7 @@ setDefault(function () {
146
146
  makeMenuStyles == null || makeMenuStyles.clearCache();
147
147
  makeGroupStyles == null || makeGroupStyles.clearCache();
148
148
  });
149
+ export { select };
149
150
  export var makeStyles = cache(function makeStyles(k) {
150
151
  return /*#__PURE__*/css("display:inline-flex;align-items:center;vertical-align:middle;position:relative;width:", select.width, ";cursor:pointer;outline:none;border:", select.border, ";background:", select.bgColor, ";transition:border ", select.transition, ",background ", select.transition, ",box-shadow ", select.transition, ";border-radius:", select.borderRadius, ";.", k, "-select-main{flex:1;min-width:0;}.", k, "-select-prefix,.", k, "-select-suffix{display:flex;align-items:center;position:relative;}.", k, "-select-suffix{margin-left:", select.suffixGap, ";}.", k, "-select-placeholder{color:", select.placeholderColor, ";user-select:none;}.", k, "-input .", k, "-input-inner{background:transparent;}&.", k, "-fluid{width:100%;}.", k, "-select-clear{opacity:0;transition:opacity ", select.transition, ",color ", select.transition, "!important;pointer-events:none;position:absolute;z-index:1;top:50%;left:50%;transform:translate(-50%, -50%);}&:hover{border:", select.hoverBorder, ";.", k, "-select-clear.", k, "-show{opacity:1;pointer-events:all;+.", k, "-select-suffix-icon{opacity:0;}}}.", k, "-select-suffix-icon{display:inline-flex;align-items:center;transition:opacity ", select.transition, ";}.", k, "-select-arrow{display:inline-block;transition:transform ", select.transition, ";}&.", k, "-dropdown-open{border:", select.focusBorder, ";.", k, "-select-arrow{transform:rotateX(180deg);}}&:focus{outline:none;border:", select.focusBorder, ";}.", k, "-tags{padding:3px 0;}.", k, "-tag{word-break:break-word;height:auto;max-width:calc(100% - ", getRight(select.tag.margin), " - 1px);}", _mapInstanceProperty(sizes).call(sizes, function (size) {
151
152
  var styles = select[size];
@@ -1,8 +1,9 @@
1
1
  import { Children, NonNullableRefObject } from 'intact-vue-next';
2
- export declare function useCard(defaultActiveIndex: NonNullableRefObject<number[]>): {
3
- process: (children: Children) => {
2
+ import { State } from '../../hooks/useState';
3
+ export declare function useCard(defaultActiveIndex: NonNullableRefObject<number[]>, keywords: State<string>): {
4
+ process: (children: Children, isSearching: boolean) => {
4
5
  labels: Children[] | import('intact-vue-next').Block<any>[];
5
6
  group: Children[];
6
7
  };
7
- activeIndex: import("../../hooks/useState").State<number>;
8
+ activeIndex: State<number>;
8
9
  };
@@ -2,11 +2,22 @@ import { useInstance } from 'intact-vue-next';
2
2
  import { eachChildren, isComponentVNode, last } from '../utils';
3
3
  import { EMPTY_OBJ } from 'intact-shared';
4
4
  import { OptionGroup } from './group';
5
- import { useState } from '../../hooks/useState';
6
- export function useCard(defaultActiveIndex) {
7
- var children = useInstance().get('children');
5
+ import { useState, watchState } from '../../hooks/useState';
6
+ export function useCard(defaultActiveIndex, keywords) {
7
+ var instance = useInstance();
8
8
  var activeIndex = useState(last(defaultActiveIndex.value) || 0);
9
- function process(children) {
9
+ watchState(keywords, function (keywords) {
10
+ if (keywords) {
11
+ activeIndex.set(0);
12
+ } else {
13
+ setDefaultActiveIndex();
14
+ }
15
+ });
16
+ instance.select.on('show', setDefaultActiveIndex);
17
+ function setDefaultActiveIndex() {
18
+ activeIndex.set(last(defaultActiveIndex.value) || 0);
19
+ }
20
+ function process(children, isSearching) {
10
21
  var groupLabels = [];
11
22
  var _children = [];
12
23
  var index = 0;
@@ -1,6 +1,6 @@
1
1
  import { State } from '../../hooks/useState';
2
2
  import type { Input } from '../input';
3
- export declare function useInput(resetKeywords: (keywords: State<string>) => void): {
3
+ export declare function useInput(resetKeywords: () => void): {
4
4
  onInput: (value: string) => void;
5
5
  keywords: State<string>;
6
6
  inputRef: import('intact-vue-next').RefObject<Input<string | number>>;
@@ -29,9 +29,9 @@ export function useInput(resetKeywords) {
29
29
  component.on('$changed:show', function (show) {
30
30
  if (show) {
31
31
  focusInput();
32
- resetKeywords(keywords);
32
+ resetKeywords();
33
33
  } else if (component.get('multiple')) {
34
- resetKeywords(keywords);
34
+ resetKeywords();
35
35
  }
36
36
  });
37
37
  component.on('$changed:value', function () {
@@ -45,8 +45,8 @@ export function useInput(resetKeywords) {
45
45
  * don't reset keywords on multiple mode for continue selection
46
46
  * https://github.com/ksc-fe/kpc/issues/983
47
47
  */
48
- if (keepKeywords) {
49
- resetKeywords(keywords);
48
+ if (!keepKeywords) {
49
+ resetKeywords();
50
50
  }
51
51
  }
52
52
  });
@@ -321,100 +321,138 @@ describe('Spinner', function () {
321
321
  }
322
322
  }, _callee6);
323
323
  })));
324
- it('dynamic step', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
325
- var _mount8, instance, element, btns, test, _test;
326
- return _regeneratorRuntime.wrap(function _callee8$(_context11) {
327
- while (1) switch (_context11.prev = _context11.next) {
324
+ it('forceStep without min value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
325
+ var Demo, _mount8, instance, element;
326
+ return _regeneratorRuntime.wrap(function _callee7$(_context10) {
327
+ while (1) switch (_context10.prev = _context10.next) {
328
328
  case 0:
329
- _test = function _test3() {
330
- _test = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(index) {
329
+ Demo = /*#__PURE__*/function (_Component3) {
330
+ _inheritsLoose(Demo, _Component3);
331
+ function Demo() {
331
332
  var _context9;
332
- var _ref8, prev, next, model;
333
- return _regeneratorRuntime.wrap(function _callee7$(_context10) {
334
- while (1) switch (_context10.prev = _context10.next) {
333
+ var _this3;
334
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
335
+ args[_key3] = arguments[_key3];
336
+ }
337
+ _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
338
+ _this3.Spinner = Spinner;
339
+ return _this3;
340
+ }
341
+ Demo.defaults = function defaults() {
342
+ return {
343
+ value: 1
344
+ };
345
+ };
346
+ return Demo;
347
+ }(Component);
348
+ Demo.template = "const {Spinner} = this;\n <Spinner step={1} v-model=\"value\" forceStep />\n ";
349
+ _mount8 = mount(Demo), instance = _mount8[0], element = _mount8[1];
350
+ expect(instance.get('value')).to.eql(1);
351
+ instance.set('value', -1);
352
+ _context10.next = 7;
353
+ return wait();
354
+ case 7:
355
+ expect(instance.get('value')).to.eql(-1);
356
+ case 8:
357
+ case "end":
358
+ return _context10.stop();
359
+ }
360
+ }, _callee7);
361
+ })));
362
+ it('dynamic step', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
363
+ var _mount9, instance, element, btns, test, _test;
364
+ return _regeneratorRuntime.wrap(function _callee9$(_context13) {
365
+ while (1) switch (_context13.prev = _context13.next) {
366
+ case 0:
367
+ _test = function _test3() {
368
+ _test = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(index) {
369
+ var _context11;
370
+ var _ref9, prev, next, model;
371
+ return _regeneratorRuntime.wrap(function _callee8$(_context12) {
372
+ while (1) switch (_context12.prev = _context12.next) {
335
373
  case 0:
336
- _ref8 = index === 1 ? btns : _sliceInstanceProperty(_context9 = _Array$from(btns)).call(_context9, 2), prev = _ref8[0], next = _ref8[1];
374
+ _ref9 = index === 1 ? btns : _sliceInstanceProperty(_context11 = _Array$from(btns)).call(_context11, 2), prev = _ref9[0], next = _ref9[1];
337
375
  model = "value" + index;
338
376
  prev.click();
339
- _context10.next = 5;
377
+ _context12.next = 5;
340
378
  return wait();
341
379
  case 5:
342
380
  expect(instance.get(model)).to.eql(-1);
343
381
  instance.set(model, -5);
344
- _context10.next = 9;
382
+ _context12.next = 9;
345
383
  return wait();
346
384
  case 9:
347
385
  prev.click();
348
- _context10.next = 12;
386
+ _context12.next = 12;
349
387
  return wait();
350
388
  case 12:
351
389
  expect(instance.get(model)).to.eql(-10);
352
390
  next.click();
353
- _context10.next = 16;
391
+ _context12.next = 16;
354
392
  return wait();
355
393
  case 16:
356
394
  expect(instance.get(model)).to.eql(-5);
357
395
  next.click();
358
- _context10.next = 20;
396
+ _context12.next = 20;
359
397
  return wait();
360
398
  case 20:
361
399
  expect(instance.get(model)).to.eql(-4);
362
400
  instance.set(model, 5);
363
- _context10.next = 24;
401
+ _context12.next = 24;
364
402
  return wait();
365
403
  case 24:
366
404
  next.click();
367
- _context10.next = 27;
405
+ _context12.next = 27;
368
406
  return wait();
369
407
  case 27:
370
408
  expect(instance.get(model)).to.eql(10);
371
409
  prev.click();
372
- _context10.next = 31;
410
+ _context12.next = 31;
373
411
  return wait();
374
412
  case 31:
375
413
  expect(instance.get(model)).to.eql(5);
376
414
  prev.click();
377
- _context10.next = 35;
415
+ _context12.next = 35;
378
416
  return wait();
379
417
  case 35:
380
418
  expect(instance.get(model)).to.eql(4);
381
419
  case 36:
382
420
  case "end":
383
- return _context10.stop();
421
+ return _context12.stop();
384
422
  }
385
- }, _callee7);
423
+ }, _callee8);
386
424
  }));
387
425
  return _test.apply(this, arguments);
388
426
  };
389
427
  test = function _test2(_x) {
390
428
  return _test.apply(this, arguments);
391
429
  };
392
- _mount8 = mount(DynamicStepDemo), instance = _mount8[0], element = _mount8[1];
430
+ _mount9 = mount(DynamicStepDemo), instance = _mount9[0], element = _mount9[1];
393
431
  btns = element.querySelectorAll('.k-btn');
394
- _context11.next = 6;
432
+ _context13.next = 6;
395
433
  return test(1);
396
434
  case 6:
397
435
  case "end":
398
- return _context11.stop();
436
+ return _context13.stop();
399
437
  }
400
- }, _callee8);
438
+ }, _callee9);
401
439
  })));
402
- it('should set correct value with dynamic step when min is not equal 0', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
403
- var Demo, _mount9, instance, element, _element$querySelecto5, prev, next;
404
- return _regeneratorRuntime.wrap(function _callee9$(_context13) {
405
- while (1) switch (_context13.prev = _context13.next) {
440
+ it('should set correct value with dynamic step when min is not equal 0', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
441
+ var Demo, _mount10, instance, element, _element$querySelecto5, prev, next;
442
+ return _regeneratorRuntime.wrap(function _callee10$(_context15) {
443
+ while (1) switch (_context15.prev = _context15.next) {
406
444
  case 0:
407
- Demo = /*#__PURE__*/function (_Component3) {
408
- _inheritsLoose(Demo, _Component3);
445
+ Demo = /*#__PURE__*/function (_Component4) {
446
+ _inheritsLoose(Demo, _Component4);
409
447
  function Demo() {
410
- var _context12;
411
- var _this3;
412
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
413
- args[_key3] = arguments[_key3];
448
+ var _context14;
449
+ var _this4;
450
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
451
+ args[_key4] = arguments[_key4];
414
452
  }
415
- _this3 = _Component3.call.apply(_Component3, _concatInstanceProperty(_context12 = [this]).call(_context12, args)) || this;
416
- _this3.Spinner = Spinner;
417
- return _this3;
453
+ _this4 = _Component4.call.apply(_Component4, _concatInstanceProperty(_context14 = [this]).call(_context14, args)) || this;
454
+ _this4.Spinner = Spinner;
455
+ return _this4;
418
456
  }
419
457
  Demo.defaults = function defaults() {
420
458
  return {
@@ -424,27 +462,27 @@ describe('Spinner', function () {
424
462
  return Demo;
425
463
  }(Component);
426
464
  Demo.template = "const {Spinner} = this; <Spinner min={30}\n max={500}\n step={{100: 10, 500: 50}}\n v-model=\"value\"\n forceStep\n />";
427
- _mount9 = mount(Demo), instance = _mount9[0], element = _mount9[1];
465
+ _mount10 = mount(Demo), instance = _mount10[0], element = _mount10[1];
428
466
  _element$querySelecto5 = element.querySelectorAll('.k-btn'), prev = _element$querySelecto5[0], next = _element$querySelecto5[1];
429
467
  next.click();
430
- _context13.next = 7;
468
+ _context15.next = 7;
431
469
  return wait();
432
470
  case 7:
433
471
  expect(instance.get('value')).to.eql(150);
434
472
  prev.click();
435
- _context13.next = 11;
473
+ _context15.next = 11;
436
474
  return wait();
437
475
  case 11:
438
476
  expect(instance.get('value')).to.eql(100);
439
477
  prev.click();
440
- _context13.next = 15;
478
+ _context15.next = 15;
441
479
  return wait();
442
480
  case 15:
443
481
  expect(instance.get('value')).to.eql(90);
444
482
  case 16:
445
483
  case "end":
446
- return _context13.stop();
484
+ return _context15.stop();
447
485
  }
448
- }, _callee9);
486
+ }, _callee10);
449
487
  })));
450
488
  });
@@ -78,7 +78,8 @@ export function minMaxStep(value, min, max, step) {
78
78
  if (value >= max) return max;
79
79
  if (value <= min) return min;
80
80
  if (step) {
81
- value = Number((Math.round((value - min) / step) * step + min).toFixed(10));
81
+ var _min = min === -Infinity ? 0 : min;
82
+ value = Number((Math.round((value - _min) / step) * step + _min).toFixed(10));
82
83
  // value = Number((Math.round(value / step) * step).toFixed(10))
83
84
  return minMaxStep(value, min, max, null);
84
85
  }
@@ -5,6 +5,7 @@ import _JSON$stringify from "@babel/runtime-corejs3/core-js/json/stringify";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
6
6
  import _findIndexInstanceProperty from "@babel/runtime-corejs3/core-js/instance/find-index";
7
7
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js/instance/includes";
8
+ import _Array$from from "@babel/runtime-corejs3/core-js/array/from";
8
9
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
9
10
  import { __decorate } from "tslib";
10
11
  import BasicDemo from '~/components/table/demos/basic';
@@ -784,21 +785,20 @@ describe('Table', function () {
784
785
  return wait();
785
786
  case 6:
786
787
  expect(element.innerHTML).to.matchSnapshot();
787
- debugger;
788
788
  expect(table.getCheckedData()).to.have.lengthOf(8);
789
789
  arrow = element.querySelector('.k-table-arrow');
790
790
  arrow.click();
791
- _context21.next = 13;
791
+ _context21.next = 12;
792
792
  return wait();
793
- case 13:
793
+ case 12:
794
794
  expect(element.innerHTML).to.matchSnapshot();
795
795
  arrow.click();
796
- _context21.next = 17;
796
+ _context21.next = 16;
797
797
  return wait();
798
- case 17:
798
+ case 16:
799
799
  expect(element.innerHTML).to.matchSnapshot();
800
800
  expect(table.getCheckedData()).to.have.lengthOf(8);
801
- case 19:
801
+ case 18:
802
802
  case "end":
803
803
  return _context21.stop();
804
804
  }
@@ -1102,4 +1102,82 @@ describe('Table', function () {
1102
1102
  }
1103
1103
  }, _callee24);
1104
1104
  })));
1105
+ it('fixHeader with Affix header scroll sync', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25() {
1106
+ var Demo, _mount27, instance, element, scrollContainer, affixWrapper1, affixWrapper2, affixWrapper3;
1107
+ return _regeneratorRuntime.wrap(function _callee25$(_context32) {
1108
+ while (1) switch (_context32.prev = _context32.next) {
1109
+ case 0:
1110
+ Demo = /*#__PURE__*/function (_Component6) {
1111
+ _inheritsLoose(Demo, _Component6);
1112
+ function Demo() {
1113
+ var _context31;
1114
+ var _this5;
1115
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1116
+ args[_key5] = arguments[_key5];
1117
+ }
1118
+ _this5 = _Component6.call.apply(_Component6, _concatInstanceProperty(_context31 = [this]).call(_context31, args)) || this;
1119
+ _this5.Table = Table;
1120
+ _this5.TableColumn = TableColumn;
1121
+ return _this5;
1122
+ }
1123
+ Demo.defaults = function defaults() {
1124
+ return {
1125
+ data: _Array$from({
1126
+ length: 10
1127
+ }, function (_, i) {
1128
+ return {
1129
+ name: "Name " + i,
1130
+ column1: "Column1 " + i,
1131
+ column2: "Column2 " + i,
1132
+ column3: "Column3 " + i,
1133
+ action: "Action " + i
1134
+ };
1135
+ }),
1136
+ fixHeader: 200,
1137
+ virtual: false,
1138
+ stickScrollbar: false
1139
+ };
1140
+ };
1141
+ return Demo;
1142
+ }(Component);
1143
+ Demo.template = "\n const {Table, TableColumn} = this;\n const {data, fixHeader, virtual, stickScrollbar} = this.get();\n <Table data={data} fixHeader={fixHeader} virtual={virtual} stickScrollbar={stickScrollbar} ref=\"table\">\n <TableColumn fixed=\"left\" key=\"name\" title=\"Name\" width=\"200\" />\n <TableColumn key=\"column1\" title=\"Column1\" width=\"300\" />\n <TableColumn key=\"column2\" title=\"Column2\" width=\"300\" />\n <TableColumn key=\"column3\" title=\"Column3\" width=\"300\" />\n <TableColumn fixed=\"right\" key=\"action\" title=\"Action\" width=\"200\" />\n </Table>\n ";
1144
+ _mount27 = mount(Demo), instance = _mount27[0], element = _mount27[1]; // Test 1: fixHeader only - scroll left 50px
1145
+ _context32.next = 5;
1146
+ return wait();
1147
+ case 5:
1148
+ scrollContainer = element.querySelector('.k-table-wrapper');
1149
+ scrollContainer.scrollLeft = 50;
1150
+ _context32.next = 9;
1151
+ return wait(100);
1152
+ case 9:
1153
+ affixWrapper1 = element.querySelector('.k-table-affix-header .k-affix-wrapper');
1154
+ expect(affixWrapper1.scrollLeft).to.eql(50);
1155
+ // Test 2: fixHeader + virtual - scroll left 50px more (total 100px)
1156
+ instance.set('virtual', true);
1157
+ _context32.next = 14;
1158
+ return wait();
1159
+ case 14:
1160
+ scrollContainer.scrollLeft = 100;
1161
+ _context32.next = 17;
1162
+ return wait(100);
1163
+ case 17:
1164
+ affixWrapper2 = element.querySelector('.k-table-affix-header .k-affix-wrapper');
1165
+ expect(affixWrapper2.scrollLeft).to.eql(100);
1166
+ // Test 3: stickScrollbar + fixHeader - scroll right 50px (back to 50px)
1167
+ instance.set('stickScrollbar', true);
1168
+ _context32.next = 22;
1169
+ return wait();
1170
+ case 22:
1171
+ scrollContainer.scrollLeft = 50;
1172
+ _context32.next = 25;
1173
+ return wait(100);
1174
+ case 25:
1175
+ affixWrapper3 = element.querySelector('.k-table-affix-header .k-affix-wrapper');
1176
+ expect(affixWrapper3.scrollLeft).to.eql(50);
1177
+ case 27:
1178
+ case "end":
1179
+ return _context32.stop();
1180
+ }
1181
+ }, _callee25);
1182
+ })));
1105
1183
  });
@@ -17,7 +17,7 @@ export function useStickyHeader(callbacks) {
17
17
  });
18
18
  // when the scroll element scroll horizontally, scroll the sticky header too
19
19
  callbacks.push(function (scrollLeft) {
20
- if (isNull(stickHeader.value)) return;
20
+ if (isNull(stickHeader.value) && !instance.get('fixHeader')) return;
21
21
  var affixHeadWrapper = headRef.value.parentElement;
22
22
  affixHeadWrapper.scrollLeft = scrollLeft;
23
23
  });