blunt-ui 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +80 -57
- package/dist/index.js +852 -821
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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"),
|
|
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"),to=(o,r,n)=>s.css`
|
|
2
2
|
background: ${r};
|
|
3
3
|
color: ${n};
|
|
4
4
|
border: ${o.brutalism.borderWidth} solid ${o.colors.neutral[900]};
|
|
5
5
|
box-shadow: 2px 2px 0 ${o.colors.neutral[900]};
|
|
6
|
-
`,
|
|
6
|
+
`,pr=s.span`
|
|
7
7
|
display: inline-flex;
|
|
8
8
|
align-items: center;
|
|
9
9
|
font-weight: ${({theme:o})=>o.fontWeights.bold};
|
|
@@ -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:to(r,r.colors.primary[500],r.colors.primary.contrast),neutral:to(r,r.colors.neutral[200],r.colors.neutral[900]),success:to(r,r.colors.success[50],r.colors.success[500]),error:to(r,r.colors.error[50],r.colors.error[500]),warning:to(r,r.colors.warning[50],r.colors.warning[500]),info:to(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 No({variant:o="primary",size:r="md",children:n,...e}){return t.jsx(pr,{$variant:o,$size:r,...e,children:n})}No.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]};
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
transform: translate(2px, 2px);
|
|
56
56
|
box-shadow: 2px 2px 0 ${o.colors.neutral[900]};
|
|
57
57
|
}
|
|
58
|
-
`,
|
|
58
|
+
`,fr=s.button`
|
|
59
59
|
display: inline-flex;
|
|
60
60
|
align-items: center;
|
|
61
61
|
justify-content: center;
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
font-weight: ${({theme:o})=>o.fontWeights.semibold};
|
|
64
64
|
cursor: pointer;
|
|
65
65
|
text-decoration: none;
|
|
66
|
+
touch-action: manipulation;
|
|
66
67
|
|
|
67
68
|
&:focus-visible {
|
|
68
69
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
@@ -107,12 +108,12 @@
|
|
|
107
108
|
padding: ${r.spacing[3]} ${r.spacing[6]};
|
|
108
109
|
font-size: ${r.fontSizes.lg};
|
|
109
110
|
`})[o]}
|
|
110
|
-
`;function
|
|
111
|
+
`;function uo({ref:o,as:r,href:n,variant:e="primary",size:i="md",isLoading:l,disabled:d,children:p,...u}){const f=r??(n?"a":"button");return t.jsx(fr,{ref:o,as:f,href:n,$variant:e,$size:i,disabled:l||d,...u,children:l?"Loading...":p})}uo.displayName="Button";const gr=s.div`
|
|
111
112
|
display: flex;
|
|
112
113
|
flex-direction: column;
|
|
113
114
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
114
115
|
width: ${({$fullWidth:o})=>o?"100%":"auto"};
|
|
115
|
-
|
|
116
|
+
`,$r=s.label`
|
|
116
117
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
117
118
|
font-weight: ${({theme:o})=>o.brutalism?o.fontWeights.bold:o.fontWeights.medium};
|
|
118
119
|
`,br=s.span`
|
|
@@ -171,7 +172,7 @@
|
|
|
171
172
|
cursor: not-allowed;
|
|
172
173
|
opacity: 0.6;
|
|
173
174
|
}
|
|
174
|
-
`,
|
|
175
|
+
`,Co=s.div`
|
|
175
176
|
display: inline-flex;
|
|
176
177
|
align-items: center;
|
|
177
178
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
@@ -188,7 +189,7 @@
|
|
|
188
189
|
&:hover {
|
|
189
190
|
opacity: 0.8;
|
|
190
191
|
}
|
|
191
|
-
`;function
|
|
192
|
+
`;function Fo({ref:o,type:r="text",size:n="md",variant:e="default",label:i,helperText:l,error:d,leftElement:p,rightElement:u,clearable:f,onClear:$,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,T=typeof d=="string"?d:void 0,I=!!(l||d),M=P=>{b||m(P.target.value),j?.(P)},N=()=>{b||m(""),$?.()};return t.jsxs(gr,{$fullWidth:w,children:[i&&t.jsx($r,{htmlFor:E,children:i}),t.jsxs(xr,{$size:n,$variant:e,$error:!!d,children:[p&&t.jsx(Co,{children:p}),t.jsx(yr,{id:E,ref:o,type:r,value:S,onChange:M,...W,"aria-invalid":!!d,"aria-describedby":I?x:void 0}),f&&S&&t.jsx(hr,{type:"button",onClick:N,"aria-label":"Clear input",children:"✕"}),u&&t.jsx(Co,{children:u})]}),I&&t.jsx(br,{id:x,$error:!!d,children:T??l})]})}Fo.displayName="Input";const mr=s.div`
|
|
192
193
|
display: flex;
|
|
193
194
|
flex-direction: column;
|
|
194
195
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -253,14 +254,14 @@
|
|
|
253
254
|
cursor: not-allowed;
|
|
254
255
|
opacity: 0.6;
|
|
255
256
|
}
|
|
256
|
-
`;function
|
|
257
|
+
`;function Bo({ref:o,size:r="md",variant:n="default",label:e,helperText:i,error:l,fullWidth:d,id:p,value:u,defaultValue:f,onChange:$,...w}){const v=a.useId(),y=p??v,k=`${y}-hint`,[j,W]=a.useState(f??""),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),$?.(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})]})}Bo.displayName="Textarea";const Vo=(...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 Io=o=>{const r=zr(o);return r.charAt(0).toUpperCase()+r.slice(1)};var bo={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,...p},u)=>{const{size:f=24,strokeWidth:$=2,absoluteStrokeWidth:w=!1,color:v="currentColor",className:y=""}=Tr()??{},k=e??w?Number(n??$)*24/Number(r??f):n??$;return a.createElement("svg",{ref:u,...bo,width:r??f??bo.width,height:r??f??bo.height,stroke:o??v,strokeWidth:k,className:Vo("lucide",y,i),...!l&&!Cr(p)&&{"aria-hidden":"true"},...p},[...d.map(([j,W])=>a.createElement(j,W)),...Array.isArray(l)?l:[l]])});const X=(o,r)=>{const n=a.forwardRef(({className:e,...i},l)=>a.createElement(Dr,{ref:l,iconNode:r,className:Vo(`lucide-${jr(Io(o))}`,`lucide-${o}`,e),...i}));return n.displayName=Io(o),n};const Wr=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Er=X("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=X("arrow-up-down",Mr);const Rr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Lr=X("arrow-up",Rr);const Pr=[["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=X("calendar",Pr);const Fr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ao=X("chevron-down",Fr);const Br=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Vr=X("chevron-left",Br);const Ar=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],_r=X("chevron-right",Ar);const Hr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],go=X("x",Hr),Ur=s.div`
|
|
257
258
|
display: inline-flex;
|
|
258
259
|
flex-direction: column;
|
|
259
260
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
260
261
|
width: ${({$fullWidth:o})=>o?"100%":"auto"};
|
|
261
262
|
position: relative;
|
|
262
263
|
min-width: 0;
|
|
263
|
-
`,
|
|
264
|
+
`,Yr=s.div`
|
|
264
265
|
height: 0;
|
|
265
266
|
overflow: hidden;
|
|
266
267
|
visibility: hidden;
|
|
@@ -319,7 +320,7 @@
|
|
|
319
320
|
outline: none;
|
|
320
321
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
321
322
|
}
|
|
322
|
-
`,
|
|
323
|
+
`,xo=s.span`
|
|
323
324
|
flex: 1;
|
|
324
325
|
overflow: hidden;
|
|
325
326
|
white-space: nowrap;
|
|
@@ -426,7 +427,7 @@
|
|
|
426
427
|
outline-offset: 2px;
|
|
427
428
|
border-radius: 2px;
|
|
428
429
|
}
|
|
429
|
-
`;function
|
|
430
|
+
`;function wo({options:o,placeholder:r,size:n="md",variant:e="default",error:i,fullWidth:l,clearable:d,onClear:p,id:u,name:f,value:$,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),[T,I]=a.useState(-1),[M,N]=a.useState(""),[P,L]=a.useState({top:0,bottom:0,left:0,width:0,openUpward:!1}),[H,ro]=a.useState(w??""),D=$!==void 0,V=D?$:H,so=a.useRef(null),U=a.useRef(null),G=a.useRef(null),Y=a.useRef(null),no=o.find(c=>c.value===V),B=k&&M?o.filter(c=>c.label.toLowerCase().includes(M.toLowerCase())):o,A=a.useCallback(()=>{if(!U.current)return;const c=U.current.getBoundingClientRect(),C=window.innerHeight,_=G.current?.getBoundingClientRect().height??200,oo=C-c.bottom,ao=oo<_+4&&c.top>oo;L({top:c.bottom+4,bottom:C-c.top+4,left:c.left,width:c.width,openUpward:ao})},[]);a.useEffect(()=>{if(b)return A(),window.addEventListener("scroll",A,!0),window.addEventListener("resize",A),()=>{window.removeEventListener("scroll",A,!0),window.removeEventListener("resize",A)}},[b,A]),a.useLayoutEffect(()=>{b&&A()},[b,A]),a.useEffect(()=>{if(!b)return;const c=C=>{const _=so.current?.contains(C.target),oo=G.current?.contains(C.target);!_&&!oo&&S(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[b]),a.useEffect(()=>{b&&k&&setTimeout(()=>Y.current?.focus(),0),b||(N(""),I(-1))},[b,k]),a.useEffect(()=>{I(-1)},[M]),a.useEffect(()=>{if(T<0)return;const c=document.getElementById(`${x}-option-${T}`);c&&typeof c.scrollIntoView=="function"&&c.scrollIntoView({block:"nearest"})},[T,x]);function q(c,C){let _=c+C;for(;_>=0&&_<B.length;){if(!B[_].disabled)return _;_+=C}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||ro(c.value);const C={target:{name:f??"",value:c.value},currentTarget:{name:f??"",value:c.value}};v?.(C),S(!1),U.current?.focus()}function h(c){c.stopPropagation(),D||ro(""),v?.({target:{name:f??"",value:""},currentTarget:{name:f??"",value:""}}),p?.(),U.current?.focus()}function F(c){if(!y){if(!b){["ArrowDown","ArrowUp","Enter"," "].includes(c.key)&&(c.preventDefault(),S(!0),k||I(K()));return}if(c.key==="Escape"){c.preventDefault(),S(!1);return}if(!k){if(c.key==="ArrowDown"){c.preventDefault(),I(C=>q(C,1));return}if(c.key==="ArrowUp"){c.preventDefault(),I(C=>q(C,-1));return}if(c.key==="Home"){c.preventDefault(),I(K());return}if(c.key==="End"){c.preventDefault(),I(J());return}(c.key==="Enter"||c.key===" ")&&T>=0&&(c.preventDefault(),Q(B[T]))}}}function Z(c){if(c.key==="Escape"){S(!1),U.current?.focus();return}if(c.key==="ArrowDown"){c.preventDefault(),I(C=>C<0?K():q(C,1));return}if(c.key==="ArrowUp"){c.preventDefault(),I(C=>C<0?J():q(C,-1));return}c.key==="Enter"&&T>=0&&(c.preventDefault(),Q(B[T]))}const g=d&&!!V&&!y,R=T>=0?`${x}-option-${T}`:void 0;return t.jsxs(Ur,{ref:so,$fullWidth:l,children:[t.jsxs(Yr,{"aria-hidden":"true",children:[r&&t.jsx(xo,{children:r}),o.map(c=>t.jsx(xo,{children:c.label},c.value))]}),t.jsxs(qr,{ref:U,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:F,children:[t.jsx(xo,{$placeholder:!no,children:no?.label??r??"Select..."}),t.jsxs(Kr,{children:[g&&t.jsx(ss,{type:"button",onClick:h,"aria-label":"Clear selection",children:t.jsx(go,{size:14})}),t.jsx(Gr,{$open:b,"aria-hidden":"true",children:t.jsx(Ao,{size:14})})]})]}),b&&fo.createPortal(t.jsxs(Xr,{ref:G,id:x,role:"listbox","aria-label":r??"Options",style:{position:"fixed",top:P.openUpward?"auto":P.top,bottom:P.openUpward?P.bottom:"auto",left:P.left,width:P.width},children:[k&&t.jsx(Jr,{children:t.jsx(Qr,{ref:Y,id:z,type:"text",placeholder:"Search...",value:M,onChange:c=>N(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,C)=>t.jsx(os,{id:`${x}-option-${C}`,role:"option","aria-selected":c.value===V,"aria-disabled":c.disabled,$selected:c.value===V,$focused:C===T,$disabled:c.disabled,onClick:()=>Q(c),onMouseEnter:()=>!c.disabled&&I(C),children:c.label},c.value))]}),document.body),m&&t.jsx(rs,{$error:!0,children:m})]})}wo.displayName="Select";const To=s.span`
|
|
430
431
|
display: inline-block;
|
|
431
432
|
`,ns=s.span`
|
|
432
433
|
display: inline-block;
|
|
@@ -485,7 +486,7 @@
|
|
|
485
486
|
border: 1px solid ${o.colors.primary[500]};
|
|
486
487
|
box-shadow: ${o.shadows.focusRing};
|
|
487
488
|
`}
|
|
488
|
-
`;function _o({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:i,placeholder:l="Click to edit",disabled:d=!1}){const
|
|
489
|
+
`;function _o({value:o,defaultValue:r="",onChange:n,onSubmit:e,onCancel:i,placeholder:l="Click to edit",disabled:d=!1}){const p=o!==void 0,[u,f]=a.useState(r),$=p?o:u,[w,v]=a.useState(!1),[y,k]=a.useState(""),j=a.useRef(null),W=()=>{d||(k($),v(!0),setTimeout(()=>{j.current?.focus(),j.current?.select()},0))},O=()=>{p||f(y),n?.(y),e?.(y),v(!1)},E=()=>{i?.($),v(!1)},x=z=>{z.key==="Enter"?O():z.key==="Escape"&&E()};return w?t.jsx(To,{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(To,{children:t.jsx(ns,{role:d?void 0:"button",tabIndex:d?void 0:0,$disabled:d,$empty:!$,onClick:W,onKeyDown:z=>z.key==="Enter"&&W(),children:$||l})})}_o.displayName="Editable";const es=s.a`
|
|
489
490
|
text-decoration: underline;
|
|
490
491
|
text-underline-offset: 2px;
|
|
491
492
|
transition: color 0.15s;
|
|
@@ -507,7 +508,7 @@
|
|
|
507
508
|
color: ${r.colors.neutral[900]};
|
|
508
509
|
}
|
|
509
510
|
`})[o]}
|
|
510
|
-
`;function
|
|
511
|
+
`;function vo({variant:o="default",external:r,children:n,...e}){return t.jsx(es,{$variant:o,...r&&{target:"_blank",rel:"noreferrer"},...e,children:n})}vo.displayName="Link";const is=s.div`
|
|
511
512
|
display: flex;
|
|
512
513
|
flex-direction: column;
|
|
513
514
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -518,7 +519,7 @@
|
|
|
518
519
|
`,ls=s.span`
|
|
519
520
|
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
520
521
|
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
521
|
-
`;function Ho({label:o,value:r,href:n}){return t.jsxs(is,{children:[t.jsx(as,{children:o}),n?t.jsx(
|
|
522
|
+
`;function Ho({label:o,value:r,href:n}){return t.jsxs(is,{children:[t.jsx(as,{children:o}),n?t.jsx(vo,{href:n,external:!0,children:r}):t.jsx(ls,{children:r??"—"})]})}Ho.displayName="Field";const cs=s.keyframes`
|
|
522
523
|
from { opacity: 0; }
|
|
523
524
|
to { opacity: 1; }
|
|
524
525
|
`,ds=s.keyframes`
|
|
@@ -527,10 +528,10 @@
|
|
|
527
528
|
`,us=s.keyframes`
|
|
528
529
|
from { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
529
530
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
530
|
-
`,
|
|
531
|
+
`,ps=s.keyframes`
|
|
531
532
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
532
533
|
to { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
533
|
-
`,
|
|
534
|
+
`,fs=s.div`
|
|
534
535
|
position: fixed;
|
|
535
536
|
inset: 0;
|
|
536
537
|
background-color: rgba(0, 0, 0, 0.5);
|
|
@@ -540,7 +541,7 @@
|
|
|
540
541
|
z-index: ${({theme:o})=>o.zIndex.modal};
|
|
541
542
|
animation: ${({$closing:o})=>o?ds:cs} 0.15s ease
|
|
542
543
|
forwards;
|
|
543
|
-
|
|
544
|
+
`,gs=s.div`
|
|
544
545
|
position: relative;
|
|
545
546
|
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
546
547
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -549,7 +550,7 @@
|
|
|
549
550
|
display: flex;
|
|
550
551
|
flex-direction: column;
|
|
551
552
|
max-height: 90vh;
|
|
552
|
-
animation: ${({$closing:o})=>o?
|
|
553
|
+
animation: ${({$closing:o})=>o?ps:us} 0.15s ease
|
|
553
554
|
forwards;
|
|
554
555
|
|
|
555
556
|
${({$size:o})=>o==="sm"&&s.css`
|
|
@@ -567,7 +568,7 @@
|
|
|
567
568
|
max-height: 100vh;
|
|
568
569
|
border-radius: 0;
|
|
569
570
|
`}
|
|
570
|
-
|
|
571
|
+
`,$s=s.div`
|
|
571
572
|
display: flex;
|
|
572
573
|
align-items: center;
|
|
573
574
|
gap: ${({theme:o})=>o.spacing[2]};
|
|
@@ -616,21 +617,21 @@
|
|
|
616
617
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
617
618
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
618
619
|
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
|
|
620
|
+
`,ms=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function Do(o){return Array.from(o.querySelectorAll(ms))}function ko({open:o,onClose:r,title:n,children:e,footer:i,size:l="md",closeOnBackdrop:d=!0,closeOnEscape:p=!0,ariaLabelledBy:u,ariaDescribedBy:f}){const $=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||!$.current)return;const x=$.current,z=document.activeElement;(Do(x)[0]??x).focus();const b=S=>{if(S.key==="Escape"&&p){v.current();return}if(S.key!=="Tab")return;const T=Do(x);if(T.length===0){S.preventDefault();return}const I=T[0],M=T[T.length-1];S.shiftKey?document.activeElement===I&&(S.preventDefault(),M.focus()):document.activeElement===M&&(S.preventDefault(),I.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),z?.focus()}},[o,p,j]),j?fo.createPortal(t.jsx(fs,{$closing:O,onMouseDown:x=>{w.current=x.target},onClick:x=>{d&&w.current===x.currentTarget&&r()},children:t.jsxs(gs,{ref:$,role:"dialog","aria-modal":"true","aria-labelledby":k,"aria-describedby":f,$size:l,$closing:O,tabIndex:-1,onClick:x=>x.stopPropagation(),children:[t.jsxs($s,{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}ko.displayName="Modal";const Uo=s.keyframes`
|
|
620
621
|
from { opacity: 0; transform: translateY(12px); }
|
|
621
622
|
to { opacity: 1; transform: translateY(0); }
|
|
622
|
-
`,
|
|
623
|
+
`,Yo=s.keyframes`
|
|
623
624
|
from { opacity: 0; transform: translateY(-12px); }
|
|
624
625
|
to { opacity: 1; transform: translateY(0); }
|
|
625
626
|
`,qo=s.keyframes`
|
|
626
627
|
from { opacity: 1; }
|
|
627
628
|
to { opacity: 0; }
|
|
628
|
-
`,
|
|
629
|
+
`,lo=(o,r,n)=>s.css`
|
|
629
630
|
background: ${r};
|
|
630
631
|
border: ${o.brutalism.borderWidth} solid ${n};
|
|
631
632
|
box-shadow: ${o.brutalism.shadowOffset} ${o.brutalism.shadowOffset}
|
|
632
633
|
0 ${n};
|
|
633
|
-
`;function Ko(o,r){return r.brutalism?{success:
|
|
634
|
+
`;function Ko(o,r){return r.brutalism?{success:lo(r,r.colors.success[50],r.colors.success[500]),error:lo(r,r.colors.error[50],r.colors.error[500]),warning:lo(r,r.colors.warning[50],r.colors.warning[500]),info:lo(r,r.colors.info[50],r.colors.info[500])}[o]:{success:s.css`
|
|
634
635
|
background: ${r.colors.success[50]};
|
|
635
636
|
border-left: ${r.spacing[1]} solid ${r.colors.success[500]};
|
|
636
637
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
@@ -654,6 +655,12 @@
|
|
|
654
655
|
max-width: 400px;
|
|
655
656
|
padding: ${({theme:o})=>`${o.spacing[3]} ${o.spacing[4]}`};
|
|
656
657
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
658
|
+
|
|
659
|
+
@media (max-width: 640px) {
|
|
660
|
+
min-width: unset;
|
|
661
|
+
max-width: unset;
|
|
662
|
+
width: 100%;
|
|
663
|
+
}
|
|
657
664
|
`,ws={"bottom-right":s.css`
|
|
658
665
|
bottom: 24px;
|
|
659
666
|
right: 24px;
|
|
@@ -674,9 +681,9 @@
|
|
|
674
681
|
animation: ${({$closing:o,$position:r})=>o?s.css`
|
|
675
682
|
${qo} 0.2s ease forwards
|
|
676
683
|
`:r.startsWith("top")?s.css`
|
|
677
|
-
${Uo} 0.2s ease forwards
|
|
678
|
-
`:s.css`
|
|
679
684
|
${Yo} 0.2s ease forwards
|
|
685
|
+
`:s.css`
|
|
686
|
+
${Uo} 0.2s ease forwards
|
|
680
687
|
`};
|
|
681
688
|
|
|
682
689
|
${({$position:o})=>ws[o]}
|
|
@@ -688,9 +695,9 @@
|
|
|
688
695
|
animation: ${({$closing:o,$isTop:r})=>o?s.css`
|
|
689
696
|
${qo} 0.2s ease forwards
|
|
690
697
|
`:r?s.css`
|
|
691
|
-
${Uo} 0.2s ease forwards
|
|
692
|
-
`:s.css`
|
|
693
698
|
${Yo} 0.2s ease forwards
|
|
699
|
+
`:s.css`
|
|
700
|
+
${Uo} 0.2s ease forwards
|
|
694
701
|
`};
|
|
695
702
|
|
|
696
703
|
${({$variant:o,theme:r})=>Ko(o,r)}
|
|
@@ -719,6 +726,14 @@
|
|
|
719
726
|
left: ${r.spacing[6]};
|
|
720
727
|
align-items: flex-start;
|
|
721
728
|
`})[o]}
|
|
729
|
+
|
|
730
|
+
@media (max-width: 640px) {
|
|
731
|
+
top: ${({theme:o})=>o.spacing[4]};
|
|
732
|
+
left: ${({theme:o})=>o.spacing[3]};
|
|
733
|
+
right: ${({theme:o})=>o.spacing[3]};
|
|
734
|
+
bottom: auto;
|
|
735
|
+
align-items: stretch;
|
|
736
|
+
}
|
|
722
737
|
`,Xo=s.p`
|
|
723
738
|
flex: 1;
|
|
724
739
|
margin: 0;
|
|
@@ -748,7 +763,7 @@
|
|
|
748
763
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
749
764
|
outline-offset: 2px;
|
|
750
765
|
}
|
|
751
|
-
`;function Qo({open:o,onClose:r,message:n,variant:e="info",duration:i=4e3,position:l="bottom-right"}){const[d,
|
|
766
|
+
`;function Qo({open:o,onClose:r,message:n,variant:e="info",duration:i=4e3,position:l="bottom-right"}){const[d,p]=a.useState(o),[u,f]=a.useState(!1);return a.useEffect(()=>{if(o)p(!0),f(!1);else if(d){f(!0);const $=setTimeout(()=>{p(!1),f(!1)},200);return()=>{clearTimeout($)}}},[o,d]),a.useEffect(()=>{if(!o||i===0)return;const $=setTimeout(r,i);return()=>{clearTimeout($)}},[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(go,{size:14,strokeWidth:2.5})})]}),document.body):null}Qo.displayName="Toast";const Zo=a.createContext(null),Wo=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(go,{size:14,strokeWidth:2.5})})]})}function Cs({children:o}){const[r,n]=a.useState([]),e=a.useCallback(u=>{n(f=>f.map($=>$.id===u?{...$,closing:!0}:$)),setTimeout(()=>{n(f=>f.filter($=>$.id!==u))},200)},[]),i=a.useCallback(u=>{const f=Date.now();n($=>{const w=[...$,{...u,id:f,closing:!1}];return w.length>Wo?w.slice(w.length-Wo):w})},[]),l=a.useMemo(()=>Object.assign(u=>i(u),{success:(u,f)=>i({...f,message:u,variant:"success"}),error:(u,f)=>i({...f,message:u,variant:"error"}),warning:(u,f)=>i({...f,message:u,variant:"warning"}),info:(u,f)=>i({...f,message:u,variant:"info"})}),[i]),d=r[r.length-1]?.position??js,p=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:p,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
767
|
display: flex;
|
|
753
768
|
flex-direction: column;
|
|
754
769
|
gap: ${({theme:o})=>o.spacing[4]};
|
|
@@ -766,7 +781,7 @@
|
|
|
766
781
|
`,Ms=s.span`
|
|
767
782
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
768
783
|
color: ${({$error:o,theme:r})=>o?r.colors.error[500]:r.colors.neutral[500]};
|
|
769
|
-
`;function
|
|
784
|
+
`;function So({label:o,error:r,helperText:n,required:e,children:i}){const l=a.useId(),d=`${l}-hint`,p=!!(r||n),u=typeof r=="string"?r:void 0,f=a.isValidElement(i)?a.cloneElement(i,{id:l,...p&&{"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:" *"})]}),f,p&&t.jsx(Ms,{id:d,$error:!!r,children:u??n})]})}So.displayName="FormField";function Os({initialValues:o,validate:r,onSubmit:n,onError:e}){const[i,l]=a.useState(o),[d,p]=a.useState({}),[u,f]=a.useState({}),[$,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 T={...v.current,[b]:S};l(T),k.current[b]&&p(y(T))},[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."),f(S=>({...S,[b]:!0})),p(y(v.current))},[y]),O=a.useCallback(m=>{m?.preventDefault();const b=Object.keys(v.current).reduce((I,M)=>({...I,[M]:!0}),{});f(b);const S=y(v.current);if(p(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),p({}),f({}),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:$}}const Rs=(o="Required")=>r=>{if(!r.trim())return o},Ls=(o,r)=>n=>{if(n.length<o)return r??`Must be at least ${o} characters`},Ps=(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
785
|
display: flex;
|
|
771
786
|
flex-direction: column;
|
|
772
787
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -787,7 +802,7 @@
|
|
|
787
802
|
&:focus-visible + div {
|
|
788
803
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
789
804
|
}
|
|
790
|
-
`,
|
|
805
|
+
`,Us=s.div`
|
|
791
806
|
position: relative;
|
|
792
807
|
display: flex;
|
|
793
808
|
align-items: center;
|
|
@@ -821,13 +836,13 @@
|
|
|
821
836
|
transform: rotate(45deg) translate(-1px, -1px);
|
|
822
837
|
}
|
|
823
838
|
`}
|
|
824
|
-
`,
|
|
839
|
+
`,Ys=s.span`
|
|
825
840
|
font-size: ${({$size:o="md",theme:r})=>o==="sm"?r.fontSizes.sm:r.fontSizes.md};
|
|
826
841
|
font-weight: ${({theme:o})=>o.fontWeights.medium};
|
|
827
842
|
`,qs=s.span`
|
|
828
843
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
829
844
|
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:
|
|
845
|
+
`;function rr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:p,color:u,borderColor:f,checkColor:$,...w}){const v=a.useId(),y=p??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(Us,{$checked:d,$error:!!e,$disabled:l,$size:n,$color:u,$borderColor:f,$checkColor:$}),r&&t.jsx(Ys,{$size:n,children:r})]}),j&&t.jsx(qs,{$error:!!e,children:k??i})]})}rr.displayName="Checkbox";const Ks=s.div`
|
|
831
846
|
display: flex;
|
|
832
847
|
flex-direction: column;
|
|
833
848
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -886,7 +901,7 @@
|
|
|
886
901
|
`,Zs=s.span`
|
|
887
902
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
888
903
|
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:
|
|
904
|
+
`;function sr({ref:o,label:r,size:n="md",error:e,helperText:i,disabled:l,checked:d,id:p,color:u,borderColor:f,...$}){const w=a.useId(),v=p??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,...$}),t.jsx(Js,{$checked:d,$error:e,$disabled:l,$size:n,$color:u,$borderColor:f}),r&&t.jsx(Qs,{$size:n,children:r})]}),y&&t.jsx(Zs,{$error:e,children:i})]})}sr.displayName="Radio";const on=s.div`
|
|
890
905
|
display: flex;
|
|
891
906
|
flex-direction: column;
|
|
892
907
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
@@ -955,7 +970,7 @@
|
|
|
955
970
|
`,tn=s.span`
|
|
956
971
|
font-size: ${({$size:o="md",theme:r})=>o==="sm"?r.fontSizes.sm:r.fontSizes.md};
|
|
957
972
|
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:
|
|
973
|
+
`;function nr({ref:o,label:r,size:n="md",disabled:e,checked:i,id:l,color:d,borderColor:p,...u}){const f=a.useId(),$=l??f;return t.jsx(on,{children:t.jsxs(rn,{htmlFor:$,$disabled:e,children:[t.jsx(sn,{id:$,ref:o,type:"checkbox",role:"switch",checked:i,disabled:e,...u}),t.jsx(nn,{$checked:i,$size:n,$color:d,$borderColor:p}),r&&t.jsx(tn,{$size:n,children:r})]})})}nr.displayName="Switch";const en=s.div`
|
|
959
974
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
960
975
|
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
961
976
|
overflow: hidden;
|
|
@@ -1014,11 +1029,11 @@
|
|
|
1014
1029
|
align-items: flex-start;
|
|
1015
1030
|
gap: ${({theme:o})=>o.spacing[2]};
|
|
1016
1031
|
}
|
|
1017
|
-
`,
|
|
1032
|
+
`,pn=s.div`
|
|
1018
1033
|
display: flex;
|
|
1019
1034
|
align-items: center;
|
|
1020
1035
|
gap: ${({theme:o})=>o.spacing[2]};
|
|
1021
|
-
`,
|
|
1036
|
+
`,fn=s.span`
|
|
1022
1037
|
display: inline-flex;
|
|
1023
1038
|
align-items: center;
|
|
1024
1039
|
justify-content: center;
|
|
@@ -1026,29 +1041,29 @@
|
|
|
1026
1041
|
transition: transform 0.2s ease;
|
|
1027
1042
|
transform: ${({$open:o})=>o?"rotate(180deg)":"rotate(0deg)"};
|
|
1028
1043
|
color: ${({theme:o,$accentColor:r})=>r??o.colors.neutral[500]};
|
|
1029
|
-
|
|
1044
|
+
`,gn=s.div`
|
|
1030
1045
|
display: grid;
|
|
1031
1046
|
grid-template-rows: ${({$open:o})=>o?"1fr":"0fr"};
|
|
1032
1047
|
transition: grid-template-rows 0.2s ease;
|
|
1033
|
-
|
|
1048
|
+
`,$n=s.div`
|
|
1034
1049
|
overflow: hidden;
|
|
1035
1050
|
`,bn=s.div`
|
|
1036
1051
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
1037
1052
|
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:
|
|
1053
|
+
`;function tr({title:o,children:r,defaultOpen:n=!1,open:e,onToggle:i,subtitle:l,headerActions:d,accentColor:p}){const[u,f]=a.useState(n),$=a.useId(),w=e!==void 0,v=w?e:u,y=()=>{const k=!v;w||f(k),i?.(k)};return t.jsxs(en,{$accentColor:p,children:[t.jsxs(an,{type:"button",$open:v,$accentColor:p,"aria-expanded":v,"aria-controls":$,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(pn,{onClick:k=>k.stopPropagation(),children:d})]})]}),t.jsx(fn,{$open:v,$accentColor:p,"aria-hidden":"true",children:t.jsx(Ao,{size:18,strokeWidth:2.5})})]}),t.jsx(gn,{$open:v,children:t.jsx($n,{id:$,role:"region","aria-label":o,children:t.jsx(bn,{children:r})})})]})}tr.displayName="CollapsibleCard";const xn=s.keyframes`
|
|
1039
1054
|
to { transform: rotate(360deg); }
|
|
1040
1055
|
`,yn={sm:"16px",md:"24px",lg:"40px"},hn={thin:"2px",normal:"3px",bold:"5px"},mn=s.span`
|
|
1041
1056
|
display: inline-block;
|
|
1042
1057
|
border-radius: 50%;
|
|
1043
1058
|
animation: ${xn} 0.7s linear infinite;
|
|
1044
1059
|
|
|
1045
|
-
${({$size:o="md",$weight:r="normal",$color:n,theme:e})=>{const i=yn[o],l=hn[r],d=e.colors.neutral[200],
|
|
1060
|
+
${({$size:o="md",$weight:r="normal",$color:n,theme:e})=>{const i=yn[o],l=hn[r],d=e.colors.neutral[200],p=n??e.colors.primary[500];return s.css`
|
|
1046
1061
|
width: ${i};
|
|
1047
1062
|
height: ${i};
|
|
1048
1063
|
border: ${l} solid ${d};
|
|
1049
|
-
border-top-color: ${
|
|
1064
|
+
border-top-color: ${p};
|
|
1050
1065
|
`}}
|
|
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,
|
|
1066
|
+
`;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,Eo=3,Mo=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),p=i?r??null:l,u=$=>{const w=kn(p,$);return i||d(w),e?.(w),w},f=a.useMemo(()=>i||!p?o:[...o].sort(($,w)=>{const v=$[p.key],y=w[p.key],k=v<y?-1:v>y?1:0;return p.direction==="asc"?k:-k}),[o,p,i]);return{activeSort:p,sortedData:f,handleSort:u}}function jn(o,r){if(r<=wn)return Array.from({length:r},(e,i)=>i+1);const n=[1];o>Eo&&n.push("...");for(let e=Math.max(2,o-Mo);e<=Math.min(r-1,o+Mo);e++)n.push(e);return o<r-Eo+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,[p,u]=a.useState(e??1),f=d?n:p,$=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=(f-1)*r;return o.slice(j,j+r)},[o,r,f,w]);return{activePage:f,totalPages:y,displayData:k,handlePageChange:$}}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
1067
|
width: 100%;
|
|
1053
1068
|
|
|
1054
1069
|
${({theme:o,$borderColor:r})=>o.brutalism?s.css`
|
|
@@ -1073,7 +1088,8 @@
|
|
|
1073
1088
|
overflow: auto;
|
|
1074
1089
|
min-height: 0;
|
|
1075
1090
|
`,Tn=s.table`
|
|
1076
|
-
width:
|
|
1091
|
+
width: max-content;
|
|
1092
|
+
min-width: 100%;
|
|
1077
1093
|
border-collapse: collapse;
|
|
1078
1094
|
font-size: ${({$size:o,theme:r})=>({sm:r.fontSizes.sm,md:r.fontSizes.md,lg:r.fontSizes.lg})[o]};
|
|
1079
1095
|
|
|
@@ -1120,7 +1136,7 @@
|
|
|
1120
1136
|
tr:hover td {
|
|
1121
1137
|
background-color: rgba(0, 0, 0, 0.04);
|
|
1122
1138
|
}
|
|
1123
|
-
`,
|
|
1139
|
+
`,co=s.tr``,En=s(co)`
|
|
1124
1140
|
cursor: pointer;
|
|
1125
1141
|
|
|
1126
1142
|
td {
|
|
@@ -1197,13 +1213,13 @@
|
|
|
1197
1213
|
border-bottom: 1px solid
|
|
1198
1214
|
${r??n.colors.neutral[200]};
|
|
1199
1215
|
`}
|
|
1200
|
-
`,
|
|
1216
|
+
`,Ln=s.td`
|
|
1201
1217
|
text-align: center;
|
|
1202
1218
|
color: ${({theme:o})=>o.colors.neutral[400]};
|
|
1203
1219
|
padding: ${({theme:o})=>`${o.spacing[4]} ${o.spacing[3]}`};
|
|
1204
1220
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
1205
1221
|
border-bottom: none;
|
|
1206
|
-
`,
|
|
1222
|
+
`,Pn=s.keyframes`
|
|
1207
1223
|
0% { background-position: -400px 0; }
|
|
1208
1224
|
100% { background-position: 400px 0; }
|
|
1209
1225
|
`,Nn=s(ar)``,Fn=s.div`
|
|
@@ -1216,7 +1232,7 @@
|
|
|
1216
1232
|
${({theme:o})=>o.colors.neutral[200]} 75%
|
|
1217
1233
|
);
|
|
1218
1234
|
background-size: 800px 100%;
|
|
1219
|
-
animation: ${
|
|
1235
|
+
animation: ${Pn} 1.6s ease-in-out infinite;
|
|
1220
1236
|
`,Bn=s.div`
|
|
1221
1237
|
display: flex;
|
|
1222
1238
|
align-items: center;
|
|
@@ -1224,6 +1240,7 @@
|
|
|
1224
1240
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
1225
1241
|
padding: ${({theme:o})=>`${o.spacing[2]} ${o.spacing[3]}`};
|
|
1226
1242
|
flex-shrink: 0;
|
|
1243
|
+
flex-wrap: wrap;
|
|
1227
1244
|
|
|
1228
1245
|
${({theme:o})=>o.brutalism?s.css`
|
|
1229
1246
|
border-top: ${o.brutalism.borderWidth} solid
|
|
@@ -1268,7 +1285,9 @@
|
|
|
1268
1285
|
display: flex;
|
|
1269
1286
|
align-items: center;
|
|
1270
1287
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
1271
|
-
|
|
1288
|
+
flex-wrap: wrap;
|
|
1289
|
+
justify-content: center;
|
|
1290
|
+
`,yo=s.button`
|
|
1272
1291
|
display: inline-flex;
|
|
1273
1292
|
align-items: center;
|
|
1274
1293
|
justify-content: center;
|
|
@@ -1311,12 +1330,12 @@
|
|
|
1311
1330
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
1312
1331
|
outline-offset: 2px;
|
|
1313
1332
|
}
|
|
1314
|
-
`,_n=4;function Hn(o,r){return o?.key!==r?t.jsx(Or,{size:14}):o.direction==="asc"?t.jsx(
|
|
1333
|
+
`,_n=4;function Hn(o,r){return o?.key!==r?t.jsx(Or,{size:14}):o.direction==="asc"?t.jsx(Lr,{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:p,caption:u,emptyMessage:f="No data",loading:$,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:T,rowColor:I,stripeColor:M,className:N,style:P}){const{activeSort:L,sortedData:H,handleSort:ro}=Sn({data:r,sort:w,defaultSort:v,onSortChange:y}),{activePage:D,totalPages:V,displayData:so,handlePageChange:U}=zn({data:H,pageSize:k,page:j,defaultPage:W,totalRows:O,onPageChange:E}),G=h=>{const F=ro(h);m?.({sort:F,page:D})},Y=h=>{U(h),m?.({sort:L,page:h})},no=(h,F)=>String(n?h[n]:F),B=!$&&so.length===0,A=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:T,$borderColor:S,$stickyHeader:d,children:t.jsx(co,{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:()=>G(h.key),"aria-label":`Sort by ${h.header}${L?.key===h.key?`, ${L.direction}ending`:""}`,children:[h.header,t.jsx(Rn,{"aria-hidden":"true",children:Hn(L,h.key)})]}):h.header},h.key))})}),t.jsx(Wn,{$striped:i,$rowColor:I,$stripeColor:M,children:$?Array.from({length:A}).map((h,F)=>t.jsx(co,{children:o.map(Z=>t.jsx(Nn,{$size:e,$bordered:l,$borderColor:S,children:t.jsx(Fn,{})},Z.key))},F)):B?t.jsx("tr",{children:t.jsx(Ln,{colSpan:o.length,children:f})}):so.map((h,F)=>{const Z=b?En:co;return t.jsx(Z,{onClick:b?()=>b(h):void 0,$accentColor:b?S:void 0,children:o.map(g=>t.jsx(ar,{$size:e,$bordered:l,$borderColor:S,children:g.render?g.render(h[g.key],h,F):String(h[g.key]??"")||" "},g.key))},no(h,F))})})]}),Q=(q||K)&&t.jsxs(Bn,{$hasPageSizeOptions:K,children:[K&&t.jsxs(Vn,{children:["Rows per page:",t.jsx(wo,{size:"sm",value:String(k),options:x.map(h=>({value:String(h),label:String(h)})),onChange:h=>z?.(Number(h.target.value)),"aria-label":"Rows per page"})]}),q&&t.jsxs(An,{children:[t.jsx(yo,{type:"button",onClick:()=>Y(D-1),disabled:D<=1,"aria-label":"Previous page",children:"←"}),jn(D,V).map((h,F)=>h==="..."?t.jsx("span",{"aria-hidden":"true",style:{padding:"0 4px"},children:"…"},`e${F}`):t.jsx(yo,{type:"button",$active:h===D,onClick:()=>Y(h),"aria-label":`Page ${h}`,"aria-current":h===D?"page":void 0,children:h},h)),t.jsx(yo,{type:"button",onClick:()=>Y(D+1),disabled:D>=V,"aria-label":"Next page",children:"→"})]})]});return t.jsxs(Cn,{$borderColor:S,$stickyPagination:p,className:N,style:P,children:[p?t.jsx(In,{children:J}):J,Q]})}lr.displayName="Table";const Un=s.p`
|
|
1315
1334
|
margin: 0;
|
|
1316
1335
|
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
1317
1336
|
color: ${({theme:o})=>o.colors.neutral[600]};
|
|
1318
1337
|
line-height: 1.5;
|
|
1319
|
-
`,
|
|
1338
|
+
`,Yn=s.button`
|
|
1320
1339
|
display: inline-flex;
|
|
1321
1340
|
align-items: center;
|
|
1322
1341
|
justify-content: center;
|
|
@@ -1356,7 +1375,7 @@
|
|
|
1356
1375
|
box-shadow: 2px 2px 0 ${o.colors.neutral[900]};
|
|
1357
1376
|
}
|
|
1358
1377
|
`}
|
|
1359
|
-
`;function
|
|
1378
|
+
`;function jo({open:o,title:r="Are you sure?",message:n,confirmLabel:e="Confirm",cancelLabel:i="Cancel",variant:l="default",size:d="sm",onConfirm:p,onCancel:u}){return t.jsx(ko,{open:o,onClose:u,title:r,size:d,closeOnBackdrop:!1,footer:t.jsxs(t.Fragment,{children:[t.jsx(uo,{variant:"outline",onClick:u,children:i}),l==="danger"?t.jsx(Yn,{type:"button",onClick:p,children:e}):t.jsx(uo,{variant:"primary",onClick:p,children:e})]}),children:t.jsx(Un,{children:n})})}jo.displayName="ConfirmDialog";const cr=a.createContext(null);function qn({children:o}){const[r,n]=a.useState(null),e=a.useCallback(d=>new Promise(p=>{n({...d,resolve:p})}),[]),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(jo,{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`
|
|
1360
1379
|
position: relative;
|
|
1361
1380
|
display: inline-flex;
|
|
1362
1381
|
flex-direction: column;
|
|
@@ -1465,7 +1484,7 @@
|
|
|
1465
1484
|
align-items: center;
|
|
1466
1485
|
justify-content: space-between;
|
|
1467
1486
|
margin-bottom: ${({theme:o})=>o.spacing[3]};
|
|
1468
|
-
`,
|
|
1487
|
+
`,Oo=s.button`
|
|
1469
1488
|
display: inline-flex;
|
|
1470
1489
|
align-items: center;
|
|
1471
1490
|
justify-content: center;
|
|
@@ -1512,7 +1531,7 @@
|
|
|
1512
1531
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
1513
1532
|
padding: ${({theme:o})=>o.spacing[1]};
|
|
1514
1533
|
margin-bottom: ${({theme:o})=>o.spacing[.5]};
|
|
1515
|
-
`,
|
|
1534
|
+
`,ho=s.button`
|
|
1516
1535
|
display: flex;
|
|
1517
1536
|
align-items: center;
|
|
1518
1537
|
justify-content: center;
|
|
@@ -1550,7 +1569,7 @@
|
|
|
1550
1569
|
box-shadow: 2px 2px 0 ${i.colors.neutral[900]};
|
|
1551
1570
|
`}
|
|
1552
1571
|
`}
|
|
1553
|
-
`,et=["January","February","March","April","May","June","July","August","September","October","November","December"],it=["Su","Mo","Tu","We","Th","Fr","Sa"];function
|
|
1572
|
+
`,et=["January","February","March","April","May","June","July","August","September","October","November","December"],it=["Su","Mo","Tu","We","Th","Fr","Sa"];function Ro(o,r){return new Date(o,r+1,0).getDate()}function at(o,r){return new Date(o,r,1).getDay()}function io(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 Lo(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 mo(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 eo(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:p=!1,minDate:u,maxDate:f,formatDate:$,error:w,required:v,helperText:y,mode:k="single",nameFrom:j,nameTo:W,valueFrom:O,valueTo:E}){const x=k==="range",z=mo(n??""),m=mo(O??""),b=mo(E??""),S=new Date,T=()=>x?m??b??S:z??S,[I,M]=a.useState(!1),[N,P]=a.useState(()=>T().getFullYear()),[L,H]=a.useState(()=>T().getMonth()),[ro,D]=a.useState("from"),V=a.useRef(null);a.useEffect(()=>{if(!I)return;const g=R=>{V.current&&!V.current.contains(R.target)&&(M(!1),x&&D("from"))};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[I,x]),a.useEffect(()=>{!x&&z&&(P(z.getFullYear()),H(z.getMonth()))},[n,x]),a.useEffect(()=>{x&&m&&(P(m.getFullYear()),H(m.getMonth()))},[O,x]);const U=(()=>{if(!x)return z?$?$(z):Lo(z):"";if(!m&&!b)return"";const g=$??Lo;return m&&b?`${g(m)} - ${g(b)}`:m?`${g(m)} - ...`:""})(),G=x?!!(m||b):!!z,Y=g=>{const R=new Date(N,L,g);if(!x){e(o??"",eo(R)),M(!1);return}if(ro==="from"){e(j??"",eo(R)),D("to");return}if(!m){e(j??"",eo(R)),D("to");return}if(io(R,m)){e(j??"",""),e(W??"",""),D("from");return}if(R>=m){e(W??"",eo(R)),D("from"),M(!1);return}e(W??"",eo(m)),e(j??"",eo(R)),D("from"),M(!1)},no=g=>{g.stopPropagation(),x?(e(j??"",""),e(W??"",""),D("from")):e(o??"","")},B=()=>{if(d)return;const g=!I;M(g),!g&&x&&D("from")},A=g=>{if((g.key==="Enter"||g.key===" ")&&!d){g.preventDefault();const R=!I;M(R),!R&&x&&D("from")}g.key==="Escape"&&(M(!1),x&&D("from"))},q=()=>{L===0?(H(11),P(g=>g-1)):H(g=>g-1)},K=()=>{L===11?(H(0),P(g=>g+1)):H(g=>g+1)},J=Ro(N,L),Q=at(N,L),h=[],F=Ro(L===0?N-1:N,L===0?11:L-1);for(let g=Q-1;g>=0;g--)h.push({day:F-g,currentMonth:!1});for(let g=1;g<=J;g++)h.push({day:g,currentMonth:!0});const Z=42-h.length;for(let g=1;g<=Z;g++)h.push({day:g,currentMonth:!1});return t.jsx(So,{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":I,tabIndex:d?-1:0,onClick:B,onKeyDown:A,children:[t.jsx(Jn,{$hasValue:G,children:U||i}),p&&G?t.jsx(Zn,{type:"button",onClick:no,"aria-label":"Clear date",children:t.jsx(go,{size:14})}):t.jsx(Qn,{"aria-hidden":"true",children:t.jsx(Nr,{size:14})})]}),I&&t.jsxs(ot,{role:"dialog","aria-label":"Calendar",children:[t.jsxs(rt,{children:[t.jsx(Oo,{type:"button",onClick:q,"aria-label":"Previous month",children:t.jsx(Vr,{size:16})}),t.jsxs(st,{children:[et[L]," ",N]}),t.jsx(Oo,{type:"button",onClick:K,"aria-label":"Next month",children:t.jsx(_r,{size:16})})]}),t.jsxs(nt,{children:[it.map(g=>t.jsx(tt,{children:g},g)),h.map((g,R)=>{if(!g.currentMonth)return t.jsx(ho,{type:"button",$currentMonth:!1,$selected:!1,$today:!1,disabled:!0,tabIndex:-1,children:g.day},R);const c=new Date(N,L,g.day),C=io(c,S),_=lt(c,u,f);if(x){const ao=m?io(c,m):!1,zo=b?io(c,b):!1,ur=m&&b?c>m&&c<b:!1;return t.jsx(ho,{type:"button",$currentMonth:!0,$selected:!1,$today:C,$rangeStart:ao,$rangeEnd:zo,$inRange:ur,disabled:_,"aria-label":Po(c),"aria-pressed":ao||zo,onClick:()=>Y(g.day),children:g.day},R)}const oo=z?io(c,z):!1;return t.jsx(ho,{type:"button",$currentMonth:!0,$selected:oo,$today:C,disabled:_,"aria-label":Po(c),"aria-pressed":oo,onClick:()=>Y(g.day),children:g.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 po={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{...po,colors:{...po.colors,primary:{50:"#fffff0",500:o,700:o,contrast:ct(o)}}}}function ut({theme:o=po,children:r}){return t.jsx(s.ThemeProvider,{theme:o,children:r})}const pt=s.createGlobalStyle`
|
|
1554
1573
|
*, *::before, *::after {
|
|
1555
1574
|
box-sizing: border-box;
|
|
1556
1575
|
margin: 0;
|
|
@@ -1567,4 +1586,8 @@
|
|
|
1567
1586
|
button, input, select, textarea {
|
|
1568
1587
|
font-family: inherit;
|
|
1569
1588
|
}
|
|
1570
|
-
|
|
1589
|
+
|
|
1590
|
+
button, a, [role="button"] {
|
|
1591
|
+
touch-action: manipulation;
|
|
1592
|
+
}
|
|
1593
|
+
`;exports.Badge=No;exports.Button=uo;exports.Checkbox=rr;exports.CollapsibleCard=tr;exports.ConfirmDialog=jo;exports.ConfirmProvider=qn;exports.DatePicker=dr;exports.Editable=_o;exports.Field=Ho;exports.Form=or;exports.FormField=So;exports.GlobalStyles=pt;exports.Input=Fo;exports.Link=vo;exports.Modal=ko;exports.Radio=sr;exports.Select=wo;exports.Spinner=er;exports.Switch=nr;exports.Table=lr;exports.Textarea=Bo;exports.ThemeProvider=ut;exports.Toast=Qo;exports.ToastProvider=Cs;exports.composeValidators=Vs;exports.createNeoBrutalTheme=dt;exports.isEmail=Ns;exports.isUrl=Fs;exports.maxLength=Ps;exports.minLength=Ls;exports.neoBrutalTheme=po;exports.pattern=Bs;exports.required=Rs;exports.useConfirm=Kn;exports.useForm=Os;exports.useTable=vn;exports.useToast=Is;
|