@king-design/intact 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.
- package/components/button/demos/basic.md +0 -1
- package/components/cascader/index.spec.ts +7 -6
- package/components/copy/index.spec.ts +9 -14
- package/components/datepicker/basepicker.ts +26 -314
- package/components/datepicker/calendar.ts +3 -1
- package/components/datepicker/calendar.vdt +5 -2
- package/components/datepicker/dayjs.ts +2 -16
- package/components/datepicker/demos/multiple.md +5 -0
- package/components/datepicker/demos/yearMonth.md +2 -8
- package/components/datepicker/helpers.ts +5 -7
- package/components/datepicker/index.md +1 -2
- package/components/datepicker/index.spec.ts +596 -157
- package/components/datepicker/index.ts +16 -33
- package/components/datepicker/index.vdt +41 -35
- package/components/datepicker/shortcuts.ts +1 -1
- package/components/datepicker/styles.ts +27 -18
- package/components/datepicker/useConfirm.ts +82 -0
- package/components/datepicker/useDisabled.ts +29 -31
- package/components/datepicker/useFormats.ts +8 -4
- package/components/datepicker/useHighlight.ts +81 -0
- package/components/datepicker/useKeyboards.ts +2 -1
- package/components/datepicker/useMergeRange.ts +12 -12
- package/components/datepicker/useMonths.ts +6 -3
- package/components/datepicker/usePanel.ts +19 -19
- package/components/datepicker/useShowDate.ts +21 -41
- package/components/datepicker/useStatus.ts +34 -15
- package/components/datepicker/useValue.ts +43 -72
- package/components/datepicker/useValueBase.ts +312 -0
- package/components/datepicker/useWeeks.ts +1 -1
- package/components/datepicker/useYears.ts +7 -3
- package/components/dropdown/dropdown.ts +5 -4
- package/components/dropdown/index.md +1 -0
- package/components/dropdown/item.ts +1 -1
- package/components/dropdown/useKeyboard.ts +0 -1
- package/components/form/form.ts +4 -0
- package/components/form/index.md +2 -1
- package/components/form/index.spec.ts +2 -0
- package/components/input/index.spec.ts +42 -0
- package/components/input/index.ts +8 -0
- package/components/input/index.vdt +3 -4
- package/components/input/useAutoWidth.ts +19 -1
- package/components/menu/demos/horizontal.md +7 -1
- package/components/menu/index.spec.ts +19 -0
- package/components/menu/styles.ts +2 -1
- package/components/scrollSelect/useMouseEvents.ts +5 -4
- package/components/select/base.ts +3 -2
- package/components/select/base.vdt +2 -1
- package/components/select/demos/creatable.md +2 -2
- package/components/select/index.md +1 -1
- package/components/select/index.spec.ts +142 -36
- package/components/select/menu.ts +1 -1
- package/components/select/option.ts +2 -1
- package/components/select/select.ts +1 -0
- package/components/select/styles.ts +3 -1
- package/components/select/useCard.ts +22 -4
- package/components/select/useInput.ts +5 -9
- package/components/spinner/index.spec.ts +18 -0
- package/components/spinner/useValue.ts +2 -1
- package/components/table/index.spec.ts +69 -1
- package/components/table/useStickyHeader.ts +1 -1
- package/components/timepicker/index.spec.ts +145 -27
- package/components/timepicker/panelPicker.ts +10 -4
- package/components/timepicker/panelPicker.vdt +3 -5
- package/components/timepicker/styles.ts +1 -0
- package/components/timepicker/useConfirm.ts +33 -0
- package/components/timepicker/useDefaultValue.ts +30 -0
- package/components/timepicker/useDisabled.ts +17 -4
- package/components/timepicker/useFormats.ts +1 -1
- package/components/timepicker/useValue.ts +22 -19
- package/components/tour/index.spec.ts +1 -1
- package/es/components/cascader/index.spec.js +18 -19
- package/es/components/copy/index.spec.js +14 -31
- package/es/components/datepicker/basepicker.d.ts +6 -27
- package/es/components/datepicker/basepicker.js +23 -268
- package/es/components/datepicker/calendar.d.ts +4 -2
- package/es/components/datepicker/dayjs.d.ts +2 -13
- package/es/components/datepicker/helpers.d.ts +3 -2
- package/es/components/datepicker/helpers.js +2 -3
- package/es/components/datepicker/index.d.ts +21 -29
- package/es/components/datepicker/index.js +22 -32
- package/es/components/datepicker/index.spec.js +1277 -484
- package/es/components/datepicker/index.vdt.js +39 -38
- package/es/components/datepicker/shortcuts.d.ts +1 -1
- package/es/components/datepicker/styles.d.ts +7 -2
- package/es/components/datepicker/styles.js +10 -15
- package/es/components/datepicker/useConfirm.d.ts +6 -0
- package/es/components/datepicker/useConfirm.js +65 -0
- package/es/components/datepicker/useDisabled.d.ts +5 -3
- package/es/components/datepicker/useDisabled.js +22 -27
- package/es/components/datepicker/useFormats.d.ts +2 -2
- package/es/components/datepicker/useFormats.js +6 -2
- package/es/components/datepicker/useHighlight.d.ts +14 -0
- package/es/components/datepicker/useHighlight.js +60 -0
- package/es/components/datepicker/useKeyboards.js +2 -1
- package/es/components/datepicker/useMergeRange.d.ts +1 -1
- package/es/components/datepicker/useMergeRange.js +11 -16
- package/es/components/datepicker/useMonths.js +5 -3
- package/es/components/datepicker/usePanel.d.ts +1 -10
- package/es/components/datepicker/usePanel.js +19 -32
- package/es/components/datepicker/useShowDate.d.ts +1 -1
- package/es/components/datepicker/useShowDate.js +15 -40
- package/es/components/datepicker/useStatus.js +33 -16
- package/es/components/datepicker/useValue.d.ts +11 -6
- package/es/components/datepicker/useValue.js +49 -69
- package/es/components/datepicker/useValueBase.d.ts +28 -0
- package/es/components/datepicker/useValueBase.js +280 -0
- package/es/components/datepicker/useYears.js +6 -3
- package/es/components/dropdown/dropdown.d.ts +1 -0
- package/es/components/dropdown/dropdown.js +7 -4
- package/es/components/form/form.d.ts +1 -0
- package/es/components/form/form.js +7 -0
- package/es/components/form/index.spec.js +10 -8
- package/es/components/input/index.d.ts +2 -0
- package/es/components/input/index.js +6 -0
- package/es/components/input/index.spec.js +45 -0
- package/es/components/input/index.vdt.js +4 -3
- package/es/components/input/useAutoWidth.d.ts +2 -0
- package/es/components/input/useAutoWidth.js +19 -1
- package/es/components/menu/index.spec.js +28 -0
- package/es/components/menu/styles.js +2 -2
- package/es/components/scrollSelect/useMouseEvents.js +5 -4
- package/es/components/select/base.d.ts +1 -1
- package/es/components/select/base.js +3 -2
- package/es/components/select/base.vdt.js +4 -3
- package/es/components/select/index.spec.js +346 -218
- package/es/components/select/menu.js +1 -1
- package/es/components/select/option.js +2 -1
- package/es/components/select/select.js +2 -1
- package/es/components/select/styles.d.ts +79 -0
- package/es/components/select/styles.js +1 -0
- package/es/components/select/useCard.d.ts +4 -3
- package/es/components/select/useCard.js +15 -4
- package/es/components/select/useInput.d.ts +1 -1
- package/es/components/select/useInput.js +4 -4
- package/es/components/spinner/index.spec.js +82 -44
- package/es/components/spinner/useValue.js +2 -1
- package/es/components/table/index.spec.js +84 -6
- package/es/components/table/useStickyHeader.js +1 -1
- package/es/components/timepicker/index.spec.js +298 -128
- package/es/components/timepicker/panelPicker.d.ts +21 -16
- package/es/components/timepicker/panelPicker.js +7 -4
- package/es/components/timepicker/panelPicker.vdt.js +5 -9
- package/es/components/timepicker/selectPicker.d.ts +4 -3
- package/es/components/timepicker/styles.js +1 -1
- package/es/components/timepicker/useConfirm.d.ts +6 -0
- package/es/components/timepicker/useConfirm.js +19 -0
- package/es/components/timepicker/useDefaultValue.d.ts +4 -0
- package/es/components/timepicker/useDefaultValue.js +27 -0
- package/es/components/timepicker/useDisabled.d.ts +6 -3
- package/es/components/timepicker/useDisabled.js +13 -4
- package/es/components/timepicker/useFormats.d.ts +1 -1
- package/es/components/timepicker/useValue.d.ts +13 -8
- package/es/components/timepicker/useValue.js +14 -15
- package/es/components/tour/index.spec.js +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/site/data/components/button/demos/basic/react.js +0 -2
- package/es/site/data/components/datepicker/demos/multiple/index.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/index.js +2 -1
- package/es/site/data/components/datepicker/demos/multiple/react.d.ts +1 -0
- package/es/site/data/components/datepicker/demos/multiple/react.js +13 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/index.js +1 -3
- package/es/site/data/components/datepicker/demos/yearMonth/react.d.ts +0 -2
- package/es/site/data/components/datepicker/demos/yearMonth/react.js +1 -21
- package/es/site/data/components/menu/demos/horizontal/react.js +5 -1
- package/es/site/data/components/select/demos/creatable/react.js +2 -2
- package/es/site/data/components/select/demos/searchable/index.js +1 -1
- package/es/site/data/components/select/demos/searchable/react.js +1 -1
- package/es/site/data/components/tour/demos/customText/index.d.ts +19 -6
- package/es/site/data/components/tour/demos/customText/index.js +18 -17
- package/es/site/data/components/tour/demos/customText/react.d.ts +20 -6
- package/es/site/data/components/tour/demos/customText/react.js +31 -27
- package/es/test/demos.js +1 -1
- package/index.ts +2 -2
- package/package.json +2 -2
- package/components/datepicker/demos/nowrap.md +0 -35
- package/components/datepicker/usePosition.ts +0 -169
- package/es/components/datepicker/usePosition.d.ts +0 -10
- package/es/components/datepicker/usePosition.js +0 -166
- package/es/site/data/components/datepicker/demos/nowrap/index.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/index.js +0 -19
- package/es/site/data/components/datepicker/demos/nowrap/react.d.ts +0 -10
- package/es/site/data/components/datepicker/demos/nowrap/react.js +0 -49
- package/es/site/data/components/tour/demos/customButtons/index.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/index.js +0 -55
- package/es/site/data/components/tour/demos/customButtons/react.d.ts +0 -33
- package/es/site/data/components/tour/demos/customButtons/react.js +0 -99
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/slice";
|
|
2
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
3
|
+
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js/instance/trim";
|
|
4
|
+
import _spliceInstanceProperty from "@babel/runtime-corejs3/core-js/instance/splice";
|
|
5
|
+
import _sortInstanceProperty from "@babel/runtime-corejs3/core-js/instance/sort";
|
|
6
|
+
import { useInstance } from 'intact';
|
|
7
|
+
import { useState, watchState } from '../../hooks/useState';
|
|
8
|
+
import dayjs from './dayjs';
|
|
9
|
+
import { findValueIndex } from './helpers';
|
|
10
|
+
import { isEqualArray, last } from '../utils';
|
|
11
|
+
export function useValueBase(_ref, _ref2, panel, shouldUpdateValue, updateValueOnInput, getEqualType, updateStateValue) {
|
|
12
|
+
var createDateByValueFormat = _ref.createDateByValueFormat,
|
|
13
|
+
createDateByShowFormat = _ref.createDateByShowFormat,
|
|
14
|
+
getShowString = _ref.getShowString,
|
|
15
|
+
getValueString = _ref.getValueString;
|
|
16
|
+
var isDisabled = _ref2.isDisabled,
|
|
17
|
+
minDate = _ref2.minDate;
|
|
18
|
+
// Normalize the value to multipe values, no matter it's multipe or not
|
|
19
|
+
var value = useState([]);
|
|
20
|
+
var instance = useInstance();
|
|
21
|
+
var dayjsValue = [];
|
|
22
|
+
instance.watch('value', function (newValue, oldValue) {
|
|
23
|
+
if (isEqualArray(newValue, oldValue)) return;
|
|
24
|
+
dayjsValue = convertToDayjs(newValue);
|
|
25
|
+
updateStateValue(dayjsValue, value);
|
|
26
|
+
// should update keywords
|
|
27
|
+
instance.resetKeywords();
|
|
28
|
+
});
|
|
29
|
+
watchState(value, function (value) {
|
|
30
|
+
// silently update the keywords to display the currently selected value
|
|
31
|
+
instance.resetKeywords(true);
|
|
32
|
+
/**
|
|
33
|
+
* the position may changed after the input break line in multipe mode
|
|
34
|
+
* use Macro task instead of nextTick, because it has too many Micro tasks
|
|
35
|
+
*/
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
instance.position();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
instance.on('hide', function () {
|
|
41
|
+
// reset the value after hiding
|
|
42
|
+
value.set(_sliceInstanceProperty(dayjsValue).call(dayjsValue, 0));
|
|
43
|
+
});
|
|
44
|
+
watchState(instance.input.keywords, function (v) {
|
|
45
|
+
var _instance$get = instance.get(),
|
|
46
|
+
range = _instance$get.range,
|
|
47
|
+
multiple = _instance$get.multiple;
|
|
48
|
+
if (!multiple && v === '') return instance.set('value', null);
|
|
49
|
+
if (range) {
|
|
50
|
+
var _context;
|
|
51
|
+
var _v$split$map = _mapInstanceProperty(_context = v.split(/\s*~\s*/)).call(_context, function (s) {
|
|
52
|
+
return _trimInstanceProperty(s).call(s);
|
|
53
|
+
}),
|
|
54
|
+
start = _v$split$map[0],
|
|
55
|
+
end = _v$split$map[1];
|
|
56
|
+
if (start && end) {
|
|
57
|
+
var startDate = createDateByShowFormat(start);
|
|
58
|
+
if (!isValidDate(startDate)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var endDate = createDateByShowFormat(end);
|
|
62
|
+
if (!isValidDate(endDate)) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (endDate.isAfter(startDate)) {
|
|
66
|
+
updateValueOnInput([startDate, endDate]);
|
|
67
|
+
} else {
|
|
68
|
+
updateValueOnInput([endDate, startDate]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
var date = createDateByShowFormat(v);
|
|
73
|
+
if (isValidDate(date)) {
|
|
74
|
+
updateValueOnInput(date);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function convertToDayjs(v) {
|
|
79
|
+
if (!v || Array.isArray(v) && !v.length) return [];
|
|
80
|
+
var _instance$get2 = instance.get(),
|
|
81
|
+
multiple = _instance$get2.multiple;
|
|
82
|
+
if (!multiple) {
|
|
83
|
+
v = [v];
|
|
84
|
+
}
|
|
85
|
+
return _mapInstanceProperty(v).call(v, function (value) {
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
// range
|
|
88
|
+
return _mapInstanceProperty(value).call(value, createDateByValueFormat);
|
|
89
|
+
}
|
|
90
|
+
return createDateByValueFormat(value);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function convertToValueString(v) {
|
|
94
|
+
var results = _mapInstanceProperty(v).call(v, function (value) {
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
return _mapInstanceProperty(value).call(value, getValueString);
|
|
97
|
+
}
|
|
98
|
+
return getValueString(value);
|
|
99
|
+
});
|
|
100
|
+
if (!instance.get('multiple')) {
|
|
101
|
+
return results[0] || null;
|
|
102
|
+
}
|
|
103
|
+
return results;
|
|
104
|
+
}
|
|
105
|
+
function format() {
|
|
106
|
+
var _instance$get3 = instance.get(),
|
|
107
|
+
multiple = _instance$get3.multiple;
|
|
108
|
+
var labelValue = value.value;
|
|
109
|
+
if (multiple) {
|
|
110
|
+
labelValue = dayjsValue;
|
|
111
|
+
}
|
|
112
|
+
var results = _mapInstanceProperty(labelValue).call(labelValue, formatSingleValue);
|
|
113
|
+
if (!instance.get('multiple')) {
|
|
114
|
+
return results[0];
|
|
115
|
+
}
|
|
116
|
+
return results;
|
|
117
|
+
}
|
|
118
|
+
function formatSingleValue(value) {
|
|
119
|
+
if (Array.isArray(value)) {
|
|
120
|
+
if (value.length === 1) {
|
|
121
|
+
return getShowString(value[0]) + ' ~';
|
|
122
|
+
}
|
|
123
|
+
return _mapInstanceProperty(value).call(value, getShowString).join(' ~ ');
|
|
124
|
+
}
|
|
125
|
+
return getShowString(value);
|
|
126
|
+
}
|
|
127
|
+
function setSingleDate(v, fromInput) {
|
|
128
|
+
value.set([v]);
|
|
129
|
+
if (fromInput || shouldUpdateValue(v)) {
|
|
130
|
+
updateValue();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function addMultipeDate(v, fromInput) {
|
|
134
|
+
var _instance$get4 = instance.get(),
|
|
135
|
+
range = _instance$get4.range;
|
|
136
|
+
var _value = value.value;
|
|
137
|
+
_value = !_value ? [] : _sliceInstanceProperty(_value).call(_value);
|
|
138
|
+
if (range && v.length === 2) {
|
|
139
|
+
// pop the last value firstly, if it only has the start date
|
|
140
|
+
var lastValue = last(_value);
|
|
141
|
+
if (lastValue && lastValue.length < 2) {
|
|
142
|
+
_value.pop();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (_value.length > dayjsValue.length) {
|
|
146
|
+
// remove the temporary value added by selecting time directly
|
|
147
|
+
_value.pop();
|
|
148
|
+
}
|
|
149
|
+
var _shouldUpdateValue = true;
|
|
150
|
+
if (fromInput || shouldUpdateValue(v)) {
|
|
151
|
+
// if select the date/year/month, then toggle the value.
|
|
152
|
+
// if from input, treat the value as the final value
|
|
153
|
+
var index = findValueIndex(_value, v, getEqualType());
|
|
154
|
+
if (index > -1) {
|
|
155
|
+
_spliceInstanceProperty(_value).call(_value, index, 1);
|
|
156
|
+
} else {
|
|
157
|
+
_value.push(v);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
// select the datetime, only push the value,
|
|
161
|
+
// and unique the array on click confirm button
|
|
162
|
+
_value.push(v);
|
|
163
|
+
_shouldUpdateValue = false;
|
|
164
|
+
}
|
|
165
|
+
value.set(_value);
|
|
166
|
+
if (_shouldUpdateValue) {
|
|
167
|
+
updateValue();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function setValue(v, fromInput) {
|
|
171
|
+
var multiple = instance.get('multiple');
|
|
172
|
+
if (multiple) {
|
|
173
|
+
addMultipeDate(v, fromInput);
|
|
174
|
+
} else {
|
|
175
|
+
setSingleDate(v, fromInput);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function updateValue() {
|
|
179
|
+
var _value = value.value;
|
|
180
|
+
var _instance$get5 = instance.get(),
|
|
181
|
+
range = _instance$get5.range;
|
|
182
|
+
if (range) {
|
|
183
|
+
// only fix the last value, since the others are already fixed
|
|
184
|
+
var lastValue = last(_value);
|
|
185
|
+
if (lastValue) {
|
|
186
|
+
_sortInstanceProperty(lastValue).call(lastValue, function (a, b) {
|
|
187
|
+
return a.isAfter(b) ? 1 : -1;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
var valueStr = convertToValueString(_value);
|
|
192
|
+
// only trigger change event once
|
|
193
|
+
if (!isEqualArray(valueStr, instance.get('value'))) {
|
|
194
|
+
instance.set('value', valueStr);
|
|
195
|
+
instance.resetKeywords();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// TODO
|
|
199
|
+
function setMoment() {
|
|
200
|
+
var now = dayjs();
|
|
201
|
+
setValue(now, true);
|
|
202
|
+
instance.hide();
|
|
203
|
+
}
|
|
204
|
+
function unique() {
|
|
205
|
+
var _value = value.value;
|
|
206
|
+
var map = {};
|
|
207
|
+
var results = [];
|
|
208
|
+
_value.forEach(function (value) {
|
|
209
|
+
var key;
|
|
210
|
+
if (Array.isArray(value)) {
|
|
211
|
+
key = _mapInstanceProperty(value).call(value, getValueString).join(' ~ ');
|
|
212
|
+
} else {
|
|
213
|
+
key = getValueString(value);
|
|
214
|
+
}
|
|
215
|
+
if (!map[key]) {
|
|
216
|
+
map[key] = true;
|
|
217
|
+
results.push(value);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
value.set(results);
|
|
221
|
+
}
|
|
222
|
+
function isValidDate(date) {
|
|
223
|
+
return date.isValid() && !isDisabled(date, getEqualType());
|
|
224
|
+
}
|
|
225
|
+
function onChangeTime(date, flag) {
|
|
226
|
+
var _context2;
|
|
227
|
+
var _instance$get6 = instance.get(),
|
|
228
|
+
range = _instance$get6.range,
|
|
229
|
+
multiple = _instance$get6.multiple;
|
|
230
|
+
var values = _sliceInstanceProperty(_context2 = value.value).call(_context2);
|
|
231
|
+
// maybe we select time directly
|
|
232
|
+
var lastIndex = Math.max(values.length - 1, 0);
|
|
233
|
+
if (allValuesUpdatedInMultipleMode()) {
|
|
234
|
+
// need add new value, if all value.value has updated to dayjsValue
|
|
235
|
+
lastIndex = values.length;
|
|
236
|
+
}
|
|
237
|
+
var _value = date;
|
|
238
|
+
if (range) {
|
|
239
|
+
_value = values[lastIndex];
|
|
240
|
+
if (_value) {
|
|
241
|
+
_value = _sliceInstanceProperty(_value).call(_value);
|
|
242
|
+
} else {
|
|
243
|
+
_value = [];
|
|
244
|
+
}
|
|
245
|
+
_value[flag] = date;
|
|
246
|
+
instance.trigger('selecting', _value, false);
|
|
247
|
+
}
|
|
248
|
+
values[lastIndex] = _value;
|
|
249
|
+
value.set(values);
|
|
250
|
+
}
|
|
251
|
+
function getTimeValue(flag) {
|
|
252
|
+
var _value = value.value;
|
|
253
|
+
if (!_value.length) return null;
|
|
254
|
+
var _instance$get7 = instance.get(),
|
|
255
|
+
range = _instance$get7.range,
|
|
256
|
+
min = _instance$get7.min;
|
|
257
|
+
var lastValue = last(_value);
|
|
258
|
+
return range ? lastValue[flag] : lastValue;
|
|
259
|
+
}
|
|
260
|
+
function getDayjsValue() {
|
|
261
|
+
return dayjsValue;
|
|
262
|
+
}
|
|
263
|
+
function allValuesUpdatedInMultipleMode() {
|
|
264
|
+
return instance.get('multiple') && value.value.length === dayjsValue.length;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
value: value,
|
|
268
|
+
format: format,
|
|
269
|
+
formatSingleValue: formatSingleValue,
|
|
270
|
+
onChangeTime: onChangeTime,
|
|
271
|
+
getTimeValue: getTimeValue,
|
|
272
|
+
setValue: setValue,
|
|
273
|
+
convertToDayjs: convertToDayjs,
|
|
274
|
+
getDayjsValue: getDayjsValue,
|
|
275
|
+
unique: unique,
|
|
276
|
+
setMoment: setMoment,
|
|
277
|
+
updateValue: updateValue,
|
|
278
|
+
allValuesUpdatedInMultipleMode: allValuesUpdatedInMultipleMode
|
|
279
|
+
};
|
|
280
|
+
}
|
|
@@ -44,10 +44,13 @@ export function useYears(showDate, status, focusDate) {
|
|
|
44
44
|
}
|
|
45
45
|
function onClick(date) {
|
|
46
46
|
showDate.set(date);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} else {
|
|
47
|
+
var datepickerType = instance.datepicker.get('type');
|
|
48
|
+
if (datepickerType === 'year') {
|
|
50
49
|
instance.triggerChange(date);
|
|
50
|
+
} else if (datepickerType === 'quarter') {
|
|
51
|
+
instance.type.set('quarter');
|
|
52
|
+
} else {
|
|
53
|
+
instance.type.set('month');
|
|
51
54
|
}
|
|
52
55
|
}
|
|
53
56
|
return {
|
|
@@ -23,7 +23,8 @@ var typeDefs = {
|
|
|
23
23
|
// Event is undefined in NodeJs
|
|
24
24
|
of: ['self', 'parent', typeof Event === 'undefined' ? undefined : Event],
|
|
25
25
|
container: [String, Function],
|
|
26
|
-
collison: ['none', 'fit', 'flip', 'flipfit', Array]
|
|
26
|
+
collison: ['none', 'fit', 'flip', 'flipfit', Array],
|
|
27
|
+
alwaysShowOnClick: Boolean
|
|
27
28
|
};
|
|
28
29
|
var defaults = function defaults() {
|
|
29
30
|
return {
|
|
@@ -222,14 +223,16 @@ function useDocumentClickForDropdown(dropdown) {
|
|
|
222
223
|
// case 2: if right click on a trigger and its trigger type is contextmenu, ignore it
|
|
223
224
|
// case 3: if click on a trigger and its trigger type is focus, do nothing
|
|
224
225
|
// case 3: if click on sub-dropdown, we should also show the parent dropdown, so ignore it
|
|
225
|
-
var
|
|
226
|
+
var _dropdown$get = dropdown.get(),
|
|
227
|
+
trigger = _dropdown$get.trigger,
|
|
228
|
+
alwaysShowOnClick = _dropdown$get.alwaysShowOnClick;
|
|
226
229
|
if (trigger === 'focus') return;
|
|
227
230
|
var isHover = trigger === 'hover';
|
|
228
|
-
if (isHover || trigger === 'contextmenu') {
|
|
231
|
+
if (isHover || trigger === 'contextmenu' || alwaysShowOnClick) {
|
|
229
232
|
var triggerDom = findDomFromVNode(dropdown.$lastInput, true);
|
|
230
233
|
var target = e.target;
|
|
231
234
|
if (containsOrEqual(triggerDom, target)) {
|
|
232
|
-
if (isHover) return;
|
|
235
|
+
if (isHover || alwaysShowOnClick) return;
|
|
233
236
|
if (!isHover && e.type === 'contextmenu') return;
|
|
234
237
|
}
|
|
235
238
|
}
|
|
@@ -32,6 +32,7 @@ export declare class Form extends Component<FormProps, FormEvents> {
|
|
|
32
32
|
init(): void;
|
|
33
33
|
validate(): Promise<boolean>;
|
|
34
34
|
getFirstInvalidFormItem(): FormItem | undefined;
|
|
35
|
+
getAllInvalidFormItems(): FormItem[];
|
|
35
36
|
submit(e: Event): void;
|
|
36
37
|
reset(): void;
|
|
37
38
|
private onSubmit;
|
|
@@ -3,6 +3,7 @@ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js/instance/con
|
|
|
3
3
|
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
4
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js/instance/map";
|
|
5
5
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js/instance/find";
|
|
6
|
+
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js/instance/filter";
|
|
6
7
|
import { __decorate } from "tslib";
|
|
7
8
|
import { Component, provide } from 'intact';
|
|
8
9
|
import template from './form.vdt';
|
|
@@ -59,6 +60,12 @@ export var Form = /*#__PURE__*/function (_Component) {
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
};
|
|
63
|
+
_proto.getAllInvalidFormItems = function getAllInvalidFormItems() {
|
|
64
|
+
var _context4;
|
|
65
|
+
return _filterInstanceProperty(_context4 = this.items).call(_context4, function (item) {
|
|
66
|
+
return !item.isValid();
|
|
67
|
+
});
|
|
68
|
+
};
|
|
62
69
|
_proto.submit = function submit(e) {
|
|
63
70
|
var _this2 = this;
|
|
64
71
|
this.validate().then(function (valid) {
|
|
@@ -32,7 +32,7 @@ describe('Form', function () {
|
|
|
32
32
|
return unmount();
|
|
33
33
|
});
|
|
34
34
|
it('validate', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
35
|
-
var _mount, instance, element, form, item, input;
|
|
35
|
+
var _mount, instance, element, form, item, items, input;
|
|
36
36
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
37
37
|
while (1) switch (_context.prev = _context.next) {
|
|
38
38
|
case 0:
|
|
@@ -44,24 +44,26 @@ describe('Form', function () {
|
|
|
44
44
|
expect(element.innerHTML).to.matchSnapshot();
|
|
45
45
|
item = form.getFirstInvalidFormItem();
|
|
46
46
|
expect(item.get('label')).to.eql('Input');
|
|
47
|
+
items = form.getAllInvalidFormItems();
|
|
48
|
+
expect(items.length).to.eql(10);
|
|
47
49
|
instance.reset();
|
|
48
|
-
_context.next =
|
|
50
|
+
_context.next = 12;
|
|
49
51
|
return wait();
|
|
50
|
-
case
|
|
52
|
+
case 12:
|
|
51
53
|
expect(instance.get('model')).to.matchSnapshot();
|
|
52
54
|
// validate on focusout
|
|
53
55
|
input = element.querySelector('input');
|
|
54
56
|
dispatchEvent(input, 'focus');
|
|
55
|
-
_context.next =
|
|
57
|
+
_context.next = 17;
|
|
56
58
|
return wait();
|
|
57
|
-
case
|
|
59
|
+
case 17:
|
|
58
60
|
expect(element.innerHTML).to.matchSnapshot();
|
|
59
61
|
dispatchEvent(input, 'focusout');
|
|
60
|
-
_context.next =
|
|
62
|
+
_context.next = 21;
|
|
61
63
|
return wait();
|
|
62
|
-
case
|
|
64
|
+
case 21:
|
|
63
65
|
expect(element.innerHTML).to.matchSnapshot();
|
|
64
|
-
case
|
|
66
|
+
case 22:
|
|
65
67
|
case "end":
|
|
66
68
|
return _context.stop();
|
|
67
69
|
}
|
|
@@ -76,6 +76,12 @@ export var Input = /*#__PURE__*/function (_Component) {
|
|
|
76
76
|
_proto.select = function select() {
|
|
77
77
|
selectValue(this.inputRef.value);
|
|
78
78
|
};
|
|
79
|
+
_proto.getStringWidth = function getStringWidth(str) {
|
|
80
|
+
return this.autoWidth.getStringWidth(str);
|
|
81
|
+
};
|
|
82
|
+
_proto.getSelectionStart = function getSelectionStart() {
|
|
83
|
+
return this.inputRef.value.selectionStart;
|
|
84
|
+
};
|
|
79
85
|
_proto.clear = function clear(e) {
|
|
80
86
|
this.set('value', '');
|
|
81
87
|
this.focus();
|
|
@@ -259,4 +259,49 @@ describe('Input', function () {
|
|
|
259
259
|
}
|
|
260
260
|
}, _callee7);
|
|
261
261
|
})));
|
|
262
|
+
it('should handle textarea resize correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
263
|
+
var ResizeDemo, _mount8, instance, element, inputElements, resizeNoneElement, resizeVerticalElement, resizeNoneAutoElement, textareas, textarea1, textarea2, computedStyle1, computedStyle2;
|
|
264
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context10) {
|
|
265
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
266
|
+
case 0:
|
|
267
|
+
ResizeDemo = /*#__PURE__*/function (_Component2) {
|
|
268
|
+
_inheritsLoose(ResizeDemo, _Component2);
|
|
269
|
+
function ResizeDemo() {
|
|
270
|
+
var _context9;
|
|
271
|
+
var _this2;
|
|
272
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
273
|
+
args[_key2] = arguments[_key2];
|
|
274
|
+
}
|
|
275
|
+
_this2 = _Component2.call.apply(_Component2, _concatInstanceProperty(_context9 = [this]).call(_context9, args)) || this;
|
|
276
|
+
_this2.Input = Input;
|
|
277
|
+
return _this2;
|
|
278
|
+
}
|
|
279
|
+
return ResizeDemo;
|
|
280
|
+
}(Component);
|
|
281
|
+
ResizeDemo.template = "\n const {Input} = this;\n <div>\n <Input type=\"textarea\" resize=\"none\" placeholder=\"resize none\" />\n <Input type=\"textarea\" resize=\"vertical\" placeholder=\"resize vertical\" />\n <Input type=\"textarea\" resize=\"none\" rows=\"auto\" placeholder=\"resize none with auto rows\" />\n </div>\n ";
|
|
282
|
+
_mount8 = mount(ResizeDemo), instance = _mount8[0], element = _mount8[1];
|
|
283
|
+
inputElements = element.querySelectorAll('.k-input'); // should have k-resize-none class
|
|
284
|
+
resizeNoneElement = inputElements[0];
|
|
285
|
+
expect(resizeNoneElement.classList.contains('k-resize-none')).to.be.true;
|
|
286
|
+
expect(resizeNoneElement.classList.contains('k-resize-vertical')).to.be.false;
|
|
287
|
+
resizeVerticalElement = inputElements[1];
|
|
288
|
+
expect(resizeVerticalElement.classList.contains('k-resize-vertical')).to.be.true;
|
|
289
|
+
expect(resizeVerticalElement.classList.contains('k-resize-none')).to.be.false;
|
|
290
|
+
// resize="none" with rows="auto" (should have k-resize-none class)
|
|
291
|
+
resizeNoneAutoElement = inputElements[2];
|
|
292
|
+
expect(resizeNoneAutoElement.classList.contains('k-resize-none')).to.be.true;
|
|
293
|
+
// Test CSS computed styles to ensure resize is applied correctly
|
|
294
|
+
textareas = element.querySelectorAll('.k-textarea');
|
|
295
|
+
textarea1 = textareas[0];
|
|
296
|
+
textarea2 = textareas[1];
|
|
297
|
+
computedStyle1 = getComputedStyle(textarea1);
|
|
298
|
+
computedStyle2 = getComputedStyle(textarea2);
|
|
299
|
+
expect(computedStyle1.resize).to.eql('none');
|
|
300
|
+
expect(computedStyle2.resize).to.eql('vertical');
|
|
301
|
+
case 19:
|
|
302
|
+
case "end":
|
|
303
|
+
return _context10.stop();
|
|
304
|
+
}
|
|
305
|
+
}, _callee8);
|
|
306
|
+
})));
|
|
262
307
|
});
|
|
@@ -59,7 +59,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
59
59
|
focusInputOnClick = _this$focusHook.focusInputOnClick;
|
|
60
60
|
var isNotAutoRows = isStringOrNumber(rows) && rows !== 'auto';
|
|
61
61
|
var k = this.config.k;
|
|
62
|
-
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-input"] = true, _classNameObj[k + "-" + size] = size !== 'default', _classNameObj[k + "-group"] = $blocks.prepend || $blocks.append, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-clearable"] = clearable, _classNameObj[k + "-auto-width"] = autoWidth, _classNameObj[k + "-fluid"] = fluid, _classNameObj[k + "-stack-clear"] = stackClearIcon, _classNameObj[k + "-inline"] = inline, _classNameObj[k + "-flat"] = flat, _classNameObj[k + "-type-textarea"] = type === 'textarea', _classNameObj[k + "-focus"] = isFocus.value, _classNameObj[k + "-resize-" +
|
|
62
|
+
var classNameObj = (_classNameObj = {}, _classNameObj[k + "-input"] = true, _classNameObj[k + "-" + size] = size !== 'default', _classNameObj[k + "-group"] = $blocks.prepend || $blocks.append, _classNameObj[k + "-disabled"] = disabled, _classNameObj[k + "-clearable"] = clearable, _classNameObj[k + "-auto-width"] = autoWidth, _classNameObj[k + "-fluid"] = fluid, _classNameObj[k + "-stack-clear"] = stackClearIcon, _classNameObj[k + "-inline"] = inline, _classNameObj[k + "-flat"] = flat, _classNameObj[k + "-type-textarea"] = type === 'textarea', _classNameObj[k + "-focus"] = isFocus.value, _classNameObj[k + "-resize-" + (isNotAutoRows ? resize : 'none')] = type === 'textarea', _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
|
|
63
63
|
var _this$showPassword = this.showPassword,
|
|
64
64
|
isShowPassword = _this$showPassword.isShow,
|
|
65
65
|
toggleShowPassword = _this$showPassword.toggleShow,
|
|
@@ -67,7 +67,8 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
67
67
|
showPasswordIcon = _this$showPassword.showIcon;
|
|
68
68
|
var _this$autoWidth = this.autoWidth,
|
|
69
69
|
fakeRef = _this$autoWidth.fakeRef,
|
|
70
|
-
fakeWidth = _this$autoWidth.width.value
|
|
70
|
+
fakeWidth = _this$autoWidth.width.value,
|
|
71
|
+
forceShowFake = _this$autoWidth.forceShowFake;
|
|
71
72
|
var height = this.autoRows;
|
|
72
73
|
var inputValue = frozenOnInput && inputing ? originalValue : value;
|
|
73
74
|
var hasInputValue = !isNullOrUndefined(inputValue);
|
|
@@ -133,7 +134,7 @@ export default function ($props, $blocks, $__proto__) {
|
|
|
133
134
|
return block ? block.call($this, callBlock, data) : callBlock();
|
|
134
135
|
}, __$blocks['suffix'](_$no))], 0, _$cn(k + "-input-suffix"), {
|
|
135
136
|
'ev-click': stopPropagation
|
|
136
|
-
}) : undefined, autoWidth ? _$ce(2, 'div', _$ce(2, 'pre', !hasValue ? hasInputValue || !defaultValue ? placeholder : defaultValue : inputValue, 0, null, null, null, fakeRef), 2, _$cn(k + "-input-fake")) : undefined], 0, _$cn(k + "-input-wrapper"), {
|
|
137
|
+
}) : undefined, autoWidth || forceShowFake.value ? _$ce(2, 'div', _$ce(2, 'pre', !hasValue ? hasInputValue || !defaultValue ? placeholder : defaultValue : inputValue, 0, null, null, null, fakeRef), 2, _$cn(k + "-input-fake")) : undefined], 0, _$cn(k + "-input-wrapper"), {
|
|
137
138
|
'ev-click': focusInputOnClick
|
|
138
139
|
})
|
|
139
140
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function useAutoWidth(): {
|
|
2
2
|
fakeRef: import("intact").RefObject<HTMLDivElement>;
|
|
3
3
|
width: import("../../hooks/useState").State<number>;
|
|
4
|
+
forceShowFake: import("../../hooks/useState").State<boolean>;
|
|
5
|
+
getStringWidth: (str: string) => Promise<number>;
|
|
4
6
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import _Promise from "@babel/runtime-corejs3/core-js/promise";
|
|
1
2
|
import { useInstance, createRef, onMounted, nextTick } from 'intact';
|
|
2
3
|
import { useState } from '../../hooks/useState';
|
|
3
4
|
export function useAutoWidth() {
|
|
4
5
|
var instance = useInstance();
|
|
5
6
|
var fakeRef = createRef();
|
|
6
7
|
var width = useState(0);
|
|
8
|
+
var forceShowFake = useState(false);
|
|
7
9
|
instance.watch('value', adjustWidth, {
|
|
8
10
|
inited: true,
|
|
9
11
|
presented: true
|
|
@@ -24,9 +26,25 @@ export function useAutoWidth() {
|
|
|
24
26
|
});
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
function getStringWidth(str) {
|
|
30
|
+
forceShowFake.set(true);
|
|
31
|
+
return new _Promise(function (resolve) {
|
|
32
|
+
nextTick(function () {
|
|
33
|
+
var fakeElem = fakeRef.value;
|
|
34
|
+
var textNode = fakeElem.firstChild;
|
|
35
|
+
var oldStr = textNode.nodeValue;
|
|
36
|
+
textNode.nodeValue = str;
|
|
37
|
+
resolve(fakeElem.offsetWidth);
|
|
38
|
+
textNode.nodeValue = oldStr;
|
|
39
|
+
forceShowFake.set(false);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
27
43
|
return {
|
|
28
44
|
fakeRef: fakeRef,
|
|
29
|
-
width: width
|
|
45
|
+
width: width,
|
|
46
|
+
forceShowFake: forceShowFake,
|
|
47
|
+
getStringWidth: getStringWidth
|
|
30
48
|
};
|
|
31
49
|
}
|
|
32
50
|
function isVisible(elem) {
|
|
@@ -8,6 +8,7 @@ import BasicDemo from '~/components/menu/demos/basic';
|
|
|
8
8
|
import CollapseDemo from '~/components/menu/demos/collapse';
|
|
9
9
|
import AccordionDemo from '~/components/menu/demos/accordion';
|
|
10
10
|
import CollapseArrowDemo from '~/components/menu/demos/showCollapseArrow';
|
|
11
|
+
import HorizontalDemo from '~/components/menu/demos/horizontal';
|
|
11
12
|
import { mount, unmount, dispatchEvent, getElement, wait } from '../../test/utils';
|
|
12
13
|
import { Menu, MenuItem } from './';
|
|
13
14
|
describe('Menu', function () {
|
|
@@ -271,4 +272,31 @@ describe('Menu', function () {
|
|
|
271
272
|
}
|
|
272
273
|
}, _callee7);
|
|
273
274
|
})));
|
|
275
|
+
it('detecting pop-up position during rapid mouse hover over menus', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
276
|
+
var _mount8, instance, element, _element$querySelecto2, menu3, menu4, dropdownmenu1, top1, dropdownmenu2, top2;
|
|
277
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context9) {
|
|
278
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
279
|
+
case 0:
|
|
280
|
+
_mount8 = mount(HorizontalDemo), instance = _mount8[0], element = _mount8[1];
|
|
281
|
+
_element$querySelecto2 = element.querySelectorAll('.k-menu-item-title'), menu3 = _element$querySelecto2[2], menu4 = _element$querySelecto2[3];
|
|
282
|
+
dispatchEvent(menu3, 'mouseenter');
|
|
283
|
+
_context9.next = 5;
|
|
284
|
+
return wait(500);
|
|
285
|
+
case 5:
|
|
286
|
+
dropdownmenu1 = getElement('.k-dropdown-menu');
|
|
287
|
+
top1 = dropdownmenu1.getBoundingClientRect().top;
|
|
288
|
+
dispatchEvent(menu3, 'mouseleave');
|
|
289
|
+
dispatchEvent(menu4, 'mouseenter');
|
|
290
|
+
_context9.next = 11;
|
|
291
|
+
return wait(1000);
|
|
292
|
+
case 11:
|
|
293
|
+
dropdownmenu2 = getElement('.k-dropdown-menu');
|
|
294
|
+
top2 = dropdownmenu2.getBoundingClientRect().top;
|
|
295
|
+
expect(top1).to.eql(top2);
|
|
296
|
+
case 14:
|
|
297
|
+
case "end":
|
|
298
|
+
return _context9.stop();
|
|
299
|
+
}
|
|
300
|
+
}, _callee8);
|
|
301
|
+
})));
|
|
274
302
|
});
|
|
@@ -21,7 +21,7 @@ var defaults = {
|
|
|
21
21
|
item: {
|
|
22
22
|
height: '40px',
|
|
23
23
|
padding: '0 12px',
|
|
24
|
-
bodyPadding: '
|
|
24
|
+
bodyPadding: '4px',
|
|
25
25
|
color: '#aeaeb9',
|
|
26
26
|
hoverColor: '#fff',
|
|
27
27
|
disabledColor: '#53535a',
|
|
@@ -115,7 +115,7 @@ export var makeMenuStyles = cache(function makeMenuStyles(k) {
|
|
|
115
115
|
return /*#__PURE__*/css("&.", k, "-menu{width:", menu.width, ";transition:width ", menu.transition, ";background:", menu.bgColor, ";font-size:", menu.fontSize, ";position:relative;}.", k, "-icon{width:", menu.icon.width, ";margin-right:", menu.icon.gap, ";text-align:center;flex-shrink:0;}.", k, "-menu-header{height:", menu.header.height, ";padding:0 16px;color:", menu.header.color, ";font-size:", menu.header.fontSize, ";font-weight:bold;}.", k, "-menu-body{padding:", menu.item.bodyPadding, ";max-height:calc(100% - ", menu.header.height, ");overflow-y:auto;overflow-x:hidden;scrollbar-width:none;}.", k, "-menu-title{height:", menu.title.height, ";border-top:", menu.border, ";margin-top:4px;.", k, "-menu-name{transition:all ", menu.transition, ";height:", menu.title.height, ";color:", menu.title.color, ";font-weight:bold;}}.", k, "-menu-arrow-box{width:14px;height:60px;cursor:pointer;background:", menu.bgColor, ";border-radius:0 8px 8px 0;position:absolute;display:flex;align-items:center;justify-content:center;top:50%;left:calc(", menu.width, " - 2px);transition:left ", menu.transition, ";transform:translateY(-50%);border:", menu.border, ";border-left:none;.", k, "-icon{margin-right:0;}&:hover{.", k, "-menu-arrow:before{color:", menu.item.activeBgColor, ";}}}&.", k, "-light{border-right:1px solid ", theme.color.disabledBg, ";background:", menu.light.bgColor, ";.", k, "-menu-header{color:", menu.light.title.color, ";}.", k, "-menu-item{.", k, "-menu-item-title{color:", menu.light.item.color, ";&:hover{background:", menu.light.item.hoverBg, ";}}.", k, "-menu-item-arrow{color:", menu.light.item.color, ";}&.", k, "-highlighted{>.", k, "-menu-item-title{color:", menu.light.item.hoverColor, ";}}&.", k, "-disabled{>.", k, "-menu-item-title{color:", menu.light.item.disabledColor, "!important;}}}.", k, "-menu-title{border-top:", menu.light.border, ";.", k, "-menu-name{color:", menu.light.title.color, ";}}.", k, "-menu-arrow-box{background:", menu.light.bgColor, ";border:", menu.light.border, ";border-left:none;&:hover{.", k, "-menu-arrow:before{color:", menu.light.active.color, ";}}}.", k, "-menu:not(.", k, "-dropdown-menu){background:", menu.light.bgColor, ";}&.", k, "-horizontal{.", k, "-menu-header{border-right:", menu.light.border, ";}.", k, "-menu-body>.", k, "-menu-title{border-right:", menu.light.border, ";}}.", k, "-menu-item.", k, "-active{>.", k, "-menu-item-title{color:", menu.light.active.color, "!important;background:", menu.light.active.bgColor, ";}}.", k, "-sub-menu{.", k, "-menu-item-title,.", k, "-menu-item-arrow{color:", menu.light.item.subTitleColor, "!important;}}}", _mapInstanceProperty(sizes).call(sizes, function (size) {
|
|
116
116
|
var styles = menu[size];
|
|
117
117
|
return /*#__PURE__*/css("&.", k, "-", size, "{width:", styles.width, ";font-size:", styles.fontSize, ";.", k, "-menu{font-size:", styles.fontSize, ";}.", k, "-menu-arrow-box{left:calc(", styles.width, " - 2px);}}");
|
|
118
|
-
}), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
|
|
118
|
+
}), "&.", k, "-collapsed{width:calc(", menu.icon.width, " + (", getLeft(menu.item.padding), " + ", getLeft(menu.item.bodyPadding), ") * 2);.", k, "-icon{margin-right:0;}.", k, "-menu-item-arrow{display:none;}}&.", k, "-collapsed-arrow{width:0px;border-left:none;.", k, "-menu-header{padding:0;}.", k, "-menu-body{overflow:hidden;padding:0;}.", k, "-menu-arrow-box{left:0;.", k, "-menu-arrow:before{transform:rotateY(180deg);}}}&.", k, "-dropdown-menu{width:fit-content;min-width:", menu.dropdown.minWidth, ";position:absolute;.", k, "-menu-item-arrow{transform:rotate(-90deg);}}&.", k, "-horizontal{width:auto;display:flex;.", k, "-menu-body{display:flex;align-items:center;.", k, "-menu-title{border-top:none;border-right:", menu.border, ";}}}");
|
|
119
119
|
});
|
|
120
120
|
export var makeTitleStyles = cache(function makeTitleStyles(k) {
|
|
121
121
|
var item = menu.item;
|
|
@@ -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;
|
|
@@ -61,14 +62,14 @@ export function useMouseEvents(translate, list) {
|
|
|
61
62
|
e.preventDefault();
|
|
62
63
|
itemHeight = getItemHeight();
|
|
63
64
|
var threshold = itemHeight * 0.6;
|
|
64
|
-
|
|
65
|
-
if (Math.abs(
|
|
66
|
-
if (
|
|
65
|
+
wheelDeltaY += e.deltaY;
|
|
66
|
+
if (Math.abs(wheelDeltaY) >= threshold) {
|
|
67
|
+
if (wheelDeltaY > 0) {
|
|
67
68
|
setByRelativeIndex(1, null, true);
|
|
68
69
|
} else {
|
|
69
70
|
setByRelativeIndex(-1, null, true);
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
+
wheelDeltaY = 0;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
// throttle onWheel
|
|
@@ -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;
|