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