@vavt/react-ui 1.0.1 → 1.0.3

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 (168) hide show
  1. package/README.md +50 -2
  2. package/dist/Card-BkZhLXQ5.cjs +1 -0
  3. package/dist/{Card-DlztNV-6.js → Card-DCLfLn1x.js} +13 -12
  4. package/dist/Cron-3D9GmlYf.cjs +1 -0
  5. package/dist/{Cron-Di7k2FTL.js → Cron-Go4yIqrd.js} +361 -353
  6. package/dist/{DatePicker-M-MwejjV.js → DatePicker-B-F5q_s_.js} +1 -1
  7. package/dist/{DatePicker-DAxv2h-d.cjs → DatePicker-CoHW85qm.cjs} +1 -1
  8. package/dist/{DateTimePicker-BcT3FtN-.js → DateTimePicker-BSBZZ7xV.js} +1 -1
  9. package/dist/{DateTimePicker-B3C3v99L.cjs → DateTimePicker-CAkdoY--.cjs} +1 -1
  10. package/dist/Divider-BXNZyvHY.js +48 -0
  11. package/dist/Divider-BnmUNmy2.cjs +1 -0
  12. package/dist/Drawer-C0toQ-fQ.js +112 -0
  13. package/dist/Drawer-D45miZ27.cjs +1 -0
  14. package/dist/Dropdown-BsXYVdt6.cjs +1 -0
  15. package/dist/Dropdown-DljKFnvO.js +319 -0
  16. package/dist/Empty-Dny96c3p.cjs +1 -0
  17. package/dist/Empty-MmxZitR8.js +40 -0
  18. package/dist/{MessageBox-CrIifoig.js → MessageBox-B4Qo1vs2.js} +1 -1
  19. package/dist/{MessageBox-Ddn-R2MS.cjs → MessageBox-CTJfdU29.cjs} +1 -1
  20. package/dist/Modal-i_Do8GsG.cjs +1 -0
  21. package/dist/Modal-otJ_9ldu.js +210 -0
  22. package/dist/{Pagination-DKEL6maR.js → Pagination-CSI5IzQB.js} +1 -1
  23. package/dist/{Pagination-DaMWXFn5.cjs → Pagination-ODU-i3gn.cjs} +1 -1
  24. package/dist/Select-BRKxpX-_.cjs +1 -0
  25. package/dist/Select-QedbJ4pD.js +468 -0
  26. package/dist/{Table-C8cSyts5.js → Table-B9NTkptC.js} +1 -1
  27. package/dist/{Table-JoJ9vpu-.cjs → Table-Bqjey5fw.cjs} +1 -1
  28. package/dist/TimePicker-CHZsr_jj.js +207 -0
  29. package/dist/TimePicker-Cpmvn8tx.cjs +1 -0
  30. package/dist/Tooltip-Buk5F9f_.js +205 -0
  31. package/dist/Tooltip-CP8rpNYG.cjs +1 -0
  32. package/dist/Upload-DZC_bt6G.js +183 -0
  33. package/dist/Upload-bxJz2avf.cjs +1 -0
  34. package/dist/base.css +1 -1
  35. package/dist/cjs/Card.cjs +1 -1
  36. package/dist/cjs/Cron.cjs +1 -1
  37. package/dist/cjs/DatePicker.cjs +1 -1
  38. package/dist/cjs/DateTimePicker.cjs +1 -1
  39. package/dist/cjs/Divider.cjs +1 -1
  40. package/dist/cjs/Drawer.cjs +1 -1
  41. package/dist/cjs/Dropdown.cjs +1 -1
  42. package/dist/cjs/Empty.cjs +1 -0
  43. package/dist/cjs/MessageBox.cjs +1 -1
  44. package/dist/cjs/Modal.cjs +1 -1
  45. package/dist/cjs/Pagination.cjs +1 -1
  46. package/dist/cjs/Select.cjs +1 -1
  47. package/dist/cjs/Table.cjs +1 -1
  48. package/dist/cjs/TimePicker.cjs +1 -1
  49. package/dist/cjs/Tooltip.cjs +1 -1
  50. package/dist/cjs/Upload.cjs +1 -0
  51. package/dist/cjs/global.cjs +1 -1
  52. package/dist/cjs/index.cjs +1 -1
  53. package/dist/cjs/register.cjs +1 -1
  54. package/dist/content-DCGQZQp8.cjs +1 -0
  55. package/dist/content-Dllrr-7G.js +11 -0
  56. package/dist/css/Alert.css +1 -1
  57. package/dist/css/Announcement.css +1 -1
  58. package/dist/css/Button.css +1 -1
  59. package/dist/css/Checkbox.css +1 -1
  60. package/dist/css/Cron.css +1 -1
  61. package/dist/css/DatePicker.css +1 -1
  62. package/dist/css/DateTimePicker.css +1 -1
  63. package/dist/css/Dropdown.css +1 -1
  64. package/dist/css/Empty.css +1 -0
  65. package/dist/css/Form.css +1 -1
  66. package/dist/css/Input.css +1 -1
  67. package/dist/css/MessageBox.css +1 -1
  68. package/dist/css/NumberInput.css +1 -1
  69. package/dist/css/Pagination.css +1 -1
  70. package/dist/css/Radio.css +1 -1
  71. package/dist/css/Scrollbar.css +1 -1
  72. package/dist/css/Select.css +1 -1
  73. package/dist/css/Sidebar.css +1 -1
  74. package/dist/css/Switch.css +1 -1
  75. package/dist/css/Table.css +1 -1
  76. package/dist/css/Tabs.css +1 -1
  77. package/dist/css/Tag.css +1 -1
  78. package/dist/css/Textarea.css +1 -1
  79. package/dist/css/TimePicker.css +1 -1
  80. package/dist/css/Timeline.css +1 -1
  81. package/dist/css/Upload.css +1 -0
  82. package/dist/date-picker-BsiNrLZC.js +592 -0
  83. package/dist/date-picker-DNN0BiRA.cjs +1 -0
  84. package/dist/es/Card.mjs +1 -1
  85. package/dist/es/Cron.mjs +1 -1
  86. package/dist/es/DatePicker.mjs +1 -1
  87. package/dist/es/DateTimePicker.mjs +1 -1
  88. package/dist/es/Divider.mjs +1 -1
  89. package/dist/es/Drawer.mjs +1 -1
  90. package/dist/es/Dropdown.mjs +1 -1
  91. package/dist/es/Empty.mjs +3 -0
  92. package/dist/es/MessageBox.mjs +1 -1
  93. package/dist/es/Modal.mjs +1 -1
  94. package/dist/es/Pagination.mjs +1 -1
  95. package/dist/es/Select.mjs +1 -1
  96. package/dist/es/Table.mjs +1 -1
  97. package/dist/es/TimePicker.mjs +1 -1
  98. package/dist/es/Tooltip.mjs +1 -1
  99. package/dist/es/Upload.mjs +3 -0
  100. package/dist/es/global.mjs +1 -1
  101. package/dist/es/index.mjs +31 -29
  102. package/dist/es/register.mjs +1 -1
  103. package/dist/index.css +1 -1
  104. package/dist/layer-BgiUZy_t.cjs +1 -0
  105. package/dist/layer-DDm97-sb.js +53 -0
  106. package/dist/registry-BGNWNSiC.cjs +1 -0
  107. package/dist/registry-q6UdMOyj.js +83 -0
  108. package/dist/style/Empty.cjs +7 -0
  109. package/dist/style/Empty.mjs +7 -0
  110. package/dist/style/Upload.cjs +7 -0
  111. package/dist/style/Upload.mjs +7 -0
  112. package/dist/types/Col/type.d.cts +5 -5
  113. package/dist/types/Col/type.d.ts +5 -5
  114. package/dist/types/Cron/type.d.cts +2 -0
  115. package/dist/types/Cron/type.d.ts +2 -0
  116. package/dist/types/DatePicker/type.d.cts +2 -0
  117. package/dist/types/DatePicker/type.d.ts +2 -0
  118. package/dist/types/Dropdown/type.d.cts +2 -0
  119. package/dist/types/Dropdown/type.d.ts +2 -0
  120. package/dist/types/Empty/Empty.d.cts +3 -0
  121. package/dist/types/Empty/Empty.d.ts +3 -0
  122. package/dist/types/Empty/index.d.cts +5 -0
  123. package/dist/types/Empty/index.d.ts +5 -0
  124. package/dist/types/Empty/type.d.cts +24 -0
  125. package/dist/types/Empty/type.d.ts +24 -0
  126. package/dist/types/Select/type.d.cts +2 -0
  127. package/dist/types/Select/type.d.ts +2 -0
  128. package/dist/types/TimePicker/type.d.cts +2 -0
  129. package/dist/types/TimePicker/type.d.ts +2 -0
  130. package/dist/types/Tooltip/type.d.cts +2 -0
  131. package/dist/types/Tooltip/type.d.ts +2 -0
  132. package/dist/types/Upload/Upload.d.cts +3 -0
  133. package/dist/types/Upload/Upload.d.ts +3 -0
  134. package/dist/types/Upload/index.d.cts +5 -0
  135. package/dist/types/Upload/index.d.ts +5 -0
  136. package/dist/types/Upload/type.d.cts +62 -0
  137. package/dist/types/Upload/type.d.ts +62 -0
  138. package/dist/types/_shared/content.d.cts +13 -0
  139. package/dist/types/_shared/content.d.ts +13 -0
  140. package/dist/types/_shared/layer.d.cts +63 -0
  141. package/dist/types/_shared/layer.d.ts +63 -0
  142. package/dist/types/global.d.cts +4 -0
  143. package/dist/types/global.d.ts +4 -0
  144. package/dist/types/index.d.cts +2 -0
  145. package/dist/types/index.d.ts +2 -0
  146. package/dist/types/registry.d.cts +2 -0
  147. package/dist/types/registry.d.ts +2 -0
  148. package/package.json +2 -4
  149. package/dist/Card-nILlh9c_.cjs +0 -1
  150. package/dist/Cron-CoO2Vnnm.cjs +0 -1
  151. package/dist/Divider-BfvQ6BVP.cjs +0 -1
  152. package/dist/Divider-vyftxh3F.js +0 -47
  153. package/dist/Drawer-D28QbyA3.js +0 -103
  154. package/dist/Drawer-OmMfdgKN.cjs +0 -1
  155. package/dist/Dropdown-CYx6RxVv.js +0 -311
  156. package/dist/Dropdown-swfND4yK.cjs +0 -1
  157. package/dist/Modal-B_VqN16m.js +0 -201
  158. package/dist/Modal-Dm48HmGu.cjs +0 -1
  159. package/dist/Select-DQLup8Y-.cjs +0 -1
  160. package/dist/Select-DccM9YpB.js +0 -458
  161. package/dist/TimePicker-ClQCHa6M.js +0 -199
  162. package/dist/TimePicker-DNBo2Rn5.cjs +0 -1
  163. package/dist/Tooltip-CbPYYr6R.cjs +0 -1
  164. package/dist/Tooltip-Ds4Odm7K.js +0 -197
  165. package/dist/date-picker-DkRwNu2m.js +0 -584
  166. package/dist/date-picker-DyGLrw5H.cjs +0 -1
  167. package/dist/registry-BYA5h9pE.cjs +0 -1
  168. package/dist/registry-rrmu3kvY.js +0 -79
@@ -0,0 +1,207 @@
1
+ import { n as e, t } from "./state-oH-YwB7_.js";
2
+ import { t as n } from "./client-pj_wzx28.js";
3
+ import { n as ee } from "./refs-D5IYOBaf.js";
4
+ import { r as te, t as ne } from "./floating-DBAmeQIq.js";
5
+ import { t as r } from "./id-CHixuHb7.js";
6
+ import { n as re, r as ie, t as ae } from "./layer-DDm97-sb.js";
7
+ import { t as oe } from "./Transition-DiO4GsP3.js";
8
+ import { a as se, d as ce, i as le, n as ue, o as de, t as fe, v as pe, y as i } from "./time-wheel-BtvYZI6H.js";
9
+ import { Clock3 as a, X as me } from "lucide-react";
10
+ import { forwardRef as o, useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
11
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
+ import { createPortal as he } from "react-dom";
13
+ //#region components/TimePicker/TimePicker.tsx
14
+ var m = o((o, m) => {
15
+ let { value: h, defaultValue: g = null, format: ge = "HH:mm:ss", shortcuts: _ = [], minTime: v, maxTime: y, disabledTime: b, placeholder: x = "请选择时间", disabled: S = !1, clearable: _e = !1, size: ve = "md", placement: C = "bottom-start", offset: w = 8, zIndex: ye, className: be, style: xe, id: Se, "aria-label": Ce, "aria-labelledby": T, "aria-describedby": we, onChange: Te, onClear: Ee, onOpen: E, onClose: D, ...De } = o, O = u(null), k = u(null), A = u(null), j = n(), M = ie({
16
+ defaultZIndex: re.popover,
17
+ zIndex: ye
18
+ }), Oe = t(o, "value"), [N, ke] = e({
19
+ value: h ?? null,
20
+ defaultValue: g,
21
+ controlled: Oe
22
+ }), [P, Ae] = d(!1), [je, F] = d({}), [I, L] = d(!1), [Me, R] = d(C), Ne = r("vl-time-picker-control", Se), z = r("vl-time-picker-panel"), Pe = l(() => ee(O, m), [m]), B = v ? i(v) : null, V = y ? i(y) : null, H = l(() => ({
23
+ minSeconds: B,
24
+ maxSeconds: V,
25
+ disabledTime: b
26
+ }), [
27
+ b,
28
+ V,
29
+ B
30
+ ]), U = N && i(N) !== null ? N : "", W = U ? ce(pe(U), ge) : "", G = i(U) ?? i("00:00:00") ?? 0, K = Math.floor(G / 3600), q = Math.floor(G % 3600 / 60), J = G % 60, Fe = s((e) => le(e, H), [H]), Y = s((e, t, n) => ue(e, t, n, H), [H]), X = s((e) => {
31
+ e && S || e !== P && (Ae(e), e ? (L(!1), R(C), F({}), E?.()) : D?.());
32
+ }, [
33
+ S,
34
+ D,
35
+ E,
36
+ P,
37
+ C
38
+ ]), Z = s(() => {
39
+ if (!P || !k.current || !A.current) return;
40
+ let e = ne({
41
+ anchorRect: k.current.getBoundingClientRect(),
42
+ floatingRect: A.current.getBoundingClientRect(),
43
+ placement: C,
44
+ offset: w
45
+ });
46
+ R(e.placement), F({
47
+ left: `${Math.round(e.x)}px`,
48
+ top: `${Math.round(e.y)}px`
49
+ }), L(!0);
50
+ }, [
51
+ w,
52
+ P,
53
+ C
54
+ ]);
55
+ c(() => {
56
+ P && j && Z();
57
+ }, [
58
+ j,
59
+ P,
60
+ Z
61
+ ]);
62
+ let Ie = s(() => X(!1), [X]), Le = s(() => {
63
+ X(!1), k.current?.focus();
64
+ }, [X]);
65
+ te({
66
+ active: P && j,
67
+ rootRef: O,
68
+ floatingRef: A,
69
+ onOutsideClick: Ie,
70
+ onEscape: Le,
71
+ onViewportChange: Z
72
+ }), c(() => {
73
+ S && P && X(!1);
74
+ }, [
75
+ S,
76
+ P,
77
+ X
78
+ ]);
79
+ let Q = (e) => {
80
+ e !== null && Fe(e) || (ke(e), Te?.(e));
81
+ }, Re = (e, t) => {
82
+ let n = de(e, t, {
83
+ hours: K,
84
+ minutes: q,
85
+ seconds: J
86
+ }, Y);
87
+ n !== null && Q(n);
88
+ }, ze = s((e, t) => se(e, t, {
89
+ hours: K,
90
+ minutes: q,
91
+ seconds: J
92
+ }, Y), [
93
+ Y,
94
+ K,
95
+ q,
96
+ J
97
+ ]), Be = (e) => {
98
+ let t = e.getValue(/* @__PURE__ */ new Date());
99
+ t && i(t) !== null && Q(t);
100
+ }, Ve = (e) => {
101
+ e?.stopPropagation(), !S && (Q(null), Ee?.());
102
+ }, He = (e) => {
103
+ S || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), X(!P));
104
+ }, Ue = [
105
+ "vl-time-picker",
106
+ `size-${ve}`,
107
+ P ? "is-open" : "",
108
+ S ? "is-disabled" : "",
109
+ be || ""
110
+ ].filter(Boolean).join(" "), $ = /* @__PURE__ */ f(oe, {
111
+ show: P,
112
+ name: "vl-time-picker",
113
+ deferEffects: !j,
114
+ children: /* @__PURE__ */ p("div", {
115
+ ref: A,
116
+ id: z,
117
+ className: `vl-time-picker__panel is-${Me}${I ? " is-positioned" : ""}`,
118
+ style: {
119
+ ...je,
120
+ zIndex: M.zIndex,
121
+ visibility: I ? "visible" : "hidden"
122
+ },
123
+ role: "dialog",
124
+ "aria-label": "时间选择",
125
+ children: [/* @__PURE__ */ p("div", {
126
+ className: "vl-time-picker__controls",
127
+ children: [/* @__PURE__ */ p("div", {
128
+ className: "vl-time-picker__controls-title",
129
+ children: [/* @__PURE__ */ f(a, {
130
+ size: 16,
131
+ "aria-hidden": "true"
132
+ }), /* @__PURE__ */ f("span", { children: "时间" })]
133
+ }), /* @__PURE__ */ f(fe, {
134
+ value: {
135
+ hours: K,
136
+ minutes: q,
137
+ seconds: J
138
+ },
139
+ isOptionDisabled: ze,
140
+ onChange: Re
141
+ })]
142
+ }), _.length ? /* @__PURE__ */ f("div", {
143
+ className: "vl-time-picker__shortcuts",
144
+ role: "group",
145
+ "aria-label": "快捷选择",
146
+ children: _.map((e) => /* @__PURE__ */ f("button", {
147
+ type: "button",
148
+ onClick: () => Be(e),
149
+ children: e.label
150
+ }, e.label))
151
+ }) : null]
152
+ })
153
+ });
154
+ return /* @__PURE__ */ f(ae, {
155
+ layer: M.layer,
156
+ children: /* @__PURE__ */ p("div", {
157
+ ref: Pe,
158
+ className: "vl-time-picker-wrapper",
159
+ style: xe,
160
+ ...De,
161
+ children: [/* @__PURE__ */ p("div", {
162
+ ref: k,
163
+ id: Ne,
164
+ className: Ue,
165
+ role: "combobox",
166
+ "aria-expanded": P,
167
+ "aria-controls": z,
168
+ "aria-haspopup": "dialog",
169
+ "aria-disabled": S || void 0,
170
+ "aria-label": Ce ?? (T ? void 0 : x),
171
+ "aria-labelledby": T,
172
+ "aria-describedby": we,
173
+ tabIndex: S ? -1 : 0,
174
+ onClick: () => X(!P),
175
+ onKeyDown: He,
176
+ children: [
177
+ /* @__PURE__ */ f("span", {
178
+ className: "vl-time-picker__icon",
179
+ "aria-hidden": "true",
180
+ children: /* @__PURE__ */ f(a, { size: 16 })
181
+ }),
182
+ /* @__PURE__ */ f("span", {
183
+ className: `vl-time-picker__value${W ? "" : " is-placeholder"}`,
184
+ children: W || x
185
+ }),
186
+ _e && U && !S ? /* @__PURE__ */ f("button", {
187
+ type: "button",
188
+ className: "vl-time-picker__clear",
189
+ "aria-label": "清除已选",
190
+ onClick: Ve,
191
+ onMouseDown: (e) => e.preventDefault(),
192
+ children: /* @__PURE__ */ f(me, {
193
+ size: 16,
194
+ "aria-hidden": "true"
195
+ })
196
+ }) : null
197
+ ]
198
+ }), j ? he($, document.body) : $]
199
+ })
200
+ });
201
+ });
202
+ m.displayName = "VlTimePicker";
203
+ //#endregion
204
+ //#region components/TimePicker/index.ts
205
+ var h = m, g = m;
206
+ //#endregion
207
+ export { h as n, g as t };
@@ -0,0 +1 @@
1
+ const e=require("./state-ZBA75xZ_.cjs"),t=require("./client-BkoqeUs3.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./floating-DXRnx48N.cjs"),i=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),ee=require("./Transition-X_89ga-e.cjs"),o=require("./time-wheel-BaCcA9nk.cjs");let s=require("lucide-react"),c=require("react"),l=require("react/jsx-runtime"),te=require("react-dom");var u=(0,c.forwardRef)((u,d)=>{let{value:f,defaultValue:ne=null,format:re=`HH:mm:ss`,shortcuts:p=[],minTime:m,maxTime:h,disabledTime:g,placeholder:_=`请选择时间`,disabled:v=!1,clearable:ie=!1,size:ae=`md`,placement:y=`bottom-start`,offset:b=8,zIndex:oe,className:se,style:ce,id:le,"aria-label":ue,"aria-labelledby":x,"aria-describedby":S,onChange:C,onClear:de,onOpen:w,onClose:T,...fe}=u,E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=t.t(),A=a.r({defaultZIndex:a.n.popover,zIndex:oe}),pe=e.t(u,`value`),[j,me]=e.n({value:f??null,defaultValue:ne,controlled:pe}),[M,he]=(0,c.useState)(!1),[ge,N]=(0,c.useState)({}),[P,F]=(0,c.useState)(!1),[I,L]=(0,c.useState)(y),_e=i.t(`vl-time-picker-control`,le),R=i.t(`vl-time-picker-panel`),ve=(0,c.useMemo)(()=>n.n(E,d),[d]),z=m?o.y(m):null,B=h?o.y(h):null,V=(0,c.useMemo)(()=>({minSeconds:z,maxSeconds:B,disabledTime:g}),[g,B,z]),H=j&&o.y(j)!==null?j:``,U=H?o.d(o.v(H),re):``,W=o.y(H)??o.y(`00:00:00`)??0,G=Math.floor(W/3600),K=Math.floor(W%3600/60),q=W%60,ye=(0,c.useCallback)(e=>o.i(e,V),[V]),J=(0,c.useCallback)((e,t,n)=>o.n(e,t,n,V),[V]),Y=(0,c.useCallback)(e=>{e&&v||e!==M&&(he(e),e?(F(!1),L(y),N({}),w?.()):T?.())},[v,T,w,M,y]),X=(0,c.useCallback)(()=>{if(!M||!D.current||!O.current)return;let e=r.t({anchorRect:D.current.getBoundingClientRect(),floatingRect:O.current.getBoundingClientRect(),placement:y,offset:b});L(e.placement),N({left:`${Math.round(e.x)}px`,top:`${Math.round(e.y)}px`}),F(!0)},[b,M,y]);(0,c.useEffect)(()=>{M&&k&&X()},[k,M,X]);let be=(0,c.useCallback)(()=>Y(!1),[Y]),xe=(0,c.useCallback)(()=>{Y(!1),D.current?.focus()},[Y]);r.r({active:M&&k,rootRef:E,floatingRef:O,onOutsideClick:be,onEscape:xe,onViewportChange:X}),(0,c.useEffect)(()=>{v&&M&&Y(!1)},[v,M,Y]);let Z=e=>{e!==null&&ye(e)||(me(e),C?.(e))},Se=(e,t)=>{let n=o.o(e,t,{hours:G,minutes:K,seconds:q},J);n!==null&&Z(n)},Q=(0,c.useCallback)((e,t)=>o.a(e,t,{hours:G,minutes:K,seconds:q},J),[J,G,K,q]),Ce=e=>{let t=e.getValue(new Date);t&&o.y(t)!==null&&Z(t)},we=e=>{e?.stopPropagation(),!v&&(Z(null),de?.())},Te=e=>{v||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),Y(!M))},Ee=[`vl-time-picker`,`size-${ae}`,M?`is-open`:``,v?`is-disabled`:``,se||``].filter(Boolean).join(` `),$=(0,l.jsx)(ee.t,{show:M,name:`vl-time-picker`,deferEffects:!k,children:(0,l.jsxs)(`div`,{ref:O,id:R,className:`vl-time-picker__panel is-${I}${P?` is-positioned`:``}`,style:{...ge,zIndex:A.zIndex,visibility:P?`visible`:`hidden`},role:`dialog`,"aria-label":`时间选择`,children:[(0,l.jsxs)(`div`,{className:`vl-time-picker__controls`,children:[(0,l.jsxs)(`div`,{className:`vl-time-picker__controls-title`,children:[(0,l.jsx)(s.Clock3,{size:16,"aria-hidden":`true`}),(0,l.jsx)(`span`,{children:`时间`})]}),(0,l.jsx)(o.t,{value:{hours:G,minutes:K,seconds:q},isOptionDisabled:Q,onChange:Se})]}),p.length?(0,l.jsx)(`div`,{className:`vl-time-picker__shortcuts`,role:`group`,"aria-label":`快捷选择`,children:p.map(e=>(0,l.jsx)(`button`,{type:`button`,onClick:()=>Ce(e),children:e.label},e.label))}):null]})});return(0,l.jsx)(a.t,{layer:A.layer,children:(0,l.jsxs)(`div`,{ref:ve,className:`vl-time-picker-wrapper`,style:ce,...fe,children:[(0,l.jsxs)(`div`,{ref:D,id:_e,className:Ee,role:`combobox`,"aria-expanded":M,"aria-controls":R,"aria-haspopup":`dialog`,"aria-disabled":v||void 0,"aria-label":ue??(x?void 0:_),"aria-labelledby":x,"aria-describedby":S,tabIndex:v?-1:0,onClick:()=>Y(!M),onKeyDown:Te,children:[(0,l.jsx)(`span`,{className:`vl-time-picker__icon`,"aria-hidden":`true`,children:(0,l.jsx)(s.Clock3,{size:16})}),(0,l.jsx)(`span`,{className:`vl-time-picker__value${U?``:` is-placeholder`}`,children:U||_}),ie&&H&&!v?(0,l.jsx)(`button`,{type:`button`,className:`vl-time-picker__clear`,"aria-label":`清除已选`,onClick:we,onMouseDown:e=>e.preventDefault(),children:(0,l.jsx)(s.X,{size:16,"aria-hidden":`true`})}):null]}),k?(0,te.createPortal)($,document.body):$]})})});u.displayName=`VlTimePicker`;var d=u,f=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
@@ -0,0 +1,205 @@
1
+ import { n as e, t } from "./state-oH-YwB7_.js";
2
+ import { t as n } from "./client-pj_wzx28.js";
3
+ import { n as r } from "./refs-D5IYOBaf.js";
4
+ import { t as i } from "./number-BN2jHM6Z.js";
5
+ import { n as ee, r as a } from "./floating-DBAmeQIq.js";
6
+ import { t as o } from "./id-CHixuHb7.js";
7
+ import { n as s, r as te, t as ne } from "./layer-DDm97-sb.js";
8
+ import { t as re } from "./Transition-DiO4GsP3.js";
9
+ import { i as ie } from "./focus-BDDJyKk3.js";
10
+ import { Fragment as ae, cloneElement as oe, forwardRef as c, isValidElement as l, useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
11
+ import { jsx as h, jsxs as se } from "react/jsx-runtime";
12
+ import { createPortal as ce } from "react-dom";
13
+ //#region components/Tooltip/Tooltip.tsx
14
+ var g = c((c, g) => {
15
+ let { content: _, placement: v = "top", trigger: y = "hover", disabled: b = !1, offset: x = 8, showDelay: S = 100, hideDelay: C = 100, showArrow: le = !0, maxWidth: w = 300, zIndex: ue, open: de, defaultOpen: fe = !1, className: T, children: E, onChange: pe, onShow: D, onHide: O, ...me } = c, k = p(null), A = p(null), j = p(null), M = p(null), N = p(!1), P = p(!1), F = p(!1), I = p(null), L = p(null), he = f(() => r(k, g), [g]), R = n(), z = te({
16
+ defaultZIndex: s.tooltip,
17
+ zIndex: ue
18
+ }), ge = t(c, "open"), [B, V] = e({
19
+ value: !!de,
20
+ defaultValue: fe,
21
+ controlled: ge,
22
+ onChange: pe
23
+ }), H = !b && _ != null, U = H && B, W = o("vl-tooltip-popup"), [_e, ve] = m(v), [ye, be] = m({}), [xe, G] = m({}), Se = f(() => [
24
+ "vl-tooltip",
25
+ b ? "is-disabled" : "",
26
+ T || ""
27
+ ].filter(Boolean).join(" "), [b, T]), Ce = `vl-tooltip__popup is-${_e}`, K = u(() => {
28
+ I.current !== null && window.clearTimeout(I.current), L.current !== null && window.clearTimeout(L.current), I.current = null, L.current = null;
29
+ }, []), q = u(() => {
30
+ let e = M.current;
31
+ if (e?.isConnected) {
32
+ e.focus();
33
+ return;
34
+ }
35
+ A.current?.querySelector(ie)?.focus();
36
+ }, []), J = u((e, t = !1) => {
37
+ if (!(e && !H)) {
38
+ if (B === e) {
39
+ t && q();
40
+ return;
41
+ }
42
+ V(e), e ? D?.() : (O?.(), t && window.requestAnimationFrame(q));
43
+ }
44
+ }, [
45
+ H,
46
+ B,
47
+ V,
48
+ D,
49
+ O,
50
+ q
51
+ ]), Y = u(() => {
52
+ if (K(), H) {
53
+ if (S <= 0) {
54
+ J(!0);
55
+ return;
56
+ }
57
+ I.current = window.setTimeout(() => J(!0), S);
58
+ }
59
+ }, [
60
+ K,
61
+ H,
62
+ S,
63
+ J
64
+ ]), X = u(() => {
65
+ if (K(), C <= 0) {
66
+ J(!1);
67
+ return;
68
+ }
69
+ L.current = window.setTimeout(() => J(!1), C);
70
+ }, [
71
+ K,
72
+ C,
73
+ J
74
+ ]), Z = u(() => {
75
+ N.current || P.current || F.current || X();
76
+ }, [X]), Q = u(() => {
77
+ if (!U) return;
78
+ let e = A.current, t = j.current;
79
+ if (!e || !t) return;
80
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect(), { placement: a, x: o, y: s } = ee({
81
+ anchorRect: n,
82
+ floatingRect: r,
83
+ placement: v,
84
+ offset: x,
85
+ edgePadding: 8
86
+ });
87
+ if (ve(a), be({
88
+ left: `${Math.round(o)}px`,
89
+ top: `${Math.round(s)}px`
90
+ }), a.startsWith("top") || a.startsWith("bottom")) {
91
+ let e = n.left + n.width / 2 - o;
92
+ G({
93
+ left: `${Math.round(i(e, 10, Math.max(10, r.width - 10)))}px`,
94
+ top: void 0
95
+ });
96
+ } else {
97
+ let e = n.top + n.height / 2 - s;
98
+ G({
99
+ left: void 0,
100
+ top: `${Math.round(i(e, 10, Math.max(10, r.height - 10)))}px`
101
+ });
102
+ }
103
+ }, [
104
+ U,
105
+ v,
106
+ x
107
+ ]), we = () => {
108
+ y === "hover" && (N.current = !0, Y());
109
+ }, Te = () => {
110
+ y === "hover" && (N.current = !1, Z());
111
+ }, Ee = () => {
112
+ y === "hover" && (P.current = !0, K());
113
+ }, De = () => {
114
+ y === "hover" && (P.current = !1, Z());
115
+ }, Oe = (e) => {
116
+ if (y !== "click") return;
117
+ let t = e.target;
118
+ t.matches("button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") && (M.current = t), J(!U);
119
+ }, ke = (e) => {
120
+ let t = e.target;
121
+ t.matches("button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])") && (M.current = t), F.current = !0, (y === "hover" || y === "focus") && Y();
122
+ }, Ae = (e) => {
123
+ e.currentTarget.contains(e.relatedTarget) || (F.current = !1, y === "hover" ? Z() : y === "focus" && X());
124
+ };
125
+ d(() => {
126
+ if (!U || !R) return;
127
+ let e = window.requestAnimationFrame(() => {
128
+ Q(), window.requestAnimationFrame(Q);
129
+ });
130
+ return () => window.cancelAnimationFrame(e);
131
+ }, [
132
+ U,
133
+ R,
134
+ Q
135
+ ]), d(() => {
136
+ H || !B || J(!1);
137
+ }, [
138
+ H,
139
+ B,
140
+ J
141
+ ]);
142
+ let je = u(() => J(!1), [J]), Me = u(() => J(!1, !0), [J]);
143
+ a({
144
+ active: U && R,
145
+ rootRef: k,
146
+ floatingRef: j,
147
+ closeOnOutsideClick: y === "click",
148
+ onOutsideClick: je,
149
+ onEscape: Me,
150
+ onViewportChange: Q
151
+ }), d(() => () => K(), [K]);
152
+ let Ne = [l(E) ? E.props["aria-describedby"] : void 0, W].filter(Boolean).join(" "), Pe = l(E) && E.type !== ae ? oe(E, { "aria-describedby": Ne }) : E, Fe = {
153
+ ...ye,
154
+ zIndex: z.zIndex,
155
+ maxWidth: typeof w == "number" ? `${w}px` : w
156
+ }, $ = /* @__PURE__ */ h(re, {
157
+ show: U,
158
+ name: "vl-tooltip",
159
+ unmountOnExit: !1,
160
+ deferEffects: !R,
161
+ children: /* @__PURE__ */ se("div", {
162
+ ref: j,
163
+ id: W,
164
+ className: Ce,
165
+ style: Fe,
166
+ role: "tooltip",
167
+ "aria-hidden": !U || void 0,
168
+ onMouseEnter: Ee,
169
+ onMouseLeave: De,
170
+ children: [le ? /* @__PURE__ */ h("span", {
171
+ className: "vl-tooltip__arrow",
172
+ style: xe,
173
+ "aria-hidden": "true"
174
+ }) : null, /* @__PURE__ */ h("div", {
175
+ className: "vl-tooltip__content",
176
+ children: _
177
+ })]
178
+ })
179
+ });
180
+ return /* @__PURE__ */ h(ne, {
181
+ layer: z.layer,
182
+ children: /* @__PURE__ */ se("div", {
183
+ ref: he,
184
+ className: Se,
185
+ ...me,
186
+ children: [/* @__PURE__ */ h("div", {
187
+ ref: A,
188
+ className: "vl-tooltip__trigger",
189
+ "aria-describedby": l(E) ? void 0 : W,
190
+ onMouseEnter: we,
191
+ onMouseLeave: Te,
192
+ onClick: Oe,
193
+ onFocus: ke,
194
+ onBlur: Ae,
195
+ children: Pe
196
+ }), R ? ce($, document.body) : $]
197
+ })
198
+ });
199
+ });
200
+ g.displayName = "VlTooltip";
201
+ //#endregion
202
+ //#region components/Tooltip/index.ts
203
+ var _ = g, v = g;
204
+ //#endregion
205
+ export { _ as n, v as t };
@@ -0,0 +1 @@
1
+ const e=require("./state-ZBA75xZ_.cjs"),t=require("./client-BkoqeUs3.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./number-B7qJF_ZY.cjs"),i=require("./floating-DXRnx48N.cjs"),a=require("./id-CF0zOP1G.cjs"),o=require("./layer-BgiUZy_t.cjs"),s=require("./Transition-X_89ga-e.cjs"),c=require("./focus-D-h8CbGr.cjs");let l=require("react"),u=require("react/jsx-runtime"),ee=require("react-dom");var d=(0,l.forwardRef)((d,f)=>{let{content:p,placement:m=`top`,trigger:h=`hover`,disabled:g=!1,offset:_=8,showDelay:v=100,hideDelay:y=100,showArrow:te=!0,maxWidth:b=300,zIndex:ne,open:re,defaultOpen:ie=!1,className:x,children:S,onChange:ae,onShow:C,onHide:w,...oe}=d,T=(0,l.useRef)(null),E=(0,l.useRef)(null),D=(0,l.useRef)(null),O=(0,l.useRef)(null),k=(0,l.useRef)(!1),A=(0,l.useRef)(!1),j=(0,l.useRef)(!1),M=(0,l.useRef)(null),N=(0,l.useRef)(null),se=(0,l.useMemo)(()=>n.n(T,f),[f]),P=t.t(),F=o.r({defaultZIndex:o.n.tooltip,zIndex:ne}),ce=e.t(d,`open`),[I,L]=e.n({value:!!re,defaultValue:ie,controlled:ce,onChange:ae}),R=!g&&p!=null,z=R&&I,B=a.t(`vl-tooltip-popup`),[le,V]=(0,l.useState)(m),[H,U]=(0,l.useState)({}),[ue,W]=(0,l.useState)({}),de=(0,l.useMemo)(()=>[`vl-tooltip`,g?`is-disabled`:``,x||``].filter(Boolean).join(` `),[g,x]),fe=`vl-tooltip__popup is-${le}`,G=(0,l.useCallback)(()=>{M.current!==null&&window.clearTimeout(M.current),N.current!==null&&window.clearTimeout(N.current),M.current=null,N.current=null},[]),K=(0,l.useCallback)(()=>{let e=O.current;if(e?.isConnected){e.focus();return}E.current?.querySelector(c.i)?.focus()},[]),q=(0,l.useCallback)((e,t=!1)=>{if(!(e&&!R)){if(I===e){t&&K();return}L(e),e?C?.():(w?.(),t&&window.requestAnimationFrame(K))}},[R,I,L,C,w,K]),J=(0,l.useCallback)(()=>{if(G(),R){if(v<=0){q(!0);return}M.current=window.setTimeout(()=>q(!0),v)}},[G,R,v,q]),Y=(0,l.useCallback)(()=>{if(G(),y<=0){q(!1);return}N.current=window.setTimeout(()=>q(!1),y)},[G,y,q]),X=(0,l.useCallback)(()=>{k.current||A.current||j.current||Y()},[Y]),Z=(0,l.useCallback)(()=>{if(!z)return;let e=E.current,t=D.current;if(!e||!t)return;let n=e.getBoundingClientRect(),a=t.getBoundingClientRect(),{placement:o,x:s,y:c}=i.n({anchorRect:n,floatingRect:a,placement:m,offset:_,edgePadding:8});if(V(o),U({left:`${Math.round(s)}px`,top:`${Math.round(c)}px`}),o.startsWith(`top`)||o.startsWith(`bottom`)){let e=n.left+n.width/2-s;W({left:`${Math.round(r.t(e,10,Math.max(10,a.width-10)))}px`,top:void 0})}else{let e=n.top+n.height/2-c;W({left:void 0,top:`${Math.round(r.t(e,10,Math.max(10,a.height-10)))}px`})}},[z,m,_]),pe=()=>{h===`hover`&&(k.current=!0,J())},me=()=>{h===`hover`&&(k.current=!1,X())},Q=()=>{h===`hover`&&(A.current=!0,G())},he=()=>{h===`hover`&&(A.current=!1,X())},ge=e=>{if(h!==`click`)return;let t=e.target;t.matches(`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`)&&(O.current=t),q(!z)},_e=e=>{let t=e.target;t.matches(`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`)&&(O.current=t),j.current=!0,(h===`hover`||h===`focus`)&&J()},ve=e=>{e.currentTarget.contains(e.relatedTarget)||(j.current=!1,h===`hover`?X():h===`focus`&&Y())};(0,l.useEffect)(()=>{if(!z||!P)return;let e=window.requestAnimationFrame(()=>{Z(),window.requestAnimationFrame(Z)});return()=>window.cancelAnimationFrame(e)},[z,P,Z]),(0,l.useEffect)(()=>{R||!I||q(!1)},[R,I,q]);let ye=(0,l.useCallback)(()=>q(!1),[q]),be=(0,l.useCallback)(()=>q(!1,!0),[q]);i.r({active:z&&P,rootRef:T,floatingRef:D,closeOnOutsideClick:h===`click`,onOutsideClick:ye,onEscape:be,onViewportChange:Z}),(0,l.useEffect)(()=>()=>G(),[G]);let xe=[(0,l.isValidElement)(S)?S.props[`aria-describedby`]:void 0,B].filter(Boolean).join(` `),Se=(0,l.isValidElement)(S)&&S.type!==l.Fragment?(0,l.cloneElement)(S,{"aria-describedby":xe}):S,Ce={...H,zIndex:F.zIndex,maxWidth:typeof b==`number`?`${b}px`:b},$=(0,u.jsx)(s.t,{show:z,name:`vl-tooltip`,unmountOnExit:!1,deferEffects:!P,children:(0,u.jsxs)(`div`,{ref:D,id:B,className:fe,style:Ce,role:`tooltip`,"aria-hidden":!z||void 0,onMouseEnter:Q,onMouseLeave:he,children:[te?(0,u.jsx)(`span`,{className:`vl-tooltip__arrow`,style:ue,"aria-hidden":`true`}):null,(0,u.jsx)(`div`,{className:`vl-tooltip__content`,children:p})]})});return(0,u.jsx)(o.t,{layer:F.layer,children:(0,u.jsxs)(`div`,{ref:se,className:de,...oe,children:[(0,u.jsx)(`div`,{ref:E,className:`vl-tooltip__trigger`,"aria-describedby":(0,l.isValidElement)(S)?void 0:B,onMouseEnter:pe,onMouseLeave:me,onClick:ge,onFocus:_e,onBlur:ve,children:Se}),P?(0,ee.createPortal)($,document.body):$]})})});d.displayName=`VlTooltip`;var f=d,p=d;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});
@@ -0,0 +1,183 @@
1
+ import { n as e, t } from "./state-oH-YwB7_.js";
2
+ import { t as n } from "./content-Dllrr-7G.js";
3
+ import { t as r } from "./number-BN2jHM6Z.js";
4
+ import { t as i } from "./id-CHixuHb7.js";
5
+ import { File as a, FileImage as o, Paperclip as s, Trash2 as c, UploadCloud as ee } from "lucide-react";
6
+ import { forwardRef as l, useRef as u, useState as d } from "react";
7
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ //#region components/Upload/Upload.tsx
9
+ var h = [], g = 0, _ = () => `vl-upload-${++g}`, te = (e) => ({
10
+ uid: _(),
11
+ name: e.name,
12
+ size: e.size,
13
+ type: e.type,
14
+ status: "ready",
15
+ file: e
16
+ }), v = (e) => (e.file?.type ?? e.type ?? "").startsWith("image/"), y = l((l, g) => {
17
+ let { value: _, defaultValue: y = h, accept: b, multiple: x = !1, disabled: S = !1, drag: C = !1, maxCount: w, listType: T = "text", showFileList: E = !0, uploadText: D = "选择文件", tip: O, beforeUpload: k, onChange: ne, onRemove: re, onPreview: A, onExceed: j, id: ie, "aria-describedby": ae, "aria-labelledby": oe, "aria-invalid": se, "aria-busy": ce, className: le, children: M, ...N } = l, P = u(null), F = i("vl-upload", ie), I = i("vl-upload-tip"), L = t(l, "value"), [R, z] = e({
18
+ value: _ ?? h,
19
+ defaultValue: y,
20
+ controlled: L,
21
+ onChange: ne
22
+ }), [B, V] = d(!1), [H, U] = d(""), W = u(R), G = u(R);
23
+ G.current !== R && (W.current = R, G.current = R);
24
+ let K = (e, t) => {
25
+ W.current = e, G.current = e, z(e), t && U(t);
26
+ }, ue = async (e) => {
27
+ if (e.length === 0) return;
28
+ let t = W.current, n = x ? w === void 0 ? e.length : Math.max(0, w - t.length) : 1, r = e.slice(0, n);
29
+ if (r.length < e.length && j?.(e.slice(r.length), t), r.length === 0) return;
30
+ let i = [];
31
+ for (let e of r) {
32
+ if (k) {
33
+ let t;
34
+ try {
35
+ t = !!await k(e, r);
36
+ } catch {
37
+ t = !1;
38
+ }
39
+ if (!t) continue;
40
+ }
41
+ i.push(te(e));
42
+ }
43
+ if (i.length === 0) return;
44
+ let a = x ? W.current : h, o = x && w !== void 0 ? Math.max(0, w - a.length) : i.length, s = i.slice(0, o);
45
+ if (s.length < i.length) {
46
+ let e = i.slice(s.length).map((e) => e.file).filter((e) => e !== void 0);
47
+ e.length > 0 && j?.(e, a);
48
+ }
49
+ if (s.length === 0) return;
50
+ let c = s.map((e) => e.name).join("、");
51
+ K([...a, ...s], `已添加 ${c}`);
52
+ }, q = u(Promise.resolve()), J = (e) => {
53
+ S || e.length === 0 || (q.current = q.current.then(() => ue(e)).catch(() => void 0));
54
+ }, Y = x && w !== void 0 && R.length >= w, X = S || Y, de = () => {
55
+ X || P.current?.click();
56
+ }, fe = (e) => {
57
+ J(Array.from(e.target.files ?? [])), e.target.value = "";
58
+ }, Z = u(0), pe = (e) => {
59
+ e.preventDefault(), Z.current += 1, S || V(!0);
60
+ }, me = () => {
61
+ Z.current = Math.max(0, Z.current - 1), Z.current === 0 && V(!1);
62
+ }, Q = (e) => {
63
+ e.preventDefault(), Z.current = 0, V(!1), J(Array.from(e.dataTransfer.files));
64
+ }, he = (e, t) => {
65
+ e.stopPropagation();
66
+ let n = W.current.filter((e) => e.uid !== t.uid);
67
+ K(n, `已移除 ${t.name}`), re?.(t, n);
68
+ }, ge = [
69
+ "vl-upload",
70
+ C ? "is-drag" : "",
71
+ B ? "is-dragover" : "",
72
+ S ? "is-disabled" : "",
73
+ Y ? "is-full" : "",
74
+ T === "picture" ? "list-picture" : "",
75
+ le || ""
76
+ ].filter(Boolean).join(" "), $ = n(O), _e = [ae, $ ? I : void 0].filter(Boolean).join(" ") || void 0, ve = (e) => T === "picture" ? e.url ? /* @__PURE__ */ p("img", {
77
+ src: e.url,
78
+ alt: "",
79
+ className: "vl-upload__thumbnail"
80
+ }) : v(e) ? /* @__PURE__ */ p(o, { "aria-hidden": "true" }) : /* @__PURE__ */ p(a, { "aria-hidden": "true" }) : /* @__PURE__ */ p(s, { "aria-hidden": "true" }), ye = M ?? /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p(ee, {
81
+ className: "vl-upload__icon",
82
+ "aria-hidden": "true"
83
+ }), /* @__PURE__ */ p("span", {
84
+ className: "vl-upload__text",
85
+ children: D
86
+ })] });
87
+ return /* @__PURE__ */ m("div", {
88
+ ref: g,
89
+ className: ge,
90
+ ...C ? {
91
+ onDragEnter: pe,
92
+ onDragOver: (e) => e.preventDefault(),
93
+ onDragLeave: me,
94
+ onDrop: Q
95
+ } : void 0,
96
+ ...N,
97
+ children: [
98
+ /* @__PURE__ */ p("input", {
99
+ ref: P,
100
+ className: "vl-upload__input",
101
+ type: "file",
102
+ accept: b,
103
+ multiple: x,
104
+ disabled: S,
105
+ tabIndex: -1,
106
+ "aria-hidden": "true",
107
+ onChange: fe
108
+ }),
109
+ /* @__PURE__ */ p("button", {
110
+ type: "button",
111
+ id: F,
112
+ className: "vl-upload__trigger",
113
+ disabled: X,
114
+ "aria-describedby": _e,
115
+ "aria-labelledby": oe,
116
+ "aria-invalid": se,
117
+ "aria-busy": ce,
118
+ onClick: de,
119
+ children: ye
120
+ }),
121
+ $ ? /* @__PURE__ */ p("div", {
122
+ id: I,
123
+ className: "vl-upload__tip",
124
+ children: O
125
+ }) : null,
126
+ /* @__PURE__ */ p("div", {
127
+ className: "vl-upload__status",
128
+ role: "status",
129
+ "aria-live": "polite",
130
+ children: H
131
+ }),
132
+ E && R.length > 0 ? /* @__PURE__ */ p("ul", {
133
+ className: "vl-upload__list",
134
+ children: R.map((e) => /* @__PURE__ */ m("li", {
135
+ className: `vl-upload__item is-${e.status ?? "ready"}`,
136
+ children: [
137
+ ve(e),
138
+ A ? /* @__PURE__ */ p("button", {
139
+ type: "button",
140
+ className: "vl-upload__name",
141
+ title: e.name,
142
+ onClick: () => A(e),
143
+ children: e.name
144
+ }) : /* @__PURE__ */ p("span", {
145
+ className: "vl-upload__name is-static",
146
+ title: e.name,
147
+ children: e.name
148
+ }),
149
+ e.status === "error" && e.error ? /* @__PURE__ */ p("span", {
150
+ className: "vl-upload__error",
151
+ children: e.error
152
+ }) : null,
153
+ /* @__PURE__ */ p("button", {
154
+ type: "button",
155
+ className: "vl-upload__remove",
156
+ "aria-label": `移除 ${e.name}`,
157
+ onClick: (t) => he(t, e),
158
+ children: /* @__PURE__ */ p(c, { "aria-hidden": "true" })
159
+ }),
160
+ e.status === "uploading" && typeof e.percent == "number" ? /* @__PURE__ */ p("div", {
161
+ className: "vl-upload__progress",
162
+ role: "progressbar",
163
+ "aria-valuenow": r(Math.round(e.percent), 0, 100),
164
+ "aria-valuemin": 0,
165
+ "aria-valuemax": 100,
166
+ "aria-label": `${e.name} 上传进度`,
167
+ children: /* @__PURE__ */ p("div", {
168
+ className: "vl-upload__progress-bar",
169
+ style: { width: `${r(e.percent, 0, 100)}%` }
170
+ })
171
+ }) : null
172
+ ]
173
+ }, e.uid))
174
+ }) : null
175
+ ]
176
+ });
177
+ });
178
+ y.displayName = "VlUpload";
179
+ //#endregion
180
+ //#region components/Upload/index.ts
181
+ var b = y, x = y;
182
+ //#endregion
183
+ export { b as n, x as t };
@@ -0,0 +1 @@
1
+ const e=require("./state-ZBA75xZ_.cjs"),t=require("./content-DCGQZQp8.cjs"),n=require("./number-B7qJF_ZY.cjs"),r=require("./id-CF0zOP1G.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime");var s=[],c=0,l=()=>`vl-upload-${++c}`,u=e=>({uid:l(),name:e.name,size:e.size,type:e.type,status:`ready`,file:e}),d=e=>(e.file?.type??e.type??``).startsWith(`image/`),f=(0,a.forwardRef)((c,l)=>{let{value:f,defaultValue:p=s,accept:m,multiple:h=!1,disabled:g=!1,drag:_=!1,maxCount:v,listType:y=`text`,showFileList:b=!0,uploadText:x=`选择文件`,tip:S,beforeUpload:C,onChange:w,onRemove:T,onPreview:E,onExceed:D,id:O,"aria-describedby":k,"aria-labelledby":A,"aria-invalid":j,"aria-busy":M,className:ee,children:te,...ne}=c,N=(0,a.useRef)(null),P=r.t(`vl-upload`,O),F=r.t(`vl-upload-tip`),I=e.t(c,`value`),[L,R]=e.n({value:f??s,defaultValue:p,controlled:I,onChange:w}),[z,B]=(0,a.useState)(!1),[V,H]=(0,a.useState)(``),U=(0,a.useRef)(L),W=(0,a.useRef)(L);W.current!==L&&(U.current=L,W.current=L);let G=(e,t)=>{U.current=e,W.current=e,R(e),t&&H(t)},K=async e=>{if(e.length===0)return;let t=U.current,n=h?v===void 0?e.length:Math.max(0,v-t.length):1,r=e.slice(0,n);if(r.length<e.length&&D?.(e.slice(r.length),t),r.length===0)return;let i=[];for(let e of r){if(C){let t;try{t=!!await C(e,r)}catch{t=!1}if(!t)continue}i.push(u(e))}if(i.length===0)return;let a=h?U.current:s,o=h&&v!==void 0?Math.max(0,v-a.length):i.length,c=i.slice(0,o);if(c.length<i.length){let e=i.slice(c.length).map(e=>e.file).filter(e=>e!==void 0);e.length>0&&D?.(e,a)}if(c.length===0)return;let l=c.map(e=>e.name).join(`、`);G([...a,...c],`已添加 ${l}`)},q=(0,a.useRef)(Promise.resolve()),J=e=>{g||e.length===0||(q.current=q.current.then(()=>K(e)).catch(()=>void 0))},Y=h&&v!==void 0&&L.length>=v,X=g||Y,re=()=>{X||N.current?.click()},ie=e=>{J(Array.from(e.target.files??[])),e.target.value=``},Z=(0,a.useRef)(0),ae=e=>{e.preventDefault(),Z.current+=1,g||B(!0)},oe=()=>{Z.current=Math.max(0,Z.current-1),Z.current===0&&B(!1)},se=e=>{e.preventDefault(),Z.current=0,B(!1),J(Array.from(e.dataTransfer.files))},ce=(e,t)=>{e.stopPropagation();let n=U.current.filter(e=>e.uid!==t.uid);G(n,`已移除 ${t.name}`),T?.(t,n)},le=[`vl-upload`,_?`is-drag`:``,z?`is-dragover`:``,g?`is-disabled`:``,Y?`is-full`:``,y===`picture`?`list-picture`:``,ee||``].filter(Boolean).join(` `),Q=t.t(S),$=[k,Q?F:void 0].filter(Boolean).join(` `)||void 0,ue=e=>y===`picture`?e.url?(0,o.jsx)(`img`,{src:e.url,alt:``,className:`vl-upload__thumbnail`}):d(e)?(0,o.jsx)(i.FileImage,{"aria-hidden":`true`}):(0,o.jsx)(i.File,{"aria-hidden":`true`}):(0,o.jsx)(i.Paperclip,{"aria-hidden":`true`}),de=te??(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.UploadCloud,{className:`vl-upload__icon`,"aria-hidden":`true`}),(0,o.jsx)(`span`,{className:`vl-upload__text`,children:x})]});return(0,o.jsxs)(`div`,{ref:l,className:le,..._?{onDragEnter:ae,onDragOver:e=>e.preventDefault(),onDragLeave:oe,onDrop:se}:void 0,...ne,children:[(0,o.jsx)(`input`,{ref:N,className:`vl-upload__input`,type:`file`,accept:m,multiple:h,disabled:g,tabIndex:-1,"aria-hidden":`true`,onChange:ie}),(0,o.jsx)(`button`,{type:`button`,id:P,className:`vl-upload__trigger`,disabled:X,"aria-describedby":$,"aria-labelledby":A,"aria-invalid":j,"aria-busy":M,onClick:re,children:de}),Q?(0,o.jsx)(`div`,{id:F,className:`vl-upload__tip`,children:S}):null,(0,o.jsx)(`div`,{className:`vl-upload__status`,role:`status`,"aria-live":`polite`,children:V}),b&&L.length>0?(0,o.jsx)(`ul`,{className:`vl-upload__list`,children:L.map(e=>(0,o.jsxs)(`li`,{className:`vl-upload__item is-${e.status??`ready`}`,children:[ue(e),E?(0,o.jsx)(`button`,{type:`button`,className:`vl-upload__name`,title:e.name,onClick:()=>E(e),children:e.name}):(0,o.jsx)(`span`,{className:`vl-upload__name is-static`,title:e.name,children:e.name}),e.status===`error`&&e.error?(0,o.jsx)(`span`,{className:`vl-upload__error`,children:e.error}):null,(0,o.jsx)(`button`,{type:`button`,className:`vl-upload__remove`,"aria-label":`移除 ${e.name}`,onClick:t=>ce(t,e),children:(0,o.jsx)(i.Trash2,{"aria-hidden":`true`})}),e.status===`uploading`&&typeof e.percent==`number`?(0,o.jsx)(`div`,{className:`vl-upload__progress`,role:`progressbar`,"aria-valuenow":n.t(Math.round(e.percent),0,100),"aria-valuemin":0,"aria-valuemax":100,"aria-label":`${e.name} 上传进度`,children:(0,o.jsx)(`div`,{className:`vl-upload__progress-bar`,style:{width:`${n.t(e.percent,0,100)}%`}})}):null]},e.uid))}):null]})});f.displayName=`VlUpload`;var p=f,m=f;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});