@synertech/ui 0.56.1 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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!` le remplace (`cn()` ne fusionne pas).
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 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":"",o?"opacity-50 cursor-not-allowed":"",n?"bg-gray-100 dark:bg-gray-600 cursor-default":"",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
+ "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":"",n?"opacity-50 cursor-not-allowed":"",a?"bg-gray-100 dark:bg-gray-600 cursor-default":"",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
+ 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?"block 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
+ "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?"block 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
+ "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 ring-white dark:ring-gray-900",a),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 ring-white dark:ring-gray-900",l),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 ring-white dark:ring-gray-900",a),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
+ "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 ring-white dark:ring-gray-900",i),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 ring-white dark:ring-gray-900",l),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 ring-white dark:ring-gray-900",i),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
+ 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",l&&"cursor-default",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
+ "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",t&&"cursor-default",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
+ "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};
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
- * Utility to concatenate class names.
8007
- * Filters out falsy values and joins with space.
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
- * Utility to concatenate class names.
8007
- * Filters out falsy values and joins with space.
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 t=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var s=(n,e)=>{for(var r in e)t(n,r,{get:e[r],enumerable:!0})},a=(n,e,r,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of f(e))!u.call(n,i)&&i!==r&&t(n,i,{get:()=>e[i],enumerable:!(l=o(e,i))||l.enumerable});return n};var c=n=>a(t({},"__esModule",{value:!0}),n);var g={};s(g,{cn:()=>d});module.exports=c(g);function d(...n){return n.filter(Boolean).join(" ")}0&&(module.exports={cn});
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 e(...n){return n.filter(Boolean).join(" ")}export{e as cn};
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.56.1",
3
+ "version": "0.57.0",
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
  }