@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
@@ -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
+ }
@@ -0,0 +1,19 @@
1
+ import dayjs, { Dayjs } from 'dayjs';
2
+ import { State } from '../../hooks/useState';
3
+ import type { useStatus } from './useStatus';
4
+ export declare function useWeeks(showDate: State<Dayjs>, status: ReturnType<typeof useStatus>, focusDate: State<Dayjs | null>): {
5
+ getWeeks: (now: Dayjs) => {
6
+ week: number;
7
+ days: {
8
+ isExceed: boolean;
9
+ label: number;
10
+ value: dayjs.Dayjs;
11
+ isActive: boolean;
12
+ isToday: boolean;
13
+ isDisabled: boolean;
14
+ isHover: boolean;
15
+ isInRange: boolean;
16
+ }[];
17
+ }[];
18
+ onClick: (day: Dayjs) => void;
19
+ };
@@ -0,0 +1,48 @@
1
+ import { useInstance } from 'intact-vue-next';
2
+ export function useWeeks(showDate, status, focusDate) {
3
+ var instance = useInstance();
4
+ function getWeeks(now) {
5
+ var weeks = [];
6
+ // 从当前显示月份的月初开始,并调整到该周的开始
7
+ var startOfMonth = showDate.value.startOf('month');
8
+ var start = startOfMonth.startOf('week');
9
+ var current = start;
10
+ var currentMonth = showDate.value.month();
11
+ // 遍历6周,以覆盖整个月份
12
+ for (var weekIndex = 0; weekIndex < 6; weekIndex++) {
13
+ var weekNumber = current.week(); // 获取当前周的周数
14
+ var days = [];
15
+ // 遍历一周的7天
16
+ for (var i = 0; i < 7; i++) {
17
+ var day = current.add(i, 'day');
18
+ var isFirstOrLastDay = i === 0 || i === 6;
19
+ days.push({
20
+ isExceed: day.month() !== currentMonth,
21
+ label: day.date(),
22
+ value: day,
23
+ isActive: isFirstOrLastDay && status.isActive(day, 'week'),
24
+ isToday: day.isSame(now, 'week'),
25
+ isDisabled: status.isDisabled(day),
26
+ isHover: day.isSame(focusDate.value, 'week'),
27
+ isInRange: !isFirstOrLastDay && status.isActive(day, 'week')
28
+ });
29
+ }
30
+ // 每周的数据,包括周数和7天的信息
31
+ weeks.push({
32
+ week: weekNumber,
33
+ days: days
34
+ });
35
+ current = current.add(1, 'week'); // 移动到下一周的开始
36
+ }
37
+ return weeks;
38
+ }
39
+ function onClick(day) {
40
+ var weekStart = day.startOf('week');
41
+ showDate.set(weekStart); // 设置显示日期为周的开始
42
+ instance.triggerChange(weekStart); // 触发日期改变事件
43
+ }
44
+ return {
45
+ getWeeks: getWeeks,
46
+ onClick: onClick
47
+ };
48
+ }
@@ -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 {
@@ -1,72 +1,20 @@
1
- import _Set from "@babel/runtime-corejs3/core-js/set";
2
- import { useInstance, onBeforeUnmount } from 'intact-vue-next';
3
- import { scrollbarWidth } from '../position';
1
+ import { useInstance } from 'intact-vue-next';
2
+ import { useFixBody as useFixBodyHook, setHooks as setFixBodyHooks } from '../../hooks/useFixBody';
4
3
  import { SHOW } from './constants';
5
- var dialogs = new _Set();
6
- var originalStyle = null;
7
- var hooks = null;
8
4
  export function useFixBody(elementRef) {
9
5
  var instance = useInstance();
10
- var fixedBody = false;
6
+ var fixBodyHook = useFixBodyHook();
11
7
  instance.on(SHOW, onEnter);
12
8
  instance.on('afterClose', onAfterLeave);
13
- onBeforeUnmount(function () {
14
- // should also remove body style when dialog is removed, #805
15
- // if (fixedBody && instance.get('value')) {
16
- if (fixedBody) {
17
- // maybe HIDE event has not triggered
18
- onClosed(instance);
19
- }
20
- });
21
9
  function onEnter() {
22
10
  if (instance.get('overlay')) {
23
- fixedBody = true;
24
- onOpen(instance);
11
+ fixBodyHook.onOpen();
25
12
  }
26
13
  }
27
14
  function onAfterLeave() {
28
- if (fixedBody) {
29
- fixedBody = false;
30
- onClosed(instance);
31
- }
15
+ fixBodyHook.onClose();
32
16
  }
33
17
  }
34
18
  export function setHooks(h) {
35
- hooks = h;
36
- }
37
- function onOpen(dialog) {
38
- var body = document.body;
39
- if (dialogs.size === 0) {
40
- var bodyStyle = body.style;
41
- originalStyle = body.getAttribute('style');
42
- bodyStyle.overflow = 'hidden';
43
- var scrollBarWidth = shouldFixBody();
44
- if (scrollBarWidth) {
45
- bodyStyle.paddingRight = scrollBarWidth + "px";
46
- }
47
- if (hooks && hooks.onStart) {
48
- hooks.onStart(scrollBarWidth);
49
- }
50
- }
51
- dialogs.add(dialog);
52
- }
53
- function onClosed(dialog) {
54
- var body = document.body;
55
- dialogs.delete(dialog);
56
- if (dialogs.size === 0) {
57
- if (originalStyle) {
58
- // console.log(originalStyle);
59
- body.setAttribute('style', originalStyle);
60
- } else {
61
- body.removeAttribute('style');
62
- }
63
- if (hooks && hooks.onEnd) {
64
- hooks.onEnd();
65
- }
66
- }
67
- }
68
- function shouldFixBody() {
69
- if (document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight)) {
70
- return scrollbarWidth();
71
- }
19
+ setFixBodyHooks(h);
72
20
  }
@@ -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
  }
@@ -6,5 +6,5 @@ setDefault(function () {
6
6
  makeStyles == null || makeStyles.clearCache();
7
7
  });
8
8
  export var makeStyles = cache(function makeStyles(k, maxLines) {
9
- return /*#__PURE__*/css("width:100%;&.", k, "-multiline{.k-ellipsis-wrapper{white-space:normal;display:-webkit-box;-webkit-line-clamp:", maxLines, ";-webkit-box-orient:vertical;}}");
9
+ return /*#__PURE__*/css("width:100%;&.", k, "-multiline{.k-ellipsis-wrapper{white-space:normal;display:-webkit-box;-webkit-line-clamp:", maxLines, ";-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;line-clamp:", maxLines, ";box-orient:vertical;}}");
10
10
  });
@@ -46,7 +46,7 @@ setDefault(function () {
46
46
  makeFormStyles == null || makeFormStyles.clearCache();
47
47
  });
48
48
  export var makeItemStyles = cache(function makeItemStyles(k) {
49
- return /*#__PURE__*/css("display:flex;position:relative;&:not(:last-of-type){margin-bottom:", form.item.gap, ";}&.", k, "-fluid>.", k, "-form-content{flex:1;}.", k, "-form-label{display:flex;align-items:center;justify-content:", form.item.labelTextAlign === 'right' ? 'end' : 'start', ";width:", form.item.labelWidth, ";padding-right:", form.item.labelGap, ";max-height:", form.item.labelHeight, ";flex-shrink:0;}.", k, "-form-star{color:", form.item.starColor, ";margin-right:", form.item.starGap, ";}.", k, "-form-content{position:relative;}.", k, "-form-error{position:absolute;color:", form.item.errorColor, ";font-size:", form.item.errorFontSize, ";left:0;right:0;display:flex;align-items:center;&.", k, "-ellipsis{.", k, "-form-error-more{display:inline-block;}}}.", k, "-form-error-more{line-height:", form.item.errorFontSize, ";display:none;}&.", k, "-invalid{.", k, "-input{.", k, "-input-wrapper{border:", form.item.invalidBorder, ";position:relative;z-index:1;}}.", k, "-select,.", k, "-checkbox-wrapper,.", k, "-radio-wrapper{border:", form.item.invalidBorder, "!important;}.", k, "-select .", k, "-input .", k, "-input-wrapper{border:none;}}.", k, "-form-append{padding:", form.item.appendPadding, ";vertical-align:middle;}");
49
+ return /*#__PURE__*/css("display:flex;position:relative;&:not(:last-of-type){margin-bottom:", form.item.gap, ";}&.", k, "-fluid>.", k, "-form-content{flex:1;min-width:0;}.", k, "-form-label{display:flex;align-items:center;justify-content:", form.item.labelTextAlign === 'right' ? 'end' : 'start', ";width:", form.item.labelWidth, ";padding-right:", form.item.labelGap, ";max-height:", form.item.labelHeight, ";flex-shrink:0;}.", k, "-form-star{color:", form.item.starColor, ";margin-right:", form.item.starGap, ";}.", k, "-form-content{position:relative;}.", k, "-form-error{position:absolute;color:", form.item.errorColor, ";font-size:", form.item.errorFontSize, ";left:0;right:0;display:flex;align-items:center;&.", k, "-ellipsis{.", k, "-form-error-more{display:inline-block;}}}.", k, "-form-error-more{line-height:", form.item.errorFontSize, ";display:none;}&.", k, "-invalid{.", k, "-input{.", k, "-input-wrapper{border:", form.item.invalidBorder, ";position:relative;z-index:1;}}.", k, "-select,.", k, "-checkbox-wrapper,.", k, "-radio-wrapper{border:", form.item.invalidBorder, "!important;}.", k, "-select .", k, "-input .", k, "-input-wrapper{border:none;}}.", k, "-form-append{padding:", form.item.appendPadding, ";vertical-align:middle;}");
50
50
  });
51
51
  export var makeFormStyles = cache(function makeFormStyles(k) {
52
52
  var _context;
@@ -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) {