@synertech/ui 0.56.1 → 0.57.1
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/.claude/skills/use-synertech-ui/SKILL.md +8 -1
- package/README.md +20 -0
- package/dist/components/advance-detachable/AdvanceDetachable.cjs +1 -1
- package/dist/components/advance-detachable/AdvanceDetachable.js +1 -1
- package/dist/components/file-selector/FileSelector.cjs +1 -1
- package/dist/components/file-selector/FileSelector.js +1 -1
- package/dist/components/form/shared/inputStyles.cjs +1 -1
- package/dist/components/form/shared/inputStyles.js +1 -1
- package/dist/components/header/Header.cjs +1 -1
- package/dist/components/header/Header.js +1 -1
- package/dist/components/indicator/Indicator.cjs +1 -1
- package/dist/components/indicator/Indicator.js +1 -1
- package/dist/components/radio-button/RadioButton.cjs +1 -1
- package/dist/components/radio-button/RadioButton.js +1 -1
- package/dist/components/select/Select.cjs +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/lib/cn.cjs +1 -1
- package/dist/lib/cn.js +1 -1
- package/dist/styles-no-preflight.css +60 -0
- package/dist/styles.css +60 -0
- package/package.json +3 -2
|
@@ -190,6 +190,13 @@ composant à envelopper :
|
|
|
190
190
|
Les props de couleur (`bgColor`, `checkedColor`, `progressColor`…) l'emportent toujours
|
|
191
191
|
sur la rampe, composant par composant.
|
|
192
192
|
|
|
193
|
+
**Surcharger un composant par `className`** : depuis la 0.57.0, une classe passée par
|
|
194
|
+
`className` remplace celle du composant qui règle la même chose (`cn()` résout les conflits
|
|
195
|
+
avec `tailwind-merge`, la dernière écrite l'emporte). `<Button className="bg-red-600">` est
|
|
196
|
+
rouge, quel que soit l'ordre des feuilles de styles. Une classe ne remplace que celle qui
|
|
197
|
+
porte les mêmes variantes : écrire aussi `hover:` et `dark:` (`bg-red-600 hover:bg-red-700
|
|
198
|
+
dark:bg-red-500`). Le suffixe `!` (`bg-red-600!`) n'est plus nécessaire.
|
|
199
|
+
|
|
193
200
|
**Anti-pattern** : passer `bgColor="bg-orange-600"` à chaque `Button` et vivre avec des
|
|
194
201
|
anneaux de focus et des barres de progression bleus partout ailleurs. La rampe repeint
|
|
195
202
|
tout le kit d'un coup. Dans une application qui a son propre jeton Tailwind
|
|
@@ -1863,7 +1870,7 @@ import { Button, Popover, PopoverClose, PopoverContent, PopoverTrigger } from "@
|
|
|
1863
1870
|
`disabled` et sa `ref` sont gardés. `PopoverClose` sans enfant dessine une
|
|
1864
1871
|
croix nommée « Close » (libellé `popoverClose`).
|
|
1865
1872
|
- La largeur est celle du contenu : donnez-la par `className` (`w-72`). Le
|
|
1866
|
-
padding par défaut est `p-4` ; `p-2
|
|
1873
|
+
padding par défaut est `p-4` ; `className="p-2"` le remplace.
|
|
1867
1874
|
|
|
1868
1875
|
### Tooltip
|
|
1869
1876
|
|
package/README.md
CHANGED
|
@@ -206,6 +206,26 @@ blue. Redefine it and the whole kit follows — no prop, no component to wrap:
|
|
|
206
206
|
The colour props (`bgColor`, `checkedColor`, `progressColor`…) still win over the ramp,
|
|
207
207
|
one component at a time.
|
|
208
208
|
|
|
209
|
+
### 7. Changing one component's classes
|
|
210
|
+
|
|
211
|
+
A `className` you pass replaces the component's own classes that set the same thing,
|
|
212
|
+
whatever the order of the stylesheets: the library resolves the conflict with
|
|
213
|
+
[`tailwind-merge`](https://github.com/dcastil/tailwind-merge), and the class written last
|
|
214
|
+
— yours — wins.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
// The fill and the padding are replaced, the rest of the button stays.
|
|
218
|
+
<Button className="bg-red-600 px-8">Delete</Button>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
- **A class only replaces one under the same variants.** `bg-red-600` replaces the fill,
|
|
222
|
+
not its `hover:` and `dark:` shades: write those too (`hover:bg-red-700
|
|
223
|
+
dark:bg-red-500`) for a button that stays red under the pointer and in the dark theme.
|
|
224
|
+
- **Your classes need your Tailwind.** The shipped stylesheet only holds the classes the
|
|
225
|
+
library uses; a class of your own is drawn by the Tailwind of your application.
|
|
226
|
+
- To change a colour everywhere at once, set the ramp above rather than a `className` on
|
|
227
|
+
each component.
|
|
228
|
+
|
|
209
229
|
## Usage
|
|
210
230
|
|
|
211
231
|
### Button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var j=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ue=(t,c)=>{for(var o in c)j(t,o,{get:c[o],enumerable:!0})},Fe=(t,c,o,w)=>{if(c&&typeof c=="object"||typeof c=="function")for(let p of $e(c))!He.call(t,p)&&p!==o&&j(t,p,{get:()=>c[p],enumerable:!(w=We(c,p))||w.enumerable});return t};var _e=t=>Fe(j({},"__esModule",{value:!0}),t);var nn={};Ue(nn,{AdvanceDetachable:()=>Me});module.exports=_e(nn);var e=require("react"),Se=require("react-dom"),Ne=require("../detachable/useMovableContent.cjs"),f=require("../detachable/popup-window.cjs"),Ie=require("../../lib/cn.cjs"),X=require("../../lib/layer-document.cjs"),d=require("react/jsx-runtime"),Je="@synertech/ui/AdvanceDetachable",je=300,qe="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Te={clock:0,writer:""};function Xe(t,c){return t.clock>c.clock||t.clock===c.clock&&t.writer>c.writer}var Ce=(t,c)=>t===void 0||c(t),q=t=>typeof t=="string",Ge=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0;function Ke(t,c){if(typeof t!="object"||t===null)return!1;let o=t;return o.channel!==c||!q(o.instanceId)?!1:o.type==="hello"?!0:o.type==="value-sync"&&q(o.payload)&&Ce(o.clock,Ge)&&Ce(o.writer,q)}var Qe=0;function Ye(){return`${Date.now()}-${++Qe}-${Math.random().toString(36).slice(2,8)}`}function Ae(t){try{return JSON.stringify(t)}catch{return String(t)}}function Ee(t){try{return JSON.parse(t)}catch{return t}}function Ze(){return typeof BroadcastChannel<"u"}function en({mode:t,id:c,title:o="",children:w,value:p,defaultValue:Le,onValueChange:G,isDetached:K,defaultDetached:Pe=!1,onDetachedChange:Q,onPopupBlocked:Y,features:Z,target:ee,autoFocus:ne=!0,className:Ve,detachedBodyClassName:te,disabled:re=!1,readOnly:ce=!1,closeOnMainWindowUnload:oe=!0,name:ue,serialize:le,deserialize:ae},xe){let a=K!==void 0,[Oe,k]=(0,e.useState)(Pe),T=a?K:Oe,x=p!==void 0,[Be,ze]=(0,e.useState)(Le),m=x?p:Be,[y,se]=(0,e.useState)(null),u=(0,e.useRef)(null),E=(0,e.useRef)(null),v=(0,e.useRef)(null),S=(0,e.useRef)(null),O=(0,e.useRef)(null),N=(0,e.useRef)(!1),C=(0,e.useRef)(null),I=(0,e.useRef)(null),M=(0,e.useRef)(null),h=(0,e.useRef)(null),s=(0,e.useRef)(Te),ie=(0,e.useRef)(null),[b]=(0,e.useState)(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),i=(0,e.useRef)({title:o,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:c});i.current={title:o,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:c};let L=(0,e.useRef)(le??Ae);L.current=le??Ae;let de=(0,e.useRef)(ae??Ee);de.current=ae??Ee;let fe=(0,e.useRef)(G);fe.current=G;let R=(0,e.useRef)(Q);R.current=Q;let pe=(0,e.useRef)(Y);pe.current=Y;let A=(0,Ne.useMovableContent)(t==="detach"?y:null),B=(0,e.useRef)(A.bringBack);B.current=A.bringBack;let z=(0,e.useRef)(T);z.current=T;let ge=(0,e.useRef)(m);ge.current=m;let g=`${Je}/${c}`,P=(0,e.useCallback)(()=>{C.current?.(),C.current=null,S.current&&(clearInterval(S.current),S.current=null),O.current?.(),O.current=null,se(null)},[]),V=(0,e.useCallback)(()=>{v.current&&(v.current.close(),v.current=null),I.current&&typeof window<"u"&&(window.removeEventListener("message",I.current),I.current=null)},[]),D=(0,e.useCallback)(n=>{let r={channel:g,instanceId:b,messageId:Ye(),origin:"main",timestamp:Date.now(),...n};v.current?v.current.postMessage(r):u.current&&!u.current.closed&&u.current.postMessage(r,"/")},[g,b]),W=(0,e.useCallback)(n=>{if(!Ke(n,g)||n.instanceId===b||i.current.readOnly)return;if(n.type==="hello"){if(s.current.clock===0||h.current===null)return;D({type:"value-sync",payload:h.current,...s.current});return}if(n.payload===void 0)return;let r=typeof n.clock=="number"?{clock:n.clock,writer:typeof n.writer=="string"?n.writer:n.instanceId}:{clock:s.current.clock+1,writer:n.instanceId};if(!Xe(r,s.current)||(s.current=r,n.payload===h.current)||(h.current=n.payload,n.payload===M.current))return;let l=de.current(n.payload);x||ze(l),fe.current?.(l)},[g,b,x,D]),me=(0,e.useCallback)(()=>{if(V(),!(typeof window>"u")){if(ie.current!==g){ie.current=g,s.current=Te,h.current=null;let n=ge.current;M.current=n===void 0?null:L.current(n)}if(Ze()){let n=new BroadcastChannel(g),r=l=>W(l.data);n.addEventListener("message",r),v.current=n}else{let n=r=>{let l=u.current;!l||r.source!==l||r.origin===window.location.origin&&W(r.data)};window.addEventListener("message",n),I.current=n}i.current.readOnly||D({type:"hello"})}},[g,V,W,D]),he=(0,e.useCallback)(n=>{let r=L.current(n);r!==M.current&&(M.current=r,!i.current.readOnly&&r!==h.current&&(h.current=r,s.current={clock:s.current.clock+1,writer:b},D({type:"value-sync",payload:r,...s.current})))},[b,D]),we=(0,e.useCallback)(()=>{if(typeof window>"u"||i.current.disabled||N.current||u.current&&!u.current.closed)return;N.current=!0;let n=i.current,r=window.open("",n.target||"",n.features||qe),l=r?(0,f.popupDocument)(r):null;if(!r||!l){N.current=!1,a||k(!1),R.current?.(!1),pe.current?.();return}(0,f.severOpener)(r),u.current=r,E.current=l,l.title=n.title||document.title;let De=l.createElement("div");l.body.appendChild(De),se(De),O.current=(0,f.mirrorDocument)(document,l,{bodyClassName:n.detachedBodyClassName});let ke=!1,J=()=>{ke||(ke=!0,B.current(),P(),u.current=null,E.current=null,a||k(!1),R.current?.(!1))};r.addEventListener("pagehide",J),C.current=()=>r.removeEventListener("pagehide",J),S.current=setInterval(()=>{(0,f.popupDocument)(r,l)||J()},je),n.autoFocus&&r.focus(),N.current=!1},[a,P]),ye=(0,e.useCallback)(()=>{B.current();let n=u.current;u.current=null,E.current=null,P(),n&&!n.closed&&n.close()},[P]),ve=(0,e.useRef)(we);ve.current=we;let $=(0,e.useRef)(ye);$.current=ye;let be=(0,e.useRef)(he);be.current=he;let H=(0,e.useCallback)(()=>{i.current.disabled||(a||k(!0),R.current?.(!0))},[a]),U=(0,e.useCallback)(()=>{a||k(!1),R.current?.(!1)},[a]),F=(0,e.useCallback)(()=>{let n=!z.current;n&&i.current.disabled||(a||k(n),R.current?.(n))},[a]);(0,e.useImperativeHandle)(xe,()=>({open:H,close:U,toggle:F,get isDetached(){return z.current},get window(){return u.current}}),[H,U,F]),(0,e.useEffect)(()=>(me(),()=>V()),[me,V]),(0,e.useEffect)(()=>{if(T)return ve.current(),()=>$.current();$.current()},[T]),(0,e.useEffect)(()=>{m!==void 0&&be.current(m)},[m]),(0,e.useEffect)(()=>{let n=u.current,r=E.current;n&&r&&o&&(0,f.setPopupTitle)(n,r,o)},[o]),(0,e.useEffect)(()=>{if(typeof window>"u")return;let n=()=>{i.current.closeOnMainWindowUnload&&u.current&&!u.current.closed&&u.current.close()};return window.addEventListener("beforeunload",n),()=>{window.removeEventListener("beforeunload",n);let r=u.current;C.current?.(),C.current=null,u.current=null,r&&!r.closed&&r.close()}},[]);let _=typeof w=="function"?w({open:H,close:U,toggle:F,detached:T,windowRef:u.current}):w,Re=t==="detach"&&y!==null;return(0,d.jsxs)(d.Fragment,{children:[ue&&m!==void 0&&(0,d.jsx)("input",{type:"hidden",name:ue,value:L.current(m)}),(0,d.jsx)("div",{ref:A.hostRef,className:(0,Ie.cn)(Ve),hidden:Re,children:A.inline(_)}),A.portal((0,d.jsx)(X.LayerDocumentProvider,{document:Re?y.ownerDocument:null,children:_})),t==="clone"&&y&&(0,Se.createPortal)((0,d.jsx)(X.LayerDocumentProvider,{document:y.ownerDocument,children:_}),y)]})}var Me=(0,e.forwardRef)(en);Me.displayName="AdvanceDetachable";0&&(module.exports={AdvanceDetachable});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as P,useRef as r,useEffect as T,useCallback as a,useImperativeHandle as
|
|
1
|
+
"use client";import{useState as P,useRef as r,useEffect as T,useCallback as a,useImperativeHandle as Be,forwardRef as ze}from"react";import{createPortal as We}from"react-dom";import{useMovableContent as $e}from"../detachable/useMovableContent.js";import{mirrorDocument as He,popupDocument as Te,setPopupTitle as Ue,severOpener as Fe}from"../detachable/popup-window.js";import{cn as _e}from"../../lib/cn.js";import{LayerDocumentProvider as Ce}from"../../lib/layer-document.js";import{Fragment as tn,jsx as V,jsxs as rn}from"react/jsx-runtime";var Je="@synertech/ui/AdvanceDetachable",je=300,qe="width=800,height=600,menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes",Ae={clock:0,writer:""};function Xe(t,l){return t.clock>l.clock||t.clock===l.clock&&t.writer>l.writer}var Ee=(t,l)=>t===void 0||l(t),q=t=>typeof t=="string",Ge=t=>typeof t=="number"&&Number.isSafeInteger(t)&&t>=0;function Ke(t,l){if(typeof t!="object"||t===null)return!1;let u=t;return u.channel!==l||!q(u.instanceId)?!1:u.type==="hello"?!0:u.type==="value-sync"&&q(u.payload)&&Ee(u.clock,Ge)&&Ee(u.writer,q)}var Qe=0;function Ye(){return`${Date.now()}-${++Qe}-${Math.random().toString(36).slice(2,8)}`}function Se(t){try{return JSON.stringify(t)}catch{return String(t)}}function Ne(t){try{return JSON.parse(t)}catch{return t}}function Ze(){return typeof BroadcastChannel<"u"}function en({mode:t,id:l,title:u="",children:x,value:X,defaultValue:Ie,onValueChange:G,isDetached:K,defaultDetached:Me=!1,onDetachedChange:Q,onPopupBlocked:Y,features:Z,target:ee,autoFocus:ne=!0,className:Le,detachedBodyClassName:te,disabled:re=!1,readOnly:ce=!1,closeOnMainWindowUnload:oe=!0,name:ue,serialize:le,deserialize:ae},Pe){let s=K!==void 0,[Ve,b]=P(Me),R=s?K:Ve,O=X!==void 0,[xe,Oe]=P(Ie),p=O?X:xe,[m,se]=P(null),c=r(null),C=r(null),h=r(null),A=r(null),B=r(null),E=r(!1),D=r(null),S=r(null),N=r(null),g=r(null),i=r(Ae),ie=r(null),[w]=P(()=>`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`),d=r({title:u,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:l});d.current={title:u,features:Z,target:ee,autoFocus:ne,detachedBodyClassName:te,closeOnMainWindowUnload:oe,disabled:re,readOnly:ce,mode:t,id:l};let I=r(le??Se);I.current=le??Se;let de=r(ae??Ne);de.current=ae??Ne;let fe=r(G);fe.current=G;let y=r(Q);y.current=Q;let pe=r(Y);pe.current=Y;let k=$e(t==="detach"?m:null),z=r(k.bringBack);z.current=k.bringBack;let W=r(R);W.current=R;let ge=r(p);ge.current=p;let f=`${Je}/${l}`,M=a(()=>{D.current?.(),D.current=null,A.current&&(clearInterval(A.current),A.current=null),B.current?.(),B.current=null,se(null)},[]),L=a(()=>{h.current&&(h.current.close(),h.current=null),S.current&&typeof window<"u"&&(window.removeEventListener("message",S.current),S.current=null)},[]),v=a(e=>{let n={channel:f,instanceId:w,messageId:Ye(),origin:"main",timestamp:Date.now(),...e};h.current?h.current.postMessage(n):c.current&&!c.current.closed&&c.current.postMessage(n,"/")},[f,w]),$=a(e=>{if(!Ke(e,f)||e.instanceId===w||d.current.readOnly)return;if(e.type==="hello"){if(i.current.clock===0||g.current===null)return;v({type:"value-sync",payload:g.current,...i.current});return}if(e.payload===void 0)return;let n=typeof e.clock=="number"?{clock:e.clock,writer:typeof e.writer=="string"?e.writer:e.instanceId}:{clock:i.current.clock+1,writer:e.instanceId};if(!Xe(n,i.current)||(i.current=n,e.payload===g.current)||(g.current=e.payload,e.payload===N.current))return;let o=de.current(e.payload);O||Oe(o),fe.current?.(o)},[f,w,O,v]),me=a(()=>{if(L(),!(typeof window>"u")){if(ie.current!==f){ie.current=f,i.current=Ae,g.current=null;let e=ge.current;N.current=e===void 0?null:I.current(e)}if(Ze()){let e=new BroadcastChannel(f),n=o=>$(o.data);e.addEventListener("message",n),h.current=e}else{let e=n=>{let o=c.current;!o||n.source!==o||n.origin===window.location.origin&&$(n.data)};window.addEventListener("message",e),S.current=e}d.current.readOnly||v({type:"hello"})}},[f,L,$,v]),he=a(e=>{let n=I.current(e);n!==N.current&&(N.current=n,!d.current.readOnly&&n!==g.current&&(g.current=n,i.current={clock:i.current.clock+1,writer:w},v({type:"value-sync",payload:n,...i.current})))},[w,v]),we=a(()=>{if(typeof window>"u"||d.current.disabled||E.current||c.current&&!c.current.closed)return;E.current=!0;let e=d.current,n=window.open("",e.target||"",e.features||qe),o=n?Te(n):null;if(!n||!o){E.current=!1,s||b(!1),y.current?.(!1),pe.current?.();return}Fe(n),c.current=n,C.current=o,o.title=e.title||document.title;let De=o.createElement("div");o.body.appendChild(De),se(De),B.current=He(document,o,{bodyClassName:e.detachedBodyClassName});let ke=!1,j=()=>{ke||(ke=!0,z.current(),M(),c.current=null,C.current=null,s||b(!1),y.current?.(!1))};n.addEventListener("pagehide",j),D.current=()=>n.removeEventListener("pagehide",j),A.current=setInterval(()=>{Te(n,o)||j()},je),e.autoFocus&&n.focus(),E.current=!1},[s,M]),ye=a(()=>{z.current();let e=c.current;c.current=null,C.current=null,M(),e&&!e.closed&&e.close()},[M]),ve=r(we);ve.current=we;let H=r(ye);H.current=ye;let be=r(he);be.current=he;let U=a(()=>{d.current.disabled||(s||b(!0),y.current?.(!0))},[s]),F=a(()=>{s||b(!1),y.current?.(!1)},[s]),_=a(()=>{let e=!W.current;e&&d.current.disabled||(s||b(e),y.current?.(e))},[s]);Be(Pe,()=>({open:U,close:F,toggle:_,get isDetached(){return W.current},get window(){return c.current}}),[U,F,_]),T(()=>(me(),()=>L()),[me,L]),T(()=>{if(R)return ve.current(),()=>H.current();H.current()},[R]),T(()=>{p!==void 0&&be.current(p)},[p]),T(()=>{let e=c.current,n=C.current;e&&n&&u&&Ue(e,n,u)},[u]),T(()=>{if(typeof window>"u")return;let e=()=>{d.current.closeOnMainWindowUnload&&c.current&&!c.current.closed&&c.current.close()};return window.addEventListener("beforeunload",e),()=>{window.removeEventListener("beforeunload",e);let n=c.current;D.current?.(),D.current=null,c.current=null,n&&!n.closed&&n.close()}},[]);let J=typeof x=="function"?x({open:U,close:F,toggle:_,detached:R,windowRef:c.current}):x,Re=t==="detach"&&m!==null;return rn(tn,{children:[ue&&p!==void 0&&V("input",{type:"hidden",name:ue,value:I.current(p)}),V("div",{ref:k.hostRef,className:_e(Le),hidden:Re,children:k.inline(J)}),k.portal(V(Ce,{document:Re?m.ownerDocument:null,children:J})),t==="clone"&&m&&We(V(Ce,{document:m.ownerDocument,children:J}),m)]})}var nn=ze(en);nn.displayName="AdvanceDetachable";export{nn as AdvanceDetachable};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Y=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ie=(i,a)=>{for(var f in a)Y(i,f,{get:a[f],enumerable:!0})},De=(i,a,f,v)=>{if(a&&typeof a=="object"||typeof a=="function")for(let y of Se(a))!Ne.call(i,y)&&y!==f&&Y(i,y,{get:()=>a[y],enumerable:!(v=we(a,y))||v.enumerable});return i};var Ce=i=>De(Y({},"__esModule",{value:!0}),i);var ze={};Ie(ze,{DIRECTORY_ENTRY_LIMIT:()=>ae,FileSelector:()=>Ae,readDirectoryEntries:()=>ce});module.exports=Ce(ze);var l=require("react"),u=require("../../lib/cn.cjs"),k=require("../../lib/i18n.cjs"),ne=require("../../lib/accept.cjs"),le=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),Ee={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},se=i=>{if(i===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(i)/Math.log(1024));return`${(i/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},$=i=>i.webkitRelativePath||i.name,Z=i=>`${$(i)}\0${i.size}\0${i.lastModified}`,Le=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Be=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Me=0,ae=1e4;async function ce(i,{keep:a=()=>!0,wanted:f=1/0}={}){let v=[],y=0,m=0,n=()=>y>=f||m>=ae,T=async F=>{if(!n()){if(m++,F.isFile){let r=await new Promise((o,w)=>F.file(o,w));v.push(r),a(r)&&y++}else if(F.isDirectory){let r=F.createReader(),o=()=>new Promise((D,U)=>r.readEntries(D,U)),w=await o();for(;w.length>0&&!n();){for(let D of w)await T(D);n()||(w=await o())}}}};for(let F of i)await T(F);return v}function Ae({value:i,onChange:a,accept:f,multiple:v=!1,maxSize:y=10*1024*1024,maxFiles:m,mode:n="file",variant:T="dropzone",size:F="md",disabled:r=!1,readOnly:o=!1,label:w,helperText:D,error:U,showFileList:q=!0,placeholder:J,browseLabel:P,browseFolderLabel:Q,labels:fe,icon:de,onReject:W,className:ue}){let s=(0,k.useUILabels)(fe),[X,pe]=(0,l.useState)([]),B=(0,l.useRef)(X),[O,j]=(0,l.useState)(!1),S=(0,l.useRef)(null),R=(0,l.useRef)(null),_=(0,l.useId)(),h=(0,le.describeField)(_,{helperText:D,error:U}),x=i!==void 0,C=x?i.map((e,g)=>({file:e,id:`ctrl-${g}`})):X,p=Ee[F],I=(0,l.useCallback)(e=>{B.current=e,pe(e),a?.(e.map(g=>g.file))},[a]),N=v||n!=="file";(0,l.useEffect)(()=>{n==="directory"&&S.current&&S.current.setAttribute("webkitdirectory",""),n==="both"&&R.current&&R.current.setAttribute("webkitdirectory","")},[n]);let V=(0,l.useMemo)(()=>se(y),[y]),G=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[f,s.fileSelectorAllFiles]),ee=n==="directory"?s.fileSelectorDropFolder:n==="both"?s.fileSelectorDropFilesOrFolders:v?s.fileSelectorDropFiles:s.fileSelectorDropFile,ge=n==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,he=s.fileSelectorBrowseFolder,te=(0,k.formatUILabel)(s.fileSelectorTooLarge,{maxSize:V}),re=(0,k.formatUILabel)(s.fileSelectorTypeNotAccepted,{accept:G}),H=(0,l.useCallback)(e=>e.size>y?te:(0,ne.matchesAccept)(e,f)?null:re,[f,y,te,re]),M=(0,l.useCallback)(e=>{if(r||o)return;let g=Array.from(e),b=[],z=new Set(N?(x?i??[]:B.current.map(c=>c.file)).map(Z):[]);for(let c of g){let d=H(c);d?W?.(c,d):z.has(Z(c))?W?.(c,s.fileSelectorAlreadyAdded):(N&&z.add(Z(c)),b.push(c))}if(b.length!==0)if(x)if(N){let d=[...i??[],...b],L=m?d.slice(0,m):d;a?.(L)}else a?.([b[0]]);else{let c=b.map(d=>({file:d,id:`file-${++Me}`}));if(N){let d=[...B.current,...c];I(m?d.slice(0,m):d)}else I([c[0]])}},[r,o,x,N,m,i,a,W,H,I,s.fileSelectorAlreadyAdded]),ye=(0,l.useCallback)(e=>{if(!(r||o)){if(x){let g=(i??[]).filter((b,z)=>z!==e);a?.(g)}else I(B.current.filter((g,b)=>b!==e));S.current&&(S.current.value="")}},[r,o,x,i,a,I]),me=(0,l.useCallback)(()=>{r||o||(x?a?.([]):I([]),S.current&&(S.current.value=""))},[r,o,x,a,I]),oe=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&M(e.target.files)},[M]),be=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&j(!0)},[r,o]),xe=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),ve=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),j(!1),r||o)return;let g=e.dataTransfer.items;if(g&&g.length>0&&(n==="directory"||n==="both")){let b=[];for(let c=0;c<g.length;c++){let d=g[c].webkitGetAsEntry?.();d&&b.push(d)}if(b.some(c=>c.isDirectory)){let c=x?(i??[]).length:B.current.length,d=m?Math.max(0,m-c):1/0;if(d===0)return;ce(b,{keep:L=>H(L)===null,wanted:d}).then(L=>{L.length>0&&M(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&M(e.dataTransfer.files)},[r,o,n,M,x,i,m,H]),A=(0,l.useCallback)(()=>{!r&&!o&&S.current?.click()},[r,o]),ie=(0,l.useCallback)(()=>{!r&&!o&&R.current?.click()},[r,o]),E=C.length>0,ke=de||(n==="directory"?Be:Le),Fe=q&&E&&(0,t.jsxs)("div",{className:(0,u.cn)("flex flex-col",p.gap),children:[C.map((e,g)=>(0,t.jsxs)("div",{className:(0,u.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",p.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:$(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",se(e.file.size),")"]})]}),!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:()=>ye(g),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,k.formatUILabel)(s.fileSelectorRemove,{name:$(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),N&&C.length>1&&!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:me,className:(0,u.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",p.subtext),children:s.fileSelectorRemoveAll})]}),K=(0,u.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",p.button,h.invalid&&"border-red-500 dark:border-red-500");return(0,t.jsxs)("div",{className:(0,u.cn)("flex flex-col",p.gap,ue),children:[w&&(0,t.jsx)("label",{htmlFor:_,className:(0,u.cn)("block font-medium text-gray-700 dark:text-gray-300",p.text),children:w}),(0,t.jsx)("input",{ref:S,id:_,type:"file",accept:n!=="directory"?f:void 0,multiple:N,onChange:oe,className:"sr-only",tabIndex:-1,disabled:r||o,"aria-describedby":h.describedBy,"aria-invalid":h.invalid||void 0}),n==="both"&&(0,t.jsx)("input",{ref:R,type:"file",onChange:oe,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),T==="dropzone"?(0,t.jsxs)("div",{role:n==="both"?"group":"button",tabIndex:n==="both"?void 0:r||o?-1:0,onClick:n==="both"?void 0:A,onKeyDown:n==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),A())},onDragOver:be,onDragLeave:xe,onDrop:ve,className:(0,u.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",p.dropzone,O&&!r&&!o?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!r&&!o&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",n!=="both"&&!r&&!o&&"cursor-pointer",r&&"opacity-50 cursor-not-allowed",o&&"cursor-default",h.invalid&&"border-red-500 dark:border-red-500"),"aria-label":n==="both"?s.fileSelectorDropZone:J||ee,"aria-describedby":h.describedBy,children:[(0,t.jsx)("div",{className:(0,u.cn)("text-gray-500 dark:text-gray-400 mb-2",p.icon,O&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ke}),(0,t.jsxs)("p",{className:(0,u.cn)("text-gray-600 dark:text-gray-400",p.text),children:[J||ee," ",!r&&!o&&n!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:P||ge})]}),n==="both"&&!r&&!o&&(0,t.jsxs)("div",{className:(0,u.cn)("flex items-center gap-3 mt-1",p.text),children:[(0,t.jsx)("button",{type:"button",onClick:A,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:P||s.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:ie,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:Q||he})]}),(0,t.jsx)("p",{className:(0,u.cn)("text-gray-500 dark:text-gray-400 mt-1",p.subtext),children:N&&m?(0,k.formatUILabel)(s.fileSelectorConstraintsMaxFiles,{accept:G,maxSize:V,maxFiles:m}):(0,k.formatUILabel)(s.fileSelectorConstraints,{accept:G,maxSize:V})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(E?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:ie,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:Q||s.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(n==="directory"?E?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:E?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!E&&(0,t.jsx)("span",{className:(0,u.cn)("text-gray-500 dark:text-gray-400",p.text),children:n==="directory"?s.fileSelectorNoFolder:n==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),E&&!q&&(0,t.jsx)("span",{className:(0,u.cn)("text-gray-600 dark:text-gray-400 truncate",p.text),children:C.length===1?$(C[0].file):(0,k.formatUILabel)(s.fileSelectorFilesSelected,{count:C.length})})]}),Fe,h.message!==void 0&&(0,t.jsx)("p",{id:h.ids.error,className:(0,u.cn)("text-red-600 dark:text-red-400",p.subtext),children:h.message}),h.showHelper&&(0,t.jsx)("p",{id:h.ids.helper,className:(0,u.cn)(h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",p.subtext),children:D})]})}0&&(module.exports={DIRECTORY_ENTRY_LIMIT,FileSelector,readDirectoryEntries});
|
|
1
|
+
"use strict";"use client";var Y=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var Ie=(i,a)=>{for(var f in a)Y(i,f,{get:a[f],enumerable:!0})},De=(i,a,f,v)=>{if(a&&typeof a=="object"||typeof a=="function")for(let y of Se(a))!Ne.call(i,y)&&y!==f&&Y(i,y,{get:()=>a[y],enumerable:!(v=we(a,y))||v.enumerable});return i};var Ce=i=>De(Y({},"__esModule",{value:!0}),i);var ze={};Ie(ze,{DIRECTORY_ENTRY_LIMIT:()=>ae,FileSelector:()=>Ae,readDirectoryEntries:()=>ce});module.exports=Ce(ze);var l=require("react"),d=require("../../lib/cn.cjs"),k=require("../../lib/i18n.cjs"),ne=require("../../lib/accept.cjs"),le=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),Ee={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},se=i=>{if(i===0)return"0 B";let a=["B","KB","MB","GB"],f=Math.floor(Math.log(i)/Math.log(1024));return`${(i/Math.pow(1024,f)).toFixed(f===0?0:1)} ${a[f]}`},$=i=>i.webkitRelativePath||i.name,Z=i=>`${$(i)}\0${i.size}\0${i.lastModified}`,Le=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Be=(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Me=0,ae=1e4;async function ce(i,{keep:a=()=>!0,wanted:f=1/0}={}){let v=[],y=0,m=0,n=()=>y>=f||m>=ae,T=async F=>{if(!n()){if(m++,F.isFile){let r=await new Promise((o,w)=>F.file(o,w));v.push(r),a(r)&&y++}else if(F.isDirectory){let r=F.createReader(),o=()=>new Promise((D,U)=>r.readEntries(D,U)),w=await o();for(;w.length>0&&!n();){for(let D of w)await T(D);n()||(w=await o())}}}};for(let F of i)await T(F);return v}function Ae({value:i,onChange:a,accept:f,multiple:v=!1,maxSize:y=10*1024*1024,maxFiles:m,mode:n="file",variant:T="dropzone",size:F="md",disabled:r=!1,readOnly:o=!1,label:w,helperText:D,error:U,showFileList:q=!0,placeholder:J,browseLabel:P,browseFolderLabel:Q,labels:fe,icon:de,onReject:W,className:ue}){let s=(0,k.useUILabels)(fe),[X,pe]=(0,l.useState)([]),B=(0,l.useRef)(X),[O,j]=(0,l.useState)(!1),S=(0,l.useRef)(null),R=(0,l.useRef)(null),_=(0,l.useId)(),h=(0,le.describeField)(_,{helperText:D,error:U}),x=i!==void 0,C=x?i.map((e,g)=>({file:e,id:`ctrl-${g}`})):X,p=Ee[F],I=(0,l.useCallback)(e=>{B.current=e,pe(e),a?.(e.map(g=>g.file))},[a]),N=v||n!=="file";(0,l.useEffect)(()=>{n==="directory"&&S.current&&S.current.setAttribute("webkitdirectory",""),n==="both"&&R.current&&R.current.setAttribute("webkitdirectory","")},[n]);let V=(0,l.useMemo)(()=>se(y),[y]),G=(0,l.useMemo)(()=>f?f.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):s.fileSelectorAllFiles,[f,s.fileSelectorAllFiles]),ee=n==="directory"?s.fileSelectorDropFolder:n==="both"?s.fileSelectorDropFilesOrFolders:v?s.fileSelectorDropFiles:s.fileSelectorDropFile,ge=n==="directory"?s.fileSelectorBrowseFolder:s.fileSelectorBrowse,he=s.fileSelectorBrowseFolder,te=(0,k.formatUILabel)(s.fileSelectorTooLarge,{maxSize:V}),re=(0,k.formatUILabel)(s.fileSelectorTypeNotAccepted,{accept:G}),H=(0,l.useCallback)(e=>e.size>y?te:(0,ne.matchesAccept)(e,f)?null:re,[f,y,te,re]),M=(0,l.useCallback)(e=>{if(r||o)return;let g=Array.from(e),b=[],z=new Set(N?(x?i??[]:B.current.map(c=>c.file)).map(Z):[]);for(let c of g){let u=H(c);u?W?.(c,u):z.has(Z(c))?W?.(c,s.fileSelectorAlreadyAdded):(N&&z.add(Z(c)),b.push(c))}if(b.length!==0)if(x)if(N){let u=[...i??[],...b],L=m?u.slice(0,m):u;a?.(L)}else a?.([b[0]]);else{let c=b.map(u=>({file:u,id:`file-${++Me}`}));if(N){let u=[...B.current,...c];I(m?u.slice(0,m):u)}else I([c[0]])}},[r,o,x,N,m,i,a,W,H,I,s.fileSelectorAlreadyAdded]),ye=(0,l.useCallback)(e=>{if(!(r||o)){if(x){let g=(i??[]).filter((b,z)=>z!==e);a?.(g)}else I(B.current.filter((g,b)=>b!==e));S.current&&(S.current.value="")}},[r,o,x,i,a,I]),me=(0,l.useCallback)(()=>{r||o||(x?a?.([]):I([]),S.current&&(S.current.value=""))},[r,o,x,a,I]),oe=(0,l.useCallback)(e=>{e.target.files&&e.target.files.length>0&&M(e.target.files)},[M]),be=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),!r&&!o&&j(!0)},[r,o]),xe=(0,l.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j(!1)},[]),ve=(0,l.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),j(!1),r||o)return;let g=e.dataTransfer.items;if(g&&g.length>0&&(n==="directory"||n==="both")){let b=[];for(let c=0;c<g.length;c++){let u=g[c].webkitGetAsEntry?.();u&&b.push(u)}if(b.some(c=>c.isDirectory)){let c=x?(i??[]).length:B.current.length,u=m?Math.max(0,m-c):1/0;if(u===0)return;ce(b,{keep:L=>H(L)===null,wanted:u}).then(L=>{L.length>0&&M(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&M(e.dataTransfer.files)},[r,o,n,M,x,i,m,H]),A=(0,l.useCallback)(()=>{!r&&!o&&S.current?.click()},[r,o]),ie=(0,l.useCallback)(()=>{!r&&!o&&R.current?.click()},[r,o]),E=C.length>0,ke=de||(n==="directory"?Be:Le),Fe=q&&E&&(0,t.jsxs)("div",{className:(0,d.cn)("flex flex-col",p.gap),children:[C.map((e,g)=>(0,t.jsxs)("div",{className:(0,d.cn)("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",p.fileItem),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),(0,t.jsx)("span",{className:"truncate text-gray-700 dark:text-gray-300",children:$(e.file)}),(0,t.jsxs)("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",se(e.file.size),")"]})]}),!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:()=>ye(g),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":(0,k.formatUILabel)(s.fileSelectorRemove,{name:$(e.file)}),children:(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),N&&C.length>1&&!r&&!o&&(0,t.jsx)("button",{type:"button",onClick:me,className:(0,d.cn)("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",p.subtext),children:s.fileSelectorRemoveAll})]}),K=(0,d.cn)("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",p.button,h.invalid&&"border-red-500 dark:border-red-500");return(0,t.jsxs)("div",{className:(0,d.cn)("flex flex-col",p.gap,ue),children:[w&&(0,t.jsx)("label",{htmlFor:_,className:(0,d.cn)("block font-medium text-gray-700 dark:text-gray-300",p.text),children:w}),(0,t.jsx)("input",{ref:S,id:_,type:"file",accept:n!=="directory"?f:void 0,multiple:N,onChange:oe,className:"sr-only",tabIndex:-1,disabled:r||o,"aria-describedby":h.describedBy,"aria-invalid":h.invalid||void 0}),n==="both"&&(0,t.jsx)("input",{ref:R,type:"file",onChange:oe,className:"sr-only",disabled:r||o,tabIndex:-1,"aria-hidden":"true"}),T==="dropzone"?(0,t.jsxs)("div",{role:n==="both"?"group":"button",tabIndex:n==="both"?void 0:r||o?-1:0,onClick:n==="both"?void 0:A,onKeyDown:n==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),A())},onDragOver:be,onDragLeave:xe,onDrop:ve,className:(0,d.cn)("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",p.dropzone,O&&!r&&!o?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":(0,d.cn)(h.invalid?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800"),!r&&!o&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",n!=="both"&&!r&&!o&&"cursor-pointer",o&&"cursor-default",r&&"opacity-50 cursor-not-allowed"),"aria-label":n==="both"?s.fileSelectorDropZone:J||ee,"aria-describedby":h.describedBy,children:[(0,t.jsx)("div",{className:(0,d.cn)("text-gray-500 dark:text-gray-400 mb-2",p.icon,O&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ke}),(0,t.jsxs)("p",{className:(0,d.cn)("text-gray-600 dark:text-gray-400",p.text),children:[J||ee," ",!r&&!o&&n!=="both"&&(0,t.jsx)("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:P||ge})]}),n==="both"&&!r&&!o&&(0,t.jsxs)("div",{className:(0,d.cn)("flex items-center gap-3 mt-1",p.text),children:[(0,t.jsx)("button",{type:"button",onClick:A,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:P||s.fileSelectorBrowseFiles}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),(0,t.jsx)("button",{type:"button",onClick:ie,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:Q||he})]}),(0,t.jsx)("p",{className:(0,d.cn)("text-gray-500 dark:text-gray-400 mt-1",p.subtext),children:N&&m?(0,k.formatUILabel)(s.fileSelectorConstraintsMaxFiles,{accept:G,maxSize:V,maxFiles:m}):(0,k.formatUILabel)(s.fileSelectorConstraints,{accept:G,maxSize:V})})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n==="both"?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(E?s.fileSelectorChangeFiles:s.fileSelectorChooseFiles)}),(0,t.jsx)("button",{type:"button",onClick:ie,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:Q||s.fileSelectorChooseFolder})]}):(0,t.jsx)("button",{type:"button",onClick:A,disabled:r||o,className:K,"aria-describedby":h.describedBy,children:P||(n==="directory"?E?s.fileSelectorChangeFolder:s.fileSelectorChooseFolder:E?s.fileSelectorChangeFile:s.fileSelectorChooseFile)}),!E&&(0,t.jsx)("span",{className:(0,d.cn)("text-gray-500 dark:text-gray-400",p.text),children:n==="directory"?s.fileSelectorNoFolder:n==="both"?s.fileSelectorNoFileOrFolder:s.fileSelectorNoFile}),E&&!q&&(0,t.jsx)("span",{className:(0,d.cn)("text-gray-600 dark:text-gray-400 truncate",p.text),children:C.length===1?$(C[0].file):(0,k.formatUILabel)(s.fileSelectorFilesSelected,{count:C.length})})]}),Fe,h.message!==void 0&&(0,t.jsx)("p",{id:h.ids.error,className:(0,d.cn)("text-red-600 dark:text-red-400",p.subtext),children:h.message}),h.showHelper&&(0,t.jsx)("p",{id:h.ids.helper,className:(0,d.cn)(h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",p.subtext),children:D})]})}0&&(module.exports={DIRECTORY_ENTRY_LIMIT,FileSelector,readDirectoryEntries});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as ne,useRef as Z,useCallback as m,useEffect as Fe,useMemo as le,useId as we}from"react";import{cn as d}from"../../lib/cn.js";import{formatUILabel as B,useUILabels as Se}from"../../lib/i18n.js";import{matchesAccept as Ne}from"../../lib/accept.js";import{describeField as Ie}from"../form/shared/field-error.js";import{Fragment as Ae,jsx as s,jsxs as x}from"react/jsx-runtime";var De={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},ae=n=>{if(n===0)return"0 B";let p=["B","KB","MB","GB"],h=Math.floor(Math.log(n)/Math.log(1024));return`${(n/Math.pow(1024,h)).toFixed(h===0?0:1)} ${p[h]}`},U=n=>n.webkitRelativePath||n.name,q=n=>`${U(n)}\0${n.size}\0${n.lastModified}`,Ce=s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ee=s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Le=0,Be=1e4;async function Me(n,{keep:p=()=>!0,wanted:h=1/0}={}){let I=[],S=0,g=0,i=()=>S>=h||g>=Be,P=async v=>{if(!i()){if(g++,v.isFile){let t=await new Promise((r,k)=>v.file(r,k));I.push(t),p(t)&&S++}else if(v.isDirectory){let t=v.createReader(),r=()=>new Promise((D,W)=>t.readEntries(D,W)),k=await r();for(;k.length>0&&!i();){for(let D of k)await P(D);i()||(k=await r())}}}};for(let v of n)await P(v);return I}function $e({value:n,onChange:p,accept:h,multiple:I=!1,maxSize:S=10*1024*1024,maxFiles:g,mode:i="file",variant:P="dropzone",size:v="md",disabled:t=!1,readOnly:r=!1,label:k,helperText:D,error:W,showFileList:J=!0,placeholder:Q,browseLabel:R,browseFolderLabel:X,labels:ce,icon:fe,onReject:j,className:de}){let o=Se(ce),[O,ue]=ne([]),M=Z(O),[ee,_]=ne(!1),F=Z(null),H=Z(null),V=we(),u=Ie(V,{helperText:D,error:W}),b=n!==void 0,C=b?n.map((e,f)=>({file:e,id:`ctrl-${f}`})):O,c=De[v],N=m(e=>{M.current=e,ue(e),p?.(e.map(f=>f.file))},[p]),w=I||i!=="file";Fe(()=>{i==="directory"&&F.current&&F.current.setAttribute("webkitdirectory",""),i==="both"&&H.current&&H.current.setAttribute("webkitdirectory","")},[i]);let G=le(()=>ae(S),[S]),K=le(()=>h?h.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):o.fileSelectorAllFiles,[h,o.fileSelectorAllFiles]),te=i==="directory"?o.fileSelectorDropFolder:i==="both"?o.fileSelectorDropFilesOrFolders:I?o.fileSelectorDropFiles:o.fileSelectorDropFile,pe=i==="directory"?o.fileSelectorBrowseFolder:o.fileSelectorBrowse,ge=o.fileSelectorBrowseFolder,re=B(o.fileSelectorTooLarge,{maxSize:G}),oe=B(o.fileSelectorTypeNotAccepted,{accept:K}),$=m(e=>e.size>S?re:Ne(e,h)?null:oe,[h,S,re,oe]),A=m(e=>{if(t||r)return;let f=Array.from(e),y=[],T=new Set(w?(b?n??[]:M.current.map(l=>l.file)).map(q):[]);for(let l of f){let a=$(l);a?j?.(l,a):T.has(q(l))?j?.(l,o.fileSelectorAlreadyAdded):(w&&T.add(q(l)),y.push(l))}if(y.length!==0)if(b)if(w){let a=[...n??[],...y],L=g?a.slice(0,g):a;p?.(L)}else p?.([y[0]]);else{let l=y.map(a=>({file:a,id:`file-${++Le}`}));if(w){let a=[...M.current,...l];N(g?a.slice(0,g):a)}else N([l[0]])}},[t,r,b,w,g,n,p,j,$,N,o.fileSelectorAlreadyAdded]),he=m(e=>{if(!(t||r)){if(b){let f=(n??[]).filter((y,T)=>T!==e);p?.(f)}else N(M.current.filter((f,y)=>y!==e));F.current&&(F.current.value="")}},[t,r,b,n,p,N]),ye=m(()=>{t||r||(b?p?.([]):N([]),F.current&&(F.current.value=""))},[t,r,b,p,N]),ie=m(e=>{e.target.files&&e.target.files.length>0&&A(e.target.files)},[A]),me=m(e=>{e.preventDefault(),e.stopPropagation(),!t&&!r&&_(!0)},[t,r]),be=m(e=>{e.preventDefault(),e.stopPropagation(),_(!1)},[]),xe=m(e=>{if(e.preventDefault(),e.stopPropagation(),_(!1),t||r)return;let f=e.dataTransfer.items;if(f&&f.length>0&&(i==="directory"||i==="both")){let y=[];for(let l=0;l<f.length;l++){let a=f[l].webkitGetAsEntry?.();a&&y.push(a)}if(y.some(l=>l.isDirectory)){let l=b?(n??[]).length:M.current.length,a=g?Math.max(0,g-l):1/0;if(a===0)return;Me(y,{keep:L=>$(L)===null,wanted:a}).then(L=>{L.length>0&&A(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&A(e.dataTransfer.files)},[t,r,i,A,b,n,g,$]),z=m(()=>{!t&&!r&&F.current?.click()},[t,r]),se=m(()=>{!t&&!r&&H.current?.click()},[t,r]),E=C.length>0,ve=fe||(i==="directory"?Ee:Ce),ke=J&&E&&x("div",{className:d("flex flex-col",c.gap),children:[C.map((e,f)=>x("div",{className:d("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",c.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),s("span",{className:"truncate text-gray-700 dark:text-gray-300",children:U(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",ae(e.file.size),")"]})]}),!t&&!r&&s("button",{type:"button",onClick:()=>he(f),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":B(o.fileSelectorRemove,{name:U(e.file)}),children:s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),w&&C.length>1&&!t&&!r&&s("button",{type:"button",onClick:ye,className:d("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",c.subtext),children:o.fileSelectorRemoveAll})]}),Y=d("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",c.button,u.invalid&&"border-red-500 dark:border-red-500");return x("div",{className:d("flex flex-col",c.gap,de),children:[k&&s("label",{htmlFor:V,className:d("block font-medium text-gray-700 dark:text-gray-300",c.text),children:k}),s("input",{ref:F,id:V,type:"file",accept:i!=="directory"?h:void 0,multiple:w,onChange:ie,className:"sr-only",tabIndex:-1,disabled:t||r,"aria-describedby":u.describedBy,"aria-invalid":u.invalid||void 0}),i==="both"&&s("input",{ref:H,type:"file",onChange:ie,className:"sr-only",disabled:t||r,tabIndex:-1,"aria-hidden":"true"}),P==="dropzone"?x("div",{role:i==="both"?"group":"button",tabIndex:i==="both"?void 0:t||r?-1:0,onClick:i==="both"?void 0:z,onKeyDown:i==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),z())},onDragOver:me,onDragLeave:be,onDrop:xe,className:d("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c.dropzone,ee&&!t&&!r?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",!t&&!r&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",i!=="both"&&!t&&!r&&"cursor-pointer",t&&"opacity-50 cursor-not-allowed",r&&"cursor-default",u.invalid&&"border-red-500 dark:border-red-500"),"aria-label":i==="both"?o.fileSelectorDropZone:Q||te,"aria-describedby":u.describedBy,children:[s("div",{className:d("text-gray-500 dark:text-gray-400 mb-2",c.icon,ee&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ve}),x("p",{className:d("text-gray-600 dark:text-gray-400",c.text),children:[Q||te," ",!t&&!r&&i!=="both"&&s("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:R||pe})]}),i==="both"&&!t&&!r&&x("div",{className:d("flex items-center gap-3 mt-1",c.text),children:[s("button",{type:"button",onClick:z,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:R||o.fileSelectorBrowseFiles}),s("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),s("button",{type:"button",onClick:se,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:X||ge})]}),s("p",{className:d("text-gray-500 dark:text-gray-400 mt-1",c.subtext),children:w&&g?B(o.fileSelectorConstraintsMaxFiles,{accept:K,maxSize:G,maxFiles:g}):B(o.fileSelectorConstraints,{accept:K,maxSize:G})})]}):x("div",{className:"flex items-center gap-2",children:[i==="both"?x(Ae,{children:[s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(E?o.fileSelectorChangeFiles:o.fileSelectorChooseFiles)}),s("button",{type:"button",onClick:se,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:X||o.fileSelectorChooseFolder})]}):s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(i==="directory"?E?o.fileSelectorChangeFolder:o.fileSelectorChooseFolder:E?o.fileSelectorChangeFile:o.fileSelectorChooseFile)}),!E&&s("span",{className:d("text-gray-500 dark:text-gray-400",c.text),children:i==="directory"?o.fileSelectorNoFolder:i==="both"?o.fileSelectorNoFileOrFolder:o.fileSelectorNoFile}),E&&!J&&s("span",{className:d("text-gray-600 dark:text-gray-400 truncate",c.text),children:C.length===1?U(C[0].file):B(o.fileSelectorFilesSelected,{count:C.length})})]}),ke,u.message!==void 0&&s("p",{id:u.ids.error,className:d("text-red-600 dark:text-red-400",c.subtext),children:u.message}),u.showHelper&&s("p",{id:u.ids.helper,className:d(u.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",c.subtext),children:D})]})}export{Be as DIRECTORY_ENTRY_LIMIT,$e as FileSelector,Me as readDirectoryEntries};
|
|
1
|
+
"use client";import{useState as ne,useRef as Z,useCallback as m,useEffect as Fe,useMemo as le,useId as we}from"react";import{cn as c}from"../../lib/cn.js";import{formatUILabel as B,useUILabels as Se}from"../../lib/i18n.js";import{matchesAccept as Ne}from"../../lib/accept.js";import{describeField as Ie}from"../form/shared/field-error.js";import{Fragment as Ae,jsx as s,jsxs as x}from"react/jsx-runtime";var De={sm:{dropzone:"py-4 px-3",text:"text-xs",subtext:"text-[10px]",icon:"w-6 h-6",button:"px-2.5 py-1.5 text-xs",fileItem:"py-1 px-2 text-xs",gap:"gap-1"},md:{dropzone:"py-6 px-4",text:"text-sm",subtext:"text-xs",icon:"w-8 h-8",button:"px-3 py-2 text-sm",fileItem:"py-1.5 px-3 text-sm",gap:"gap-1.5"},lg:{dropzone:"py-8 px-6",text:"text-base",subtext:"text-sm",icon:"w-10 h-10",button:"px-4 py-2.5 text-base",fileItem:"py-2 px-4 text-base",gap:"gap-2"}},ae=n=>{if(n===0)return"0 B";let p=["B","KB","MB","GB"],h=Math.floor(Math.log(n)/Math.log(1024));return`${(n/Math.pow(1024,h)).toFixed(h===0?0:1)} ${p[h]}`},U=n=>n.webkitRelativePath||n.name,q=n=>`${U(n)}\0${n.size}\0${n.lastModified}`,Ce=s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})}),Ee=s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-full h-full",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776"})}),Le=0,Be=1e4;async function Me(n,{keep:p=()=>!0,wanted:h=1/0}={}){let I=[],S=0,g=0,i=()=>S>=h||g>=Be,P=async v=>{if(!i()){if(g++,v.isFile){let t=await new Promise((r,k)=>v.file(r,k));I.push(t),p(t)&&S++}else if(v.isDirectory){let t=v.createReader(),r=()=>new Promise((D,W)=>t.readEntries(D,W)),k=await r();for(;k.length>0&&!i();){for(let D of k)await P(D);i()||(k=await r())}}}};for(let v of n)await P(v);return I}function $e({value:n,onChange:p,accept:h,multiple:I=!1,maxSize:S=10*1024*1024,maxFiles:g,mode:i="file",variant:P="dropzone",size:v="md",disabled:t=!1,readOnly:r=!1,label:k,helperText:D,error:W,showFileList:J=!0,placeholder:Q,browseLabel:R,browseFolderLabel:X,labels:ce,icon:fe,onReject:j,className:de}){let o=Se(ce),[O,ue]=ne([]),M=Z(O),[ee,_]=ne(!1),F=Z(null),H=Z(null),V=we(),u=Ie(V,{helperText:D,error:W}),b=n!==void 0,C=b?n.map((e,d)=>({file:e,id:`ctrl-${d}`})):O,f=De[v],N=m(e=>{M.current=e,ue(e),p?.(e.map(d=>d.file))},[p]),w=I||i!=="file";Fe(()=>{i==="directory"&&F.current&&F.current.setAttribute("webkitdirectory",""),i==="both"&&H.current&&H.current.setAttribute("webkitdirectory","")},[i]);let G=le(()=>ae(S),[S]),K=le(()=>h?h.split(",").map(e=>e.trim()).map(e=>e.startsWith(".")?e.toUpperCase():e.endsWith("/*")?e.replace("/*","").toUpperCase():e).join(", "):o.fileSelectorAllFiles,[h,o.fileSelectorAllFiles]),te=i==="directory"?o.fileSelectorDropFolder:i==="both"?o.fileSelectorDropFilesOrFolders:I?o.fileSelectorDropFiles:o.fileSelectorDropFile,pe=i==="directory"?o.fileSelectorBrowseFolder:o.fileSelectorBrowse,ge=o.fileSelectorBrowseFolder,re=B(o.fileSelectorTooLarge,{maxSize:G}),oe=B(o.fileSelectorTypeNotAccepted,{accept:K}),$=m(e=>e.size>S?re:Ne(e,h)?null:oe,[h,S,re,oe]),A=m(e=>{if(t||r)return;let d=Array.from(e),y=[],T=new Set(w?(b?n??[]:M.current.map(l=>l.file)).map(q):[]);for(let l of d){let a=$(l);a?j?.(l,a):T.has(q(l))?j?.(l,o.fileSelectorAlreadyAdded):(w&&T.add(q(l)),y.push(l))}if(y.length!==0)if(b)if(w){let a=[...n??[],...y],L=g?a.slice(0,g):a;p?.(L)}else p?.([y[0]]);else{let l=y.map(a=>({file:a,id:`file-${++Le}`}));if(w){let a=[...M.current,...l];N(g?a.slice(0,g):a)}else N([l[0]])}},[t,r,b,w,g,n,p,j,$,N,o.fileSelectorAlreadyAdded]),he=m(e=>{if(!(t||r)){if(b){let d=(n??[]).filter((y,T)=>T!==e);p?.(d)}else N(M.current.filter((d,y)=>y!==e));F.current&&(F.current.value="")}},[t,r,b,n,p,N]),ye=m(()=>{t||r||(b?p?.([]):N([]),F.current&&(F.current.value=""))},[t,r,b,p,N]),ie=m(e=>{e.target.files&&e.target.files.length>0&&A(e.target.files)},[A]),me=m(e=>{e.preventDefault(),e.stopPropagation(),!t&&!r&&_(!0)},[t,r]),be=m(e=>{e.preventDefault(),e.stopPropagation(),_(!1)},[]),xe=m(e=>{if(e.preventDefault(),e.stopPropagation(),_(!1),t||r)return;let d=e.dataTransfer.items;if(d&&d.length>0&&(i==="directory"||i==="both")){let y=[];for(let l=0;l<d.length;l++){let a=d[l].webkitGetAsEntry?.();a&&y.push(a)}if(y.some(l=>l.isDirectory)){let l=b?(n??[]).length:M.current.length,a=g?Math.max(0,g-l):1/0;if(a===0)return;Me(y,{keep:L=>$(L)===null,wanted:a}).then(L=>{L.length>0&&A(L)});return}}e.dataTransfer.files&&e.dataTransfer.files.length>0&&A(e.dataTransfer.files)},[t,r,i,A,b,n,g,$]),z=m(()=>{!t&&!r&&F.current?.click()},[t,r]),se=m(()=>{!t&&!r&&H.current?.click()},[t,r]),E=C.length>0,ve=fe||(i==="directory"?Ee:Ce),ke=J&&E&&x("div",{className:c("flex flex-col",f.gap),children:[C.map((e,d)=>x("div",{className:c("flex items-center justify-between rounded-md border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",f.fileItem),children:[x("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4 shrink-0 text-gray-500 dark:text-gray-400",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),s("span",{className:"truncate text-gray-700 dark:text-gray-300",children:U(e.file)}),x("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:["(",ae(e.file.size),")"]})]}),!t&&!r&&s("button",{type:"button",onClick:()=>he(d),className:"shrink-0 ml-2 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer","aria-label":B(o.fileSelectorRemove,{name:U(e.file)}),children:s("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-4 h-4",children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e.id)),w&&C.length>1&&!t&&!r&&s("button",{type:"button",onClick:ye,className:c("self-start text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 transition-colors cursor-pointer",f.subtext),children:o.fileSelectorRemoveAll})]}),Y=c("rounded-md border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-700 dark:text-gray-200 font-medium transition-colors","hover:bg-gray-50 dark:hover:bg-gray-700","disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer","focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1",f.button,u.invalid&&"border-red-500 dark:border-red-500");return x("div",{className:c("flex flex-col",f.gap,de),children:[k&&s("label",{htmlFor:V,className:c("block font-medium text-gray-700 dark:text-gray-300",f.text),children:k}),s("input",{ref:F,id:V,type:"file",accept:i!=="directory"?h:void 0,multiple:w,onChange:ie,className:"sr-only",tabIndex:-1,disabled:t||r,"aria-describedby":u.describedBy,"aria-invalid":u.invalid||void 0}),i==="both"&&s("input",{ref:H,type:"file",onChange:ie,className:"sr-only",disabled:t||r,tabIndex:-1,"aria-hidden":"true"}),P==="dropzone"?x("div",{role:i==="both"?"group":"button",tabIndex:i==="both"?void 0:t||r?-1:0,onClick:i==="both"?void 0:z,onKeyDown:i==="both"?void 0:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),z())},onDragOver:me,onDragLeave:be,onDrop:xe,className:c("flex flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",f.dropzone,ee&&!t&&!r?"border-synertech-primary-500 bg-synertech-primary-50 dark:bg-synertech-primary-900/20":c(u.invalid?"border-red-500 dark:border-red-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800"),!t&&!r&&"hover:border-synertech-primary-400 dark:hover:border-synertech-primary-500 hover:bg-gray-50 dark:hover:bg-gray-800/70",i!=="both"&&!t&&!r&&"cursor-pointer",r&&"cursor-default",t&&"opacity-50 cursor-not-allowed"),"aria-label":i==="both"?o.fileSelectorDropZone:Q||te,"aria-describedby":u.describedBy,children:[s("div",{className:c("text-gray-500 dark:text-gray-400 mb-2",f.icon,ee&&"text-synertech-primary-600 dark:text-synertech-primary-400"),children:ve}),x("p",{className:c("text-gray-600 dark:text-gray-400",f.text),children:[Q||te," ",!t&&!r&&i!=="both"&&s("span",{className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium",children:R||pe})]}),i==="both"&&!t&&!r&&x("div",{className:c("flex items-center gap-3 mt-1",f.text),children:[s("button",{type:"button",onClick:z,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:R||o.fileSelectorBrowseFiles}),s("span",{className:"text-gray-500 dark:text-gray-400",children:"\xB7"}),s("button",{type:"button",onClick:se,className:"text-synertech-primary-600 dark:text-synertech-primary-400 font-medium hover:underline cursor-pointer focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 focus:ring-offset-1 rounded",children:X||ge})]}),s("p",{className:c("text-gray-500 dark:text-gray-400 mt-1",f.subtext),children:w&&g?B(o.fileSelectorConstraintsMaxFiles,{accept:K,maxSize:G,maxFiles:g}):B(o.fileSelectorConstraints,{accept:K,maxSize:G})})]}):x("div",{className:"flex items-center gap-2",children:[i==="both"?x(Ae,{children:[s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(E?o.fileSelectorChangeFiles:o.fileSelectorChooseFiles)}),s("button",{type:"button",onClick:se,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:X||o.fileSelectorChooseFolder})]}):s("button",{type:"button",onClick:z,disabled:t||r,className:Y,"aria-describedby":u.describedBy,children:R||(i==="directory"?E?o.fileSelectorChangeFolder:o.fileSelectorChooseFolder:E?o.fileSelectorChangeFile:o.fileSelectorChooseFile)}),!E&&s("span",{className:c("text-gray-500 dark:text-gray-400",f.text),children:i==="directory"?o.fileSelectorNoFolder:i==="both"?o.fileSelectorNoFileOrFolder:o.fileSelectorNoFile}),E&&!J&&s("span",{className:c("text-gray-600 dark:text-gray-400 truncate",f.text),children:C.length===1?U(C[0].file):B(o.fileSelectorFilesSelected,{count:C.length})})]}),ke,u.message!==void 0&&s("p",{id:u.ids.error,className:c("text-red-600 dark:text-red-400",f.subtext),children:u.message}),u.showHelper&&s("p",{id:u.ids.helper,className:c(u.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400",f.subtext),children:D})]})}export{Be as DIRECTORY_ENTRY_LIMIT,$e as FileSelector,Me as readDirectoryEntries};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},p=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of g(r))!i.call(e,t)&&t!==o&&a(e,t,{get:()=>r[t],enumerable:!(n=d(r,t))||n.enumerable});return e};var b=e=>p(a({},"__esModule",{value:!0}),e);var h={};c(h,{getBaseInputClasses:()=>x,getHelperTextClasses:()=>y,getIconClasses:()=>f,getLabelClasses:()=>m});module.exports=b(h);var s=require("../../../lib/cn.cjs"),u=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],x=({size:e="md",error:r,disabled:o,readOnly:n,icon:t,iconPosition:l})=>(0,s.cn)("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-hidden focus:ring-2","dark:bg-gray-700 dark:placeholder-gray-300",u(e),t&&l==="left"?"pl-9":"",t&&l==="right"?"pr-9":"",
|
|
1
|
+
"use strict";var a=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var c=(e,r)=>{for(var o in r)a(e,o,{get:r[o],enumerable:!0})},p=(e,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of g(r))!i.call(e,t)&&t!==o&&a(e,t,{get:()=>r[t],enumerable:!(n=d(r,t))||n.enumerable});return e};var b=e=>p(a({},"__esModule",{value:!0}),e);var h={};c(h,{getBaseInputClasses:()=>x,getHelperTextClasses:()=>y,getIconClasses:()=>f,getLabelClasses:()=>m});module.exports=b(h);var s=require("../../../lib/cn.cjs"),u=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],x=({size:e="md",error:r,disabled:o,readOnly:n,icon:t,iconPosition:l})=>(0,s.cn)("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-hidden focus:ring-2","dark:bg-gray-700 dark:placeholder-gray-300",u(e),t&&l==="left"?"pl-9":"",t&&l==="right"?"pr-9":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",o?"opacity-50 cursor-not-allowed":"",r?"border-red-500 dark:border-red-500 focus:border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-600 focus:border-synertech-primary-500 focus:ring-synertech-primary-500"),m=(e,r)=>(0,s.cn)("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!r&&"text-gray-900 dark:text-white"),y=e=>(0,s.cn)("mt-1 text-xs",e?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),f=e=>(0,s.cn)("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");0&&(module.exports={getBaseInputClasses,getHelperTextClasses,getIconClasses,getLabelClasses});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as t}from"../../../lib/cn.js";var l=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],g=({size:e="md",error:r,disabled:n,readOnly:a,icon:o,iconPosition:s})=>t("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-hidden focus:ring-2","dark:bg-gray-700 dark:placeholder-gray-300",l(e),o&&s==="left"?"pl-9":"",o&&s==="right"?"pr-9":"",
|
|
1
|
+
import{cn as t}from"../../../lib/cn.js";var l=(e="md")=>({sm:"text-xs p-1.5",md:"text-sm p-2.5",lg:"text-base p-3.5"})[e],g=({size:e="md",error:r,disabled:n,readOnly:a,icon:o,iconPosition:s})=>t("bg-gray-50 placeholder-gray-500 rounded-lg block w-full","border focus:outline-hidden focus:ring-2","dark:bg-gray-700 dark:placeholder-gray-300",l(e),o&&s==="left"?"pl-9":"",o&&s==="right"?"pr-9":"",a?"bg-gray-100 dark:bg-gray-600 cursor-default":"",n?"opacity-50 cursor-not-allowed":"",r?"border-red-500 dark:border-red-500 focus:border-red-500 focus:ring-red-500":"border-gray-300 dark:border-gray-600 focus:border-synertech-primary-500 focus:ring-synertech-primary-500"),i=(e,r)=>t("text-sm font-medium",e?"min-w-[120px]":"block mb-2",!r&&"text-gray-900 dark:text-white"),c=e=>t("mt-1 text-xs",e?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),p=e=>t("absolute inset-y-0 flex items-center pointer-events-none",e==="left"?"left-2.5":"right-2.5");export{g as getBaseInputClasses,c as getHelperTextClasses,p as getIconClasses,i as getLabelClasses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var M=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var ue=(a,o)=>{for(var g in o)M(a,g,{get:o[g],enumerable:!0})},me=(a,o,g,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ge(o))!pe.call(a,s)&&s!==g&&M(a,s,{get:()=>o[s],enumerable:!(i=ce(o,s))||i.enumerable});return a};var he=a=>me(M({},"__esModule",{value:!0}),a);var be={};ue(be,{Header:()=>fe});module.exports=he(be);var k=require("react"),t=require("../../lib/cn.cjs"),I=require("../../lib/safe-href.cjs"),N=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function fe({logo:a,logoHref:o="/",onLogoClick:g,navItems:i=[],actions:s,rightContent:b,variant:n="default",size:w="md",backgroundColor:u,textColor:Q,hoverColor:q,navItemTextColor:F,navItemHoverColor:_,navItemBgHover:G,navItemActiveColor:J,sticky:K=!1,fixed:V=!1,showSearch:E=!1,onSearch:T,searchPlaceholder:X,menuLabel:Y,linkComponent:Z,className:$,containerClassName:ee}){let B=(0,N.useUILabels)(),y=(0,N.useUILinkComponent)(Z),v=X??B.headerSearchPlaceholder,[C,R]=(0,k.useState)(!1),[S,P]=(0,k.useState)(null),[L,j]=(0,k.useState)(""),re=()=>{R(!C)},ae=r=>{P(S===r?null:r)},D=()=>{R(!1),P(null)},O=r=>{r.preventDefault(),T&&T(L)},ne=(0,t.cn)(K&&"sticky top-0 z-50",V&&"fixed top-0 left-0 right-0 z-50"),te=(0,t.cn)(n==="default"&&!u&&"bg-gray-900 text-white",n==="transparent"&&!u&&"bg-transparent",n==="bordered"&&!u&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",n==="shadow"&&!u&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),oe=(0,t.cn)(w==="sm"&&"py-2",w==="md"&&"py-4",w==="lg"&&"py-6"),se=u||"",le=Q||"",de=q||"",ie=(0,t.cn)(ne,te,oe,se,le,$),U=(r,l,m,h)=>{let c=(0,I.componentHref)("Header",r.href),p=d=>{r.onClick?.(d),D()},f=r.href??r.label;return c===void 0&&r.onClick?(0,e.jsx)("button",{type:"button",onClick:p,className:(0,t.cn)(l,m),children:h},f):c!==void 0&&y&&!r.external?(0,e.jsx)(y,{href:c,onClick:p,className:l,children:h},f):(0,e.jsx)("a",{href:c,onClick:p,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:l,children:h},f)},W=(r,l,m=!1)=>{let h=r.children&&r.children.length>0,c=S===l,p=(0,t.cn)("px-4 py-2 transition-colors flex items-center gap-2",m?"
|
|
1
|
+
"use strict";"use client";var M=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var ue=(a,o)=>{for(var g in o)M(a,g,{get:o[g],enumerable:!0})},me=(a,o,g,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ge(o))!pe.call(a,s)&&s!==g&&M(a,s,{get:()=>o[s],enumerable:!(i=ce(o,s))||i.enumerable});return a};var he=a=>me(M({},"__esModule",{value:!0}),a);var be={};ue(be,{Header:()=>fe});module.exports=he(be);var k=require("react"),t=require("../../lib/cn.cjs"),I=require("../../lib/safe-href.cjs"),N=require("../../lib/i18n.cjs"),e=require("react/jsx-runtime");function fe({logo:a,logoHref:o="/",onLogoClick:g,navItems:i=[],actions:s,rightContent:b,variant:n="default",size:w="md",backgroundColor:u,textColor:Q,hoverColor:q,navItemTextColor:F,navItemHoverColor:_,navItemBgHover:G,navItemActiveColor:J,sticky:K=!1,fixed:V=!1,showSearch:E=!1,onSearch:T,searchPlaceholder:X,menuLabel:Y,linkComponent:Z,className:$,containerClassName:ee}){let B=(0,N.useUILabels)(),y=(0,N.useUILinkComponent)(Z),v=X??B.headerSearchPlaceholder,[C,R]=(0,k.useState)(!1),[S,P]=(0,k.useState)(null),[L,j]=(0,k.useState)(""),re=()=>{R(!C)},ae=r=>{P(S===r?null:r)},D=()=>{R(!1),P(null)},O=r=>{r.preventDefault(),T&&T(L)},ne=(0,t.cn)(K&&"sticky top-0 z-50",V&&"fixed top-0 left-0 right-0 z-50"),te=(0,t.cn)(n==="default"&&!u&&"bg-gray-900 text-white",n==="transparent"&&!u&&"bg-transparent",n==="bordered"&&!u&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",n==="shadow"&&!u&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),oe=(0,t.cn)(w==="sm"&&"py-2",w==="md"&&"py-4",w==="lg"&&"py-6"),se=u||"",le=Q||"",de=q||"",ie=(0,t.cn)(ne,te,oe,se,le,$),U=(r,l,m,h)=>{let c=(0,I.componentHref)("Header",r.href),p=d=>{r.onClick?.(d),D()},f=r.href??r.label;return c===void 0&&r.onClick?(0,e.jsx)("button",{type:"button",onClick:p,className:(0,t.cn)(l,m),children:h},f):c!==void 0&&y&&!r.external?(0,e.jsx)(y,{href:c,onClick:p,className:l,children:h},f):(0,e.jsx)("a",{href:c,onClick:p,target:r.external?"_blank":void 0,rel:r.external?"noopener noreferrer":void 0,className:l,children:h},f)},W=(r,l,m=!1)=>{let h=r.children&&r.children.length>0,c=S===l,p=(0,t.cn)("px-4 py-2 transition-colors flex items-center gap-2",m?"w-full text-left":"inline-flex",r.active&&"font-semibold border-b-2",r.active&&(J||"border-current"),F||(n==="default"||n==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),_||de||(n==="default"||n==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),G||"");if(h)return(0,e.jsxs)("div",{className:m?"w-full":"relative",children:[(0,e.jsxs)("button",{type:"button",onClick:()=>ae(l),className:p,children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),H(r.badge)&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),(0,e.jsx)("svg",{className:(0,t.cn)("w-4 h-4 transition-transform",c&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),c&&(0,e.jsx)("div",{className:(0,t.cn)("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",m?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:r.children?.map(d=>U(d,"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700","w-full text-left",(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[d.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:d.icon}),(0,e.jsx)("span",{children:d.label}),H(d.badge)&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:d.badge}),d.external&&(0,e.jsx)("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})))})]},r.href??r.label);let f=(0,e.jsxs)(e.Fragment,{children:[r.icon&&(0,e.jsx)("span",{className:"w-5 h-5",children:r.icon}),(0,e.jsx)("span",{children:r.label}),H(r.badge)&&(0,e.jsx)("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:r.badge}),r.external&&(0,e.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,e.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return U(r,p,"",f)},x=(0,I.componentHref)("Header",o),A=r=>{g?.(r),D()},z="flex items-center hover:opacity-80 transition-opacity";return(0,e.jsxs)("header",{className:ie,children:[(0,e.jsxs)("nav",{className:(0,t.cn)("container mx-auto flex items-center justify-between px-4",ee),children:[a&&(0,e.jsx)("div",{className:"flex items-center",children:x&&y?(0,e.jsx)(y,{href:x,onClick:A,className:z,children:a}):x?(0,e.jsx)("a",{href:x,onClick:A,className:z,children:a}):(0,e.jsx)("div",{className:"flex items-center",children:a})}),E&&(0,e.jsx)("form",{onSubmit:O,className:"hidden md:flex flex-1 max-w-md mx-8",children:(0,e.jsx)("input",{type:"search","aria-label":v,value:L,onChange:r=>j(r.target.value),placeholder:v,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),(0,e.jsx)("div",{className:"hidden md:flex items-center gap-2",children:i.map((r,l)=>W(r,l,!1))}),(s||b)&&(0,e.jsxs)("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[s,b]}),i.length>0&&(0,e.jsx)("div",{className:"md:hidden",children:(0,e.jsx)("button",{type:"button",className:(0,t.cn)("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-synertech-primary-500",n==="default"||n==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:re,"aria-label":Y??B.headerToggleMenu,"aria-expanded":C,children:(0,e.jsx)("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:(0,e.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),C&&i.length>0&&(0,e.jsx)("div",{className:(0,t.cn)("md:hidden border-t animate-in slide-in-from-top duration-300",n==="default"||n==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:(0,e.jsxs)("div",{className:"flex flex-col py-2 px-4",children:[E&&(0,e.jsx)("form",{onSubmit:O,className:"mb-4",children:(0,e.jsx)("input",{type:"search","aria-label":v,value:L,onChange:r=>j(r.target.value),placeholder:v,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),i.map((r,l)=>W(r,l,!0)),(s||b)&&(0,e.jsxs)("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[s,b]})]})})]})}function H(a){return a!=null&&a!==""}0&&(module.exports={Header});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as w}from"react";import{cn as n}from"../../lib/cn.js";import{componentHref as U}from"../../lib/safe-href.js";import{useUILabels as ie,useUILinkComponent as ce}from"../../lib/i18n.js";import{Fragment as ge,jsx as r,jsxs as s}from"react/jsx-runtime";function fe({logo:l,logoHref:W="/",onLogoClick:A,navItems:m=[],actions:h,rightContent:f,variant:a="default",size:x="md",backgroundColor:c,textColor:z,hoverColor:Q,navItemTextColor:q,navItemHoverColor:F,navItemBgHover:_,navItemActiveColor:G,sticky:J=!1,fixed:K=!1,showSearch:L=!1,onSearch:M,searchPlaceholder:V,menuLabel:X,linkComponent:Y,className:Z,containerClassName:$}){let H=ie(),b=ce(Y),y=V??H.headerSearchPlaceholder,[k,I]=w(!1),[E,T]=w(null),[N,B]=w(""),ee=()=>{I(!k)},re=e=>{T(E===e?null:e)},R=()=>{I(!1),T(null)},S=e=>{e.preventDefault(),M&&M(N)},ae=n(J&&"sticky top-0 z-50",K&&"fixed top-0 left-0 right-0 z-50"),ne=n(a==="default"&&!c&&"bg-gray-900 text-white",a==="transparent"&&!c&&"bg-transparent",a==="bordered"&&!c&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!c&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),te=n(x==="sm"&&"py-2",x==="md"&&"py-4",x==="lg"&&"py-6"),oe=c||"",se=z||"",le=Q||"",de=n(ae,ne,te,oe,se,Z),P=(e,t,g,p)=>{let d=U("Header",e.href),i=o=>{e.onClick?.(o),R()},u=e.href??e.label;return d===void 0&&e.onClick?r("button",{type:"button",onClick:i,className:n(t,g),children:p},u):d!==void 0&&b&&!e.external?r(b,{href:d,onClick:i,className:t,children:p},u):r("a",{href:d,onClick:i,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:t,children:p},u)},j=(e,t,g=!1)=>{let p=e.children&&e.children.length>0,d=E===t,i=n("px-4 py-2 transition-colors flex items-center gap-2",g?"
|
|
1
|
+
"use client";import{useState as w}from"react";import{cn as n}from"../../lib/cn.js";import{componentHref as U}from"../../lib/safe-href.js";import{useUILabels as ie,useUILinkComponent as ce}from"../../lib/i18n.js";import{Fragment as ge,jsx as r,jsxs as s}from"react/jsx-runtime";function fe({logo:l,logoHref:W="/",onLogoClick:A,navItems:m=[],actions:h,rightContent:f,variant:a="default",size:x="md",backgroundColor:c,textColor:z,hoverColor:Q,navItemTextColor:q,navItemHoverColor:F,navItemBgHover:_,navItemActiveColor:G,sticky:J=!1,fixed:K=!1,showSearch:L=!1,onSearch:M,searchPlaceholder:V,menuLabel:X,linkComponent:Y,className:Z,containerClassName:$}){let H=ie(),b=ce(Y),y=V??H.headerSearchPlaceholder,[k,I]=w(!1),[E,T]=w(null),[N,B]=w(""),ee=()=>{I(!k)},re=e=>{T(E===e?null:e)},R=()=>{I(!1),T(null)},S=e=>{e.preventDefault(),M&&M(N)},ae=n(J&&"sticky top-0 z-50",K&&"fixed top-0 left-0 right-0 z-50"),ne=n(a==="default"&&!c&&"bg-gray-900 text-white",a==="transparent"&&!c&&"bg-transparent",a==="bordered"&&!c&&"bg-white border-b border-gray-200 text-gray-900 dark:bg-gray-900 dark:border-gray-800 dark:text-gray-100",a==="shadow"&&!c&&"bg-white shadow-md text-gray-900 dark:bg-gray-900 dark:text-gray-100"),te=n(x==="sm"&&"py-2",x==="md"&&"py-4",x==="lg"&&"py-6"),oe=c||"",se=z||"",le=Q||"",de=n(ae,ne,te,oe,se,Z),P=(e,t,g,p)=>{let d=U("Header",e.href),i=o=>{e.onClick?.(o),R()},u=e.href??e.label;return d===void 0&&e.onClick?r("button",{type:"button",onClick:i,className:n(t,g),children:p},u):d!==void 0&&b&&!e.external?r(b,{href:d,onClick:i,className:t,children:p},u):r("a",{href:d,onClick:i,target:e.external?"_blank":void 0,rel:e.external?"noopener noreferrer":void 0,className:t,children:p},u)},j=(e,t,g=!1)=>{let p=e.children&&e.children.length>0,d=E===t,i=n("px-4 py-2 transition-colors flex items-center gap-2",g?"w-full text-left":"inline-flex",e.active&&"font-semibold border-b-2",e.active&&(G||"border-current"),q||(a==="default"||a==="transparent"?"text-gray-300":"text-gray-600 dark:text-gray-300"),F||le||(a==="default"||a==="transparent"?"hover:text-white":"hover:text-synertech-primary-600 dark:hover:text-synertech-primary-400"),_||"");if(p)return s("div",{className:g?"w-full":"relative",children:[s("button",{type:"button",onClick:()=>re(t),className:i,children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),C(e.badge)&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),r("svg",{className:n("w-4 h-4 transition-transform",d&&"rotate-180"),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),d&&r("div",{className:n("bg-white shadow-lg rounded-lg overflow-hidden dark:bg-gray-800 dark:shadow-black/40",g?"mt-2 mb-2":"absolute top-full left-0 mt-1 min-w-[200px]"),children:e.children?.map(o=>P(o,"block px-4 py-2 text-gray-700 hover:bg-gray-100 transition-colors dark:text-gray-200 dark:hover:bg-gray-700","w-full text-left",s("div",{className:"flex items-center gap-2",children:[o.icon&&r("span",{className:"w-5 h-5",children:o.icon}),r("span",{children:o.label}),C(o.badge)&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full ml-auto",children:o.badge}),o.external&&r("svg",{className:"w-4 h-4 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})))})]},e.href??e.label);let u=s(ge,{children:[e.icon&&r("span",{className:"w-5 h-5",children:e.icon}),r("span",{children:e.label}),C(e.badge)&&r("span",{className:"bg-red-600 text-white text-xs px-2 py-0.5 rounded-full",children:e.badge}),e.external&&r("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]});return P(e,i,"",u)},v=U("Header",W),D=e=>{A?.(e),R()},O="flex items-center hover:opacity-80 transition-opacity";return s("header",{className:de,children:[s("nav",{className:n("container mx-auto flex items-center justify-between px-4",$),children:[l&&r("div",{className:"flex items-center",children:v&&b?r(b,{href:v,onClick:D,className:O,children:l}):v?r("a",{href:v,onClick:D,className:O,children:l}):r("div",{className:"flex items-center",children:l})}),L&&r("form",{onSubmit:S,className:"hidden md:flex flex-1 max-w-md mx-8",children:r("input",{type:"search","aria-label":y,value:N,onChange:e=>B(e.target.value),placeholder:y,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),r("div",{className:"hidden md:flex items-center gap-2",children:m.map((e,t)=>j(e,t,!1))}),(h||f)&&s("div",{className:"hidden md:flex items-center gap-2 ml-4",children:[h,f]}),m.length>0&&r("div",{className:"md:hidden",children:r("button",{type:"button",className:n("inline-flex rounded-lg border-2 p-2 w-10 h-10 justify-center transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-synertech-primary-500",a==="default"||a==="transparent"?"text-gray-300 hover:text-white":"text-gray-600 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"),onClick:ee,"aria-label":X??H.headerToggleMenu,"aria-expanded":k,children:r("svg",{className:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 14",children:r("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M1 1h15M1 7h15M1 13h15"})})})})]}),k&&m.length>0&&r("div",{className:n("md:hidden border-t animate-in slide-in-from-top duration-300",a==="default"||a==="transparent"?"border-gray-700":"border-gray-200 dark:border-gray-800"),children:s("div",{className:"flex flex-col py-2 px-4",children:[L&&r("form",{onSubmit:S,className:"mb-4",children:r("input",{type:"search","aria-label":y,value:N,onChange:e=>B(e.target.value),placeholder:y,className:"w-full px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-synertech-primary-500 text-gray-900 placeholder-gray-500 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-400"})}),m.map((e,t)=>j(e,t,!0)),(h||f)&&s("div",{className:"flex flex-col gap-2 mt-4 pt-4 border-t border-gray-700",children:[h,f]})]})})]})}function C(l){return l!=null&&l!==""}export{fe as Header};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},P=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of w(t))!I.call(e,a)&&a!==r&&g(e,a,{get:()=>t[a],enumerable:!(n=y(t,a))||n.enumerable});return e};var k=e=>P(g({},"__esModule",{value:!0}),e);var W={};C(W,{Indicator:()=>b});module.exports=k(W);var i=require("../../lib/cn.cjs"),o=require("react/jsx-runtime"),m={default:"bg-gray-400",primary:"bg-synertech-primary-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},z={default:"bg-gray-500 text-white",primary:"bg-synertech-primary-600 text-synertech-on-primary",success:"bg-green-700 text-white",warning:"bg-yellow-400 text-gray-900",error:"bg-red-600 text-white",info:"bg-cyan-700 text-white",dark:"bg-gray-900 text-white dark:bg-gray-700",purple:"bg-purple-600 text-white",indigo:"bg-indigo-600 text-white",teal:"bg-teal-700 text-white"},p={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},N={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},u={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},f={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function R(e,t){return e>t?`${t}+`:`${e}`}function v({color:e="primary",size:t="md",placement:r="top-right",bordered:n=!1,borderColor:a,pulse:s=!1,offset:l=!1,className:c,...d}){return(0,o.jsx)("span",{"data-testid":"indicator",className:(0,i.cn)("absolute z-10 rounded-full",m[e],p[t],l?f[r]:u[r],n&&(0,i.cn)("ring-2
|
|
1
|
+
"use strict";var g=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},P=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of w(t))!I.call(e,a)&&a!==r&&g(e,a,{get:()=>t[a],enumerable:!(n=y(t,a))||n.enumerable});return e};var k=e=>P(g({},"__esModule",{value:!0}),e);var W={};C(W,{Indicator:()=>b});module.exports=k(W);var i=require("../../lib/cn.cjs"),o=require("react/jsx-runtime"),m={default:"bg-gray-400",primary:"bg-synertech-primary-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},z={default:"bg-gray-500 text-white",primary:"bg-synertech-primary-600 text-synertech-on-primary",success:"bg-green-700 text-white",warning:"bg-yellow-400 text-gray-900",error:"bg-red-600 text-white",info:"bg-cyan-700 text-white",dark:"bg-gray-900 text-white dark:bg-gray-700",purple:"bg-purple-600 text-white",indigo:"bg-indigo-600 text-white",teal:"bg-teal-700 text-white"},p={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},N={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},u={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},f={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function R(e,t){return e>t?`${t}+`:`${e}`}function v({color:e="primary",size:t="md",placement:r="top-right",bordered:n=!1,borderColor:a,pulse:s=!1,offset:l=!1,className:c,...d}){return(0,o.jsx)("span",{"data-testid":"indicator",className:(0,i.cn)("absolute z-10 rounded-full",m[e],p[t],l?f[r]:u[r],n&&(0,i.cn)("ring-2",a||"ring-white dark:ring-gray-900"),s&&"animate-pulse motion-reduce:animate-none",c),...d})}function S({color:e="error",size:t="md",placement:r="top-right",count:n=0,maxCount:a=99,bordered:s=!1,borderColor:l,pulse:c=!1,offset:d=!1,className:x,...h}){return(0,o.jsx)("span",{"data-testid":"indicator",className:(0,i.cn)("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold",z[e],N[t],d?f[r]:u[r],s&&(0,i.cn)("ring-2",l||"ring-white dark:ring-gray-900"),c&&"animate-pulse motion-reduce:animate-none",x),...h,children:R(n,a)})}function O({color:e="success",size:t="md",placement:r="bottom-right",bordered:n=!0,borderColor:a,pulse:s=!1,offset:l=!1,className:c,...d}){return(0,o.jsx)("span",{"data-testid":"indicator",className:(0,i.cn)("absolute z-10 rounded-full",m[e],p[t],l?f[r]:u[r],n&&(0,i.cn)("ring-2",a||"ring-white dark:ring-gray-900"),s&&"animate-pulse motion-reduce:animate-none",c),...d})}function V({color:e="primary",size:t="sm",label:r,className:n,...a}){return(0,o.jsxs)("span",{"data-testid":"indicator",className:(0,i.cn)("inline-flex items-center gap-2",n),...a,children:[(0,o.jsx)("span",{className:(0,i.cn)("rounded-full shrink-0",m[e],p[t])}),r?(0,o.jsx)("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:r}):null]})}function b({variant:e="dot",children:t,...r}){if(e==="legend")return(0,o.jsx)(V,{...r});let n=(()=>{switch(e){case"count":return(0,o.jsx)(S,{...r});case"status":return(0,o.jsx)(O,{...r});default:return(0,o.jsx)(v,{...r})}})();return t?(0,o.jsxs)("div",{className:"relative inline-flex",children:[t,n]}):n}b.displayName="Indicator";0&&(module.exports={Indicator});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cn as o}from"../../lib/cn.js";import{jsx as a,jsxs as f}from"react/jsx-runtime";var g={default:"bg-gray-400",primary:"bg-synertech-primary-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},h={default:"bg-gray-500 text-white",primary:"bg-synertech-primary-600 text-synertech-on-primary",success:"bg-green-700 text-white",warning:"bg-yellow-400 text-gray-900",error:"bg-red-600 text-white",info:"bg-cyan-700 text-white",dark:"bg-gray-900 text-white dark:bg-gray-700",purple:"bg-purple-600 text-white",indigo:"bg-indigo-600 text-white",teal:"bg-teal-700 text-white"},m={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},y={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},p={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},u={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function w(e,r){return e>r?`${r}+`:`${e}`}function I({color:e="primary",size:r="md",placement:t="top-right",bordered:n=!1,borderColor:i,pulse:s=!1,offset:l=!1,className:c,...d}){return a("span",{"data-testid":"indicator",className:o("absolute z-10 rounded-full",g[e],m[r],l?u[t]:p[t],n&&o("ring-2
|
|
1
|
+
import{cn as o}from"../../lib/cn.js";import{jsx as a,jsxs as f}from"react/jsx-runtime";var g={default:"bg-gray-400",primary:"bg-synertech-primary-600",success:"bg-green-500",warning:"bg-yellow-400",error:"bg-red-500",info:"bg-cyan-500",dark:"bg-gray-900 dark:bg-gray-700",purple:"bg-purple-600",indigo:"bg-indigo-600",teal:"bg-teal-500"},h={default:"bg-gray-500 text-white",primary:"bg-synertech-primary-600 text-synertech-on-primary",success:"bg-green-700 text-white",warning:"bg-yellow-400 text-gray-900",error:"bg-red-600 text-white",info:"bg-cyan-700 text-white",dark:"bg-gray-900 text-white dark:bg-gray-700",purple:"bg-purple-600 text-white",indigo:"bg-indigo-600 text-white",teal:"bg-teal-700 text-white"},m={xs:"w-2 h-2",sm:"w-2.5 h-2.5",md:"w-3 h-3",lg:"w-3.5 h-3.5",xl:"w-4 h-4"},y={xs:"min-w-4 h-4 text-[10px] px-1",sm:"min-w-5 h-5 text-xs px-1",md:"min-w-5 h-5 text-xs px-1.5",lg:"min-w-6 h-6 text-sm px-1.5",xl:"min-w-7 h-7 text-sm px-2"},p={"top-left":"top-0 left-0 -translate-x-1/2 -translate-y-1/2","top-center":"top-0 left-1/2 -translate-x-1/2 -translate-y-1/2","top-right":"top-0 right-0 translate-x-1/2 -translate-y-1/2","center-left":"top-1/2 left-0 -translate-x-1/2 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 translate-x-1/2 -translate-y-1/2","bottom-left":"bottom-0 left-0 -translate-x-1/2 translate-y-1/2","bottom-center":"bottom-0 left-1/2 -translate-x-1/2 translate-y-1/2","bottom-right":"bottom-0 right-0 translate-x-1/2 translate-y-1/2"},u={"top-left":"top-0 left-0","top-center":"top-0 left-1/2 -translate-x-1/2","top-right":"top-0 right-0","center-left":"top-1/2 left-0 -translate-y-1/2",center:"top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2","center-right":"top-1/2 right-0 -translate-y-1/2","bottom-left":"bottom-0 left-0","bottom-center":"bottom-0 left-1/2 -translate-x-1/2","bottom-right":"bottom-0 right-0"};function w(e,r){return e>r?`${r}+`:`${e}`}function I({color:e="primary",size:r="md",placement:t="top-right",bordered:n=!1,borderColor:i,pulse:s=!1,offset:l=!1,className:c,...d}){return a("span",{"data-testid":"indicator",className:o("absolute z-10 rounded-full",g[e],m[r],l?u[t]:p[t],n&&o("ring-2",i||"ring-white dark:ring-gray-900"),s&&"animate-pulse motion-reduce:animate-none",c),...d})}function C({color:e="error",size:r="md",placement:t="top-right",count:n=0,maxCount:i=99,bordered:s=!1,borderColor:l,pulse:c=!1,offset:d=!1,className:b,...x}){return a("span",{"data-testid":"indicator",className:o("absolute z-10 inline-flex items-center justify-center rounded-full font-semibold",h[e],y[r],d?u[t]:p[t],s&&o("ring-2",l||"ring-white dark:ring-gray-900"),c&&"animate-pulse motion-reduce:animate-none",b),...x,children:w(n,i)})}function P({color:e="success",size:r="md",placement:t="bottom-right",bordered:n=!0,borderColor:i,pulse:s=!1,offset:l=!1,className:c,...d}){return a("span",{"data-testid":"indicator",className:o("absolute z-10 rounded-full",g[e],m[r],l?u[t]:p[t],n&&o("ring-2",i||"ring-white dark:ring-gray-900"),s&&"animate-pulse motion-reduce:animate-none",c),...d})}function k({color:e="primary",size:r="sm",label:t,className:n,...i}){return f("span",{"data-testid":"indicator",className:o("inline-flex items-center gap-2",n),...i,children:[a("span",{className:o("rounded-full shrink-0",g[e],m[r])}),t?a("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:t}):null]})}function z({variant:e="dot",children:r,...t}){if(e==="legend")return a(k,{...t});let n=(()=>{switch(e){case"count":return a(C,{...t});case"status":return a(P,{...t});default:return a(I,{...t})}})();return r?f("div",{className:"relative inline-flex",children:[r,n]}):n}z.displayName="Indicator";export{z as Indicator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var E=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var ge=(e,r)=>{for(var s in r)E(e,s,{get:r[s],enumerable:!0})},ue=(e,r,s,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of de(r))!ce.call(e,a)&&a!==s&&E(e,a,{get:()=>r[a],enumerable:!(c=le(r,a))||c.enumerable});return e};var he=e=>ue(E({},"__esModule",{value:!0}),e);var ye={};ge(ye,{RadioButton:()=>H});module.exports=he(ye);var C=require("react"),o=require("../../lib/cn.cjs"),i=require("../../lib/css-value.cjs"),F=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),be=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],fe=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],me=(e,r,s,c,a,v,p,g)=>{if(r)return(0,o.cn)("border-2",c?"":"border-red-500",s&&!a?"bg-red-500":"");switch(e){case"filled":return(0,o.cn)("border-2",g?"":"border-gray-300 dark:border-gray-600",s?v?"":"bg-synertech-primary-600 border-synertech-primary-600 dark:bg-synertech-primary-500 dark:border-synertech-primary-500":p?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case"outlined":return(0,o.cn)("border-[3px]",g?"":s?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return(0,o.cn)("border-2",g?"":s?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},pe={},H=(0,C.forwardRef)(({label:e,description:r,value:s,checked:c,defaultChecked:a=!1,onCheckedChange:v,size:p="md",variant:g="default",labelPosition:y="right",error:L,disabled:u=!1,readOnly:l=!1,required:I=!1,checkedColor:T,uncheckedColor:W,borderColor:q,labelColor:V,errorColor:A,dotColor:G,hoverColor:J,focusRingColor:K,showFocusRing:M=!0,className:Q,containerClassName:U,id:X,onClick:Y,"aria-describedby":Z,..._},$)=>{let f=(0,i.safeCssColor)(T),k=(0,i.safeCssColor)(W),x=(0,i.safeCssColor)(q),w=(0,i.safeCssColor)(V),h=(0,i.safeCssColor)(A),m=(0,i.safeCssColor)(G),R=(0,i.safeCssColor)(J),S=(0,i.safeCssColor)(K),j=c!==void 0,O=(0,C.useId)(),N=X||O,b=(0,F.describeField)(N,{description:r,error:L,own:Z}),P=b.message,z=b.invalid,ee=n=>{u||l||v?.(n.target.checked)},re=n=>{Y?.(n),l&&n.preventDefault()},oe=w?"":"text-gray-700 dark:text-gray-200",te=h?"":"text-red-600 dark:text-red-400",se=R?"hover:border-[color:var(--synertech-radio-hover)]":"hover:border-synertech-primary-500 dark:hover:border-synertech-primary-400",ne=S?"peer-focus-visible:ring-[color:var(--synertech-radio-ring)]":"peer-focus-visible:ring-synertech-primary-500",B=n=>{let d={};f&&n&&(d.backgroundColor=f,d.borderColor=f),k&&!n&&(d.backgroundColor=k),x&&(d.borderColor=x),z&&h&&(d.borderColor=h,n&&!m&&(d.backgroundColor=h));let D=d;return R&&(D["--synertech-radio-hover"]=R),S&&(D["--synertech-radio-ring"]=S),(0,t.jsx)("div",{className:(0,o.cn)("rounded-full transition-all duration-200",be(p),me(g,z,n,h,m,f,k,x),!u&&!l&&se,!u&&!l&&M&&"peer-focus-visible:ring-2 ring-offset-2",!u&&!l&&M&&ne,Q,n?"hidden peer-checked:block":"peer-checked:hidden"),style:d,children:n&&(0,t.jsx)("div",{className:(0,o.cn)("rounded-full absolute inset-0 m-auto transition-all duration-200",fe(p),m?"":g==="outlined"||g==="default"?"bg-synertech-primary-600 dark:bg-synertech-primary-500":f?"bg-white":"bg-synertech-on-primary"),style:m?{backgroundColor:m}:void 0})})},ae=w?{color:w}:{},ie=h?{color:h}:{};return(0,t.jsxs)("div",{className:(0,o.cn)("inline-flex flex-col",U),style:pe,children:[(0,t.jsxs)("label",{className:(0,o.cn)("inline-flex items-center cursor-pointer",u&&"opacity-50 cursor-not-allowed",
|
|
1
|
+
"use strict";"use client";var E=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var ce=Object.prototype.hasOwnProperty;var ge=(e,r)=>{for(var s in r)E(e,s,{get:r[s],enumerable:!0})},ue=(e,r,s,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of de(r))!ce.call(e,a)&&a!==s&&E(e,a,{get:()=>r[a],enumerable:!(c=le(r,a))||c.enumerable});return e};var he=e=>ue(E({},"__esModule",{value:!0}),e);var ye={};ge(ye,{RadioButton:()=>H});module.exports=he(ye);var C=require("react"),o=require("../../lib/cn.cjs"),i=require("../../lib/css-value.cjs"),F=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),be=e=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[e],fe=e=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[e],me=(e,r,s,c,a,v,p,g)=>{if(r)return(0,o.cn)("border-2",c?"":"border-red-500",s&&!a?"bg-red-500":"");switch(e){case"filled":return(0,o.cn)("border-2",g?"":"border-gray-300 dark:border-gray-600",s?v?"":"bg-synertech-primary-600 border-synertech-primary-600 dark:bg-synertech-primary-500 dark:border-synertech-primary-500":p?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case"outlined":return(0,o.cn)("border-[3px]",g?"":s?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return(0,o.cn)("border-2",g?"":s?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},pe={},H=(0,C.forwardRef)(({label:e,description:r,value:s,checked:c,defaultChecked:a=!1,onCheckedChange:v,size:p="md",variant:g="default",labelPosition:y="right",error:L,disabled:u=!1,readOnly:l=!1,required:I=!1,checkedColor:T,uncheckedColor:W,borderColor:q,labelColor:V,errorColor:A,dotColor:G,hoverColor:J,focusRingColor:K,showFocusRing:M=!0,className:Q,containerClassName:U,id:X,onClick:Y,"aria-describedby":Z,..._},$)=>{let f=(0,i.safeCssColor)(T),k=(0,i.safeCssColor)(W),x=(0,i.safeCssColor)(q),w=(0,i.safeCssColor)(V),h=(0,i.safeCssColor)(A),m=(0,i.safeCssColor)(G),R=(0,i.safeCssColor)(J),S=(0,i.safeCssColor)(K),j=c!==void 0,O=(0,C.useId)(),N=X||O,b=(0,F.describeField)(N,{description:r,error:L,own:Z}),P=b.message,z=b.invalid,ee=n=>{u||l||v?.(n.target.checked)},re=n=>{Y?.(n),l&&n.preventDefault()},oe=w?"":"text-gray-700 dark:text-gray-200",te=h?"":"text-red-600 dark:text-red-400",se=R?"hover:border-[color:var(--synertech-radio-hover)]":"hover:border-synertech-primary-500 dark:hover:border-synertech-primary-400",ne=S?"peer-focus-visible:ring-[color:var(--synertech-radio-ring)]":"peer-focus-visible:ring-synertech-primary-500",B=n=>{let d={};f&&n&&(d.backgroundColor=f,d.borderColor=f),k&&!n&&(d.backgroundColor=k),x&&(d.borderColor=x),z&&h&&(d.borderColor=h,n&&!m&&(d.backgroundColor=h));let D=d;return R&&(D["--synertech-radio-hover"]=R),S&&(D["--synertech-radio-ring"]=S),(0,t.jsx)("div",{className:(0,o.cn)("rounded-full transition-all duration-200",be(p),me(g,z,n,h,m,f,k,x),!u&&!l&&se,!u&&!l&&M&&"peer-focus-visible:ring-2 ring-offset-2",!u&&!l&&M&&ne,Q,n?"hidden peer-checked:block":"peer-checked:hidden"),style:d,children:n&&(0,t.jsx)("div",{className:(0,o.cn)("rounded-full absolute inset-0 m-auto transition-all duration-200",fe(p),m?"":g==="outlined"||g==="default"?"bg-synertech-primary-600 dark:bg-synertech-primary-500":f?"bg-white":"bg-synertech-on-primary"),style:m?{backgroundColor:m}:void 0})})},ae=w?{color:w}:{},ie=h?{color:h}:{};return(0,t.jsxs)("div",{className:(0,o.cn)("inline-flex flex-col",U),style:pe,children:[(0,t.jsxs)("label",{className:(0,o.cn)("inline-flex items-center cursor-pointer",l&&"cursor-default",u&&"opacity-50 cursor-not-allowed",y==="left"&&"flex-row-reverse"),htmlFor:N,children:[(0,t.jsxs)("div",{className:"relative inline-flex items-center",children:[(0,t.jsx)("input",{ref:$,type:"radio",id:N,value:s,...j?{checked:c}:{defaultChecked:a},onChange:ee,onClick:re,disabled:u,readOnly:l,required:I,"aria-invalid":z||void 0,"aria-describedby":b.describedBy,className:"sr-only peer",tabIndex:l?-1:void 0,..._}),B(!1),B(!0)]}),e&&(0,t.jsxs)("span",{className:(0,o.cn)("select-none",y==="left"?"mr-2":"ml-2",oe,u&&"opacity-50"),style:ae,children:[e,I&&(0,t.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-1","aria-hidden":"true",children:"*"})]})]}),b.hasDescription&&(0,t.jsx)("p",{id:b.ids.description,className:(0,o.cn)("text-sm text-gray-500 dark:text-gray-400 mt-1",y==="left"?"text-right":"ml-7"),children:r}),P!==void 0&&(0,t.jsx)("p",{id:b.ids.error,className:(0,o.cn)("text-sm mt-1",y==="left"?"text-right":"ml-7",te),style:ie,children:P})]})});H.displayName="RadioButton";0&&(module.exports={RadioButton});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useId as ne,forwardRef as ae}from"react";import{cn as r}from"../../lib/cn.js";import{safeCssColor as n}from"../../lib/css-value.js";import{describeField as ie}from"../form/shared/field-error.js";import{jsx as u,jsxs as y}from"react/jsx-runtime";var le=o=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[o],de=o=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[o],ce=(o,d,c,f,C,v,m,a)=>{if(d)return r("border-2",f?"":"border-red-500",c&&!C?"bg-red-500":"");switch(o){case"filled":return r("border-2",a?"":"border-gray-300 dark:border-gray-600",c?v?"":"bg-synertech-primary-600 border-synertech-primary-600 dark:bg-synertech-primary-500 dark:border-synertech-primary-500":m?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case"outlined":return r("border-[3px]",a?"":c?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return r("border-2",a?"":c?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},ge={},ue=ae(({label:o,description:d,value:c,checked:f,defaultChecked:C=!1,onCheckedChange:v,size:m="md",variant:a="default",labelPosition:p="right",error:D,disabled:i=!1,readOnly:t=!1,required:E=!1,checkedColor:F,uncheckedColor:H,borderColor:L,labelColor:T,errorColor:W,dotColor:q,hoverColor:V,focusRingColor:A,showFocusRing:I=!0,className:G,containerClassName:J,id:K,onClick:Q,"aria-describedby":U,...X},Y)=>{let h=n(F),k=n(H),x=n(L),w=n(T),l=n(W),b=n(q),R=n(V),S=n(A),Z=f!==void 0,_=ne(),N=K||_,g=ie(N,{description:d,error:D,own:U}),M=g.message,z=g.invalid,$=e=>{i||t||v?.(e.target.checked)},j=e=>{Q?.(e),t&&e.preventDefault()},O=w?"":"text-gray-700 dark:text-gray-200",ee=l?"":"text-red-600 dark:text-red-400",re=R?"hover:border-[color:var(--synertech-radio-hover)]":"hover:border-synertech-primary-500 dark:hover:border-synertech-primary-400",oe=S?"peer-focus-visible:ring-[color:var(--synertech-radio-ring)]":"peer-focus-visible:ring-synertech-primary-500",P=e=>{let s={};h&&e&&(s.backgroundColor=h,s.borderColor=h),k&&!e&&(s.backgroundColor=k),x&&(s.borderColor=x),z&&l&&(s.borderColor=l,e&&!b&&(s.backgroundColor=l));let B=s;return R&&(B["--synertech-radio-hover"]=R),S&&(B["--synertech-radio-ring"]=S),u("div",{className:r("rounded-full transition-all duration-200",le(m),ce(a,z,e,l,b,h,k,x),!i&&!t&&re,!i&&!t&&I&&"peer-focus-visible:ring-2 ring-offset-2",!i&&!t&&I&&oe,G,e?"hidden peer-checked:block":"peer-checked:hidden"),style:s,children:e&&u("div",{className:r("rounded-full absolute inset-0 m-auto transition-all duration-200",de(m),b?"":a==="outlined"||a==="default"?"bg-synertech-primary-600 dark:bg-synertech-primary-500":h?"bg-white":"bg-synertech-on-primary"),style:b?{backgroundColor:b}:void 0})})},te=w?{color:w}:{},se=l?{color:l}:{};return y("div",{className:r("inline-flex flex-col",J),style:ge,children:[y("label",{className:r("inline-flex items-center cursor-pointer",i&&"opacity-50 cursor-not-allowed",
|
|
1
|
+
"use client";import{useId as ne,forwardRef as ae}from"react";import{cn as r}from"../../lib/cn.js";import{safeCssColor as n}from"../../lib/css-value.js";import{describeField as ie}from"../form/shared/field-error.js";import{jsx as u,jsxs as y}from"react/jsx-runtime";var le=o=>({sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"})[o],de=o=>({sm:"w-2 h-2",md:"w-2.5 h-2.5",lg:"w-3 h-3"})[o],ce=(o,d,c,f,C,v,m,a)=>{if(d)return r("border-2",f?"":"border-red-500",c&&!C?"bg-red-500":"");switch(o){case"filled":return r("border-2",a?"":"border-gray-300 dark:border-gray-600",c?v?"":"bg-synertech-primary-600 border-synertech-primary-600 dark:bg-synertech-primary-500 dark:border-synertech-primary-500":m?"":"bg-gray-200 border-gray-200 dark:bg-gray-700 dark:border-gray-700");case"outlined":return r("border-[3px]",a?"":c?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800");default:return r("border-2",a?"":c?"border-synertech-primary-600 dark:border-synertech-primary-500":"border-gray-300 dark:border-gray-600","bg-white dark:bg-gray-800")}},ge={},ue=ae(({label:o,description:d,value:c,checked:f,defaultChecked:C=!1,onCheckedChange:v,size:m="md",variant:a="default",labelPosition:p="right",error:D,disabled:i=!1,readOnly:t=!1,required:E=!1,checkedColor:F,uncheckedColor:H,borderColor:L,labelColor:T,errorColor:W,dotColor:q,hoverColor:V,focusRingColor:A,showFocusRing:I=!0,className:G,containerClassName:J,id:K,onClick:Q,"aria-describedby":U,...X},Y)=>{let h=n(F),k=n(H),x=n(L),w=n(T),l=n(W),b=n(q),R=n(V),S=n(A),Z=f!==void 0,_=ne(),N=K||_,g=ie(N,{description:d,error:D,own:U}),M=g.message,z=g.invalid,$=e=>{i||t||v?.(e.target.checked)},j=e=>{Q?.(e),t&&e.preventDefault()},O=w?"":"text-gray-700 dark:text-gray-200",ee=l?"":"text-red-600 dark:text-red-400",re=R?"hover:border-[color:var(--synertech-radio-hover)]":"hover:border-synertech-primary-500 dark:hover:border-synertech-primary-400",oe=S?"peer-focus-visible:ring-[color:var(--synertech-radio-ring)]":"peer-focus-visible:ring-synertech-primary-500",P=e=>{let s={};h&&e&&(s.backgroundColor=h,s.borderColor=h),k&&!e&&(s.backgroundColor=k),x&&(s.borderColor=x),z&&l&&(s.borderColor=l,e&&!b&&(s.backgroundColor=l));let B=s;return R&&(B["--synertech-radio-hover"]=R),S&&(B["--synertech-radio-ring"]=S),u("div",{className:r("rounded-full transition-all duration-200",le(m),ce(a,z,e,l,b,h,k,x),!i&&!t&&re,!i&&!t&&I&&"peer-focus-visible:ring-2 ring-offset-2",!i&&!t&&I&&oe,G,e?"hidden peer-checked:block":"peer-checked:hidden"),style:s,children:e&&u("div",{className:r("rounded-full absolute inset-0 m-auto transition-all duration-200",de(m),b?"":a==="outlined"||a==="default"?"bg-synertech-primary-600 dark:bg-synertech-primary-500":h?"bg-white":"bg-synertech-on-primary"),style:b?{backgroundColor:b}:void 0})})},te=w?{color:w}:{},se=l?{color:l}:{};return y("div",{className:r("inline-flex flex-col",J),style:ge,children:[y("label",{className:r("inline-flex items-center cursor-pointer",t&&"cursor-default",i&&"opacity-50 cursor-not-allowed",p==="left"&&"flex-row-reverse"),htmlFor:N,children:[y("div",{className:"relative inline-flex items-center",children:[u("input",{ref:Y,type:"radio",id:N,value:c,...Z?{checked:f}:{defaultChecked:C},onChange:$,onClick:j,disabled:i,readOnly:t,required:E,"aria-invalid":z||void 0,"aria-describedby":g.describedBy,className:"sr-only peer",tabIndex:t?-1:void 0,...X}),P(!1),P(!0)]}),o&&y("span",{className:r("select-none",p==="left"?"mr-2":"ml-2",O,i&&"opacity-50"),style:te,children:[o,E&&u("span",{className:"text-red-600 dark:text-red-400 ml-1","aria-hidden":"true",children:"*"})]})]}),g.hasDescription&&u("p",{id:g.ids.description,className:r("text-sm text-gray-500 dark:text-gray-400 mt-1",p==="left"?"text-right":"ml-7"),children:d}),M!==void 0&&u("p",{id:g.ids.error,className:r("text-sm mt-1",p==="left"?"text-right":"ml-7",ee),style:se,children:M})]})});ue.displayName="RadioButton";export{ue as RadioButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";"use client";var Se=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var Lt=(o,s)=>{for(var a in s)Se(o,a,{get:s[a],enumerable:!0})},Nt=(o,s,a,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of wt(s))!Ct.call(o,f)&&f!==a&&Se(o,f,{get:()=>s[f],enumerable:!(c=kt(s,f))||c.enumerable});return o};var It=o=>Nt(Se({},"__esModule",{value:!0}),o);var zt={};Lt(zt,{Select:()=>Ht});module.exports=It(zt);var r=require("react"),Xe=require("react-dom"),Ze=require("../../lib/aria-hide.cjs"),Z=require("../../lib/owner-document.cjs"),j=require("../../lib/i18n.cjs"),Ge=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),St=[],se=[],X=o=>o.preventDefault(),Mt=(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ye=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Et=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Dt=(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,t.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Ot=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),S={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},Me={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},Tt="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Bt="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function m(...o){let s="";for(let a=0;a<o.length;a++){let c=o[a];c&&(s&&(s+=" "),s+=c)}return s}function Rt(o,s){if(!s)return o;let a=s.toLowerCase();return o.filter(c=>{if(c.label.toLowerCase().includes(a)||c.value.toLowerCase().includes(a))return!0;if(c.keywords){for(let f of c.keywords)if(f.toLowerCase().includes(a))return!0}return!1})}function Qe(o,s){if(o!==void 0)return Array.isArray(o)?s?new Set(o).size===o.length?o:Array.from(new Set(o)):o.slice(0,1):o===""?se:[o]}function Je(o,s,a,c,f){return m(S[o].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!c&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",a&&!s&&!f&&"bg-gray-50 dark:bg-gray-700/50",c&&"opacity-50 cursor-not-allowed")}var At=(0,r.memo)((0,r.forwardRef)(function({option:s,isSelected:a,isHighlighted:c,isDisabled:f,multiple:A,sizeKey:U,optionId:oe,onClick:le,onMouseEnter:W,index:b},v){let u=()=>{f||le(s.value)},x=()=>{f||W(b)};return(0,t.jsxs)("div",{ref:v,id:oe,role:"option","aria-selected":a,"aria-disabled":f||void 0,"data-highlighted":c||void 0,className:Je(U,c,a,f,A),onMouseDown:X,onClick:u,onMouseEnter:x,children:[A?(0,t.jsx)("span",{"aria-hidden":"true",className:m("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",a?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:a?Vt:null}):null,s.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:s.icon}):null,(0,t.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"truncate",children:s.label}),s.description?(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:s.description}):null]}),a&&!A?(0,t.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Ot}):null]})}));function Ht(o){let{options:s=St,multiple:a=!1,value:c,defaultValue:f,onValueChange:A,maxTagCount:U,creatable:oe=!1,searchable:le=!1,clearable:W=!1,disabled:b=!1,readOnly:v=!1,loading:u=!1,size:x="md",variant:ie="default",placeholder:et,label:G,description:Ee,helperText:De,error:tt,required:Oe=!1,noOptionsText:rt,clearLabel:Ve,searchLabel:nt,searchPlaceholder:at,labels:st,onSearchChange:Pe,name:ce,className:ot,triggerClassName:Te,contentClassName:lt,maxHeight:de=256}=o,w=a&&oe,V=le||w,N=(0,j.useUILabels)(st),Be=et??N.selectPlaceholder,it=rt??N.selectNoOptions,H=(0,r.useId)(),ue=`${H}-label`,pe=`${H}-trigger`,ge=`${H}-listbox`,h=(0,Ge.describeField)(pe,{description:Ee,helperText:De,error:tt}),y=(0,r.useRef)(null),fe=(0,r.useRef)(null),he=(0,r.useRef)(null),me=(0,r.useRef)(null),be=(0,r.useRef)([]),Re=c!==void 0,[ye,ct]=(0,r.useState)(()=>Qe(f,a)??se),Ae=(0,r.useMemo)(()=>Qe(c,a),[c,a]),l=(0,r.useMemo)(()=>Ae??(a?ye:ye.slice(0,1)),[Ae,ye,a]),[p,xe]=(0,r.useState)(!1),[z,F]=(0,r.useState)(""),[g,k]=(0,r.useState)(-1),[P,He]=(0,r.useState)(null),K=(0,r.useMemo)(()=>{let e=new Map;for(let n of s)e.has(n.value)||e.set(n.value,n);return e},[s]),$=(0,r.useMemo)(()=>{if(!w)return s;let e=[];for(let n of l)K.has(n)||e.push({value:n,label:n});return e.length>0?[...s,...e]:s},[w,s,l,K]),I=(0,r.useMemo)(()=>V?Rt($,z):$,[$,z,V]),M=z.trim(),_=(0,r.useMemo)(()=>{if(!w||M==="")return null;let e=M.toLowerCase();return $.find(n=>n.label.toLowerCase()===e)??null},[w,M,$]),ve=w&&M!==""&&_===null,T=ve?I.length:-1,B=I.length+(ve?1:0),q=(0,r.useMemo)(()=>new Set(l),[l]),J=(0,r.useMemo)(()=>a?null:K.get(l[0]??"")??null,[a,K,l]),ke=(0,r.useMemo)(()=>{let e=new Set;for(let n of s)n.disabled&&e.add(n.value);return e},[s]),ee=(0,r.useCallback)(e=>e<I.length&&ke.has(I[e].value),[I,ke]),ze=(0,r.useCallback)(e=>K.get(e)?.label??e,[K]),E=(0,r.useCallback)(e=>{Re||ct(e),A?.(a?e:e[0]??"")},[Re,A,a]),dt=(0,r.useCallback)(e=>{u||(E([e]),xe(!1),F(""),k(-1),y.current?.focus())},[E,u]),D=(0,r.useCallback)(e=>{u||E(e)},[E,u]),ut=(0,r.useCallback)(e=>{D(q.has(e)?l.filter(n=>n!==e):[...l,e])},[D,q,l]),pt=(0,r.useCallback)(e=>{D(l.filter(n=>n!==e))},[D,l]),te=(0,r.useCallback)(()=>{l.length!==0&&D(l.slice(0,-1))},[D,l]),Y=(0,r.useCallback)(()=>{if(!w||M===""||u||_?.disabled)return;let e=_?_.value:M;q.has(e)||D([...l,e]),F(""),k(-1)},[w,M,_,u,q,D,l]),we=a?ut:dt,Ce=(0,r.useCallback)(e=>{if(e===T){Y();return}e<0||e>=I.length||ee(e)||we(I[e].value)},[T,Y,I,ee,we]),Le=(0,r.useCallback)(()=>{((p&&V?me.current:null)??y.current)?.focus()},[p,V]),Fe=(0,r.useCallback)(e=>{e.stopPropagation(),E(se),F(""),Le()},[E,Le]),R=(0,r.useCallback)(()=>{b||v||(xe(!0),F(""),k(-1))},[b,v]),C=(0,r.useCallback)(()=>{xe(!1),F(""),k(-1),y.current?.focus()},[]),gt=(0,r.useCallback)(()=>{p?C():R()},[p,C,R]),Q=(0,r.useCallback)((e,n)=>{let i=B;if(i===0)return-1;let d=e;for(let O=0;O<i;O++)if(d=((d+n)%i+i)%i,!ee(d))return d;return-1},[B,ee]),re=(0,r.useCallback)((e,n)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let i=Q(g,1);i!==-1&&k(i);break}case"ArrowUp":{e.preventDefault();let i=Q(g,-1);i!==-1&&k(i);break}case"Home":{e.preventDefault();let i=Q(-1,1);i!==-1&&k(i);break}case"End":{e.preventDefault();let i=Q(B,-1);i!==-1&&k(i);break}case"Enter":{e.preventDefault(),g>=0&&g<B?Ce(g):w&&Y();break}case" ":if(n)break;e.preventDefault(),g>=0&&g<B?Ce(g):C();break;case"Backspace":a&&(!n||z==="")&&(n||e.preventDefault(),te());break;case"Escape":e.preventDefault(),C();break;case"Tab":C();break}},[Q,g,B,Ce,w,Y,C,a,z,te]),ft=(0,r.useCallback)(e=>{if(!(b||v)){if(p){re(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),R();break;case"Enter":case" ":e.preventDefault(),R();break;case"Backspace":case"Delete":a?e.key==="Backspace"&&l.length>0&&(e.preventDefault(),te()):W&&!u&&l.length>0&&(e.preventDefault(),E(se));break}}},[b,v,p,re,R,a,l.length,te,W,u,E]),ht=(0,r.useCallback)(e=>re(e,!0),[re]),mt=(0,r.useCallback)(e=>{let n=e.target.value;F(n),k(-1),Pe?.(n)},[Pe]),L=!b&&!v,bt=(0,r.useCallback)(e=>{L&&(y.current?.contains(e.target)||e.preventDefault())},[L]),yt=(0,r.useCallback)(()=>{L&&(p?C():(y.current?.focus(),R()))},[L,p,C,R]);(0,r.useEffect)(()=>{if(!p)return;let e=i=>{let d=i.target;y.current?.contains(d)||fe.current?.contains(d)||he.current?.contains(d)||C()},n=(0,Z.ownerDocumentOf)(y.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[p,C]);let xt=a?l.length:0;(0,r.useEffect)(()=>{if(!p||!y.current){He(null);return}let e=(0,Z.ownerWindowOf)(y.current),n=()=>{let i=a?fe.current:y.current;if(!i)return;let d=i.getBoundingClientRect(),O=e.innerHeight-d.bottom,Ie=d.top,vt=de+8,qe=O<vt&&Ie>O?"top":"bottom";He({top:qe==="bottom"?d.bottom+e.scrollY+4:d.top+e.scrollY-4,left:d.left+e.scrollX,width:d.width,placement:qe})};return n(),e.addEventListener("scroll",n,!0),e.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n,!0),e.removeEventListener("resize",n)}},[p,de,a,xt]);let ne=p&&P!==null;(0,r.useEffect)(()=>{ne&&V&&me.current?.focus()},[ne,V]),(0,r.useEffect)(()=>{let e=he.current;if(!(!ne||!e))return(0,Ze.registerFloatingLayer)(e,()=>y.current)},[ne]),(0,r.useEffect)(()=>{if(g>=0){let e=be.current[g];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[g]);let ae=l.length>0,Ke=W&&ae&&!b&&!v&&!u,je=L&&!u,Ue=p&&g>=0?`${H}-option-${g}`:void 0,We={ref:y,id:pe,type:"button",role:"combobox","aria-expanded":p,"aria-haspopup":"listbox","aria-controls":p?ge:void 0,"aria-labelledby":G?ue:void 0,"aria-required":Oe||void 0,"aria-invalid":h.invalid||void 0,"aria-describedby":h.describedBy,"aria-activedescendant":Ue,disabled:b,onKeyDown:ft},$e=u?(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Dt}):null,_e=(0,t.jsx)("span",{className:m("text-gray-500 dark:text-gray-400 transition-transform duration-200",p&&"rotate-180"),children:Mt}),Ne;if(a){let e=U===void 0||!Number.isFinite(U)?l.length:Math.max(0,Math.floor(U)),n=l.slice(0,e),i=l.length-n.length;Ne=(0,t.jsxs)("div",{ref:fe,className:m("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].frame,Me[ie].trigger,!h.invalid&&L&&Tt,h.invalid&&Bt,b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",L&&"cursor-pointer",Te),onMouseDown:bt,onClick:yt,children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[n.map(d=>{let O=ze(d);return(0,t.jsxs)("span",{className:m("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",S[x].tag,!je&&"pr-2"),children:[(0,t.jsx)("span",{className:"min-w-0 truncate","aria-hidden":"true",children:O}),je?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":(0,j.formatUILabel)(N.selectRemoveValue,{label:O}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:X,onClick:Ie=>{Ie.stopPropagation(),pt(d),Le()},children:Et}):null]},d)}),i>0?(0,t.jsx)("span",{"aria-hidden":"true",className:m("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",S[x].tag,"pr-2"),children:(0,j.formatUILabel)(N.selectMoreValues,{count:i})}):null,(0,t.jsx)("button",{...We,className:m("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",S[x].combobox,L?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:ae?(0,t.jsx)("span",{className:"sr-only",children:l.map(ze).join(", ")}):(0,t.jsx)("span",{className:"truncate text-gray-600 dark:text-gray-300",children:Be})})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:X,onClick:Fe,children:Ye}):null,_e]})]})}else{let e=m("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].trigger,Me[ie].trigger,!h.invalid&&L&&Me[ie].focus,h.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",!b&&!v&&"cursor-pointer",Te);Ne=(0,t.jsxs)("button",{...We,className:e,onClick:L?gt:void 0,children:[(0,t.jsxs)("span",{className:m("flex items-center gap-2 min-w-0 flex-1 truncate",!ae&&"text-gray-600 dark:text-gray-300"),children:[J?.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:J.icon}):null,(0,t.jsx)("span",{className:"truncate",children:ae&&J?J.label:Be})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("span",{role:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Fe,onMouseDown:X,children:Ye}):null,_e]})]})}return(0,t.jsxs)("div",{className:m("flex flex-col gap-1",ot),children:[G?(0,t.jsxs)("label",{id:ue,htmlFor:pe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[G,Oe?(0,t.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,h.hasDescription?(0,t.jsx)("p",{id:h.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ee}):null,Ne,h.message!==void 0?(0,t.jsx)("p",{id:h.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:h.message}):h.showHelper?(0,t.jsx)("p",{id:h.ids.helper,className:m("text-xs",h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:De}):null,ce?a?l.map(e=>(0,t.jsx)("input",{type:"hidden",name:ce,value:e},e)):(0,t.jsx)("input",{type:"hidden",name:ce,value:l[0]??""}):null,p&&P?(0,Xe.createPortal)((0,t.jsxs)("div",{ref:he,className:m("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",S[x].content,lt),"data-placement":P.placement,style:{top:P.top,left:P.left,width:P.width,position:"absolute",translate:P.placement==="top"?"0 -100%":void 0},onKeyDown:ht,children:[V?(0,t.jsx)("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:(0,t.jsx)("input",{ref:me,type:"text",role:"searchbox","aria-label":nt??N.selectSearch,"aria-controls":ge,"aria-activedescendant":Ue,className:m(S[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:at??N.selectSearchPlaceholder,value:z,onChange:mt})}):null,(0,t.jsxs)("div",{role:"listbox",id:ge,"aria-labelledby":G?ue:void 0,"aria-multiselectable":a||void 0,className:"overflow-y-auto",style:{maxHeight:de},children:[I.map((e,n)=>(0,t.jsx)(At,{option:e,isSelected:q.has(e.value),isHighlighted:n===g,isDisabled:u||ke.has(e.value),multiple:a,sizeKey:x,optionId:`${H}-option-${n}`,onClick:we,onMouseEnter:k,index:n,ref:i=>{be.current[n]=i}},e.value)),ve?(0,t.jsxs)("div",{ref:e=>{be.current[T]=e},id:`${H}-option-${T}`,role:"option","aria-selected":!1,"aria-disabled":u||void 0,"data-highlighted":T===g||void 0,className:Je(x,T===g,!1,u,a),onMouseDown:X,onClick:u?void 0:Y,onMouseEnter:u?void 0:()=>k(T),children:[(0,t.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Pt}),(0,t.jsx)("span",{className:"truncate",children:(0,j.formatUILabel)(N.selectCreateOption,{label:M})})]}):null]}),B===0?(0,t.jsx)("div",{className:m(S[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:it}):null]}),(0,Z.ownerDocumentOf)(y.current).body):null]})}0&&(module.exports={Select});
|
|
1
|
+
"use strict";"use client";var Se=Object.defineProperty;var kt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var Lt=(o,s)=>{for(var a in s)Se(o,a,{get:s[a],enumerable:!0})},Nt=(o,s,a,p)=>{if(s&&typeof s=="object"||typeof s=="function")for(let f of wt(s))!Ct.call(o,f)&&f!==a&&Se(o,f,{get:()=>s[f],enumerable:!(p=kt(s,f))||p.enumerable});return o};var It=o=>Nt(Se({},"__esModule",{value:!0}),o);var zt={};Lt(zt,{Select:()=>Ht});module.exports=It(zt);var r=require("react"),Xe=require("react-dom"),Ze=require("../../lib/aria-hide.cjs"),h=require("../../lib/cn.cjs"),Z=require("../../lib/owner-document.cjs"),j=require("../../lib/i18n.cjs"),Ge=require("../form/shared/field-error.cjs"),t=require("react/jsx-runtime"),St=[],se=[],X=o=>o.preventDefault(),Mt=(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ye=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Et=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Dt=(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[(0,t.jsx)("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),(0,t.jsx)("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Ot=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=(0,t.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=(0,t.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),S={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},Me={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},Tt="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Bt="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function Rt(o,s){if(!s)return o;let a=s.toLowerCase();return o.filter(p=>{if(p.label.toLowerCase().includes(a)||p.value.toLowerCase().includes(a))return!0;if(p.keywords){for(let f of p.keywords)if(f.toLowerCase().includes(a))return!0}return!1})}function Qe(o,s){if(o!==void 0)return Array.isArray(o)?s?new Set(o).size===o.length?o:Array.from(new Set(o)):o.slice(0,1):o===""?se:[o]}function Je(o,s,a,p,f){return(0,h.cn)(S[o].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",s&&!p&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",a&&!s&&!f&&"bg-gray-50 dark:bg-gray-700/50",p&&"opacity-50 cursor-not-allowed")}var At=(0,r.memo)((0,r.forwardRef)(function({option:s,isSelected:a,isHighlighted:p,isDisabled:f,multiple:A,sizeKey:U,optionId:oe,onClick:le,onMouseEnter:W,index:b},v){let d=()=>{f||le(s.value)},x=()=>{f||W(b)};return(0,t.jsxs)("div",{ref:v,id:oe,role:"option","aria-selected":a,"aria-disabled":f||void 0,"data-highlighted":p||void 0,className:Je(U,p,a,f,A),onMouseDown:X,onClick:d,onMouseEnter:x,children:[A?(0,t.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",a?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:a?Vt:null}):null,s.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:s.icon}):null,(0,t.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"truncate",children:s.label}),s.description?(0,t.jsx)("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:s.description}):null]}),a&&!A?(0,t.jsx)("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Ot}):null]})}));function Ht(o){let{options:s=St,multiple:a=!1,value:p,defaultValue:f,onValueChange:A,maxTagCount:U,creatable:oe=!1,searchable:le=!1,clearable:W=!1,disabled:b=!1,readOnly:v=!1,loading:d=!1,size:x="md",variant:ie="default",placeholder:et,label:G,description:Ee,helperText:De,error:tt,required:Oe=!1,noOptionsText:rt,clearLabel:Ve,searchLabel:nt,searchPlaceholder:at,labels:st,onSearchChange:Pe,name:ce,className:ot,triggerClassName:Te,contentClassName:lt,maxHeight:de=256}=o,w=a&&oe,V=le||w,N=(0,j.useUILabels)(st),Be=et??N.selectPlaceholder,it=rt??N.selectNoOptions,H=(0,r.useId)(),ue=`${H}-label`,pe=`${H}-trigger`,ge=`${H}-listbox`,m=(0,Ge.describeField)(pe,{description:Ee,helperText:De,error:tt}),y=(0,r.useRef)(null),fe=(0,r.useRef)(null),he=(0,r.useRef)(null),me=(0,r.useRef)(null),be=(0,r.useRef)([]),Re=p!==void 0,[ye,ct]=(0,r.useState)(()=>Qe(f,a)??se),Ae=(0,r.useMemo)(()=>Qe(p,a),[p,a]),l=(0,r.useMemo)(()=>Ae??(a?ye:ye.slice(0,1)),[Ae,ye,a]),[u,xe]=(0,r.useState)(!1),[z,F]=(0,r.useState)(""),[g,k]=(0,r.useState)(-1),[P,He]=(0,r.useState)(null),K=(0,r.useMemo)(()=>{let e=new Map;for(let n of s)e.has(n.value)||e.set(n.value,n);return e},[s]),$=(0,r.useMemo)(()=>{if(!w)return s;let e=[];for(let n of l)K.has(n)||e.push({value:n,label:n});return e.length>0?[...s,...e]:s},[w,s,l,K]),I=(0,r.useMemo)(()=>V?Rt($,z):$,[$,z,V]),M=z.trim(),_=(0,r.useMemo)(()=>{if(!w||M==="")return null;let e=M.toLowerCase();return $.find(n=>n.label.toLowerCase()===e)??null},[w,M,$]),ve=w&&M!==""&&_===null,T=ve?I.length:-1,B=I.length+(ve?1:0),q=(0,r.useMemo)(()=>new Set(l),[l]),J=(0,r.useMemo)(()=>a?null:K.get(l[0]??"")??null,[a,K,l]),ke=(0,r.useMemo)(()=>{let e=new Set;for(let n of s)n.disabled&&e.add(n.value);return e},[s]),ee=(0,r.useCallback)(e=>e<I.length&&ke.has(I[e].value),[I,ke]),ze=(0,r.useCallback)(e=>K.get(e)?.label??e,[K]),E=(0,r.useCallback)(e=>{Re||ct(e),A?.(a?e:e[0]??"")},[Re,A,a]),dt=(0,r.useCallback)(e=>{d||(E([e]),xe(!1),F(""),k(-1),y.current?.focus())},[E,d]),D=(0,r.useCallback)(e=>{d||E(e)},[E,d]),ut=(0,r.useCallback)(e=>{D(q.has(e)?l.filter(n=>n!==e):[...l,e])},[D,q,l]),pt=(0,r.useCallback)(e=>{D(l.filter(n=>n!==e))},[D,l]),te=(0,r.useCallback)(()=>{l.length!==0&&D(l.slice(0,-1))},[D,l]),Y=(0,r.useCallback)(()=>{if(!w||M===""||d||_?.disabled)return;let e=_?_.value:M;q.has(e)||D([...l,e]),F(""),k(-1)},[w,M,_,d,q,D,l]),we=a?ut:dt,Ce=(0,r.useCallback)(e=>{if(e===T){Y();return}e<0||e>=I.length||ee(e)||we(I[e].value)},[T,Y,I,ee,we]),Le=(0,r.useCallback)(()=>{((u&&V?me.current:null)??y.current)?.focus()},[u,V]),Fe=(0,r.useCallback)(e=>{e.stopPropagation(),E(se),F(""),Le()},[E,Le]),R=(0,r.useCallback)(()=>{b||v||(xe(!0),F(""),k(-1))},[b,v]),C=(0,r.useCallback)(()=>{xe(!1),F(""),k(-1),y.current?.focus()},[]),gt=(0,r.useCallback)(()=>{u?C():R()},[u,C,R]),Q=(0,r.useCallback)((e,n)=>{let i=B;if(i===0)return-1;let c=e;for(let O=0;O<i;O++)if(c=((c+n)%i+i)%i,!ee(c))return c;return-1},[B,ee]),re=(0,r.useCallback)((e,n)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let i=Q(g,1);i!==-1&&k(i);break}case"ArrowUp":{e.preventDefault();let i=Q(g,-1);i!==-1&&k(i);break}case"Home":{e.preventDefault();let i=Q(-1,1);i!==-1&&k(i);break}case"End":{e.preventDefault();let i=Q(B,-1);i!==-1&&k(i);break}case"Enter":{e.preventDefault(),g>=0&&g<B?Ce(g):w&&Y();break}case" ":if(n)break;e.preventDefault(),g>=0&&g<B?Ce(g):C();break;case"Backspace":a&&(!n||z==="")&&(n||e.preventDefault(),te());break;case"Escape":e.preventDefault(),C();break;case"Tab":C();break}},[Q,g,B,Ce,w,Y,C,a,z,te]),ft=(0,r.useCallback)(e=>{if(!(b||v)){if(u){re(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),R();break;case"Enter":case" ":e.preventDefault(),R();break;case"Backspace":case"Delete":a?e.key==="Backspace"&&l.length>0&&(e.preventDefault(),te()):W&&!d&&l.length>0&&(e.preventDefault(),E(se));break}}},[b,v,u,re,R,a,l.length,te,W,d,E]),ht=(0,r.useCallback)(e=>re(e,!0),[re]),mt=(0,r.useCallback)(e=>{let n=e.target.value;F(n),k(-1),Pe?.(n)},[Pe]),L=!b&&!v,bt=(0,r.useCallback)(e=>{L&&(y.current?.contains(e.target)||e.preventDefault())},[L]),yt=(0,r.useCallback)(()=>{L&&(u?C():(y.current?.focus(),R()))},[L,u,C,R]);(0,r.useEffect)(()=>{if(!u)return;let e=i=>{let c=i.target;y.current?.contains(c)||fe.current?.contains(c)||he.current?.contains(c)||C()},n=(0,Z.ownerDocumentOf)(y.current);return n.addEventListener("mousedown",e),n.addEventListener("touchstart",e,{passive:!0}),()=>{n.removeEventListener("mousedown",e),n.removeEventListener("touchstart",e)}},[u,C]);let xt=a?l.length:0;(0,r.useEffect)(()=>{if(!u||!y.current){He(null);return}let e=(0,Z.ownerWindowOf)(y.current),n=()=>{let i=a?fe.current:y.current;if(!i)return;let c=i.getBoundingClientRect(),O=e.innerHeight-c.bottom,Ie=c.top,vt=de+8,qe=O<vt&&Ie>O?"top":"bottom";He({top:qe==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:qe})};return n(),e.addEventListener("scroll",n,!0),e.addEventListener("resize",n),()=>{e.removeEventListener("scroll",n,!0),e.removeEventListener("resize",n)}},[u,de,a,xt]);let ne=u&&P!==null;(0,r.useEffect)(()=>{ne&&V&&me.current?.focus()},[ne,V]),(0,r.useEffect)(()=>{let e=he.current;if(!(!ne||!e))return(0,Ze.registerFloatingLayer)(e,()=>y.current)},[ne]),(0,r.useEffect)(()=>{if(g>=0){let e=be.current[g];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[g]);let ae=l.length>0,Ke=W&&ae&&!b&&!v&&!d,je=L&&!d,Ue=u&&g>=0?`${H}-option-${g}`:void 0,We={ref:y,id:pe,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?ge:void 0,"aria-labelledby":G?ue:void 0,"aria-required":Oe||void 0,"aria-invalid":m.invalid||void 0,"aria-describedby":m.describedBy,"aria-activedescendant":Ue,disabled:b,onKeyDown:ft},$e=d?(0,t.jsx)("span",{className:"text-gray-500 dark:text-gray-400",children:Dt}):null,_e=(0,t.jsx)("span",{className:(0,h.cn)("text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Mt}),Ne;if(a){let e=U===void 0||!Number.isFinite(U)?l.length:Math.max(0,Math.floor(U)),n=l.slice(0,e),i=l.length-n.length;Ne=(0,t.jsxs)("div",{ref:fe,className:(0,h.cn)("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].frame,Me[ie].trigger,!m.invalid&&L&&Tt,m.invalid&&Bt,v&&"cursor-default",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",L&&"cursor-pointer",Te),onMouseDown:bt,onClick:yt,children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[n.map(c=>{let O=ze(c);return(0,t.jsxs)("span",{className:(0,h.cn)("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",S[x].tag,!je&&"pr-2"),children:[(0,t.jsx)("span",{className:"min-w-0 truncate","aria-hidden":"true",children:O}),je?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":(0,j.formatUILabel)(N.selectRemoveValue,{label:O}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:X,onClick:Ie=>{Ie.stopPropagation(),pt(c),Le()},children:Et}):null]},c)}),i>0?(0,t.jsx)("span",{"aria-hidden":"true",className:(0,h.cn)("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",S[x].tag,"pr-2"),children:(0,j.formatUILabel)(N.selectMoreValues,{count:i})}):null,(0,t.jsx)("button",{...We,className:(0,h.cn)("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",S[x].combobox,L?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:ae?(0,t.jsx)("span",{className:"sr-only",children:l.map(ze).join(", ")}):(0,t.jsx)("span",{className:"truncate text-gray-600 dark:text-gray-300",children:Be})})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("button",{type:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:X,onClick:Fe,children:Ye}):null,_e]})]})}else{let e=(0,h.cn)("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",S[x].trigger,Me[ie].trigger,!m.invalid&&L&&Me[ie].focus,m.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",v&&"cursor-default",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",!b&&!v&&"cursor-pointer",Te);Ne=(0,t.jsxs)("button",{...We,className:e,onClick:L?gt:void 0,children:[(0,t.jsxs)("span",{className:(0,h.cn)("flex items-center gap-2 min-w-0 flex-1 truncate",!ae&&"text-gray-600 dark:text-gray-300"),children:[J?.icon?(0,t.jsx)("span",{className:"flex shrink-0 items-center",children:J.icon}):null,(0,t.jsx)("span",{className:"truncate",children:ae&&J?J.label:Be})]}),(0,t.jsxs)("span",{className:"flex items-center gap-1 shrink-0",children:[$e,Ke?(0,t.jsx)("span",{role:"button",tabIndex:-1,"aria-label":Ve??N.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Fe,onMouseDown:X,children:Ye}):null,_e]})]})}return(0,t.jsxs)("div",{className:(0,h.cn)("flex flex-col gap-1",ot),children:[G?(0,t.jsxs)("label",{id:ue,htmlFor:pe,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[G,Oe?(0,t.jsx)("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,m.hasDescription?(0,t.jsx)("p",{id:m.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ee}):null,Ne,m.message!==void 0?(0,t.jsx)("p",{id:m.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:m.message}):m.showHelper?(0,t.jsx)("p",{id:m.ids.helper,className:(0,h.cn)("text-xs",m.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:De}):null,ce?a?l.map(e=>(0,t.jsx)("input",{type:"hidden",name:ce,value:e},e)):(0,t.jsx)("input",{type:"hidden",name:ce,value:l[0]??""}):null,u&&P?(0,Xe.createPortal)((0,t.jsxs)("div",{ref:he,className:(0,h.cn)("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",S[x].content,lt),"data-placement":P.placement,style:{top:P.top,left:P.left,width:P.width,position:"absolute",translate:P.placement==="top"?"0 -100%":void 0},onKeyDown:ht,children:[V?(0,t.jsx)("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:(0,t.jsx)("input",{ref:me,type:"text",role:"searchbox","aria-label":nt??N.selectSearch,"aria-controls":ge,"aria-activedescendant":Ue,className:(0,h.cn)(S[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:at??N.selectSearchPlaceholder,value:z,onChange:mt})}):null,(0,t.jsxs)("div",{role:"listbox",id:ge,"aria-labelledby":G?ue:void 0,"aria-multiselectable":a||void 0,className:"overflow-y-auto",style:{maxHeight:de},children:[I.map((e,n)=>(0,t.jsx)(At,{option:e,isSelected:q.has(e.value),isHighlighted:n===g,isDisabled:d||ke.has(e.value),multiple:a,sizeKey:x,optionId:`${H}-option-${n}`,onClick:we,onMouseEnter:k,index:n,ref:i=>{be.current[n]=i}},e.value)),ve?(0,t.jsxs)("div",{ref:e=>{be.current[T]=e},id:`${H}-option-${T}`,role:"option","aria-selected":!1,"aria-disabled":d||void 0,"data-highlighted":T===g||void 0,className:Je(x,T===g,!1,d,a),onMouseDown:X,onClick:d?void 0:Y,onMouseEnter:d?void 0:()=>k(T),children:[(0,t.jsx)("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Pt}),(0,t.jsx)("span",{className:"truncate",children:(0,j.formatUILabel)(N.selectCreateOption,{label:M})})]}):null]}),B===0?(0,t.jsx)("div",{className:(0,h.cn)(S[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:it}):null]}),(0,Z.ownerDocumentOf)(y.current).body):null]})}0&&(module.exports={Select});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useState as Z,useRef as G,useEffect as J,useCallback as i,useMemo as M,useId as wt,memo as Ct,forwardRef as Lt}from"react";import{createPortal as Nt}from"react-dom";import{registerFloatingLayer as It}from"../../lib/aria-hide.js";import{ownerDocumentOf as Ze,ownerWindowOf as St}from"../../lib/owner-document.js";import{formatUILabel as De,useUILabels as Mt}from"../../lib/i18n.js";import{describeField as Et}from"../form/shared/field-error.js";import{jsx as r,jsxs as f}from"react/jsx-runtime";var Dt=[],ie=[],ee=l=>l.preventDefault(),Ot=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ge=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=f("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Tt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Bt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Rt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),E={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},Oe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},At="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Ht="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function m(...l){let a="";for(let n=0;n<l.length;n++){let p=l[n];p&&(a&&(a+=" "),a+=p)}return a}function zt(l,a){if(!a)return l;let n=a.toLowerCase();return l.filter(p=>{if(p.label.toLowerCase().includes(n)||p.value.toLowerCase().includes(n))return!0;if(p.keywords){for(let w of p.keywords)if(w.toLowerCase().includes(n))return!0}return!1})}function Je(l,a){if(l!==void 0)return Array.isArray(l)?a?new Set(l).size===l.length?l:Array.from(new Set(l)):l.slice(0,1):l===""?ie:[l]}function et(l,a,n,p,w){return m(E[l].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",a&&!p&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",n&&!a&&!w&&"bg-gray-50 dark:bg-gray-700/50",p&&"opacity-50 cursor-not-allowed")}var Ft=Ct(Lt(function({option:a,isSelected:n,isHighlighted:p,isDisabled:w,multiple:z,sizeKey:W,optionId:ce,onClick:de,onMouseEnter:$,index:b},v){let d=()=>{w||de(a.value)},x=()=>{w||$(b)};return f("div",{ref:v,id:ce,role:"option","aria-selected":n,"aria-disabled":w||void 0,"data-highlighted":p||void 0,className:et(W,p,n,w,z),onMouseDown:ee,onClick:d,onMouseEnter:x,children:[z?r("span",{"aria-hidden":"true",className:m("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",n?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:n?Bt:null}):null,a.icon?r("span",{className:"flex shrink-0 items-center",children:a.icon}):null,f("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:a.label}),a.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:a.description}):null]}),n&&!z?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Tt}):null]})}));function qt(l){let{options:a=Dt,multiple:n=!1,value:p,defaultValue:w,onValueChange:z,maxTagCount:W,creatable:ce=!1,searchable:de=!1,clearable:$=!1,disabled:b=!1,readOnly:v=!1,loading:d=!1,size:x="md",variant:ue="default",placeholder:tt,label:te,description:Ve,helperText:Pe,error:rt,required:Te=!1,noOptionsText:nt,clearLabel:Be,searchLabel:at,searchPlaceholder:st,labels:ot,onSearchChange:Re,name:pe,className:lt,triggerClassName:Ae,contentClassName:it,maxHeight:ge=256}=l,C=n&&ce,T=de||C,I=Mt(ot),He=tt??I.selectPlaceholder,ct=nt??I.selectNoOptions,F=wt(),fe=`${F}-label`,he=`${F}-trigger`,me=`${F}-listbox`,h=Et(he,{description:Ve,helperText:Pe,error:rt}),y=G(null),be=G(null),ye=G(null),xe=G(null),ve=G([]),ze=p!==void 0,[ke,dt]=Z(()=>Je(w,n)??ie),Fe=M(()=>Je(p,n),[p,n]),s=M(()=>Fe??(n?ke:ke.slice(0,1)),[Fe,ke,n]),[u,we]=Z(!1),[K,j]=Z(""),[g,k]=Z(-1),[B,Ke]=Z(null),U=M(()=>{let e=new Map;for(let t of a)e.has(t.value)||e.set(t.value,t);return e},[a]),_=M(()=>{if(!C)return a;let e=[];for(let t of s)U.has(t)||e.push({value:t,label:t});return e.length>0?[...a,...e]:a},[C,a,s,U]),S=M(()=>T?zt(_,K):_,[_,K,T]),D=K.trim(),q=M(()=>{if(!C||D==="")return null;let e=D.toLowerCase();return _.find(t=>t.label.toLowerCase()===e)??null},[C,D,_]),Ce=C&&D!==""&&q===null,R=Ce?S.length:-1,A=S.length+(Ce?1:0),Y=M(()=>new Set(s),[s]),re=M(()=>n?null:U.get(s[0]??"")??null,[n,U,s]),Le=M(()=>{let e=new Set;for(let t of a)t.disabled&&e.add(t.value);return e},[a]),ne=i(e=>e<S.length&&Le.has(S[e].value),[S,Le]),je=i(e=>U.get(e)?.label??e,[U]),O=i(e=>{ze||dt(e),z?.(n?e:e[0]??"")},[ze,z,n]),ut=i(e=>{d||(O([e]),we(!1),j(""),k(-1),y.current?.focus())},[O,d]),V=i(e=>{d||O(e)},[O,d]),pt=i(e=>{V(Y.has(e)?s.filter(t=>t!==e):[...s,e])},[V,Y,s]),gt=i(e=>{V(s.filter(t=>t!==e))},[V,s]),ae=i(()=>{s.length!==0&&V(s.slice(0,-1))},[V,s]),Q=i(()=>{if(!C||D===""||d||q?.disabled)return;let e=q?q.value:D;Y.has(e)||V([...s,e]),j(""),k(-1)},[C,D,q,d,Y,V,s]),Ne=n?pt:ut,Ie=i(e=>{if(e===R){Q();return}e<0||e>=S.length||ne(e)||Ne(S[e].value)},[R,Q,S,ne,Ne]),Se=i(()=>{((u&&T?xe.current:null)??y.current)?.focus()},[u,T]),Ue=i(e=>{e.stopPropagation(),O(ie),j(""),Se()},[O,Se]),H=i(()=>{b||v||(we(!0),j(""),k(-1))},[b,v]),L=i(()=>{we(!1),j(""),k(-1),y.current?.focus()},[]),ft=i(()=>{u?L():H()},[u,L,H]),X=i((e,t)=>{let o=A;if(o===0)return-1;let c=e;for(let P=0;P<o;P++)if(c=((c+t)%o+o)%o,!ne(c))return c;return-1},[A,ne]),se=i((e,t)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let o=X(g,1);o!==-1&&k(o);break}case"ArrowUp":{e.preventDefault();let o=X(g,-1);o!==-1&&k(o);break}case"Home":{e.preventDefault();let o=X(-1,1);o!==-1&&k(o);break}case"End":{e.preventDefault();let o=X(A,-1);o!==-1&&k(o);break}case"Enter":{e.preventDefault(),g>=0&&g<A?Ie(g):C&&Q();break}case" ":if(t)break;e.preventDefault(),g>=0&&g<A?Ie(g):L();break;case"Backspace":n&&(!t||K==="")&&(t||e.preventDefault(),ae());break;case"Escape":e.preventDefault(),L();break;case"Tab":L();break}},[X,g,A,Ie,C,Q,L,n,K,ae]),ht=i(e=>{if(!(b||v)){if(u){se(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),H();break;case"Enter":case" ":e.preventDefault(),H();break;case"Backspace":case"Delete":n?e.key==="Backspace"&&s.length>0&&(e.preventDefault(),ae()):$&&!d&&s.length>0&&(e.preventDefault(),O(ie));break}}},[b,v,u,se,H,n,s.length,ae,$,d,O]),mt=i(e=>se(e,!0),[se]),bt=i(e=>{let t=e.target.value;j(t),k(-1),Re?.(t)},[Re]),N=!b&&!v,yt=i(e=>{N&&(y.current?.contains(e.target)||e.preventDefault())},[N]),xt=i(()=>{N&&(u?L():(y.current?.focus(),H()))},[N,u,L,H]);J(()=>{if(!u)return;let e=o=>{let c=o.target;y.current?.contains(c)||be.current?.contains(c)||ye.current?.contains(c)||L()},t=Ze(y.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[u,L]);let vt=n?s.length:0;J(()=>{if(!u||!y.current){Ke(null);return}let e=St(y.current),t=()=>{let o=n?be.current:y.current;if(!o)return;let c=o.getBoundingClientRect(),P=e.innerHeight-c.bottom,Ee=c.top,kt=ge+8,Xe=P<kt&&Ee>P?"top":"bottom";Ke({top:Xe==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:Xe})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[u,ge,n,vt]);let oe=u&&B!==null;J(()=>{oe&&T&&xe.current?.focus()},[oe,T]),J(()=>{let e=ye.current;if(!(!oe||!e))return It(e,()=>y.current)},[oe]),J(()=>{if(g>=0){let e=ve.current[g];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[g]);let le=s.length>0,We=$&&le&&!b&&!v&&!d,$e=N&&!d,_e=u&&g>=0?`${F}-option-${g}`:void 0,qe={ref:y,id:he,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?me:void 0,"aria-labelledby":te?fe:void 0,"aria-required":Te||void 0,"aria-invalid":h.invalid||void 0,"aria-describedby":h.describedBy,"aria-activedescendant":_e,disabled:b,onKeyDown:ht},Ye=d?r("span",{className:"text-gray-500 dark:text-gray-400",children:Pt}):null,Qe=r("span",{className:m("text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Ot}),Me;if(n){let e=W===void 0||!Number.isFinite(W)?s.length:Math.max(0,Math.floor(W)),t=s.slice(0,e),o=s.length-t.length;Me=f("div",{ref:be,className:m("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].frame,Oe[ue].trigger,!h.invalid&&N&&At,h.invalid&&Ht,b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",N&&"cursor-pointer",Ae),onMouseDown:yt,onClick:xt,children:[f("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[t.map(c=>{let P=je(c);return f("span",{className:m("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",E[x].tag,!$e&&"pr-2"),children:[r("span",{className:"min-w-0 truncate","aria-hidden":"true",children:P}),$e?r("button",{type:"button",tabIndex:-1,"aria-label":De(I.selectRemoveValue,{label:P}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:ee,onClick:Ee=>{Ee.stopPropagation(),gt(c),Se()},children:Vt}):null]},c)}),o>0?r("span",{"aria-hidden":"true",className:m("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",E[x].tag,"pr-2"),children:De(I.selectMoreValues,{count:o})}):null,r("button",{...qe,className:m("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",E[x].combobox,N?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:le?r("span",{className:"sr-only",children:s.map(je).join(", ")}):r("span",{className:"truncate text-gray-600 dark:text-gray-300",children:He})})]}),f("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("button",{type:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:ee,onClick:Ue,children:Ge}):null,Qe]})]})}else{let e=m("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].trigger,Oe[ue].trigger,!h.invalid&&N&&Oe[ue].focus,h.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",v&&"cursor-default",!b&&!v&&"cursor-pointer",Ae);Me=f("button",{...qe,className:e,onClick:N?ft:void 0,children:[f("span",{className:m("flex items-center gap-2 min-w-0 flex-1 truncate",!le&&"text-gray-600 dark:text-gray-300"),children:[re?.icon?r("span",{className:"flex shrink-0 items-center",children:re.icon}):null,r("span",{className:"truncate",children:le&&re?re.label:He})]}),f("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("span",{role:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ue,onMouseDown:ee,children:Ge}):null,Qe]})]})}return f("div",{className:m("flex flex-col gap-1",lt),children:[te?f("label",{id:fe,htmlFor:he,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[te,Te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,h.hasDescription?r("p",{id:h.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ve}):null,Me,h.message!==void 0?r("p",{id:h.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:h.message}):h.showHelper?r("p",{id:h.ids.helper,className:m("text-xs",h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:Pe}):null,pe?n?s.map(e=>r("input",{type:"hidden",name:pe,value:e},e)):r("input",{type:"hidden",name:pe,value:s[0]??""}):null,u&&B?Nt(f("div",{ref:ye,className:m("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",E[x].content,it),"data-placement":B.placement,style:{top:B.top,left:B.left,width:B.width,position:"absolute",translate:B.placement==="top"?"0 -100%":void 0},onKeyDown:mt,children:[T?r("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:r("input",{ref:xe,type:"text",role:"searchbox","aria-label":at??I.selectSearch,"aria-controls":me,"aria-activedescendant":_e,className:m(E[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:st??I.selectSearchPlaceholder,value:K,onChange:bt})}):null,f("div",{role:"listbox",id:me,"aria-labelledby":te?fe:void 0,"aria-multiselectable":n||void 0,className:"overflow-y-auto",style:{maxHeight:ge},children:[S.map((e,t)=>r(Ft,{option:e,isSelected:Y.has(e.value),isHighlighted:t===g,isDisabled:d||Le.has(e.value),multiple:n,sizeKey:x,optionId:`${F}-option-${t}`,onClick:Ne,onMouseEnter:k,index:t,ref:o=>{ve.current[t]=o}},e.value)),Ce?f("div",{ref:e=>{ve.current[R]=e},id:`${F}-option-${R}`,role:"option","aria-selected":!1,"aria-disabled":d||void 0,"data-highlighted":R===g||void 0,className:et(x,R===g,!1,d,n),onMouseDown:ee,onClick:d?void 0:Q,onMouseEnter:d?void 0:()=>k(R),children:[r("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Rt}),r("span",{className:"truncate",children:De(I.selectCreateOption,{label:D})})]}):null]}),A===0?r("div",{className:m(E[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ct}):null]}),Ze(y.current).body):null]})}export{qt as Select};
|
|
1
|
+
"use client";import{useState as Z,useRef as G,useEffect as J,useCallback as l,useMemo as M,useId as wt,memo as Ct,forwardRef as Lt}from"react";import{createPortal as Nt}from"react-dom";import{registerFloatingLayer as It}from"../../lib/aria-hide.js";import{cn as m}from"../../lib/cn.js";import{ownerDocumentOf as Ze,ownerWindowOf as St}from"../../lib/owner-document.js";import{formatUILabel as De,useUILabels as Mt}from"../../lib/i18n.js";import{describeField as Et}from"../form/shared/field-error.js";import{jsx as r,jsxs as g}from"react/jsx-runtime";var Dt=[],ie=[],ee=i=>i.preventDefault(),Ot=r("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Ge=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Vt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M10.5 3.5L3.5 10.5M3.5 3.5L10.5 10.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),Pt=g("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",className:"shrink-0 animate-spin",children:[r("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor",strokeWidth:"2",strokeOpacity:"0.25"}),r("path",{d:"M14 8a6 6 0 00-6-6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Tt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",className:"shrink-0",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),Bt=r("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M11.5 3.5L5.5 10.5L2.5 7.5",stroke:"currentColor",strokeWidth:"2.25",strokeLinecap:"round",strokeLinejoin:"round"})}),Rt=r("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:r("path",{d:"M7 2.5V11.5M2.5 7H11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),E={sm:{trigger:"h-8 px-2.5 text-xs gap-1.5",content:"text-xs",option:"px-2.5 py-1.5",searchInput:"px-2.5 py-1.5 text-xs",frame:"min-h-8 pl-1 pr-2.5 py-1 text-xs gap-1.5",tag:"h-5 pl-1.5 pr-0.5 gap-0.5 text-xs",combobox:"h-5 px-1"},md:{trigger:"h-10 px-3 text-sm gap-2",content:"text-sm",option:"px-3 py-2",searchInput:"px-3 py-2 text-sm",frame:"min-h-10 pl-1.5 pr-3 py-1.5 text-sm gap-2",tag:"h-6 pl-2 pr-1 gap-1 text-xs",combobox:"h-6 px-1.5"},lg:{trigger:"h-12 px-4 text-base gap-2.5",content:"text-base",option:"px-4 py-2.5",searchInput:"px-4 py-2.5 text-base",frame:"min-h-12 pl-2 pr-4 py-2 text-base gap-2.5",tag:"h-7 pl-2.5 pr-1 gap-1 text-sm",combobox:"h-7 px-2"}},Oe={default:{trigger:"border border-gray-300 bg-white dark:border-gray-600 dark:bg-gray-800",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},outlined:{trigger:"border-2 border-gray-300 bg-transparent dark:border-gray-600",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"},filled:{trigger:"border border-transparent bg-gray-100 dark:bg-gray-700",focus:"focus:ring-2 focus:ring-synertech-primary-500 focus:border-synertech-primary-500"}},At="focus-within:ring-2 focus-within:ring-synertech-primary-500 focus-within:border-synertech-primary-500",Ht="border-red-500 dark:border-red-400 focus-within:ring-2 focus-within:ring-red-500 focus-within:border-red-500";function zt(i,o){if(!o)return i;let n=o.toLowerCase();return i.filter(f=>{if(f.label.toLowerCase().includes(n)||f.value.toLowerCase().includes(n))return!0;if(f.keywords){for(let w of f.keywords)if(w.toLowerCase().includes(n))return!0}return!1})}function Je(i,o){if(i!==void 0)return Array.isArray(i)?o?new Set(i).size===i.length?i:Array.from(new Set(i)):i.slice(0,1):i===""?ie:[i]}function et(i,o,n,f,w){return m(E[i].option,"flex items-center gap-2 cursor-pointer select-none transition-colors",o&&!f&&"bg-synertech-primary-50 dark:bg-synertech-primary-900/30",n&&!o&&!w&&"bg-gray-50 dark:bg-gray-700/50",f&&"opacity-50 cursor-not-allowed")}var Ft=Ct(Lt(function({option:o,isSelected:n,isHighlighted:f,isDisabled:w,multiple:z,sizeKey:W,optionId:ce,onClick:de,onMouseEnter:$,index:b},v){let d=()=>{w||de(o.value)},x=()=>{w||$(b)};return g("div",{ref:v,id:ce,role:"option","aria-selected":n,"aria-disabled":w||void 0,"data-highlighted":f||void 0,className:et(W,f,n,w,z),onMouseDown:ee,onClick:d,onMouseEnter:x,children:[z?r("span",{"aria-hidden":"true",className:m("flex size-4 shrink-0 items-center justify-center rounded border-2 transition-colors",n?"border-synertech-primary-600 bg-synertech-primary-600 text-synertech-on-primary":"border-gray-500 dark:border-gray-400"),children:n?Bt:null}):null,o.icon?r("span",{className:"flex shrink-0 items-center",children:o.icon}):null,g("span",{className:"flex flex-col min-w-0 flex-1",children:[r("span",{className:"truncate",children:o.label}),o.description?r("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.description}):null]}),n&&!z?r("span",{className:"ml-auto text-synertech-primary-600 dark:text-synertech-primary-400",children:Tt}):null]})}));function Yt(i){let{options:o=Dt,multiple:n=!1,value:f,defaultValue:w,onValueChange:z,maxTagCount:W,creatable:ce=!1,searchable:de=!1,clearable:$=!1,disabled:b=!1,readOnly:v=!1,loading:d=!1,size:x="md",variant:ue="default",placeholder:tt,label:te,description:Ve,helperText:Pe,error:rt,required:Te=!1,noOptionsText:nt,clearLabel:Be,searchLabel:at,searchPlaceholder:st,labels:ot,onSearchChange:Re,name:pe,className:lt,triggerClassName:Ae,contentClassName:it,maxHeight:ge=256}=i,C=n&&ce,T=de||C,I=Mt(ot),He=tt??I.selectPlaceholder,ct=nt??I.selectNoOptions,F=wt(),fe=`${F}-label`,he=`${F}-trigger`,me=`${F}-listbox`,h=Et(he,{description:Ve,helperText:Pe,error:rt}),y=G(null),be=G(null),ye=G(null),xe=G(null),ve=G([]),ze=f!==void 0,[ke,dt]=Z(()=>Je(w,n)??ie),Fe=M(()=>Je(f,n),[f,n]),a=M(()=>Fe??(n?ke:ke.slice(0,1)),[Fe,ke,n]),[u,we]=Z(!1),[K,j]=Z(""),[p,k]=Z(-1),[B,Ke]=Z(null),U=M(()=>{let e=new Map;for(let t of o)e.has(t.value)||e.set(t.value,t);return e},[o]),_=M(()=>{if(!C)return o;let e=[];for(let t of a)U.has(t)||e.push({value:t,label:t});return e.length>0?[...o,...e]:o},[C,o,a,U]),S=M(()=>T?zt(_,K):_,[_,K,T]),D=K.trim(),q=M(()=>{if(!C||D==="")return null;let e=D.toLowerCase();return _.find(t=>t.label.toLowerCase()===e)??null},[C,D,_]),Ce=C&&D!==""&&q===null,R=Ce?S.length:-1,A=S.length+(Ce?1:0),Y=M(()=>new Set(a),[a]),re=M(()=>n?null:U.get(a[0]??"")??null,[n,U,a]),Le=M(()=>{let e=new Set;for(let t of o)t.disabled&&e.add(t.value);return e},[o]),ne=l(e=>e<S.length&&Le.has(S[e].value),[S,Le]),je=l(e=>U.get(e)?.label??e,[U]),O=l(e=>{ze||dt(e),z?.(n?e:e[0]??"")},[ze,z,n]),ut=l(e=>{d||(O([e]),we(!1),j(""),k(-1),y.current?.focus())},[O,d]),V=l(e=>{d||O(e)},[O,d]),pt=l(e=>{V(Y.has(e)?a.filter(t=>t!==e):[...a,e])},[V,Y,a]),gt=l(e=>{V(a.filter(t=>t!==e))},[V,a]),ae=l(()=>{a.length!==0&&V(a.slice(0,-1))},[V,a]),Q=l(()=>{if(!C||D===""||d||q?.disabled)return;let e=q?q.value:D;Y.has(e)||V([...a,e]),j(""),k(-1)},[C,D,q,d,Y,V,a]),Ne=n?pt:ut,Ie=l(e=>{if(e===R){Q();return}e<0||e>=S.length||ne(e)||Ne(S[e].value)},[R,Q,S,ne,Ne]),Se=l(()=>{((u&&T?xe.current:null)??y.current)?.focus()},[u,T]),Ue=l(e=>{e.stopPropagation(),O(ie),j(""),Se()},[O,Se]),H=l(()=>{b||v||(we(!0),j(""),k(-1))},[b,v]),L=l(()=>{we(!1),j(""),k(-1),y.current?.focus()},[]),ft=l(()=>{u?L():H()},[u,L,H]),X=l((e,t)=>{let s=A;if(s===0)return-1;let c=e;for(let P=0;P<s;P++)if(c=((c+t)%s+s)%s,!ne(c))return c;return-1},[A,ne]),se=l((e,t)=>{switch(e.key){case"ArrowDown":{e.preventDefault();let s=X(p,1);s!==-1&&k(s);break}case"ArrowUp":{e.preventDefault();let s=X(p,-1);s!==-1&&k(s);break}case"Home":{e.preventDefault();let s=X(-1,1);s!==-1&&k(s);break}case"End":{e.preventDefault();let s=X(A,-1);s!==-1&&k(s);break}case"Enter":{e.preventDefault(),p>=0&&p<A?Ie(p):C&&Q();break}case" ":if(t)break;e.preventDefault(),p>=0&&p<A?Ie(p):L();break;case"Backspace":n&&(!t||K==="")&&(t||e.preventDefault(),ae());break;case"Escape":e.preventDefault(),L();break;case"Tab":L();break}},[X,p,A,Ie,C,Q,L,n,K,ae]),ht=l(e=>{if(!(b||v)){if(u){se(e,!1);return}switch(e.key){case"ArrowDown":case"ArrowUp":e.preventDefault(),H();break;case"Enter":case" ":e.preventDefault(),H();break;case"Backspace":case"Delete":n?e.key==="Backspace"&&a.length>0&&(e.preventDefault(),ae()):$&&!d&&a.length>0&&(e.preventDefault(),O(ie));break}}},[b,v,u,se,H,n,a.length,ae,$,d,O]),mt=l(e=>se(e,!0),[se]),bt=l(e=>{let t=e.target.value;j(t),k(-1),Re?.(t)},[Re]),N=!b&&!v,yt=l(e=>{N&&(y.current?.contains(e.target)||e.preventDefault())},[N]),xt=l(()=>{N&&(u?L():(y.current?.focus(),H()))},[N,u,L,H]);J(()=>{if(!u)return;let e=s=>{let c=s.target;y.current?.contains(c)||be.current?.contains(c)||ye.current?.contains(c)||L()},t=Ze(y.current);return t.addEventListener("mousedown",e),t.addEventListener("touchstart",e,{passive:!0}),()=>{t.removeEventListener("mousedown",e),t.removeEventListener("touchstart",e)}},[u,L]);let vt=n?a.length:0;J(()=>{if(!u||!y.current){Ke(null);return}let e=St(y.current),t=()=>{let s=n?be.current:y.current;if(!s)return;let c=s.getBoundingClientRect(),P=e.innerHeight-c.bottom,Ee=c.top,kt=ge+8,Xe=P<kt&&Ee>P?"top":"bottom";Ke({top:Xe==="bottom"?c.bottom+e.scrollY+4:c.top+e.scrollY-4,left:c.left+e.scrollX,width:c.width,placement:Xe})};return t(),e.addEventListener("scroll",t,!0),e.addEventListener("resize",t),()=>{e.removeEventListener("scroll",t,!0),e.removeEventListener("resize",t)}},[u,ge,n,vt]);let oe=u&&B!==null;J(()=>{oe&&T&&xe.current?.focus()},[oe,T]),J(()=>{let e=ye.current;if(!(!oe||!e))return It(e,()=>y.current)},[oe]),J(()=>{if(p>=0){let e=ve.current[p];e&&typeof e.scrollIntoView=="function"&&e.scrollIntoView({block:"nearest"})}},[p]);let le=a.length>0,We=$&&le&&!b&&!v&&!d,$e=N&&!d,_e=u&&p>=0?`${F}-option-${p}`:void 0,qe={ref:y,id:he,type:"button",role:"combobox","aria-expanded":u,"aria-haspopup":"listbox","aria-controls":u?me:void 0,"aria-labelledby":te?fe:void 0,"aria-required":Te||void 0,"aria-invalid":h.invalid||void 0,"aria-describedby":h.describedBy,"aria-activedescendant":_e,disabled:b,onKeyDown:ht},Ye=d?r("span",{className:"text-gray-500 dark:text-gray-400",children:Pt}):null,Qe=r("span",{className:m("text-gray-500 dark:text-gray-400 transition-transform duration-200",u&&"rotate-180"),children:Ot}),Me;if(n){let e=W===void 0||!Number.isFinite(W)?a.length:Math.max(0,Math.floor(W)),t=a.slice(0,e),s=a.length-t.length;Me=g("div",{ref:be,className:m("w-full flex items-center rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].frame,Oe[ue].trigger,!h.invalid&&N&&At,h.invalid&&Ht,v&&"cursor-default",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",N&&"cursor-pointer",Ae),onMouseDown:yt,onClick:xt,children:[g("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-1",children:[t.map(c=>{let P=je(c);return g("span",{className:m("inline-flex max-w-full items-center rounded","bg-synertech-primary-100 text-synertech-primary-700 dark:bg-synertech-primary-900/50 dark:text-synertech-primary-300",E[x].tag,!$e&&"pr-2"),children:[r("span",{className:"min-w-0 truncate","aria-hidden":"true",children:P}),$e?r("button",{type:"button",tabIndex:-1,"aria-label":De(I.selectRemoveValue,{label:P}),className:"flex shrink-0 items-center justify-center rounded-sm p-0.5 hover:bg-synertech-primary-200 dark:hover:bg-synertech-primary-800",onMouseDown:ee,onClick:Ee=>{Ee.stopPropagation(),gt(c),Se()},children:Vt}):null]},c)}),s>0?r("span",{"aria-hidden":"true",className:m("inline-flex items-center rounded bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-200",E[x].tag,"pr-2"),children:De(I.selectMoreValues,{count:s})}):null,r("button",{...qe,className:m("min-w-8 flex-1 text-left outline-hidden","flex items-center bg-transparent",E[x].combobox,N?"cursor-pointer":b?"cursor-not-allowed":"cursor-default"),children:le?r("span",{className:"sr-only",children:a.map(je).join(", ")}):r("span",{className:"truncate text-gray-600 dark:text-gray-300",children:He})})]}),g("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("button",{type:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onMouseDown:ee,onClick:Ue,children:Ge}):null,Qe]})]})}else{let e=m("w-full flex items-center justify-between rounded-md transition-colors","text-gray-900 dark:text-gray-100",E[x].trigger,Oe[ue].trigger,!h.invalid&&N&&Oe[ue].focus,h.invalid&&"border-red-500 dark:border-red-400 focus:ring-2 focus:ring-red-500 focus:border-red-500",v&&"cursor-default",b&&"opacity-50 cursor-not-allowed bg-gray-50 dark:bg-gray-900",!b&&!v&&"cursor-pointer",Ae);Me=g("button",{...qe,className:e,onClick:N?ft:void 0,children:[g("span",{className:m("flex items-center gap-2 min-w-0 flex-1 truncate",!le&&"text-gray-600 dark:text-gray-300"),children:[re?.icon?r("span",{className:"flex shrink-0 items-center",children:re.icon}):null,r("span",{className:"truncate",children:le&&re?re.label:He})]}),g("span",{className:"flex items-center gap-1 shrink-0",children:[Ye,We?r("span",{role:"button",tabIndex:-1,"aria-label":Be??I.selectClear,className:"text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 p-0.5 rounded transition-colors",onClick:Ue,onMouseDown:ee,children:Ge}):null,Qe]})]})}return g("div",{className:m("flex flex-col gap-1",lt),children:[te?g("label",{id:fe,htmlFor:he,className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[te,Te?r("span",{className:"text-red-600 dark:text-red-400 ml-0.5","aria-hidden":"true",children:"*"}):null]}):null,h.hasDescription?r("p",{id:h.ids.description,className:"text-xs text-gray-500 dark:text-gray-400",children:Ve}):null,Me,h.message!==void 0?r("p",{id:h.ids.error,className:"text-xs text-red-600 dark:text-red-400",children:h.message}):h.showHelper?r("p",{id:h.ids.helper,className:m("text-xs",h.invalid?"text-red-600 dark:text-red-400":"text-gray-500 dark:text-gray-400"),children:Pe}):null,pe?n?a.map(e=>r("input",{type:"hidden",name:pe,value:e},e)):r("input",{type:"hidden",name:pe,value:a[0]??""}):null,u&&B?Nt(g("div",{ref:ye,className:m("fixed z-50 bg-white text-gray-900 dark:bg-gray-800 dark:text-gray-100 border border-gray-200 dark:border-gray-700","rounded-md shadow-lg overflow-hidden","animate-in fade-in-0 zoom-in-95",E[x].content,it),"data-placement":B.placement,style:{top:B.top,left:B.left,width:B.width,position:"absolute",translate:B.placement==="top"?"0 -100%":void 0},onKeyDown:mt,children:[T?r("div",{className:"border-b-2 border-gray-200 focus-within:border-synertech-primary-500 dark:border-gray-700 dark:focus-within:border-synertech-primary-400",children:r("input",{ref:xe,type:"text",role:"searchbox","aria-label":at??I.selectSearch,"aria-controls":me,"aria-activedescendant":_e,className:m(E[x].searchInput,"w-full outline-hidden bg-transparent text-gray-900 dark:text-gray-100","placeholder:text-gray-500 dark:placeholder:text-gray-400"),placeholder:st??I.selectSearchPlaceholder,value:K,onChange:bt})}):null,g("div",{role:"listbox",id:me,"aria-labelledby":te?fe:void 0,"aria-multiselectable":n||void 0,className:"overflow-y-auto",style:{maxHeight:ge},children:[S.map((e,t)=>r(Ft,{option:e,isSelected:Y.has(e.value),isHighlighted:t===p,isDisabled:d||Le.has(e.value),multiple:n,sizeKey:x,optionId:`${F}-option-${t}`,onClick:Ne,onMouseEnter:k,index:t,ref:s=>{ve.current[t]=s}},e.value)),Ce?g("div",{ref:e=>{ve.current[R]=e},id:`${F}-option-${R}`,role:"option","aria-selected":!1,"aria-disabled":d||void 0,"data-highlighted":R===p||void 0,className:et(x,R===p,!1,d,n),onMouseDown:ee,onClick:d?void 0:Q,onMouseEnter:d?void 0:()=>k(R),children:[r("span",{className:"flex size-4 shrink-0 items-center justify-center text-gray-500 dark:text-gray-400",children:Rt}),r("span",{className:"truncate",children:De(I.selectCreateOption,{label:D})})]}):null]}),A===0?r("div",{className:m(E[x].option,"text-gray-500 dark:text-gray-400 text-center py-4"),children:ct}):null]}),Ze(y.current).body):null]})}export{Yt as Select};
|
package/dist/index.d.cts
CHANGED
|
@@ -5749,6 +5749,11 @@ interface IndicatorProps extends Omit<ComponentPropsWithoutRef<"div">, "color">
|
|
|
5749
5749
|
maxCount?: number;
|
|
5750
5750
|
label?: string;
|
|
5751
5751
|
bordered?: boolean;
|
|
5752
|
+
/**
|
|
5753
|
+
* Ring colour of a `bordered` mark, as Tailwind classes (`ring-blue-500`).
|
|
5754
|
+
* It replaces the default in both themes: write a `dark:` class beside it
|
|
5755
|
+
* for a dark one of its own.
|
|
5756
|
+
*/
|
|
5752
5757
|
borderColor?: string;
|
|
5753
5758
|
pulse?: boolean;
|
|
5754
5759
|
offset?: boolean;
|
|
@@ -8003,8 +8008,12 @@ declare namespace WizardActions {
|
|
|
8003
8008
|
}
|
|
8004
8009
|
|
|
8005
8010
|
/**
|
|
8006
|
-
*
|
|
8007
|
-
*
|
|
8011
|
+
* Joins class names, skipping falsy values, and resolves the Tailwind classes
|
|
8012
|
+
* that set the same thing: the one written last wins, whatever the order of
|
|
8013
|
+
* the stylesheet. `cn("px-4 bg-white", className)` with `className="bg-red-600"`
|
|
8014
|
+
* gives `px-4 bg-red-600`. A class under a variant (`hover:`, `dark:`,
|
|
8015
|
+
* `md:`) only replaces one under the same variants, and a class Tailwind does
|
|
8016
|
+
* not know is kept as it is.
|
|
8008
8017
|
*/
|
|
8009
8018
|
declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
8010
8019
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5749,6 +5749,11 @@ interface IndicatorProps extends Omit<ComponentPropsWithoutRef<"div">, "color">
|
|
|
5749
5749
|
maxCount?: number;
|
|
5750
5750
|
label?: string;
|
|
5751
5751
|
bordered?: boolean;
|
|
5752
|
+
/**
|
|
5753
|
+
* Ring colour of a `bordered` mark, as Tailwind classes (`ring-blue-500`).
|
|
5754
|
+
* It replaces the default in both themes: write a `dark:` class beside it
|
|
5755
|
+
* for a dark one of its own.
|
|
5756
|
+
*/
|
|
5752
5757
|
borderColor?: string;
|
|
5753
5758
|
pulse?: boolean;
|
|
5754
5759
|
offset?: boolean;
|
|
@@ -8003,8 +8008,12 @@ declare namespace WizardActions {
|
|
|
8003
8008
|
}
|
|
8004
8009
|
|
|
8005
8010
|
/**
|
|
8006
|
-
*
|
|
8007
|
-
*
|
|
8011
|
+
* Joins class names, skipping falsy values, and resolves the Tailwind classes
|
|
8012
|
+
* that set the same thing: the one written last wins, whatever the order of
|
|
8013
|
+
* the stylesheet. `cn("px-4 bg-white", className)` with `className="bg-red-600"`
|
|
8014
|
+
* gives `px-4 bg-red-600`. A class under a variant (`hover:`, `dark:`,
|
|
8015
|
+
* `md:`) only replaces one under the same variants, and a class Tailwind does
|
|
8016
|
+
* not know is kept as it is.
|
|
8008
8017
|
*/
|
|
8009
8018
|
declare function cn(...classes: (string | undefined | null | false)[]): string;
|
|
8010
8019
|
|
package/dist/lib/cn.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(e,n)=>{for(var t in n)s(e,t,{get:n[t],enumerable:!0})},c=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of m(n))!l.call(e,i)&&i!==t&&s(e,i,{get:()=>n[i],enumerable:!(r=o(n,i))||r.enumerable});return e};var d=e=>c(s({},"__esModule",{value:!0}),e);var p={};u(p,{cn:()=>g});module.exports=d(p);var a=require("tailwind-merge"),f=(0,a.extendTailwindMerge)({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{animate:["shimmer"]},classGroups:{animate:[{animate:["in","out"]}]}}});function g(...e){return f(...e)}0&&(module.exports={cn});
|
package/dist/lib/cn.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
import{extendTailwindMerge as n}from"tailwind-merge";var i=n({override:{conflictingClassGroups:{"font-size":[]}},extend:{theme:{animate:["shimmer"]},classGroups:{animate:[{animate:["in","out"]}]}}});function s(...e){return i(...e)}export{s as cn};
|
|
@@ -1435,6 +1435,9 @@
|
|
|
1435
1435
|
.animate-\[progress-indeterminate_1\.5s_ease-in-out_infinite\] {
|
|
1436
1436
|
animation: progress-indeterminate 1.5s ease-in-out infinite;
|
|
1437
1437
|
}
|
|
1438
|
+
.animate-none {
|
|
1439
|
+
animation: none;
|
|
1440
|
+
}
|
|
1438
1441
|
.animate-pulse {
|
|
1439
1442
|
animation: var(--animate-pulse);
|
|
1440
1443
|
}
|
|
@@ -2537,6 +2540,9 @@
|
|
|
2537
2540
|
.bg-red-600 {
|
|
2538
2541
|
background-color: var(--color-red-600);
|
|
2539
2542
|
}
|
|
2543
|
+
.bg-red-600\! {
|
|
2544
|
+
background-color: var(--color-red-600) !important;
|
|
2545
|
+
}
|
|
2540
2546
|
.bg-rose-100 {
|
|
2541
2547
|
background-color: var(--color-rose-100);
|
|
2542
2548
|
}
|
|
@@ -2642,6 +2648,9 @@
|
|
|
2642
2648
|
.bg-yellow-100 {
|
|
2643
2649
|
background-color: var(--color-yellow-100);
|
|
2644
2650
|
}
|
|
2651
|
+
.bg-yellow-300 {
|
|
2652
|
+
background-color: var(--color-yellow-300);
|
|
2653
|
+
}
|
|
2645
2654
|
.bg-yellow-400 {
|
|
2646
2655
|
background-color: var(--color-yellow-400);
|
|
2647
2656
|
}
|
|
@@ -3325,6 +3334,10 @@
|
|
|
3325
3334
|
font-size: var(--text-sm);
|
|
3326
3335
|
line-height: calc(var(--spacing) * 5);
|
|
3327
3336
|
}
|
|
3337
|
+
.text-sm\/6 {
|
|
3338
|
+
font-size: var(--text-sm);
|
|
3339
|
+
line-height: calc(var(--spacing) * 6);
|
|
3340
|
+
}
|
|
3328
3341
|
.text-xl {
|
|
3329
3342
|
font-size: var(--text-xl);
|
|
3330
3343
|
line-height: var(--tw-leading, var(--text-xl--line-height));
|
|
@@ -6506,6 +6519,19 @@
|
|
|
6506
6519
|
}
|
|
6507
6520
|
}
|
|
6508
6521
|
}
|
|
6522
|
+
.dark\:bg-amber-900 {
|
|
6523
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
6524
|
+
background-color: var(--color-amber-900);
|
|
6525
|
+
}
|
|
6526
|
+
@media (prefers-color-scheme: dark) {
|
|
6527
|
+
&:where(
|
|
6528
|
+
:root:not(.light):not([data-theme="light"]),
|
|
6529
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
6530
|
+
) {
|
|
6531
|
+
background-color: var(--color-amber-900);
|
|
6532
|
+
}
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6509
6535
|
.dark\:bg-amber-900\/20 {
|
|
6510
6536
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
6511
6537
|
background-color: color-mix(in srgb, oklch(41.4% 0.112 45.904) 20%, transparent);
|
|
@@ -8395,6 +8421,19 @@
|
|
|
8395
8421
|
}
|
|
8396
8422
|
}
|
|
8397
8423
|
}
|
|
8424
|
+
.dark\:text-amber-100 {
|
|
8425
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
8426
|
+
color: var(--color-amber-100);
|
|
8427
|
+
}
|
|
8428
|
+
@media (prefers-color-scheme: dark) {
|
|
8429
|
+
&:where(
|
|
8430
|
+
:root:not(.light):not([data-theme="light"]),
|
|
8431
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
8432
|
+
) {
|
|
8433
|
+
color: var(--color-amber-100);
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
}
|
|
8398
8437
|
.dark\:text-amber-200 {
|
|
8399
8438
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
8400
8439
|
color: var(--color-amber-200);
|
|
@@ -10016,6 +10055,27 @@
|
|
|
10016
10055
|
}
|
|
10017
10056
|
}
|
|
10018
10057
|
}
|
|
10058
|
+
.dark\:hover\:bg-red-900 {
|
|
10059
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
10060
|
+
&:hover {
|
|
10061
|
+
@media (hover: hover) {
|
|
10062
|
+
background-color: var(--color-red-900);
|
|
10063
|
+
}
|
|
10064
|
+
}
|
|
10065
|
+
}
|
|
10066
|
+
@media (prefers-color-scheme: dark) {
|
|
10067
|
+
&:where(
|
|
10068
|
+
:root:not(.light):not([data-theme="light"]),
|
|
10069
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
10070
|
+
) {
|
|
10071
|
+
&:hover {
|
|
10072
|
+
@media (hover: hover) {
|
|
10073
|
+
background-color: var(--color-red-900);
|
|
10074
|
+
}
|
|
10075
|
+
}
|
|
10076
|
+
}
|
|
10077
|
+
}
|
|
10078
|
+
}
|
|
10019
10079
|
.dark\:hover\:bg-red-900\/20 {
|
|
10020
10080
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
10021
10081
|
&:hover {
|
package/dist/styles.css
CHANGED
|
@@ -1598,6 +1598,9 @@
|
|
|
1598
1598
|
.animate-\[progress-indeterminate_1\.5s_ease-in-out_infinite\] {
|
|
1599
1599
|
animation: progress-indeterminate 1.5s ease-in-out infinite;
|
|
1600
1600
|
}
|
|
1601
|
+
.animate-none {
|
|
1602
|
+
animation: none;
|
|
1603
|
+
}
|
|
1601
1604
|
.animate-pulse {
|
|
1602
1605
|
animation: var(--animate-pulse);
|
|
1603
1606
|
}
|
|
@@ -2700,6 +2703,9 @@
|
|
|
2700
2703
|
.bg-red-600 {
|
|
2701
2704
|
background-color: var(--color-red-600);
|
|
2702
2705
|
}
|
|
2706
|
+
.bg-red-600\! {
|
|
2707
|
+
background-color: var(--color-red-600) !important;
|
|
2708
|
+
}
|
|
2703
2709
|
.bg-rose-100 {
|
|
2704
2710
|
background-color: var(--color-rose-100);
|
|
2705
2711
|
}
|
|
@@ -2805,6 +2811,9 @@
|
|
|
2805
2811
|
.bg-yellow-100 {
|
|
2806
2812
|
background-color: var(--color-yellow-100);
|
|
2807
2813
|
}
|
|
2814
|
+
.bg-yellow-300 {
|
|
2815
|
+
background-color: var(--color-yellow-300);
|
|
2816
|
+
}
|
|
2808
2817
|
.bg-yellow-400 {
|
|
2809
2818
|
background-color: var(--color-yellow-400);
|
|
2810
2819
|
}
|
|
@@ -3488,6 +3497,10 @@
|
|
|
3488
3497
|
font-size: var(--text-sm);
|
|
3489
3498
|
line-height: calc(var(--spacing) * 5);
|
|
3490
3499
|
}
|
|
3500
|
+
.text-sm\/6 {
|
|
3501
|
+
font-size: var(--text-sm);
|
|
3502
|
+
line-height: calc(var(--spacing) * 6);
|
|
3503
|
+
}
|
|
3491
3504
|
.text-xl {
|
|
3492
3505
|
font-size: var(--text-xl);
|
|
3493
3506
|
line-height: var(--tw-leading, var(--text-xl--line-height));
|
|
@@ -6669,6 +6682,19 @@
|
|
|
6669
6682
|
}
|
|
6670
6683
|
}
|
|
6671
6684
|
}
|
|
6685
|
+
.dark\:bg-amber-900 {
|
|
6686
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
6687
|
+
background-color: var(--color-amber-900);
|
|
6688
|
+
}
|
|
6689
|
+
@media (prefers-color-scheme: dark) {
|
|
6690
|
+
&:where(
|
|
6691
|
+
:root:not(.light):not([data-theme="light"]),
|
|
6692
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
6693
|
+
) {
|
|
6694
|
+
background-color: var(--color-amber-900);
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
}
|
|
6672
6698
|
.dark\:bg-amber-900\/20 {
|
|
6673
6699
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
6674
6700
|
background-color: color-mix(in srgb, oklch(41.4% 0.112 45.904) 20%, transparent);
|
|
@@ -8558,6 +8584,19 @@
|
|
|
8558
8584
|
}
|
|
8559
8585
|
}
|
|
8560
8586
|
}
|
|
8587
|
+
.dark\:text-amber-100 {
|
|
8588
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
8589
|
+
color: var(--color-amber-100);
|
|
8590
|
+
}
|
|
8591
|
+
@media (prefers-color-scheme: dark) {
|
|
8592
|
+
&:where(
|
|
8593
|
+
:root:not(.light):not([data-theme="light"]),
|
|
8594
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
8595
|
+
) {
|
|
8596
|
+
color: var(--color-amber-100);
|
|
8597
|
+
}
|
|
8598
|
+
}
|
|
8599
|
+
}
|
|
8561
8600
|
.dark\:text-amber-200 {
|
|
8562
8601
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
8563
8602
|
color: var(--color-amber-200);
|
|
@@ -10179,6 +10218,27 @@
|
|
|
10179
10218
|
}
|
|
10180
10219
|
}
|
|
10181
10220
|
}
|
|
10221
|
+
.dark\:hover\:bg-red-900 {
|
|
10222
|
+
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
10223
|
+
&:hover {
|
|
10224
|
+
@media (hover: hover) {
|
|
10225
|
+
background-color: var(--color-red-900);
|
|
10226
|
+
}
|
|
10227
|
+
}
|
|
10228
|
+
}
|
|
10229
|
+
@media (prefers-color-scheme: dark) {
|
|
10230
|
+
&:where(
|
|
10231
|
+
:root:not(.light):not([data-theme="light"]),
|
|
10232
|
+
:root:not(.light):not([data-theme="light"]) *
|
|
10233
|
+
) {
|
|
10234
|
+
&:hover {
|
|
10235
|
+
@media (hover: hover) {
|
|
10236
|
+
background-color: var(--color-red-900);
|
|
10237
|
+
}
|
|
10238
|
+
}
|
|
10239
|
+
}
|
|
10240
|
+
}
|
|
10241
|
+
}
|
|
10182
10242
|
.dark\:hover\:bg-red-900\/20 {
|
|
10183
10243
|
&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *) {
|
|
10184
10244
|
&:hover {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synertech/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React dashboards, from a single package: charts, a data grid, forms and accessible dialogs for React and Next.js, with a compiled stylesheet and labels in English and French.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -142,6 +142,7 @@
|
|
|
142
142
|
"dependencies": {
|
|
143
143
|
"dompurify": "^3.4.18",
|
|
144
144
|
"react-markdown": "^10.1.0",
|
|
145
|
-
"remark-gfm": "^4.0.1"
|
|
145
|
+
"remark-gfm": "^4.0.1",
|
|
146
|
+
"tailwind-merge": "^3.7.3"
|
|
146
147
|
}
|
|
147
148
|
}
|