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,196 +1,218 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useLocale as
|
|
3
|
-
import { getComponentPrefix as
|
|
4
|
-
import { addUnit as
|
|
5
|
-
import { isFunction as
|
|
6
|
-
import
|
|
7
|
-
import { useOverflow as
|
|
8
|
-
import { KEYBOARD_KEY as
|
|
9
|
-
import { getElement as
|
|
10
|
-
import { dialogProps as
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
|
|
1
|
+
import { defineComponent as ie, computed as c, ref as v, reactive as se, onBeforeUnmount as ce, watch as V, createVNode as a, Teleport as re, withDirectives as de, mergeProps as ue, Transition as R, vShow as fe, nextTick as me } from "vue";
|
|
2
|
+
import { useLocale as be } from "../../locale/index.js";
|
|
3
|
+
import { getComponentPrefix as ve, getClassNameMixin as j } from "../../_utils/config.js";
|
|
4
|
+
import { addUnit as F } from "../../_utils/helpers.js";
|
|
5
|
+
import { isFunction as ye, isPromise as ge } from "../../_utils/is.js";
|
|
6
|
+
import he from "../../_hooks/use-popup-manager.js";
|
|
7
|
+
import { useOverflow as Ce } from "../../_hooks/use-overflow.js";
|
|
8
|
+
import { KEYBOARD_KEY as I } from "../../_utils/keyboard.js";
|
|
9
|
+
import { getElement as xe, on as we, off as Ee } from "../../_utils/dom.js";
|
|
10
|
+
import { dialogProps as ke } from "./props.js";
|
|
11
|
+
const De = ["width", "minWidth", "height", "minHeight"];
|
|
12
|
+
let Se = 0;
|
|
13
|
+
const Be = ["a[href]", "button:not([disabled])", "textarea:not([disabled])", 'input:not([disabled]):not([type="hidden"])', "select:not([disabled])", '[tabindex]:not([tabindex="-1"])'].join(","), M = (t) => Array.from(t.querySelectorAll(Be)).filter((i) => {
|
|
14
|
+
if (i.matches(':disabled, input[type="hidden"]') || i.closest('[hidden], [inert], [aria-hidden="true"]'))
|
|
15
|
+
return !1;
|
|
16
|
+
for (let s = i; s; s = s.parentElement) {
|
|
17
|
+
const o = window.getComputedStyle(s);
|
|
18
|
+
if (o.display === "none" || o.visibility === "hidden" || o.visibility === "collapse")
|
|
19
|
+
return !1;
|
|
20
|
+
}
|
|
21
|
+
return !0;
|
|
22
|
+
}), Fe = /* @__PURE__ */ ie({
|
|
23
|
+
name: ve("Dialog"),
|
|
15
24
|
inheritAttrs: !1,
|
|
16
|
-
props:
|
|
25
|
+
props: ke,
|
|
17
26
|
slots: Object,
|
|
18
27
|
emits: ["closed", "close", "open", "opened", "update:modelValue"],
|
|
19
28
|
setup(t, {
|
|
20
|
-
attrs:
|
|
21
|
-
emit:
|
|
22
|
-
slots:
|
|
29
|
+
attrs: i,
|
|
30
|
+
emit: s,
|
|
31
|
+
slots: o
|
|
23
32
|
}) {
|
|
24
|
-
const
|
|
25
|
-
t:
|
|
26
|
-
} =
|
|
33
|
+
const r = j("dialog"), {
|
|
34
|
+
t: N
|
|
35
|
+
} = be(), z = r.block, f = j("message-box"), y = `x-dialog-title-${++Se}`, G = c(() => [z, t.messageBox && "is-message-box", t.messageBox && f.block, t.popupClass && t.popupClass, i.class]), H = c(() => {
|
|
27
36
|
const {
|
|
28
37
|
class: e,
|
|
29
38
|
style: n,
|
|
30
|
-
id:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
id: l,
|
|
40
|
+
"aria-label": u,
|
|
41
|
+
"aria-labelledby": B,
|
|
42
|
+
"aria-describedby": T,
|
|
43
|
+
...ae
|
|
44
|
+
} = i;
|
|
45
|
+
return ae;
|
|
46
|
+
}), g = c(() => {
|
|
35
47
|
if (!(typeof document > "u"))
|
|
36
|
-
return
|
|
37
|
-
}),
|
|
38
|
-
zIndex:
|
|
39
|
-
},
|
|
48
|
+
return xe(t.renderTo) || document.body;
|
|
49
|
+
}), h = v(), C = v(), p = c(() => t.disabled || !g.value), U = c(() => [{
|
|
50
|
+
zIndex: $.value
|
|
51
|
+
}, i.style]), Y = c(() => {
|
|
40
52
|
const e = {};
|
|
41
|
-
return t.fullscreen || (!t.center && t.top && (e.top =
|
|
42
|
-
t[n] && (e[n] =
|
|
53
|
+
return t.fullscreen || (!t.center && t.top && (e.top = F(t.top)), De.forEach((n) => {
|
|
54
|
+
t[n] && (e[n] = F(t[n]));
|
|
43
55
|
})), e;
|
|
44
|
-
}), x =
|
|
45
|
-
zIndex:
|
|
46
|
-
isLastDialog:
|
|
47
|
-
|
|
48
|
-
|
|
56
|
+
}), x = v(!1), d = c(() => t.modelValue), K = c(() => d.value || x.value), q = c(() => !t.destroyOnClosed || K.value), W = c(() => K.value), {
|
|
57
|
+
zIndex: $,
|
|
58
|
+
isLastDialog: w,
|
|
59
|
+
close: J
|
|
60
|
+
} = he("dialog", {
|
|
61
|
+
visible: d
|
|
49
62
|
}), {
|
|
50
|
-
setOverflowHidden:
|
|
51
|
-
resetOverflow:
|
|
52
|
-
} =
|
|
53
|
-
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
setOverflowHidden: Q,
|
|
64
|
+
resetOverflow: A
|
|
65
|
+
} = Ce(g, h), O = (e, n) => {
|
|
66
|
+
s("update:modelValue", !1), s("close", e, n);
|
|
67
|
+
}, E = v(null);
|
|
68
|
+
let k = !1;
|
|
69
|
+
const L = () => {
|
|
70
|
+
var l, u;
|
|
71
|
+
const e = E.value;
|
|
72
|
+
if (E.value = null, !(e != null && e.isConnected) || typeof document > "u" || d.value && !w()) return;
|
|
73
|
+
const n = document.activeElement;
|
|
74
|
+
n != null && n.isConnected && n !== document.body && n !== document.documentElement && n !== e && !((l = h.value) != null && l.contains(n)) || (u = e.focus) == null || u.call(e, {
|
|
75
|
+
preventScroll: !0
|
|
76
|
+
});
|
|
77
|
+
}, X = () => {
|
|
78
|
+
typeof document > "u" || me(() => {
|
|
79
|
+
const e = C.value;
|
|
80
|
+
if (!e || !d.value || k || !w()) return;
|
|
81
|
+
(M(e)[0] || e).focus({
|
|
59
82
|
preventScroll: !0
|
|
60
83
|
});
|
|
61
84
|
});
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, X = () => {
|
|
68
|
-
u("opened"), J();
|
|
69
|
-
}, m = le({
|
|
85
|
+
}, Z = () => {
|
|
86
|
+
k || (x.value = !1, A(), L(), s("closed"));
|
|
87
|
+
}, ee = () => {
|
|
88
|
+
s("opened"), X();
|
|
89
|
+
}, m = se({
|
|
70
90
|
ok: !1,
|
|
71
91
|
cancel: !1
|
|
72
|
-
}),
|
|
73
|
-
let
|
|
74
|
-
if (m[e] = !0,
|
|
92
|
+
}), b = (e, n) => {
|
|
93
|
+
let l = !0;
|
|
94
|
+
if (m[e] = !0, ye(t.onBeforeCancel))
|
|
75
95
|
try {
|
|
76
|
-
|
|
96
|
+
l = t.onBeforeCancel(e) ?? !1;
|
|
77
97
|
} catch {
|
|
78
|
-
|
|
98
|
+
l = !1;
|
|
79
99
|
}
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
100
|
+
if (ge(l)) {
|
|
101
|
+
l.then((u) => {
|
|
102
|
+
u && O(e, n);
|
|
83
103
|
}).catch(() => !1).finally(() => {
|
|
84
104
|
m[e] = !1;
|
|
85
105
|
});
|
|
86
106
|
return;
|
|
87
107
|
}
|
|
88
|
-
m[e] = !1,
|
|
89
|
-
},
|
|
90
|
-
t.maskToClose && t.mask &&
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
-
|
|
108
|
+
m[e] = !1, l && O(e, n);
|
|
109
|
+
}, te = () => {
|
|
110
|
+
t.maskToClose && t.mask && b("cancel");
|
|
111
|
+
}, ne = (e) => {
|
|
112
|
+
b("cancel", e);
|
|
113
|
+
}, le = (e) => {
|
|
114
|
+
b("ok", e);
|
|
95
115
|
};
|
|
96
|
-
let
|
|
97
|
-
const
|
|
98
|
-
t.escToClose && e.key ===
|
|
99
|
-
},
|
|
100
|
-
typeof document > "u" || t.escToClose && !
|
|
101
|
-
},
|
|
102
|
-
typeof document > "u" || (
|
|
103
|
-
},
|
|
104
|
-
if (e.key !==
|
|
105
|
-
const n =
|
|
116
|
+
let D = !1;
|
|
117
|
+
const P = (e) => {
|
|
118
|
+
t.escToClose && e.key === I.ESC && w() && b("cancel", e);
|
|
119
|
+
}, _ = () => {
|
|
120
|
+
typeof document > "u" || t.escToClose && !D && (D = !0, we(document.documentElement, "keydown", P));
|
|
121
|
+
}, S = () => {
|
|
122
|
+
typeof document > "u" || (D = !1, Ee(document.documentElement, "keydown", P));
|
|
123
|
+
}, oe = (e) => {
|
|
124
|
+
if (e.key !== I.TAB) return;
|
|
125
|
+
const n = C.value;
|
|
106
126
|
if (!n) return;
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
127
|
+
const l = M(n);
|
|
128
|
+
if (!l.length) {
|
|
109
129
|
e.preventDefault(), n.focus({
|
|
110
130
|
preventScroll: !0
|
|
111
131
|
});
|
|
112
132
|
return;
|
|
113
133
|
}
|
|
114
|
-
const
|
|
115
|
-
e.shiftKey &&
|
|
134
|
+
const u = l[0], B = l[l.length - 1], T = document.activeElement;
|
|
135
|
+
e.shiftKey && T === u ? (e.preventDefault(), B.focus({
|
|
116
136
|
preventScroll: !0
|
|
117
|
-
})) : !e.shiftKey &&
|
|
137
|
+
})) : !e.shiftKey && T === B && (e.preventDefault(), u.focus({
|
|
118
138
|
preventScroll: !0
|
|
119
139
|
}));
|
|
120
140
|
};
|
|
121
|
-
return
|
|
122
|
-
|
|
123
|
-
}),
|
|
124
|
-
e ? (
|
|
141
|
+
return ce(() => {
|
|
142
|
+
k = !0, L(), J(), A(), S();
|
|
143
|
+
}), V(() => d.value, (e) => {
|
|
144
|
+
e ? (E.value = typeof document > "u" ? null : document.activeElement, s("open"), Q(), x.value = !0, _()) : S();
|
|
125
145
|
}, {
|
|
126
146
|
immediate: !0
|
|
127
|
-
}),
|
|
128
|
-
|
|
129
|
-
}), () =>
|
|
130
|
-
to:
|
|
131
|
-
disabled:
|
|
147
|
+
}), V(() => t.escToClose, (e) => {
|
|
148
|
+
d.value && (e ? _() : S());
|
|
149
|
+
}), () => a(re, {
|
|
150
|
+
to: g.value,
|
|
151
|
+
disabled: p.value
|
|
132
152
|
}, {
|
|
133
|
-
default: () => [
|
|
134
|
-
ref:
|
|
135
|
-
class:
|
|
136
|
-
style:
|
|
137
|
-
id:
|
|
138
|
-
},
|
|
153
|
+
default: () => [q.value && de(a("div", ue({
|
|
154
|
+
ref: h,
|
|
155
|
+
class: G.value,
|
|
156
|
+
style: U.value,
|
|
157
|
+
id: i.id
|
|
158
|
+
}, H.value), [a(R, {
|
|
139
159
|
name: "x-fade-in-standard",
|
|
140
160
|
appear: !0
|
|
141
161
|
}, {
|
|
142
|
-
default: () => [t.mask &&
|
|
143
|
-
class:
|
|
162
|
+
default: () => [t.mask && d.value && a("div", {
|
|
163
|
+
class: r.element("mask")
|
|
144
164
|
}, null)]
|
|
145
|
-
}),
|
|
146
|
-
class: [
|
|
165
|
+
}), a("div", {
|
|
166
|
+
class: [r.element("wrapper"), {
|
|
147
167
|
"is-center": t.center
|
|
148
168
|
}],
|
|
149
|
-
onClick: (e) => e.target === e.currentTarget &&
|
|
150
|
-
}, [
|
|
169
|
+
onClick: (e) => e.target === e.currentTarget && te()
|
|
170
|
+
}, [a(R, {
|
|
151
171
|
name: "x-zoom-in",
|
|
152
172
|
appear: !0,
|
|
153
|
-
onAfterEnter:
|
|
154
|
-
onAfterLeave:
|
|
173
|
+
onAfterEnter: ee,
|
|
174
|
+
onAfterLeave: Z
|
|
155
175
|
}, {
|
|
156
|
-
default: () => [
|
|
157
|
-
ref:
|
|
158
|
-
class: [
|
|
176
|
+
default: () => [d.value && a("div", {
|
|
177
|
+
ref: C,
|
|
178
|
+
class: [r.element("container"), {
|
|
159
179
|
"is-fullscreen": t.fullscreen
|
|
160
180
|
}],
|
|
161
|
-
style:
|
|
181
|
+
style: Y.value,
|
|
162
182
|
role: "dialog",
|
|
163
183
|
"aria-modal": t.mask ? "true" : void 0,
|
|
164
|
-
"aria-
|
|
184
|
+
"aria-label": t.title || o.title ? void 0 : i["aria-label"],
|
|
185
|
+
"aria-labelledby": t.title || o.title ? y : i["aria-labelledby"],
|
|
186
|
+
"aria-describedby": i["aria-describedby"],
|
|
165
187
|
tabindex: -1,
|
|
166
|
-
onKeydown:
|
|
167
|
-
}, [
|
|
168
|
-
class: [t.messageBox ? f.element("header") :
|
|
169
|
-
id:
|
|
170
|
-
}, [
|
|
171
|
-
id: t.title ?
|
|
172
|
-
class: [
|
|
173
|
-
}, [t.title])]),
|
|
174
|
-
class: [t.messageBox ? f.element("body") :
|
|
175
|
-
}, [
|
|
176
|
-
class: [t.messageBox ? f.element("footer") :
|
|
177
|
-
}, [
|
|
178
|
-
cancel:
|
|
179
|
-
ok:
|
|
188
|
+
onKeydown: oe
|
|
189
|
+
}, [a("div", {
|
|
190
|
+
class: [t.messageBox ? f.element("header") : r.element("header"), t.showHeaderBottomLine && "is-bottom-line"],
|
|
191
|
+
id: o.title ? y : void 0
|
|
192
|
+
}, [o.title ? o.title() : a("div", {
|
|
193
|
+
id: t.title ? y : void 0,
|
|
194
|
+
class: [r.element("header-title")]
|
|
195
|
+
}, [t.title])]), a("div", {
|
|
196
|
+
class: [t.messageBox ? f.element("body") : r.element("body")]
|
|
197
|
+
}, [o.default && o.default()]), !t.hideFooter && o.footer && a("div", {
|
|
198
|
+
class: [t.messageBox ? f.element("footer") : r.element("footer")]
|
|
199
|
+
}, [o.footer({
|
|
200
|
+
cancel: ne,
|
|
201
|
+
ok: le,
|
|
180
202
|
loadingObj: m,
|
|
181
203
|
"loading-obj": m
|
|
182
|
-
})]), t.showClose &&
|
|
204
|
+
})]), t.showClose && a("button", {
|
|
183
205
|
type: "button",
|
|
184
|
-
class: [
|
|
185
|
-
"aria-label":
|
|
206
|
+
class: [r.element("close-icon"), t.messageBox && f.element("close-icon")],
|
|
207
|
+
"aria-label": N("common.closeTarget", {
|
|
186
208
|
target: "对话框"
|
|
187
209
|
}),
|
|
188
|
-
onClick: (e) =>
|
|
210
|
+
onClick: (e) => b("cancel", e)
|
|
189
211
|
}, null)])]
|
|
190
|
-
})])]), [[
|
|
212
|
+
})])]), [[fe, W.value]])]
|
|
191
213
|
});
|
|
192
214
|
}
|
|
193
215
|
});
|
|
194
216
|
export {
|
|
195
|
-
|
|
217
|
+
Fe as default
|
|
196
218
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import { formInjectionKey as
|
|
4
|
-
import { isArray as
|
|
5
|
-
import { useSize as
|
|
6
|
-
import { getFormElementId as
|
|
7
|
-
import { getClassNameMixin as
|
|
8
|
-
const
|
|
1
|
+
import { defineComponent as K, ref as U, toRefs as D, computed as m, watch as G, onBeforeUnmount as H, reactive as E, provide as J } from "vue";
|
|
2
|
+
import Q from "../../node_modules/.pnpm/scroll-into-view-if-needed@3.1.0/node_modules/scroll-into-view-if-needed/dist/index.js";
|
|
3
|
+
import { formInjectionKey as X } from "./context.js";
|
|
4
|
+
import { isArray as Y, isFunction as S } from "../../_utils/is.js";
|
|
5
|
+
import { useSize as Z } from "../../_hooks/use-size.js";
|
|
6
|
+
import { getFormElementId as I } from "./utils.js";
|
|
7
|
+
import { getClassNameMixin as ee } from "../../_utils/config.js";
|
|
8
|
+
const de = K({
|
|
9
9
|
name: "Form",
|
|
10
10
|
props: {
|
|
11
11
|
/**
|
|
@@ -125,129 +125,141 @@ const se = q({
|
|
|
125
125
|
submitFailed: (l, n) => !0
|
|
126
126
|
},
|
|
127
127
|
setup(l, { emit: n }) {
|
|
128
|
-
const
|
|
129
|
-
id:
|
|
130
|
-
model:
|
|
131
|
-
layout:
|
|
132
|
-
disabled:
|
|
133
|
-
labelAlign:
|
|
134
|
-
labelColProps:
|
|
135
|
-
wrapperColProps:
|
|
136
|
-
labelColStyle:
|
|
137
|
-
wrapperColStyle:
|
|
138
|
-
size:
|
|
139
|
-
rules:
|
|
140
|
-
} = D(l), { mergedSize: F } =
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
const f = ee("form"), v = U(), {
|
|
129
|
+
id: j,
|
|
130
|
+
model: u,
|
|
131
|
+
layout: g,
|
|
132
|
+
disabled: C,
|
|
133
|
+
labelAlign: O,
|
|
134
|
+
labelColProps: T,
|
|
135
|
+
wrapperColProps: V,
|
|
136
|
+
labelColStyle: z,
|
|
137
|
+
wrapperColStyle: W,
|
|
138
|
+
size: x,
|
|
139
|
+
rules: L
|
|
140
|
+
} = D(l), { mergedSize: F } = Z(x), P = m(() => l.layout === "horizontal" && l.autoLabelWidth), a = [];
|
|
141
|
+
let d = 0;
|
|
142
|
+
G(u, () => {
|
|
143
|
+
d++;
|
|
144
|
+
}, { deep: !0, flush: "sync" }), H(() => {
|
|
145
|
+
d++;
|
|
146
|
+
});
|
|
147
|
+
const h = E({}), w = m(() => Math.max(0, ...Object.values(h))), A = (e) => {
|
|
148
|
+
e && e.field && !a.includes(e) && (d++, a.push(e));
|
|
149
|
+
}, B = (e) => {
|
|
143
150
|
if (e) {
|
|
144
151
|
const t = a.indexOf(e);
|
|
145
|
-
t > -1 && a.splice(t, 1);
|
|
152
|
+
t > -1 && (d++, a.splice(t, 1));
|
|
146
153
|
}
|
|
147
|
-
},
|
|
148
|
-
a.forEach((t) => {
|
|
154
|
+
}, R = (e) => {
|
|
155
|
+
d++, a.forEach((t) => {
|
|
149
156
|
e[t.field] && t.setField(e[t.field]);
|
|
150
157
|
});
|
|
151
|
-
},
|
|
152
|
-
t &&
|
|
153
|
-
},
|
|
154
|
-
e && delete
|
|
155
|
-
},
|
|
158
|
+
}, _ = (e, t) => {
|
|
159
|
+
t && h[t] !== e && (h[t] = e);
|
|
160
|
+
}, k = (e) => {
|
|
161
|
+
e && delete h[e];
|
|
162
|
+
}, M = (e) => {
|
|
163
|
+
d++;
|
|
156
164
|
const t = e ? [].concat(e) : [];
|
|
157
|
-
a.forEach((
|
|
158
|
-
(t.length === 0 || t.includes(
|
|
165
|
+
a.forEach((r) => {
|
|
166
|
+
(t.length === 0 || t.includes(r.field)) && r.resetField();
|
|
159
167
|
});
|
|
160
|
-
},
|
|
168
|
+
}, N = (e) => {
|
|
169
|
+
d++;
|
|
161
170
|
const t = e ? [].concat(e) : [];
|
|
162
|
-
a.forEach((
|
|
163
|
-
(t.length === 0 || t.includes(
|
|
171
|
+
a.forEach((r) => {
|
|
172
|
+
(t.length === 0 || t.includes(r.field)) && r.clearValidate();
|
|
164
173
|
});
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
r
|
|
174
|
+
}, y = (e, t) => {
|
|
175
|
+
var o;
|
|
176
|
+
const r = I(l.id, e), i = Array.from(((o = v.value) == null ? void 0 : o.querySelectorAll("[id]")) ?? []).find((s) => s.id === r);
|
|
177
|
+
i && Q(i, {
|
|
168
178
|
// @ts-ignore
|
|
169
179
|
behavior: "smooth",
|
|
170
180
|
block: "nearest",
|
|
171
181
|
scrollMode: "if-needed",
|
|
172
182
|
...t
|
|
173
183
|
});
|
|
174
|
-
},
|
|
184
|
+
}, b = (e) => {
|
|
175
185
|
const t = typeof l.scrollToFirstError == "object" ? l.scrollToFirstError : void 0;
|
|
176
|
-
|
|
177
|
-
},
|
|
186
|
+
y(e, t);
|
|
187
|
+
}, q = (e) => {
|
|
178
188
|
const t = [];
|
|
179
|
-
return a.forEach((
|
|
180
|
-
t.push(
|
|
181
|
-
}), Promise.all(t).then((
|
|
182
|
-
const r = {};
|
|
183
|
-
let i = !1;
|
|
184
|
-
return o.forEach((s) => {
|
|
185
|
-
s && (i = !0, r[s.field] = s);
|
|
186
|
-
}), i && l.scrollToFirstError && f(Object.keys(r)[0]), E(e) && e(i ? r : void 0), i ? r : void 0;
|
|
187
|
-
});
|
|
188
|
-
}, y = (e, t) => {
|
|
189
|
-
const o = [];
|
|
190
|
-
for (const r of a)
|
|
191
|
-
(Q(e) && e.includes(r.field) || e === r.field) && o.push(r.validate());
|
|
192
|
-
return Promise.all(o).then((r) => {
|
|
189
|
+
return a.forEach((r) => {
|
|
190
|
+
t.push(r.validate());
|
|
191
|
+
}), Promise.all(t).then((r) => {
|
|
193
192
|
const i = {};
|
|
193
|
+
let o = !1;
|
|
194
|
+
return r.forEach((s) => {
|
|
195
|
+
s && (o = !0, i[s.field] = s);
|
|
196
|
+
}), o && l.scrollToFirstError && b(Object.keys(i)[0]), S(e) && e(o ? i : void 0), o ? i : void 0;
|
|
197
|
+
});
|
|
198
|
+
}, p = (e, t) => {
|
|
199
|
+
const r = [];
|
|
200
|
+
for (const i of a)
|
|
201
|
+
(Y(e) && e.includes(i.field) || e === i.field) && r.push(i.validate());
|
|
202
|
+
return Promise.all(r).then((i) => {
|
|
203
|
+
const o = {};
|
|
194
204
|
let s = !1;
|
|
195
|
-
return
|
|
196
|
-
|
|
197
|
-
}), s && l.scrollToFirstError &&
|
|
205
|
+
return i.forEach((c) => {
|
|
206
|
+
c && (s = !0, o[c.field] = c);
|
|
207
|
+
}), s && l.scrollToFirstError && b(Object.keys(o)[0]), S(t) && t(s ? o : void 0), s ? o : void 0;
|
|
198
208
|
});
|
|
199
209
|
}, $ = (e) => {
|
|
200
|
-
const t = [];
|
|
201
|
-
a.forEach((
|
|
202
|
-
|
|
203
|
-
}), Promise.all(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
o
|
|
207
|
-
|
|
208
|
-
|
|
210
|
+
const t = ++d, r = [];
|
|
211
|
+
a.forEach((i) => {
|
|
212
|
+
r.push(i.validate());
|
|
213
|
+
}), Promise.all(r).then((i) => {
|
|
214
|
+
if (t !== d)
|
|
215
|
+
return;
|
|
216
|
+
const o = {};
|
|
217
|
+
let s = !1;
|
|
218
|
+
i.forEach((c) => {
|
|
219
|
+
c && (s = !0, o[c.field] = c);
|
|
220
|
+
}), s ? (l.scrollToFirstError && b(Object.keys(o)[0]), n("submitFailed", { values: u.value, errors: o }, e)) : n("submitSuccess", u.value, e), n("submit", { values: u.value, errors: s ? o : void 0 }, e);
|
|
209
221
|
});
|
|
210
222
|
};
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
id:
|
|
215
|
-
layout:
|
|
216
|
-
disabled:
|
|
217
|
-
labelAlign:
|
|
218
|
-
labelColProps:
|
|
219
|
-
wrapperColProps:
|
|
220
|
-
labelColStyle:
|
|
221
|
-
wrapperColStyle:
|
|
222
|
-
model:
|
|
223
|
+
return J(
|
|
224
|
+
X,
|
|
225
|
+
E({
|
|
226
|
+
id: j,
|
|
227
|
+
layout: g,
|
|
228
|
+
disabled: C,
|
|
229
|
+
labelAlign: O,
|
|
230
|
+
labelColProps: T,
|
|
231
|
+
wrapperColProps: V,
|
|
232
|
+
labelColStyle: z,
|
|
233
|
+
wrapperColStyle: W,
|
|
234
|
+
model: u,
|
|
223
235
|
size: F,
|
|
224
|
-
rules:
|
|
236
|
+
rules: L,
|
|
225
237
|
fields: a,
|
|
226
|
-
addField:
|
|
227
|
-
removeField:
|
|
228
|
-
validateField:
|
|
229
|
-
setLabelWidth:
|
|
230
|
-
removeLabelWidth:
|
|
231
|
-
maxLabelWidth:
|
|
232
|
-
autoLabelWidth:
|
|
238
|
+
addField: A,
|
|
239
|
+
removeField: B,
|
|
240
|
+
validateField: p,
|
|
241
|
+
setLabelWidth: _,
|
|
242
|
+
removeLabelWidth: k,
|
|
243
|
+
maxLabelWidth: w,
|
|
244
|
+
autoLabelWidth: P
|
|
233
245
|
})
|
|
234
246
|
), {
|
|
235
|
-
cls:
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
cls: m(() => [
|
|
248
|
+
f.block,
|
|
249
|
+
f.modifier(`layout-${l.layout}`),
|
|
250
|
+
f.modifier(`size-${F.value}`),
|
|
239
251
|
{
|
|
240
|
-
[
|
|
252
|
+
[f.modifier("auto-label-width")]: l.autoLabelWidth
|
|
241
253
|
}
|
|
242
254
|
]),
|
|
243
|
-
formRef:
|
|
255
|
+
formRef: v,
|
|
244
256
|
handleSubmit: $,
|
|
245
|
-
innerValidate:
|
|
246
|
-
innerValidateField:
|
|
247
|
-
innerResetFields:
|
|
248
|
-
innerClearValidate:
|
|
249
|
-
innerSetFields:
|
|
250
|
-
innerScrollToField:
|
|
257
|
+
innerValidate: q,
|
|
258
|
+
innerValidateField: p,
|
|
259
|
+
innerResetFields: M,
|
|
260
|
+
innerClearValidate: N,
|
|
261
|
+
innerSetFields: R,
|
|
262
|
+
innerScrollToField: y
|
|
251
263
|
};
|
|
252
264
|
},
|
|
253
265
|
methods: {
|
|
@@ -313,5 +325,5 @@ const se = q({
|
|
|
313
325
|
}
|
|
314
326
|
});
|
|
315
327
|
export {
|
|
316
|
-
|
|
328
|
+
de as default
|
|
317
329
|
};
|