@king-design/react 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.
- package/components/cascader/index.spec.js +18 -19
- package/components/datepicker/basepicker.d.ts +6 -25
- package/components/datepicker/basepicker.js +22 -234
- package/components/datepicker/calendar.d.ts +36 -6
- package/components/datepicker/calendar.js +4 -0
- package/components/datepicker/calendar.vdt.js +21 -5
- package/components/datepicker/dayjs.d.ts +2 -2
- package/components/datepicker/dayjs.js +6 -0
- package/components/datepicker/helpers.d.ts +8 -7
- package/components/datepicker/helpers.js +2 -3
- package/components/datepicker/index.d.ts +26 -19
- package/components/datepicker/index.js +21 -13
- package/components/datepicker/index.spec.js +1389 -633
- package/components/datepicker/index.vdt.js +43 -46
- package/components/datepicker/shortcuts.d.ts +1 -1
- package/components/datepicker/styles.d.ts +22 -0
- package/components/datepicker/styles.js +26 -4
- package/components/datepicker/useConfirm.d.ts +6 -0
- package/components/datepicker/useConfirm.js +65 -0
- package/components/datepicker/useDisabled.d.ts +7 -5
- package/components/datepicker/useDisabled.js +22 -27
- package/components/datepicker/useFormats.d.ts +2 -2
- package/components/datepicker/useFormats.js +9 -3
- package/components/datepicker/useHighlight.d.ts +14 -0
- package/components/datepicker/useHighlight.js +60 -0
- package/components/datepicker/useKeyboards.js +2 -1
- package/components/datepicker/useMergeRange.d.ts +5 -0
- package/components/datepicker/useMergeRange.js +45 -0
- package/components/datepicker/useMonths.js +5 -3
- package/components/datepicker/usePanel.d.ts +1 -10
- package/components/datepicker/usePanel.js +19 -32
- package/components/datepicker/useQuarters.d.ts +15 -0
- package/components/datepicker/useQuarters.js +36 -0
- package/components/datepicker/useShowDate.js +10 -2
- package/components/datepicker/useStatus.d.ts +1 -1
- package/components/datepicker/useStatus.js +33 -16
- package/components/datepicker/useValue.d.ts +12 -6
- package/components/datepicker/useValue.js +49 -45
- package/components/datepicker/useValueBase.d.ts +28 -0
- package/components/datepicker/useValueBase.js +277 -0
- package/components/datepicker/useWeeks.d.ts +19 -0
- package/components/datepicker/useWeeks.js +48 -0
- package/components/datepicker/useYears.js +6 -3
- package/components/dialog/useFixBody.js +6 -58
- package/components/dropdown/dropdown.d.ts +1 -0
- package/components/dropdown/dropdown.js +7 -4
- package/components/ellipsis/styles.js +1 -1
- package/components/form/styles.js +1 -1
- package/components/input/index.d.ts +2 -0
- package/components/input/index.js +6 -0
- package/components/input/index.spec.js +45 -0
- package/components/input/index.vdt.js +4 -3
- package/components/input/useAutoWidth.d.ts +2 -0
- package/components/input/useAutoWidth.js +19 -1
- package/components/scrollSelect/index.spec.js +4 -6
- package/components/scrollSelect/useMouseEvents.js +22 -9
- package/components/select/base.d.ts +1 -1
- package/components/select/base.js +3 -2
- package/components/select/base.vdt.js +5 -2
- package/components/select/index.spec.js +329 -82
- package/components/select/option.d.ts +1 -0
- package/components/select/option.js +10 -2
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +4 -2
- package/components/select/styles.d.ts +79 -0
- package/components/select/styles.js +1 -0
- package/components/select/useFilterable.js +2 -1
- package/components/select/useInput.d.ts +1 -1
- package/components/select/useInput.js +7 -4
- package/components/select/useSearchable.js +1 -0
- package/components/table/index.spec.js +84 -6
- package/components/table/useStickyHeader.js +1 -1
- package/components/timepicker/index.spec.js +298 -128
- package/components/timepicker/panelPicker.d.ts +23 -17
- package/components/timepicker/panelPicker.js +7 -4
- package/components/timepicker/panelPicker.vdt.js +8 -4
- package/components/timepicker/selectPicker.d.ts +5 -4
- package/components/timepicker/useConfirm.d.ts +6 -0
- package/components/timepicker/useConfirm.js +19 -0
- package/components/timepicker/useDefaultValue.d.ts +4 -0
- package/components/timepicker/useDefaultValue.js +27 -0
- package/components/timepicker/useDisabled.d.ts +7 -4
- package/components/timepicker/useDisabled.js +13 -4
- package/components/timepicker/useFormats.d.ts +1 -1
- package/components/timepicker/useValue.d.ts +14 -8
- package/components/timepicker/useValue.js +14 -15
- package/components/tour/index.d.ts +2 -0
- package/components/tour/index.js +2 -0
- package/components/tour/index.spec.d.ts +1 -0
- package/components/tour/index.spec.js +356 -0
- package/components/tour/step.d.ts +23 -0
- package/components/tour/step.js +46 -0
- package/components/tour/step.vdt.js +74 -0
- package/components/tour/styles.d.ts +7 -0
- package/components/tour/styles.js +84 -0
- package/components/tour/tour.d.ts +73 -0
- package/components/tour/tour.js +70 -0
- package/components/tour/tour.vdt.js +66 -0
- package/components/tour/useArrow.d.ts +4 -0
- package/components/tour/useArrow.js +40 -0
- package/components/tour/useFixBody.d.ts +4 -0
- package/components/tour/useFixBody.js +17 -0
- package/components/tour/useHighlight.d.ts +4 -0
- package/components/tour/useHighlight.js +31 -0
- package/components/tour/useMaskClosable.d.ts +1 -0
- package/components/tour/useMaskClosable.js +25 -0
- package/components/tour/useNavigation.d.ts +5 -0
- package/components/tour/useNavigation.js +103 -0
- package/components/tour/usePosition.d.ts +6 -0
- package/components/tour/usePosition.js +93 -0
- package/components/tour/useSteps.d.ts +6 -0
- package/components/tour/useSteps.js +68 -0
- package/hooks/useFixBody.d.ts +11 -0
- package/hooks/useFixBody.js +72 -0
- package/index.d.ts +3 -2
- package/index.js +3 -2
- 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,
|
|
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-react';
|
|
10
10
|
describe('ScrollSelect', function () {
|
|
11
|
-
afterEach(
|
|
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:
|
|
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: -
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,
|
|
76
|
+
var _onWheel = throttle(onWheel, 50, function (e) {
|
|
72
77
|
return e.preventDefault();
|
|
73
78
|
});
|
|
74
79
|
function onClick(item, index) {
|
|
75
|
-
|
|
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(
|
|
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(
|
|
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) {
|