x-next 1.1.0 → 1.2.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 (188) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/_hooks/use-form-item.d.ts +5 -0
  3. package/dist/_hooks/use-picker-focus.d.ts +17 -0
  4. package/dist/components/_components/feedback-icon/index.vue.d.ts +4 -4
  5. package/dist/components/_components/picker/input-range.vue.d.ts +10 -6
  6. package/dist/components/_components/picker/input.vue.d.ts +9 -5
  7. package/dist/components/alert/Alert.vue.d.ts +5 -5
  8. package/dist/components/alert/index.d.ts +10 -10
  9. package/dist/components/date-picker/DatePanel.vue.d.ts +5 -0
  10. package/dist/components/date-picker/DatePicker.vue.d.ts +36 -16
  11. package/dist/components/date-picker/index.d.ts +77 -33
  12. package/dist/components/dialog/Dialog.d.ts +1 -1
  13. package/dist/components/dialog/index.d.ts +3 -3
  14. package/dist/components/drawer/index.d.ts +3 -3
  15. package/dist/components/drawer/src/Drawer.vue.d.ts +1 -1
  16. package/dist/components/dropdown/Dropdown.vue.d.ts +3 -3
  17. package/dist/components/dropdown/DropdownButton.vue.d.ts +4 -4
  18. package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +4 -4
  19. package/dist/components/dropdown/index.d.ts +22 -22
  20. package/dist/components/form/FormItem.vue.d.ts +12 -4
  21. package/dist/components/form/context.d.ts +6 -0
  22. package/dist/components/form/form-item-label.vue.d.ts +4 -4
  23. package/dist/components/form/form-item-message.vue.d.ts +2 -0
  24. package/dist/components/form/index.d.ts +30 -8
  25. package/dist/components/form/interface.d.ts +2 -2
  26. package/dist/components/form-input/InputPassword.vue.d.ts +20 -2
  27. package/dist/components/form-input/index.d.ts +22 -4
  28. package/dist/components/form-select/Select.d.ts +3 -3
  29. package/dist/components/form-select/index.d.ts +6 -6
  30. package/dist/components/form-slider/Slider.vue.d.ts +10 -3
  31. package/dist/components/form-slider/index.d.ts +26 -6
  32. package/dist/components/form-slider/slider-button.vue.d.ts +4 -3
  33. package/dist/components/form-switch/Switch.vue.d.ts +2 -1
  34. package/dist/components/form-switch/index.d.ts +5 -2
  35. package/dist/components/form-textarea/Textarea.vue.d.ts +2 -2
  36. package/dist/components/form-textarea/index.d.ts +5 -5
  37. package/dist/components/image/Image.vue.d.ts +10 -9
  38. package/dist/components/image/ImagePreview.vue.d.ts +8 -7
  39. package/dist/components/image/ImagePreviewAction.d.ts +3 -3
  40. package/dist/components/image/ImagePreviewGroup.vue.d.ts +8 -7
  41. package/dist/components/image/index.d.ts +59 -52
  42. package/dist/components/image/preview-arrow.vue.d.ts +2 -2
  43. package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
  44. package/dist/components/layout/LayoutSidebar.vue.d.ts +2 -2
  45. package/dist/components/layout/index.d.ts +4 -4
  46. package/dist/components/link/Link.vue.d.ts +2 -2
  47. package/dist/components/link/index.d.ts +4 -4
  48. package/dist/components/menu/Menu.d.ts +2 -2
  49. package/dist/components/menu/base-menu.vue.d.ts +2 -2
  50. package/dist/components/menu/index.d.ts +4 -4
  51. package/dist/components/menu/sub-menu-pop.vue.d.ts +5 -5
  52. package/dist/components/message/index.d.ts +17 -17
  53. package/dist/components/message/message.vue.d.ts +8 -8
  54. package/dist/components/notification/Notification.d.ts +1 -1
  55. package/dist/components/notification/index.d.ts +3 -3
  56. package/dist/components/pagination/page-item-ellipsis.vue.d.ts +1 -1
  57. package/dist/components/pagination/page-item-step.vue.d.ts +2 -2
  58. package/dist/components/pagination/page-options.vue.d.ts +6 -6
  59. package/dist/components/popconfirm/src/popup.vue.d.ts +1 -1
  60. package/dist/components/popover/Popover.d.ts +1 -1
  61. package/dist/components/popover/index.d.ts +3 -3
  62. package/dist/components/popup/Popup.d.ts +1 -1
  63. package/dist/components/popup/index.d.ts +3 -3
  64. package/dist/components/progress/Progress.vue.d.ts +4 -4
  65. package/dist/components/progress/circle.vue.d.ts +2 -2
  66. package/dist/components/progress/index.d.ts +8 -8
  67. package/dist/components/progress/line.vue.d.ts +1 -1
  68. package/dist/components/progress/steps.vue.d.ts +1 -1
  69. package/dist/components/steps/Step.vue.d.ts +2 -2
  70. package/dist/components/steps/index.d.ts +4 -4
  71. package/dist/components/tabs/Tabs.d.ts +1 -1
  72. package/dist/components/tabs/index.d.ts +3 -3
  73. package/dist/components/tabs/tabs-tab.vue.d.ts +1 -1
  74. package/dist/components/tag/Tag.vue.d.ts +2 -2
  75. package/dist/components/tag/index.d.ts +4 -4
  76. package/dist/components/time-picker/TimeColumn.vue.d.ts +3 -0
  77. package/dist/components/time-picker/TimePanel.vue.d.ts +3 -0
  78. package/dist/components/time-picker/TimePicker.vue.d.ts +33 -17
  79. package/dist/components/time-picker/index.d.ts +73 -36
  80. package/dist/components/time-range-selector/TimeRangeSelector.vue.d.ts +8 -0
  81. package/dist/components/time-range-selector/index.d.ts +22 -0
  82. package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
  83. package/dist/components/tooltip/index.d.ts +3 -3
  84. package/dist/components/trigger/Trigger.d.ts +1 -1
  85. package/dist/components/trigger/index.d.ts +3 -3
  86. package/dist/es/_hooks/use-form-item.js +36 -10
  87. package/dist/es/_hooks/use-picker-focus.js +57 -0
  88. package/dist/es/_utils/constant.js +17 -5
  89. package/dist/es/components/_components/picker/input-range.vue.js +45 -55
  90. package/dist/es/components/_components/picker/input-range.vue2.js +105 -70
  91. package/dist/es/components/_components/picker/input.vue.js +22 -25
  92. package/dist/es/components/_components/picker/input.vue2.js +58 -43
  93. package/dist/es/components/_components/select-view/select-view.js +67 -66
  94. package/dist/es/components/date-picker/DatePanel.vue.js +102 -94
  95. package/dist/es/components/date-picker/DatePanel.vue2.js +97 -44
  96. package/dist/es/components/date-picker/DatePicker.vue.js +71 -58
  97. package/dist/es/components/date-picker/DatePicker.vue2.js +285 -231
  98. package/dist/es/components/dialog/Dialog.js +154 -132
  99. package/dist/es/components/form/Form.vue2.js +113 -101
  100. package/dist/es/components/form/FormItem.vue.js +26 -22
  101. package/dist/es/components/form/FormItem.vue2.js +162 -125
  102. package/dist/es/components/form/form-item-message.vue.js +31 -24
  103. package/dist/es/components/form/form-item-message.vue2.js +4 -2
  104. package/dist/es/components/form-checkbox/Checkbox.js +75 -71
  105. package/dist/es/components/form-checkbox/CheckboxGroup.js +43 -38
  106. package/dist/es/components/form-input/Input.js +83 -79
  107. package/dist/es/components/form-input/InputPassword.vue.js +19 -16
  108. package/dist/es/components/form-input/InputPassword.vue2.js +39 -29
  109. package/dist/es/components/form-input/InputSearch.js +47 -37
  110. package/dist/es/components/form-input-number/InputNumber.js +134 -133
  111. package/dist/es/components/form-input-tag/InputTag.js +173 -162
  112. package/dist/es/components/form-radio/Radio.js +74 -71
  113. package/dist/es/components/form-radio/RadioGroup.js +55 -49
  114. package/dist/es/components/form-select/Select.js +99 -98
  115. package/dist/es/components/form-slider/Slider.vue.js +28 -28
  116. package/dist/es/components/form-slider/Slider.vue2.js +139 -132
  117. package/dist/es/components/form-slider/slider-button.vue.js +6 -6
  118. package/dist/es/components/form-slider/slider-button.vue2.js +39 -34
  119. package/dist/es/components/form-switch/Switch.vue.js +9 -9
  120. package/dist/es/components/form-switch/Switch.vue2.js +81 -74
  121. package/dist/es/components/form-textarea/Textarea.vue2.js +123 -108
  122. package/dist/es/components/image/Image.vue2.js +77 -76
  123. package/dist/es/components/image/ImagePreview.vue.js +13 -12
  124. package/dist/es/components/image/ImagePreview.vue2.js +141 -136
  125. package/dist/es/components/image/ImagePreviewGroup.vue.js +1 -1
  126. package/dist/es/components/image/ImagePreviewGroup.vue2.js +82 -83
  127. package/dist/es/components/rate/Rate.js +106 -103
  128. package/dist/es/components/time-picker/TimeColumn.vue.js +34 -23
  129. package/dist/es/components/time-picker/TimeColumn.vue2.js +37 -28
  130. package/dist/es/components/time-picker/TimePicker.vue.js +83 -64
  131. package/dist/es/components/time-picker/TimePicker.vue2.js +192 -156
  132. package/dist/es/components/time-range-selector/TimeRangeSelector.vue.js +327 -193
  133. package/dist/es/locale/en-US.js +6 -0
  134. package/dist/es/locale/zh-CN.js +6 -0
  135. package/dist/es/style.css +1 -1
  136. package/dist/icons/_self/down.d.ts +1 -1
  137. package/dist/icons/_self/dropdown/more.d.ts +1 -1
  138. package/dist/icons/_self/empty-better.d.ts +1 -1
  139. package/dist/icons/_self/empty.d.ts +1 -1
  140. package/dist/icons/_self/eye-invisible.d.ts +1 -1
  141. package/dist/icons/_self/eye.d.ts +1 -1
  142. package/dist/icons/_self/full-screen.d.ts +1 -1
  143. package/dist/icons/_self/left.d.ts +1 -1
  144. package/dist/icons/_self/menu/down.d.ts +1 -1
  145. package/dist/icons/_self/minus.d.ts +1 -1
  146. package/dist/icons/_self/more-dot.d.ts +1 -1
  147. package/dist/icons/_self/next.d.ts +1 -1
  148. package/dist/icons/_self/original-size.d.ts +1 -1
  149. package/dist/icons/_self/plus.d.ts +1 -1
  150. package/dist/icons/_self/prev.d.ts +1 -1
  151. package/dist/icons/_self/question-message.d.ts +1 -1
  152. package/dist/icons/_self/right.d.ts +1 -1
  153. package/dist/icons/_self/rotate-left.d.ts +1 -1
  154. package/dist/icons/_self/rotate-right.d.ts +1 -1
  155. package/dist/icons/_self/search.d.ts +1 -1
  156. package/dist/icons/_self/up.d.ts +1 -1
  157. package/dist/icons/_self/zoom-in.d.ts +1 -1
  158. package/dist/icons/_self/zoom-out.d.ts +1 -1
  159. package/dist/icons/_ui/alone-left.d.ts +1 -1
  160. package/dist/icons/_ui/alone-margin-left.d.ts +1 -1
  161. package/dist/icons/_ui/alone-margin-right.d.ts +1 -1
  162. package/dist/icons/_ui/alone-right.d.ts +1 -1
  163. package/dist/icons/_ui/calendar.d.ts +1 -1
  164. package/dist/icons/_ui/time.d.ts +1 -1
  165. package/dist/icons/animation/animation-loading.d.ts +1 -1
  166. package/dist/icons/default/check-circle-fill.d.ts +1 -1
  167. package/dist/icons/default/check.d.ts +1 -1
  168. package/dist/icons/default/close-circle-fill.d.ts +1 -1
  169. package/dist/icons/default/close.d.ts +1 -1
  170. package/dist/icons/default/exclamation-circle-fill.d.ts +1 -1
  171. package/dist/icons/default/exclamation.d.ts +1 -1
  172. package/dist/icons/default/filter.d.ts +1 -1
  173. package/dist/icons/default/info-circle-fill.d.ts +1 -1
  174. package/dist/icons/default/link.d.ts +1 -1
  175. package/dist/icons/default/logo-simple.d.ts +1 -1
  176. package/dist/icons/default/minus-circle-fill.d.ts +1 -1
  177. package/dist/icons/icon.d.ts +2 -2
  178. package/dist/icons/index.d.ts +3 -3
  179. package/dist/index.cjs +4 -4
  180. package/dist/index.umd.js +4 -4
  181. package/dist/locale/interface.d.ts +6 -0
  182. package/dist/style/base.css +1 -1
  183. package/dist/style/date-picker.css +1 -1
  184. package/dist/style/form.css +1 -1
  185. package/dist/style/image.css +1 -1
  186. package/dist/style/time-range-selector.css +1 -1
  187. package/dist/style.css +1 -1
  188. package/package.json +2 -2
@@ -1,14 +1,14 @@
1
- import { defineComponent as D, toRefs as I, ref as m, computed as i, watch as M, onMounted as $, nextTick as H } from "vue";
2
- import K from "../../icons/animation/animation-loading.js";
3
- import { useFormItem as U } from "../../_hooks/use-form-item.js";
4
- import { useSize as j } from "../../_hooks/use-size.js";
5
- import { isUndefined as q, isNull as E, isFunction as G } from "../../_utils/is.js";
6
- import { getClassNameMixin as J } from "../../_utils/config.js";
7
- const p = D({
1
+ import { defineComponent as $, toRefs as q, ref as k, computed as r, onBeforeUnmount as H, watch as K, onMounted as j, nextTick as E } from "vue";
2
+ import G from "../../icons/animation/animation-loading.js";
3
+ import { useFormItem as J, useFormItemControl as O } from "../../_hooks/use-form-item.js";
4
+ import { useSize as P } from "../../_hooks/use-size.js";
5
+ import { isUndefined as Q, isNull as W, isFunction as X } from "../../_utils/is.js";
6
+ import { getClassNameMixin as Y } from "../../_utils/config.js";
7
+ const ne = $({
8
8
  name: "Switch",
9
9
  inheritAttrs: !1,
10
10
  components: {
11
- IconLoading: K
11
+ IconLoading: G
12
12
  },
13
13
  props: {
14
14
  /**
@@ -135,7 +135,7 @@ const p = D({
135
135
  * @param { boolean | string | number } value
136
136
  * @param {Event} ev
137
137
  */
138
- change: (e, a) => !0,
138
+ change: (e, n) => !0,
139
139
  /**
140
140
  * @zh 组件获得焦点时触发
141
141
  * @en Triggered when the component gets focus
@@ -154,7 +154,7 @@ const p = D({
154
154
  * @param { boolean | string | number } value
155
155
  * @param {MouseEvent} ev
156
156
  */
157
- click: (e, a) => !0
157
+ click: (e, n) => !0
158
158
  },
159
159
  /**
160
160
  * @zh 打开状态时的文案(`type='line'`时不生效)
@@ -176,100 +176,107 @@ const p = D({
176
176
  * @en The icon on the button when closed
177
177
  * @slot unchecked-icon
178
178
  */
179
- setup(e, { emit: a, expose: V, slots: g }) {
180
- const { disabled: b, size: S, modelValue: w } = I(e), u = J("switch"), {
181
- mergedDisabled: r,
182
- mergedSize: x,
179
+ setup(e, { emit: n, expose: b, slots: g, attrs: S }) {
180
+ const { disabled: w, size: x, modelValue: B } = q(e), c = Y("switch"), {
181
+ formItemCtx: z,
182
+ mergedDisabled: o,
183
+ mergedSize: A,
183
184
  eventHandlers: s
184
- } = U({
185
- disabled: b,
186
- size: S
187
- }), { mergedSize: y } = j(x), o = m(e.defaultChecked ? e.checkedValue : e.uncheckedValue), n = i(
188
- () => (e.modelValue ?? o.value) === e.checkedValue
189
- ), k = m(!1), f = i(() => k.value || e.loading), h = m(), B = i(
185
+ } = J({
186
+ disabled: w,
187
+ size: x
188
+ }), F = O(z, () => S, { required: !1 }), { mergedSize: y } = P(A), d = k(e.defaultChecked ? e.checkedValue : e.uncheckedValue), a = r(
189
+ () => (e.modelValue ?? d.value) === e.checkedValue
190
+ ), m = k(!1);
191
+ let v = !1;
192
+ H(() => {
193
+ v = !0;
194
+ });
195
+ const f = r(() => m.value || e.loading), h = k(), N = r(
190
196
  () => e.type !== "line" && y.value !== "mini" && (!!e.checkedText || !!e.uncheckedText || !!g.checked || !!g.unchecked)
191
- ), v = (t, c) => {
192
- var l, d;
193
- o.value = t ? e.checkedValue : e.uncheckedValue, a("update:modelValue", o.value), a("change", o.value, c), (d = (l = s.value) == null ? void 0 : l.onChange) == null || d.call(l, c);
194
- }, C = async (t, c) => {
195
- if (f.value || r.value)
197
+ ), C = (t, l) => {
198
+ var u, i;
199
+ d.value = t ? e.checkedValue : e.uncheckedValue, n("update:modelValue", d.value), n("change", d.value, l), (i = (u = s.value) == null ? void 0 : u.onChange) == null || i.call(u, l);
200
+ }, V = async (t, l) => {
201
+ if (f.value || o.value)
196
202
  return;
197
- const l = t ? e.checkedValue : e.uncheckedValue, d = e.beforeChange;
198
- if (G(d)) {
199
- k.value = !0;
203
+ const u = t ? e.checkedValue : e.uncheckedValue, i = e.beforeChange;
204
+ if (X(i)) {
205
+ m.value = !0;
200
206
  try {
201
- (await d(l) ?? !0) && v(t, c);
207
+ (await i(u) ?? !0) && !o.value && !v && C(t, l);
202
208
  } catch {
203
209
  } finally {
204
- k.value = !1;
210
+ m.value = !1;
205
211
  }
206
212
  } else
207
- v(t, c);
208
- }, z = async (t) => {
209
- const c = n.value ? e.uncheckedValue : e.checkedValue;
210
- a("click", c, t), await C(!n.value, t);
211
- }, N = async (t) => {
213
+ C(t, l);
214
+ }, R = async (t) => {
215
+ const l = a.value ? e.uncheckedValue : e.checkedValue;
216
+ n("click", l, t), await V(!a.value, t);
217
+ }, T = async (t) => {
212
218
  if (t.key !== "ArrowLeft" && t.key !== "Left" && t.key !== "ArrowRight" && t.key !== "Right")
213
219
  return;
214
220
  t.preventDefault();
215
- const c = t.key === "ArrowRight" || t.key === "Right";
216
- c !== n.value && await C(c, t);
217
- }, R = (t) => {
218
- var c, l;
219
- a("focus", t), (l = (c = s.value) == null ? void 0 : c.onFocus) == null || l.call(c, t);
220
- }, T = (t) => {
221
- var c, l;
222
- a("blur", t), (l = (c = s.value) == null ? void 0 : c.onBlur) == null || l.call(c, t);
221
+ const l = t.key === "ArrowRight" || t.key === "Right";
222
+ l !== a.value && await V(l, t);
223
+ }, L = (t) => {
224
+ var l, u;
225
+ n("focus", t), (u = (l = s.value) == null ? void 0 : l.onFocus) == null || u.call(l, t);
226
+ }, _ = (t) => {
227
+ var l, u;
228
+ n("blur", t), (u = (l = s.value) == null ? void 0 : l.onBlur) == null || u.call(l, t);
223
229
  };
224
- M(w, (t) => {
225
- (q(t) || E(t)) && (o.value = e.uncheckedValue);
230
+ K(B, (t) => {
231
+ (Q(t) || W(t)) && (d.value = e.uncheckedValue);
226
232
  });
227
- const A = i(() => [
228
- u.block,
229
- u.modifier(`type-${e.type}`),
230
- u.modifier(`size-${y.value}`),
233
+ const I = r(() => [
234
+ c.block,
235
+ c.modifier(`type-${e.type}`),
236
+ c.modifier(`size-${y.value}`),
231
237
  {
232
- [u.modifier("checked")]: n.value,
233
- [u.modifier("disabled")]: r.value,
234
- [u.modifier("loading")]: f.value,
235
- [u.modifier("custom-color")]: e.type === "line" && (e.checkedColor || e.uncheckedColor)
238
+ [c.modifier("checked")]: a.value,
239
+ [c.modifier("disabled")]: o.value,
240
+ [c.modifier("loading")]: f.value,
241
+ [c.modifier("custom-color")]: e.type === "line" && (e.checkedColor || e.uncheckedColor)
236
242
  }
237
- ]), F = i(() => {
238
- if (n.value && e.checkedColor)
243
+ ]), D = r(() => {
244
+ if (a.value && e.checkedColor)
239
245
  return e.type === "line" ? { "--custom-color": e.checkedColor } : { backgroundColor: e.checkedColor };
240
- if (!n.value && e.uncheckedColor)
246
+ if (!a.value && e.uncheckedColor)
241
247
  return e.type === "line" ? { "--custom-color": e.uncheckedColor } : { backgroundColor: e.uncheckedColor };
242
- }), L = () => {
248
+ }), M = () => {
243
249
  var t;
244
250
  return (t = h.value) == null ? void 0 : t.focus();
245
- }, _ = () => {
251
+ }, U = () => {
246
252
  var t;
247
253
  return (t = h.value) == null ? void 0 : t.blur();
248
254
  };
249
- return $(() => {
250
- !e.autofocus || r.value || f.value || H(() => {
255
+ return j(() => {
256
+ !e.autofocus || o.value || f.value || E(() => {
251
257
  var t;
252
258
  (t = h.value) == null || t.focus();
253
259
  });
254
- }), V({
255
- focus: L,
256
- blur: _
260
+ }), b({
261
+ focus: M,
262
+ blur: U
257
263
  }), {
258
- className: u,
259
- cls: A,
264
+ formControlAttrs: F,
265
+ className: c,
266
+ cls: I,
260
267
  switchRef: h,
261
- mergedDisabled: r,
262
- buttonStyle: F,
263
- computedCheck: n,
268
+ mergedDisabled: o,
269
+ buttonStyle: D,
270
+ computedCheck: a,
264
271
  computedLoading: f,
265
- showText: B,
266
- handleClick: z,
267
- handleKeydown: N,
268
- handleFocus: R,
269
- handleBlur: T
272
+ showText: N,
273
+ handleClick: R,
274
+ handleKeydown: T,
275
+ handleFocus: L,
276
+ handleBlur: _
270
277
  };
271
278
  }
272
279
  });
273
280
  export {
274
- p as default
281
+ ne as default
275
282
  };
@@ -1,20 +1,20 @@
1
- import { defineComponent as me, toRefs as ve, ref as s, computed as u, watch as I, onMounted as de, nextTick as D } from "vue";
2
- import he from "../../_container/resize-observer.js";
3
- import { useLocale as ge } from "../../locale/index.js";
4
- import Se from "../_components/icon-hover/index.vue.js";
5
- import ye from "../../icons/default/close-circle-fill.js";
6
- import { getSizeStyles as we } from "./utils.js";
7
- import { isUndefined as xe, isNull as pe, isObject as w, isFunction as be } from "../../_utils/is.js";
8
- import { omit as U } from "../../_utils/omit.js";
9
- import { INPUT_EVENTS as W } from "../../_utils/constant.js";
10
- import ze from "../../_utils/pick.js";
11
- import { useFormItem as Ce } from "../../_hooks/use-form-item.js";
12
- import { useSize as Le } from "../../_hooks/use-size.js";
13
- import { useCursor as Fe } from "../../_hooks/use-cursor.js";
14
- import { getClassNameMixin as Be } from "../../_utils/config.js";
15
- const De = me({
1
+ import { defineComponent as de, toRefs as he, ref as s, computed as r, watch as z, onMounted as ge, nextTick as U } from "vue";
2
+ import Se from "../../_container/resize-observer.js";
3
+ import { useLocale as we } from "../../locale/index.js";
4
+ import ye from "../_components/icon-hover/index.vue.js";
5
+ import xe from "../../icons/default/close-circle-fill.js";
6
+ import { getSizeStyles as ze } from "./utils.js";
7
+ import { isUndefined as be, isNull as Ce, isObject as b, isFunction as pe } from "../../_utils/is.js";
8
+ import { omit as W } from "../../_utils/omit.js";
9
+ import { INPUT_EVENTS as P } from "../../_utils/constant.js";
10
+ import Le from "../../_utils/pick.js";
11
+ import { useFormItem as Fe, useFormItemControl as Be } from "../../_hooks/use-form-item.js";
12
+ import { useSize as He } from "../../_hooks/use-size.js";
13
+ import { useCursor as Ie } from "../../_hooks/use-cursor.js";
14
+ import { getClassNameMixin as Ne } from "../../_utils/config.js";
15
+ const Pe = de({
16
16
  name: "Textarea",
17
- components: { ResizeObserver: he, IconHover: Se, IconClose: ye },
17
+ components: { ResizeObserver: Se, IconHover: ye, IconClose: xe },
18
18
  inheritAttrs: !1,
19
19
  props: {
20
20
  /**
@@ -123,14 +123,14 @@ const De = me({
123
123
  * @param {string} value
124
124
  * @param {Event} ev
125
125
  */
126
- input: (t, c) => !0,
126
+ input: (t, f) => !0,
127
127
  /**
128
128
  * @zh 仅在文本框失焦时触发
129
129
  * @en Only emitted when the textarea is out of focus
130
130
  * @param {string} value
131
131
  * @param {Event} ev
132
132
  */
133
- change: (t, c) => !0,
133
+ change: (t, f) => !0,
134
134
  /**
135
135
  * @zh 点击清除按钮时触发
136
136
  * @en Emitted when the clear button is clicked
@@ -150,134 +150,149 @@ const De = me({
150
150
  */
151
151
  blur: (t) => !0
152
152
  },
153
- setup(t, { emit: c, attrs: d }) {
154
- const { disabled: P, error: q, modelValue: x, size: G } = ve(t), f = Be("textarea"), {
153
+ setup(t, { emit: f, attrs: h }) {
154
+ const { disabled: q, error: G, modelValue: C, size: J } = he(t), m = Ne("textarea"), {
155
+ formItemCtx: K,
155
156
  mergedDisabled: p,
156
- mergedError: J,
157
- mergedSize: K,
158
- eventHandlers: m
159
- } = Ce({ disabled: P, error: q, size: G }), { t: Q } = ge(), { mergedSize: X } = Le(K), r = s(), O = s(), h = s(), T = s(), b = s(t.defaultValue), n = u(() => x.value ?? b.value), [Y, Z] = Fe(r);
160
- I(x, (e) => {
161
- (xe(e) || pe(e)) && (b.value = "");
157
+ mergedError: Q,
158
+ mergedSize: X,
159
+ eventHandlers: v
160
+ } = Fe({ disabled: q, error: G, size: J }), { t: Y } = we(), { mergedSize: _ } = He(X), o = s(), L = s(), c = s(), F = s(), B = s(t.defaultValue), n = r(() => C.value ?? B.value), [Z, ee] = Ie(o);
161
+ z(C, (e) => {
162
+ (be(e) || Ce(e)) && (B.value = "");
162
163
  });
163
- const g = u(
164
- () => w(t.maxLength) && !!t.maxLength.errorOnly
165
- ), o = u(() => w(t.maxLength) ? t.maxLength.length : t.maxLength), S = (e) => be(t.wordLength) ? t.wordLength(e) : Array.from(e).length, E = u(() => S(n.value)), _ = u(
166
- () => J.value || !!(o.value && g.value && E.value > o.value)
167
- ), v = s(!1), z = s(!1), j = u(
164
+ const g = r(
165
+ () => b(t.maxLength) && !!t.maxLength.errorOnly
166
+ ), u = r(() => b(t.maxLength) ? t.maxLength.length : t.maxLength), S = (e) => pe(t.wordLength) ? t.wordLength(e) : Array.from(e).length, j = r(() => S(n.value)), M = r(
167
+ () => Q.value || !!(u.value && g.value && j.value > u.value)
168
+ ), d = s(!1), H = s(!1), $ = r(
168
169
  () => t.allowClear && !p.value && n.value
169
- ), C = s(!1), L = () => {
170
- Y(), D(() => {
171
- r.value && n.value !== r.value.value && (r.value.value = n.value, Z());
170
+ ), I = s(!1), N = () => {
171
+ Z(), U(() => {
172
+ o.value && n.value !== o.value.value && (o.value.value = n.value, ee());
172
173
  });
173
- }, y = (e, l = !0) => {
174
+ }, w = (e, l = !0) => {
174
175
  var a;
175
- o.value && !g.value && S(e) > o.value && (e = ((a = t.wordSlice) == null ? void 0 : a.call(t, e, o.value)) ?? Array.from(e).slice(0, o.value).join("")), b.value = e, l && c("update:modelValue", e), L();
176
+ u.value && !g.value && S(e) > u.value && (e = ((a = t.wordSlice) == null ? void 0 : a.call(t, e, u.value)) ?? Array.from(e).slice(0, u.value).join("")), B.value = e, l && f("update:modelValue", e), N();
176
177
  };
177
- let F = n.value;
178
- const M = (e, l) => {
178
+ let R = n.value;
179
+ const k = (e, l) => {
179
180
  var a, i;
180
- e !== F && (F = e, c("change", e, l), (i = (a = m.value) == null ? void 0 : a.onChange) == null || i.call(a, l));
181
- }, ee = (e) => {
182
- var l, a;
183
- z.value = !0, F = n.value, c("focus", e), (a = (l = m.value) == null ? void 0 : l.onFocus) == null || a.call(l, e);
181
+ e !== R && (R = e, f("change", e, l), (i = (a = v.value) == null ? void 0 : a.onChange) == null || i.call(a, l));
184
182
  }, te = (e) => {
185
183
  var l, a;
186
- z.value = !1, c("blur", e), (a = (l = m.value) == null ? void 0 : l.onBlur) == null || a.call(l, e), M(n.value, e);
184
+ H.value = !0, R = n.value, f("focus", e), (a = (l = v.value) == null ? void 0 : l.onFocus) == null || a.call(l, e);
187
185
  }, ae = (e) => {
186
+ var l, a;
187
+ H.value = !1, f("blur", e), (a = (l = v.value) == null ? void 0 : l.onBlur) == null || a.call(l, e), k(n.value, e);
188
+ }, le = (e) => {
188
189
  var a, i;
189
190
  const { value: l } = e.target;
190
191
  if (e.type === "compositionend") {
191
- if (C.value = !1, o.value && !g.value && n.value.length >= o.value && S(l) > o.value) {
192
- L();
192
+ if (I.value = !1, u.value && !g.value && n.value.length >= u.value && S(l) > u.value) {
193
+ N();
193
194
  return;
194
195
  }
195
- y(l), c("input", l, e), (i = (a = m.value) == null ? void 0 : a.onInput) == null || i.call(a, e);
196
+ w(l), f("input", l, e), (i = (a = v.value) == null ? void 0 : a.onInput) == null || i.call(a, e);
196
197
  } else
197
- C.value = !0;
198
- }, le = (e) => {
198
+ I.value = !0;
199
+ }, oe = (e) => {
199
200
  var a, i;
200
201
  const { value: l } = e.target;
201
- if (!C.value) {
202
- if (o.value && !g.value && n.value.length >= o.value && S(l) > o.value && e.inputType === "insertText") {
203
- L();
202
+ if (!I.value) {
203
+ if (u.value && !g.value && n.value.length >= u.value && S(l) > u.value && e.inputType === "insertText") {
204
+ N();
204
205
  return;
205
206
  }
206
- y(l), c("input", l, e), (i = (a = m.value) == null ? void 0 : a.onInput) == null || i.call(a, e);
207
+ w(l), f("input", l, e), (i = (a = v.value) == null ? void 0 : a.onInput) == null || i.call(a, e);
207
208
  }
208
- }, oe = (e) => {
209
- y(""), M("", e), c("clear", e);
209
+ }, ue = (e) => {
210
+ var l, a;
211
+ w(""), k("", e), (a = (l = v.value) == null ? void 0 : l.onInput) == null || a.call(l, e), f("clear", e);
210
212
  };
211
- I(x, (e) => {
212
- e !== n.value && y(e ?? "", !1);
213
+ z(C, (e) => {
214
+ e !== n.value && w(e ?? "", !1);
213
215
  });
214
- const re = u(() => U(U(d, W), ["class", "style"])), ue = u(() => d.style), ne = u(() => ze(d, W)), ie = u(() => {
216
+ const re = r(() => W(W(h, P), ["class", "style"])), ne = r(() => h.style), ie = r(() => Le(h, P)), se = Be(K, () => ({
217
+ ...ie.value,
218
+ ...t.textareaAttrs
219
+ })), fe = r(() => {
215
220
  const e = {
216
- ...ne.value,
217
- ...t.textareaAttrs
221
+ ...se.value
218
222
  };
219
- return _.value && (e["aria-invalid"] = !0), e;
220
- }), se = u(() => [
221
- f.element("wrapper"),
222
- d.class,
223
- f.modifier(`size-${X.value}`),
223
+ return M.value && (e["aria-invalid"] = !0), e;
224
+ }), me = r(() => [
225
+ m.element("wrapper"),
226
+ h.class,
227
+ m.modifier(`size-${_.value}`),
224
228
  {
225
- [f.modifier("focus")]: z.value,
226
- [f.modifier("disabled")]: p.value,
227
- [f.modifier("error")]: _.value,
228
- [f.modifier("scroll")]: v.value,
229
- [f.modifier("has-clear")]: j.value,
230
- [f.modifier("has-word-limit")]: !!(o.value && t.showWordLimit)
229
+ [m.modifier("focus")]: H.value,
230
+ [m.modifier("disabled")]: p.value,
231
+ [m.modifier("error")]: M.value,
232
+ [m.modifier("scroll")]: d.value,
233
+ [m.modifier("has-clear")]: $.value,
234
+ [m.modifier("has-word-limit")]: !!(u.value && t.showWordLimit)
231
235
  }
232
236
  ]);
233
- let $;
234
- const B = s(0), H = s(0), N = u(() => !w(t.autoSize) || !t.autoSize.minRows ? 0 : t.autoSize.minRows * B.value + H.value), R = u(() => !w(t.autoSize) || !t.autoSize.maxRows ? 0 : t.autoSize.maxRows * B.value + H.value), V = () => {
235
- const e = we($);
236
- B.value = Number.parseFloat(e["line-height"] || "0"), H.value = Number.parseFloat(e["border-top-width"] || "0") + Number.parseFloat(e["border-bottom-width"] || "0") + Number.parseFloat(e["padding-top"] || "0") + Number.parseFloat(e["padding-bottom"] || "0"), T.value = e, D(() => {
237
- var k;
238
- let a = ((k = h.value) == null ? void 0 : k.offsetHeight) ?? 0, i = "hidden";
239
- N.value && a < N.value && (a = N.value), R.value && a > R.value && (a = R.value, i = "auto"), O.value = {
237
+ let V;
238
+ const A = s(0), O = s(0), T = r(() => !b(t.autoSize) || !t.autoSize.minRows ? 0 : t.autoSize.minRows * A.value + O.value), E = r(() => !b(t.autoSize) || !t.autoSize.maxRows ? 0 : t.autoSize.maxRows * A.value + O.value), y = () => {
239
+ if (!o.value || !t.autoSize)
240
+ return;
241
+ V = window.getComputedStyle(o.value);
242
+ const e = ze(V);
243
+ A.value = Number.parseFloat(e["line-height"] || "0"), O.value = Number.parseFloat(e["border-top-width"] || "0") + Number.parseFloat(e["border-bottom-width"] || "0") + Number.parseFloat(e["padding-top"] || "0") + Number.parseFloat(e["padding-bottom"] || "0"), F.value = e, U(() => {
244
+ var D;
245
+ if (!t.autoSize || !c.value)
246
+ return;
247
+ let a = ((D = c.value) == null ? void 0 : D.offsetHeight) ?? 0, i = "hidden";
248
+ T.value && a < T.value && (a = T.value), E.value && a > E.value && (a = E.value, i = "auto"), L.value = {
240
249
  height: `${a}px`,
241
250
  resize: "none",
242
251
  overflow: i
243
252
  };
244
253
  });
245
254
  };
246
- de(() => {
247
- r.value && ($ = window.getComputedStyle(r.value), t.autoSize && V()), A();
255
+ ge(() => {
256
+ o.value && (V = window.getComputedStyle(o.value), t.autoSize && y()), x();
248
257
  });
249
- const ce = () => {
250
- t.autoSize && h.value && V(), A();
251
- }, fe = (e) => {
252
- r.value && e.target !== r.value && (e.preventDefault(), r.value.focus());
253
- }, A = () => {
254
- r.value && (r.value.scrollHeight > r.value.offsetHeight ? v.value || (v.value = !0) : v.value && (v.value = !1));
258
+ const ve = () => {
259
+ t.autoSize && c.value && y(), x();
260
+ }, ce = (e) => {
261
+ o.value && e.target !== o.value && (e.preventDefault(), o.value.focus());
262
+ }, x = () => {
263
+ o.value && (o.value.scrollHeight > o.value.offsetHeight ? d.value || (d.value = !0) : d.value && (d.value = !1));
255
264
  };
256
- return I(n, () => {
257
- t.autoSize && h.value && V(), A();
258
- }), {
259
- t: Q,
260
- className: f,
261
- wrapperCls: se,
262
- textareaRef: r,
263
- textareaStyle: O,
264
- mirrorRef: h,
265
- mirrorStyle: T,
265
+ return z(n, () => {
266
+ t.autoSize && c.value && y(), x();
267
+ }), z(
268
+ () => [t.autoSize, _.value],
269
+ () => {
270
+ t.autoSize ? y() : (L.value = void 0, F.value = void 0), x();
271
+ },
272
+ { deep: !0, flush: "post" }
273
+ ), {
274
+ t: Y,
275
+ className: m,
276
+ wrapperCls: me,
277
+ textareaRef: o,
278
+ textareaStyle: L,
279
+ mirrorRef: c,
280
+ mirrorStyle: F,
266
281
  computedValue: n,
267
- showClearBtn: j,
268
- valueLength: E,
269
- computedMaxLength: o,
282
+ showClearBtn: $,
283
+ valueLength: j,
284
+ computedMaxLength: u,
270
285
  mergedDisabled: p,
271
- mergeTextareaAttrs: ie,
286
+ mergeTextareaAttrs: fe,
272
287
  wrapperAttrs: re,
273
- wrapperStyle: ue,
274
- handleInput: le,
275
- handleFocus: ee,
276
- handleBlur: te,
277
- handleComposition: ae,
278
- handleClear: oe,
279
- handleResize: ce,
280
- handleMousedown: fe
288
+ wrapperStyle: ne,
289
+ handleInput: oe,
290
+ handleFocus: te,
291
+ handleBlur: ae,
292
+ handleComposition: le,
293
+ handleClear: ue,
294
+ handleResize: ve,
295
+ handleMousedown: ce
281
296
  };
282
297
  },
283
298
  methods: {
@@ -304,5 +319,5 @@ const De = me({
304
319
  }
305
320
  });
306
321
  export {
307
- De as default
322
+ Pe as default
308
323
  };