@mcistudio/unoui-vue 1.0.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 (187) hide show
  1. package/README.md +95 -0
  2. package/dist/alert/Alert.vue.d.ts +67 -0
  3. package/dist/alert/index.d.ts +40 -0
  4. package/dist/alert/index.js +2 -0
  5. package/dist/attrs.d.ts +11 -0
  6. package/dist/attrs.js +16 -0
  7. package/dist/attrs.js.map +1 -0
  8. package/dist/badge/Badge.vue.d.ts +57 -0
  9. package/dist/badge/BadgeRibbon.vue.d.ts +34 -0
  10. package/dist/badge/index.d.ts +42 -0
  11. package/dist/badge/index.js +2 -0
  12. package/dist/build.d.ts +2 -0
  13. package/dist/button/Button.vue.d.ts +46 -0
  14. package/dist/button/ButtonGroup.vue.d.ts +13 -0
  15. package/dist/button/index.d.ts +13 -0
  16. package/dist/button/index.js +2 -0
  17. package/dist/checkbox/Checkbox.vue.d.ts +47 -0
  18. package/dist/checkbox/CheckboxGroup.vue.d.ts +38 -0
  19. package/dist/checkbox/index.d.ts +30 -0
  20. package/dist/checkbox/index.js +2 -0
  21. package/dist/chunks/Progress-BL4KZ3HE.js +271 -0
  22. package/dist/chunks/Progress-BL4KZ3HE.js.map +1 -0
  23. package/dist/chunks/Skeleton-ohStUD4M.js +153 -0
  24. package/dist/chunks/Skeleton-ohStUD4M.js.map +1 -0
  25. package/dist/chunks/Table-DhXmuKQd.js +330 -0
  26. package/dist/chunks/Table-DhXmuKQd.js.map +1 -0
  27. package/dist/chunks/_plugin-vue_export-helper-B3ysoDQm.js +8 -0
  28. package/dist/chunks/alert-CczW_DKs.js +190 -0
  29. package/dist/chunks/alert-CczW_DKs.js.map +1 -0
  30. package/dist/chunks/badge-BHOZeImh.js +287 -0
  31. package/dist/chunks/badge-BHOZeImh.js.map +1 -0
  32. package/dist/chunks/button-pDObrN_X.js +168 -0
  33. package/dist/chunks/button-pDObrN_X.js.map +1 -0
  34. package/dist/chunks/checkbox-9_0oR4kg.js +260 -0
  35. package/dist/chunks/checkbox-9_0oR4kg.js.map +1 -0
  36. package/dist/chunks/colorpicker-CcizUCQv.js +594 -0
  37. package/dist/chunks/colorpicker-CcizUCQv.js.map +1 -0
  38. package/dist/chunks/datepicker-Cy808x7X.js +1414 -0
  39. package/dist/chunks/datepicker-Cy808x7X.js.map +1 -0
  40. package/dist/chunks/drawer-C3JZ28Xo.js +193 -0
  41. package/dist/chunks/drawer-C3JZ28Xo.js.map +1 -0
  42. package/dist/chunks/dropdown-0l967g7D.js +329 -0
  43. package/dist/chunks/dropdown-0l967g7D.js.map +1 -0
  44. package/dist/chunks/form-Qeqkd-HH.js +642 -0
  45. package/dist/chunks/form-Qeqkd-HH.js.map +1 -0
  46. package/dist/chunks/input-BDOXVCrK.js +1281 -0
  47. package/dist/chunks/input-BDOXVCrK.js.map +1 -0
  48. package/dist/chunks/inputOtp-Dyxj9lNj.js +261 -0
  49. package/dist/chunks/inputOtp-Dyxj9lNj.js.map +1 -0
  50. package/dist/chunks/message-xPfuG0EX.js +107 -0
  51. package/dist/chunks/message-xPfuG0EX.js.map +1 -0
  52. package/dist/chunks/millercolumns-Dp3fBrq6.js +426 -0
  53. package/dist/chunks/millercolumns-Dp3fBrq6.js.map +1 -0
  54. package/dist/chunks/modal-D6l1iIvE.js +81 -0
  55. package/dist/chunks/modal-D6l1iIvE.js.map +1 -0
  56. package/dist/chunks/pagination-Bc583AQX.js +265 -0
  57. package/dist/chunks/pagination-Bc583AQX.js.map +1 -0
  58. package/dist/chunks/popconfirm-D6lUfSxG.js +343 -0
  59. package/dist/chunks/popconfirm-D6lUfSxG.js.map +1 -0
  60. package/dist/chunks/qrcode-B0t_pZna.js +1099 -0
  61. package/dist/chunks/qrcode-B0t_pZna.js.map +1 -0
  62. package/dist/chunks/radio-DnYm59xH.js +477 -0
  63. package/dist/chunks/radio-DnYm59xH.js.map +1 -0
  64. package/dist/chunks/rate-0sme__Kb.js +309 -0
  65. package/dist/chunks/rate-0sme__Kb.js.map +1 -0
  66. package/dist/chunks/select-ChTfQM5u.js +417 -0
  67. package/dist/chunks/select-ChTfQM5u.js.map +1 -0
  68. package/dist/chunks/slider-C-W5GzTP.js +724 -0
  69. package/dist/chunks/slider-C-W5GzTP.js.map +1 -0
  70. package/dist/chunks/splitter-CgfiXY65.js +524 -0
  71. package/dist/chunks/splitter-CgfiXY65.js.map +1 -0
  72. package/dist/chunks/switch-BULGbODP.js +327 -0
  73. package/dist/chunks/switch-BULGbODP.js.map +1 -0
  74. package/dist/chunks/tab-Dxfg1_To.js +663 -0
  75. package/dist/chunks/tab-Dxfg1_To.js.map +1 -0
  76. package/dist/chunks/tag-BYmNsrZC.js +167 -0
  77. package/dist/chunks/tag-BYmNsrZC.js.map +1 -0
  78. package/dist/chunks/timepicker-DsGIdcf8.js +1059 -0
  79. package/dist/chunks/timepicker-DsGIdcf8.js.map +1 -0
  80. package/dist/chunks/tooltip-DMhiAqto.js +242 -0
  81. package/dist/chunks/tooltip-DMhiAqto.js.map +1 -0
  82. package/dist/colorpicker/ColorPicker.vue.d.ts +30 -0
  83. package/dist/colorpicker/color.d.ts +56 -0
  84. package/dist/colorpicker/color.js +99 -0
  85. package/dist/colorpicker/color.js.map +1 -0
  86. package/dist/colorpicker/index.d.ts +12 -0
  87. package/dist/colorpicker/index.js +2 -0
  88. package/dist/config.d.ts +55 -0
  89. package/dist/config.js +260 -0
  90. package/dist/config.js.map +1 -0
  91. package/dist/datepicker/DatePicker.vue.d.ts +82 -0
  92. package/dist/datepicker/RangePicker.vue.d.ts +87 -0
  93. package/dist/datepicker/index.d.ts +59 -0
  94. package/dist/datepicker/index.js +2 -0
  95. package/dist/drawer/Drawer.vue.d.ts +86 -0
  96. package/dist/drawer/index.d.ts +23 -0
  97. package/dist/drawer/index.js +2 -0
  98. package/dist/dropdown/Dropdown.vue.d.ts +118 -0
  99. package/dist/dropdown/index.d.ts +2 -0
  100. package/dist/dropdown/index.js +2 -0
  101. package/dist/form/Form.vue.d.ts +170 -0
  102. package/dist/form/FormItem.vue.d.ts +83 -0
  103. package/dist/form/index.d.ts +176 -0
  104. package/dist/form/index.js +2 -0
  105. package/dist/index.d.ts +31 -0
  106. package/dist/index.js +32 -0
  107. package/dist/input/Autocomplete.vue.d.ts +121 -0
  108. package/dist/input/Input.vue.d.ts +142 -0
  109. package/dist/input/InputI18n.vue.d.ts +80 -0
  110. package/dist/input/InputTag.vue.d.ts +114 -0
  111. package/dist/input/index.d.ts +41 -0
  112. package/dist/input/index.js +2 -0
  113. package/dist/inputOtp/InputOtp.vue.d.ts +60 -0
  114. package/dist/inputOtp/index.d.ts +21 -0
  115. package/dist/inputOtp/index.js +2 -0
  116. package/dist/message/MessageContainer.vue.d.ts +11 -0
  117. package/dist/message/index.d.ts +20 -0
  118. package/dist/message/index.js +2 -0
  119. package/dist/message/types.d.ts +25 -0
  120. package/dist/millercolumns/MillerColumns.vue.d.ts +88 -0
  121. package/dist/millercolumns/index.d.ts +39 -0
  122. package/dist/millercolumns/index.js +2 -0
  123. package/dist/modal/Modal.vue.d.ts +54 -0
  124. package/dist/modal/index.d.ts +2 -0
  125. package/dist/modal/index.js +2 -0
  126. package/dist/pagination/Pagination.vue.d.ts +70 -0
  127. package/dist/pagination/index.d.ts +12 -0
  128. package/dist/pagination/index.js +2 -0
  129. package/dist/popconfirm/Popconfirm.vue.d.ts +104 -0
  130. package/dist/popconfirm/index.d.ts +36 -0
  131. package/dist/popconfirm/index.js +2 -0
  132. package/dist/progress/Progress.vue.d.ts +64 -0
  133. package/dist/progress/index.d.ts +26 -0
  134. package/dist/progress/index.js +2 -0
  135. package/dist/qrcode/QRCode.vue.d.ts +87 -0
  136. package/dist/qrcode/index.d.ts +43 -0
  137. package/dist/qrcode/index.js +2 -0
  138. package/dist/qrcode/qr.d.ts +51 -0
  139. package/dist/qrcode/qrcodegen.d.ts +94 -0
  140. package/dist/radio/Radio.vue.d.ts +52 -0
  141. package/dist/radio/RadioGroup.vue.d.ts +44 -0
  142. package/dist/radio/index.d.ts +55 -0
  143. package/dist/radio/index.js +2 -0
  144. package/dist/rate/Rate.vue.d.ts +100 -0
  145. package/dist/rate/index.d.ts +38 -0
  146. package/dist/rate/index.js +2 -0
  147. package/dist/select/Select.vue.d.ts +129 -0
  148. package/dist/select/index.d.ts +33 -0
  149. package/dist/select/index.js +2 -0
  150. package/dist/skeleton/Skeleton.vue.d.ts +31 -0
  151. package/dist/skeleton/index.d.ts +2 -0
  152. package/dist/skeleton/index.js +2 -0
  153. package/dist/slider/Slider.vue.d.ts +81 -0
  154. package/dist/slider/index.d.ts +61 -0
  155. package/dist/slider/index.js +2 -0
  156. package/dist/splitter/Splitter.vue.d.ts +63 -0
  157. package/dist/splitter/SplitterPanel.vue.d.ts +53 -0
  158. package/dist/splitter/index.d.ts +39 -0
  159. package/dist/splitter/index.js +2 -0
  160. package/dist/style.css +2 -0
  161. package/dist/switch/Switch.vue.d.ts +97 -0
  162. package/dist/switch/index.d.ts +31 -0
  163. package/dist/switch/index.js +2 -0
  164. package/dist/tab/TabPane.vue.d.ts +32 -0
  165. package/dist/tab/Tabs.vue.d.ts +87 -0
  166. package/dist/tab/index.d.ts +78 -0
  167. package/dist/tab/index.js +2 -0
  168. package/dist/table/Table.vue.d.ts +96 -0
  169. package/dist/table/index.d.ts +3 -0
  170. package/dist/table/index.js +2 -0
  171. package/dist/table/types.d.ts +35 -0
  172. package/dist/table/types.js +0 -0
  173. package/dist/tag/Tag.vue.d.ts +46 -0
  174. package/dist/tag/index.d.ts +11 -0
  175. package/dist/tag/index.js +2 -0
  176. package/dist/timepicker/TimePicker.vue.d.ts +92 -0
  177. package/dist/timepicker/TimeRangePicker.vue.d.ts +90 -0
  178. package/dist/timepicker/index.d.ts +39 -0
  179. package/dist/timepicker/index.js +2 -0
  180. package/dist/tooltip/Tooltip.vue.d.ts +79 -0
  181. package/dist/tooltip/index.d.ts +14 -0
  182. package/dist/tooltip/index.js +2 -0
  183. package/dist/uno.d.ts +32 -0
  184. package/dist/uno.js +83 -0
  185. package/dist/uno.js.map +1 -0
  186. package/dist/utils/DnD.d.ts +38 -0
  187. package/package.json +115 -0
@@ -0,0 +1,642 @@
1
+ import { getUiExposeAttrs as e } from "../attrs.js";
2
+ import { r as t } from "./tooltip-DMhiAqto.js";
3
+ import { cva as n } from "class-variance-authority";
4
+ import { cloneVNode as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, getCurrentInstance as d, inject as f, mergeProps as ee, nextTick as te, normalizeClass as p, onBeforeUnmount as ne, onMounted as m, openBlock as h, provide as re, ref as g, renderSlot as _, shallowRef as v, toDisplayString as y, toRaw as b, toRef as x, unref as S, useAttrs as C, useSlots as w, watch as ie, withCtx as T } from "vue";
5
+ import { clsx as E } from "clsx";
6
+ import D from "async-validator";
7
+ //#region src/form/Form.vue?vue&type=script&setup=true&lang.ts
8
+ var O = ["data-disabled"], k = /* @__PURE__ */ u({
9
+ inheritAttrs: !1,
10
+ __name: "Form",
11
+ props: {
12
+ model: { default: void 0 },
13
+ rules: { default: void 0 },
14
+ inline: {
15
+ type: Boolean,
16
+ default: !1
17
+ },
18
+ labelPosition: { default: "right" },
19
+ labelWidth: { default: "96px" },
20
+ reserveLabelSpace: {
21
+ type: Boolean,
22
+ default: !0
23
+ },
24
+ itemGap: { default: "16px" },
25
+ size: { default: "md" },
26
+ disabled: {
27
+ type: Boolean,
28
+ default: !1
29
+ },
30
+ showMessage: {
31
+ type: Boolean,
32
+ default: !0
33
+ },
34
+ validateTrigger: { default: () => ["change", "blur"] },
35
+ validateOnRuleChange: {
36
+ type: Boolean,
37
+ default: !0
38
+ },
39
+ requireAsteriskPosition: { default: "left" },
40
+ hideRequiredAsterisk: {
41
+ type: Boolean,
42
+ default: !1
43
+ }
44
+ },
45
+ emits: [
46
+ "validate",
47
+ "submit",
48
+ "reset"
49
+ ],
50
+ setup(t, { expose: n, emit: r }) {
51
+ let a = t, s = r, c = C(), l = v([]), u = i(() => E(c.class, V({
52
+ inline: a.inline,
53
+ size: a.size,
54
+ disabled: a.disabled
55
+ }))), d = i(() => ({
56
+ ...c.style,
57
+ "--ui-form-item-gap": typeof a.itemGap == "number" ? `${a.itemGap}px` : a.itemGap
58
+ }));
59
+ function f() {
60
+ return a.labelPosition === "top" ? "auto" : typeof a.labelWidth == "number" ? `${a.labelWidth}px` : a.labelWidth;
61
+ }
62
+ function p(e, t) {
63
+ let n = F(e);
64
+ return [...R(n ? a.rules?.[n] : void 0), ...R(t)];
65
+ }
66
+ function ne(e) {
67
+ return I(a.model, e);
68
+ }
69
+ function m(e, t) {
70
+ L(a.model, e, t);
71
+ }
72
+ function y(e) {
73
+ if (!e) return [...l.value];
74
+ let t = Array.isArray(e) && typeof e[0] != "string" ? e : [e], n = new Set(t.map((e) => F(e)));
75
+ return l.value.filter((e) => e.prop && n.has(F(e.prop)));
76
+ }
77
+ async function b(e, t) {
78
+ let n = y(e), r = {}, i = !0;
79
+ for (let e of n) {
80
+ let t = await e.validate(), n = F(e.prop);
81
+ !t.valid && n && (i = !1, r[n] = t.errors ?? []);
82
+ }
83
+ return await t?.(i, i ? void 0 : r), i;
84
+ }
85
+ function w(e) {
86
+ y(e).forEach((e) => e.clearValidate());
87
+ }
88
+ function T(e) {
89
+ y(e).forEach((e) => e.resetField());
90
+ }
91
+ function D(e) {
92
+ l.value = [...l.value, e];
93
+ }
94
+ function k(e) {
95
+ l.value = l.value.filter((t) => t !== e);
96
+ }
97
+ function A(e, t, n) {
98
+ s("validate", e, t, n);
99
+ }
100
+ function ae(e) {
101
+ s("submit", e);
102
+ }
103
+ function oe(e) {
104
+ T(), s("reset", e);
105
+ }
106
+ return ie(() => a.rules, () => {
107
+ a.validateOnRuleChange && te(() => b());
108
+ }, { deep: !0 }), re(M, {
109
+ get model() {
110
+ return a.model;
111
+ },
112
+ get rules() {
113
+ return a.rules;
114
+ },
115
+ size: x(a, "size"),
116
+ disabled: x(a, "disabled"),
117
+ inline: x(a, "inline"),
118
+ labelPosition: x(a, "labelPosition"),
119
+ labelWidth: i(f),
120
+ reserveLabelSpace: x(a, "reserveLabelSpace"),
121
+ itemGap: x(a, "itemGap"),
122
+ showMessage: x(a, "showMessage"),
123
+ validateTrigger: x(a, "validateTrigger"),
124
+ requireAsteriskPosition: x(a, "requireAsteriskPosition"),
125
+ hideRequiredAsterisk: x(a, "hideRequiredAsterisk"),
126
+ validateOnRuleChange: x(a, "validateOnRuleChange"),
127
+ registerField: D,
128
+ unregisterField: k,
129
+ getFieldRules: p,
130
+ getFieldValue: ne,
131
+ setFieldValue: m,
132
+ validateField: b,
133
+ clearValidate: w,
134
+ resetFields: T,
135
+ emitValidate: A
136
+ }), n({
137
+ validate: (e) => b(void 0, e),
138
+ validateField: b,
139
+ resetFields: T,
140
+ clearValidate: w,
141
+ fields: l,
142
+ defaultValidateMessages: g(B)
143
+ }), (n, r) => (h(), o("form", ee(S(e)(S(c)), {
144
+ class: u.value,
145
+ style: d.value,
146
+ "data-disabled": t.disabled || void 0,
147
+ onSubmit: ae,
148
+ onReset: oe
149
+ }), [_(n.$slots, "default")], 16, O));
150
+ }
151
+ }), A = ["data-status"], ae = ["id", "for"], oe = { class: "min-w-0 whitespace-normal break-words text-inherit" }, se = ["aria-label"], ce = ["id", "aria-labelledby"], j = /* @__PURE__ */ u({
152
+ inheritAttrs: !1,
153
+ __name: "FormItem",
154
+ props: {
155
+ prop: { default: void 0 },
156
+ label: { default: "" },
157
+ info: { default: "" },
158
+ rules: { default: void 0 },
159
+ required: {
160
+ type: Boolean,
161
+ default: void 0
162
+ },
163
+ error: { default: "" },
164
+ validateStatus: { default: "" },
165
+ showMessage: {
166
+ type: Boolean,
167
+ default: void 0
168
+ },
169
+ validateTrigger: { default: void 0 },
170
+ labelWidth: { default: void 0 },
171
+ reserveLabelSpace: {
172
+ type: Boolean,
173
+ default: void 0
174
+ },
175
+ labelPosition: { default: void 0 },
176
+ size: { default: void 0 }
177
+ },
178
+ setup(n, { expose: re }) {
179
+ let x = n, D = C(), O = w(), k = d(), j = f(M, void 0), N = g(""), P = g(""), I = v(), L = g(!1), R = i(() => x.size ?? j?.size.value ?? "md"), B = i(() => x.labelPosition ?? j?.labelPosition.value ?? "right"), V = i(() => {
180
+ if (B.value === "top") return "auto";
181
+ let e = x.labelWidth ?? j?.labelWidth.value ?? "96px";
182
+ return typeof e == "number" ? `${e}px` : e;
183
+ }), le = i(() => x.showMessage ?? j?.showMessage.value ?? !0), ue = i(() => {
184
+ let e = x.validateTrigger ?? j?.validateTrigger.value ?? ["change", "blur"];
185
+ return Array.isArray(e) ? e : [e];
186
+ }), K = i(() => j?.getFieldRules(x.prop, x.rules) ?? []), de = i(() => x.required ?? K.value.some((e) => e.required)), fe = i(() => de.value && !(j?.hideRequiredAsterisk.value ?? !1)), pe = i(() => {
187
+ let e = k?.vnode.props;
188
+ return !!e && ("reserveLabelSpace" in e || "reserve-label-space" in e);
189
+ }), me = i(() => pe.value ? x.reserveLabelSpace : j?.reserveLabelSpace.value ?? !0), he = i(() => !x.label && me.value && (B.value !== "top" || (j?.inline.value ?? !1))), q = i(() => x.validateStatus || (x.error ? "error" : N.value)), J = i(() => x.error || P.value), ge = i(() => x.label ? `ui-form-item-${F(x.prop) ?? Math.random().toString(36).slice(2)}-label` : void 0), _e = i(() => x.prop ? `ui-form-item-${F(x.prop)}-content` : void 0), ve = i(() => E(D.class, H({
190
+ inline: j?.inline.value ?? !1,
191
+ labelPosition: B.value,
192
+ size: R.value,
193
+ error: q.value === "error"
194
+ }))), ye = i(() => ({
195
+ ...D.style,
196
+ "--ui-form-item-gap": typeof j?.itemGap.value == "number" ? `${j.itemGap.value}px` : j?.itemGap.value,
197
+ "--ui-form-label-width": V.value
198
+ })), be = i(() => U({
199
+ labelPosition: B.value,
200
+ size: R.value,
201
+ required: fe.value,
202
+ requiredPosition: j?.requireAsteriskPosition.value ?? "left"
203
+ })), xe = i(() => E("ml-1 inline-flex shrink-0 items-center", B.value === "top" && "h-[1lh] self-start")), Se = i(() => B.value === "top" && "h-[1lh] shrink-0"), Ce = i(() => E(W({
204
+ labelPosition: B.value,
205
+ size: R.value
206
+ }), !x.label && B.value !== "top" && (he.value ? "col-start-2" : "col-span-full"))), we = i(() => G({ status: q.value }));
207
+ function Te(e) {
208
+ return typeof e == "object" && !!e;
209
+ }
210
+ function Y(e) {
211
+ let t = b(e);
212
+ if (Array.isArray(t)) return t.map((e) => Y(e));
213
+ if (!Te(t)) return t;
214
+ if (t instanceof Date) return new Date(t);
215
+ if (t instanceof RegExp) {
216
+ let e = new RegExp(t.source, t.flags);
217
+ return e.lastIndex = t.lastIndex, e;
218
+ }
219
+ if (t instanceof ArrayBuffer || ArrayBuffer.isView(t)) return structuredClone(t);
220
+ if (t instanceof Map) return new Map(Array.from(t.entries(), ([e, t]) => [Y(e), Y(t)]));
221
+ if (t instanceof Set) return new Set(Array.from(t.values(), (e) => Y(e)));
222
+ let n = Object.getPrototypeOf(t);
223
+ if (n !== Object.prototype && n !== null) try {
224
+ return structuredClone(t);
225
+ } catch {
226
+ return t;
227
+ }
228
+ let r = {};
229
+ return Reflect.ownKeys(t).forEach((e) => {
230
+ r[e] = Y(t[e]);
231
+ }), r;
232
+ }
233
+ function Ee(e, t) {
234
+ return !t || !e ? !0 : Array.isArray(e) ? e.includes(t) : e === t;
235
+ }
236
+ async function X(e, t = {}) {
237
+ let n = K.value.filter((t) => Ee(t.trigger, e));
238
+ if (!x.prop || K.value.length === 0) return N.value = "", P.value = "", { valid: !0 };
239
+ if (n.length === 0) return { valid: !0 };
240
+ N.value = "validating";
241
+ let r = await z(x.prop, j?.getFieldValue(x.prop), n, t);
242
+ return N.value = r.valid ? "success" : "error", P.value = r.errors?.[0]?.message ?? "", j?.emitValidate(x.prop, r.valid, P.value), r;
243
+ }
244
+ let Z = /* @__PURE__ */ new Set();
245
+ function Q(e) {
246
+ !ue.value.includes(e) || Z.has(e) || (Z.add(e), te(() => {
247
+ Z.delete(e), X(e);
248
+ }));
249
+ }
250
+ function De(e) {
251
+ return typeof e.type == "symbol" ? e : r(e, typeof e.type == "string" ? {
252
+ onInput: () => Q("change"),
253
+ onChange: () => Q("change"),
254
+ onBlur: () => Q("blur")
255
+ } : {
256
+ "onUpdate:modelValue": () => Q("change"),
257
+ onBlur: () => Q("blur")
258
+ }, !0);
259
+ }
260
+ let Oe = u({
261
+ name: "UnoUIFormItemControl",
262
+ setup() {
263
+ return () => O.default?.({
264
+ validate: X,
265
+ validateState: q.value,
266
+ validateMessage: J.value
267
+ })?.map(De);
268
+ }
269
+ });
270
+ function ke() {
271
+ x.prop && j && L.value && j.setFieldValue(x.prop, Y(I.value)), $();
272
+ }
273
+ function $() {
274
+ N.value = "", P.value = "";
275
+ }
276
+ let Ae = {
277
+ prop: x.prop,
278
+ validateState: N,
279
+ validateMessage: P,
280
+ validate: X,
281
+ resetField: ke,
282
+ clearValidate: $,
283
+ isRequired: de
284
+ };
285
+ return ie(() => x.error, (e) => {
286
+ e && (N.value = "error", P.value = e);
287
+ }, { immediate: !0 }), m(() => {
288
+ x.prop && j && (I.value = Y(j.getFieldValue(x.prop)), L.value = !0, j.registerField(Ae));
289
+ }), ne(() => {
290
+ j?.unregisterField(Ae);
291
+ }), re({
292
+ validate: X,
293
+ resetField: ke,
294
+ clearValidate: $,
295
+ validateState: N,
296
+ validateMessage: P
297
+ }), (r, i) => (h(), o("div", ee(S(e)(S(D)), {
298
+ class: ve.value,
299
+ style: ye.value,
300
+ "data-status": q.value || void 0
301
+ }), [_(r.$slots, "label", { label: n.label }, () => [n.label ? (h(), o("label", {
302
+ key: 0,
303
+ id: ge.value,
304
+ for: _e.value,
305
+ class: p(be.value)
306
+ }, [s("span", oe, y(n.label), 1), n.info || r.$slots.info ? (h(), o("span", {
307
+ key: 0,
308
+ class: p(xe.value),
309
+ "data-ui-form-item-info-wrapper": "true"
310
+ }, [l(S(t), {
311
+ title: n.info,
312
+ trigger: ["hover", "focus"],
313
+ "mouse-enter-delay": 0
314
+ }, {
315
+ title: T(() => [_(r.$slots, "info", {}, () => [c(y(n.info), 1)])]),
316
+ default: T(() => [s("span", {
317
+ class: "i-lucide:info size-3.5 cursor-help rounded-sm text-tertiary outline-none transition-colors hover:text-secondary focus-visible:text-secondary focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1",
318
+ "data-ui-form-item-info": "true",
319
+ role: "img",
320
+ tabindex: "0",
321
+ "aria-label": n.info || `${n.label}说明`
322
+ }, null, 8, se)]),
323
+ _: 3
324
+ }, 8, ["title"])], 2)) : a("", !0)], 10, ae)) : he.value ? (h(), o("div", {
325
+ key: 1,
326
+ class: p(Se.value),
327
+ "aria-hidden": "true"
328
+ }, null, 2)) : a("", !0)]), s("div", {
329
+ id: _e.value,
330
+ class: p(Ce.value),
331
+ "aria-labelledby": ge.value
332
+ }, [l(S(Oe)), le.value && J.value ? _(r.$slots, "error", {
333
+ key: 0,
334
+ error: J.value,
335
+ validateState: q.value
336
+ }, () => [s("div", { class: p(we.value) }, y(J.value), 3)]) : a("", !0)], 10, ce)], 16, A));
337
+ }
338
+ }), M = Symbol("ui-form-context"), N = {
339
+ email: {
340
+ pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
341
+ message: "请输入正确的邮箱地址"
342
+ },
343
+ phoneCN: {
344
+ pattern: /^1[3-9]\d{9}$/,
345
+ message: "请输入正确的手机号"
346
+ },
347
+ url: {
348
+ pattern: /^(https?:\/\/)?([\w-]+\.)+[\w-]+(\/[\w./?%&=+#:-]*)?$/i,
349
+ message: "请输入正确的 URL"
350
+ },
351
+ ipv4: {
352
+ pattern: /^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/,
353
+ message: "请输入正确的 IPv4 地址"
354
+ },
355
+ idCardCN: {
356
+ pattern: /(^\d{15}$)|(^\d{17}[\dXx]$)/,
357
+ message: "请输入正确的身份证号码"
358
+ },
359
+ postalCodeCN: {
360
+ pattern: /^\d{6}$/,
361
+ message: "请输入正确的邮政编码"
362
+ },
363
+ integer: {
364
+ pattern: /^-?\d+$/,
365
+ message: "请输入整数"
366
+ },
367
+ positiveInteger: {
368
+ pattern: /^[1-9]\d*$/,
369
+ message: "请输入正整数"
370
+ },
371
+ number: {
372
+ pattern: /^-?(\d+|\d+\.\d+|\.\d+)$/,
373
+ message: "请输入数字"
374
+ },
375
+ decimal2: {
376
+ pattern: /^-?\d+(\.\d{1,2})?$/,
377
+ message: "最多保留两位小数"
378
+ },
379
+ alpha: {
380
+ pattern: /^[A-Za-z]+$/,
381
+ message: "只能输入英文字母"
382
+ },
383
+ alphaNum: {
384
+ pattern: /^[A-Za-z0-9]+$/,
385
+ message: "只能输入英文字母和数字"
386
+ },
387
+ projectId: {
388
+ pattern: /^[A-Za-z0-9_-]+$/,
389
+ message: "只能输入字母、数字、下划线和短横线"
390
+ },
391
+ slug: {
392
+ pattern: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,
393
+ message: "请输入小写字母、数字和短横线组成的标识"
394
+ },
395
+ hexColor: {
396
+ pattern: /^#(?:[0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/,
397
+ message: "请输入正确的十六进制颜色"
398
+ },
399
+ chinese: {
400
+ pattern: /^[\u4e00-\u9fa5]+$/,
401
+ message: "只能输入中文"
402
+ },
403
+ password: {
404
+ pattern: /^(?=.*[A-Za-z])(?=.*\d).{8,32}$/,
405
+ message: "密码需包含字母和数字,长度 8-32 位"
406
+ }
407
+ };
408
+ function P(e, t = {}) {
409
+ let n = N[e];
410
+ return {
411
+ pattern: n.pattern,
412
+ message: n.message,
413
+ ...t
414
+ };
415
+ }
416
+ function F(e) {
417
+ return Array.isArray(e) ? e.join(".") : e;
418
+ }
419
+ function I(e, t) {
420
+ if (!(!e || !t)) return (Array.isArray(t) ? t : String(t).split(".")).reduce((e, t) => typeof e == "object" && e ? e[t] : void 0, e);
421
+ }
422
+ function L(e, t, n) {
423
+ if (!e || !t) return;
424
+ let r = Array.isArray(t) ? t : String(t).split("."), i = r.at(-1);
425
+ if (!i) return;
426
+ let a = e;
427
+ for (let e of r.slice(0, -1)) {
428
+ let t = a[e];
429
+ (typeof t != "object" || !t) && (a[e] = {}), a = a[e];
430
+ }
431
+ a[i] = n;
432
+ }
433
+ function R(e) {
434
+ return e ? (Array.isArray(e) ? e : [e]).map((e) => {
435
+ if (!e.preset) return { ...e };
436
+ let t = N[e.preset];
437
+ return {
438
+ pattern: t.pattern,
439
+ message: t.message,
440
+ ...e,
441
+ preset: void 0
442
+ };
443
+ }) : [];
444
+ }
445
+ async function z(e, t, n, r = {}) {
446
+ let i = F(e);
447
+ if (!i || n.length === 0) return { valid: !0 };
448
+ let a = new D({ [i]: n.map(({ trigger: e, preset: t, ...n }) => n) });
449
+ try {
450
+ return await a.validate({ [i]: t }, r), { valid: !0 };
451
+ } catch (e) {
452
+ let t = e;
453
+ return {
454
+ valid: !1,
455
+ errors: t.errors ?? t.fields?.[i] ?? []
456
+ };
457
+ }
458
+ }
459
+ var B = {
460
+ default: "字段验证错误",
461
+ required: "%s 为必填项",
462
+ types: {
463
+ email: "%s 不是有效的邮箱地址",
464
+ url: "%s 不是有效的 URL",
465
+ number: "%s 不是有效的数字"
466
+ },
467
+ string: {
468
+ min: "%s 至少 %s 个字符",
469
+ max: "%s 最多 %s 个字符",
470
+ range: "%s 长度需在 %s 到 %s 个字符之间"
471
+ },
472
+ number: {
473
+ min: "%s 不能小于 %s",
474
+ max: "%s 不能大于 %s",
475
+ range: "%s 需在 %s 到 %s 之间"
476
+ }
477
+ }, V = n("ui-form text-primary", {
478
+ variants: {
479
+ inline: {
480
+ true: "flex flex-wrap items-start gap-x-4",
481
+ false: ""
482
+ },
483
+ size: {
484
+ sm: "text-sm",
485
+ md: "text-sm",
486
+ lg: "text-base"
487
+ },
488
+ disabled: {
489
+ true: "opacity-70",
490
+ false: ""
491
+ }
492
+ },
493
+ defaultVariants: {
494
+ inline: !1,
495
+ size: "md",
496
+ disabled: !1
497
+ }
498
+ }), H = n("ui-form-item mb-[var(--ui-form-item-gap,16px)] min-w-0 self-start content-start last:mb-0", {
499
+ variants: {
500
+ inline: {
501
+ true: "inline-flex w-auto items-start",
502
+ false: "grid w-full"
503
+ },
504
+ labelPosition: {
505
+ left: "grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3",
506
+ right: "grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3",
507
+ top: "gap-1"
508
+ },
509
+ size: {
510
+ sm: "",
511
+ md: "",
512
+ lg: ""
513
+ },
514
+ error: {
515
+ true: "",
516
+ false: ""
517
+ }
518
+ },
519
+ compoundVariants: [{
520
+ inline: !0,
521
+ labelPosition: "top",
522
+ class: "flex-col"
523
+ }],
524
+ defaultVariants: {
525
+ inline: !1,
526
+ labelPosition: "right",
527
+ size: "md",
528
+ error: !1
529
+ }
530
+ }), U = n("flex min-w-0 whitespace-normal break-words text-primary", {
531
+ variants: {
532
+ labelPosition: {
533
+ left: "justify-start",
534
+ right: "justify-end",
535
+ top: "justify-start"
536
+ },
537
+ size: {
538
+ sm: "text-xs/5",
539
+ md: "text-sm/5",
540
+ lg: "text-base/6"
541
+ },
542
+ required: {
543
+ true: "",
544
+ false: ""
545
+ },
546
+ requiredPosition: {
547
+ left: "",
548
+ right: ""
549
+ }
550
+ },
551
+ compoundVariants: [
552
+ {
553
+ required: !0,
554
+ requiredPosition: "left",
555
+ class: "before:mr-1 before:text-red-500 before:content-['*']"
556
+ },
557
+ {
558
+ required: !0,
559
+ requiredPosition: "right",
560
+ class: "after:ml-1 after:text-red-500 after:content-['*']"
561
+ },
562
+ {
563
+ labelPosition: ["left", "right"],
564
+ size: "sm",
565
+ class: "min-h-[calc(1.75rem+7px)] items-center"
566
+ },
567
+ {
568
+ labelPosition: ["left", "right"],
569
+ size: "md",
570
+ class: "min-h-[calc(2rem+3px)] items-center"
571
+ },
572
+ {
573
+ labelPosition: ["left", "right"],
574
+ size: "lg",
575
+ class: "min-h-[calc(2.25rem)] items-center"
576
+ }
577
+ ],
578
+ defaultVariants: {
579
+ labelPosition: "right",
580
+ size: "md",
581
+ required: !1,
582
+ requiredPosition: "right"
583
+ }
584
+ }), W = n("flex min-w-0 flex-col justify-center", {
585
+ variants: {
586
+ labelPosition: {
587
+ left: "",
588
+ right: "",
589
+ top: ""
590
+ },
591
+ size: {
592
+ sm: "text-sm",
593
+ md: "text-sm",
594
+ lg: "text-base"
595
+ }
596
+ },
597
+ compoundVariants: [
598
+ {
599
+ labelPosition: [
600
+ "left",
601
+ "right",
602
+ "top"
603
+ ],
604
+ size: "sm",
605
+ class: "min-h-[calc(1.75rem+7px)]"
606
+ },
607
+ {
608
+ labelPosition: [
609
+ "left",
610
+ "right",
611
+ "top"
612
+ ],
613
+ size: "md",
614
+ class: "min-h-[calc(2rem+3px)]"
615
+ },
616
+ {
617
+ labelPosition: [
618
+ "left",
619
+ "right",
620
+ "top"
621
+ ],
622
+ size: "lg",
623
+ class: "min-h-[calc(2.25rem)]"
624
+ }
625
+ ],
626
+ defaultVariants: {
627
+ labelPosition: "right",
628
+ size: "md"
629
+ }
630
+ }), G = n("mt-1.5 min-h-4 text-xs/4", {
631
+ variants: { status: {
632
+ "": "text-tertiary",
633
+ validating: "text-brand-500",
634
+ success: "text-green-600 dark:text-green-400",
635
+ error: "text-red-600 dark:text-red-400"
636
+ } },
637
+ defaultVariants: { status: "" }
638
+ });
639
+ //#endregion
640
+ export { W as a, V as c, F as d, R as f, k as g, j as h, H as i, N as l, z as m, B as n, U as o, L as p, M as r, G as s, P as t, I as u };
641
+
642
+ //# sourceMappingURL=form-Qeqkd-HH.js.map