@vavt/react-ui 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Anchor-QZROepM_.js → Anchor-CAZPkv56.js} +1 -1
- package/dist/{Anchor-iriRYxEs.cjs → Anchor-CmuV1Ump.cjs} +1 -1
- package/dist/{Announcement-XjJyJ28N.cjs → Announcement-D0hZE2sM.cjs} +1 -1
- package/dist/{Announcement-D_NccvTm.js → Announcement-DzzaTvcO.js} +1 -1
- package/dist/Checkbox-CBMmX-R-.js +86 -0
- package/dist/Checkbox-CzNGP2tH.cjs +1 -0
- package/dist/Checkbox-GJlGNzlH.cjs +1 -0
- package/dist/Checkbox-bHOjYdMp.js +61 -0
- package/dist/{Cron-Go4yIqrd.js → Cron-DIB4GG4y.js} +7 -7
- package/dist/{Cron-3D9GmlYf.cjs → Cron-MhbYMEeJ.cjs} +1 -1
- package/dist/{DatePicker-D75NqBYX.js → DatePicker--13tW0cw.js} +1 -1
- package/dist/{DatePicker-D3tdU7GY.cjs → DatePicker-Bj709smn.cjs} +1 -1
- package/dist/{DateTimePicker-CG-yv54X.js → DateTimePicker-Blqs2Bcv.js} +1 -1
- package/dist/{DateTimePicker-CCe5NUkC.cjs → DateTimePicker-ZSScsk-j.cjs} +1 -1
- package/dist/{Drawer-CeBlbSjY.cjs → Drawer-DcbgMkub.cjs} +1 -1
- package/dist/{Drawer-CgaSQfT_.js → Drawer-yM_r1M0H.js} +1 -1
- package/dist/{Dropdown-BsXYVdt6.cjs → Dropdown-PHqXNiAZ.cjs} +1 -1
- package/dist/{Dropdown-DljKFnvO.js → Dropdown-mYCY-LcF.js} +2 -2
- package/dist/Form-BkyDHPEI.cjs +1 -0
- package/dist/Form-D_Uv-8HG.js +449 -0
- package/dist/{Input-CIB_TY2n.js → Input-BRy5Xuwy.js} +28 -37
- package/dist/Input-C9ESmbJ7.cjs +1 -0
- package/dist/{MessageBox-nHLRzRJS.cjs → MessageBox-BSMYQenX.cjs} +1 -1
- package/dist/{MessageBox-DlAv_jQm.js → MessageBox-DipOfKXI.js} +2 -2
- package/dist/{Modal-CAZ8vap0.cjs → Modal-BOI8r4y1.cjs} +1 -1
- package/dist/{Modal-DnLKpKvW.js → Modal-De9igZ5e.js} +1 -1
- package/dist/{NumberInput-C_vLULbX.js → NumberInput-CB-nKZgs.js} +1 -1
- package/dist/{NumberInput-CYVj89_s.cjs → NumberInput-Dp1vTDkW.cjs} +1 -1
- package/dist/{Pagination-CSI5IzQB.js → Pagination-CpbboRbF.js} +2 -2
- package/dist/{Pagination-ODU-i3gn.cjs → Pagination-DatEegaF.cjs} +1 -1
- package/dist/RadioGroup-DTodR0VJ.cjs +1 -0
- package/dist/RadioGroup-DYjQMXdB.js +136 -0
- package/dist/Select-BHWa_6Q2.js +466 -0
- package/dist/Select-C6O0tmM_.cjs +1 -0
- package/dist/{Slider-BzlZc0p4.js → Slider-CKU03SsT.js} +1 -1
- package/dist/{Slider-DCIUxcBa.cjs → Slider-CU9OS2HB.cjs} +1 -1
- package/dist/{Switch-7yJ-Q_o_.cjs → Switch-CpXDMcPW.cjs} +1 -1
- package/dist/{Switch-DOO2tiYR.js → Switch-CqTFvp-k.js} +1 -1
- package/dist/Table-BNGO_7Rx.cjs +1 -0
- package/dist/Table-Cfs3XJgN.js +531 -0
- package/dist/{Tabs-BhjvKN84.cjs → Tabs-BZ0Zc0bL.cjs} +1 -1
- package/dist/{Tabs-VT6nQ63W.js → Tabs-HWLkyrQR.js} +1 -1
- package/dist/{Textarea-BEd7ToXv.js → Textarea-CA6Vzu7t.js} +1 -1
- package/dist/{Textarea-C2dNYM0F.cjs → Textarea-CEhAvE10.cjs} +1 -1
- package/dist/{TimePicker-CHZsr_jj.js → TimePicker-CYlcUTTM.js} +2 -2
- package/dist/{TimePicker-Cpmvn8tx.cjs → TimePicker-DoGbwfkU.cjs} +1 -1
- package/dist/{Tooltip-Buk5F9f_.js → Tooltip-BKPreZML.js} +2 -2
- package/dist/{Tooltip-CP8rpNYG.cjs → Tooltip-DDjGLjoV.cjs} +1 -1
- package/dist/{Upload-CVIzg2Px.js → Upload-DZ6VaM7r.js} +1 -1
- package/dist/{Upload-CIOunhpr.cjs → Upload-wHEEoe1c.cjs} +1 -1
- package/dist/cjs/Anchor.cjs +1 -1
- package/dist/cjs/Announcement.cjs +1 -1
- package/dist/cjs/Checkbox.cjs +1 -1
- 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/Input.cjs +1 -1
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/NumberInput.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Radio.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Slider.cjs +1 -1
- package/dist/cjs/Switch.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/Tabs.cjs +1 -1
- package/dist/cjs/Textarea.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/Upload.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/Checkbox.css +1 -1
- package/dist/css/Form.css +1 -1
- package/dist/css/Input.css +1 -1
- package/dist/css/Radio.css +1 -1
- package/dist/css/Select.css +1 -1
- package/dist/{date-picker-pwA2wCag.cjs → date-picker-Be_1wA3S.cjs} +1 -1
- package/dist/{date-picker-BH--Nh7g.js → date-picker-CHP0eBuL.js} +4 -4
- package/dist/es/Anchor.mjs +1 -1
- package/dist/es/Announcement.mjs +1 -1
- package/dist/es/Checkbox.mjs +1 -1
- 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/Input.mjs +1 -1
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/NumberInput.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Radio.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Slider.mjs +1 -1
- package/dist/es/Switch.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/Tabs.mjs +1 -1
- package/dist/es/Textarea.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/Upload.mjs +1 -1
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +24 -24
- package/dist/es/register.mjs +1 -1
- package/dist/floating-5PRFyI8D.cjs +1 -0
- package/dist/floating-CqdcJWk2.js +181 -0
- package/dist/index.css +1 -1
- package/dist/{registry-macDoSyW.js → registry-BLaletUC.js} +23 -23
- package/dist/registry-hU7S5myb.cjs +1 -0
- package/dist/state-BSDh-Ob2.js +22 -0
- package/dist/state-BuUx1onZ.cjs +1 -0
- package/dist/types/Checkbox/context.d.cts +12 -2
- package/dist/types/Checkbox/context.d.ts +12 -2
- package/dist/types/Checkbox/type.d.cts +33 -3
- package/dist/types/Checkbox/type.d.ts +33 -3
- 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 +31 -0
- package/dist/types/Form/context.d.ts +31 -0
- package/dist/types/Form/index.d.cts +2 -2
- package/dist/types/Form/index.d.ts +2 -2
- package/dist/types/Form/type.d.cts +0 -2
- package/dist/types/Form/type.d.ts +0 -2
- package/dist/types/Radio/context.d.cts +12 -2
- package/dist/types/Radio/context.d.ts +12 -2
- package/dist/types/Radio/type.d.cts +33 -3
- package/dist/types/Radio/type.d.ts +33 -3
- package/dist/types/_shared/state.d.cts +3 -0
- package/dist/types/_shared/state.d.ts +3 -0
- package/dist/types/registry.d.cts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/package.json +1 -1
- package/dist/Checkbox-BCXbK1-8.cjs +0 -1
- package/dist/Checkbox-CQZSg9Xu.cjs +0 -1
- package/dist/Checkbox-CQeqLO0S.js +0 -46
- package/dist/Checkbox-cnXHW9Oz.js +0 -61
- package/dist/Form-BfXRwX6y.js +0 -353
- package/dist/Form-QpWOfQpR.cjs +0 -1
- package/dist/Input-CoDZggqc.cjs +0 -1
- package/dist/RadioGroup-BRcNi5Oc.js +0 -98
- package/dist/RadioGroup-q2Aa50NV.cjs +0 -1
- package/dist/Select-BRKxpX-_.cjs +0 -1
- package/dist/Select-QedbJ4pD.js +0 -468
- package/dist/Table-BFqTvxt1.js +0 -440
- package/dist/Table-D4csqW47.cjs +0 -1
- package/dist/floating-DBAmeQIq.js +0 -157
- package/dist/floating-DXRnx48N.cjs +0 -1
- package/dist/registry-BO2ao8Jc.cjs +0 -1
- package/dist/state-ZBA75xZ_.cjs +0 -1
- package/dist/state-oH-YwB7_.js +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as e } from "./state-
|
|
1
|
+
import { t as e } from "./state-BSDh-Ob2.js";
|
|
2
2
|
import { t } from "./number-BN2jHM6Z.js";
|
|
3
|
-
import { t as n } from "./Select-
|
|
3
|
+
import { t as n } from "./Select-BHWa_6Q2.js";
|
|
4
4
|
import { ChevronLeft as r, ChevronRight as i, ChevronsLeft as a, ChevronsRight as ee } from "lucide-react";
|
|
5
5
|
import { createElement as o, forwardRef as s, useEffect as c, useMemo as l, useState as u } from "react";
|
|
6
6
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./state-
|
|
1
|
+
const e=require("./state-BuUx1onZ.cjs"),t=require("./number-B7qJF_ZY.cjs"),n=require("./Select-C6O0tmM_.cjs");let r=require("lucide-react"),i=require("react"),a=require("react/jsx-runtime");var o=[10,20,50,100],s=(e,t)=>typeof e!=`number`||!Number.isFinite(e)?t:Math.max(1,Math.floor(e)),c=e=>typeof e!=`number`||!Number.isFinite(e)?0:Math.max(0,Math.floor(e)),l=(e,t)=>{let n=[...e??o].filter(e=>typeof e==`number`&&Number.isFinite(e)&&e>0).map(e=>Math.floor(e)).filter(e=>e>0).filter((e,t,n)=>n.indexOf(e)===t).sort((e,t)=>e-t);return n.length?n:[t]},u=(e,t)=>{if(e<=7)return Array.from({length:e},(e,t)=>t+1);let n=Math.max(2,t-1),r=Math.min(e-1,t+1),i=n>2,a=r<e-1;return i?a?[1,`ellipsis-start`,n,t,r,`ellipsis-end`,e]:[1,`ellipsis-start`,e-4,e-3,e-2,e-1,e]:[1,2,3,4,5,`ellipsis-end`,e]},d=(0,i.forwardRef)((o,d)=>{let{current:f,defaultCurrent:p=1,total:m=0,pageSize:h,defaultPageSize:g=10,pageSizeOptions:_,showTotal:v=!1,showSizeChanger:y=!1,showQuickJumper:b=!1,size:x=`md`,disabled:S=!1,className:C,id:w,"aria-label":T=`分页导航`,onChange:E,onPageSizeChange:D,...O}=o,k=e.t(o,`current`),A=e.t(o,`pageSize`),j=s(g,10),[M,N]=(0,i.useState)(()=>s(p,1)),[P,F]=(0,i.useState)(j),[I,L]=(0,i.useState)(``),R=c(m),z=s(A?h:P,j),B=Math.max(1,Math.ceil(R/z)),V=t.t(s(k?f:M,1),1,B),H=(0,i.useMemo)(()=>l(_,z),[_,z]),U=(0,i.useMemo)(()=>H.map(e=>({value:e,label:`${e} 条/页`})),[H]),W=(0,i.useMemo)(()=>u(B,V),[B,V]),G=R===0?[0,0]:[(V-1)*z+1,Math.min(V*z,R)];(0,i.useEffect)(()=>{L(String(V))},[V]),(0,i.useEffect)(()=>{!k&&M!==V&&N(V)},[V,k,M]);let K=[`vl-pagination`,`size-${x}`,S?`is-disabled`:``,C||``].filter(Boolean).join(` `),q=(e,t=z)=>{k||N(e),E?.(e,t)},J=e=>{if(S)return;let n=t.t(e,1,B);n!==V&&q(n)},Y=e=>{if(S||e===null||Array.isArray(e))return;let n=s(Number(e),z);if(n===z)return;let r=Math.max(1,Math.ceil(R/n)),i=t.t(V,1,r);A||F(n),k||N(i),D?.(n,i),E?.(i,n)},X=()=>{if(S)return;let e=I.trim();if(!/^\d+$/.test(e))return;let t=Number(e);!Number.isSafeInteger(t)||t<1||t>B||J(t)},Z=e=>{e.key===`Enter`&&(e.preventDefault(),X())},Q=(e,t,n,r)=>{let o=e===`first`||e===`previous`?V<=1:V>=B;return(0,a.jsx)(`button`,{type:`button`,className:`vl-pagination__button vl-pagination__nav-button`,"aria-label":t,disabled:S||o,onClick:()=>J(n),children:(0,i.createElement)(r,{"aria-hidden":!0,focusable:!1})})};return(0,a.jsxs)(`nav`,{ref:d,id:w,className:K,"aria-label":T,"aria-disabled":S||void 0,...O,children:[v?(0,a.jsx)(`span`,{className:`vl-pagination__total`,children:typeof v==`function`?v(R,G):`第 ${G[0]}-${G[1]} 条,共 ${R} 条`}):null,(0,a.jsxs)(`div`,{className:`vl-pagination__controls`,children:[(0,a.jsxs)(`div`,{className:`vl-pagination__pages`,children:[Q(`first`,`第一页`,1,r.ChevronsLeft),Q(`previous`,`上一页`,V-1,r.ChevronLeft),W.map(e=>typeof e==`number`?(0,a.jsx)(`button`,{type:`button`,className:`vl-pagination__button ${e===V?`is-active`:``}`,"aria-label":`第 ${e} 页`,"aria-current":e===V?`page`:void 0,disabled:S,onClick:()=>J(e),children:e},e):(0,a.jsx)(`span`,{className:`vl-pagination__ellipsis`,"aria-hidden":`true`,children:`…`},e)),Q(`next`,`下一页`,V+1,r.ChevronRight),Q(`last`,`最后一页`,B,r.ChevronsRight)]}),y?(0,a.jsx)(`div`,{className:`vl-pagination__size-changer`,children:(0,a.jsx)(n.t,{value:z,options:U,size:x,disabled:S,"aria-label":`每页条数`,onChange:Y})}):null,b?(0,a.jsxs)(`label`,{className:`vl-pagination__quick-jumper`,children:[(0,a.jsx)(`span`,{children:`跳至`}),(0,a.jsx)(`input`,{value:I,type:`text`,inputMode:`numeric`,"aria-label":`跳转到页码`,disabled:S,onChange:e=>L(e.target.value),onKeyDown:Z,onBlur:X}),(0,a.jsx)(`span`,{children:`页`})]}):null]})]})});d.displayName=`VlPagination`;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 @@
|
|
|
1
|
+
const e=require("./state-BuUx1onZ.cjs"),t=require("./id-CF0zOP1G.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.createContext)(null),a=i.Provider,o=()=>(0,n.useContext)(i),s=(0,n.forwardRef)((t,n)=>{let{checked:i,defaultChecked:a=!1,value:s,label:c,title:l,description:u,extra:d,disabled:f,bordered:p,card:m,indicator:h,indicatorPlacement:g,align:_,block:v,name:y,size:b,className:x,style:S,children:C,onChange:w,...T}=t,E=o(),D=e.t(t,`checked`),[O,k]=e.n({value:!!i,defaultValue:a,controlled:D}),A=E!==null&&s!==void 0,j=A?Object.is(E.value,s):O,M=f??E?.disabled??!1,N=p??E?.bordered??!1,P=m??E?.card??!1,F=h??E?.indicator,I=g??E?.indicatorPlacement,L=(F===void 0?I===void 0?!P:I!==`none`:F)?I??(P?`top-left`:`start`):`none`,R=_??E?.align??`start`,z=v??E?.block??!1,B=y??(A?E.name:void 0),V=b??E?.size??`md`,H=[`vl-radio`,V?`size-${V}`:``,M?`is-disabled`:``,N?`is-bordered`:``,P?`is-card`:``,P?`indicator-${L}`:``,P?`align-${R}`:``,z?`is-block`:``,j?`is-checked`:``,x||``].filter(Boolean).join(` `),U=!!(l||d),W=!!(l||u||d),G=W||c!=null||C!=null,K=()=>{if(!(M||j)){if(A){E.selectValue(s),w?.(s,!0);return}k(!0),w?.(s,!0)}},q=typeof s==`boolean`?String(s):s,J=()=>G?P||W?(0,r.jsxs)(`div`,{className:`vl-radio__content`,children:[U?(0,r.jsxs)(`div`,{className:`vl-radio__header`,children:[l?(0,r.jsx)(`div`,{className:`vl-radio__title`,children:l}):null,d?(0,r.jsx)(`div`,{className:`vl-radio__extra`,children:d}):null]}):null,u?(0,r.jsx)(`div`,{className:`vl-radio__description`,children:u}):null,C??c]}):(0,r.jsx)(`span`,{className:`vl-radio__label`,children:C??c}):null;return(0,r.jsxs)(`label`,{className:H,style:S,children:[(0,r.jsx)(`input`,{ref:n,className:`vl-radio__input`,type:`radio`,name:B,value:q,checked:j,disabled:M,"aria-checked":j?`true`:`false`,onChange:K,...T}),L===`none`?null:(0,r.jsx)(`span`,{className:`vl-radio__control`,"aria-hidden":`true`,children:(0,r.jsx)(`span`,{className:`vl-radio__icon`})}),J()]})});s.displayName=`VlRadio`;var c=(0,n.forwardRef)((i,o)=>{let{value:s,defaultValue:c=null,disabled:l,bordered:u,card:d,indicator:f,indicatorPlacement:p,align:m,block:h,name:g,size:_,children:v,className:y,onChange:b,...x}=i,S=t.t(`vl-radio-group`),C=e.t(i,`value`),[w,T]=e.n({value:s??null,defaultValue:c,controlled:C,onChange:e=>{e!==null&&b?.(e)}}),E=(0,n.useCallback)(e=>{Object.is(w,e)||T(e)},[T,w]),D=(0,n.useMemo)(()=>({value:w,disabled:l,bordered:u,card:d,indicator:f,indicatorPlacement:p,align:m,block:h,name:g??S,size:_,selectValue:E}),[w,l,u,d,f,p,m,h,g,S,_,E]),O=[`vl-radio-group`,d?`is-card-group`:``,h?`is-block`:``,y||``].filter(Boolean).join(` `);return(0,r.jsx)(a,{value:D,children:(0,r.jsx)(`div`,{ref:o,className:O,role:`radiogroup`,"aria-disabled":l||void 0,...x,children:v})})});c.displayName=`VlRadioGroup`,Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { n as e, t } from "./state-BSDh-Ob2.js";
|
|
2
|
+
import { t as n } from "./id-CHixuHb7.js";
|
|
3
|
+
import { createContext as r, forwardRef as i, useCallback as a, useContext as o, useMemo as s } from "react";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
|
+
//#region components/Radio/context.ts
|
|
6
|
+
var u = r(null), d = u.Provider, f = () => o(u), p = i((n, r) => {
|
|
7
|
+
let { checked: i, defaultChecked: a = !1, value: o, label: s, title: u, description: d, extra: p, disabled: m, bordered: h, card: g, indicator: _, indicatorPlacement: v, align: y, block: b, name: x, size: S, className: C, style: w, children: T, onChange: E, ...D } = n, O = f(), k = t(n, "checked"), [A, j] = e({
|
|
8
|
+
value: !!i,
|
|
9
|
+
defaultValue: a,
|
|
10
|
+
controlled: k
|
|
11
|
+
}), M = O !== null && o !== void 0, N = M ? Object.is(O.value, o) : A, P = m ?? O?.disabled ?? !1, F = h ?? O?.bordered ?? !1, I = g ?? O?.card ?? !1, L = _ ?? O?.indicator, R = v ?? O?.indicatorPlacement, z = (L === void 0 ? R === void 0 ? !I : R !== "none" : L) ? R ?? (I ? "top-left" : "start") : "none", B = y ?? O?.align ?? "start", V = b ?? O?.block ?? !1, H = x ?? (M ? O.name : void 0), U = S ?? O?.size ?? "md", W = [
|
|
12
|
+
"vl-radio",
|
|
13
|
+
U ? `size-${U}` : "",
|
|
14
|
+
P ? "is-disabled" : "",
|
|
15
|
+
F ? "is-bordered" : "",
|
|
16
|
+
I ? "is-card" : "",
|
|
17
|
+
I ? `indicator-${z}` : "",
|
|
18
|
+
I ? `align-${B}` : "",
|
|
19
|
+
V ? "is-block" : "",
|
|
20
|
+
N ? "is-checked" : "",
|
|
21
|
+
C || ""
|
|
22
|
+
].filter(Boolean).join(" "), G = !!(u || p), K = !!(u || d || p), q = K || s != null || T != null, J = () => {
|
|
23
|
+
if (!(P || N)) {
|
|
24
|
+
if (M) {
|
|
25
|
+
O.selectValue(o), E?.(o, !0);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
j(!0), E?.(o, !0);
|
|
29
|
+
}
|
|
30
|
+
}, Y = typeof o == "boolean" ? String(o) : o, X = () => q ? I || K ? /* @__PURE__ */ l("div", {
|
|
31
|
+
className: "vl-radio__content",
|
|
32
|
+
children: [
|
|
33
|
+
G ? /* @__PURE__ */ l("div", {
|
|
34
|
+
className: "vl-radio__header",
|
|
35
|
+
children: [u ? /* @__PURE__ */ c("div", {
|
|
36
|
+
className: "vl-radio__title",
|
|
37
|
+
children: u
|
|
38
|
+
}) : null, p ? /* @__PURE__ */ c("div", {
|
|
39
|
+
className: "vl-radio__extra",
|
|
40
|
+
children: p
|
|
41
|
+
}) : null]
|
|
42
|
+
}) : null,
|
|
43
|
+
d ? /* @__PURE__ */ c("div", {
|
|
44
|
+
className: "vl-radio__description",
|
|
45
|
+
children: d
|
|
46
|
+
}) : null,
|
|
47
|
+
T ?? s
|
|
48
|
+
]
|
|
49
|
+
}) : /* @__PURE__ */ c("span", {
|
|
50
|
+
className: "vl-radio__label",
|
|
51
|
+
children: T ?? s
|
|
52
|
+
}) : null;
|
|
53
|
+
return /* @__PURE__ */ l("label", {
|
|
54
|
+
className: W,
|
|
55
|
+
style: w,
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ c("input", {
|
|
58
|
+
ref: r,
|
|
59
|
+
className: "vl-radio__input",
|
|
60
|
+
type: "radio",
|
|
61
|
+
name: H,
|
|
62
|
+
value: Y,
|
|
63
|
+
checked: N,
|
|
64
|
+
disabled: P,
|
|
65
|
+
"aria-checked": N ? "true" : "false",
|
|
66
|
+
onChange: J,
|
|
67
|
+
...D
|
|
68
|
+
}),
|
|
69
|
+
z === "none" ? null : /* @__PURE__ */ c("span", {
|
|
70
|
+
className: "vl-radio__control",
|
|
71
|
+
"aria-hidden": "true",
|
|
72
|
+
children: /* @__PURE__ */ c("span", { className: "vl-radio__icon" })
|
|
73
|
+
}),
|
|
74
|
+
X()
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
p.displayName = "VlRadio";
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region components/Radio/RadioGroup.tsx
|
|
81
|
+
var m = i((r, i) => {
|
|
82
|
+
let { value: o, defaultValue: l = null, disabled: u, bordered: f, card: p, indicator: m, indicatorPlacement: h, align: g, block: _, name: v, size: y, children: b, className: x, onChange: S, ...C } = r, w = n("vl-radio-group"), T = t(r, "value"), [E, D] = e({
|
|
83
|
+
value: o ?? null,
|
|
84
|
+
defaultValue: l,
|
|
85
|
+
controlled: T,
|
|
86
|
+
onChange: (e) => {
|
|
87
|
+
e !== null && S?.(e);
|
|
88
|
+
}
|
|
89
|
+
}), O = a((e) => {
|
|
90
|
+
Object.is(E, e) || D(e);
|
|
91
|
+
}, [D, E]), k = s(() => ({
|
|
92
|
+
value: E,
|
|
93
|
+
disabled: u,
|
|
94
|
+
bordered: f,
|
|
95
|
+
card: p,
|
|
96
|
+
indicator: m,
|
|
97
|
+
indicatorPlacement: h,
|
|
98
|
+
align: g,
|
|
99
|
+
block: _,
|
|
100
|
+
name: v ?? w,
|
|
101
|
+
size: y,
|
|
102
|
+
selectValue: O
|
|
103
|
+
}), [
|
|
104
|
+
E,
|
|
105
|
+
u,
|
|
106
|
+
f,
|
|
107
|
+
p,
|
|
108
|
+
m,
|
|
109
|
+
h,
|
|
110
|
+
g,
|
|
111
|
+
_,
|
|
112
|
+
v,
|
|
113
|
+
w,
|
|
114
|
+
y,
|
|
115
|
+
O
|
|
116
|
+
]), A = [
|
|
117
|
+
"vl-radio-group",
|
|
118
|
+
p ? "is-card-group" : "",
|
|
119
|
+
_ ? "is-block" : "",
|
|
120
|
+
x || ""
|
|
121
|
+
].filter(Boolean).join(" ");
|
|
122
|
+
return /* @__PURE__ */ c(d, {
|
|
123
|
+
value: k,
|
|
124
|
+
children: /* @__PURE__ */ c("div", {
|
|
125
|
+
ref: i,
|
|
126
|
+
className: A,
|
|
127
|
+
role: "radiogroup",
|
|
128
|
+
"aria-disabled": u || void 0,
|
|
129
|
+
...C,
|
|
130
|
+
children: b
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
m.displayName = "VlRadioGroup";
|
|
135
|
+
//#endregion
|
|
136
|
+
export { p as n, m as t };
|
|
@@ -0,0 +1,466 @@
|
|
|
1
|
+
import { t as e } from "./icon-Cbvuv4yF.js";
|
|
2
|
+
import { n as t, t as n } from "./state-BSDh-Ob2.js";
|
|
3
|
+
import { t as r } from "./client-pj_wzx28.js";
|
|
4
|
+
import { n as i } from "./refs-D5IYOBaf.js";
|
|
5
|
+
import { r as ee, t as te } from "./floating-CqdcJWk2.js";
|
|
6
|
+
import { t as ne } from "./id-CHixuHb7.js";
|
|
7
|
+
import { n as re, r as ie, t as ae } from "./layer-DDm97-sb.js";
|
|
8
|
+
import { t as oe } from "./Transition-DiO4GsP3.js";
|
|
9
|
+
import { ChevronDown as se, LoaderCircle as ce, X as le } from "lucide-react";
|
|
10
|
+
import { forwardRef as a, useCallback as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
11
|
+
import { Fragment as ue, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
|
+
import { createPortal as de } from "react-dom";
|
|
13
|
+
//#region components/Select/Select.tsx
|
|
14
|
+
var p = (e) => !!(e && !e.disabled && !e.divider), m = a((a, m) => {
|
|
15
|
+
let { value: fe, defaultValue: pe, options: h = [], placeholder: g = "请选择", filterable: me = !1, filterPlaceholder: he = "搜索", multiple: ge = !1, taggable: _ = !1, maxTagCount: v, disabled: y = !1, loading: b = !1, size: _e = "md", clearable: ve = !1, placement: x = "bottom-start", offset: ye = 8, zIndex: be, emptyText: xe = "暂无数据", renderOption: Se, emptyContent: Ce, className: we, style: Te, onChange: Ee, onClear: De, onOpen: Oe, onClose: ke, onFocus: Ae, onBlur: je, id: Me, "aria-label": Ne, "aria-labelledby": Pe, "aria-describedby": Fe, tabIndex: Ie, ...Le } = a, Re = l(null), S = l(null), C = l(null), ze = l(null), Be = l([]), Ve = c(() => i(Re, m), [m]), w = r(), He = ie({
|
|
16
|
+
defaultZIndex: re.dropdown,
|
|
17
|
+
zIndex: be
|
|
18
|
+
}), T = me || _, E = ge || _, Ue = c(() => E ? [] : null, [E]), We = n(a, "value"), D = l(void 0), [O, Ge] = t({
|
|
19
|
+
value: fe ?? Ue,
|
|
20
|
+
defaultValue: pe ?? Ue,
|
|
21
|
+
controlled: We,
|
|
22
|
+
onChange: (e) => {
|
|
23
|
+
let t = D.current;
|
|
24
|
+
D.current = void 0, Ee?.(e, t);
|
|
25
|
+
}
|
|
26
|
+
}), [k, Ke] = u(!1), [qe, Je] = u(!1), [A, j] = u(""), [Ye, M] = u([]), [Xe, Ze] = u({}), [Qe, $e] = u(x), [N, P] = u(-1), et = ne("vl-select-control", Me), F = ne("vl-select-listbox"), tt = o((e) => `${F}-option-${e}`, [F]), nt = c(() => ["vl-select-wrapper", we || ""].filter(Boolean).join(" "), [we]), rt = c(() => [
|
|
27
|
+
"vl-select",
|
|
28
|
+
`size-${_e}`,
|
|
29
|
+
E ? "is-multiple" : "",
|
|
30
|
+
k ? "is-open" : "",
|
|
31
|
+
qe ? "is-focus-within" : "",
|
|
32
|
+
y ? "is-disabled" : "",
|
|
33
|
+
b ? "is-loading" : ""
|
|
34
|
+
].filter(Boolean).join(" "), [
|
|
35
|
+
_e,
|
|
36
|
+
E,
|
|
37
|
+
k,
|
|
38
|
+
qe,
|
|
39
|
+
y,
|
|
40
|
+
b
|
|
41
|
+
]), I = c(() => {
|
|
42
|
+
if (!_) return h;
|
|
43
|
+
let e = Ye.filter((e) => !h.some((t) => t.value === e.value));
|
|
44
|
+
return [...h, ...e];
|
|
45
|
+
}, [
|
|
46
|
+
h,
|
|
47
|
+
Ye,
|
|
48
|
+
_
|
|
49
|
+
]), L = c(() => {
|
|
50
|
+
if (!T || !k) return I;
|
|
51
|
+
let e = A.trim().toLocaleLowerCase();
|
|
52
|
+
return e ? I.filter((t) => !t.divider && t.label.toLocaleLowerCase().includes(e)) : I;
|
|
53
|
+
}, [
|
|
54
|
+
I,
|
|
55
|
+
T,
|
|
56
|
+
k,
|
|
57
|
+
A
|
|
58
|
+
]), R = c(() => L.flatMap((e, t) => p(e) ? [t] : []), [L]), it = L.some((e) => !e.divider), z = c(() => E && Array.isArray(O) ? O : [], [E, O]), B = c(() => {
|
|
59
|
+
if (!(E || Array.isArray(O))) return I.find((e) => e.value === O);
|
|
60
|
+
}, [
|
|
61
|
+
I,
|
|
62
|
+
E,
|
|
63
|
+
O
|
|
64
|
+
]), V = c(() => E ? "" : B ? B.label : O === null || O === "" || Array.isArray(O) ? "" : String(O), [
|
|
65
|
+
E,
|
|
66
|
+
B,
|
|
67
|
+
O
|
|
68
|
+
]), H = c(() => z.map((e) => ({
|
|
69
|
+
value: e,
|
|
70
|
+
label: I.find((t) => t.value === e)?.label ?? String(e)
|
|
71
|
+
})), [z, I]), at = c(() => !E || v === void 0 || !Number.isFinite(v) ? Infinity : Math.max(0, Math.floor(v)), [E, v]), ot = at === Infinity ? H : H.slice(0, at), U = Math.max(0, H.length - ot.length), st = E ? z.length > 0 : O !== null && O !== "" && !Array.isArray(O), ct = ve && !y && !b && st, lt = N >= 0 && p(L[N]) ? tt(N) : void 0, ut = c(() => ["vl-select__panel", `is-${Qe}`].join(" "), [Qe]), W = o((e) => {
|
|
72
|
+
e && (y || b) || k !== e && (Ke(e), e ? Oe?.() : ke?.());
|
|
73
|
+
}, [
|
|
74
|
+
y,
|
|
75
|
+
b,
|
|
76
|
+
Oe,
|
|
77
|
+
ke,
|
|
78
|
+
k
|
|
79
|
+
]), G = o((e) => E ? z.includes(e.value) : e.value === O, [
|
|
80
|
+
E,
|
|
81
|
+
z,
|
|
82
|
+
O
|
|
83
|
+
]), K = o((e, t) => {
|
|
84
|
+
D.current = t, Ge(e), D.current = void 0;
|
|
85
|
+
}, [Ge]), q = o((e) => {
|
|
86
|
+
_ && M((t) => t.filter((t) => e.includes(t.value)));
|
|
87
|
+
}, [_]), J = o((e) => {
|
|
88
|
+
if (p(e)) {
|
|
89
|
+
if (E) {
|
|
90
|
+
let t = z.includes(e.value) ? z.filter((t) => t !== e.value) : [...z, e.value];
|
|
91
|
+
K(t, e), q(t), j("");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
K(e.value, e), j(e.label), W(!1);
|
|
95
|
+
}
|
|
96
|
+
}, [
|
|
97
|
+
E,
|
|
98
|
+
z,
|
|
99
|
+
K,
|
|
100
|
+
q,
|
|
101
|
+
W
|
|
102
|
+
]), dt = o((e) => {
|
|
103
|
+
if (!_) return !1;
|
|
104
|
+
let t = e.trim();
|
|
105
|
+
if (!t) return !1;
|
|
106
|
+
let n = t.toLocaleLowerCase(), r = I.find((e) => e.label.toLocaleLowerCase() === n || String(e.value).toLocaleLowerCase() === n);
|
|
107
|
+
if (r) return G(r) ? j("") : J(r), !0;
|
|
108
|
+
let i = {
|
|
109
|
+
label: t,
|
|
110
|
+
value: t
|
|
111
|
+
};
|
|
112
|
+
return M((e) => [...e, i]), J(i), !0;
|
|
113
|
+
}, [
|
|
114
|
+
_,
|
|
115
|
+
I,
|
|
116
|
+
G,
|
|
117
|
+
J
|
|
118
|
+
]), Y = o(() => {
|
|
119
|
+
let e = L.findIndex((e) => p(e) && G(e));
|
|
120
|
+
return e >= 0 ? e : R[0] ?? -1;
|
|
121
|
+
}, [
|
|
122
|
+
L,
|
|
123
|
+
R,
|
|
124
|
+
G
|
|
125
|
+
]), X = o((e) => {
|
|
126
|
+
p(L[e]) && (P(e), Be.current[e]?.scrollIntoView?.({ block: "nearest" }));
|
|
127
|
+
}, [L]), ft = o((e) => {
|
|
128
|
+
if (!R.length) return;
|
|
129
|
+
let t = R.indexOf(N), n = (t >= 0 ? t + e : (e > 0 ? -1 : 0) + e + R.length) % R.length;
|
|
130
|
+
X(R[n]);
|
|
131
|
+
}, [
|
|
132
|
+
R,
|
|
133
|
+
N,
|
|
134
|
+
X
|
|
135
|
+
]), pt = o(() => {
|
|
136
|
+
let e = R[0];
|
|
137
|
+
e !== void 0 && X(e);
|
|
138
|
+
}, [R, X]), mt = o(() => {
|
|
139
|
+
let e = R.at(-1);
|
|
140
|
+
e !== void 0 && X(e);
|
|
141
|
+
}, [R, X]), Z = o(() => {
|
|
142
|
+
if (!k) return;
|
|
143
|
+
let e = S.current, t = C.current;
|
|
144
|
+
if (!e || !t) return;
|
|
145
|
+
let n = e.getBoundingClientRect(), r = te({
|
|
146
|
+
anchorRect: n,
|
|
147
|
+
floatingRect: t.getBoundingClientRect(),
|
|
148
|
+
placement: x,
|
|
149
|
+
offset: ye
|
|
150
|
+
});
|
|
151
|
+
$e(r.placement), Ze({
|
|
152
|
+
left: `${Math.round(r.x)}px`,
|
|
153
|
+
top: `${Math.round(r.y)}px`,
|
|
154
|
+
minWidth: `${Math.round(n.width)}px`
|
|
155
|
+
});
|
|
156
|
+
}, [
|
|
157
|
+
k,
|
|
158
|
+
x,
|
|
159
|
+
ye
|
|
160
|
+
]), Q = o(() => {
|
|
161
|
+
T ? ze.current?.focus() : S.current?.focus();
|
|
162
|
+
}, [T]), $ = o((e = "first") => {
|
|
163
|
+
if (y || b) return;
|
|
164
|
+
k || (T && j(""), W(!0));
|
|
165
|
+
let t = e === "last" ? R.at(-1) : Y();
|
|
166
|
+
t !== void 0 && t >= 0 && P(t), window.requestAnimationFrame(() => {
|
|
167
|
+
Q(), Z();
|
|
168
|
+
});
|
|
169
|
+
}, [
|
|
170
|
+
y,
|
|
171
|
+
b,
|
|
172
|
+
k,
|
|
173
|
+
T,
|
|
174
|
+
W,
|
|
175
|
+
R,
|
|
176
|
+
Y,
|
|
177
|
+
Q,
|
|
178
|
+
Z
|
|
179
|
+
]), ht = o(() => {
|
|
180
|
+
W(!1), window.requestAnimationFrame(Q);
|
|
181
|
+
}, [W, Q]), gt = o(() => {
|
|
182
|
+
let e = L[N];
|
|
183
|
+
return p(e) ? (J(e), !0) : !1;
|
|
184
|
+
}, [
|
|
185
|
+
L,
|
|
186
|
+
N,
|
|
187
|
+
J
|
|
188
|
+
]), _t = (e) => {
|
|
189
|
+
if (!(y || b) && !e.target.closest("button")) {
|
|
190
|
+
if (T) {
|
|
191
|
+
$();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
k ? W(!1) : $();
|
|
195
|
+
}
|
|
196
|
+
}, vt = (e) => {
|
|
197
|
+
if (!(y || b)) {
|
|
198
|
+
if (e.key === "ArrowDown") {
|
|
199
|
+
e.preventDefault(), k ? ft(1) : $("first");
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (e.key === "ArrowUp") {
|
|
203
|
+
e.preventDefault(), k ? ft(-1) : $("last");
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (e.key === "Home" && k && !T) {
|
|
207
|
+
e.preventDefault(), pt();
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (e.key === "End" && k && !T) {
|
|
211
|
+
e.preventDefault(), mt();
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (e.key === "Escape" && k) {
|
|
215
|
+
e.preventDefault(), ht();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (e.key === "Tab" && k) {
|
|
219
|
+
W(!1);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (e.key === "Enter") {
|
|
223
|
+
if (!k) {
|
|
224
|
+
e.preventDefault(), $();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
e.preventDefault(), !gt() && T && dt(A);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (e.key === " " && !T) {
|
|
231
|
+
e.preventDefault(), k ? gt() : $();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (e.key === "Backspace" && T && E && !A && z.length) {
|
|
235
|
+
let e = z.slice(0, -1);
|
|
236
|
+
K(e), q(e);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}, yt = () => {
|
|
240
|
+
y || b || (K(E ? [] : null), De?.(), j(""), q([]), W(!1), Q());
|
|
241
|
+
}, bt = (e) => {
|
|
242
|
+
if (y || b) return;
|
|
243
|
+
let t = z.filter((t) => t !== e);
|
|
244
|
+
K(t), q(t);
|
|
245
|
+
}, xt = (e) => {
|
|
246
|
+
e.currentTarget.contains(e.relatedTarget) || (Je(!0), Ae?.(e));
|
|
247
|
+
}, St = (e) => {
|
|
248
|
+
e.currentTarget.contains(e.relatedTarget) || (Je(!1), je?.(e));
|
|
249
|
+
};
|
|
250
|
+
s(() => {
|
|
251
|
+
k || (j(E ? "" : V), P(-1));
|
|
252
|
+
}, [
|
|
253
|
+
k,
|
|
254
|
+
E,
|
|
255
|
+
V
|
|
256
|
+
]), s(() => {
|
|
257
|
+
if (!k || !w) return;
|
|
258
|
+
P(Y());
|
|
259
|
+
let e = window.requestAnimationFrame(Z);
|
|
260
|
+
return () => window.cancelAnimationFrame(e);
|
|
261
|
+
}, [
|
|
262
|
+
k,
|
|
263
|
+
w,
|
|
264
|
+
L,
|
|
265
|
+
Y,
|
|
266
|
+
Z
|
|
267
|
+
]), s(() => {
|
|
268
|
+
if (!_ || !E) return;
|
|
269
|
+
let e = new Set(I.map((e) => e.value)), t = z.filter((t) => !e.has(t));
|
|
270
|
+
t.length && M((e) => [...e, ...t.map((e) => ({
|
|
271
|
+
label: String(e),
|
|
272
|
+
value: e
|
|
273
|
+
}))]);
|
|
274
|
+
}, [
|
|
275
|
+
_,
|
|
276
|
+
E,
|
|
277
|
+
I,
|
|
278
|
+
z
|
|
279
|
+
]), s(() => {
|
|
280
|
+
(y || b) && k && W(!1);
|
|
281
|
+
}, [
|
|
282
|
+
y,
|
|
283
|
+
b,
|
|
284
|
+
k,
|
|
285
|
+
W
|
|
286
|
+
]), ee({
|
|
287
|
+
active: k && w,
|
|
288
|
+
rootRef: Re,
|
|
289
|
+
floatingRef: C,
|
|
290
|
+
onOutsideClick: () => W(!1),
|
|
291
|
+
onViewportChange: Z
|
|
292
|
+
});
|
|
293
|
+
let Ct = {
|
|
294
|
+
role: "combobox",
|
|
295
|
+
"aria-controls": F,
|
|
296
|
+
"aria-expanded": k,
|
|
297
|
+
"aria-haspopup": "listbox",
|
|
298
|
+
"aria-activedescendant": k ? lt : void 0,
|
|
299
|
+
"aria-disabled": y || b || void 0,
|
|
300
|
+
"aria-busy": b || void 0,
|
|
301
|
+
"aria-label": Ne ?? (Pe ? void 0 : g),
|
|
302
|
+
"aria-labelledby": Pe,
|
|
303
|
+
"aria-describedby": Fe
|
|
304
|
+
}, wt = T ? /* @__PURE__ */ d("input", {
|
|
305
|
+
ref: ze,
|
|
306
|
+
id: et,
|
|
307
|
+
className: "vl-select__input",
|
|
308
|
+
type: "text",
|
|
309
|
+
value: A,
|
|
310
|
+
placeholder: k ? he : E && z.length ? "" : g,
|
|
311
|
+
disabled: y || b,
|
|
312
|
+
autoComplete: "off",
|
|
313
|
+
"aria-autocomplete": "list",
|
|
314
|
+
...Ct,
|
|
315
|
+
tabIndex: Ie,
|
|
316
|
+
onChange: (e) => {
|
|
317
|
+
j(e.target.value), k || W(!0);
|
|
318
|
+
},
|
|
319
|
+
onFocus: () => {
|
|
320
|
+
k || $();
|
|
321
|
+
},
|
|
322
|
+
onKeyDown: vt
|
|
323
|
+
}) : null, Tt = /* @__PURE__ */ d(oe, {
|
|
324
|
+
show: k,
|
|
325
|
+
name: "vl-select",
|
|
326
|
+
deferEffects: !w,
|
|
327
|
+
children: /* @__PURE__ */ d("div", {
|
|
328
|
+
ref: C,
|
|
329
|
+
id: F,
|
|
330
|
+
className: ut,
|
|
331
|
+
style: {
|
|
332
|
+
...Xe,
|
|
333
|
+
zIndex: He.zIndex
|
|
334
|
+
},
|
|
335
|
+
role: "listbox",
|
|
336
|
+
"aria-hidden": !k || void 0,
|
|
337
|
+
"aria-multiselectable": E || void 0,
|
|
338
|
+
children: it ? /* @__PURE__ */ d("div", {
|
|
339
|
+
className: "vl-select__list",
|
|
340
|
+
children: L.map((t, n) => {
|
|
341
|
+
if (t.divider) return /* @__PURE__ */ d("div", {
|
|
342
|
+
className: "vl-select__divider",
|
|
343
|
+
role: "separator"
|
|
344
|
+
}, `divider-${n}`);
|
|
345
|
+
let r = G(t), i = [
|
|
346
|
+
"vl-select__option",
|
|
347
|
+
t.disabled ? "is-disabled" : "",
|
|
348
|
+
r ? "is-selected" : "",
|
|
349
|
+
N === n ? "is-active" : ""
|
|
350
|
+
].filter(Boolean).join(" ");
|
|
351
|
+
return /* @__PURE__ */ d("div", {
|
|
352
|
+
ref: (e) => {
|
|
353
|
+
Be.current[n] = e;
|
|
354
|
+
},
|
|
355
|
+
id: tt(n),
|
|
356
|
+
className: i,
|
|
357
|
+
role: "option",
|
|
358
|
+
"aria-disabled": t.disabled || void 0,
|
|
359
|
+
"aria-selected": r,
|
|
360
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
361
|
+
onMouseEnter: () => {
|
|
362
|
+
p(t) && P(n);
|
|
363
|
+
},
|
|
364
|
+
onClick: () => J(t),
|
|
365
|
+
children: Se ? Se(t, n, r) : /* @__PURE__ */ f(ue, { children: [t.icon ? e(t.icon, "vl-select__option-icon") : null, /* @__PURE__ */ d("span", {
|
|
366
|
+
className: "vl-select__option-label",
|
|
367
|
+
children: t.label
|
|
368
|
+
})] })
|
|
369
|
+
}, `${String(t.value)}-${n}`);
|
|
370
|
+
})
|
|
371
|
+
}) : /* @__PURE__ */ d("div", {
|
|
372
|
+
className: "vl-select__empty",
|
|
373
|
+
role: "status",
|
|
374
|
+
children: Ce ?? xe
|
|
375
|
+
})
|
|
376
|
+
})
|
|
377
|
+
});
|
|
378
|
+
return /* @__PURE__ */ d(ae, {
|
|
379
|
+
layer: He.layer,
|
|
380
|
+
children: /* @__PURE__ */ f("div", {
|
|
381
|
+
ref: Ve,
|
|
382
|
+
className: nt,
|
|
383
|
+
style: Te,
|
|
384
|
+
...Le,
|
|
385
|
+
children: [/* @__PURE__ */ f("div", {
|
|
386
|
+
ref: S,
|
|
387
|
+
id: T ? void 0 : et,
|
|
388
|
+
className: rt,
|
|
389
|
+
...T ? {} : Ct,
|
|
390
|
+
tabIndex: y || b || T ? -1 : Ie ?? 0,
|
|
391
|
+
onClick: _t,
|
|
392
|
+
onKeyDown: T ? void 0 : vt,
|
|
393
|
+
onFocus: xt,
|
|
394
|
+
onBlur: St,
|
|
395
|
+
children: [/* @__PURE__ */ d("div", {
|
|
396
|
+
className: "vl-select__value",
|
|
397
|
+
children: E ? /* @__PURE__ */ f("div", {
|
|
398
|
+
className: "vl-select__tags",
|
|
399
|
+
children: [
|
|
400
|
+
ot.map((e) => /* @__PURE__ */ f("span", {
|
|
401
|
+
className: "vl-select__tag",
|
|
402
|
+
children: [/* @__PURE__ */ d("span", {
|
|
403
|
+
className: "vl-select__tag-label",
|
|
404
|
+
children: e.label
|
|
405
|
+
}), /* @__PURE__ */ d("button", {
|
|
406
|
+
type: "button",
|
|
407
|
+
className: "vl-select__tag-remove",
|
|
408
|
+
"aria-label": `移除 ${e.label}`,
|
|
409
|
+
disabled: y || b,
|
|
410
|
+
onClick: () => bt(e.value),
|
|
411
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
412
|
+
children: /* @__PURE__ */ d(le, {
|
|
413
|
+
size: 12,
|
|
414
|
+
"aria-hidden": "true"
|
|
415
|
+
})
|
|
416
|
+
})]
|
|
417
|
+
}, e.value)),
|
|
418
|
+
U > 0 ? /* @__PURE__ */ f("span", {
|
|
419
|
+
className: "vl-select__tag is-collapsed",
|
|
420
|
+
"aria-label": `另有 ${U} 项`,
|
|
421
|
+
children: ["+", U]
|
|
422
|
+
}) : null,
|
|
423
|
+
T ? wt : H.length ? null : /* @__PURE__ */ d("span", {
|
|
424
|
+
className: "vl-select__placeholder",
|
|
425
|
+
children: g
|
|
426
|
+
})
|
|
427
|
+
]
|
|
428
|
+
}) : T ? wt : V ? /* @__PURE__ */ d("span", {
|
|
429
|
+
className: "vl-select__label",
|
|
430
|
+
children: V
|
|
431
|
+
}) : /* @__PURE__ */ d("span", {
|
|
432
|
+
className: "vl-select__placeholder",
|
|
433
|
+
children: g
|
|
434
|
+
})
|
|
435
|
+
}), /* @__PURE__ */ f("div", {
|
|
436
|
+
className: "vl-select__suffix",
|
|
437
|
+
children: [ct ? /* @__PURE__ */ d("button", {
|
|
438
|
+
type: "button",
|
|
439
|
+
className: "vl-select__clear",
|
|
440
|
+
"aria-label": "清除已选",
|
|
441
|
+
onClick: yt,
|
|
442
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
443
|
+
children: /* @__PURE__ */ d(le, {
|
|
444
|
+
size: 16,
|
|
445
|
+
"aria-hidden": "true"
|
|
446
|
+
})
|
|
447
|
+
}) : null, b ? /* @__PURE__ */ d(ce, {
|
|
448
|
+
className: "vl-select__loading",
|
|
449
|
+
size: 16,
|
|
450
|
+
"aria-hidden": "true"
|
|
451
|
+
}) : /* @__PURE__ */ d("span", {
|
|
452
|
+
className: "vl-select__arrow",
|
|
453
|
+
"aria-hidden": "true",
|
|
454
|
+
children: /* @__PURE__ */ d(se, { size: 16 })
|
|
455
|
+
})]
|
|
456
|
+
})]
|
|
457
|
+
}), w ? de(Tt, document.body) : Tt]
|
|
458
|
+
})
|
|
459
|
+
});
|
|
460
|
+
});
|
|
461
|
+
m.displayName = "VlSelect";
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region components/Select/index.ts
|
|
464
|
+
var fe = m, pe = m;
|
|
465
|
+
//#endregion
|
|
466
|
+
export { fe as n, pe as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./icon-DRLyKu8p.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./floating-5PRFyI8D.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),te=require("./Transition-X_89ga-e.cjs");let o=require("lucide-react"),s=require("react"),c=require("react/jsx-runtime"),ne=require("react-dom");var l=e=>!!(e&&!e.disabled&&!e.divider),u=(0,s.forwardRef)((u,d)=>{let{value:re,defaultValue:ie,options:f=[],placeholder:p=`请选择`,filterable:ae=!1,filterPlaceholder:oe=`搜索`,multiple:se=!1,taggable:m=!1,maxTagCount:h,disabled:g=!1,loading:_=!1,size:ce=`md`,clearable:le=!1,placement:v=`bottom-start`,offset:ue=8,zIndex:de,emptyText:fe=`暂无数据`,renderOption:pe,emptyContent:me,className:he,style:ge,onChange:_e,onClear:ve,onOpen:ye,onClose:be,onFocus:xe,onBlur:Se,id:Ce,"aria-label":we,"aria-labelledby":Te,"aria-describedby":Ee,tabIndex:De,...Oe}=u,ke=(0,s.useRef)(null),y=(0,s.useRef)(null),b=(0,s.useRef)(null),Ae=(0,s.useRef)(null),je=(0,s.useRef)([]),Me=(0,s.useMemo)(()=>r.n(ke,d),[d]),x=n.t(),S=a.r({defaultZIndex:a.n.dropdown,zIndex:de}),C=ae||m,w=se||m,Ne=(0,s.useMemo)(()=>w?[]:null,[w]),Pe=t.t(u,`value`),T=(0,s.useRef)(void 0),[E,Fe]=t.n({value:re??Ne,defaultValue:ie??Ne,controlled:Pe,onChange:e=>{let t=T.current;T.current=void 0,_e?.(e,t)}}),[D,Ie]=(0,s.useState)(!1),[Le,Re]=(0,s.useState)(!1),[O,k]=(0,s.useState)(``),[ze,A]=(0,s.useState)([]),[Be,Ve]=(0,s.useState)({}),[He,Ue]=(0,s.useState)(v),[j,M]=(0,s.useState)(-1),We=ee.t(`vl-select-control`,Ce),N=ee.t(`vl-select-listbox`),P=(0,s.useCallback)(e=>`${N}-option-${e}`,[N]),Ge=(0,s.useMemo)(()=>[`vl-select-wrapper`,he||``].filter(Boolean).join(` `),[he]),Ke=(0,s.useMemo)(()=>[`vl-select`,`size-${ce}`,w?`is-multiple`:``,D?`is-open`:``,Le?`is-focus-within`:``,g?`is-disabled`:``,_?`is-loading`:``].filter(Boolean).join(` `),[ce,w,D,Le,g,_]),F=(0,s.useMemo)(()=>{if(!m)return f;let e=ze.filter(e=>!f.some(t=>t.value===e.value));return[...f,...e]},[f,ze,m]),I=(0,s.useMemo)(()=>{if(!C||!D)return F;let e=O.trim().toLocaleLowerCase();return e?F.filter(t=>!t.divider&&t.label.toLocaleLowerCase().includes(e)):F},[F,C,D,O]),L=(0,s.useMemo)(()=>I.flatMap((e,t)=>l(e)?[t]:[]),[I]),qe=I.some(e=>!e.divider),R=(0,s.useMemo)(()=>w&&Array.isArray(E)?E:[],[w,E]),z=(0,s.useMemo)(()=>{if(!(w||Array.isArray(E)))return F.find(e=>e.value===E)},[F,w,E]),B=(0,s.useMemo)(()=>w?``:z?z.label:E===null||E===``||Array.isArray(E)?``:String(E),[w,z,E]),V=(0,s.useMemo)(()=>R.map(e=>({value:e,label:F.find(t=>t.value===e)?.label??String(e)})),[R,F]),Je=(0,s.useMemo)(()=>!w||h===void 0||!Number.isFinite(h)?1/0:Math.max(0,Math.floor(h)),[w,h]),Ye=Je===1/0?V:V.slice(0,Je),H=Math.max(0,V.length-Ye.length),Xe=w?R.length>0:E!==null&&E!==``&&!Array.isArray(E),Ze=le&&!g&&!_&&Xe,Qe=j>=0&&l(I[j])?P(j):void 0,$e=(0,s.useMemo)(()=>[`vl-select__panel`,`is-${He}`].join(` `),[He]),U=(0,s.useCallback)(e=>{e&&(g||_)||D!==e&&(Ie(e),e?ye?.():be?.())},[g,_,ye,be,D]),W=(0,s.useCallback)(e=>w?R.includes(e.value):e.value===E,[w,R,E]),G=(0,s.useCallback)((e,t)=>{T.current=t,Fe(e),T.current=void 0},[Fe]),K=(0,s.useCallback)(e=>{m&&A(t=>t.filter(t=>e.includes(t.value)))},[m]),q=(0,s.useCallback)(e=>{if(l(e)){if(w){let t=R.includes(e.value)?R.filter(t=>t!==e.value):[...R,e.value];G(t,e),K(t),k(``);return}G(e.value,e),k(e.label),U(!1)}},[w,R,G,K,U]),et=(0,s.useCallback)(e=>{if(!m)return!1;let t=e.trim();if(!t)return!1;let n=t.toLocaleLowerCase(),r=F.find(e=>e.label.toLocaleLowerCase()===n||String(e.value).toLocaleLowerCase()===n);if(r)return W(r)?k(``):q(r),!0;let i={label:t,value:t};return A(e=>[...e,i]),q(i),!0},[m,F,W,q]),J=(0,s.useCallback)(()=>{let e=I.findIndex(e=>l(e)&&W(e));return e>=0?e:L[0]??-1},[I,L,W]),Y=(0,s.useCallback)(e=>{l(I[e])&&(M(e),je.current[e]?.scrollIntoView?.({block:`nearest`}))},[I]),tt=(0,s.useCallback)(e=>{if(!L.length)return;let t=L.indexOf(j),n=(t>=0?t+e:(e>0?-1:0)+e+L.length)%L.length;Y(L[n])},[L,j,Y]),nt=(0,s.useCallback)(()=>{let e=L[0];e!==void 0&&Y(e)},[L,Y]),rt=(0,s.useCallback)(()=>{let e=L.at(-1);e!==void 0&&Y(e)},[L,Y]),X=(0,s.useCallback)(()=>{if(!D)return;let e=y.current,t=b.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=i.t({anchorRect:n,floatingRect:t.getBoundingClientRect(),placement:v,offset:ue});Ue(r.placement),Ve({left:`${Math.round(r.x)}px`,top:`${Math.round(r.y)}px`,minWidth:`${Math.round(n.width)}px`})},[D,v,ue]),Z=(0,s.useCallback)(()=>{C?Ae.current?.focus():y.current?.focus()},[C]),Q=(0,s.useCallback)((e=`first`)=>{if(g||_)return;D||(C&&k(``),U(!0));let t=e===`last`?L.at(-1):J();t!==void 0&&t>=0&&M(t),window.requestAnimationFrame(()=>{Z(),X()})},[g,_,D,C,U,L,J,Z,X]),it=(0,s.useCallback)(()=>{U(!1),window.requestAnimationFrame(Z)},[U,Z]),at=(0,s.useCallback)(()=>{let e=I[j];return l(e)?(q(e),!0):!1},[I,j,q]),ot=e=>{if(!(g||_)&&!e.target.closest(`button`)){if(C){Q();return}D?U(!1):Q()}},st=e=>{if(!(g||_)){if(e.key===`ArrowDown`){e.preventDefault(),D?tt(1):Q(`first`);return}if(e.key===`ArrowUp`){e.preventDefault(),D?tt(-1):Q(`last`);return}if(e.key===`Home`&&D&&!C){e.preventDefault(),nt();return}if(e.key===`End`&&D&&!C){e.preventDefault(),rt();return}if(e.key===`Escape`&&D){e.preventDefault(),it();return}if(e.key===`Tab`&&D){U(!1);return}if(e.key===`Enter`){if(!D){e.preventDefault(),Q();return}e.preventDefault(),!at()&&C&&et(O);return}if(e.key===` `&&!C){e.preventDefault(),D?at():Q();return}if(e.key===`Backspace`&&C&&w&&!O&&R.length){let e=R.slice(0,-1);G(e),K(e)}}},ct=()=>{g||_||(G(w?[]:null),ve?.(),k(``),K([]),U(!1),Z())},lt=e=>{if(g||_)return;let t=R.filter(t=>t!==e);G(t),K(t)},ut=e=>{e.currentTarget.contains(e.relatedTarget)||(Re(!0),xe?.(e))},dt=e=>{e.currentTarget.contains(e.relatedTarget)||(Re(!1),Se?.(e))};(0,s.useEffect)(()=>{D||(k(w?``:B),M(-1))},[D,w,B]),(0,s.useEffect)(()=>{if(!D||!x)return;M(J());let e=window.requestAnimationFrame(X);return()=>window.cancelAnimationFrame(e)},[D,x,I,J,X]),(0,s.useEffect)(()=>{if(!m||!w)return;let e=new Set(F.map(e=>e.value)),t=R.filter(t=>!e.has(t));t.length&&A(e=>[...e,...t.map(e=>({label:String(e),value:e}))])},[m,w,F,R]),(0,s.useEffect)(()=>{(g||_)&&D&&U(!1)},[g,_,D,U]),i.r({active:D&&x,rootRef:ke,floatingRef:b,onOutsideClick:()=>U(!1),onViewportChange:X});let ft={role:`combobox`,"aria-controls":N,"aria-expanded":D,"aria-haspopup":`listbox`,"aria-activedescendant":D?Qe:void 0,"aria-disabled":g||_||void 0,"aria-busy":_||void 0,"aria-label":we??(Te?void 0:p),"aria-labelledby":Te,"aria-describedby":Ee},pt=C?(0,c.jsx)(`input`,{ref:Ae,id:We,className:`vl-select__input`,type:`text`,value:O,placeholder:D?oe:w&&R.length?``:p,disabled:g||_,autoComplete:`off`,"aria-autocomplete":`list`,...ft,tabIndex:De,onChange:e=>{k(e.target.value),D||U(!0)},onFocus:()=>{D||Q()},onKeyDown:st}):null,$=(0,c.jsx)(te.t,{show:D,name:`vl-select`,deferEffects:!x,children:(0,c.jsx)(`div`,{ref:b,id:N,className:$e,style:{...Be,zIndex:S.zIndex},role:`listbox`,"aria-hidden":!D||void 0,"aria-multiselectable":w||void 0,children:qe?(0,c.jsx)(`div`,{className:`vl-select__list`,children:I.map((t,n)=>{if(t.divider)return(0,c.jsx)(`div`,{className:`vl-select__divider`,role:`separator`},`divider-${n}`);let r=W(t),i=[`vl-select__option`,t.disabled?`is-disabled`:``,r?`is-selected`:``,j===n?`is-active`:``].filter(Boolean).join(` `);return(0,c.jsx)(`div`,{ref:e=>{je.current[n]=e},id:P(n),className:i,role:`option`,"aria-disabled":t.disabled||void 0,"aria-selected":r,onPointerDown:e=>e.preventDefault(),onMouseEnter:()=>{l(t)&&M(n)},onClick:()=>q(t),children:pe?pe(t,n,r):(0,c.jsxs)(c.Fragment,{children:[t.icon?e.t(t.icon,`vl-select__option-icon`):null,(0,c.jsx)(`span`,{className:`vl-select__option-label`,children:t.label})]})},`${String(t.value)}-${n}`)})}):(0,c.jsx)(`div`,{className:`vl-select__empty`,role:`status`,children:me??fe})})});return(0,c.jsx)(a.t,{layer:S.layer,children:(0,c.jsxs)(`div`,{ref:Me,className:Ge,style:ge,...Oe,children:[(0,c.jsxs)(`div`,{ref:y,id:C?void 0:We,className:Ke,...C?{}:ft,tabIndex:g||_||C?-1:De??0,onClick:ot,onKeyDown:C?void 0:st,onFocus:ut,onBlur:dt,children:[(0,c.jsx)(`div`,{className:`vl-select__value`,children:w?(0,c.jsxs)(`div`,{className:`vl-select__tags`,children:[Ye.map(e=>(0,c.jsxs)(`span`,{className:`vl-select__tag`,children:[(0,c.jsx)(`span`,{className:`vl-select__tag-label`,children:e.label}),(0,c.jsx)(`button`,{type:`button`,className:`vl-select__tag-remove`,"aria-label":`移除 ${e.label}`,disabled:g||_,onClick:()=>lt(e.value),onPointerDown:e=>e.stopPropagation(),children:(0,c.jsx)(o.X,{size:12,"aria-hidden":`true`})})]},e.value)),H>0?(0,c.jsxs)(`span`,{className:`vl-select__tag is-collapsed`,"aria-label":`另有 ${H} 项`,children:[`+`,H]}):null,C?pt:V.length?null:(0,c.jsx)(`span`,{className:`vl-select__placeholder`,children:p})]}):C?pt:B?(0,c.jsx)(`span`,{className:`vl-select__label`,children:B}):(0,c.jsx)(`span`,{className:`vl-select__placeholder`,children:p})}),(0,c.jsxs)(`div`,{className:`vl-select__suffix`,children:[Ze?(0,c.jsx)(`button`,{type:`button`,className:`vl-select__clear`,"aria-label":`清除已选`,onClick:ct,onPointerDown:e=>e.stopPropagation(),children:(0,c.jsx)(o.X,{size:16,"aria-hidden":`true`})}):null,_?(0,c.jsx)(o.LoaderCircle,{className:`vl-select__loading`,size:16,"aria-hidden":`true`}):(0,c.jsx)(`span`,{className:`vl-select__arrow`,"aria-hidden":`true`,children:(0,c.jsx)(o.ChevronDown,{size:16})})]})]}),x?(0,ne.createPortal)($,document.body):$]})})});u.displayName=`VlSelect`;var d=u,re=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return re}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
-
import { t } from "./state-
|
|
2
|
+
import { t } from "./state-BSDh-Ob2.js";
|
|
3
3
|
import { t as n } from "./number-BN2jHM6Z.js";
|
|
4
4
|
import { forwardRef as r, useCallback as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
5
5
|
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|