@king-design/vue 3.5.2 → 3.6.0

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 (119) hide show
  1. package/__tests__/__snapshots__/Vue Next Demos.md +111 -47
  2. package/__tests__/components/misc.spec.ts +93 -0
  3. package/components/cascader/index.spec.js +18 -19
  4. package/components/datepicker/basepicker.d.ts +6 -25
  5. package/components/datepicker/basepicker.js +22 -234
  6. package/components/datepicker/calendar.d.ts +36 -6
  7. package/components/datepicker/calendar.js +4 -0
  8. package/components/datepicker/calendar.vdt.js +21 -5
  9. package/components/datepicker/dayjs.d.ts +2 -2
  10. package/components/datepicker/dayjs.js +6 -0
  11. package/components/datepicker/helpers.d.ts +8 -7
  12. package/components/datepicker/helpers.js +2 -3
  13. package/components/datepicker/index.d.ts +26 -19
  14. package/components/datepicker/index.js +21 -13
  15. package/components/datepicker/index.spec.js +1389 -633
  16. package/components/datepicker/index.vdt.js +43 -46
  17. package/components/datepicker/shortcuts.d.ts +1 -1
  18. package/components/datepicker/styles.d.ts +22 -0
  19. package/components/datepicker/styles.js +26 -4
  20. package/components/datepicker/useConfirm.d.ts +6 -0
  21. package/components/datepicker/useConfirm.js +65 -0
  22. package/components/datepicker/useDisabled.d.ts +7 -5
  23. package/components/datepicker/useDisabled.js +22 -27
  24. package/components/datepicker/useFormats.d.ts +2 -2
  25. package/components/datepicker/useFormats.js +9 -3
  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 +5 -0
  30. package/components/datepicker/useMergeRange.js +45 -0
  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/useQuarters.d.ts +15 -0
  35. package/components/datepicker/useQuarters.js +36 -0
  36. package/components/datepicker/useShowDate.js +10 -2
  37. package/components/datepicker/useStatus.d.ts +1 -1
  38. package/components/datepicker/useStatus.js +33 -16
  39. package/components/datepicker/useValue.d.ts +12 -6
  40. package/components/datepicker/useValue.js +49 -45
  41. package/components/datepicker/useValueBase.d.ts +28 -0
  42. package/components/datepicker/useValueBase.js +277 -0
  43. package/components/datepicker/useWeeks.d.ts +19 -0
  44. package/components/datepicker/useWeeks.js +48 -0
  45. package/components/datepicker/useYears.js +6 -3
  46. package/components/dialog/useFixBody.js +6 -58
  47. package/components/dropdown/dropdown.d.ts +1 -0
  48. package/components/dropdown/dropdown.js +7 -4
  49. package/components/ellipsis/styles.js +1 -1
  50. package/components/form/styles.js +1 -1
  51. package/components/input/index.d.ts +2 -0
  52. package/components/input/index.js +6 -0
  53. package/components/input/index.spec.js +45 -0
  54. package/components/input/index.vdt.js +4 -3
  55. package/components/input/useAutoWidth.d.ts +2 -0
  56. package/components/input/useAutoWidth.js +19 -1
  57. package/components/scrollSelect/index.spec.js +4 -6
  58. package/components/scrollSelect/useMouseEvents.js +22 -9
  59. package/components/select/base.d.ts +1 -1
  60. package/components/select/base.js +3 -2
  61. package/components/select/base.vdt.js +5 -2
  62. package/components/select/index.spec.js +329 -82
  63. package/components/select/option.d.ts +1 -0
  64. package/components/select/option.js +10 -2
  65. package/components/select/select.d.ts +1 -0
  66. package/components/select/select.js +4 -2
  67. package/components/select/styles.d.ts +79 -0
  68. package/components/select/styles.js +1 -0
  69. package/components/select/useFilterable.js +2 -1
  70. package/components/select/useInput.d.ts +1 -1
  71. package/components/select/useInput.js +7 -4
  72. package/components/select/useSearchable.js +1 -0
  73. package/components/table/index.spec.js +84 -6
  74. package/components/table/useStickyHeader.js +1 -1
  75. package/components/timepicker/index.spec.js +298 -128
  76. package/components/timepicker/panelPicker.d.ts +23 -17
  77. package/components/timepicker/panelPicker.js +7 -4
  78. package/components/timepicker/panelPicker.vdt.js +8 -4
  79. package/components/timepicker/selectPicker.d.ts +5 -4
  80. package/components/timepicker/useConfirm.d.ts +6 -0
  81. package/components/timepicker/useConfirm.js +19 -0
  82. package/components/timepicker/useDefaultValue.d.ts +4 -0
  83. package/components/timepicker/useDefaultValue.js +27 -0
  84. package/components/timepicker/useDisabled.d.ts +7 -4
  85. package/components/timepicker/useDisabled.js +13 -4
  86. package/components/timepicker/useFormats.d.ts +1 -1
  87. package/components/timepicker/useValue.d.ts +14 -8
  88. package/components/timepicker/useValue.js +14 -15
  89. package/components/tour/index.d.ts +2 -0
  90. package/components/tour/index.js +2 -0
  91. package/components/tour/index.spec.d.ts +1 -0
  92. package/components/tour/index.spec.js +356 -0
  93. package/components/tour/step.d.ts +23 -0
  94. package/components/tour/step.js +46 -0
  95. package/components/tour/step.vdt.js +74 -0
  96. package/components/tour/styles.d.ts +7 -0
  97. package/components/tour/styles.js +84 -0
  98. package/components/tour/tour.d.ts +73 -0
  99. package/components/tour/tour.js +70 -0
  100. package/components/tour/tour.vdt.js +66 -0
  101. package/components/tour/useArrow.d.ts +4 -0
  102. package/components/tour/useArrow.js +40 -0
  103. package/components/tour/useFixBody.d.ts +4 -0
  104. package/components/tour/useFixBody.js +17 -0
  105. package/components/tour/useHighlight.d.ts +4 -0
  106. package/components/tour/useHighlight.js +31 -0
  107. package/components/tour/useMaskClosable.d.ts +1 -0
  108. package/components/tour/useMaskClosable.js +25 -0
  109. package/components/tour/useNavigation.d.ts +5 -0
  110. package/components/tour/useNavigation.js +103 -0
  111. package/components/tour/usePosition.d.ts +6 -0
  112. package/components/tour/usePosition.js +93 -0
  113. package/components/tour/useSteps.d.ts +6 -0
  114. package/components/tour/useSteps.js +68 -0
  115. package/hooks/useFixBody.d.ts +11 -0
  116. package/hooks/useFixBody.js +72 -0
  117. package/index.d.ts +3 -2
  118. package/index.js +3 -2
  119. package/package.json +2 -2
@@ -3,14 +3,12 @@ import _asyncToGenerator from "@babel/runtime-corejs3/helpers/asyncToGenerator";
3
3
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/concat";
4
4
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
5
5
  import _regeneratorRuntime from "@babel/runtime-corejs3/regenerator";
6
- import { mount, unmount, dispatchEvent, wait } from '../../test/utils';
6
+ import { mount, dispatchEvent, wait } from '../../test/utils';
7
7
  import BasicDemo from '~/components/scrollSelect/demos/basic';
8
8
  import { ScrollSelect } from './';
9
9
  import { Component } from 'intact-vue-next';
10
10
  describe('ScrollSelect', function () {
11
- afterEach(function () {
12
- return unmount();
13
- });
11
+ // afterEach(() => unmount());
14
12
  it('should select by scroll', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
15
13
  var _mount, instance, element;
16
14
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -18,14 +16,14 @@ describe('ScrollSelect', function () {
18
16
  case 0:
19
17
  _mount = mount(BasicDemo), instance = _mount[0], element = _mount[1]; // scroll
20
18
  dispatchEvent(element.firstElementChild, 'wheel', {
21
- deltaY: 1
19
+ deltaY: 30
22
20
  });
23
21
  _context.next = 4;
24
22
  return wait(100);
25
23
  case 4:
26
24
  expect(instance.get('value')).to.eql(1);
27
25
  dispatchEvent(element.firstElementChild, 'wheel', {
28
- deltaY: -1
26
+ deltaY: -30
29
27
  });
30
28
  _context.next = 8;
31
29
  return wait(100);
@@ -12,6 +12,7 @@ export function useMouseEvents(translate, list) {
12
12
  var y;
13
13
  var itemHeight;
14
14
  var deltaY;
15
+ var wheelDeltaY = 0;
15
16
  var _useDraggable = useDraggable({
16
17
  onStart: function onStart(e) {
17
18
  dragged = false;
@@ -21,11 +22,11 @@ export function useMouseEvents(translate, list) {
21
22
  deltaY = meta.deltaY;
22
23
  },
23
24
  onMove: function onMove(e) {
24
- var deltaY = e.clientY - y;
25
+ var deltaY = (e.clientY - y) * 0.8;
25
26
  dragged = !!deltaY;
26
27
  y = e.clientY;
27
28
  var _deltaY = y - initY;
28
- var offsetIndex = Math.floor(Math.abs(_deltaY) / itemHeight);
29
+ var offsetIndex = Math.floor(Math.abs(_deltaY) / itemHeight * 1.2);
29
30
  if (offsetIndex) {
30
31
  if (_deltaY < 0) {
31
32
  offsetIndex = -offsetIndex;
@@ -60,24 +61,36 @@ export function useMouseEvents(translate, list) {
60
61
  function onWheel(e) {
61
62
  e.preventDefault();
62
63
  itemHeight = getItemHeight();
63
- if (e.deltaY > 0) {
64
- // down
65
- setByRelativeIndex(1, null, true);
66
- } else {
67
- setByRelativeIndex(-1, null, true);
64
+ var threshold = itemHeight * 0.6;
65
+ wheelDeltaY += e.deltaY;
66
+ if (Math.abs(wheelDeltaY) >= threshold) {
67
+ if (wheelDeltaY > 0) {
68
+ setByRelativeIndex(1, null, true);
69
+ } else {
70
+ setByRelativeIndex(-1, null, true);
71
+ }
72
+ wheelDeltaY = 0;
68
73
  }
69
74
  }
70
75
  // throttle onWheel
71
- var _onWheel = throttle(onWheel, 0, function (e) {
76
+ var _onWheel = throttle(onWheel, 50, function (e) {
72
77
  return e.preventDefault();
73
78
  });
74
79
  function onClick(item, index) {
75
- // if _dragged, do not trigger click event, #123
80
+ var _context2;
81
+ // if dragged, do not trigger click event
76
82
  if (dragged) return;
77
83
  var _instance$get = instance.get(),
78
84
  count = _instance$get.count;
79
85
  var half = Math.floor(count / 2);
80
86
  var itemHeight = getItemHeight();
87
+ var currentIndex = _findIndexInstanceProperty(_context2 = list.data.value).call(_context2, function (v) {
88
+ return v.value === list.value.value;
89
+ });
90
+ var targetOffset = index - half;
91
+ if (currentIndex + targetOffset < 0 || currentIndex + targetOffset >= list.data.value.length) {
92
+ return;
93
+ }
81
94
  translate.set(translate.value - itemHeight * (index - half));
82
95
  marginTop.set(marginTop.value + itemHeight * (index - half));
83
96
  list.setValue(item.value, true);
@@ -67,7 +67,7 @@ export declare abstract class BaseSelect<T extends BaseSelectProps<any> = BaseSe
67
67
  position(): void;
68
68
  show(): void;
69
69
  hide(): void;
70
- resetKeywords(keywords: State<string>): void;
70
+ resetKeywords(): void;
71
71
  protected hasValue(): any;
72
72
  private delete;
73
73
  protected clear(e: MouseEvent): void;
@@ -90,8 +90,8 @@ export var BaseSelect = /*#__PURE__*/function (_Component) {
90
90
  _proto.hide = function hide() {
91
91
  this.set('show', false);
92
92
  };
93
- _proto.resetKeywords = function resetKeywords(keywords) {
94
- keywords.set('');
93
+ _proto.resetKeywords = function resetKeywords() {
94
+ this.input.keywords.set('');
95
95
  };
96
96
  _proto.hasValue = function hasValue() {
97
97
  var _this$get = this.get(),
@@ -142,5 +142,6 @@ BaseSelect.events = events;
142
142
  __decorate([bind], BaseSelect.prototype, "position", null);
143
143
  __decorate([bind], BaseSelect.prototype, "show", null);
144
144
  __decorate([bind], BaseSelect.prototype, "hide", null);
145
+ __decorate([bind], BaseSelect.prototype, "resetKeywords", null);
145
146
  __decorate([bind], BaseSelect.prototype, "clear", null);
146
147
  __decorate([bind], BaseSelect.prototype, "onKeydown", null);
@@ -44,7 +44,8 @@ export default function ($props, $blocks, $__proto__) {
44
44
  position = _this$get.position,
45
45
  flat = _flatInstanceProperty(_this$get),
46
46
  nowrap = _this$get.nowrap,
47
- draggable = _this$get.draggable;
47
+ draggable = _this$get.draggable,
48
+ range = _this$get.range;
48
49
  var k = this.config.k;
49
50
  var classNameObj = (_classNameObj = {}, _classNameObj[k + "-select"] = true, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-" + size] = size !== 'default', _classNameObj[k + "-fluid"] = fluid, _classNameObj[k + "-inline"] = inline, _classNameObj[k + "-flat"] = flat, _classNameObj[k + "-nowrap"] = nowrap, _classNameObj[className] = className, _classNameObj[$props.className] = $props.className, _classNameObj[makeStyles(k)] = true, _classNameObj);
50
51
  var placeholder = this.getPlaceholder();
@@ -86,6 +87,7 @@ export default function ($props, $blocks, $__proto__) {
86
87
  'disabled': disabled,
87
88
  'container': container,
88
89
  'position': position,
90
+ 'alwaysShowOnClick': $props.alwaysShowOnClick,
89
91
  'children': [_$cv('div', _extends({}, getRestProps(_this), {
90
92
  'className': _$cn(classNameObj),
91
93
  'tabindex': disabled ? '-1' : '0',
@@ -94,7 +96,8 @@ export default function ($props, $blocks, $__proto__) {
94
96
  'style': !isNullOrUndefined(width) ? addStyle(style, {
95
97
  width: width + "px"
96
98
  }) : style,
97
- 'ref': triggerRef
99
+ 'ref': triggerRef,
100
+ 'ev-click': $props.onClick
98
101
  }), [$blocks.prefix ? _$ce(2, 'div', (_$blocks['prefix'] = function ($super) {
99
102
  return null;
100
103
  }, __$blocks['prefix'] = function ($super, data) {