blunt-ui 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -12
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Table/Table.types.d.ts +3 -0
- package/dist/components/Table/stories/Table.stories.d.ts +1 -5
- package/dist/index.cjs +93 -50
- package/dist/index.js +918 -866
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("styled-components"),a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),s=require("styled-components"),a=require("react"),fo=require("react-dom"),no=(o,r,n)=>s.css`
|
|
2
2
|
background: ${r};
|
|
3
3
|
color: ${n};
|
|
4
4
|
border: ${o.brutalism.borderWidth} solid ${o.colors.neutral[900]};
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
font-size: ${r.fontSizes.sm};
|
|
24
24
|
`})[o]}
|
|
25
25
|
|
|
26
|
-
${({$variant:o,theme:r})=>r.brutalism?{primary:
|
|
26
|
+
${({$variant:o,theme:r})=>r.brutalism?{primary:no(r,r.colors.primary[500],r.colors.primary.contrast),neutral:no(r,r.colors.neutral[200],r.colors.neutral[900]),success:no(r,r.colors.success[50],r.colors.success[500]),error:no(r,r.colors.error[50],r.colors.error[500]),warning:no(r,r.colors.warning[50],r.colors.warning[500]),info:no(r,r.colors.info[50],r.colors.info[500])}[o]:{primary:s.css`
|
|
27
27
|
background: ${r.colors.primary[50]};
|
|
28
28
|
color: ${r.colors.primary[500]};
|
|
29
29
|
`,neutral:s.css`
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
background: ${r.colors.info[50]};
|
|
43
43
|
color: ${r.colors.info[500]};
|
|
44
44
|
`}[o]}
|
|
45
|
-
`;function
|
|
45
|
+
`;function Lo({variant:o="primary",size:r="md",children:n,...e}){return t.jsx(fr,{$variant:o,$size:r,...e,children:n})}Lo.displayName="Badge";const $o=(o,r,n)=>s.css`
|
|
46
46
|
background-color: ${r};
|
|
47
47
|
color: ${n};
|
|
48
48
|
border: ${o.brutalism.borderWidth} solid ${o.colors.neutral[900]};
|
|
@@ -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
|
|
110
|
+
`;function co({ref:o,as:r,href:n,variant:e="primary",size:i="md",isLoading:l,disabled:d,children:f,...u}){const p=r??(n?"a":"button");return t.jsx(pr,{ref:o,as:p,href:n,$variant:e,$size:i,disabled:l||d,...u,children:l?"Loading...":f})}co.displayName="Button";const $r=s.div`
|
|
111
111
|
display: flex;
|
|
112
112
|
flex-direction: column;
|
|
113
113
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
cursor: not-allowed;
|
|
172
172
|
opacity: 0.6;
|
|
173
173
|
}
|
|
174
|
-
`,
|
|
174
|
+
`,zo=s.div`
|
|
175
175
|
display: inline-flex;
|
|
176
176
|
align-items: center;
|
|
177
177
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
@@ -188,7 +188,7 @@
|
|
|
188
188
|
&:hover {
|
|
189
189
|
opacity: 0.8;
|
|
190
190
|
}
|
|
191
|
-
`;function
|
|
191
|
+
`;function No({ref:o,type:r="text",size:n="md",variant:e="default",label:i,helperText:l,error:d,leftElement:f,rightElement:u,clearable:p,onClear:g,fullWidth:w,id:v,value:y,defaultValue:k,onChange:j,...W}){const O=a.useId(),E=v??O,x=`${E}-hint`,[z,m]=a.useState(k??""),b=y!==void 0,S=b?y:z,I=typeof d=="string"?d:void 0,C=!!(l||d),M=F=>{b||m(F.target.value),j?.(F)},L=()=>{b||m(""),g?.()};return t.jsxs($r,{$fullWidth:w,children:[i&&t.jsx(gr,{htmlFor:E,children:i}),t.jsxs(xr,{$size:n,$variant:e,$error:!!d,children:[f&&t.jsx(zo,{children:f}),t.jsx(yr,{id:E,ref:o,type:r,value:S,onChange:M,...W,"aria-invalid":!!d,"aria-describedby":C?x:void 0}),p&&S&&t.jsx(hr,{type:"button",onClick:L,"aria-label":"Clear input",children:"✕"}),u&&t.jsx(zo,{children:u})]}),C&&t.jsx(br,{id:x,$error:!!d,children:I??l})]})}No.displayName="Input";const mr=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 Fo({ref:o,size:r="md",variant:n="default",label:e,helperText:i,error:l,fullWidth:d,id:f,value:u,defaultValue:p,onChange
|
|
256
|
+
`;function Fo({ref:o,size:r="md",variant:n="default",label:e,helperText:i,error:l,fullWidth:d,id:f,value:u,defaultValue:p,onChange:g,...w}){const v=a.useId(),y=f??v,k=`${y}-hint`,[j,W]=a.useState(p??""),O=u!==void 0,E=O?u:j,x=typeof l=="string"?l:void 0,z=!!(i||l),m=b=>{O||W(b.target.value),g?.(b)};return t.jsxs(mr,{$fullWidth:d,children:[e&&t.jsx(wr,{htmlFor:y,children:e}),t.jsx(kr,{$size:r,$variant:n,$error:!!l,children:t.jsx(Sr,{id:y,ref:o,value:E,onChange:m,...w,"aria-invalid":!!l,"aria-describedby":z?k:void 0})}),z&&t.jsx(vr,{id:k,$error:!!l,children:x??i})]})}Fo.displayName="Textarea";const Bo=(...o)=>o.filter((r,n,e)=>!!r&&r.trim()!==""&&e.indexOf(r)===n).join(" ").trim();const jr=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const zr=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,n,e)=>e?e.toUpperCase():n.toLowerCase());const Co=o=>{const r=zr(o);return r.charAt(0).toUpperCase()+r.slice(1)};var go={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 Cr=o=>{for(const r in o)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1},Ir=a.createContext({}),Tr=()=>a.useContext(Ir),Dr=a.forwardRef(({color:o,size:r,strokeWidth:n,absoluteStrokeWidth:e,className:i="",children:l,iconNode:d,...f},u)=>{const{size:p=24,strokeWidth:g=2,absoluteStrokeWidth:w=!1,color:v="currentColor",className:y=""}=Tr()??{},k=e??w?Number(n??g)*24/Number(r??p):n??g;return a.createElement("svg",{ref:u,...go,width:r??p??go.width,height:r??p??go.height,stroke:o??v,strokeWidth:k,className:Bo("lucide",y,i),...!l&&!Cr(f)&&{"aria-hidden":"true"},...f},[...d.map(([j,W])=>a.createElement(j,W)),...Array.isArray(l)?l:[l]])});const G=(o,r)=>{const n=a.forwardRef(({className:e,...i},l)=>a.createElement(Dr,{ref:l,iconNode:r,className:Bo(`lucide-${jr(Co(o))}`,`lucide-${o}`,e),...i}));return n.displayName=Co(o),n};const Wr=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Er=G("arrow-down",Wr);const Mr=[["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"}]],Or=G("arrow-up-down",Mr);const Rr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Pr=G("arrow-up",Rr);const Lr=[["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"}]],Nr=G("calendar",Lr);const Fr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Vo=G("chevron-down",Fr);const Br=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vr=G("chevron-left",Br);const Ar=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_r=G("chevron-right",Ar);const Hr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],po=G("x",Hr),Yr=s.div`
|
|
257
257
|
display: inline-flex;
|
|
258
258
|
flex-direction: column;
|
|
259
259
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -426,7 +426,7 @@
|
|
|
426
426
|
outline-offset: 2px;
|
|
427
427
|
border-radius: 2px;
|
|
428
428
|
}
|
|
429
|
-
`;function Ao({options:o,placeholder:r,size:n="md",variant:e="default",error:i,fullWidth:l,clearable:d,onClear:f,id:u,name:p,value
|
|
429
|
+
`;function Ao({options:o,placeholder:r,size:n="md",variant:e="default",error:i,fullWidth:l,clearable:d,onClear:f,id:u,name:p,value:g,defaultValue:w,onChange:v,disabled:y,searchable:k,"aria-label":j,"aria-describedby":W}){const O=a.useId(),E=u??O,x=`${E}-list`,z=`${E}-search`,m=typeof i=="string"?i:void 0,[b,S]=a.useState(!1),[I,C]=a.useState(-1),[M,L]=a.useState(""),[F,P]=a.useState({top:0,left:0,width:0}),[A,oo]=a.useState(w??""),D=g!==void 0,V=D?g:A,ro=a.useRef(null),_=a.useRef(null),X=a.useRef(null),U=a.useRef(null),so=o.find(c=>c.value===V),B=k&&M?o.filter(c=>c.label.toLowerCase().includes(M.toLowerCase())):o,H=a.useCallback(()=>{if(!_.current)return;const c=_.current.getBoundingClientRect();P({top:c.bottom+4,left:c.left,width:c.width})},[]);a.useEffect(()=>{if(b)return H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[b,H]),a.useEffect(()=>{if(!b)return;const c=T=>{const Y=ro.current?.contains(T.target),io=X.current?.contains(T.target);!Y&&!io&&S(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[b]),a.useEffect(()=>{b&&k&&setTimeout(()=>U.current?.focus(),0),b||(L(""),C(-1))},[b,k]),a.useEffect(()=>{C(-1)},[M]),a.useEffect(()=>{if(I<0)return;const c=document.getElementById(`${x}-option-${I}`);c&&typeof c.scrollIntoView=="function"&&c.scrollIntoView({block:"nearest"})},[I,x]);function q(c,T){let Y=c+T;for(;Y>=0&&Y<B.length;){if(!B[Y].disabled)return Y;Y+=T}return c}function K(){return B.findIndex(c=>!c.disabled)}function J(){for(let c=B.length-1;c>=0;c--)if(!B[c].disabled)return c;return-1}function Q(c){if(c.disabled)return;D||oo(c.value);const T={target:{name:p??"",value:c.value},currentTarget:{name:p??"",value:c.value}};v?.(T),S(!1),_.current?.focus()}function h(c){c.stopPropagation(),D||oo(""),v?.({target:{name:p??"",value:""},currentTarget:{name:p??"",value:""}}),f?.(),_.current?.focus()}function N(c){if(!y){if(!b){["ArrowDown","ArrowUp","Enter"," "].includes(c.key)&&(c.preventDefault(),S(!0),k||C(K()));return}if(c.key==="Escape"){c.preventDefault(),S(!1);return}if(!k){if(c.key==="ArrowDown"){c.preventDefault(),C(T=>q(T,1));return}if(c.key==="ArrowUp"){c.preventDefault(),C(T=>q(T,-1));return}if(c.key==="Home"){c.preventDefault(),C(K());return}if(c.key==="End"){c.preventDefault(),C(J());return}(c.key==="Enter"||c.key===" ")&&I>=0&&(c.preventDefault(),Q(B[I]))}}}function Z(c){if(c.key==="Escape"){S(!1),_.current?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),C(T=>T<0?K():q(T,1));return}if(c.key==="ArrowUp"){c.preventDefault(),C(T=>T<0?J():q(T,-1));return}c.key==="Enter"&&I>=0&&(c.preventDefault(),Q(B[I]))}const $=d&&!!V&&!y,R=I>=0?`${x}-option-${I}`:void 0;return t.jsxs(Yr,{ref:ro,$fullWidth:l,children:[t.jsxs(Ur,{"aria-hidden":"true",children:[r&&t.jsx(bo,{children:r}),o.map(c=>t.jsx(bo,{children:c.label},c.value))]}),t.jsxs(qr,{ref:_,id:E,type:"button",role:"combobox","aria-expanded":b,"aria-haspopup":"listbox","aria-controls":b?x:void 0,"aria-activedescendant":b&&!k?R:void 0,"aria-invalid":!!i,"aria-label":j,"aria-describedby":W,$size:n,$variant:e,$error:!!i,$disabled:y,$open:b,disabled:y,onClick:()=>!y&&S(c=>!c),onKeyDown:N,children:[t.jsx(bo,{$placeholder:!so,children:so?.label??r??"Select..."}),t.jsxs(Kr,{children:[$&&t.jsx(ss,{type:"button",onClick:h,"aria-label":"Clear selection",children:t.jsx(po,{size:14})}),t.jsx(Gr,{$open:b,"aria-hidden":"true",children:t.jsx(Vo,{size:14})})]})]}),b&&fo.createPortal(t.jsxs(Xr,{ref:X,id:x,role:"listbox","aria-label":r??"Options",style:{position:"fixed",top:F.top,left:F.left,width:F.width},children:[k&&t.jsx(Jr,{children:t.jsx(Qr,{ref:U,id:z,type:"text",placeholder:"Search...",value:M,onChange:c=>L(c.target.value),onKeyDown:Z,"aria-label":"Search options","aria-controls":x,"aria-activedescendant":R})}),B.length===0&&t.jsx(Zr,{children:"No options found"}),B.map((c,T)=>t.jsx(os,{id:`${x}-option-${T}`,role:"option","aria-selected":c.value===V,"aria-disabled":c.disabled,$selected:c.value===V,$focused:T===I,$disabled:c.disabled,onClick:()=>Q(c),onMouseEnter:()=>!c.disabled&&C(T),children:c.label},c.value))]}),document.body),m&&t.jsx(rs,{$error:!0,children:m})]})}Ao.displayName="Select";const Io=s.span`
|
|
430
430
|
display: inline-block;
|
|
431
431
|
`,ns=s.span`
|
|
432
432
|
display: inline-block;
|
|
@@ -485,7 +485,7 @@
|
|
|
485
485
|
border: 1px solid ${o.colors.primary[500]};
|
|
486
486
|
box-shadow: ${o.shadows.focusRing};
|
|
487
487
|
`}
|
|
488
|
-
`;function _o({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:i,placeholder:l="Click to edit",disabled:d=!1}){const f=o!==void 0,[u,p]=a.useState(r)
|
|
488
|
+
`;function _o({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:i,placeholder:l="Click to edit",disabled:d=!1}){const f=o!==void 0,[u,p]=a.useState(r),g=f?o:u,[w,v]=a.useState(!1),[y,k]=a.useState(""),j=a.useRef(null),W=()=>{d||(k(g),v(!0),setTimeout(()=>{j.current?.focus(),j.current?.select()},0))},O=()=>{f||p(y),n?.(y),e?.(y),v(!1)},E=()=>{i?.(g),v(!1)},x=z=>{z.key==="Enter"?O():z.key==="Escape"&&E()};return w?t.jsx(Io,{children:t.jsx(ts,{ref:j,value:y,size:Math.max(y.length,l.length,10),onChange:z=>k(z.target.value),onBlur:O,onKeyDown:x,"aria-label":"Edit value"})}):t.jsx(Io,{children:t.jsx(ns,{role:d?void 0:"button",tabIndex:d?void 0:0,$disabled:d,$empty:!g,onClick:W,onKeyDown:z=>z.key==="Enter"&&W(),children:g||l})})}_o.displayName="Editable";const es=s.a`
|
|
489
489
|
text-decoration: underline;
|
|
490
490
|
text-underline-offset: 2px;
|
|
491
491
|
transition: color 0.15s;
|
|
@@ -616,7 +616,7 @@
|
|
|
616
616
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
617
617
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
618
618
|
flex-shrink: 0;
|
|
619
|
-
`,ms=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function To(o){return Array.from(o.querySelectorAll(ms))}function wo({open:o,onClose:r,title:n,children:e,footer:i,size:l="md",closeOnBackdrop:d=!0,closeOnEscape:f=!0,ariaLabelledBy:u,ariaDescribedBy:p}){const
|
|
619
|
+
`,ms=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function To(o){return Array.from(o.querySelectorAll(ms))}function wo({open:o,onClose:r,title:n,children:e,footer:i,size:l="md",closeOnBackdrop:d=!0,closeOnEscape:f=!0,ariaLabelledBy:u,ariaDescribedBy:p}){const g=a.useRef(null),w=a.useRef(null),v=a.useRef(r);v.current=r;const y=a.useId(),k=u??(n?y:void 0),[j,W]=a.useState(o),[O,E]=a.useState(!1);return a.useEffect(()=>{if(o)W(!0),E(!1);else if(j){E(!0);const x=setTimeout(()=>{W(!1),E(!1)},150);return()=>clearTimeout(x)}},[o,j]),a.useEffect(()=>{if(!o)return;const x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x}},[o]),a.useEffect(()=>{if(!o||!g.current)return;const x=g.current,z=document.activeElement;(To(x)[0]??x).focus();const b=S=>{if(S.key==="Escape"&&f){v.current();return}if(S.key!=="Tab")return;const I=To(x);if(I.length===0){S.preventDefault();return}const C=I[0],M=I[I.length-1];S.shiftKey?document.activeElement===C&&(S.preventDefault(),M.focus()):document.activeElement===M&&(S.preventDefault(),C.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),z?.focus()}},[o,f,j]),j?fo.createPortal(t.jsx(ps,{$closing:O,onMouseDown:x=>{w.current=x.target},onClick:x=>{d&&w.current===x.currentTarget&&r()},children:t.jsxs($s,{ref:g,role:"dialog","aria-modal":"true","aria-labelledby":k,"aria-describedby":p,$size:l,$closing:O,tabIndex:-1,onClick:x=>x.stopPropagation(),children:[t.jsxs(gs,{children:[n&&t.jsx(bs,{id:y,children:n}),t.jsx(xs,{onClick:r,"aria-label":"Close modal",children:"×"})]}),t.jsx(ys,{children:e}),i&&t.jsx(hs,{children:i})]})}),document.body):null}wo.displayName="Modal";const Yo=s.keyframes`
|
|
620
620
|
from { opacity: 0; transform: translateY(12px); }
|
|
621
621
|
to { opacity: 1; transform: translateY(0); }
|
|
622
622
|
`,Uo=s.keyframes`
|
|
@@ -625,12 +625,12 @@
|
|
|
625
625
|
`,qo=s.keyframes`
|
|
626
626
|
from { opacity: 1; }
|
|
627
627
|
to { opacity: 0; }
|
|
628
|
-
`,
|
|
628
|
+
`,ao=(o,r,n)=>s.css`
|
|
629
629
|
background: ${r};
|
|
630
630
|
border: ${o.brutalism.borderWidth} solid ${n};
|
|
631
631
|
box-shadow: ${o.brutalism.shadowOffset} ${o.brutalism.shadowOffset}
|
|
632
632
|
0 ${n};
|
|
633
|
-
`;function Ko(o,r){return r.brutalism?{success:
|
|
633
|
+
`;function Ko(o,r){return r.brutalism?{success:ao(r,r.colors.success[50],r.colors.success[500]),error:ao(r,r.colors.error[50],r.colors.error[500]),warning:ao(r,r.colors.warning[50],r.colors.warning[500]),info:ao(r,r.colors.info[50],r.colors.info[500])}[o]:{success:s.css`
|
|
634
634
|
background: ${r.colors.success[50]};
|
|
635
635
|
border-left: ${r.spacing[1]} solid ${r.colors.success[500]};
|
|
636
636
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
@@ -748,7 +748,7 @@
|
|
|
748
748
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
749
749
|
outline-offset: 2px;
|
|
750
750
|
}
|
|
751
|
-
`;function Qo({open:o,onClose:r,message:n,variant:e="info",duration:i=4e3,position:l="bottom-right"}){const[d,f]=a.useState(o),[u,p]=a.useState(!1);return a.useEffect(()=>{if(o)f(!0),p(!1);else if(d){p(!0);const
|
|
751
|
+
`;function Qo({open:o,onClose:r,message:n,variant:e="info",duration:i=4e3,position:l="bottom-right"}){const[d,f]=a.useState(o),[u,p]=a.useState(!1);return a.useEffect(()=>{if(o)f(!0),p(!1);else if(d){p(!0);const g=setTimeout(()=>{f(!1),p(!1)},200);return()=>{clearTimeout(g)}}},[o,d]),a.useEffect(()=>{if(!o||i===0)return;const g=setTimeout(r,i);return()=>{clearTimeout(g)}},[o,i,r]),d?fo.createPortal(t.jsxs(vs,{$position:l,$variant:e,$closing:u,role:"alert","aria-live":"polite",children:[t.jsx(Xo,{children:n}),t.jsx(Jo,{onClick:r,"aria-label":"Close notification",children:t.jsx(po,{size:14,strokeWidth:2.5})})]}),document.body):null}Qo.displayName="Toast";const Zo=a.createContext(null),Do=5,js="bottom-right";function zs({toast:o,isTop:r,onClose:n}){return a.useEffect(()=>{const e=o.duration??4e3;if(e===0)return;const i=setTimeout(()=>n(o.id),e);return()=>clearTimeout(i)},[o.id,o.duration,n]),t.jsxs(ks,{$variant:o.variant??"info",$closing:o.closing,$isTop:r,role:"alert","aria-live":"polite",children:[t.jsx(Xo,{children:o.message}),t.jsx(Jo,{onClick:()=>n(o.id),"aria-label":"Close notification",children:t.jsx(po,{size:14,strokeWidth:2.5})})]})}function Cs({children:o}){const[r,n]=a.useState([]),e=a.useCallback(u=>{n(p=>p.map(g=>g.id===u?{...g,closing:!0}:g)),setTimeout(()=>{n(p=>p.filter(g=>g.id!==u))},200)},[]),i=a.useCallback(u=>{const p=Date.now();n(g=>{const w=[...g,{...u,id:p,closing:!1}];return w.length>Do?w.slice(w.length-Do):w})},[]),l=a.useMemo(()=>Object.assign(u=>i(u),{success:(u,p)=>i({...p,message:u,variant:"success"}),error:(u,p)=>i({...p,message:u,variant:"error"}),warning:(u,p)=>i({...p,message:u,variant:"warning"}),info:(u,p)=>i({...p,message:u,variant:"info"})}),[i]),d=r[r.length-1]?.position??js,f=d.startsWith("top");return t.jsxs(Zo.Provider,{value:{toast:l},children:[o,r.length>0&&fo.createPortal(t.jsx(Ss,{$position:d,children:r.map(u=>t.jsx(zs,{toast:u,isTop:f,onClose:e},u.id))}),document.body)]})}function Is(){const o=a.useContext(Zo);if(!o)throw new Error("useToast must be used within a ToastProvider");return o}const Ts=s.form`
|
|
752
752
|
display: flex;
|
|
753
753
|
flex-direction: column;
|
|
754
754
|
gap: ${({theme:o})=>o.spacing[4]};
|
|
@@ -766,7 +766,7 @@
|
|
|
766
766
|
`,Ms=s.span`
|
|
767
767
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
768
768
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
769
|
-
`;function vo({label:o,error:r,helperText:n,required:e,children:i}){const l=a.useId(),d=`${l}-hint`,f=!!(r||n),u=typeof r=="string"?r:void 0,p=a.isValidElement(i)?a.cloneElement(i,{id:l,...f&&{"aria-describedby":d},...r&&{"aria-invalid":!0}}):i;return t.jsxs(Ds,{children:[o&&t.jsxs(Ws,{htmlFor:l,children:[o,e&&t.jsx(Es,{"aria-hidden":"true",children:" *"})]}),p,f&&t.jsx(Ms,{id:d,$error:!!r,children:u??n})]})}vo.displayName="FormField";function Os({initialValues:o,validate:r,onSubmit:n,onError:e}){const[i,l]=a.useState(o),[d,f]=a.useState({}),[u,p]=a.useState({}),[
|
|
769
|
+
`;function vo({label:o,error:r,helperText:n,required:e,children:i}){const l=a.useId(),d=`${l}-hint`,f=!!(r||n),u=typeof r=="string"?r:void 0,p=a.isValidElement(i)?a.cloneElement(i,{id:l,...f&&{"aria-describedby":d},...r&&{"aria-invalid":!0}}):i;return t.jsxs(Ds,{children:[o&&t.jsxs(Ws,{htmlFor:l,children:[o,e&&t.jsx(Es,{"aria-hidden":"true",children:" *"})]}),p,f&&t.jsx(Ms,{id:d,$error:!!r,children:u??n})]})}vo.displayName="FormField";function Os({initialValues:o,validate:r,onSubmit:n,onError:e}){const[i,l]=a.useState(o),[d,f]=a.useState({}),[u,p]=a.useState({}),[g,w]=a.useState(!1),v=a.useRef(i);v.current=i;const y=a.useCallback(m=>{if(!r)return{};const b=r(m);return Object.fromEntries(Object.entries(b).filter(([,S])=>S!==void 0))},[r]),k=a.useRef(u);k.current=u;const j=a.useCallback(m=>{const{name:b,value:S}=m.target;process.env.NODE_ENV!=="production"&&!b&&console.warn("[useForm] handleChange: field is missing a `name` attribute — value will not be tracked.");const I={...v.current,[b]:S};l(I),k.current[b]&&f(y(I))},[y]),W=a.useCallback(m=>{const{name:b}=m.target;process.env.NODE_ENV!=="production"&&!b&&console.warn("[useForm] handleBlur: field is missing a `name` attribute — touched state will not be tracked."),p(S=>({...S,[b]:!0})),f(y(v.current))},[y]),O=a.useCallback(m=>{m?.preventDefault();const b=Object.keys(v.current).reduce((C,M)=>({...C,[M]:!0}),{});p(b);const S=y(v.current);if(f(S),Object.keys(S).length>0){e?.(S);return}(async()=>{w(!0);try{await n?.(v.current)}finally{w(!1)}})()},[y,n,e]),E=a.useCallback((m,b)=>{l(S=>({...S,[m]:b}))},[]),x=a.useCallback(m=>{l(m??o),f({}),p({}),w(!1)},[o]),z=Object.fromEntries(Object.entries(d).filter(([m])=>u[m]));return{values:i,errors:z,touched:u,handleChange:j,handleBlur:W,handleSubmit:O,setFieldValue:E,reset:x,isSubmitting:g}}const Rs=(o="Required")=>r=>{if(!r.trim())return o},Ps=(o,r)=>n=>{if(n.length<o)return r??`Must be at least ${o} characters`},Ls=(o,r)=>n=>{if(n.length>o)return r??`Must be at most ${o} characters`},Ns=(o="Enter a valid email")=>r=>{if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r))return o},Fs=(o="Enter a valid URL")=>r=>{try{new URL(r);return}catch{return o}},Bs=(o,r)=>n=>{if(!o.test(n))return r};function Vs(...o){return r=>{for(const n of o){const e=n(r);if(e!==void 0)return e}}}const As=s.div`
|
|
770
770
|
display: flex;
|
|
771
771
|
flex-direction: column;
|
|
772
772
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -827,7 +827,7 @@
|
|
|
827
827
|
`,qs=s.span`
|
|
828
828
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
829
829
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
830
|
-
`;function rr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:f,color:u,borderColor:p,checkColor
|
|
830
|
+
`;function rr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:f,color:u,borderColor:p,checkColor:g,...w}){const v=a.useId(),y=f??v,k=typeof e=="string"?e:void 0,j=!!(i||e);return t.jsxs(As,{children:[t.jsxs(_s,{htmlFor:y,$disabled:l,children:[t.jsx(Hs,{id:y,ref:o,type:"checkbox",checked:d,disabled:l,"aria-invalid":!!e,...w}),t.jsx(Ys,{$checked:d,$error:!!e,$disabled:l,$size:n,$color:u,$borderColor:p,$checkColor:g}),r&&t.jsx(Us,{$size:n,children:r})]}),j&&t.jsx(qs,{$error:!!e,children:k??i})]})}rr.displayName="Checkbox";const Ks=s.div`
|
|
831
831
|
display: flex;
|
|
832
832
|
flex-direction: column;
|
|
833
833
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -886,7 +886,7 @@
|
|
|
886
886
|
`,Zs=s.span`
|
|
887
887
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
888
888
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
889
|
-
`;function sr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:f,color:u,borderColor:p
|
|
889
|
+
`;function sr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:f,color:u,borderColor:p,...g}){const w=a.useId(),v=f??w,y=!!(i||e);return t.jsxs(Ks,{children:[t.jsxs(Gs,{htmlFor:v,$disabled:l,children:[t.jsx(Xs,{id:v,ref:o,type:"radio",checked:d,disabled:l,"aria-invalid":!!e,...g}),t.jsx(Js,{$checked:d,$error:e,$disabled:l,$size:n,$color:u,$borderColor:p}),r&&t.jsx(Qs,{$size:n,children:r})]}),y&&t.jsx(Zs,{$error:e,children:i})]})}sr.displayName="Radio";const on=s.div`
|
|
890
890
|
display: flex;
|
|
891
891
|
flex-direction: column;
|
|
892
892
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -955,7 +955,7 @@
|
|
|
955
955
|
`,tn=s.span`
|
|
956
956
|
font-size: ${({$size:o="md",theme:r})=>o==="sm"?r.fontSizes.sm:r.fontSizes.md};
|
|
957
957
|
font-weight: ${({theme:o})=>o.fontWeights.medium};
|
|
958
|
-
`;function nr({ref:o,label:r,size:n="md",disabled:e,checked:i,id:l,color:d,borderColor:f,...u}){const p=a.useId()
|
|
958
|
+
`;function nr({ref:o,label:r,size:n="md",disabled:e,checked:i,id:l,color:d,borderColor:f,...u}){const p=a.useId(),g=l??p;return t.jsx(on,{children:t.jsxs(rn,{htmlFor:g,$disabled:e,children:[t.jsx(sn,{id:g,ref:o,type:"checkbox",role:"switch",checked:i,disabled:e,...u}),t.jsx(nn,{$checked:i,$size:n,$color:d,$borderColor:f}),r&&t.jsx(tn,{$size:n,children:r})]})})}nr.displayName="Switch";const en=s.div`
|
|
959
959
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
960
960
|
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
961
961
|
overflow: hidden;
|
|
@@ -1035,7 +1035,7 @@
|
|
|
1035
1035
|
`,bn=s.div`
|
|
1036
1036
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
1037
1037
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
1038
|
-
`;function tr({title:o,children:r,defaultOpen:n=!1,open:e,onToggle:i,subtitle:l,headerActions:d,accentColor:f}){const[u,p]=a.useState(n)
|
|
1038
|
+
`;function tr({title:o,children:r,defaultOpen:n=!1,open:e,onToggle:i,subtitle:l,headerActions:d,accentColor:f}){const[u,p]=a.useState(n),g=a.useId(),w=e!==void 0,v=w?e:u,y=()=>{const k=!v;w||p(k),i?.(k)};return t.jsxs(en,{$accentColor:f,children:[t.jsxs(an,{type:"button",$open:v,$accentColor:f,"aria-expanded":v,"aria-controls":g,onClick:y,children:[t.jsxs(ln,{children:[t.jsx(cn,{children:o}),(l||d)&&t.jsxs(un,{children:[l&&t.jsx(dn,{children:l}),d&&t.jsx(fn,{onClick:k=>k.stopPropagation(),children:d})]})]}),t.jsx(pn,{$open:v,$accentColor:f,"aria-hidden":"true",children:t.jsx(Vo,{size:18,strokeWidth:2.5})})]}),t.jsx($n,{$open:v,children:t.jsx(gn,{id:g,role:"region","aria-label":o,children:t.jsx(bn,{children:r})})})]})}tr.displayName="CollapsibleCard";const xn=s.keyframes`
|
|
1039
1039
|
to { transform: rotate(360deg); }
|
|
1040
1040
|
`,yn={sm:"16px",md:"24px",lg:"40px"},hn={thin:"2px",normal:"3px",bold:"5px"},mn=s.span`
|
|
1041
1041
|
display: inline-block;
|
|
@@ -1048,7 +1048,7 @@
|
|
|
1048
1048
|
border: ${l} solid ${d};
|
|
1049
1049
|
border-top-color: ${f};
|
|
1050
1050
|
`}}
|
|
1051
|
-
`;function er({size:o="md",weight:r="normal",color:n,label:e="Loading..."}){return t.jsx(mn,{$size:o,$weight:r,$color:n,role:"status","aria-label":e})}er.displayName="Spinner";const wn=7,Wo=3,Eo=1;function vn({defaultSort:o,defaultPage:r=1}={}){const[n,e]=a.useState(o??null),[i,l]=a.useState(r);return{sort:n,page:i,onSortChange:u=>{e(u),l(1)},onPageChange:u=>{l(u)}}}function kn(o,r){return o?.key!==r?{key:r,direction:"asc"}:o.direction==="asc"?{key:r,direction:"desc"}:null}function Sn({data:o,sort:r,defaultSort:n,onSortChange:e}){const i=r!==void 0,[l,d]=a.useState(n??null),f=i?r??null:l,u
|
|
1051
|
+
`;function er({size:o="md",weight:r="normal",color:n,label:e="Loading..."}){return t.jsx(mn,{$size:o,$weight:r,$color:n,role:"status","aria-label":e})}er.displayName="Spinner";const wn=7,Wo=3,Eo=1;function vn({defaultSort:o,defaultPage:r=1}={}){const[n,e]=a.useState(o??null),[i,l]=a.useState(r);return{sort:n,page:i,onSortChange:u=>{e(u),l(1)},onPageChange:u=>{l(u)}}}function kn(o,r){return o?.key!==r?{key:r,direction:"asc"}:o.direction==="asc"?{key:r,direction:"desc"}:null}function Sn({data:o,sort:r,defaultSort:n,onSortChange:e}){const i=r!==void 0,[l,d]=a.useState(n??null),f=i?r??null:l,u=g=>{const w=kn(f,g);return i||d(w),e?.(w),w},p=a.useMemo(()=>i||!f?o:[...o].sort((g,w)=>{const v=g[f.key],y=w[f.key],k=v<y?-1:v>y?1:0;return f.direction==="asc"?k:-k}),[o,f,i]);return{activeSort:f,sortedData:p,handleSort:u}}function jn(o,r){if(r<=wn)return Array.from({length:r},(e,i)=>i+1);const n=[1];o>Wo&&n.push("...");for(let e=Math.max(2,o-Eo);e<=Math.min(r-1,o+Eo);e++)n.push(e);return o<r-Wo+1&&n.push("..."),n.push(r),n}function zn({data:o,pageSize:r,page:n,defaultPage:e,totalRows:i,onPageChange:l}){const d=n!==void 0,[f,u]=a.useState(e??1),p=d?n:f,g=j=>{d||u(j),l?.(j)},w=i!==void 0,v=i??o.length,y=r?Math.max(1,Math.ceil(v/r)):1,k=a.useMemo(()=>{if(!r||w)return o;const j=(p-1)*r;return o.slice(j,j+r)},[o,r,p,w]);return{activePage:p,totalPages:y,displayData:k,handlePageChange:g}}const ir=(o,r)=>o==="sm"?`${r.spacing[1]} ${r.spacing[2]}`:o==="lg"?`${r.spacing[3]} ${r.spacing[4]}`:`${r.spacing[2]} ${r.spacing[3]}`,Cn=s.div`
|
|
1052
1052
|
width: 100%;
|
|
1053
1053
|
|
|
1054
1054
|
${({theme:o,$borderColor:r})=>o.brutalism?s.css`
|
|
@@ -1063,11 +1063,16 @@
|
|
|
1063
1063
|
overflow: hidden;
|
|
1064
1064
|
`}
|
|
1065
1065
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1066
|
+
${({$stickyPagination:o})=>o?s.css`
|
|
1067
|
+
display: flex;
|
|
1068
|
+
flex-direction: column;
|
|
1069
|
+
`:s.css`
|
|
1070
|
+
overflow-x: auto;
|
|
1071
|
+
`}
|
|
1072
|
+
`,In=s.div`
|
|
1073
|
+
overflow: auto;
|
|
1074
|
+
min-height: 0;
|
|
1075
|
+
`,Tn=s.table`
|
|
1071
1076
|
width: 100%;
|
|
1072
1077
|
border-collapse: collapse;
|
|
1073
1078
|
font-size: ${({$size:o,theme:r})=>({sm:r.fontSizes.sm,md:r.fontSizes.md,lg:r.fontSizes.lg})[o]};
|
|
@@ -1075,7 +1080,7 @@
|
|
|
1075
1080
|
caption {
|
|
1076
1081
|
padding: ${({theme:o})=>o.spacing[2]} 0;
|
|
1077
1082
|
}
|
|
1078
|
-
`,
|
|
1083
|
+
`,Dn=s.thead`
|
|
1079
1084
|
${({$stickyHeader:o})=>o&&s.css`
|
|
1080
1085
|
position: sticky;
|
|
1081
1086
|
top: 0;
|
|
@@ -1095,7 +1100,7 @@
|
|
|
1095
1100
|
--th-text: ${o.colors.neutral[600]};
|
|
1096
1101
|
--th-sep: ${n??o.colors.neutral[300]};
|
|
1097
1102
|
`}
|
|
1098
|
-
`,
|
|
1103
|
+
`,Wn=s.tbody`
|
|
1099
1104
|
${({$rowColor:o})=>o&&s.css`
|
|
1100
1105
|
tr {
|
|
1101
1106
|
background-color: ${o};
|
|
@@ -1115,7 +1120,7 @@
|
|
|
1115
1120
|
tr:hover td {
|
|
1116
1121
|
background-color: rgba(0, 0, 0, 0.04);
|
|
1117
1122
|
}
|
|
1118
|
-
`,
|
|
1123
|
+
`,lo=s.tr``,En=s(lo)`
|
|
1119
1124
|
cursor: pointer;
|
|
1120
1125
|
|
|
1121
1126
|
td {
|
|
@@ -1132,7 +1137,7 @@
|
|
|
1132
1137
|
box-shadow: inset 4px 0 0
|
|
1133
1138
|
${({$accentColor:o,theme:r})=>o??r.colors.neutral[900]};
|
|
1134
1139
|
}
|
|
1135
|
-
`,
|
|
1140
|
+
`,Mn=s.th`
|
|
1136
1141
|
background-color: var(--th-bg);
|
|
1137
1142
|
color: var(--th-text);
|
|
1138
1143
|
text-align: left;
|
|
@@ -1150,7 +1155,7 @@
|
|
|
1150
1155
|
}
|
|
1151
1156
|
`}
|
|
1152
1157
|
`}
|
|
1153
|
-
`,
|
|
1158
|
+
`,On=s.button`
|
|
1154
1159
|
display: inline-flex;
|
|
1155
1160
|
align-items: center;
|
|
1156
1161
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -1169,7 +1174,7 @@
|
|
|
1169
1174
|
outline-offset: 2px;
|
|
1170
1175
|
border-radius: 2px;
|
|
1171
1176
|
}
|
|
1172
|
-
`,
|
|
1177
|
+
`,Rn=s.span`
|
|
1173
1178
|
opacity: 0.5;
|
|
1174
1179
|
display: inline-flex;
|
|
1175
1180
|
align-items: center;
|
|
@@ -1192,16 +1197,16 @@
|
|
|
1192
1197
|
border-bottom: 1px solid
|
|
1193
1198
|
${r??n.colors.neutral[200]};
|
|
1194
1199
|
`}
|
|
1195
|
-
`,
|
|
1200
|
+
`,Pn=s.td`
|
|
1196
1201
|
text-align: center;
|
|
1197
1202
|
color: ${({theme:o})=>o.colors.neutral[400]};
|
|
1198
1203
|
padding: ${({theme:o})=>`${o.spacing[4]} ${o.spacing[3]}`};
|
|
1199
1204
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
1200
1205
|
border-bottom: none;
|
|
1201
|
-
`,
|
|
1206
|
+
`,Ln=s.keyframes`
|
|
1202
1207
|
0% { background-position: -400px 0; }
|
|
1203
1208
|
100% { background-position: 400px 0; }
|
|
1204
|
-
`,Nn=s(ar)``,
|
|
1209
|
+
`,Nn=s(ar)``,Fn=s.div`
|
|
1205
1210
|
height: 14px;
|
|
1206
1211
|
border-radius: 4px;
|
|
1207
1212
|
background: linear-gradient(
|
|
@@ -1211,13 +1216,14 @@
|
|
|
1211
1216
|
${({theme:o})=>o.colors.neutral[200]} 75%
|
|
1212
1217
|
);
|
|
1213
1218
|
background-size: 800px 100%;
|
|
1214
|
-
animation: ${
|
|
1215
|
-
`,
|
|
1219
|
+
animation: ${Ln} 1.6s ease-in-out infinite;
|
|
1220
|
+
`,Bn=s.div`
|
|
1216
1221
|
display: flex;
|
|
1217
1222
|
align-items: center;
|
|
1218
|
-
justify-content: center;
|
|
1223
|
+
justify-content: ${({$hasPageSizeOptions:o})=>o?"space-between":"center"};
|
|
1219
1224
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
1220
1225
|
padding: ${({theme:o})=>`${o.spacing[2]} ${o.spacing[3]}`};
|
|
1226
|
+
flex-shrink: 0;
|
|
1221
1227
|
|
|
1222
1228
|
${({theme:o})=>o.brutalism?s.css`
|
|
1223
1229
|
border-top: ${o.brutalism.borderWidth} solid
|
|
@@ -1225,6 +1231,43 @@
|
|
|
1225
1231
|
`:s.css`
|
|
1226
1232
|
border-top: 1px solid ${o.colors.neutral[200]};
|
|
1227
1233
|
`}
|
|
1234
|
+
`,Vn=s.label`
|
|
1235
|
+
display: flex;
|
|
1236
|
+
align-items: center;
|
|
1237
|
+
gap: ${({theme:o})=>o.spacing[2]};
|
|
1238
|
+
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
1239
|
+
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
1240
|
+
white-space: nowrap;
|
|
1241
|
+
|
|
1242
|
+
select {
|
|
1243
|
+
padding: ${({theme:o})=>`${o.spacing[1]} ${o.spacing[2]}`};
|
|
1244
|
+
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
1245
|
+
font-family: inherit;
|
|
1246
|
+
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
1247
|
+
background-color: ${({theme:o})=>o.colors.neutral[0]};
|
|
1248
|
+
cursor: pointer;
|
|
1249
|
+
|
|
1250
|
+
${({theme:o})=>o.brutalism?s.css`
|
|
1251
|
+
border: ${o.brutalism.borderWidth} solid
|
|
1252
|
+
${o.colors.neutral[900]};
|
|
1253
|
+
`:s.css`
|
|
1254
|
+
border: 1px solid ${o.colors.neutral[300]};
|
|
1255
|
+
border-radius: ${o.radius.md};
|
|
1256
|
+
|
|
1257
|
+
&:hover {
|
|
1258
|
+
border-color: ${o.colors.neutral[400]};
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
&:focus {
|
|
1262
|
+
outline: 2px solid ${o.colors.primary[500]};
|
|
1263
|
+
outline-offset: 1px;
|
|
1264
|
+
}
|
|
1265
|
+
`}
|
|
1266
|
+
}
|
|
1267
|
+
`,An=s.div`
|
|
1268
|
+
display: flex;
|
|
1269
|
+
align-items: center;
|
|
1270
|
+
gap: ${({theme:o})=>o.spacing[1]};
|
|
1228
1271
|
`,xo=s.button`
|
|
1229
1272
|
display: inline-flex;
|
|
1230
1273
|
align-items: center;
|
|
@@ -1268,12 +1311,12 @@
|
|
|
1268
1311
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
1269
1312
|
outline-offset: 2px;
|
|
1270
1313
|
}
|
|
1271
|
-
`,
|
|
1314
|
+
`,_n=4;function Hn(o,r){return o?.key!==r?t.jsx(Or,{size:14}):o.direction==="asc"?t.jsx(Pr,{size:14}):t.jsx(Er,{size:14})}function lr({columns:o,data:r,rowKey:n,size:e="md",striped:i,bordered:l,stickyHeader:d,stickyPagination:f,caption:u,emptyMessage:p="No data",loading:g,sort:w,defaultSort:v,onSortChange:y,pageSize:k,page:j,defaultPage:W,totalRows:O,onPageChange:E,pageSizeOptions:x,onPageSizeChange:z,onChange:m,onRowClick:b,borderColor:S,headerColor:I,rowColor:C,stripeColor:M,className:L,style:F}){const{activeSort:P,sortedData:A,handleSort:oo}=Sn({data:r,sort:w,defaultSort:v,onSortChange:y}),{activePage:D,totalPages:V,displayData:ro,handlePageChange:_}=zn({data:A,pageSize:k,page:j,defaultPage:W,totalRows:O,onPageChange:E}),X=h=>{const N=oo(h);m?.({sort:N,page:D})},U=h=>{_(h),m?.({sort:P,page:h})},so=(h,N)=>String(n?h[n]:N),B=!g&&ro.length===0,H=k??_n,q=!!k&&V>1,K=!!x?.length,J=t.jsxs(Tn,{$size:e,children:[u&&t.jsx("caption",{children:u}),t.jsx(Dn,{$headerColor:I,$borderColor:S,$stickyHeader:d,children:t.jsx(lo,{children:o.map(h=>t.jsx(Mn,{$size:e,$bordered:l,scope:"col",style:h.width?{width:h.width}:void 0,children:h.sortable?t.jsxs(On,{type:"button",onClick:()=>X(h.key),"aria-label":`Sort by ${h.header}${P?.key===h.key?`, ${P.direction}ending`:""}`,children:[h.header,t.jsx(Rn,{"aria-hidden":"true",children:Hn(P,h.key)})]}):h.header},h.key))})}),t.jsx(Wn,{$striped:i,$rowColor:C,$stripeColor:M,children:g?Array.from({length:H}).map((h,N)=>t.jsx(lo,{children:o.map(Z=>t.jsx(Nn,{$size:e,$bordered:l,$borderColor:S,children:t.jsx(Fn,{})},Z.key))},N)):B?t.jsx("tr",{children:t.jsx(Pn,{colSpan:o.length,children:p})}):ro.map((h,N)=>{const Z=b?En:lo;return t.jsx(Z,{onClick:b?()=>b(h):void 0,$accentColor:b?S:void 0,children:o.map($=>t.jsx(ar,{$size:e,$bordered:l,$borderColor:S,children:$.render?$.render(h[$.key],h,N):String(h[$.key]??"")||" "},$.key))},so(h,N))})})]}),Q=(q||K)&&t.jsxs(Bn,{$hasPageSizeOptions:K,children:[K&&t.jsxs(Vn,{children:["Rows per page:",t.jsx("select",{value:k,onChange:h=>z?.(Number(h.target.value)),"aria-label":"Rows per page",children:x.map(h=>t.jsx("option",{value:h,children:h},h))})]}),q&&t.jsxs(An,{children:[t.jsx(xo,{type:"button",onClick:()=>U(D-1),disabled:D<=1,"aria-label":"Previous page",children:"←"}),jn(D,V).map((h,N)=>h==="..."?t.jsx("span",{"aria-hidden":"true",style:{padding:"0 4px"},children:"…"},`e${N}`):t.jsx(xo,{type:"button",$active:h===D,onClick:()=>U(h),"aria-label":`Page ${h}`,"aria-current":h===D?"page":void 0,children:h},h)),t.jsx(xo,{type:"button",onClick:()=>U(D+1),disabled:D>=V,"aria-label":"Next page",children:"→"})]})]});return t.jsxs(Cn,{$borderColor:S,$stickyPagination:f,className:L,style:F,children:[f?t.jsx(In,{children:J}):J,Q]})}lr.displayName="Table";const Yn=s.p`
|
|
1272
1315
|
margin: 0;
|
|
1273
1316
|
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
1274
1317
|
color: ${({theme:o})=>o.colors.neutral[600]};
|
|
1275
1318
|
line-height: 1.5;
|
|
1276
|
-
`,
|
|
1319
|
+
`,Un=s.button`
|
|
1277
1320
|
display: inline-flex;
|
|
1278
1321
|
align-items: center;
|
|
1279
1322
|
justify-content: center;
|
|
@@ -1313,12 +1356,12 @@
|
|
|
1313
1356
|
box-shadow: 2px 2px 0 ${o.colors.neutral[900]};
|
|
1314
1357
|
}
|
|
1315
1358
|
`}
|
|
1316
|
-
`;function ko({open:o,title:r="Are you sure?",message:n,confirmLabel:e="Confirm",cancelLabel:i="Cancel",variant:l="default",size:d="sm",onConfirm:f,onCancel:u}){return t.jsx(wo,{open:o,onClose:u,title:r,size:d,closeOnBackdrop:!1,footer:t.jsxs(t.Fragment,{children:[t.jsx(
|
|
1359
|
+
`;function ko({open:o,title:r="Are you sure?",message:n,confirmLabel:e="Confirm",cancelLabel:i="Cancel",variant:l="default",size:d="sm",onConfirm:f,onCancel:u}){return t.jsx(wo,{open:o,onClose:u,title:r,size:d,closeOnBackdrop:!1,footer:t.jsxs(t.Fragment,{children:[t.jsx(co,{variant:"outline",onClick:u,children:i}),l==="danger"?t.jsx(Un,{type:"button",onClick:f,children:e}):t.jsx(co,{variant:"primary",onClick:f,children:e})]}),children:t.jsx(Yn,{children:n})})}ko.displayName="ConfirmDialog";const cr=a.createContext(null);function qn({children:o}){const[r,n]=a.useState(null),e=a.useCallback(d=>new Promise(f=>{n({...d,resolve:f})}),[]),i=()=>{r?.resolve(!0),n(null)},l=()=>{r?.resolve(!1),n(null)};return t.jsxs(cr.Provider,{value:{confirm:e},children:[o,r&&t.jsx(ko,{open:!0,title:r.title,message:r.message,confirmLabel:r.confirmLabel,cancelLabel:r.cancelLabel,variant:r.variant,size:r.size,onConfirm:i,onCancel:l})]})}function Kn(){const o=a.useContext(cr);if(!o)throw new Error("useConfirm must be used within a ConfirmProvider");return o.confirm}const Gn=s.div`
|
|
1317
1360
|
position: relative;
|
|
1318
1361
|
display: inline-flex;
|
|
1319
1362
|
flex-direction: column;
|
|
1320
1363
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
1321
|
-
`,
|
|
1364
|
+
`,Xn=s.div`
|
|
1322
1365
|
display: flex;
|
|
1323
1366
|
align-items: center;
|
|
1324
1367
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -1363,19 +1406,19 @@
|
|
|
1363
1406
|
outline: none;
|
|
1364
1407
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
1365
1408
|
}
|
|
1366
|
-
`,
|
|
1409
|
+
`,Jn=s.span`
|
|
1367
1410
|
flex: 1;
|
|
1368
1411
|
color: ${({$hasValue:o,theme:r})=>o?r.colors.neutral[900]:r.colors.neutral[400]};
|
|
1369
1412
|
white-space: nowrap;
|
|
1370
1413
|
overflow: hidden;
|
|
1371
1414
|
text-overflow: ellipsis;
|
|
1372
|
-
`,
|
|
1415
|
+
`,Qn=s.span`
|
|
1373
1416
|
display: inline-flex;
|
|
1374
1417
|
align-items: center;
|
|
1375
1418
|
margin-left: ${({theme:o})=>o.spacing[2]};
|
|
1376
1419
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
1377
1420
|
flex-shrink: 0;
|
|
1378
|
-
`,
|
|
1421
|
+
`,Zn=s.button`
|
|
1379
1422
|
display: inline-flex;
|
|
1380
1423
|
align-items: center;
|
|
1381
1424
|
margin-left: ${({theme:o})=>o.spacing[2]};
|
|
@@ -1398,7 +1441,7 @@
|
|
|
1398
1441
|
`;s.span`
|
|
1399
1442
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
1400
1443
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
1401
|
-
`;const
|
|
1444
|
+
`;const ot=s.div`
|
|
1402
1445
|
position: absolute;
|
|
1403
1446
|
top: calc(100% + 4px);
|
|
1404
1447
|
left: 0;
|
|
@@ -1417,7 +1460,7 @@
|
|
|
1417
1460
|
border: 1px solid ${o.colors.neutral[200]};
|
|
1418
1461
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
|
1419
1462
|
`}
|
|
1420
|
-
`,
|
|
1463
|
+
`,rt=s.div`
|
|
1421
1464
|
display: flex;
|
|
1422
1465
|
align-items: center;
|
|
1423
1466
|
justify-content: space-between;
|
|
@@ -1452,15 +1495,15 @@
|
|
|
1452
1495
|
transform: translate(1px, 1px);
|
|
1453
1496
|
}
|
|
1454
1497
|
`}
|
|
1455
|
-
`,
|
|
1498
|
+
`,st=s.span`
|
|
1456
1499
|
font-weight: ${({theme:o})=>o.fontWeights.semibold};
|
|
1457
1500
|
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
1458
1501
|
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
1459
|
-
`,
|
|
1502
|
+
`,nt=s.div`
|
|
1460
1503
|
display: grid;
|
|
1461
1504
|
grid-template-columns: repeat(7, 1fr);
|
|
1462
1505
|
gap: ${({theme:o})=>o.spacing[.5]};
|
|
1463
|
-
`,
|
|
1506
|
+
`,tt=s.span`
|
|
1464
1507
|
display: flex;
|
|
1465
1508
|
align-items: center;
|
|
1466
1509
|
justify-content: center;
|
|
@@ -1507,7 +1550,7 @@
|
|
|
1507
1550
|
box-shadow: 2px 2px 0 ${i.colors.neutral[900]};
|
|
1508
1551
|
`}
|
|
1509
1552
|
`}
|
|
1510
|
-
`,
|
|
1553
|
+
`,et=["January","February","March","April","May","June","July","August","September","October","November","December"],it=["Su","Mo","Tu","We","Th","Fr","Sa"];function Oo(o,r){return new Date(o,r+1,0).getDate()}function at(o,r){return new Date(o,r,1).getDay()}function eo(o,r){return o.getFullYear()===r.getFullYear()&&o.getMonth()===r.getMonth()&&o.getDate()===r.getDate()}function lt(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 Ro(o){return o.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Po(o){return o.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}function ho(o){if(!o)return null;const r=o.split("-");if(r.length!==3)return null;const n=parseInt(r[0],10),e=parseInt(r[1],10),i=parseInt(r[2],10);return isNaN(n)||isNaN(e)||isNaN(i)?null:new Date(n,e-1,i)}function to(o){const r=o.getFullYear(),n=String(o.getMonth()+1).padStart(2,"0"),e=String(o.getDate()).padStart(2,"0");return`${r}-${n}-${e}`}function dr({name:o,label:r,value:n,onChange:e,placeholder:i="Select date...",size:l="md",disabled:d=!1,clearable:f=!1,minDate:u,maxDate:p,formatDate:g,error:w,required:v,helperText:y,mode:k="single",nameFrom:j,nameTo:W,valueFrom:O,valueTo:E}){const x=k==="range",z=ho(n??""),m=ho(O??""),b=ho(E??""),S=new Date,I=()=>x?m??b??S:z??S,[C,M]=a.useState(!1),[L,F]=a.useState(()=>I().getFullYear()),[P,A]=a.useState(()=>I().getMonth()),[oo,D]=a.useState("from"),V=a.useRef(null);a.useEffect(()=>{if(!C)return;const $=R=>{V.current&&!V.current.contains(R.target)&&(M(!1),x&&D("from"))};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[C,x]),a.useEffect(()=>{!x&&z&&(F(z.getFullYear()),A(z.getMonth()))},[n,x]),a.useEffect(()=>{x&&m&&(F(m.getFullYear()),A(m.getMonth()))},[O,x]);const _=(()=>{if(!x)return z?g?g(z):Ro(z):"";if(!m&&!b)return"";const $=g??Ro;return m&&b?`${$(m)} - ${$(b)}`:m?`${$(m)} - ...`:""})(),X=x?!!(m||b):!!z,U=$=>{const R=new Date(L,P,$);if(!x){e(o??"",to(R)),M(!1);return}if(oo==="from"){e(j??"",to(R)),D("to");return}if(!m){e(j??"",to(R)),D("to");return}if(eo(R,m)){e(j??"",""),e(W??"",""),D("from");return}if(R>=m){e(W??"",to(R)),D("from"),M(!1);return}e(W??"",to(m)),e(j??"",to(R)),D("from"),M(!1)},so=$=>{$.stopPropagation(),x?(e(j??"",""),e(W??"",""),D("from")):e(o??"","")},B=()=>{if(d)return;const $=!C;M($),!$&&x&&D("from")},H=$=>{if(($.key==="Enter"||$.key===" ")&&!d){$.preventDefault();const R=!C;M(R),!R&&x&&D("from")}$.key==="Escape"&&(M(!1),x&&D("from"))},q=()=>{P===0?(A(11),F($=>$-1)):A($=>$-1)},K=()=>{P===11?(A(0),F($=>$+1)):A($=>$+1)},J=Oo(L,P),Q=at(L,P),h=[],N=Oo(P===0?L-1:L,P===0?11:P-1);for(let $=Q-1;$>=0;$--)h.push({day:N-$,currentMonth:!1});for(let $=1;$<=J;$++)h.push({day:$,currentMonth:!0});const Z=42-h.length;for(let $=1;$<=Z;$++)h.push({day:$,currentMonth:!1});return t.jsx(vo,{label:r,error:w,helperText:y,required:v,children:t.jsxs(Gn,{ref:V,children:[t.jsxs(Xn,{$size:l,$error:!!w,$disabled:d,role:"combobox","aria-haspopup":"true","aria-expanded":C,tabIndex:d?-1:0,onClick:B,onKeyDown:H,children:[t.jsx(Jn,{$hasValue:X,children:_||i}),f&&X?t.jsx(Zn,{type:"button",onClick:so,"aria-label":"Clear date",children:t.jsx(po,{size:14})}):t.jsx(Qn,{"aria-hidden":"true",children:t.jsx(Nr,{size:14})})]}),C&&t.jsxs(ot,{role:"dialog","aria-label":"Calendar",children:[t.jsxs(rt,{children:[t.jsx(Mo,{type:"button",onClick:q,"aria-label":"Previous month",children:t.jsx(Vr,{size:16})}),t.jsxs(st,{children:[et[P]," ",L]}),t.jsx(Mo,{type:"button",onClick:K,"aria-label":"Next month",children:t.jsx(_r,{size:16})})]}),t.jsxs(nt,{children:[it.map($=>t.jsx(tt,{children:$},$)),h.map(($,R)=>{if(!$.currentMonth)return t.jsx(yo,{type:"button",$currentMonth:!1,$selected:!1,$today:!1,disabled:!0,tabIndex:-1,children:$.day},R);const c=new Date(L,P,$.day),T=eo(c,S),Y=lt(c,u,p);if(x){const So=m?eo(c,m):!1,jo=b?eo(c,b):!1,ur=m&&b?c>m&&c<b:!1;return t.jsx(yo,{type:"button",$currentMonth:!0,$selected:!1,$today:T,$rangeStart:So,$rangeEnd:jo,$inRange:ur,disabled:Y,"aria-label":Po(c),"aria-pressed":So||jo,onClick:()=>U($.day),children:$.day},R)}const io=z?eo(c,z):!1;return t.jsx(yo,{type:"button",$currentMonth:!0,$selected:io,$today:T,disabled:Y,"aria-label":Po(c),"aria-pressed":io,onClick:()=>U($.day),children:$.day},R)})]})]})]})})}dr.displayName="DatePicker";function ct(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,i=d=>d<=.03928?d/12.92:((d+.055)/1.055)**2.4;return .2126*i(r)+.7152*i(n)+.0722*i(e)>.179?"#111111":"#ffffff"}const uo={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:{.5:"2px",1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px",8:"32px",10:"40px"},radius:{md:"2px"},zIndex:{modal:1e3,toast:1100},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px"},fontWeights:{normal:"400",medium:"500",semibold:"600",bold:"700"},shadows:{focusRing:"3px 3px 0 #111111"},brutalism:{borderWidth:"2px",shadowOffset:"4px"}};function dt(o){return{...uo,colors:{...uo.colors,primary:{50:"#fffff0",500:o,700:o,contrast:ct(o)}}}}function ut({theme:o=uo,children:r}){return t.jsx(s.ThemeProvider,{theme:o,children:r})}const ft=s.createGlobalStyle`
|
|
1511
1554
|
*, *::before, *::after {
|
|
1512
1555
|
box-sizing: border-box;
|
|
1513
1556
|
margin: 0;
|
|
@@ -1524,4 +1567,4 @@
|
|
|
1524
1567
|
button, input, select, textarea {
|
|
1525
1568
|
font-family: inherit;
|
|
1526
1569
|
}
|
|
1527
|
-
`;exports.Badge=
|
|
1570
|
+
`;exports.Badge=Lo;exports.Button=co;exports.Checkbox=rr;exports.CollapsibleCard=tr;exports.ConfirmDialog=ko;exports.ConfirmProvider=qn;exports.DatePicker=dr;exports.Editable=_o;exports.Field=Ho;exports.Form=or;exports.FormField=vo;exports.GlobalStyles=ft;exports.Input=No;exports.Link=mo;exports.Modal=wo;exports.Radio=sr;exports.Select=Ao;exports.Spinner=er;exports.Switch=nr;exports.Table=lr;exports.Textarea=Fo;exports.ThemeProvider=ut;exports.Toast=Qo;exports.ToastProvider=Cs;exports.composeValidators=Vs;exports.createNeoBrutalTheme=dt;exports.isEmail=Ns;exports.isUrl=Fs;exports.maxLength=Ls;exports.minLength=Ps;exports.neoBrutalTheme=uo;exports.pattern=Bs;exports.required=Rs;exports.useConfirm=Kn;exports.useForm=Os;exports.useTable=vn;exports.useToast=Is;
|