@king-design/vue 3.6.0-beta.0 → 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 (80) 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 -27
  5. package/components/datepicker/basepicker.js +23 -268
  6. package/components/datepicker/calendar.d.ts +4 -2
  7. package/components/datepicker/dayjs.d.ts +2 -13
  8. package/components/datepicker/helpers.d.ts +3 -2
  9. package/components/datepicker/helpers.js +2 -3
  10. package/components/datepicker/index.d.ts +21 -29
  11. package/components/datepicker/index.js +22 -32
  12. package/components/datepicker/index.spec.js +1333 -578
  13. package/components/datepicker/index.vdt.js +39 -38
  14. package/components/datepicker/shortcuts.d.ts +1 -1
  15. package/components/datepicker/styles.d.ts +7 -2
  16. package/components/datepicker/styles.js +10 -15
  17. package/components/datepicker/useConfirm.d.ts +6 -0
  18. package/components/datepicker/useConfirm.js +65 -0
  19. package/components/datepicker/useDisabled.d.ts +5 -3
  20. package/components/datepicker/useDisabled.js +22 -27
  21. package/components/datepicker/useFormats.d.ts +2 -2
  22. package/components/datepicker/useFormats.js +6 -2
  23. package/components/datepicker/useHighlight.d.ts +14 -0
  24. package/components/datepicker/useHighlight.js +60 -0
  25. package/components/datepicker/useKeyboards.js +2 -1
  26. package/components/datepicker/useMergeRange.d.ts +1 -1
  27. package/components/datepicker/useMergeRange.js +11 -16
  28. package/components/datepicker/useMonths.js +5 -3
  29. package/components/datepicker/usePanel.d.ts +1 -10
  30. package/components/datepicker/usePanel.js +19 -32
  31. package/components/datepicker/useShowDate.d.ts +1 -1
  32. package/components/datepicker/useShowDate.js +15 -40
  33. package/components/datepicker/useStatus.js +33 -16
  34. package/components/datepicker/useValue.d.ts +11 -6
  35. package/components/datepicker/useValue.js +49 -69
  36. package/components/datepicker/useValueBase.d.ts +28 -0
  37. package/components/datepicker/useValueBase.js +277 -0
  38. package/components/datepicker/useYears.js +6 -3
  39. package/components/dropdown/dropdown.d.ts +1 -0
  40. package/components/dropdown/dropdown.js +7 -4
  41. package/components/input/index.d.ts +2 -0
  42. package/components/input/index.js +6 -0
  43. package/components/input/index.spec.js +45 -0
  44. package/components/input/index.vdt.js +4 -3
  45. package/components/input/useAutoWidth.d.ts +2 -0
  46. package/components/input/useAutoWidth.js +19 -1
  47. package/components/scrollSelect/useMouseEvents.js +5 -4
  48. package/components/select/base.d.ts +1 -1
  49. package/components/select/base.js +3 -2
  50. package/components/select/base.vdt.js +4 -3
  51. package/components/select/index.spec.js +158 -84
  52. package/components/select/option.js +2 -1
  53. package/components/select/select.js +2 -1
  54. package/components/select/styles.d.ts +79 -0
  55. package/components/select/styles.js +1 -0
  56. package/components/select/useInput.d.ts +1 -1
  57. package/components/select/useInput.js +4 -4
  58. package/components/table/index.spec.js +84 -6
  59. package/components/table/useStickyHeader.js +1 -1
  60. package/components/timepicker/index.spec.js +298 -128
  61. package/components/timepicker/panelPicker.d.ts +21 -16
  62. package/components/timepicker/panelPicker.js +7 -4
  63. package/components/timepicker/panelPicker.vdt.js +5 -9
  64. package/components/timepicker/selectPicker.d.ts +4 -3
  65. package/components/timepicker/styles.js +1 -1
  66. package/components/timepicker/useConfirm.d.ts +6 -0
  67. package/components/timepicker/useConfirm.js +19 -0
  68. package/components/timepicker/useDefaultValue.d.ts +4 -0
  69. package/components/timepicker/useDefaultValue.js +27 -0
  70. package/components/timepicker/useDisabled.d.ts +6 -3
  71. package/components/timepicker/useDisabled.js +13 -4
  72. package/components/timepicker/useFormats.d.ts +1 -1
  73. package/components/timepicker/useValue.d.ts +13 -8
  74. package/components/timepicker/useValue.js +14 -15
  75. package/components/tour/index.spec.js +1 -1
  76. package/index.d.ts +2 -2
  77. package/index.js +2 -2
  78. package/package.json +2 -2
  79. package/components/datepicker/usePosition.d.ts +0 -10
  80. package/components/datepicker/usePosition.js +0 -166
@@ -0,0 +1,277 @@
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-vue-next';
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
+ instance.set('value', valueStr);
193
+ instance.resetKeywords();
194
+ }
195
+ // TODO
196
+ function setMoment() {
197
+ var now = dayjs();
198
+ setValue(now, true);
199
+ instance.hide();
200
+ }
201
+ function unique() {
202
+ var _value = value.value;
203
+ var map = {};
204
+ var results = [];
205
+ _value.forEach(function (value) {
206
+ var key;
207
+ if (Array.isArray(value)) {
208
+ key = _mapInstanceProperty(value).call(value, getValueString).join(' ~ ');
209
+ } else {
210
+ key = getValueString(value);
211
+ }
212
+ if (!map[key]) {
213
+ map[key] = true;
214
+ results.push(value);
215
+ }
216
+ });
217
+ value.set(results);
218
+ }
219
+ function isValidDate(date) {
220
+ return date.isValid() && !isDisabled(date, getEqualType());
221
+ }
222
+ function onChangeTime(date, flag) {
223
+ var _context2;
224
+ var _instance$get6 = instance.get(),
225
+ range = _instance$get6.range,
226
+ multiple = _instance$get6.multiple;
227
+ var values = _sliceInstanceProperty(_context2 = value.value).call(_context2);
228
+ // maybe we select time directly
229
+ var lastIndex = Math.max(values.length - 1, 0);
230
+ if (allValuesUpdatedInMultipleMode()) {
231
+ // need add new value, if all value.value has updated to dayjsValue
232
+ lastIndex = values.length;
233
+ }
234
+ var _value = date;
235
+ if (range) {
236
+ _value = values[lastIndex];
237
+ if (_value) {
238
+ _value = _sliceInstanceProperty(_value).call(_value);
239
+ } else {
240
+ _value = [];
241
+ }
242
+ _value[flag] = date;
243
+ instance.trigger('selecting', _value, false);
244
+ }
245
+ values[lastIndex] = _value;
246
+ value.set(values);
247
+ }
248
+ function getTimeValue(flag) {
249
+ var _value = value.value;
250
+ if (!_value.length) return null;
251
+ var _instance$get7 = instance.get(),
252
+ range = _instance$get7.range,
253
+ min = _instance$get7.min;
254
+ var lastValue = last(_value);
255
+ return range ? lastValue[flag] : lastValue;
256
+ }
257
+ function getDayjsValue() {
258
+ return dayjsValue;
259
+ }
260
+ function allValuesUpdatedInMultipleMode() {
261
+ return instance.get('multiple') && value.value.length === dayjsValue.length;
262
+ }
263
+ return {
264
+ value: value,
265
+ format: format,
266
+ formatSingleValue: formatSingleValue,
267
+ onChangeTime: onChangeTime,
268
+ getTimeValue: getTimeValue,
269
+ setValue: setValue,
270
+ convertToDayjs: convertToDayjs,
271
+ getDayjsValue: getDayjsValue,
272
+ unique: unique,
273
+ setMoment: setMoment,
274
+ updateValue: updateValue,
275
+ allValuesUpdatedInMultipleMode: allValuesUpdatedInMultipleMode
276
+ };
277
+ }
@@ -44,10 +44,13 @@ export function useYears(showDate, status, focusDate) {
44
44
  }
45
45
  function onClick(date) {
46
46
  showDate.set(date);
47
- if (instance.datepicker.get('type') !== 'year') {
48
- instance.type.set('month');
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 {
@@ -16,6 +16,7 @@ export interface DropdownProps {
16
16
  collison?: Position['collision'];
17
17
  of?: 'self' | 'parent' | Event;
18
18
  container?: PortalProps['container'];
19
+ alwaysShowOnClick?: boolean;
19
20
  }
20
21
  export interface DropdownEvents {
21
22
  shouldFocus: [];
@@ -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 trigger = dropdown.get('trigger');
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
  }
@@ -64,5 +64,7 @@ export declare class Input<V extends Value = Value> extends Component<InputProps
64
64
  focus(): void;
65
65
  blur(): void;
66
66
  select(): void;
67
+ getStringWidth(str: string): Promise<number>;
68
+ getSelectionStart(): number | null;
67
69
  private clear;
68
70
  }
@@ -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-" + resize] = type === 'textarea' && isNotAutoRows, _classNameObj[k + "-resize-none"] = type === 'textarea' && !isNotAutoRows, _classNameObj[className] = className, _classNameObj[makeStyles(k)] = true, _classNameObj);
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-vue-next').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-vue-next';
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) {
@@ -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
- deltaY = (deltaY || 0) + e.deltaY;
65
- if (Math.abs(deltaY) >= threshold) {
66
- if (deltaY > 0) {
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
- deltaY = 0;
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(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);
@@ -87,6 +87,7 @@ export default function ($props, $blocks, $__proto__) {
87
87
  'disabled': disabled,
88
88
  'container': container,
89
89
  'position': position,
90
+ 'alwaysShowOnClick': $props.alwaysShowOnClick,
90
91
  'children': [_$cv('div', _extends({}, getRestProps(_this), {
91
92
  'className': _$cn(classNameObj),
92
93
  'tabindex': disabled ? '-1' : '0',
@@ -95,7 +96,8 @@ export default function ($props, $blocks, $__proto__) {
95
96
  'style': !isNullOrUndefined(width) ? addStyle(style, {
96
97
  width: width + "px"
97
98
  }) : style,
98
- 'ref': triggerRef
99
+ 'ref': triggerRef,
100
+ 'ev-click': $props.onClick
99
101
  }), [$blocks.prefix ? _$ce(2, 'div', (_$blocks['prefix'] = function ($super) {
100
102
  return null;
101
103
  }, __$blocks['prefix'] = function ($super, data) {
@@ -123,8 +125,7 @@ export default function ($props, $blocks, $__proto__) {
123
125
  'key': 'input',
124
126
  'readonly': !show,
125
127
  'waveDisabled': true,
126
- 'flat': flat,
127
- 'ev-click': $props.onClick
128
+ 'flat': flat
128
129
  }, 'input', inputRef) : !filterable && !hasValue ? _$ce(2, 'div', placeholder, 0, _$cn(k + "-select-placeholder c-ellipsis"), null, 'placeholder') : !multiple ? _$ce(2, 'div', (_$blocks['value'] = function ($super) {
129
130
  return label;
130
131
  }, __$blocks['value'] = function ($super, data) {