@vavt/react-ui 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Announcement-BUvNHscy.cjs +1 -0
- package/dist/Announcement-CznCpx2T.js +174 -0
- package/dist/Badge-BkqoSV-F.cjs +1 -0
- package/dist/Badge-FzXPw1qS.js +72 -0
- package/dist/{Cron-DIB4GG4y.js → Cron-C3S1XI-J.js} +18 -18
- package/dist/{Cron-MhbYMEeJ.cjs → Cron-CIZ9GKm0.cjs} +1 -1
- package/dist/{DatePicker-Bj709smn.cjs → DatePicker-B5uYQlzy.cjs} +1 -1
- package/dist/{DatePicker--13tW0cw.js → DatePicker-DhRxFPCj.js} +1 -1
- package/dist/{DateTimePicker-Blqs2Bcv.js → DateTimePicker-BjDD15Av.js} +1 -1
- package/dist/{DateTimePicker-ZSScsk-j.cjs → DateTimePicker-Bve5qoeh.cjs} +1 -1
- package/dist/Drawer-DNZCj--j.js +113 -0
- package/dist/Drawer-YWO6-KLG.cjs +1 -0
- package/dist/{Dropdown-mYCY-LcF.js → Dropdown-BcT4uaQT.js} +13 -13
- package/dist/Dropdown-CPW-aSTx.cjs +1 -0
- package/dist/Form-LuUPwJc2.cjs +1 -0
- package/dist/Form-rXq9r3N-.js +442 -0
- package/dist/{Loading-CL0wUgYK.js → Loading-BAKnIASq.js} +4 -4
- package/dist/{Loading-C2pY-4fA.cjs → Loading-BSqhKOle.cjs} +1 -1
- package/dist/MessageBox-C35_ifsL.js +166 -0
- package/dist/MessageBox-C6NLihE1.cjs +1 -0
- package/dist/{Modal-Du7aVdWl.js → Modal-6kNs-9QU.js} +13 -12
- package/dist/Modal-BKvRyCXZ.cjs +1 -0
- package/dist/{Pagination-DatEegaF.cjs → Pagination-BRxRbWlU.cjs} +1 -1
- package/dist/{Pagination-CpbboRbF.js → Pagination-DTRhw83o.js} +1 -1
- package/dist/Select-B9umyfKd.cjs +1 -0
- package/dist/{Select-BHWa_6Q2.js → Select-DDsgKaDL.js} +13 -13
- package/dist/{Table-BNGO_7Rx.cjs → Table-B1BEfBJC.cjs} +1 -1
- package/dist/{Table-Cfs3XJgN.js → Table-DdWKhZAZ.js} +1 -1
- package/dist/{TimePicker-CYlcUTTM.js → TimePicker-77L1Vyxn.js} +12 -12
- package/dist/{TimePicker-DoGbwfkU.cjs → TimePicker-CsaiM5CQ.cjs} +1 -1
- package/dist/{Tooltip-BKPreZML.js → Tooltip-DH3oc4Wa.js} +18 -18
- package/dist/{Tooltip-DDjGLjoV.cjs → Tooltip-DP2yxQpo.cjs} +1 -1
- package/dist/base.css +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Badge.cjs +1 -0
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Form.cjs +1 -1
- package/dist/cjs/Loading.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/css/Announcement.css +1 -1
- package/dist/css/Badge.css +1 -0
- package/dist/css/Form.css +1 -1
- package/dist/css/Modal.css +1 -1
- package/dist/date-picker-CIAVlMqv.cjs +1 -0
- package/dist/{date-picker-CHP0eBuL.js → date-picker-Co0ySn01.js} +14 -14
- package/dist/dialog-shell-B7mE8A1p.cjs +1 -0
- package/dist/dialog-shell-FS5nSlBm.js +118 -0
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Badge.mjs +3 -0
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Form.mjs +1 -1
- package/dist/es/Loading.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +41 -40
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/{layer-DDm97-sb.js → layer-C1yCY0MO.js} +1 -1
- package/dist/{layer-BgiUZy_t.cjs → layer-DL1xVbJT.cjs} +1 -1
- package/dist/registry-Chcx2tDO.cjs +1 -0
- package/dist/registry-DbMCy1-n.js +87 -0
- package/dist/style/Badge.cjs +8 -0
- package/dist/style/Badge.mjs +8 -0
- package/dist/types/Announcement/type.d.cts +2 -2
- package/dist/types/Announcement/type.d.ts +2 -2
- package/dist/types/Badge/Badge.d.cts +3 -0
- package/dist/types/Badge/Badge.d.ts +3 -0
- package/dist/types/Badge/index.d.cts +5 -0
- package/dist/types/Badge/index.d.ts +5 -0
- package/dist/types/Badge/type.d.cts +31 -0
- package/dist/types/Badge/type.d.ts +31 -0
- package/dist/types/Form/FormItem.d.cts +1 -1
- package/dist/types/Form/FormItem.d.ts +1 -1
- package/dist/types/Form/context.d.cts +4 -2
- package/dist/types/Form/context.d.ts +4 -2
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/_shared/dialog.d.cts +5 -1
- package/dist/types/_shared/dialog.d.ts +5 -1
- package/dist/types/global.d.cts +2 -0
- package/dist/types/global.d.ts +2 -0
- package/dist/types/index.d.cts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/registry.d.cts +2 -1
- package/dist/types/registry.d.ts +2 -1
- package/package.json +1 -1
- package/dist/Announcement-D0hZE2sM.cjs +0 -1
- package/dist/Announcement-DzzaTvcO.js +0 -212
- package/dist/Drawer-DcbgMkub.cjs +0 -1
- package/dist/Drawer-yM_r1M0H.js +0 -112
- package/dist/Dropdown-PHqXNiAZ.cjs +0 -1
- package/dist/Form-BkyDHPEI.cjs +0 -1
- package/dist/Form-D_Uv-8HG.js +0 -449
- package/dist/MessageBox-D7Ib1f7K.cjs +0 -1
- package/dist/MessageBox-DDP6UWFU.js +0 -141
- package/dist/Modal-DPxZEr2v.cjs +0 -1
- package/dist/Select-C6O0tmM_.cjs +0 -1
- package/dist/date-picker-Be_1wA3S.cjs +0 -1
- package/dist/dialog-shell-CdYlPT9f.js +0 -111
- package/dist/dialog-shell-CzeGytVj.cjs +0 -1
- package/dist/registry-BUQSQSwB.js +0 -85
- package/dist/registry-DF1N2ITX.cjs +0 -1
- package/dist/types/Announcement/host.d.cts +0 -12
- package/dist/types/Announcement/host.d.ts +0 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./state-BuUx1onZ.cjs"),t=require("./refs-DCqd87V8.cjs"),n=require("./content-DCGQZQp8.cjs"),r=require("./client-BkoqeUs3.cjs"),i=require("./number-B7qJF_ZY.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-DL1xVbJT.cjs"),o=require("./dialog-shell-B7mE8A1p.cjs");let s=require("lucide-react"),c=require("react"),l=require("react/jsx-runtime");var u=(0,c.forwardRef)((u,d)=>{let{open:f,defaultOpen:p=!1,title:m,header:h,footer:g,placement:_=`right`,width:v=360,height:y=320,mask:b=!0,closeOnClickOverlay:x=!0,closeOnPressEscape:S=!0,showClose:C=!0,lockScroll:w=!0,destroyOnClose:T=!1,zIndex:E,className:D,style:O,children:te,onClick:ne,onChange:k,onOpen:A,onClose:j,"aria-label":M,"aria-labelledby":N,"aria-describedby":P,...F}=u,I=r.t(),L=typeof O?.zIndex==`number`?O.zIndex:void 0,R=a.a({defaultZIndex:a.r.modal,zIndex:E??L,withMask:!0}),z=(0,c.useRef)(null),B=(0,c.useMemo)(()=>t.n(z,d),[d]),V=(0,c.useRef)(!1),H=e.t(u,`open`),[U,W]=e.n({value:!!f,defaultValue:p,controlled:H,onChange:k}),G=(0,c.useCallback)(()=>W(!1),[W]),{isTopLayer:K}=o.i({active:I&&U,layer:R.layer,containerRef:z,closeOnPressEscape:S,lockScroll:w,onRequestClose:G}),q=ee.t(`vl-drawer-title`);(0,c.useEffect)(()=>{let e=V.current;U&&!e?A?.():!U&&e&&j?.(),V.current=U},[U,A,j]);let J=()=>{x&&K()&&G()},Y=e=>{e.stopPropagation(),ne?.(e)},X=[`vl-drawer`,`is-${_}`,D||``].filter(Boolean).join(` `),Z={...O};R.zIndex!==void 0&&(Z.zIndex=R.zIndex),_===`left`||_===`right`?(Z.width=i.n(v)??`360px`,Z.height=`100vh`):(Z.height=i.n(y)??`320px`,Z.width=`100vw`);let Q=h??(m?(0,l.jsx)(`div`,{id:q,className:`vl-drawer__title`,children:m}):null),$=N??(!h&&m?q:void 0),re=M??($?void 0:typeof m==`string`?m:`抽屉`);return(0,l.jsx)(a.t,{layer:R.layer,children:(0,l.jsxs)(o.t,{clientReady:I,open:U,mask:b,destroyOnClose:T,maskUnmountOnExit:T,maskTransitionName:`vl-drawer-mask`,transitionName:`vl-drawer-${_}`,maskClassName:`vl-drawer__mask`,panelClassName:X,panelStyle:Z,maskStyle:R.maskZIndex===void 0?void 0:{zIndex:R.maskZIndex},panelRef:B,role:`dialog`,ariaLabel:re,ariaLabelledBy:$,ariaDescribedBy:P,onMaskClick:J,onPanelClick:Y,panelProps:F,children:[n.t(Q)||C?(0,l.jsx)(`div`,{className:`vl-drawer__header`,children:(0,l.jsxs)(`div`,{className:`vl-drawer__headerInner`,children:[(0,l.jsx)(`div`,{className:`vl-drawer__headerMain`,children:Q}),C?(0,l.jsx)(`button`,{type:`button`,className:`vl-drawer__close`,"aria-label":`关闭抽屉`,onClick:G,children:(0,l.jsx)(s.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,l.jsx)(`div`,{className:`vl-drawer__body`,children:te}),n.t(g)?(0,l.jsx)(`div`,{className:`vl-drawer__footer`,children:g}):null]})})});u.displayName=`VlDrawer`;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}});
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { t as e } from "./icon-Cbvuv4yF.js";
|
|
2
2
|
import { t } from "./effect-nifYL_rH.js";
|
|
3
3
|
import { n, t as r } from "./state-BSDh-Ob2.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as ie } from "./
|
|
8
|
-
import {
|
|
9
|
-
import { t as ce } from "./
|
|
4
|
+
import { n as ee } from "./refs-D5IYOBaf.js";
|
|
5
|
+
import { t as te } from "./Transition-DiO4GsP3.js";
|
|
6
|
+
import { t as ne } from "./client-pj_wzx28.js";
|
|
7
|
+
import { r as re, t as ie } from "./floating-CqdcJWk2.js";
|
|
8
|
+
import { t as ae } from "./id-CHixuHb7.js";
|
|
9
|
+
import { a as oe, r as se, t as ce } from "./layer-C1yCY0MO.js";
|
|
10
10
|
import { i as le } from "./focus-BDDJyKk3.js";
|
|
11
11
|
import { Fragment as ue, cloneElement as de, forwardRef as i, isValidElement as fe, useCallback as a, useEffect as pe, useMemo as o, useRef as s, useState as c } from "react";
|
|
12
12
|
import { jsx as l, jsxs as me } from "react/jsx-runtime";
|
|
13
13
|
import { createPortal as he } from "react-dom";
|
|
14
14
|
//#region components/Dropdown/Dropdown.tsx
|
|
15
15
|
var ge = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
16
|
-
let { open: _e, defaultOpen: ve = !1, disabled: f = !1, placement: p = "bottom-start", offset: m = 8, zIndex: ye, closeOnContentClick: be = !0, trigger: h = "hover", options: g = ge, closeOnOutsideClick: xe = !0, triggerContent: _, menuLabel: Se = "菜单", className: v, style: y, children: Ce, onChange: we, onOpen: b, onClose: x, onSelect: Te, onCommand: Ee, "aria-label": S, "aria-labelledby": De, ...Oe } = i, ke = s(null), C = s(null), w = s(null), T = s([]), E = s(null), D = s(null), O = s(null), k = s(null), Ae = o(() =>
|
|
17
|
-
defaultZIndex:
|
|
16
|
+
let { open: _e, defaultOpen: ve = !1, disabled: f = !1, placement: p = "bottom-start", offset: m = 8, zIndex: ye, closeOnContentClick: be = !0, trigger: h = "hover", options: g = ge, closeOnOutsideClick: xe = !0, triggerContent: _, menuLabel: Se = "菜单", className: v, style: y, children: Ce, onChange: we, onOpen: b, onClose: x, onSelect: Te, onCommand: Ee, "aria-label": S, "aria-labelledby": De, ...Oe } = i, ke = s(null), C = s(null), w = s(null), T = s([]), E = s(null), D = s(null), O = s(null), k = s(null), Ae = o(() => ee(ke, d), [d]), A = ne(), je = oe({
|
|
17
|
+
defaultZIndex: se.dropdown,
|
|
18
18
|
zIndex: ye
|
|
19
19
|
}), Me = r(i, "open"), [j, Ne] = n({
|
|
20
20
|
value: !!_e,
|
|
21
21
|
defaultValue: ve,
|
|
22
22
|
controlled: Me,
|
|
23
23
|
onChange: we
|
|
24
|
-
}), M = j && !f, [N, Pe] = c(-1), [Fe, P] = c({}), [Ie, F] = c(p), [I, L] = c(!1), [R, z] = c(M), [Le, B] = c(!1), V =
|
|
24
|
+
}), M = j && !f, [N, Pe] = c(-1), [Fe, P] = c({}), [Ie, F] = c(p), [I, L] = c(!1), [R, z] = c(M), [Le, B] = c(!1), V = ae("vl-dropdown-menu"), Re = a((e) => `${V}-option-${e}`, [V]), H = o(() => g.flatMap((e, t) => u(e) ? [t] : []), [g]), ze = H.length > 0, Be = g.some((e) => !e.divider), U = H.includes(N) ? N : H[0] ?? -1, Ve = o(() => [
|
|
25
25
|
"vl-dropdown",
|
|
26
26
|
M ? "is-open" : "",
|
|
27
27
|
f ? "is-disabled" : "",
|
|
@@ -100,7 +100,7 @@ var ge = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
|
100
100
|
height: 0
|
|
101
101
|
} : C.current?.getBoundingClientRect();
|
|
102
102
|
if (!n) return;
|
|
103
|
-
let r =
|
|
103
|
+
let r = ie({
|
|
104
104
|
anchorRect: n,
|
|
105
105
|
floatingRect: e.getBoundingClientRect(),
|
|
106
106
|
placement: p,
|
|
@@ -204,7 +204,7 @@ var ge = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
|
204
204
|
}, [p]), rt = a(() => {
|
|
205
205
|
M || (z(!1), nt());
|
|
206
206
|
}, [M, nt]), it = a(() => K(!1), [K]), at = a(() => K(!1, !0), [K]);
|
|
207
|
-
|
|
207
|
+
re({
|
|
208
208
|
active: M && A,
|
|
209
209
|
rootRef: ke,
|
|
210
210
|
floatingRef: w,
|
|
@@ -232,7 +232,7 @@ var ge = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
|
232
232
|
"vl-dropdown__panel",
|
|
233
233
|
`is-${Ie}`,
|
|
234
234
|
I ? "is-positioned" : ""
|
|
235
|
-
].filter(Boolean).join(" "), lt = /* @__PURE__ */ l(
|
|
235
|
+
].filter(Boolean).join(" "), lt = /* @__PURE__ */ l(te, {
|
|
236
236
|
show: A ? Le : M,
|
|
237
237
|
name: "vl-dropdown",
|
|
238
238
|
forceMount: A,
|
|
@@ -289,7 +289,7 @@ var ge = [], u = (e) => !!(e && !e.disabled && !e.divider), d = i((i, d) => {
|
|
|
289
289
|
})
|
|
290
290
|
})
|
|
291
291
|
});
|
|
292
|
-
return /* @__PURE__ */ l(
|
|
292
|
+
return /* @__PURE__ */ l(ce, {
|
|
293
293
|
layer: je.layer,
|
|
294
294
|
children: /* @__PURE__ */ me("div", {
|
|
295
295
|
ref: Ae,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./icon-DRLyKu8p.cjs"),t=require("./effect-BpNxm_06.cjs"),n=require("./state-BuUx1onZ.cjs"),r=require("./refs-DCqd87V8.cjs"),ee=require("./Transition-X_89ga-e.cjs"),te=require("./client-BkoqeUs3.cjs"),i=require("./floating-5PRFyI8D.cjs"),ne=require("./id-CF0zOP1G.cjs"),a=require("./layer-DL1xVbJT.cjs"),re=require("./focus-D-h8CbGr.cjs");let o=require("react"),s=require("react/jsx-runtime"),ie=require("react-dom");var ae=[],c=e=>!!(e&&!e.disabled&&!e.divider),l=(0,o.forwardRef)((l,u)=>{let{open:d,defaultOpen:oe=!1,disabled:f=!1,placement:p=`bottom-start`,offset:m=8,zIndex:se,closeOnContentClick:h=!0,trigger:g=`hover`,options:_=ae,closeOnOutsideClick:ce=!0,triggerContent:v,menuLabel:le=`菜单`,className:ue,style:de,children:fe,onChange:pe,onOpen:me,onClose:he,onSelect:ge,onCommand:_e,"aria-label":y,"aria-labelledby":ve,...ye}=l,b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)([]),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(null),D=(0,o.useRef)(null),be=(0,o.useMemo)(()=>r.n(b,u),[u]),O=te.t(),k=a.a({defaultZIndex:a.r.dropdown,zIndex:se}),xe=n.t(l,`open`),[A,j]=n.n({value:!!d,defaultValue:oe,controlled:xe,onChange:pe}),M=A&&!f,[N,P]=(0,o.useState)(-1),[Se,F]=(0,o.useState)({}),[Ce,I]=(0,o.useState)(p),[L,R]=(0,o.useState)(!1),[z,B]=(0,o.useState)(M),[we,V]=(0,o.useState)(!1),H=ne.t(`vl-dropdown-menu`),Te=(0,o.useCallback)(e=>`${H}-option-${e}`,[H]),U=(0,o.useMemo)(()=>_.flatMap((e,t)=>c(e)?[t]:[]),[_]),Ee=U.length>0,De=_.some(e=>!e.divider),W=U.includes(N)?N:U[0]??-1,Oe=(0,o.useMemo)(()=>[`vl-dropdown`,M?`is-open`:``,f?`is-disabled`:``,ue||``].filter(Boolean).join(` `),[M,f,ue]),ke=(0,o.useMemo)(()=>({"--vl-dropdown-offset":`${m}px`,...de}),[m,de]),G=(0,o.useCallback)(()=>{let e=w.current;if(e&&e.isConnected){e.focus();return}(x.current?.querySelector(re.i))?.focus()},[]),K=(0,o.useCallback)(()=>{let e=document.activeElement;if(e&&x.current?.contains(e)){w.current=e;return}w.current=x.current?.querySelector(`button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])`)??null},[]),q=(0,o.useCallback)((e,t=!1)=>{if(!(e&&f)){if(A===e){t&&G();return}e&&(K(),R(!1),F({}),I(p)),j(e),e?me?.():(he?.(),t&&window.requestAnimationFrame(G))}},[f,A,p,G,K,j,me,he]),J=(0,o.useCallback)(()=>{E.current!==null&&(window.clearTimeout(E.current),E.current=null)},[]),Y=(0,o.useCallback)(()=>{J(),E.current=window.setTimeout(()=>{let e=document.activeElement;e&&(x.current?.contains(e)||S.current?.contains(e))||q(!1)},160)},[J,q]),X=(0,o.useCallback)(e=>{c(_[e])&&(P(e),C.current[e]?.focus())},[_]),Z=(0,o.useCallback)(()=>{let e=U[0];e!==void 0&&X(e)},[U,X]),Q=(0,o.useCallback)(()=>{let e=U.at(-1);e!==void 0&&X(e)},[U,X]),Ae=(0,o.useCallback)(e=>{if(!U.length)return;let t=U.indexOf(N),n=t<0?e>0?0:U.length-1:(t+e+U.length)%U.length;X(U[n])},[U,N,X]),$=(0,o.useCallback)(()=>{if(!M)return;let e=S.current;if(!e)return;let t=T.current,n=t?{left:t.x,right:t.x,top:t.y,bottom:t.y,width:0,height:0}:x.current?.getBoundingClientRect();if(!n)return;let r=i.t({anchorRect:n,floatingRect:e.getBoundingClientRect(),placement:p,offset:m});I(r.placement),F({left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`}),R(!0)},[M,p,m]),je=e=>{f||g!==`click`||(e.stopPropagation(),T.current=null,q(!M))},Me=()=>{f||g!==`hover`||(T.current=null,J(),q(!0))},Ne=()=>{f||g!==`hover`||Y()},Pe=()=>{f||g!==`hover`||(T.current=null,J(),q(!0))},Fe=e=>{e.currentTarget.contains(e.relatedTarget)||g===`hover`&&Y()},Ie=e=>{f||g!==`context-menu`||(e.preventDefault(),e.stopPropagation(),T.current={x:e.clientX,y:e.clientY},q(!0))},Le=()=>{g===`hover`&&J()},Re=()=>{g===`hover`&&Y()},ze=()=>J(),Be=e=>{c(e)&&(e.onClick?.(e),ge?.(e),_e?.(e.value,e),h&&q(!1,!0))},Ve=()=>{_.length||!h||q(!1,!0)},He=e=>{if(!f){if(T.current=null,e.key===`Escape`&&M){e.preventDefault(),q(!1,!0);return}e.key===`ArrowDown`||e.key===`Enter`||e.key===` `?(e.preventDefault(),K(),M?Z():(D.current=`first`,q(!0))):e.key===`ArrowUp`&&(e.preventDefault(),K(),M?Q():(D.current=`last`,q(!0)))}},Ue=e=>{if(M){if(e.key===`Escape`){e.preventDefault(),q(!1,!0);return}if(e.key===`Tab`){q(!1);return}if(Ee){if(e.key===`ArrowDown`)e.preventDefault(),Ae(1);else if(e.key===`ArrowUp`)e.preventDefault(),Ae(-1);else if(e.key===`Home`)e.preventDefault(),Z();else if(e.key===`End`)e.preventDefault(),Q();else if(e.key===`Enter`||e.key===` `){e.preventDefault();let t=_[N];t&&Be(t)}}}};(0,o.useEffect)(()=>{f&&A&&q(!1)},[f,A,q]),t.t(()=>{if(!O)return;if(!M){V(!1);return}if(!z){B(!0);return}$(),V(!0);let e=D.current;D.current=null;let t=window.requestAnimationFrame(()=>{$(),e===`first`?Z():e===`last`&&Q()});return()=>window.cancelAnimationFrame(t)},[M,O,z,Z,Q,$]);let We=(0,o.useCallback)(()=>{R(!1),F({}),I(p)},[p]),Ge=(0,o.useCallback)(()=>{M||(B(!1),We())},[M,We]),Ke=(0,o.useCallback)(()=>q(!1),[q]),qe=(0,o.useCallback)(()=>q(!1,!0),[q]);i.r({active:M&&O,rootRef:b,floatingRef:S,closeOnOutsideClick:ce&&g!==`hover`,ignoreEscapeInsideFloating:!0,onOutsideClick:Ke,onEscape:qe,onViewportChange:$}),(0,o.useEffect)(()=>()=>J(),[J]);let Je={"aria-haspopup":`menu`,"aria-expanded":M,"aria-controls":H,"aria-disabled":f||void 0,...y?{"aria-label":y}:{},...ve?{"aria-labelledby":ve}:{},tabIndex:f?-1:void 0},Ye=(0,o.isValidElement)(v)&&v.type!==o.Fragment?(0,o.cloneElement)(v,Je):(0,s.jsx)(`button`,{type:`button`,className:`vl-dropdown__defaultTrigger`,disabled:f,...Je,children:v??`Menu`}),Xe=[`vl-dropdown__panel`,`is-${Ce}`,L?`is-positioned`:``].filter(Boolean).join(` `),Ze=(0,s.jsx)(ee.t,{show:O?we:M,name:`vl-dropdown`,forceMount:O,deferEffects:!O,onAfterLeave:Ge,children:(0,s.jsx)(`div`,{ref:S,id:H,className:Xe,style:{...Se,zIndex:k.zIndex,visibility:O&&!L?`hidden`:`visible`},role:`menu`,"aria-label":le,"aria-hidden":!M||void 0,onClick:Ve,onMouseEnter:Le,onMouseLeave:Re,onFocus:ze,onKeyDown:Ue,children:(0,s.jsx)(`div`,{className:`vl-dropdown__content`,children:De?_.map((t,n)=>t.divider?(0,s.jsx)(`div`,{className:`vl-dropdown__divider`,role:`separator`},`divider-${n}`):(0,s.jsxs)(`div`,{ref:e=>{C.current[n]=e},id:Te(n),className:[`vl-dropdown__option`,t.status?`is-${t.status}`:``,t.disabled?`is-disabled`:``,W===n?`is-active`:``].filter(Boolean).join(` `),role:`menuitem`,tabIndex:W===n&&!t.disabled?0:-1,"aria-disabled":t.disabled||void 0,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{c(t)&&P(n)},onClick:e=>{e.stopPropagation(),Be(t)},children:[t.icon?e.t(t.icon,`vl-dropdown__option-icon`):null,(0,s.jsx)(`span`,{className:`vl-dropdown__option-label`,children:t.label??``})]},t.value??n)):fe})})});return(0,s.jsx)(a.t,{layer:k.layer,children:(0,s.jsxs)(`div`,{ref:be,className:Oe,style:ke,...ye,onMouseEnter:Me,onMouseLeave:Ne,onFocus:Pe,onBlur:Fe,children:[(0,s.jsx)(`div`,{ref:x,className:`vl-dropdown__trigger`,onClick:je,onContextMenu:Ie,onKeyDown:He,children:Ye}),z?O?(0,ie.createPortal)(Ze,document.body):Ze:null]})})});l.displayName=`VlDropdown`;var u=l,d=l;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return d}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./id-CF0zOP1G.cjs"),i=require("./focus-D-h8CbGr.cjs"),a=require("./Tooltip-DP2yxQpo.cjs");let o=require("react"),s=require("react/jsx-runtime");var c=[],l=Object.freeze({value:void 0,errors:c,isValidating:!1}),u=(0,o.createContext)(null),d=u.Provider,f=()=>(0,o.useContext)(u),p=(0,o.createContext)(null),m=p.Provider,h=()=>(0,o.useContext)(p),g=(0,o.createContext)(null).Provider,ee=e=>{let t=f(),n=(0,o.useCallback)(n=>!e||!t?()=>{}:t.subscribeField(e,n),[t,e]),r=(0,o.useCallback)(()=>!e||!t?l:t.getFieldState(e),[t,e]);return(0,o.useSyncExternalStore)(n,r,r)},_=[`blur`,`submit`],v=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,te=e=>e?Array.isArray(e)?e:[e]:_,y=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)&&e.length===0,b=(e,t,n,r)=>{let i=t??e;if(n.required&&y(r))return n.message??`请输入${i}`;if(y(r))return;if(n.type&&!(n.type===`array`?Array.isArray(r):n.type===`email`?typeof r==`string`&&v.test(r):typeof r===n.type)||(n.pattern&&(n.pattern.lastIndex=0),n.pattern&&(typeof r!=`string`||!n.pattern.test(r))))return n.message??`${i}格式不正确`;let a=typeof r==`number`?r:typeof r==`string`||Array.isArray(r)?r.length:null;if(n.len!==void 0&&a!==null&&a!==n.len)return n.message??`${i}长度必须为 ${n.len}`;if(n.min!==void 0&&a!==null&&a<n.min)return n.message??`${i}不能小于 ${n.min}`;if(n.max!==void 0&&a!==null&&a>n.max)return n.message??`${i}不能大于 ${n.max}`},x=(0,o.forwardRef)((n,r)=>{let{values:a,defaultValues:l={},layout:u=`vertical`,labelWidth:f,labelAlign:p=u===`horizontal`?`right`:`left`,validateTrigger:h,className:ee,style:_,children:v,onValuesChange:y,onFinish:x,onFinishError:S,onFinishFailed:C,noValidate:w=!0,...T}=n,E=t.t(n,`values`),D=(0,o.useMemo)(()=>E?a??{}:null,[E,a]),O=(0,o.useRef)(D??l),k=(0,o.useRef)({}),A=(0,o.useRef)({}),j=(0,o.useRef)(!1),[M,N]=(0,o.useState)(!1),P=(0,o.useRef)(null),F=(0,o.useRef)(new Map),I=(0,o.useRef)(new Map),L=(0,o.useRef)(new Map),R=(0,o.useRef)(new Map),z=(0,o.useRef)(y),B=(0,o.useRef)(x),V=(0,o.useRef)(S),H=(0,o.useRef)(C);e.t(()=>{z.current=y,B.current=x,V.current=S,H.current=C});let U=(0,o.useMemo)(()=>te(h),[h]),W=(0,o.useCallback)(e=>{let t=L.current.get(e);t&&t.forEach(e=>e())},[]),G=(0,o.useCallback)((e,t)=>{let n=L.current.get(e);return n||(n=new Set,L.current.set(e,n)),n.add(t),()=>{n?.delete(t),n&&n.size===0&&L.current.delete(e)}},[]),K=(0,o.useCallback)(e=>{let t=E?void 0:O.current[e],n=k.current[e]??c,r=!!A.current[e],i=R.current.get(e);if(i&&Object.is(i.value,t)&&i.errors===n&&i.isValidating===r)return i;let a={value:t,errors:n,isValidating:r};return R.current.set(e,a),a},[E]);e.t(()=>{D!==null&&(O.current=D)},[D]);let q=(0,o.useCallback)(e=>{let t=k.current;k.current=e;let n=new Set;for(let r of Object.keys(t))t[r]!==e[r]&&n.add(r);for(let r of Object.keys(e))t[r]!==e[r]&&n.add(r);n.forEach(e=>{W(e)})},[W]),J=(0,o.useCallback)(e=>(F.current.set(e.name,e),()=>{if(F.current.get(e.name)?.token===e.token){if(F.current.delete(e.name),I.current.delete(e.name),R.current.delete(e.name),Object.prototype.hasOwnProperty.call(k.current,e.name)){let t={...k.current};delete t[e.name],q(t)}if(A.current[e.name]){let t={...A.current};delete t[e.name],A.current=t,W(e.name)}}}),[q,W]),Y=(0,o.useCallback)((e,t)=>{let n={...O.current,[e]:t};return E||(O.current=n,W(e)),z.current?.({[e]:t},n),n},[E,W]),X=(0,o.useCallback)(async(e,t)=>{let n=F.current.get(e);if(!n)return[];let r=t??O.current,i=r[e],a=Symbol(e);I.current.set(e,a),A.current={...A.current,[e]:!0},W(e);let o=[],{rules:s,label:c}=n.metaRef.current;for(let t of s){let n=b(e,c,t,i);if(n&&o.push(n),t.validator)try{let e=await t.validator(i,r);e&&o.push(t.message??e)}catch(e){let n=e instanceof Error?e.message:`校验失败`;o.push(t.message??n)}}if(F.current.get(e)?.token!==n.token||I.current.get(e)!==a)return o;let l={...k.current};return o.length?l[e]=o:delete l[e],q(l),A.current={...A.current,[e]:!1},W(e),o},[q,W]),Z=(0,o.useCallback)(async()=>{let e=O.current,t=[...F.current.values()],n=await Promise.all(t.map(async t=>{let n=X(t.name,e);return[t,I.current.get(t.name),await n]})),r={...k.current};return n.forEach(([e,t,n])=>{F.current.get(e.name)?.token===e.token&&I.current.get(e.name)===t&&(n.length?r[e.name]=n:delete r[e.name])}),q(r),{valid:Object.keys(r).length===0,values:e,errors:r}},[q,X]),Q=(0,o.useCallback)(()=>{if(P.current)return P.current;let e=(async()=>{j.current=!0,N(!0);try{let e=await Z();if(e.valid)try{await B.current?.(e.values)}catch(t){V.current?.(t,e.values)}else{H.current?.(e.errors,e.values);let t=[...F.current.keys()].find(t=>e.errors[t]);t&&i.n(F.current.get(t)?.metaRef.current.element??null)}return e}finally{j.current=!1,N(!1)}})();return P.current=e,e.then(()=>{P.current===e&&(P.current=null)},()=>{P.current===e&&(P.current=null)}),e},[Z]),ne=(0,o.useCallback)(e=>{let t=O.current,n={...t,...e};O.current=n;for(let r of Object.keys(e))Object.is(t[r],n[r])||W(r);z.current?.(e,n)},[W]),$=(0,o.useCallback)(()=>{let e={...l},t=O.current;O.current=e;let n=new Set([...Object.keys(t),...Object.keys(e)]),r=Object.fromEntries([...n].filter(n=>!Object.is(t[n],e[n])).map(t=>[t,e[t]]));Object.keys(r).length&&z.current?.(r,e),n.forEach(n=>{Object.is(t[n],e[n])||W(n)}),q({}),I.current.clear();let i=A.current;A.current={},Object.keys(i).forEach(e=>{i[e]&&W(e)})},[q,l,W]);(0,o.useImperativeHandle)(r,()=>({getValues:()=>O.current,setValues:ne,reset:$,validate:Z,submit:Q,isSubmitting:()=>j.current,getErrors:()=>k.current}),[$,ne,Q,Z]);let re=(0,o.useMemo)(()=>({defaultValidateTrigger:U,registerField:J,updateField:Y,validateField:X,subscribeField:G,getFieldState:K}),[U,K,J,G,Y,X]),ie=(0,o.useMemo)(()=>({get values(){return O.current},get errors(){return k.current},get validating(){return A.current},defaultValidateTrigger:U,registerField:J,updateField:Y,validateField:X}),[U,J,Y,X]),ae={..._,...f===void 0?null:{"--vl-form-label-width":typeof f==`number`?`${f}px`:f}},oe=[`vl-form`,`vl-form--${u}`,`vl-form--label-${p}`,M?`is-submitting`:``,ee||``].filter(Boolean).join(` `),se=e=>{e.preventDefault(),Q()},ce=e=>{e.preventDefault(),$()};return(0,s.jsx)(d,{value:re,children:(0,s.jsx)(m,{value:D,children:(0,s.jsx)(g,{value:ie,children:(0,s.jsx)(`form`,{...T,className:oe,style:ae,"aria-busy":M||void 0,noValidate:w,onSubmit:se,onReset:ce,children:v})})})})});x.displayName=`VlForm`;var S=[],C=[],w=(e,t)=>e?Array.isArray(e)?e:[e]:t,T=(e,t)=>{if(e===`checked`&&typeof t[1]==`boolean`)return t[1];let n=t[0];if(n&&typeof n==`object`&&`target`in n){let t=n.target;if(t)return e===`checked`?t.checked:t.value}return n},E=({id:t,content:n})=>{let r=(0,o.useRef)(null),[i,c]=(0,o.useState)(!1),l=(0,o.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.scrollWidth>e.clientWidth;c(e=>e===t?e:t)},[]);return e.t(()=>{l();let e=r.current,t=typeof ResizeObserver>`u`?null:new ResizeObserver(l);return e&&t?.observe(e),window.addEventListener(`resize`,l,{passive:!0}),()=>{t?.disconnect(),window.removeEventListener(`resize`,l)}},[n,l]),(0,s.jsx)(a.t,{id:t,className:`vl-form-item__help-tooltip`,content:n,disabled:!i,children:(0,s.jsx)(`div`,{ref:r,className:`vl-form-item__help is-text`,tabIndex:i?0:void 0,children:n})})},D=(0,o.forwardRef)((t,i)=>{let{formControlled:a,formValue:c,name:l,label:u,required:d=!1,rules:p=S,help:m,valuePropName:h=`value`,trigger:g=`onChange`,getValueFromEvent:_,validateTrigger:v,className:te,children:y,...b}=t,x=f(),D=x?.registerField,O=(0,o.isValidElement)(y)?y:null,k=O?.props??{},A=r.t(`vl-form-control`,k.id),j=r.t(`vl-form-label`),M=r.t(`vl-form-help`),N=r.t(`vl-form-error`),P=(0,o.useRef)(null),F=x?.defaultValidateTrigger??C,I=(0,o.useMemo)(()=>w(v,F),[F,v]),L=(0,o.useMemo)(()=>d&&!p.some(e=>e.required)?[{required:!0},...p]:p,[d,p]),R=d||L.some(e=>e.required),z=m!=null&&typeof m!=`boolean`&&m!==``,B=ee(l),V=B.errors,H=B.isValidating,U=a?c:B.value,W=I.includes(`change`)||V.length>0,[G]=(0,o.useState)(()=>Symbol(`form-field`)),K=(0,o.useRef)({label:void 0,rules:S,element:null});e.t(()=>{K.current.label=typeof u==`string`?u:void 0,K.current.rules=L},[L,u]),(0,o.useEffect)(()=>{if(!(!l||!D))return D({name:l,token:G,metaRef:K})},[G,l,D]);let q=V.length>0,J=z&&!q,Y={id:A,"aria-describedby":[k[`aria-describedby`],q?N:void 0,J?M:void 0].filter(Boolean).join(` `)||void 0,"aria-labelledby":[k[`aria-labelledby`],u===void 0?void 0:j].filter(Boolean).join(` `)||void 0,"aria-invalid":V.length>0||void 0,"aria-busy":H||void 0,ref:e=>{P.current=e,K.current.element=e,n.t(k.ref,e)}};if(l&&x){Y[h]=U;let e=k[g];if(Y[g]=(...t)=>{typeof e==`function`&&e(...t);let n=_?_(...t):T(h,t),r=x.updateField(l,n);(W||g===`onBlur`&&I.includes(`blur`))&&x.validateField(l,r)},g!==`onBlur`){let e=k.onBlur;Y.onBlur=t=>{typeof e==`function`&&e(t),I.includes(`blur`)&&x.validateField(l)}}}let X=O?(0,o.cloneElement)(O,Y):y,Z=[`vl-form-item`,l?`has-name`:``,u===void 0?``:`has-label`,z?`has-help`:``,V.length?`is-error`:``,H?`is-validating`:``,R?`is-required`:``,te||``].filter(Boolean).join(` `),Q=H||V.length>0;return(0,s.jsxs)(`div`,{...b,ref:i,className:Z,children:[u===void 0?null:(0,s.jsxs)(`label`,{id:j,className:`vl-form-item__label`,htmlFor:A,children:[R?(0,s.jsx)(`span`,{className:`vl-form-item__required`,"aria-hidden":`true`,children:`*`}):null,u]}),(0,s.jsxs)(`div`,{className:`vl-form-item__control`,children:[(0,s.jsxs)(`div`,{className:`vl-form-item__field`,children:[(0,s.jsx)(`div`,{className:`vl-form-item__control-input`,children:X}),l?(0,s.jsxs)(`div`,{className:`vl-form-item__validation${Q?``:` is-empty`}`,"aria-hidden":!Q||void 0,children:[H?(0,s.jsxs)(`div`,{className:`vl-form-item__status`,role:`status`,"aria-label":`校验中`,children:[(0,s.jsx)(`span`,{className:`vl-form-item__spinner`,"aria-hidden":`true`}),(0,s.jsx)(`span`,{children:`校验中`})]}):null,V.length?(0,s.jsx)(`div`,{id:N,className:`vl-form-item__error`,role:`alert`,children:V.map(e=>(0,s.jsx)(`div`,{children:e},e))}):null]}):null]}),J?(0,s.jsx)(`div`,{className:`vl-form-item__feedback`,children:typeof m==`string`||typeof m==`number`?(0,s.jsx)(E,{id:M,content:m}):(0,s.jsx)(`div`,{id:M,className:`vl-form-item__help`,children:m})}):null]})]})}),O=(0,o.memo)(D,(e,t)=>{if(e.formControlled!==t.formControlled||!Object.is(e.formValue,t.formValue)||e.name!==t.name||e.label!==t.label||e.required!==t.required||e.help!==t.help||e.valuePropName!==t.valuePropName||e.trigger!==t.trigger||e.getValueFromEvent!==t.getValueFromEvent||e.validateTrigger!==t.validateTrigger||e.className!==t.className||e.style!==t.style)return!1;if(e.rules!==t.rules){let n=e.rules??S,r=t.rules??S;if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1}if(e.children!==t.children){let n=e.children,r=t.children;if(!(0,o.isValidElement)(n)||!(0,o.isValidElement)(r))return Object.is(n,r);if(n.type!==r.type||n.key!==r.key)return!1;let i=n.props,a=r.props,s=Object.keys(i),c=Object.keys(a);if(s.length!==c.length)return!1;for(let e of s)if(!Object.is(i[e],a[e]))return!1}let n=new Set([`formControlled`,`formValue`,`name`,`label`,`required`,`rules`,`help`,`valuePropName`,`trigger`,`getValueFromEvent`,`validateTrigger`,`className`,`style`,`children`]),r=e,i=t;for(let t of Object.keys(e))if(!n.has(t)&&!Object.is(r[t],i[t]))return!1;for(let e of Object.keys(t))if(!n.has(e)&&!Object.is(r[e],i[e]))return!1;return!0}),k=(0,o.forwardRef)((e,t)=>{let n=h();return(0,s.jsx)(O,{...e,ref:t,formControlled:n!==null,formValue:e.name?n?.[e.name]:void 0})});k.displayName=`VlFormItem`;var A=Object.assign(x,{Item:k}),j=k;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return A}});
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
+
import { t } from "./state-BSDh-Ob2.js";
|
|
3
|
+
import { t as n } from "./refs-D5IYOBaf.js";
|
|
4
|
+
import { t as r } from "./id-CHixuHb7.js";
|
|
5
|
+
import { n as i } from "./focus-BDDJyKk3.js";
|
|
6
|
+
import { t as a } from "./Tooltip-DH3oc4Wa.js";
|
|
7
|
+
import { cloneElement as o, createContext as s, forwardRef as c, isValidElement as l, memo as u, useCallback as d, useContext as f, useEffect as ee, useImperativeHandle as p, useMemo as m, useRef as h, useState as g, useSyncExternalStore as _ } from "react";
|
|
8
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
9
|
+
//#region components/Form/context.ts
|
|
10
|
+
var b = [], x = Object.freeze({
|
|
11
|
+
value: void 0,
|
|
12
|
+
errors: b,
|
|
13
|
+
isValidating: !1
|
|
14
|
+
}), S = s(null), te = S.Provider, C = () => f(S), w = s(null), ne = w.Provider, T = () => f(w), E = s(null).Provider, D = (e) => {
|
|
15
|
+
let t = C(), n = d((n) => !e || !t ? () => {} : t.subscribeField(e, n), [t, e]), r = d(() => !e || !t ? x : t.getFieldState(e), [t, e]);
|
|
16
|
+
return _(n, r, r);
|
|
17
|
+
}, O = ["blur", "submit"], k = /^[^\s@]+@[^\s@]+\.[^\s@]+$/, re = (e) => e ? Array.isArray(e) ? e : [e] : O, A = (e) => e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) && e.length === 0, j = (e, t, n, r) => {
|
|
18
|
+
let i = t ?? e;
|
|
19
|
+
if (n.required && A(r)) return n.message ?? `请输入${i}`;
|
|
20
|
+
if (A(r)) return;
|
|
21
|
+
if (n.type && !(n.type === "array" ? Array.isArray(r) : n.type === "email" ? typeof r == "string" && k.test(r) : typeof r === n.type) || (n.pattern && (n.pattern.lastIndex = 0), n.pattern && (typeof r != "string" || !n.pattern.test(r)))) return n.message ?? `${i}格式不正确`;
|
|
22
|
+
let a = typeof r == "number" ? r : typeof r == "string" || Array.isArray(r) ? r.length : null;
|
|
23
|
+
if (n.len !== void 0 && a !== null && a !== n.len) return n.message ?? `${i}长度必须为 ${n.len}`;
|
|
24
|
+
if (n.min !== void 0 && a !== null && a < n.min) return n.message ?? `${i}不能小于 ${n.min}`;
|
|
25
|
+
if (n.max !== void 0 && a !== null && a > n.max) return n.message ?? `${i}不能大于 ${n.max}`;
|
|
26
|
+
}, M = c((n, r) => {
|
|
27
|
+
let { values: a, defaultValues: o = {}, layout: s = "vertical", labelWidth: c, labelAlign: l = s === "horizontal" ? "right" : "left", validateTrigger: u, className: f, style: ee, children: _, onValuesChange: y, onFinish: x, onFinishError: S, onFinishFailed: C, noValidate: w = !0, ...T } = n, D = t(n, "values"), O = m(() => D ? a ?? {} : null, [D, a]), k = h(O ?? o), A = h({}), M = h({}), N = h(!1), [P, F] = g(!1), I = h(null), L = h(/* @__PURE__ */ new Map()), R = h(/* @__PURE__ */ new Map()), z = h(/* @__PURE__ */ new Map()), B = h(/* @__PURE__ */ new Map()), V = h(y), H = h(x), U = h(S), W = h(C);
|
|
28
|
+
e(() => {
|
|
29
|
+
V.current = y, H.current = x, U.current = S, W.current = C;
|
|
30
|
+
});
|
|
31
|
+
let G = m(() => re(u), [u]), K = d((e) => {
|
|
32
|
+
let t = z.current.get(e);
|
|
33
|
+
t && t.forEach((e) => e());
|
|
34
|
+
}, []), ie = d((e, t) => {
|
|
35
|
+
let n = z.current.get(e);
|
|
36
|
+
return n || (n = /* @__PURE__ */ new Set(), z.current.set(e, n)), n.add(t), () => {
|
|
37
|
+
n?.delete(t), n && n.size === 0 && z.current.delete(e);
|
|
38
|
+
};
|
|
39
|
+
}, []), ae = d((e) => {
|
|
40
|
+
let t = D ? void 0 : k.current[e], n = A.current[e] ?? b, r = !!M.current[e], i = B.current.get(e);
|
|
41
|
+
if (i && Object.is(i.value, t) && i.errors === n && i.isValidating === r) return i;
|
|
42
|
+
let a = {
|
|
43
|
+
value: t,
|
|
44
|
+
errors: n,
|
|
45
|
+
isValidating: r
|
|
46
|
+
};
|
|
47
|
+
return B.current.set(e, a), a;
|
|
48
|
+
}, [D]);
|
|
49
|
+
e(() => {
|
|
50
|
+
O !== null && (k.current = O);
|
|
51
|
+
}, [O]);
|
|
52
|
+
let q = d((e) => {
|
|
53
|
+
let t = A.current;
|
|
54
|
+
A.current = e;
|
|
55
|
+
let n = /* @__PURE__ */ new Set();
|
|
56
|
+
for (let r of Object.keys(t)) t[r] !== e[r] && n.add(r);
|
|
57
|
+
for (let r of Object.keys(e)) t[r] !== e[r] && n.add(r);
|
|
58
|
+
n.forEach((e) => {
|
|
59
|
+
K(e);
|
|
60
|
+
});
|
|
61
|
+
}, [K]), J = d((e) => (L.current.set(e.name, e), () => {
|
|
62
|
+
if (L.current.get(e.name)?.token === e.token) {
|
|
63
|
+
if (L.current.delete(e.name), R.current.delete(e.name), B.current.delete(e.name), Object.prototype.hasOwnProperty.call(A.current, e.name)) {
|
|
64
|
+
let t = { ...A.current };
|
|
65
|
+
delete t[e.name], q(t);
|
|
66
|
+
}
|
|
67
|
+
if (M.current[e.name]) {
|
|
68
|
+
let t = { ...M.current };
|
|
69
|
+
delete t[e.name], M.current = t, K(e.name);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}), [q, K]), Y = d((e, t) => {
|
|
73
|
+
let n = {
|
|
74
|
+
...k.current,
|
|
75
|
+
[e]: t
|
|
76
|
+
};
|
|
77
|
+
return D || (k.current = n, K(e)), V.current?.({ [e]: t }, n), n;
|
|
78
|
+
}, [D, K]), X = d(async (e, t) => {
|
|
79
|
+
let n = L.current.get(e);
|
|
80
|
+
if (!n) return [];
|
|
81
|
+
let r = t ?? k.current, i = r[e], a = Symbol(e);
|
|
82
|
+
R.current.set(e, a), M.current = {
|
|
83
|
+
...M.current,
|
|
84
|
+
[e]: !0
|
|
85
|
+
}, K(e);
|
|
86
|
+
let o = [], { rules: s, label: c } = n.metaRef.current;
|
|
87
|
+
for (let t of s) {
|
|
88
|
+
let n = j(e, c, t, i);
|
|
89
|
+
if (n && o.push(n), t.validator) try {
|
|
90
|
+
let e = await t.validator(i, r);
|
|
91
|
+
e && o.push(t.message ?? e);
|
|
92
|
+
} catch (e) {
|
|
93
|
+
let n = e instanceof Error ? e.message : "校验失败";
|
|
94
|
+
o.push(t.message ?? n);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (L.current.get(e)?.token !== n.token || R.current.get(e) !== a) return o;
|
|
98
|
+
let l = { ...A.current };
|
|
99
|
+
return o.length ? l[e] = o : delete l[e], q(l), M.current = {
|
|
100
|
+
...M.current,
|
|
101
|
+
[e]: !1
|
|
102
|
+
}, K(e), o;
|
|
103
|
+
}, [q, K]), Z = d(async () => {
|
|
104
|
+
let e = k.current, t = [...L.current.values()], n = await Promise.all(t.map(async (t) => {
|
|
105
|
+
let n = X(t.name, e);
|
|
106
|
+
return [
|
|
107
|
+
t,
|
|
108
|
+
R.current.get(t.name),
|
|
109
|
+
await n
|
|
110
|
+
];
|
|
111
|
+
})), r = { ...A.current };
|
|
112
|
+
return n.forEach(([e, t, n]) => {
|
|
113
|
+
L.current.get(e.name)?.token === e.token && R.current.get(e.name) === t && (n.length ? r[e.name] = n : delete r[e.name]);
|
|
114
|
+
}), q(r), {
|
|
115
|
+
valid: Object.keys(r).length === 0,
|
|
116
|
+
values: e,
|
|
117
|
+
errors: r
|
|
118
|
+
};
|
|
119
|
+
}, [q, X]), Q = d(() => {
|
|
120
|
+
if (I.current) return I.current;
|
|
121
|
+
let e = (async () => {
|
|
122
|
+
N.current = !0, F(!0);
|
|
123
|
+
try {
|
|
124
|
+
let e = await Z();
|
|
125
|
+
if (e.valid) try {
|
|
126
|
+
await H.current?.(e.values);
|
|
127
|
+
} catch (t) {
|
|
128
|
+
U.current?.(t, e.values);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
W.current?.(e.errors, e.values);
|
|
132
|
+
let t = [...L.current.keys()].find((t) => e.errors[t]);
|
|
133
|
+
t && i(L.current.get(t)?.metaRef.current.element ?? null);
|
|
134
|
+
}
|
|
135
|
+
return e;
|
|
136
|
+
} finally {
|
|
137
|
+
N.current = !1, F(!1);
|
|
138
|
+
}
|
|
139
|
+
})();
|
|
140
|
+
return I.current = e, e.then(() => {
|
|
141
|
+
I.current === e && (I.current = null);
|
|
142
|
+
}, () => {
|
|
143
|
+
I.current === e && (I.current = null);
|
|
144
|
+
}), e;
|
|
145
|
+
}, [Z]), oe = d((e) => {
|
|
146
|
+
let t = k.current, n = {
|
|
147
|
+
...t,
|
|
148
|
+
...e
|
|
149
|
+
};
|
|
150
|
+
k.current = n;
|
|
151
|
+
for (let r of Object.keys(e)) Object.is(t[r], n[r]) || K(r);
|
|
152
|
+
V.current?.(e, n);
|
|
153
|
+
}, [K]), $ = d(() => {
|
|
154
|
+
let e = { ...o }, t = k.current;
|
|
155
|
+
k.current = e;
|
|
156
|
+
let n = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]), r = Object.fromEntries([...n].filter((n) => !Object.is(t[n], e[n])).map((t) => [t, e[t]]));
|
|
157
|
+
Object.keys(r).length && V.current?.(r, e), n.forEach((n) => {
|
|
158
|
+
Object.is(t[n], e[n]) || K(n);
|
|
159
|
+
}), q({}), R.current.clear();
|
|
160
|
+
let i = M.current;
|
|
161
|
+
M.current = {}, Object.keys(i).forEach((e) => {
|
|
162
|
+
i[e] && K(e);
|
|
163
|
+
});
|
|
164
|
+
}, [
|
|
165
|
+
q,
|
|
166
|
+
o,
|
|
167
|
+
K
|
|
168
|
+
]);
|
|
169
|
+
p(r, () => ({
|
|
170
|
+
getValues: () => k.current,
|
|
171
|
+
setValues: oe,
|
|
172
|
+
reset: $,
|
|
173
|
+
validate: Z,
|
|
174
|
+
submit: Q,
|
|
175
|
+
isSubmitting: () => N.current,
|
|
176
|
+
getErrors: () => A.current
|
|
177
|
+
}), [
|
|
178
|
+
$,
|
|
179
|
+
oe,
|
|
180
|
+
Q,
|
|
181
|
+
Z
|
|
182
|
+
]);
|
|
183
|
+
let se = m(() => ({
|
|
184
|
+
defaultValidateTrigger: G,
|
|
185
|
+
registerField: J,
|
|
186
|
+
updateField: Y,
|
|
187
|
+
validateField: X,
|
|
188
|
+
subscribeField: ie,
|
|
189
|
+
getFieldState: ae
|
|
190
|
+
}), [
|
|
191
|
+
G,
|
|
192
|
+
ae,
|
|
193
|
+
J,
|
|
194
|
+
ie,
|
|
195
|
+
Y,
|
|
196
|
+
X
|
|
197
|
+
]), ce = m(() => ({
|
|
198
|
+
get values() {
|
|
199
|
+
return k.current;
|
|
200
|
+
},
|
|
201
|
+
get errors() {
|
|
202
|
+
return A.current;
|
|
203
|
+
},
|
|
204
|
+
get validating() {
|
|
205
|
+
return M.current;
|
|
206
|
+
},
|
|
207
|
+
defaultValidateTrigger: G,
|
|
208
|
+
registerField: J,
|
|
209
|
+
updateField: Y,
|
|
210
|
+
validateField: X
|
|
211
|
+
}), [
|
|
212
|
+
G,
|
|
213
|
+
J,
|
|
214
|
+
Y,
|
|
215
|
+
X
|
|
216
|
+
]), le = {
|
|
217
|
+
...ee,
|
|
218
|
+
...c === void 0 ? null : { "--vl-form-label-width": typeof c == "number" ? `${c}px` : c }
|
|
219
|
+
}, ue = [
|
|
220
|
+
"vl-form",
|
|
221
|
+
`vl-form--${s}`,
|
|
222
|
+
`vl-form--label-${l}`,
|
|
223
|
+
P ? "is-submitting" : "",
|
|
224
|
+
f || ""
|
|
225
|
+
].filter(Boolean).join(" "), de = (e) => {
|
|
226
|
+
e.preventDefault(), Q();
|
|
227
|
+
}, fe = (e) => {
|
|
228
|
+
e.preventDefault(), $();
|
|
229
|
+
};
|
|
230
|
+
return /* @__PURE__ */ v(te, {
|
|
231
|
+
value: se,
|
|
232
|
+
children: /* @__PURE__ */ v(ne, {
|
|
233
|
+
value: O,
|
|
234
|
+
children: /* @__PURE__ */ v(E, {
|
|
235
|
+
value: ce,
|
|
236
|
+
children: /* @__PURE__ */ v("form", {
|
|
237
|
+
...T,
|
|
238
|
+
className: ue,
|
|
239
|
+
style: le,
|
|
240
|
+
"aria-busy": P || void 0,
|
|
241
|
+
noValidate: w,
|
|
242
|
+
onSubmit: de,
|
|
243
|
+
onReset: fe,
|
|
244
|
+
children: _
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
})
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
M.displayName = "VlForm";
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region components/Form/FormItem.tsx
|
|
253
|
+
var N = [], P = [], F = (e, t) => e ? Array.isArray(e) ? e : [e] : t, I = (e, t) => {
|
|
254
|
+
if (e === "checked" && typeof t[1] == "boolean") return t[1];
|
|
255
|
+
let n = t[0];
|
|
256
|
+
if (n && typeof n == "object" && "target" in n) {
|
|
257
|
+
let t = n.target;
|
|
258
|
+
if (t) return e === "checked" ? t.checked : t.value;
|
|
259
|
+
}
|
|
260
|
+
return n;
|
|
261
|
+
}, L = ({ id: t, content: n }) => {
|
|
262
|
+
let r = h(null), [i, o] = g(!1), s = d(() => {
|
|
263
|
+
let e = r.current;
|
|
264
|
+
if (!e) return;
|
|
265
|
+
let t = e.scrollWidth > e.clientWidth;
|
|
266
|
+
o((e) => e === t ? e : t);
|
|
267
|
+
}, []);
|
|
268
|
+
return e(() => {
|
|
269
|
+
s();
|
|
270
|
+
let e = r.current, t = typeof ResizeObserver > "u" ? null : new ResizeObserver(s);
|
|
271
|
+
return e && t?.observe(e), window.addEventListener("resize", s, { passive: !0 }), () => {
|
|
272
|
+
t?.disconnect(), window.removeEventListener("resize", s);
|
|
273
|
+
};
|
|
274
|
+
}, [n, s]), /* @__PURE__ */ v(a, {
|
|
275
|
+
id: t,
|
|
276
|
+
className: "vl-form-item__help-tooltip",
|
|
277
|
+
content: n,
|
|
278
|
+
disabled: !i,
|
|
279
|
+
children: /* @__PURE__ */ v("div", {
|
|
280
|
+
ref: r,
|
|
281
|
+
className: "vl-form-item__help is-text",
|
|
282
|
+
tabIndex: i ? 0 : void 0,
|
|
283
|
+
children: n
|
|
284
|
+
})
|
|
285
|
+
});
|
|
286
|
+
}, R = c((t, i) => {
|
|
287
|
+
let { formControlled: a, formValue: s, name: c, label: u, required: d = !1, rules: f = N, help: p, valuePropName: _ = "value", trigger: b = "onChange", getValueFromEvent: x, validateTrigger: S, className: te, children: w, ...ne } = t, T = C(), E = T?.registerField, O = l(w) ? w : null, k = O?.props ?? {}, re = r("vl-form-control", k.id), A = r("vl-form-label"), j = r("vl-form-help"), M = r("vl-form-error"), R = h(null), z = T?.defaultValidateTrigger ?? P, B = m(() => F(S, z), [z, S]), V = m(() => d && !f.some((e) => e.required) ? [{ required: !0 }, ...f] : f, [d, f]), H = d || V.some((e) => e.required), U = p != null && typeof p != "boolean" && p !== "", W = D(c), G = W.errors, K = W.isValidating, ie = a ? s : W.value, ae = B.includes("change") || G.length > 0, [q] = g(() => Symbol("form-field")), J = h({
|
|
288
|
+
label: void 0,
|
|
289
|
+
rules: N,
|
|
290
|
+
element: null
|
|
291
|
+
});
|
|
292
|
+
e(() => {
|
|
293
|
+
J.current.label = typeof u == "string" ? u : void 0, J.current.rules = V;
|
|
294
|
+
}, [V, u]), ee(() => {
|
|
295
|
+
if (!(!c || !E)) return E({
|
|
296
|
+
name: c,
|
|
297
|
+
token: q,
|
|
298
|
+
metaRef: J
|
|
299
|
+
});
|
|
300
|
+
}, [
|
|
301
|
+
q,
|
|
302
|
+
c,
|
|
303
|
+
E
|
|
304
|
+
]);
|
|
305
|
+
let Y = G.length > 0, X = U && !Y, Z = {
|
|
306
|
+
id: re,
|
|
307
|
+
"aria-describedby": [
|
|
308
|
+
k["aria-describedby"],
|
|
309
|
+
Y ? M : void 0,
|
|
310
|
+
X ? j : void 0
|
|
311
|
+
].filter(Boolean).join(" ") || void 0,
|
|
312
|
+
"aria-labelledby": [k["aria-labelledby"], u === void 0 ? void 0 : A].filter(Boolean).join(" ") || void 0,
|
|
313
|
+
"aria-invalid": G.length > 0 || void 0,
|
|
314
|
+
"aria-busy": K || void 0,
|
|
315
|
+
ref: (e) => {
|
|
316
|
+
R.current = e, J.current.element = e, n(k.ref, e);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
if (c && T) {
|
|
320
|
+
Z[_] = ie;
|
|
321
|
+
let e = k[b];
|
|
322
|
+
if (Z[b] = (...t) => {
|
|
323
|
+
typeof e == "function" && e(...t);
|
|
324
|
+
let n = x ? x(...t) : I(_, t), r = T.updateField(c, n);
|
|
325
|
+
(ae || b === "onBlur" && B.includes("blur")) && T.validateField(c, r);
|
|
326
|
+
}, b !== "onBlur") {
|
|
327
|
+
let e = k.onBlur;
|
|
328
|
+
Z.onBlur = (t) => {
|
|
329
|
+
typeof e == "function" && e(t), B.includes("blur") && T.validateField(c);
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
let Q = O ? o(O, Z) : w, oe = [
|
|
334
|
+
"vl-form-item",
|
|
335
|
+
c ? "has-name" : "",
|
|
336
|
+
u === void 0 ? "" : "has-label",
|
|
337
|
+
U ? "has-help" : "",
|
|
338
|
+
G.length ? "is-error" : "",
|
|
339
|
+
K ? "is-validating" : "",
|
|
340
|
+
H ? "is-required" : "",
|
|
341
|
+
te || ""
|
|
342
|
+
].filter(Boolean).join(" "), $ = K || G.length > 0;
|
|
343
|
+
return /* @__PURE__ */ y("div", {
|
|
344
|
+
...ne,
|
|
345
|
+
ref: i,
|
|
346
|
+
className: oe,
|
|
347
|
+
children: [u === void 0 ? null : /* @__PURE__ */ y("label", {
|
|
348
|
+
id: A,
|
|
349
|
+
className: "vl-form-item__label",
|
|
350
|
+
htmlFor: re,
|
|
351
|
+
children: [H ? /* @__PURE__ */ v("span", {
|
|
352
|
+
className: "vl-form-item__required",
|
|
353
|
+
"aria-hidden": "true",
|
|
354
|
+
children: "*"
|
|
355
|
+
}) : null, u]
|
|
356
|
+
}), /* @__PURE__ */ y("div", {
|
|
357
|
+
className: "vl-form-item__control",
|
|
358
|
+
children: [/* @__PURE__ */ y("div", {
|
|
359
|
+
className: "vl-form-item__field",
|
|
360
|
+
children: [/* @__PURE__ */ v("div", {
|
|
361
|
+
className: "vl-form-item__control-input",
|
|
362
|
+
children: Q
|
|
363
|
+
}), c ? /* @__PURE__ */ y("div", {
|
|
364
|
+
className: `vl-form-item__validation${$ ? "" : " is-empty"}`,
|
|
365
|
+
"aria-hidden": !$ || void 0,
|
|
366
|
+
children: [K ? /* @__PURE__ */ y("div", {
|
|
367
|
+
className: "vl-form-item__status",
|
|
368
|
+
role: "status",
|
|
369
|
+
"aria-label": "校验中",
|
|
370
|
+
children: [/* @__PURE__ */ v("span", {
|
|
371
|
+
className: "vl-form-item__spinner",
|
|
372
|
+
"aria-hidden": "true"
|
|
373
|
+
}), /* @__PURE__ */ v("span", { children: "校验中" })]
|
|
374
|
+
}) : null, G.length ? /* @__PURE__ */ v("div", {
|
|
375
|
+
id: M,
|
|
376
|
+
className: "vl-form-item__error",
|
|
377
|
+
role: "alert",
|
|
378
|
+
children: G.map((e) => /* @__PURE__ */ v("div", { children: e }, e))
|
|
379
|
+
}) : null]
|
|
380
|
+
}) : null]
|
|
381
|
+
}), X ? /* @__PURE__ */ v("div", {
|
|
382
|
+
className: "vl-form-item__feedback",
|
|
383
|
+
children: typeof p == "string" || typeof p == "number" ? /* @__PURE__ */ v(L, {
|
|
384
|
+
id: j,
|
|
385
|
+
content: p
|
|
386
|
+
}) : /* @__PURE__ */ v("div", {
|
|
387
|
+
id: j,
|
|
388
|
+
className: "vl-form-item__help",
|
|
389
|
+
children: p
|
|
390
|
+
})
|
|
391
|
+
}) : null]
|
|
392
|
+
})]
|
|
393
|
+
});
|
|
394
|
+
}), z = u(R, (e, t) => {
|
|
395
|
+
if (e.formControlled !== t.formControlled || !Object.is(e.formValue, t.formValue) || e.name !== t.name || e.label !== t.label || e.required !== t.required || e.help !== t.help || e.valuePropName !== t.valuePropName || e.trigger !== t.trigger || e.getValueFromEvent !== t.getValueFromEvent || e.validateTrigger !== t.validateTrigger || e.className !== t.className || e.style !== t.style) return !1;
|
|
396
|
+
if (e.rules !== t.rules) {
|
|
397
|
+
let n = e.rules ?? N, r = t.rules ?? N;
|
|
398
|
+
if (n.length !== r.length) return !1;
|
|
399
|
+
for (let e = 0; e < n.length; e++) if (n[e] !== r[e]) return !1;
|
|
400
|
+
}
|
|
401
|
+
if (e.children !== t.children) {
|
|
402
|
+
let n = e.children, r = t.children;
|
|
403
|
+
if (!l(n) || !l(r)) return Object.is(n, r);
|
|
404
|
+
if (n.type !== r.type || n.key !== r.key) return !1;
|
|
405
|
+
let i = n.props, a = r.props, o = Object.keys(i), s = Object.keys(a);
|
|
406
|
+
if (o.length !== s.length) return !1;
|
|
407
|
+
for (let e of o) if (!Object.is(i[e], a[e])) return !1;
|
|
408
|
+
}
|
|
409
|
+
let n = /* @__PURE__ */ new Set([
|
|
410
|
+
"formControlled",
|
|
411
|
+
"formValue",
|
|
412
|
+
"name",
|
|
413
|
+
"label",
|
|
414
|
+
"required",
|
|
415
|
+
"rules",
|
|
416
|
+
"help",
|
|
417
|
+
"valuePropName",
|
|
418
|
+
"trigger",
|
|
419
|
+
"getValueFromEvent",
|
|
420
|
+
"validateTrigger",
|
|
421
|
+
"className",
|
|
422
|
+
"style",
|
|
423
|
+
"children"
|
|
424
|
+
]), r = e, i = t;
|
|
425
|
+
for (let t of Object.keys(e)) if (!n.has(t) && !Object.is(r[t], i[t])) return !1;
|
|
426
|
+
for (let e of Object.keys(t)) if (!n.has(e) && !Object.is(r[e], i[e])) return !1;
|
|
427
|
+
return !0;
|
|
428
|
+
}), B = c((e, t) => {
|
|
429
|
+
let n = T();
|
|
430
|
+
return /* @__PURE__ */ v(z, {
|
|
431
|
+
...e,
|
|
432
|
+
ref: t,
|
|
433
|
+
formControlled: n !== null,
|
|
434
|
+
formValue: e.name ? n?.[e.name] : void 0
|
|
435
|
+
});
|
|
436
|
+
});
|
|
437
|
+
B.displayName = "VlFormItem";
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region components/Form/index.ts
|
|
440
|
+
var V = Object.assign(M, { Item: B }), H = B;
|
|
441
|
+
//#endregion
|
|
442
|
+
export { H as n, V as t };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { t as e } from "./
|
|
2
|
-
import { t } from "./
|
|
1
|
+
import { t as e } from "./Transition-DiO4GsP3.js";
|
|
2
|
+
import { t } from "./client-pj_wzx28.js";
|
|
3
3
|
import { forwardRef as n } from "react";
|
|
4
4
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
5
|
import { createPortal as a } from "react-dom";
|
|
6
6
|
//#region components/Loading/Loading.tsx
|
|
7
7
|
var o = n((n, o) => {
|
|
8
|
-
let { visible: s = !1, text: c, spinner: l, background: u, fullscreen: d = !1, className: f, style: p, role: m = "status", "aria-label": h, "aria-live": g = "polite", ..._ } = n, v =
|
|
8
|
+
let { visible: s = !1, text: c, spinner: l, background: u, fullscreen: d = !1, className: f, style: p, role: m = "status", "aria-label": h, "aria-live": g = "polite", ..._ } = n, v = t(), y = [
|
|
9
9
|
"vl-loading-mask",
|
|
10
10
|
d ? "vl-loading-fullscreen" : "",
|
|
11
11
|
f || ""
|
|
12
12
|
].filter(Boolean).join(" "), b = {
|
|
13
13
|
...u ? { backgroundColor: u } : {},
|
|
14
14
|
...p
|
|
15
|
-
}, x = /* @__PURE__ */ r(
|
|
15
|
+
}, x = /* @__PURE__ */ r(e, {
|
|
16
16
|
show: s,
|
|
17
17
|
name: "vl-loading-fade",
|
|
18
18
|
deferEffects: !v,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./
|
|
1
|
+
const e=require("./Transition-X_89ga-e.cjs"),t=require("./client-BkoqeUs3.cjs");let n=require("react"),r=require("react/jsx-runtime"),i=require("react-dom");var a=(0,n.forwardRef)((n,a)=>{let{visible:o=!1,text:s,spinner:c,background:l,fullscreen:u=!1,className:d,style:f,role:p=`status`,"aria-label":m,"aria-live":h=`polite`,...g}=n,_=t.t(),v=[`vl-loading-mask`,u?`vl-loading-fullscreen`:``,d||``].filter(Boolean).join(` `),y={...l?{backgroundColor:l}:{},...f},b=(0,r.jsx)(e.t,{show:o,name:`vl-loading-fade`,deferEffects:!_,children:(0,r.jsxs)(`div`,{ref:a,className:v,style:y,role:p,"aria-label":m??(s?void 0:`加载中`),"aria-live":h,"aria-busy":`true`,...g,children:[(0,r.jsx)(`div`,{className:`vl-loading-spinner`,"aria-hidden":`true`,children:c??(0,r.jsx)(`div`,{className:`vl-loading-spinner-icon`})}),s?(0,r.jsx)(`div`,{className:`vl-loading-text`,children:s}):null]})});return u&&_?(0,i.createPortal)(b,document.body):b});a.displayName=`VlLoading`;var o=a,s=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|