blunt-ui 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -125
- package/dist/index.cjs +22 -22
- package/dist/index.js +308 -306
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
padding: ${r.spacing[3]} ${r.spacing[6]};
|
|
108
108
|
font-size: ${r.fontSizes.lg};
|
|
109
109
|
`})[o]}
|
|
110
|
-
`;function H({ref:o,as:r,href:n,variant:e="primary",size:l="md",isLoading:i,disabled:c,children:d,...p}){const
|
|
110
|
+
`;function H({ref:o,as:r,href:n,variant:e="primary",size:l="md",isLoading:i,disabled:c,children:d,...p}){const $=r??(n?"a":"button");return t.jsx(No,{ref:o,as:$,href:n,$variant:e,$size:l,disabled:i||c,...p,children:i?"Loading...":d})}H.displayName="Button";const Fo=s.div`
|
|
111
111
|
display: flex;
|
|
112
112
|
flex-direction: column;
|
|
113
113
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
`,Bo=s.span`
|
|
119
119
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
120
120
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
121
|
-
`,
|
|
121
|
+
`,Ro=s.div`
|
|
122
122
|
display: flex;
|
|
123
123
|
align-items: center;
|
|
124
124
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
&:focus-within {
|
|
161
161
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
162
162
|
}
|
|
163
|
-
`,
|
|
163
|
+
`,Vo=s.input`
|
|
164
164
|
flex: 1;
|
|
165
165
|
border: none;
|
|
166
166
|
outline: none;
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
display: inline-flex;
|
|
176
176
|
align-items: center;
|
|
177
177
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
178
|
-
`,
|
|
178
|
+
`,_o=s.button`
|
|
179
179
|
display: inline-flex;
|
|
180
180
|
align-items: center;
|
|
181
181
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
&:hover {
|
|
189
189
|
opacity: 0.8;
|
|
190
190
|
}
|
|
191
|
-
`;function xo({ref:o,type:r="text",size:n="md",variant:e="default",label:l,helperText:i,error:c,leftElement:d,rightElement:p,clearable:b,
|
|
191
|
+
`;function xo({ref:o,type:r="text",size:n="md",variant:e="default",label:l,helperText:i,error:c,leftElement:d,rightElement:p,clearable:$,onClear:b,fullWidth:w,id:x,value:f,defaultValue:y,onChange:h,...j}){const I=a.useId(),v=x??I,g=`${v}-hint`,[k,z]=a.useState(y??""),S=f!==void 0,C=S?f:k,T=typeof c=="string"?c:void 0,D=!!(i||c),M=E=>{S||z(E.target.value),h?.(E)},R=()=>{S||z(""),b?.()};return t.jsxs(Fo,{$fullWidth:w,children:[l&&t.jsx(Lo,{htmlFor:v,children:l}),t.jsxs(Ro,{$size:n,$variant:e,$error:!!c,children:[d&&t.jsx(to,{children:d}),t.jsx(Vo,{id:v,ref:o,type:r,value:C,onChange:M,...j,"aria-invalid":!!c,"aria-describedby":D?g:void 0}),$&&C&&t.jsx(_o,{type:"button",onClick:R,"aria-label":"Clear input",children:"✕"}),p&&t.jsx(to,{children:p})]}),D&&t.jsx(Bo,{id:g,$error:!!c,children:T??i})]})}xo.displayName="Input";const Ao=s.div`
|
|
192
192
|
display: flex;
|
|
193
193
|
flex-direction: column;
|
|
194
194
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
cursor: not-allowed;
|
|
254
254
|
opacity: 0.6;
|
|
255
255
|
}
|
|
256
|
-
`;function yo({ref:o,size:r="md",variant:n="default",label:e,helperText:l,error:i,fullWidth:c,id:d,value:p,defaultValue:b
|
|
256
|
+
`;function yo({ref:o,size:r="md",variant:n="default",label:e,helperText:l,error:i,fullWidth:c,id:d,value:p,defaultValue:$,onChange:b,...w}){const x=a.useId(),f=d??x,y=`${f}-hint`,[h,j]=a.useState($??""),I=p!==void 0,v=I?p:h,g=typeof i=="string"?i:void 0,k=!!(l||i),z=S=>{I||j(S.target.value),b?.(S)};return t.jsxs(Ao,{$fullWidth:c,children:[e&&t.jsx(Yo,{htmlFor:f,children:e}),t.jsx(qo,{$size:r,$variant:n,$error:!!i,children:t.jsx(Uo,{id:f,ref:o,value:v,onChange:z,...w,"aria-invalid":!!i,"aria-describedby":k?y:void 0})}),k&&t.jsx(Ho,{id:y,$error:!!i,children:g??l})]})}yo.displayName="Textarea";const ho=(...o)=>o.filter((r,n,e)=>!!r&&r.trim()!==""&&e.indexOf(r)===n).join(" ").trim();const Ko=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Go=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,n,e)=>e?e.toUpperCase():n.toLowerCase());const eo=o=>{const r=Go(o);return r.charAt(0).toUpperCase()+r.slice(1)};var X={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Jo=o=>{for(const r in o)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1},Xo=a.createContext({}),Zo=()=>a.useContext(Xo),Qo=a.forwardRef(({color:o,size:r,strokeWidth:n,absoluteStrokeWidth:e,className:l="",children:i,iconNode:c,...d},p)=>{const{size:$=24,strokeWidth:b=2,absoluteStrokeWidth:w=!1,color:x="currentColor",className:f=""}=Zo()??{},y=e??w?Number(n??b)*24/Number(r??$):n??b;return a.createElement("svg",{ref:p,...X,width:r??$??X.width,height:r??$??X.height,stroke:o??x,strokeWidth:y,className:ho("lucide",f,l),...!i&&!Jo(d)&&{"aria-hidden":"true"},...d},[...c.map(([h,j])=>a.createElement(h,j)),...Array.isArray(i)?i:[i]])});const N=(o,r)=>{const n=a.forwardRef(({className:e,...l},i)=>a.createElement(Qo,{ref:i,iconNode:r,className:ho(`lucide-${Ko(eo(o))}`,`lucide-${o}`,e),...l}));return n.displayName=eo(o),n};const or=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],rr=N("arrow-down",or);const sr=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],nr=N("arrow-up-down",sr);const tr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],er=N("arrow-up",tr);const ir=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],ar=N("calendar",ir);const lr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],wo=N("chevron-down",lr);const cr=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],dr=N("chevron-left",cr);const ur=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],pr=N("chevron-right",ur);const fr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Q=N("x",fr),$r=s.div`
|
|
257
257
|
display: inline-flex;
|
|
258
258
|
flex-direction: column;
|
|
259
259
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
display: flex;
|
|
347
347
|
align-items: center;
|
|
348
348
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
349
|
-
`;function mo({options:o,placeholder:r,size:n="md",variant:e="default",error:l,fullWidth:i,clearable:c,onClear:d,id:p,value:b,
|
|
349
|
+
`;function mo({options:o,placeholder:r,size:n="md",variant:e="default",error:l,fullWidth:i,clearable:c,onClear:d,id:p,value:$,defaultValue:b,onChange:w,...x}){const f=a.useId(),y=p??f,h=`${y}-hint`,j=typeof l=="string"?l:void 0,[I,v]=a.useState(b??""),g=$!==void 0,k=g?$:I,z=T=>{g||v(T.target.value),w?.(T)},S=()=>{g||v(""),d?.()},C=c&&!!k;return t.jsxs($r,{$fullWidth:i,children:[t.jsxs(br,{children:[t.jsxs(xr,{id:y,$size:n,$variant:e,$error:!!l,"aria-invalid":!!l,"aria-describedby":j?h:void 0,value:k,onChange:z,...x,children:[r&&t.jsx("option",{value:"",disabled:!0,children:r}),o.map(T=>t.jsx("option",{value:T.value,disabled:T.disabled,children:T.label},T.value))]}),C?t.jsx(yr,{type:"button",onClick:S,"aria-label":"Clear selection",children:t.jsx(Q,{size:14})}):t.jsx(hr,{"aria-hidden":"true",children:t.jsx(wo,{size:14})})]}),j&&t.jsx(gr,{id:h,$error:!0,children:j})]})}mo.displayName="Select";const io=s.span`
|
|
350
350
|
display: inline-block;
|
|
351
351
|
`,wr=s.span`
|
|
352
352
|
display: inline-block;
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
border: 1px solid ${o.colors.primary[500]};
|
|
406
406
|
box-shadow: ${o.shadows.focusRing};
|
|
407
407
|
`}
|
|
408
|
-
`;function vo({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:l,placeholder:i="Click to edit",disabled:c=!1}){const d=o!==void 0,[p
|
|
408
|
+
`;function vo({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:l,placeholder:i="Click to edit",disabled:c=!1}){const d=o!==void 0,[p,$]=a.useState(r),b=d?o:p,[w,x]=a.useState(!1),[f,y]=a.useState(""),h=a.useRef(null),j=()=>{c||(y(b),x(!0),setTimeout(()=>{h.current?.focus(),h.current?.select()},0))},I=()=>{d||$(f),n?.(f),e?.(f),x(!1)},v=()=>{l?.(b),x(!1)},g=k=>{k.key==="Enter"?I():k.key==="Escape"&&v()};return w?t.jsx(io,{children:t.jsx(mr,{ref:h,value:f,size:Math.max(f.length,i.length,10),onChange:k=>y(k.target.value),onBlur:I,onKeyDown:g,"aria-label":"Edit value"})}):t.jsx(io,{children:t.jsx(wr,{role:c?void 0:"button",tabIndex:c?void 0:0,$disabled:c,$empty:!b,onClick:j,onKeyDown:k=>k.key==="Enter"&&j(),children:b||i})})}vo.displayName="Editable";const vr=s.a`
|
|
409
409
|
text-decoration: underline;
|
|
410
410
|
text-underline-offset: 2px;
|
|
411
411
|
transition: color 0.15s;
|
|
@@ -536,16 +536,16 @@
|
|
|
536
536
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
537
537
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
538
538
|
flex-shrink: 0;
|
|
539
|
-
`,Fr=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function ao(o){return Array.from(o.querySelectorAll(Fr))}function ro({open:o,onClose:r,title:n,children:e,footer:l,size:i="md",closeOnBackdrop:c=!0,closeOnEscape:d=!0,ariaLabelledBy:p,ariaDescribedBy
|
|
539
|
+
`,Fr=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function ao(o){return Array.from(o.querySelectorAll(Fr))}function ro({open:o,onClose:r,title:n,children:e,footer:l,size:i="md",closeOnBackdrop:c=!0,closeOnEscape:d=!0,ariaLabelledBy:p,ariaDescribedBy:$}){const b=a.useRef(null),w=a.useRef(null),x=a.useRef(r);x.current=r;const f=a.useId(),y=p??(n?f:void 0),[h,j]=a.useState(o),[I,v]=a.useState(!1);return a.useEffect(()=>{if(o)j(!0),v(!1);else if(h){v(!0);const g=setTimeout(()=>{j(!1),v(!1)},150);return()=>clearTimeout(g)}},[o,h]),a.useEffect(()=>{if(!o)return;const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=g}},[o]),a.useEffect(()=>{if(!o||!b.current)return;const g=b.current,k=document.activeElement;(ao(g)[0]??g).focus();const S=C=>{if(C.key==="Escape"&&d){x.current();return}if(C.key!=="Tab")return;const T=ao(g);if(T.length===0){C.preventDefault();return}const D=T[0],M=T[T.length-1];C.shiftKey?document.activeElement===D&&(C.preventDefault(),M.focus()):document.activeElement===M&&(C.preventDefault(),D.focus())};return document.addEventListener("keydown",S),()=>{document.removeEventListener("keydown",S),k?.focus()}},[o,d,h]),h?bo.createPortal(t.jsx(Mr,{$closing:I,onMouseDown:g=>{w.current=g.target},onClick:g=>{c&&w.current===g.currentTarget&&r()},children:t.jsxs(Dr,{ref:b,role:"dialog","aria-modal":"true","aria-labelledby":y,"aria-describedby":$,$size:i,$closing:I,tabIndex:-1,onClick:g=>g.stopPropagation(),children:[t.jsxs(Er,{children:[n&&t.jsx(Pr,{id:f,children:n}),t.jsx(Wr,{onClick:r,"aria-label":"Close modal",children:"×"})]}),t.jsx(Or,{children:e}),l&&t.jsx(Nr,{children:l})]})}),document.body):null}ro.displayName="Modal";const Lr=s.keyframes`
|
|
540
540
|
from { opacity: 0; transform: translateY(12px); }
|
|
541
541
|
to { opacity: 1; transform: translateY(0); }
|
|
542
542
|
`,Br=s.keyframes`
|
|
543
543
|
from { opacity: 0; transform: translateY(-12px); }
|
|
544
544
|
to { opacity: 1; transform: translateY(0); }
|
|
545
|
-
`,
|
|
545
|
+
`,Rr=s.keyframes`
|
|
546
546
|
from { opacity: 1; }
|
|
547
547
|
to { opacity: 0; }
|
|
548
|
-
`,
|
|
548
|
+
`,Vr=s.div`
|
|
549
549
|
position: fixed;
|
|
550
550
|
z-index: ${({theme:o})=>o.zIndex.toast};
|
|
551
551
|
display: flex;
|
|
@@ -556,7 +556,7 @@
|
|
|
556
556
|
padding: ${({theme:o})=>`${o.spacing[3]} ${o.spacing[4]}`};
|
|
557
557
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
558
558
|
animation: ${({$closing:o,$position:r})=>o?s.css`
|
|
559
|
-
${
|
|
559
|
+
${Rr} 0.2s ease forwards
|
|
560
560
|
`:r.startsWith("top")?s.css`
|
|
561
561
|
${Br} 0.2s ease forwards
|
|
562
562
|
`:s.css`
|
|
@@ -581,7 +581,7 @@
|
|
|
581
581
|
border: ${o.brutalism.borderWidth} solid ${n};
|
|
582
582
|
box-shadow: ${o.brutalism.shadowOffset} ${o.brutalism.shadowOffset}
|
|
583
583
|
0 ${n};
|
|
584
|
-
`,
|
|
584
|
+
`,_r=s(Vr)`
|
|
585
585
|
${({$variant:o,theme:r})=>r.brutalism?{success:A(r,r.colors.success[50],r.colors.success[500]),error:A(r,r.colors.error[50],r.colors.error[500]),warning:A(r,r.colors.warning[50],r.colors.warning[500]),info:A(r,r.colors.info[50],r.colors.info[500])}[o]:{success:s.css`
|
|
586
586
|
background: ${r.colors.success[50]};
|
|
587
587
|
border-left: 4px solid ${r.colors.success[500]};
|
|
@@ -628,7 +628,7 @@
|
|
|
628
628
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
629
629
|
outline-offset: 2px;
|
|
630
630
|
}
|
|
631
|
-
`;function so({open:o,onClose:r,message:n,variant:e="info",duration:l=4e3,position:i="bottom-right"}){const[c,d]=a.useState(o),[p
|
|
631
|
+
`;function so({open:o,onClose:r,message:n,variant:e="info",duration:l=4e3,position:i="bottom-right"}){const[c,d]=a.useState(o),[p,$]=a.useState(!1);return a.useEffect(()=>{if(o)d(!0),$(!1);else if(c){$(!0);const b=setTimeout(()=>{d(!1),$(!1)},200);return()=>{clearTimeout(b)}}},[o,c]),a.useEffect(()=>{if(!o||l===0)return;const b=setTimeout(r,l);return()=>{clearTimeout(b)}},[o,l,r]),c?bo.createPortal(t.jsxs(_r,{$position:i,$variant:e,$closing:p,role:"alert","aria-live":"polite",children:[t.jsx(Ar,{children:n}),t.jsx(Yr,{onClick:r,"aria-label":"Close notification",children:t.jsx(Q,{size:14,strokeWidth:2.5})})]}),document.body):null}so.displayName="Toast";const So=a.createContext(null);function Hr({children:o}){const[r,n]=a.useState(null),e=a.useCallback(i=>{n({...i,id:Date.now()})},[]),l=a.useMemo(()=>Object.assign(i=>e(i),{success:(i,c)=>e({...c,message:i,variant:"success"}),error:(i,c)=>e({...c,message:i,variant:"error"}),warning:(i,c)=>e({...c,message:i,variant:"warning"}),info:(i,c)=>e({...c,message:i,variant:"info"})}),[e]);return t.jsxs(So.Provider,{value:{toast:l},children:[o,r&&t.jsx(so,{open:!0,onClose:()=>n(null),message:r.message,variant:r.variant,duration:r.duration,position:r.position},r.id)]})}function qr(){const o=a.useContext(So);if(!o)throw new Error("useToast must be used within a ToastProvider");return o}const Ur=s.form`
|
|
632
632
|
display: flex;
|
|
633
633
|
flex-direction: column;
|
|
634
634
|
gap: ${({theme:o})=>o.spacing[4]};
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
`,Xr=s.span`
|
|
647
647
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
648
648
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
649
|
-
`;function jo({onSubmit:o,children:r,...n}){return t.jsx(Ur,{onSubmit:e=>{e.preventDefault(),o?.(e)},noValidate:!0,...n,children:r})}jo.displayName="Form";function Co({label:o,error:r,helperText:n,required:e,children:l}){const i=a.useId(),c=`${i}-hint`,d=!!(r||n),p=typeof r=="string"?r:void 0
|
|
649
|
+
`;function jo({onSubmit:o,children:r,...n}){return t.jsx(Ur,{onSubmit:e=>{e.preventDefault(),o?.(e)},noValidate:!0,...n,children:r})}jo.displayName="Form";function Co({label:o,error:r,helperText:n,required:e,children:l}){const i=a.useId(),c=`${i}-hint`,d=!!(r||n),p=typeof r=="string"?r:void 0,$=a.isValidElement(l)?a.cloneElement(l,{id:i,...d&&{"aria-describedby":c},...r&&{"aria-invalid":!0}}):l;return t.jsxs(Kr,{children:[o&&t.jsxs(Gr,{htmlFor:i,children:[o,e&&t.jsx(Jr,{"aria-hidden":"true",children:" *"})]}),$,d&&t.jsx(Xr,{id:c,$error:!!r,children:p??n})]})}Co.displayName="FormField";function Zr({initialValues:o,validate:r,onSubmit:n,onError:e}){const[l,i]=a.useState(o),[c,d]=a.useState({}),[p,$]=a.useState({}),[b,w]=a.useState(!1),x=a.useRef(l);x.current=l;const f=a.useCallback(z=>{if(!r)return{};const S=r(z);return Object.fromEntries(Object.entries(S).filter(([,C])=>C!==void 0))},[r]),y=a.useRef(p);y.current=p;const h=a.useCallback(z=>{const{name:S,value:C}=z.target;process.env.NODE_ENV!=="production"&&!S&&console.warn("[useForm] handleChange: field is missing a `name` attribute — value will not be tracked.");const T={...x.current,[S]:C};i(T),y.current[S]&&d(f(T))},[f]),j=a.useCallback(z=>{const{name:S}=z.target;process.env.NODE_ENV!=="production"&&!S&&console.warn("[useForm] handleBlur: field is missing a `name` attribute — touched state will not be tracked."),$(C=>({...C,[S]:!0})),d(f(x.current))},[f]),I=a.useCallback(z=>{z?.preventDefault();const S=Object.keys(x.current).reduce((D,M)=>({...D,[M]:!0}),{});$(S);const C=f(x.current);if(d(C),Object.keys(C).length>0){e?.(C);return}(async()=>{w(!0);try{await n?.(x.current)}finally{w(!1)}})()},[f,n,e]),v=a.useCallback((z,S)=>{i(C=>({...C,[z]:S}))},[]),g=a.useCallback(z=>{i(z??o),d({}),$({}),w(!1)},[o]),k=Object.fromEntries(Object.entries(c).filter(([z])=>p[z]));return{values:l,errors:k,touched:p,handleChange:h,handleBlur:j,handleSubmit:I,setFieldValue:v,reset:g,isSubmitting:b}}const Qr=s.div`
|
|
650
650
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
651
651
|
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
652
652
|
overflow: hidden;
|
|
@@ -726,7 +726,7 @@
|
|
|
726
726
|
`,cs=s.div`
|
|
727
727
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
728
728
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
729
|
-
`;function zo({title:o,children:r,defaultOpen:n=!1,open:e,onToggle:l,subtitle:i,headerActions:c,accentColor:d}){const[p
|
|
729
|
+
`;function zo({title:o,children:r,defaultOpen:n=!1,open:e,onToggle:l,subtitle:i,headerActions:c,accentColor:d}){const[p,$]=a.useState(n),b=a.useId(),w=e!==void 0,x=w?e:p,f=()=>{const y=!x;w||$(y),l?.(y)};return t.jsxs(Qr,{$accentColor:d,children:[t.jsxs(os,{type:"button",$open:x,$accentColor:d,"aria-expanded":x,"aria-controls":b,onClick:f,children:[t.jsxs(rs,{children:[t.jsx(ss,{children:o}),(i||c)&&t.jsxs(ts,{children:[i&&t.jsx(ns,{children:i}),c&&t.jsx(es,{onClick:y=>y.stopPropagation(),children:c})]})]}),t.jsx(is,{$open:x,$accentColor:d,"aria-hidden":"true",children:t.jsx(wo,{size:18,strokeWidth:2.5})})]}),t.jsx(as,{$open:x,children:t.jsx(ls,{id:b,role:"region","aria-label":o,children:t.jsx(cs,{children:r})})})]})}zo.displayName="CollapsibleCard";const ds=s.keyframes`
|
|
730
730
|
to { transform: rotate(360deg); }
|
|
731
731
|
`,us={sm:"16px",md:"24px",lg:"40px"},ps={thin:"2px",normal:"3px",bold:"5px"},fs=s.span`
|
|
732
732
|
display: inline-block;
|
|
@@ -739,7 +739,7 @@
|
|
|
739
739
|
border: ${i} solid ${c};
|
|
740
740
|
border-top-color: ${d};
|
|
741
741
|
`}}
|
|
742
|
-
`;function To({size:o="md",weight:r="normal",color:n,label:e="Loading..."}){return t.jsx(fs,{$size:o,$weight:r,$color:n,role:"status","aria-label":e})}To.displayName="Spinner";function $s(o,r){return o?.key!==r?{key:r,direction:"asc"}:o.direction==="asc"?{key:r,direction:"desc"}:null}function bs({data:o,sort:r,defaultSort:n,onSortChange:e}){const l=r!==void 0,[i,c]=a.useState(n??null),d=l?r??null:i,p=
|
|
742
|
+
`;function To({size:o="md",weight:r="normal",color:n,label:e="Loading..."}){return t.jsx(fs,{$size:o,$weight:r,$color:n,role:"status","aria-label":e})}To.displayName="Spinner";function $s(o,r){return o?.key!==r?{key:r,direction:"asc"}:o.direction==="asc"?{key:r,direction:"desc"}:null}function bs({data:o,sort:r,defaultSort:n,onSortChange:e}){const l=r!==void 0,[i,c]=a.useState(n??null),d=l?r??null:i,p=b=>{const w=$s(d,b);return l||c(w),e?.(w),w},$=a.useMemo(()=>l||!d?o:[...o].sort((b,w)=>{const x=b[d.key],f=w[d.key],y=x<f?-1:x>f?1:0;return d.direction==="asc"?y:-y}),[o,d,l]);return{activeSort:d,sortedData:$,handleSort:p}}const gs=7,lo=3,co=1;function xs(o,r){if(r<=gs)return Array.from({length:r},(e,l)=>l+1);const n=[1];o>lo&&n.push("...");for(let e=Math.max(2,o-co);e<=Math.min(r-1,o+co);e++)n.push(e);return o<r-lo+1&&n.push("..."),n.push(r),n}function ys({data:o,pageSize:r,page:n,defaultPage:e,totalRows:l,onPageChange:i}){const c=n!==void 0,[d,p]=a.useState(e??1),$=c?n:d,b=h=>{c||p(h),i?.(h)},w=c||l!==void 0,x=l??o.length,f=r?Math.max(1,Math.ceil(x/r)):1,y=a.useMemo(()=>{if(!r||w)return o;const h=($-1)*r;return o.slice(h,h+r)},[o,r,$,w]);return{activePage:$,totalPages:f,displayData:y,handlePageChange:b}}const Io=(o,r)=>o==="sm"?`${r.spacing[1]} ${r.spacing[2]}`:o==="lg"?`${r.spacing[3]} ${r.spacing[4]}`:`${r.spacing[2]} ${r.spacing[3]}`,hs=s.div`
|
|
743
743
|
width: 100%;
|
|
744
744
|
|
|
745
745
|
${({theme:o,$borderColor:r})=>o.brutalism?s.css`
|
|
@@ -959,7 +959,7 @@
|
|
|
959
959
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
960
960
|
outline-offset: 2px;
|
|
961
961
|
}
|
|
962
|
-
`,Es=4;function Ps(o,r){return o?.key!==r?t.jsx(nr,{size:14}):o.direction==="asc"?t.jsx(er,{size:14}):t.jsx(rr,{size:14})}function Do({columns:o,data:r,rowKey:n,size:e="md",striped:l,bordered:i,stickyHeader:c,caption:d,emptyMessage:p="No data",loading:b,
|
|
962
|
+
`,Es=4;function Ps(o,r){return o?.key!==r?t.jsx(nr,{size:14}):o.direction==="asc"?t.jsx(er,{size:14}):t.jsx(rr,{size:14})}function Do({columns:o,data:r,rowKey:n,size:e="md",striped:l,bordered:i,stickyHeader:c,caption:d,emptyMessage:p="No data",loading:$,sort:b,defaultSort:w,onSortChange:x,pageSize:f,page:y,defaultPage:h,totalRows:j,onPageChange:I,onChange:v,onRowClick:g,borderColor:k,headerColor:z,rowColor:S,stripeColor:C,className:T,style:D}){const{activeSort:M,sortedData:R,handleSort:E}=bs({data:r,sort:b,defaultSort:w,onSortChange:x}),{activePage:P,totalPages:V,displayData:u,handlePageChange:O}=ys({data:R,pageSize:f,page:y,defaultPage:h,totalRows:j,onPageChange:I}),F=m=>{const W=E(m);v?.({sort:W,page:P})},L=m=>{O(m),v?.({sort:M,page:m})},U=(m,W)=>String(n?m[n]:W),K=!$&&u.length===0,Wo=f??Es;return t.jsxs(hs,{$borderColor:k,$stickyHeader:c,className:T,style:D,children:[t.jsxs(ws,{$size:e,children:[d&&t.jsx("caption",{children:d}),t.jsx(ms,{$headerColor:z,$borderColor:k,$stickyHeader:c,children:t.jsx(Y,{children:o.map(m=>t.jsx(Ss,{$size:e,$bordered:i,scope:"col",style:m.width?{width:m.width}:void 0,children:m.sortable?t.jsxs(js,{type:"button",onClick:()=>F(m.key),"aria-label":`Sort by ${m.header}${M?.key===m.key?`, ${M.direction}ending`:""}`,children:[m.header,t.jsx(Cs,{"aria-hidden":"true",children:Ps(M,m.key)})]}):m.header},m.key))})}),t.jsx(vs,{$striped:l,$rowColor:S,$stripeColor:C,children:$?Array.from({length:Wo}).map((m,W)=>t.jsx(Y,{children:o.map(G=>t.jsx(Is,{$size:e,$bordered:i,$borderColor:k,children:t.jsx(Ms,{})},G.key))},W)):K?t.jsx("tr",{children:t.jsx(zs,{colSpan:o.length,children:p})}):u.map((m,W)=>{const G=g?ks:Y;return t.jsx(G,{onClick:g?()=>g(m):void 0,$accentColor:g?k:void 0,children:o.map(_=>t.jsx(Mo,{$size:e,$bordered:i,$borderColor:k,children:_.render?_.render(m[_.key],m,W):String(m[_.key]??"")||" "},_.key))},U(m,W))})})]}),f&&V>1&&t.jsxs(Ds,{children:[t.jsx(Z,{type:"button",onClick:()=>L(P-1),disabled:P<=1,"aria-label":"Previous page",children:"←"}),xs(P,V).map((m,W)=>m==="..."?t.jsx("span",{"aria-hidden":"true",style:{padding:"0 4px"},children:"…"},`e${W}`):t.jsx(Z,{type:"button",$active:m===P,onClick:()=>L(m),"aria-label":`Page ${m}`,"aria-current":m===P?"page":void 0,children:m},m)),t.jsx(Z,{type:"button",onClick:()=>L(P+1),disabled:P>=V,"aria-label":"Next page",children:"→"})]})]})}Do.displayName="Table";function Ws({defaultSort:o,defaultPage:r=1}={}){const[n,e]=a.useState(o??null),[l,i]=a.useState(r);return{sort:n,page:l,onSortChange:p=>{e(p),i(1)},onPageChange:p=>{i(p)}}}const Os=s.p`
|
|
963
963
|
margin: 0;
|
|
964
964
|
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
965
965
|
color: ${({theme:o})=>o.colors.neutral[600]};
|
|
@@ -1009,7 +1009,7 @@
|
|
|
1009
1009
|
display: inline-flex;
|
|
1010
1010
|
flex-direction: column;
|
|
1011
1011
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
1012
|
-
`,
|
|
1012
|
+
`,Rs=s.div`
|
|
1013
1013
|
display: flex;
|
|
1014
1014
|
align-items: center;
|
|
1015
1015
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -1054,13 +1054,13 @@
|
|
|
1054
1054
|
outline: none;
|
|
1055
1055
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
1056
1056
|
}
|
|
1057
|
-
`,
|
|
1057
|
+
`,Vs=s.span`
|
|
1058
1058
|
flex: 1;
|
|
1059
1059
|
color: ${({$hasValue:o,theme:r})=>o?r.colors.neutral[900]:r.colors.neutral[400]};
|
|
1060
1060
|
white-space: nowrap;
|
|
1061
1061
|
overflow: hidden;
|
|
1062
1062
|
text-overflow: ellipsis;
|
|
1063
|
-
`,
|
|
1063
|
+
`,_s=s.span`
|
|
1064
1064
|
display: inline-flex;
|
|
1065
1065
|
align-items: center;
|
|
1066
1066
|
margin-left: ${({theme:o})=>o.spacing[2]};
|
|
@@ -1198,7 +1198,7 @@
|
|
|
1198
1198
|
box-shadow: 2px 2px 0 ${n.colors.neutral[900]};
|
|
1199
1199
|
`}
|
|
1200
1200
|
`}
|
|
1201
|
-
`,Js=["January","February","March","April","May","June","July","August","September","October","November","December"],Xs=["Su","Mo","Tu","We","Th","Fr","Sa"];function fo(o,r){return new Date(o,r+1,0).getDate()}function Zs(o,r){return new Date(o,r,1).getDay()}function $o(o,r){return o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate()}function Qs(o,r,n){if(r){const e=new Date(r.getFullYear(),r.getMonth(),r.getDate());if(o<e)return!0}if(n){const e=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(o>e)return!0}return!1}function on(o){return o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function rn(o){return o.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}function Po({value:o=null,onChange:r,placeholder:n="Select date...",size:e="md",disabled:l=!1,clearable:i=!1,minDate:c,maxDate:d,formatDate:p,id:b
|
|
1201
|
+
`,Js=["January","February","March","April","May","June","July","August","September","October","November","December"],Xs=["Su","Mo","Tu","We","Th","Fr","Sa"];function fo(o,r){return new Date(o,r+1,0).getDate()}function Zs(o,r){return new Date(o,r,1).getDay()}function $o(o,r){return o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate()}function Qs(o,r,n){if(r){const e=new Date(r.getFullYear(),r.getMonth(),r.getDate());if(o<e)return!0}if(n){const e=new Date(n.getFullYear(),n.getMonth(),n.getDate());if(o>e)return!0}return!1}function on(o){return o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function rn(o){return o.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}function Po({value:o=null,onChange:r,placeholder:n="Select date...",size:e="md",disabled:l=!1,clearable:i=!1,minDate:c,maxDate:d,formatDate:p,id:$,error:b}){const w=a.useId(),x=$??w,f=new Date,[y,h]=a.useState(!1),[j,I]=a.useState(()=>(o??f).getFullYear()),[v,g]=a.useState(()=>(o??f).getMonth()),k=a.useRef(null);a.useEffect(()=>{if(!y)return;const u=O=>{k.current&&!k.current.contains(O.target)&&h(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[y]),a.useEffect(()=>{o&&(I(o.getFullYear()),g(o.getMonth()))},[o]);const z=o?p?p(o):on(o):"",S=u=>{r?.(new Date(j,v,u)),h(!1)},C=u=>{u.stopPropagation(),r?.(null)},T=()=>{v===0?(g(11),I(u=>u-1)):g(u=>u-1)},D=()=>{v===11?(g(0),I(u=>u+1)):g(u=>u+1)},M=fo(j,v),R=Zs(j,v),E=[],P=fo(v===0?j-1:j,v===0?11:v-1);for(let u=R-1;u>=0;u--)E.push({day:P-u,currentMonth:!1});for(let u=1;u<=M;u++)E.push({day:u,currentMonth:!0});const V=42-E.length;for(let u=1;u<=V;u++)E.push({day:u,currentMonth:!1});return t.jsxs(Bs,{ref:k,children:[t.jsxs(Rs,{id:x,$size:e,$error:!!b,$disabled:l,role:"combobox","aria-haspopup":"true","aria-expanded":y,tabIndex:l?-1:0,onClick:()=>{l||h(u=>!u)},onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&!l&&(u.preventDefault(),h(O=>!O)),u.key==="Escape"&&h(!1)},children:[t.jsx(Vs,{$hasValue:!!o,children:z||n}),i&&o?t.jsx(As,{type:"button",onClick:C,"aria-label":"Clear date",children:t.jsx(Q,{size:14})}):t.jsx(_s,{"aria-hidden":"true",children:t.jsx(ar,{size:14})})]}),typeof b=="string"&&t.jsx(Ys,{$error:!0,children:b}),y&&t.jsxs(Hs,{role:"dialog","aria-label":"Calendar",children:[t.jsxs(qs,{children:[t.jsx(uo,{type:"button",onClick:T,"aria-label":"Previous month",children:t.jsx(dr,{size:16})}),t.jsxs(Us,{children:[Js[v]," ",j]}),t.jsx(uo,{type:"button",onClick:D,"aria-label":"Next month",children:t.jsx(pr,{size:16})})]}),t.jsxs(Ks,{children:[Xs.map(u=>t.jsx(Gs,{children:u},u)),E.map((u,O)=>{if(!u.currentMonth)return t.jsx(po,{type:"button",$currentMonth:!1,$selected:!1,$today:!1,disabled:!0,tabIndex:-1,children:u.day},O);const F=new Date(j,v,u.day),L=o?$o(F,o):!1,U=$o(F,f),K=Qs(F,c,d);return t.jsx(po,{type:"button",$currentMonth:!0,$selected:L,$today:U,disabled:K,"aria-label":rn(F),"aria-pressed":L,onClick:()=>S(u.day),children:u.day},O)})]})]})]})}Po.displayName="DatePicker";function sn(o){const r=parseInt(o.slice(1,3),16)/255,n=parseInt(o.slice(3,5),16)/255,e=parseInt(o.slice(5,7),16)/255,l=c=>c<=.03928?c/12.92:((c+.055)/1.055)**2.4;return .2126*l(r)+.7152*l(n)+.0722*l(e)>.179?"#111111":"#ffffff"}const q={colors:{primary:{50:"#fffde6",500:"#ffd000",700:"#ffd000",contrast:"#111111"},neutral:{0:"#ffffff",100:"#f5f0e8",200:"#e8e3db",300:"#ccc8c0",400:"#a8a49c",500:"#706c64",600:"#3c3830",900:"#111111"},error:{50:"#fff0f0",500:"#ff3333"},success:{50:"#f0fff4",500:"#00cc44"},warning:{50:"#fffbe6",500:"#ff9900"},info:{50:"#f0f0ff",500:"#3333ff"}},spacing:{1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px"},radius:{md:"2px"},zIndex:{modal:1e3,toast:1100},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px"},shadows:{focusRing:"3px 3px 0 #111111"},brutalism:{borderWidth:"2px",shadowOffset:"4px"}};function nn(o){return{...q,colors:{...q.colors,primary:{50:"#fffff0",500:o,700:o,contrast:sn(o)}}}}function tn({theme:o=q,children:r}){return t.jsx(s.ThemeProvider,{theme:o,children:r})}const en=s.createGlobalStyle`
|
|
1202
1202
|
*, *::before, *::after {
|
|
1203
1203
|
box-sizing: border-box;
|
|
1204
1204
|
margin: 0;
|