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.
- package/CHANGELOG.md +26 -0
- package/dist/_hooks/use-form-item.d.ts +5 -0
- package/dist/_hooks/use-picker-focus.d.ts +17 -0
- package/dist/components/_components/feedback-icon/index.vue.d.ts +4 -4
- package/dist/components/_components/picker/input-range.vue.d.ts +10 -6
- package/dist/components/_components/picker/input.vue.d.ts +9 -5
- package/dist/components/alert/Alert.vue.d.ts +5 -5
- package/dist/components/alert/index.d.ts +10 -10
- package/dist/components/date-picker/DatePanel.vue.d.ts +5 -0
- package/dist/components/date-picker/DatePicker.vue.d.ts +36 -16
- package/dist/components/date-picker/index.d.ts +77 -33
- package/dist/components/dialog/Dialog.d.ts +1 -1
- package/dist/components/dialog/index.d.ts +3 -3
- package/dist/components/drawer/index.d.ts +3 -3
- package/dist/components/drawer/src/Drawer.vue.d.ts +1 -1
- package/dist/components/dropdown/Dropdown.vue.d.ts +3 -3
- package/dist/components/dropdown/DropdownButton.vue.d.ts +4 -4
- package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +4 -4
- package/dist/components/dropdown/index.d.ts +22 -22
- package/dist/components/form/FormItem.vue.d.ts +12 -4
- package/dist/components/form/context.d.ts +6 -0
- package/dist/components/form/form-item-label.vue.d.ts +4 -4
- package/dist/components/form/form-item-message.vue.d.ts +2 -0
- package/dist/components/form/index.d.ts +30 -8
- package/dist/components/form/interface.d.ts +2 -2
- package/dist/components/form-input/InputPassword.vue.d.ts +20 -2
- package/dist/components/form-input/index.d.ts +22 -4
- package/dist/components/form-select/Select.d.ts +3 -3
- package/dist/components/form-select/index.d.ts +6 -6
- package/dist/components/form-slider/Slider.vue.d.ts +10 -3
- package/dist/components/form-slider/index.d.ts +26 -6
- package/dist/components/form-slider/slider-button.vue.d.ts +4 -3
- package/dist/components/form-switch/Switch.vue.d.ts +2 -1
- package/dist/components/form-switch/index.d.ts +5 -2
- package/dist/components/form-textarea/Textarea.vue.d.ts +2 -2
- package/dist/components/form-textarea/index.d.ts +5 -5
- package/dist/components/image/Image.vue.d.ts +10 -9
- package/dist/components/image/ImagePreview.vue.d.ts +8 -7
- package/dist/components/image/ImagePreviewAction.d.ts +3 -3
- package/dist/components/image/ImagePreviewGroup.vue.d.ts +8 -7
- package/dist/components/image/index.d.ts +59 -52
- package/dist/components/image/preview-arrow.vue.d.ts +2 -2
- package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
- package/dist/components/layout/LayoutSidebar.vue.d.ts +2 -2
- package/dist/components/layout/index.d.ts +4 -4
- package/dist/components/link/Link.vue.d.ts +2 -2
- package/dist/components/link/index.d.ts +4 -4
- package/dist/components/menu/Menu.d.ts +2 -2
- package/dist/components/menu/base-menu.vue.d.ts +2 -2
- package/dist/components/menu/index.d.ts +4 -4
- package/dist/components/menu/sub-menu-pop.vue.d.ts +5 -5
- package/dist/components/message/index.d.ts +17 -17
- package/dist/components/message/message.vue.d.ts +8 -8
- package/dist/components/notification/Notification.d.ts +1 -1
- package/dist/components/notification/index.d.ts +3 -3
- package/dist/components/pagination/page-item-ellipsis.vue.d.ts +1 -1
- package/dist/components/pagination/page-item-step.vue.d.ts +2 -2
- package/dist/components/pagination/page-options.vue.d.ts +6 -6
- package/dist/components/popconfirm/src/popup.vue.d.ts +1 -1
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -3
- package/dist/components/popup/Popup.d.ts +1 -1
- package/dist/components/popup/index.d.ts +3 -3
- package/dist/components/progress/Progress.vue.d.ts +4 -4
- package/dist/components/progress/circle.vue.d.ts +2 -2
- package/dist/components/progress/index.d.ts +8 -8
- package/dist/components/progress/line.vue.d.ts +1 -1
- package/dist/components/progress/steps.vue.d.ts +1 -1
- package/dist/components/steps/Step.vue.d.ts +2 -2
- package/dist/components/steps/index.d.ts +4 -4
- package/dist/components/tabs/Tabs.d.ts +1 -1
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/tabs/tabs-tab.vue.d.ts +1 -1
- package/dist/components/tag/Tag.vue.d.ts +2 -2
- package/dist/components/tag/index.d.ts +4 -4
- package/dist/components/time-picker/TimeColumn.vue.d.ts +3 -0
- package/dist/components/time-picker/TimePanel.vue.d.ts +3 -0
- package/dist/components/time-picker/TimePicker.vue.d.ts +33 -17
- package/dist/components/time-picker/index.d.ts +73 -36
- package/dist/components/time-range-selector/TimeRangeSelector.vue.d.ts +8 -0
- package/dist/components/time-range-selector/index.d.ts +22 -0
- package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/components/trigger/Trigger.d.ts +1 -1
- package/dist/components/trigger/index.d.ts +3 -3
- package/dist/es/_hooks/use-form-item.js +36 -10
- package/dist/es/_hooks/use-picker-focus.js +57 -0
- package/dist/es/_utils/constant.js +17 -5
- package/dist/es/components/_components/picker/input-range.vue.js +45 -55
- package/dist/es/components/_components/picker/input-range.vue2.js +105 -70
- package/dist/es/components/_components/picker/input.vue.js +22 -25
- package/dist/es/components/_components/picker/input.vue2.js +58 -43
- package/dist/es/components/_components/select-view/select-view.js +67 -66
- package/dist/es/components/date-picker/DatePanel.vue.js +102 -94
- package/dist/es/components/date-picker/DatePanel.vue2.js +97 -44
- package/dist/es/components/date-picker/DatePicker.vue.js +71 -58
- package/dist/es/components/date-picker/DatePicker.vue2.js +285 -231
- package/dist/es/components/dialog/Dialog.js +154 -132
- package/dist/es/components/form/Form.vue2.js +113 -101
- package/dist/es/components/form/FormItem.vue.js +26 -22
- package/dist/es/components/form/FormItem.vue2.js +162 -125
- package/dist/es/components/form/form-item-message.vue.js +31 -24
- package/dist/es/components/form/form-item-message.vue2.js +4 -2
- package/dist/es/components/form-checkbox/Checkbox.js +75 -71
- package/dist/es/components/form-checkbox/CheckboxGroup.js +43 -38
- package/dist/es/components/form-input/Input.js +83 -79
- package/dist/es/components/form-input/InputPassword.vue.js +19 -16
- package/dist/es/components/form-input/InputPassword.vue2.js +39 -29
- package/dist/es/components/form-input/InputSearch.js +47 -37
- package/dist/es/components/form-input-number/InputNumber.js +134 -133
- package/dist/es/components/form-input-tag/InputTag.js +173 -162
- package/dist/es/components/form-radio/Radio.js +74 -71
- package/dist/es/components/form-radio/RadioGroup.js +55 -49
- package/dist/es/components/form-select/Select.js +99 -98
- package/dist/es/components/form-slider/Slider.vue.js +28 -28
- package/dist/es/components/form-slider/Slider.vue2.js +139 -132
- package/dist/es/components/form-slider/slider-button.vue.js +6 -6
- package/dist/es/components/form-slider/slider-button.vue2.js +39 -34
- package/dist/es/components/form-switch/Switch.vue.js +9 -9
- package/dist/es/components/form-switch/Switch.vue2.js +81 -74
- package/dist/es/components/form-textarea/Textarea.vue2.js +123 -108
- package/dist/es/components/image/Image.vue2.js +77 -76
- package/dist/es/components/image/ImagePreview.vue.js +13 -12
- package/dist/es/components/image/ImagePreview.vue2.js +141 -136
- package/dist/es/components/image/ImagePreviewGroup.vue.js +1 -1
- package/dist/es/components/image/ImagePreviewGroup.vue2.js +82 -83
- package/dist/es/components/rate/Rate.js +106 -103
- package/dist/es/components/time-picker/TimeColumn.vue.js +34 -23
- package/dist/es/components/time-picker/TimeColumn.vue2.js +37 -28
- package/dist/es/components/time-picker/TimePicker.vue.js +83 -64
- package/dist/es/components/time-picker/TimePicker.vue2.js +192 -156
- package/dist/es/components/time-range-selector/TimeRangeSelector.vue.js +327 -193
- package/dist/es/locale/en-US.js +6 -0
- package/dist/es/locale/zh-CN.js +6 -0
- package/dist/es/style.css +1 -1
- package/dist/icons/_self/down.d.ts +1 -1
- package/dist/icons/_self/dropdown/more.d.ts +1 -1
- package/dist/icons/_self/empty-better.d.ts +1 -1
- package/dist/icons/_self/empty.d.ts +1 -1
- package/dist/icons/_self/eye-invisible.d.ts +1 -1
- package/dist/icons/_self/eye.d.ts +1 -1
- package/dist/icons/_self/full-screen.d.ts +1 -1
- package/dist/icons/_self/left.d.ts +1 -1
- package/dist/icons/_self/menu/down.d.ts +1 -1
- package/dist/icons/_self/minus.d.ts +1 -1
- package/dist/icons/_self/more-dot.d.ts +1 -1
- package/dist/icons/_self/next.d.ts +1 -1
- package/dist/icons/_self/original-size.d.ts +1 -1
- package/dist/icons/_self/plus.d.ts +1 -1
- package/dist/icons/_self/prev.d.ts +1 -1
- package/dist/icons/_self/question-message.d.ts +1 -1
- package/dist/icons/_self/right.d.ts +1 -1
- package/dist/icons/_self/rotate-left.d.ts +1 -1
- package/dist/icons/_self/rotate-right.d.ts +1 -1
- package/dist/icons/_self/search.d.ts +1 -1
- package/dist/icons/_self/up.d.ts +1 -1
- package/dist/icons/_self/zoom-in.d.ts +1 -1
- package/dist/icons/_self/zoom-out.d.ts +1 -1
- package/dist/icons/_ui/alone-left.d.ts +1 -1
- package/dist/icons/_ui/alone-margin-left.d.ts +1 -1
- package/dist/icons/_ui/alone-margin-right.d.ts +1 -1
- package/dist/icons/_ui/alone-right.d.ts +1 -1
- package/dist/icons/_ui/calendar.d.ts +1 -1
- package/dist/icons/_ui/time.d.ts +1 -1
- package/dist/icons/animation/animation-loading.d.ts +1 -1
- package/dist/icons/default/check-circle-fill.d.ts +1 -1
- package/dist/icons/default/check.d.ts +1 -1
- package/dist/icons/default/close-circle-fill.d.ts +1 -1
- package/dist/icons/default/close.d.ts +1 -1
- package/dist/icons/default/exclamation-circle-fill.d.ts +1 -1
- package/dist/icons/default/exclamation.d.ts +1 -1
- package/dist/icons/default/filter.d.ts +1 -1
- package/dist/icons/default/info-circle-fill.d.ts +1 -1
- package/dist/icons/default/link.d.ts +1 -1
- package/dist/icons/default/logo-simple.d.ts +1 -1
- package/dist/icons/default/minus-circle-fill.d.ts +1 -1
- package/dist/icons/icon.d.ts +2 -2
- package/dist/icons/index.d.ts +3 -3
- package/dist/index.cjs +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/locale/interface.d.ts +6 -0
- package/dist/style/base.css +1 -1
- package/dist/style/date-picker.css +1 -1
- package/dist/style/form.css +1 -1
- package/dist/style/image.css +1 -1
- package/dist/style/time-range-selector.css +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useFormItem as
|
|
4
|
-
import { useSize as
|
|
5
|
-
import { isUndefined as
|
|
6
|
-
import { getClassNameMixin as
|
|
7
|
-
const
|
|
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:
|
|
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,
|
|
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,
|
|
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:
|
|
180
|
-
const { disabled:
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
} =
|
|
185
|
-
disabled:
|
|
186
|
-
size:
|
|
187
|
-
}), { mergedSize: y } =
|
|
188
|
-
() => (e.modelValue ??
|
|
189
|
-
),
|
|
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
|
-
),
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
if (f.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
|
|
198
|
-
if (
|
|
199
|
-
|
|
203
|
+
const u = t ? e.checkedValue : e.uncheckedValue, i = e.beforeChange;
|
|
204
|
+
if (X(i)) {
|
|
205
|
+
m.value = !0;
|
|
200
206
|
try {
|
|
201
|
-
(await
|
|
207
|
+
(await i(u) ?? !0) && !o.value && !v && C(t, l);
|
|
202
208
|
} catch {
|
|
203
209
|
} finally {
|
|
204
|
-
|
|
210
|
+
m.value = !1;
|
|
205
211
|
}
|
|
206
212
|
} else
|
|
207
|
-
|
|
208
|
-
},
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
},
|
|
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
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
var
|
|
219
|
-
|
|
220
|
-
},
|
|
221
|
-
var
|
|
222
|
-
|
|
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
|
-
|
|
225
|
-
(
|
|
230
|
+
K(B, (t) => {
|
|
231
|
+
(Q(t) || W(t)) && (d.value = e.uncheckedValue);
|
|
226
232
|
});
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
const I = r(() => [
|
|
234
|
+
c.block,
|
|
235
|
+
c.modifier(`type-${e.type}`),
|
|
236
|
+
c.modifier(`size-${y.value}`),
|
|
231
237
|
{
|
|
232
|
-
[
|
|
233
|
-
[
|
|
234
|
-
[
|
|
235
|
-
[
|
|
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
|
-
]),
|
|
238
|
-
if (
|
|
243
|
+
]), D = r(() => {
|
|
244
|
+
if (a.value && e.checkedColor)
|
|
239
245
|
return e.type === "line" ? { "--custom-color": e.checkedColor } : { backgroundColor: e.checkedColor };
|
|
240
|
-
if (!
|
|
246
|
+
if (!a.value && e.uncheckedColor)
|
|
241
247
|
return e.type === "line" ? { "--custom-color": e.uncheckedColor } : { backgroundColor: e.uncheckedColor };
|
|
242
|
-
}),
|
|
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 ||
|
|
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
|
-
}),
|
|
255
|
-
focus:
|
|
256
|
-
blur:
|
|
260
|
+
}), b({
|
|
261
|
+
focus: M,
|
|
262
|
+
blur: U
|
|
257
263
|
}), {
|
|
258
|
-
|
|
259
|
-
|
|
264
|
+
formControlAttrs: F,
|
|
265
|
+
className: c,
|
|
266
|
+
cls: I,
|
|
260
267
|
switchRef: h,
|
|
261
|
-
mergedDisabled:
|
|
262
|
-
buttonStyle:
|
|
263
|
-
computedCheck:
|
|
268
|
+
mergedDisabled: o,
|
|
269
|
+
buttonStyle: D,
|
|
270
|
+
computedCheck: a,
|
|
264
271
|
computedLoading: f,
|
|
265
|
-
showText:
|
|
266
|
-
handleClick:
|
|
267
|
-
handleKeydown:
|
|
268
|
-
handleFocus:
|
|
269
|
-
handleBlur:
|
|
272
|
+
showText: N,
|
|
273
|
+
handleClick: R,
|
|
274
|
+
handleKeydown: T,
|
|
275
|
+
handleFocus: L,
|
|
276
|
+
handleBlur: _
|
|
270
277
|
};
|
|
271
278
|
}
|
|
272
279
|
});
|
|
273
280
|
export {
|
|
274
|
-
|
|
281
|
+
ne as default
|
|
275
282
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { useLocale as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { getSizeStyles as
|
|
7
|
-
import { isUndefined as
|
|
8
|
-
import { omit as
|
|
9
|
-
import { INPUT_EVENTS as
|
|
10
|
-
import
|
|
11
|
-
import { useFormItem as
|
|
12
|
-
import { useSize as
|
|
13
|
-
import { useCursor as
|
|
14
|
-
import { getClassNameMixin as
|
|
15
|
-
const
|
|
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:
|
|
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,
|
|
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,
|
|
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:
|
|
154
|
-
const { disabled:
|
|
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:
|
|
157
|
-
mergedSize:
|
|
158
|
-
eventHandlers:
|
|
159
|
-
} =
|
|
160
|
-
|
|
161
|
-
(
|
|
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 =
|
|
164
|
-
() =>
|
|
165
|
-
),
|
|
166
|
-
() =>
|
|
167
|
-
),
|
|
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
|
-
),
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
},
|
|
174
|
+
}, w = (e, l = !0) => {
|
|
174
175
|
var a;
|
|
175
|
-
|
|
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
|
|
178
|
-
const
|
|
178
|
+
let R = n.value;
|
|
179
|
+
const k = (e, l) => {
|
|
179
180
|
var a, i;
|
|
180
|
-
e !==
|
|
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
|
-
|
|
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 (
|
|
192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
198
|
-
},
|
|
198
|
+
I.value = !0;
|
|
199
|
+
}, oe = (e) => {
|
|
199
200
|
var a, i;
|
|
200
201
|
const { value: l } = e.target;
|
|
201
|
-
if (!
|
|
202
|
-
if (
|
|
203
|
-
|
|
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
|
-
|
|
207
|
+
w(l), f("input", l, e), (i = (a = v.value) == null ? void 0 : a.onInput) == null || i.call(a, e);
|
|
207
208
|
}
|
|
208
|
-
},
|
|
209
|
-
|
|
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
|
-
|
|
212
|
-
e !== n.value &&
|
|
213
|
+
z(C, (e) => {
|
|
214
|
+
e !== n.value && w(e ?? "", !1);
|
|
213
215
|
});
|
|
214
|
-
const re =
|
|
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
|
-
...
|
|
217
|
-
...t.textareaAttrs
|
|
221
|
+
...se.value
|
|
218
222
|
};
|
|
219
|
-
return
|
|
220
|
-
}),
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
[
|
|
226
|
-
[
|
|
227
|
-
[
|
|
228
|
-
[
|
|
229
|
-
[
|
|
230
|
-
[
|
|
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
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
247
|
-
|
|
255
|
+
ge(() => {
|
|
256
|
+
o.value && (V = window.getComputedStyle(o.value), t.autoSize && y()), x();
|
|
248
257
|
});
|
|
249
|
-
const
|
|
250
|
-
t.autoSize &&
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
},
|
|
254
|
-
|
|
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
|
|
257
|
-
t.autoSize &&
|
|
258
|
-
}),
|
|
259
|
-
t
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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:
|
|
268
|
-
valueLength:
|
|
269
|
-
computedMaxLength:
|
|
282
|
+
showClearBtn: $,
|
|
283
|
+
valueLength: j,
|
|
284
|
+
computedMaxLength: u,
|
|
270
285
|
mergedDisabled: p,
|
|
271
|
-
mergeTextareaAttrs:
|
|
286
|
+
mergeTextareaAttrs: fe,
|
|
272
287
|
wrapperAttrs: re,
|
|
273
|
-
wrapperStyle:
|
|
274
|
-
handleInput:
|
|
275
|
-
handleFocus:
|
|
276
|
-
handleBlur:
|
|
277
|
-
handleComposition:
|
|
278
|
-
handleClear:
|
|
279
|
-
handleResize:
|
|
280
|
-
handleMousedown:
|
|
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
|
-
|
|
322
|
+
Pe as default
|
|
308
323
|
};
|