blunt-ui 0.2.1 → 0.2.2
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 +1 -5
- package/dist/index.cjs +34 -19
- package/dist/index.js +86 -69
- package/package.json +1 -8
package/README.md
CHANGED
|
@@ -71,11 +71,7 @@ Sizes: `sm`, `md`, `lg`, `fullscreen`.
|
|
|
71
71
|
A card with a clickable header that shows/hides its content. Supports controlled and uncontrolled modes, an optional subtitle, a slot for header actions, and an `accentColor` prop to tint the border and chevron.
|
|
72
72
|
|
|
73
73
|
```tsx
|
|
74
|
-
<CollapsibleCard
|
|
75
|
-
title="blunt-ui"
|
|
76
|
-
subtitle="Subtitle"
|
|
77
|
-
defaultOpen
|
|
78
|
-
>
|
|
74
|
+
<CollapsibleCard title="blunt-ui" subtitle="Subtitle" defaultOpen>
|
|
79
75
|
React component library in neo-brutalism style.
|
|
80
76
|
</CollapsibleCard>
|
|
81
77
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
letter-spacing: 0.04em;
|
|
11
11
|
cursor: default;
|
|
12
12
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
text-overflow: ellipsis;
|
|
16
|
+
max-width: 20ch;
|
|
13
17
|
|
|
14
18
|
${({$size:o,theme:s})=>({sm:r.css`
|
|
15
19
|
padding: 2px 8px;
|
|
@@ -170,7 +174,7 @@
|
|
|
170
174
|
cursor: not-allowed;
|
|
171
175
|
opacity: 0.6;
|
|
172
176
|
}
|
|
173
|
-
`,
|
|
177
|
+
`,N=r.div`
|
|
174
178
|
display: inline-flex;
|
|
175
179
|
align-items: center;
|
|
176
180
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
@@ -187,16 +191,16 @@
|
|
|
187
191
|
&:hover {
|
|
188
192
|
opacity: 0.8;
|
|
189
193
|
}
|
|
190
|
-
`;function H({ref:o,type:s="text",size:n="md",variant:e="default",label:c,helperText:l,error:i,leftElement:d,rightElement:p,clearable:u,onClear:x,fullWidth:
|
|
194
|
+
`;function H({ref:o,type:s="text",size:n="md",variant:e="default",label:c,helperText:l,error:i,leftElement:d,rightElement:p,clearable:u,onClear:x,fullWidth:v,id:b,value:$,defaultValue:m,onChange:C,...h}){const k=a.useId(),j=b??k,S=`${j}-hint`,[z,f]=a.useState(m??""),g=$!==void 0,y=g?$:z,w=typeof i=="string"?i:void 0,T=!!(l||i),O=R=>{g||f(R.target.value),C?.(R)},ro=()=>{g||f(""),x?.()};return t.jsxs(eo,{$fullWidth:v,children:[c&&t.jsx(ao,{htmlFor:j,children:c}),t.jsxs(lo,{$size:n,$variant:e,$error:!!i,children:[d&&t.jsx(N,{children:d}),t.jsx(co,{id:j,ref:o,type:s,value:y,onChange:O,...h,"aria-invalid":!!i,"aria-describedby":T?S:void 0}),u&&y&&t.jsx(uo,{type:"button",onClick:ro,"aria-label":"Clear input",children:"✕"}),p&&t.jsx(N,{children:p})]}),T&&t.jsx(io,{id:S,$error:!!i,children:w??l})]})}H.displayName="Input";const fo=r.keyframes`
|
|
191
195
|
from { opacity: 0; }
|
|
192
196
|
to { opacity: 1; }
|
|
193
197
|
`,po=r.keyframes`
|
|
194
198
|
from { opacity: 1; }
|
|
195
199
|
to { opacity: 0; }
|
|
196
|
-
`,
|
|
200
|
+
`,go=r.keyframes`
|
|
197
201
|
from { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
198
202
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
199
|
-
`,
|
|
203
|
+
`,bo=r.keyframes`
|
|
200
204
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
201
205
|
to { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
202
206
|
`,$o=r.div`
|
|
@@ -218,7 +222,7 @@
|
|
|
218
222
|
display: flex;
|
|
219
223
|
flex-direction: column;
|
|
220
224
|
max-height: 90vh;
|
|
221
|
-
animation: ${({$closing:o})=>o?go
|
|
225
|
+
animation: ${({$closing:o})=>o?bo:go} 0.15s ease
|
|
222
226
|
forwards;
|
|
223
227
|
|
|
224
228
|
${({$size:o})=>o==="sm"&&r.css`
|
|
@@ -248,7 +252,7 @@
|
|
|
248
252
|
font-size: ${({theme:o})=>o.fontSizes.lg};
|
|
249
253
|
font-weight: 600;
|
|
250
254
|
margin: 0;
|
|
251
|
-
`,
|
|
255
|
+
`,wo=r.button`
|
|
252
256
|
display: inline-flex;
|
|
253
257
|
align-items: center;
|
|
254
258
|
justify-content: center;
|
|
@@ -273,7 +277,7 @@
|
|
|
273
277
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
274
278
|
outline-offset: 2px;
|
|
275
279
|
}
|
|
276
|
-
`,
|
|
280
|
+
`,vo=r.div`
|
|
277
281
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
278
282
|
overflow-y: auto;
|
|
279
283
|
flex: 1;
|
|
@@ -285,7 +289,7 @@
|
|
|
285
289
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
286
290
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
287
291
|
flex-shrink: 0;
|
|
288
|
-
`,
|
|
292
|
+
`,ho=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function V(o){return Array.from(o.querySelectorAll(ho))}function q({open:o,onClose:s,title:n,children:e,footer:c,size:l="md",closeOnBackdrop:i=!0,closeOnEscape:d=!0,ariaLabelledBy:p,ariaDescribedBy:u}){const x=a.useRef(null),v=a.useId(),b=p??(n?v:void 0),[$,m]=a.useState(o),[C,h]=a.useState(!1);return a.useEffect(()=>{if(o)m(!0),h(!1);else if($){h(!0);const k=setTimeout(()=>{m(!1),h(!1)},150);return()=>clearTimeout(k)}},[o,$]),a.useEffect(()=>{if(!o)return;const k=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=k}},[o]),a.useEffect(()=>{if(!o||!x.current)return;const k=x.current,j=document.activeElement;(V(k)[0]??k).focus();const z=f=>{if(f.key==="Escape"&&d){s();return}if(f.key!=="Tab")return;const g=V(k);if(g.length===0){f.preventDefault();return}const y=g[0],w=g[g.length-1];f.shiftKey?document.activeElement===y&&(f.preventDefault(),w.focus()):document.activeElement===w&&(f.preventDefault(),y.focus())};return document.addEventListener("keydown",z),()=>{document.removeEventListener("keydown",z),j?.focus()}},[o,d,s,$]),$?A.createPortal(t.jsx($o,{$closing:C,onClick:i?s:void 0,children:t.jsxs(xo,{ref:x,role:"dialog","aria-modal":"true","aria-labelledby":b,"aria-describedby":u,$size:l,$closing:C,tabIndex:-1,onClick:k=>k.stopPropagation(),children:[t.jsxs(yo,{children:[n&&t.jsx(mo,{id:v,children:n}),t.jsx(wo,{onClick:s,"aria-label":"Close modal",children:"×"})]}),t.jsx(vo,{children:e}),c&&t.jsx(ko,{children:c})]})}),document.body):null}q.displayName="Modal";const _=(...o)=>o.filter((s,n,e)=>!!s&&s.trim()!==""&&e.indexOf(s)===n).join(" ").trim();const Co=o=>o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const jo=o=>o.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,e)=>e?e.toUpperCase():n.toLowerCase());const M=o=>{const s=jo(o);return s.charAt(0).toUpperCase()+s.slice(1)};var F={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 So=o=>{for(const s in o)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1},zo=a.createContext({}),Io=()=>a.useContext(zo),To=a.forwardRef(({color:o,size:s,strokeWidth:n,absoluteStrokeWidth:e,className:c="",children:l,iconNode:i,...d},p)=>{const{size:u=24,strokeWidth:x=2,absoluteStrokeWidth:v=!1,color:b="currentColor",className:$=""}=Io()??{},m=e??v?Number(n??x)*24/Number(s??u):n??x;return a.createElement("svg",{ref:p,...F,width:s??u??F.width,height:s??u??F.height,stroke:o??b,strokeWidth:m,className:_("lucide",$,c),...!l&&!So(d)&&{"aria-hidden":"true"},...d},[...i.map(([C,h])=>a.createElement(C,h)),...Array.isArray(l)?l:[l]])});const K=(o,s)=>{const n=a.forwardRef(({className:e,...c},l)=>a.createElement(To,{ref:l,iconNode:s,className:_(`lucide-${Co(M(o))}`,`lucide-${o}`,e),...c}));return n.displayName=M(o),n};const Wo=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],U=K("chevron-down",Wo);const Bo=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Z=K("x",Bo),Oo=r.keyframes`
|
|
289
293
|
from { opacity: 0; transform: translateY(12px); }
|
|
290
294
|
to { opacity: 1; transform: translateY(0); }
|
|
291
295
|
`,Eo=r.keyframes`
|
|
@@ -330,7 +334,7 @@
|
|
|
330
334
|
border: ${o.brutalism.borderWidth} solid ${n};
|
|
331
335
|
box-shadow: ${o.brutalism.shadowOffset} ${o.brutalism.shadowOffset}
|
|
332
336
|
0 ${n};
|
|
333
|
-
`,
|
|
337
|
+
`,Ro=r(Lo)`
|
|
334
338
|
${({$variant:o,theme:s})=>s.brutalism?{success:W(s,s.colors.success[50],s.colors.success[500]),error:W(s,s.colors.error[50],s.colors.error[500]),warning:W(s,s.colors.warning[50],s.colors.warning[500]),info:W(s,s.colors.info[50],s.colors.info[500])}[o]:{success:r.css`
|
|
335
339
|
background: ${s.colors.success[50]};
|
|
336
340
|
border-left: 4px solid ${s.colors.success[500]};
|
|
@@ -348,7 +352,7 @@
|
|
|
348
352
|
border-left: 4px solid ${s.colors.info[500]};
|
|
349
353
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
350
354
|
`}[o]}
|
|
351
|
-
`,
|
|
355
|
+
`,No=r.p`
|
|
352
356
|
flex: 1;
|
|
353
357
|
margin: 0;
|
|
354
358
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
@@ -377,7 +381,7 @@
|
|
|
377
381
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
378
382
|
outline-offset: 2px;
|
|
379
383
|
}
|
|
380
|
-
`;function L({open:o,onClose:s,message:n,variant:e="info",duration:c=4e3,position:l="bottom-right"}){const[i,d]=a.useState(o),[p,u]=a.useState(!1);return a.useEffect(()=>{if(o)d(!0),u(!1);else if(i){u(!0);const x=setTimeout(()=>{d(!1),u(!1)},200);return()=>clearTimeout(x)}},[o,i]),a.useEffect(()=>{if(!o||c===0)return;const x=setTimeout(s,c);return()=>clearTimeout(x)},[o,c,s]),i?A.createPortal(t.jsxs(
|
|
384
|
+
`;function L({open:o,onClose:s,message:n,variant:e="info",duration:c=4e3,position:l="bottom-right"}){const[i,d]=a.useState(o),[p,u]=a.useState(!1);return a.useEffect(()=>{if(o)d(!0),u(!1);else if(i){u(!0);const x=setTimeout(()=>{d(!1),u(!1)},200);return()=>clearTimeout(x)}},[o,i]),a.useEffect(()=>{if(!o||c===0)return;const x=setTimeout(s,c);return()=>clearTimeout(x)},[o,c,s]),i?A.createPortal(t.jsxs(Ro,{$position:l,$variant:e,$closing:p,role:"alert","aria-live":"polite",children:[t.jsx(No,{children:n}),t.jsx(Vo,{onClick:s,"aria-label":"Close notification",children:t.jsx(Z,{size:14,strokeWidth:2.5})})]}),document.body):null}L.displayName="Toast";const Mo=r.form`
|
|
381
385
|
display: flex;
|
|
382
386
|
flex-direction: column;
|
|
383
387
|
gap: ${({theme:o})=>o.spacing[4]};
|
|
@@ -492,7 +496,7 @@
|
|
|
492
496
|
display: flex;
|
|
493
497
|
align-items: center;
|
|
494
498
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
495
|
-
`;function J({options:o,placeholder:s,size:n="md",variant:e="default",error:c,fullWidth:l,clearable:i,onClear:d,id:p,value:u,defaultValue:x,onChange:
|
|
499
|
+
`;function J({options:o,placeholder:s,size:n="md",variant:e="default",error:c,fullWidth:l,clearable:i,onClear:d,id:p,value:u,defaultValue:x,onChange:v,...b}){const $=a.useId(),m=p??$,C=`${m}-hint`,h=typeof c=="string"?c:void 0,[k,j]=a.useState(x??""),S=u!==void 0,z=S?u:k,f=w=>{S||j(w.target.value),v?.(w)},g=()=>{S||j(""),d?.()},y=i&&!!z;return t.jsxs(Ho,{$fullWidth:l,children:[t.jsxs(qo,{children:[t.jsxs(Ko,{id:m,$size:n,$variant:e,$error:!!c,"aria-invalid":!!c,"aria-describedby":h?C:void 0,value:z,onChange:f,...b,children:[s&&t.jsx("option",{value:"",disabled:!0,children:s}),o.map(w=>t.jsx("option",{value:w.value,disabled:w.disabled,children:w.label},w.value))]}),y?t.jsx(Uo,{type:"button",onClick:g,"aria-label":"Clear selection",children:t.jsx(Z,{size:14})}):t.jsx(Zo,{"aria-hidden":"true",children:t.jsx(U,{size:14})})]}),h&&t.jsx(_o,{id:C,$error:!0,children:h})]})}J.displayName="Select";const Xo=r.a`
|
|
496
500
|
text-decoration: underline;
|
|
497
501
|
text-underline-offset: 2px;
|
|
498
502
|
transition: color 0.15s;
|
|
@@ -532,7 +536,7 @@
|
|
|
532
536
|
`,Jo=r.button`
|
|
533
537
|
width: 100%;
|
|
534
538
|
display: flex;
|
|
535
|
-
align-items:
|
|
539
|
+
align-items: flex-start;
|
|
536
540
|
gap: ${({theme:o})=>o.spacing[3]};
|
|
537
541
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
538
542
|
background: ${({theme:o})=>o.brutalism?o.colors.neutral[100]:o.colors.neutral[0]};
|
|
@@ -561,12 +565,23 @@
|
|
|
561
565
|
display: block;
|
|
562
566
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
563
567
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
564
|
-
margin-top: ${({theme:o})=>o.spacing[1]};
|
|
565
568
|
`,rs=r.div`
|
|
569
|
+
display: flex;
|
|
570
|
+
flex-direction: row;
|
|
571
|
+
align-items: center;
|
|
572
|
+
justify-content: space-between;
|
|
573
|
+
margin-top: ${({theme:o})=>o.spacing[1]};
|
|
574
|
+
|
|
575
|
+
@media (max-width: 640px) {
|
|
576
|
+
flex-direction: column;
|
|
577
|
+
align-items: flex-start;
|
|
578
|
+
gap: ${({theme:o})=>o.spacing[2]};
|
|
579
|
+
}
|
|
580
|
+
`,ns=r.div`
|
|
566
581
|
display: flex;
|
|
567
582
|
align-items: center;
|
|
568
583
|
gap: ${({theme:o})=>o.spacing[2]};
|
|
569
|
-
`,
|
|
584
|
+
`,ts=r.span`
|
|
570
585
|
display: inline-flex;
|
|
571
586
|
align-items: center;
|
|
572
587
|
justify-content: center;
|
|
@@ -574,13 +589,13 @@
|
|
|
574
589
|
transition: transform 0.2s ease;
|
|
575
590
|
transform: ${({$open:o})=>o?"rotate(180deg)":"rotate(0deg)"};
|
|
576
591
|
color: ${({theme:o,$accentColor:s})=>s??o.colors.neutral[500]};
|
|
577
|
-
`,
|
|
592
|
+
`,es=r.div`
|
|
578
593
|
display: grid;
|
|
579
594
|
grid-template-rows: ${({$open:o})=>o?"1fr":"0fr"};
|
|
580
595
|
transition: grid-template-rows 0.2s ease;
|
|
581
|
-
`,es=r.div`
|
|
582
|
-
overflow: hidden;
|
|
583
596
|
`,as=r.div`
|
|
597
|
+
overflow: hidden;
|
|
598
|
+
`,is=r.div`
|
|
584
599
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
585
600
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
586
|
-
`;function oo({title:o,children:s,defaultOpen:n=!1,open:e,onToggle:c,subtitle:l,headerActions:i,accentColor:d}){const[p,u]=a.useState(n),x=a.useId(),
|
|
601
|
+
`;function oo({title:o,children:s,defaultOpen:n=!1,open:e,onToggle:c,subtitle:l,headerActions:i,accentColor:d}){const[p,u]=a.useState(n),x=a.useId(),v=e!==void 0,b=v?e:p,$=()=>{const m=!b;v||u(m),c?.(m)};return t.jsxs(Go,{$accentColor:d,children:[t.jsxs(Jo,{type:"button",$open:b,$accentColor:d,"aria-expanded":b,"aria-controls":x,onClick:$,children:[t.jsxs(Qo,{children:[t.jsx(os,{children:o}),(l||i)&&t.jsxs(rs,{children:[l&&t.jsx(ss,{children:l}),i&&t.jsx(ns,{onClick:m=>m.stopPropagation(),children:i})]})]}),t.jsx(ts,{$open:b,$accentColor:d,"aria-hidden":"true",children:t.jsx(U,{size:18,strokeWidth:2.5})})]}),t.jsx(es,{$open:b,children:t.jsx(as,{id:x,role:"region","aria-label":o,children:t.jsx(is,{children:s})})})]})}oo.displayName="CollapsibleCard";const so=a.createContext(null);function ls({children:o}){const[s,n]=a.useState(null),e=a.useCallback(l=>{n({...l,id:Date.now()})},[]),c=a.useMemo(()=>{const l=i=>e(i);return l.success=(i,d)=>e({...d,message:i,variant:"success"}),l.error=(i,d)=>e({...d,message:i,variant:"error"}),l.warning=(i,d)=>e({...d,message:i,variant:"warning"}),l.info=(i,d)=>e({...d,message:i,variant:"info"}),l},[e]);return t.jsxs(so.Provider,{value:{toast:c},children:[o,s&&t.jsx(L,{open:!0,onClose:()=>n(null),message:s.message,variant:s.variant,duration:s.duration,position:s.position},s.id)]})}function cs(){const o=a.useContext(so);if(!o)throw new Error("useToast must be used within a ToastProvider");return o}function ds({initialValues:o,validate:s,onSubmit:n,onError:e}){const[c,l]=a.useState(o),[i,d]=a.useState({}),[p,u]=a.useState({}),[x,v]=a.useState(!1),b=a.useRef(c);b.current=c;const $=a.useCallback(f=>{if(!s)return{};const g=s(f);return Object.fromEntries(Object.entries(g).filter(([,y])=>y!==void 0))},[s]),m=a.useRef(p);m.current=p;const C=a.useCallback(f=>{const{name:g,value:y}=f.target,w={...b.current,[g]:y};l(w),m.current[g]&&d($(w))},[$]),h=a.useCallback(f=>{const{name:g}=f.target;u(y=>({...y,[g]:!0})),d($(b.current))},[$]),k=a.useCallback(f=>{f?.preventDefault();const g=Object.keys(b.current).reduce((T,O)=>({...T,[O]:!0}),{});u(g);const y=$(b.current);if(d(y),Object.keys(y).length>0){e?.(y);return}(async()=>{v(!0);try{await n?.(b.current)}finally{v(!1)}})()},[$,n,e]),j=a.useCallback((f,g)=>{l(y=>({...y,[f]:g}))},[]),S=a.useCallback(()=>{l(o),d({}),u({}),v(!1)},[o]),z=Object.fromEntries(Object.entries(i).filter(([f])=>p[f]));return{values:c,errors:z,touched:p,handleChange:C,handleBlur:h,handleSubmit:k,setFieldValue:j,reset:S,isSubmitting:x}}const P={primary:{50:"#f0f8ff",500:"#0070f3",700:"#005bb5"},neutral:{0:"#ffffff",100:"#f5f5f5",200:"#eaeaea",300:"#cacaca",400:"#cccccc",500:"#666666",600:"#333333",900:"#111111"},error:{50:"#fef2f2",500:"#d32f2f"},success:{50:"#f0fdf4",500:"#16a34a"},warning:{50:"#fffbeb",500:"#d97706"},info:{50:"#eff6ff",500:"#2563eb"}},us={1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px"},fs={md:"6px"},ps={modal:1e3,toast:1100},gs={xs:"12px",sm:"14px",md:"16px",lg:"18px"},bs={colors:{...P,primary:{...P.primary,contrast:"#ffffff"}},spacing:us,fontSizes:gs,radius:fs,zIndex:ps,shadows:{focusRing:"0 0 0 2px rgba(0, 112, 243, 0.25)"}};function $s(o){const s=parseInt(o.slice(1,3),16)/255,n=parseInt(o.slice(3,5),16)/255,e=parseInt(o.slice(5,7),16)/255,c=i=>i<=.03928?i/12.92:((i+.055)/1.055)**2.4;return .2126*c(s)+.7152*c(n)+.0722*c(e)>.179?"#111111":"#ffffff"}const B={colors:{primary:{50:"#fffde6",500:"#ffd000",700:"#ffd000",contrast:"#111111"},neutral:{0:"#ffffff",100:"#f5f0e8",200:"#e8e3db",300:"#ccc8c0",400:"#a8a49c",500:"#706c64",600:"#3c3830",900:"#111111"},error:{50:"#fff0f0",500:"#ff3333"},success:{50:"#f0fff4",500:"#00cc44"},warning:{50:"#fffbe6",500:"#ff9900"},info:{50:"#f0f0ff",500:"#3333ff"}},spacing:{1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px"},radius:{md:"2px"},zIndex:{modal:1e3,toast:1100},fontSizes:{xs:"12px",sm:"14px",md:"16px",lg:"18px"},shadows:{focusRing:"3px 3px 0 #111111"},brutalism:{borderWidth:"2px",shadowOffset:"4px"}};function xs(o){return{...B,colors:{...B.colors,primary:{50:"#fffff0",500:o,700:o,contrast:$s(o)}}}}function ys({theme:o=B,children:s}){return t.jsx(r.ThemeProvider,{theme:o,children:s})}exports.Badge=D;exports.Button=Y;exports.CollapsibleCard=oo;exports.Form=X;exports.FormField=G;exports.Input=H;exports.Link=Q;exports.Modal=q;exports.Select=J;exports.ThemeProvider=ys;exports.Toast=L;exports.ToastProvider=ls;exports.createNeoBrutalTheme=xs;exports.defaultTheme=bs;exports.neoBrutalTheme=B;exports.useForm=ds;exports.useToast=cs;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as l, jsxs as h } from "react/jsx-runtime";
|
|
2
2
|
import i, { css as s, keyframes as O, ThemeProvider as eo } from "styled-components";
|
|
3
|
-
import H, { useId as F, useState as z, useRef as
|
|
3
|
+
import H, { useId as F, useState as z, useRef as M, useEffect as j, useContext as Z, createContext as X, forwardRef as G, createElement as P, useCallback as B, useMemo as ao } from "react";
|
|
4
4
|
import { createPortal as J } from "react-dom";
|
|
5
5
|
const L = (o, r, n) => s`
|
|
6
6
|
background: ${r};
|
|
@@ -14,6 +14,10 @@ const L = (o, r, n) => s`
|
|
|
14
14
|
letter-spacing: 0.04em;
|
|
15
15
|
cursor: default;
|
|
16
16
|
border-radius: ${({ theme: o }) => o.radius.md};
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
max-width: 20ch;
|
|
17
21
|
|
|
18
22
|
${({ $size: o, theme: r }) => ({
|
|
19
23
|
sm: s`
|
|
@@ -298,7 +302,7 @@ const po = i.div`
|
|
|
298
302
|
opacity: 0.8;
|
|
299
303
|
}
|
|
300
304
|
`;
|
|
301
|
-
function
|
|
305
|
+
function wo({
|
|
302
306
|
ref: o,
|
|
303
307
|
type: r = "text",
|
|
304
308
|
size: n = "md",
|
|
@@ -313,11 +317,11 @@ function vo({
|
|
|
313
317
|
fullWidth: m,
|
|
314
318
|
id: $,
|
|
315
319
|
value: x,
|
|
316
|
-
defaultValue:
|
|
320
|
+
defaultValue: w,
|
|
317
321
|
onChange: S,
|
|
318
322
|
...C
|
|
319
323
|
}) {
|
|
320
|
-
const k = F(), I = $ ?? k, T = `${I}-hint`, [W, f] = z(
|
|
324
|
+
const k = F(), I = $ ?? k, T = `${I}-hint`, [W, f] = z(w ?? ""), g = x !== void 0, y = g ? x : W, v = typeof e == "string" ? e : void 0, E = !!(a || e), V = (D) => {
|
|
321
325
|
g || f(D.target.value), S?.(D);
|
|
322
326
|
}, io = () => {
|
|
323
327
|
g || f(""), b?.();
|
|
@@ -350,11 +354,11 @@ function vo({
|
|
|
350
354
|
),
|
|
351
355
|
p && /* @__PURE__ */ l(_, { children: p })
|
|
352
356
|
] }),
|
|
353
|
-
E && /* @__PURE__ */ l($o, { id: T, $error: !!e, children:
|
|
357
|
+
E && /* @__PURE__ */ l($o, { id: T, $error: !!e, children: v ?? a })
|
|
354
358
|
] });
|
|
355
359
|
}
|
|
356
|
-
|
|
357
|
-
const
|
|
360
|
+
wo.displayName = "Input";
|
|
361
|
+
const vo = O`
|
|
358
362
|
from { opacity: 0; }
|
|
359
363
|
to { opacity: 1; }
|
|
360
364
|
`, mo = O`
|
|
@@ -374,7 +378,7 @@ const wo = O`
|
|
|
374
378
|
align-items: center;
|
|
375
379
|
justify-content: center;
|
|
376
380
|
z-index: ${({ theme: o }) => o.zIndex.modal};
|
|
377
|
-
animation: ${({ $closing: o }) => o ? mo :
|
|
381
|
+
animation: ${({ $closing: o }) => o ? mo : vo} 0.15s ease
|
|
378
382
|
forwards;
|
|
379
383
|
`, zo = i.div`
|
|
380
384
|
position: relative;
|
|
@@ -477,14 +481,14 @@ function Lo({
|
|
|
477
481
|
ariaLabelledBy: p,
|
|
478
482
|
ariaDescribedBy: u
|
|
479
483
|
}) {
|
|
480
|
-
const b =
|
|
484
|
+
const b = M(null), m = F(), $ = p ?? (n ? m : void 0), [x, w] = z(o), [S, C] = z(!1);
|
|
481
485
|
return j(() => {
|
|
482
486
|
if (o)
|
|
483
|
-
|
|
487
|
+
w(!0), C(!1);
|
|
484
488
|
else if (x) {
|
|
485
489
|
C(!0);
|
|
486
490
|
const k = setTimeout(() => {
|
|
487
|
-
|
|
491
|
+
w(!1), C(!1);
|
|
488
492
|
}, 150);
|
|
489
493
|
return () => clearTimeout(k);
|
|
490
494
|
}
|
|
@@ -512,8 +516,8 @@ function Lo({
|
|
|
512
516
|
f.preventDefault();
|
|
513
517
|
return;
|
|
514
518
|
}
|
|
515
|
-
const y = g[0],
|
|
516
|
-
f.shiftKey ? document.activeElement === y && (f.preventDefault(),
|
|
519
|
+
const y = g[0], v = g[g.length - 1];
|
|
520
|
+
f.shiftKey ? document.activeElement === y && (f.preventDefault(), v.focus()) : document.activeElement === v && (f.preventDefault(), y.focus());
|
|
517
521
|
};
|
|
518
522
|
return document.addEventListener("keydown", W), () => {
|
|
519
523
|
document.removeEventListener("keydown", W), I?.focus();
|
|
@@ -562,7 +566,7 @@ const K = (o) => {
|
|
|
562
566
|
const r = Fo(o);
|
|
563
567
|
return r.charAt(0).toUpperCase() + r.slice(1);
|
|
564
568
|
};
|
|
565
|
-
var
|
|
569
|
+
var R = {
|
|
566
570
|
xmlns: "http://www.w3.org/2000/svg",
|
|
567
571
|
width: 24,
|
|
568
572
|
height: 24,
|
|
@@ -586,16 +590,16 @@ const Eo = (o) => {
|
|
|
586
590
|
absoluteStrokeWidth: m = !1,
|
|
587
591
|
color: $ = "currentColor",
|
|
588
592
|
className: x = ""
|
|
589
|
-
} = Vo() ?? {},
|
|
593
|
+
} = Vo() ?? {}, w = t ?? m ? Number(n ?? b) * 24 / Number(r ?? u) : n ?? b;
|
|
590
594
|
return P(
|
|
591
595
|
"svg",
|
|
592
596
|
{
|
|
593
597
|
ref: p,
|
|
594
|
-
...
|
|
595
|
-
width: r ?? u ??
|
|
596
|
-
height: r ?? u ??
|
|
598
|
+
...R,
|
|
599
|
+
width: r ?? u ?? R.width,
|
|
600
|
+
height: r ?? u ?? R.height,
|
|
597
601
|
stroke: o ?? $,
|
|
598
|
-
strokeWidth:
|
|
602
|
+
strokeWidth: w,
|
|
599
603
|
className: Q("lucide", x, c),
|
|
600
604
|
...!a && !Eo(d) && { "aria-hidden": "true" },
|
|
601
605
|
...d
|
|
@@ -622,11 +626,11 @@ const oo = (o, r) => {
|
|
|
622
626
|
);
|
|
623
627
|
return n.displayName = K(o), n;
|
|
624
628
|
};
|
|
625
|
-
const
|
|
626
|
-
const
|
|
629
|
+
const Ro = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], ro = oo("chevron-down", Ro);
|
|
630
|
+
const Mo = [
|
|
627
631
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
628
632
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
629
|
-
], no = oo("x",
|
|
633
|
+
], no = oo("x", Mo), Po = O`
|
|
630
634
|
from { opacity: 0; transform: translateY(12px); }
|
|
631
635
|
to { opacity: 1; transform: translateY(0); }
|
|
632
636
|
`, Yo = O`
|
|
@@ -968,10 +972,10 @@ function ar({
|
|
|
968
972
|
onChange: m,
|
|
969
973
|
...$
|
|
970
974
|
}) {
|
|
971
|
-
const x = F(),
|
|
975
|
+
const x = F(), w = p ?? x, S = `${w}-hint`, C = typeof c == "string" ? c : void 0, [k, I] = z(
|
|
972
976
|
b ?? ""
|
|
973
|
-
), T = u !== void 0, W = T ? u : k, f = (
|
|
974
|
-
T || I(
|
|
977
|
+
), T = u !== void 0, W = T ? u : k, f = (v) => {
|
|
978
|
+
T || I(v.target.value), m?.(v);
|
|
975
979
|
}, g = () => {
|
|
976
980
|
T || I(""), d?.();
|
|
977
981
|
}, y = e && !!W;
|
|
@@ -980,7 +984,7 @@ function ar({
|
|
|
980
984
|
/* @__PURE__ */ h(
|
|
981
985
|
tr,
|
|
982
986
|
{
|
|
983
|
-
id:
|
|
987
|
+
id: w,
|
|
984
988
|
$size: n,
|
|
985
989
|
$variant: t,
|
|
986
990
|
$error: !!c,
|
|
@@ -991,7 +995,7 @@ function ar({
|
|
|
991
995
|
...$,
|
|
992
996
|
children: [
|
|
993
997
|
r && /* @__PURE__ */ l("option", { value: "", disabled: !0, children: r }),
|
|
994
|
-
o.map((
|
|
998
|
+
o.map((v) => /* @__PURE__ */ l("option", { value: v.value, disabled: v.disabled, children: v.label }, v.value))
|
|
995
999
|
]
|
|
996
1000
|
}
|
|
997
1001
|
),
|
|
@@ -1070,7 +1074,7 @@ const dr = i.div`
|
|
|
1070
1074
|
`, ur = i.button`
|
|
1071
1075
|
width: 100%;
|
|
1072
1076
|
display: flex;
|
|
1073
|
-
align-items:
|
|
1077
|
+
align-items: flex-start;
|
|
1074
1078
|
gap: ${({ theme: o }) => o.spacing[3]};
|
|
1075
1079
|
padding: ${({ theme: o }) => o.spacing[4]};
|
|
1076
1080
|
background: ${({ theme: o }) => o.brutalism ? o.colors.neutral[100] : o.colors.neutral[0]};
|
|
@@ -1099,12 +1103,23 @@ const dr = i.div`
|
|
|
1099
1103
|
display: block;
|
|
1100
1104
|
font-size: ${({ theme: o }) => o.fontSizes.sm};
|
|
1101
1105
|
color: ${({ theme: o }) => o.colors.neutral[500]};
|
|
1102
|
-
margin-top: ${({ theme: o }) => o.spacing[1]};
|
|
1103
1106
|
`, $r = i.div`
|
|
1107
|
+
display: flex;
|
|
1108
|
+
flex-direction: row;
|
|
1109
|
+
align-items: center;
|
|
1110
|
+
justify-content: space-between;
|
|
1111
|
+
margin-top: ${({ theme: o }) => o.spacing[1]};
|
|
1112
|
+
|
|
1113
|
+
@media (max-width: 640px) {
|
|
1114
|
+
flex-direction: column;
|
|
1115
|
+
align-items: flex-start;
|
|
1116
|
+
gap: ${({ theme: o }) => o.spacing[2]};
|
|
1117
|
+
}
|
|
1118
|
+
`, br = i.div`
|
|
1104
1119
|
display: flex;
|
|
1105
1120
|
align-items: center;
|
|
1106
1121
|
gap: ${({ theme: o }) => o.spacing[2]};
|
|
1107
|
-
`,
|
|
1122
|
+
`, xr = i.span`
|
|
1108
1123
|
display: inline-flex;
|
|
1109
1124
|
align-items: center;
|
|
1110
1125
|
justify-content: center;
|
|
@@ -1112,17 +1127,17 @@ const dr = i.div`
|
|
|
1112
1127
|
transition: transform 0.2s ease;
|
|
1113
1128
|
transform: ${({ $open: o }) => o ? "rotate(180deg)" : "rotate(0deg)"};
|
|
1114
1129
|
color: ${({ theme: o, $accentColor: r }) => r ?? o.colors.neutral[500]};
|
|
1115
|
-
`,
|
|
1130
|
+
`, yr = i.div`
|
|
1116
1131
|
display: grid;
|
|
1117
1132
|
grid-template-rows: ${({ $open: o }) => o ? "1fr" : "0fr"};
|
|
1118
1133
|
transition: grid-template-rows 0.2s ease;
|
|
1119
|
-
`,
|
|
1134
|
+
`, wr = i.div`
|
|
1120
1135
|
overflow: hidden;
|
|
1121
1136
|
`, vr = i.div`
|
|
1122
1137
|
padding: ${({ theme: o }) => o.spacing[4]};
|
|
1123
1138
|
border-top: 1px solid ${({ theme: o }) => o.colors.neutral[200]};
|
|
1124
1139
|
`;
|
|
1125
|
-
function
|
|
1140
|
+
function mr({
|
|
1126
1141
|
title: o,
|
|
1127
1142
|
children: r,
|
|
1128
1143
|
defaultOpen: n = !1,
|
|
@@ -1143,17 +1158,19 @@ function wr({
|
|
|
1143
1158
|
"aria-expanded": $,
|
|
1144
1159
|
"aria-controls": b,
|
|
1145
1160
|
onClick: () => {
|
|
1146
|
-
const
|
|
1147
|
-
m || u(
|
|
1161
|
+
const w = !$;
|
|
1162
|
+
m || u(w), c?.(w);
|
|
1148
1163
|
},
|
|
1149
1164
|
children: [
|
|
1150
1165
|
/* @__PURE__ */ h(fr, { children: [
|
|
1151
1166
|
/* @__PURE__ */ l(pr, { children: o }),
|
|
1152
|
-
a && /* @__PURE__ */
|
|
1167
|
+
(a || e) && /* @__PURE__ */ h($r, { children: [
|
|
1168
|
+
a && /* @__PURE__ */ l(gr, { children: a }),
|
|
1169
|
+
e && /* @__PURE__ */ l(br, { onClick: (w) => w.stopPropagation(), children: e })
|
|
1170
|
+
] })
|
|
1153
1171
|
] }),
|
|
1154
|
-
e && /* @__PURE__ */ l($r, { onClick: (v) => v.stopPropagation(), children: e }),
|
|
1155
1172
|
/* @__PURE__ */ l(
|
|
1156
|
-
|
|
1173
|
+
xr,
|
|
1157
1174
|
{
|
|
1158
1175
|
$open: $,
|
|
1159
1176
|
$accentColor: d,
|
|
@@ -1164,12 +1181,12 @@ function wr({
|
|
|
1164
1181
|
]
|
|
1165
1182
|
}
|
|
1166
1183
|
),
|
|
1167
|
-
/* @__PURE__ */ l(
|
|
1184
|
+
/* @__PURE__ */ l(yr, { $open: $, children: /* @__PURE__ */ l(wr, { id: b, role: "region", "aria-label": o, children: /* @__PURE__ */ l(vr, { children: r }) }) })
|
|
1168
1185
|
] });
|
|
1169
1186
|
}
|
|
1170
|
-
|
|
1187
|
+
mr.displayName = "CollapsibleCard";
|
|
1171
1188
|
const to = X(null);
|
|
1172
|
-
function
|
|
1189
|
+
function Or({ children: o }) {
|
|
1173
1190
|
const [r, n] = z(null), t = B((a) => {
|
|
1174
1191
|
n({ ...a, id: Date.now() });
|
|
1175
1192
|
}, []), c = ao(() => {
|
|
@@ -1192,13 +1209,13 @@ function Br({ children: o }) {
|
|
|
1192
1209
|
)
|
|
1193
1210
|
] });
|
|
1194
1211
|
}
|
|
1195
|
-
function
|
|
1212
|
+
function Lr() {
|
|
1196
1213
|
const o = Z(to);
|
|
1197
1214
|
if (!o)
|
|
1198
1215
|
throw new Error("useToast must be used within a ToastProvider");
|
|
1199
1216
|
return o;
|
|
1200
1217
|
}
|
|
1201
|
-
function
|
|
1218
|
+
function jr({
|
|
1202
1219
|
initialValues: o,
|
|
1203
1220
|
validate: r,
|
|
1204
1221
|
onSubmit: n,
|
|
@@ -1206,7 +1223,7 @@ function Lr({
|
|
|
1206
1223
|
}) {
|
|
1207
1224
|
const [c, a] = z(o), [e, d] = z(
|
|
1208
1225
|
{}
|
|
1209
|
-
), [p, u] = z({}), [b, m] = z(!1), $ =
|
|
1226
|
+
), [p, u] = z({}), [b, m] = z(!1), $ = M(c);
|
|
1210
1227
|
$.current = c;
|
|
1211
1228
|
const x = B(
|
|
1212
1229
|
(f) => {
|
|
@@ -1218,12 +1235,12 @@ function Lr({
|
|
|
1218
1235
|
);
|
|
1219
1236
|
},
|
|
1220
1237
|
[r]
|
|
1221
|
-
),
|
|
1222
|
-
|
|
1238
|
+
), w = M(p);
|
|
1239
|
+
w.current = p;
|
|
1223
1240
|
const S = B(
|
|
1224
1241
|
(f) => {
|
|
1225
|
-
const { name: g, value: y } = f.target,
|
|
1226
|
-
a(
|
|
1242
|
+
const { name: g, value: y } = f.target, v = { ...$.current, [g]: y };
|
|
1243
|
+
a(v), w.current[g] && d(x(v));
|
|
1227
1244
|
},
|
|
1228
1245
|
[x]
|
|
1229
1246
|
), C = B(
|
|
@@ -1306,34 +1323,34 @@ const U = {
|
|
|
1306
1323
|
50: "#eff6ff",
|
|
1307
1324
|
500: "#2563eb"
|
|
1308
1325
|
}
|
|
1309
|
-
},
|
|
1326
|
+
}, kr = {
|
|
1310
1327
|
1: "4px",
|
|
1311
1328
|
2: "8px",
|
|
1312
1329
|
3: "12px",
|
|
1313
1330
|
4: "16px",
|
|
1314
1331
|
5: "20px",
|
|
1315
1332
|
6: "24px"
|
|
1316
|
-
}, kr = {
|
|
1317
|
-
md: "6px"
|
|
1318
1333
|
}, hr = {
|
|
1334
|
+
md: "6px"
|
|
1335
|
+
}, Cr = {
|
|
1319
1336
|
modal: 1e3,
|
|
1320
1337
|
toast: 1100
|
|
1321
|
-
},
|
|
1338
|
+
}, zr = {
|
|
1322
1339
|
xs: "12px",
|
|
1323
1340
|
sm: "14px",
|
|
1324
1341
|
md: "16px",
|
|
1325
1342
|
lg: "18px"
|
|
1326
|
-
},
|
|
1343
|
+
}, Fr = {
|
|
1327
1344
|
colors: { ...U, primary: { ...U.primary, contrast: "#ffffff" } },
|
|
1328
|
-
spacing:
|
|
1329
|
-
fontSizes:
|
|
1330
|
-
radius:
|
|
1331
|
-
zIndex:
|
|
1345
|
+
spacing: kr,
|
|
1346
|
+
fontSizes: zr,
|
|
1347
|
+
radius: hr,
|
|
1348
|
+
zIndex: Cr,
|
|
1332
1349
|
shadows: {
|
|
1333
1350
|
focusRing: "0 0 0 2px rgba(0, 112, 243, 0.25)"
|
|
1334
1351
|
}
|
|
1335
1352
|
};
|
|
1336
|
-
function
|
|
1353
|
+
function Sr(o) {
|
|
1337
1354
|
const r = parseInt(o.slice(1, 3), 16) / 255, n = parseInt(o.slice(3, 5), 16) / 255, t = parseInt(o.slice(5, 7), 16) / 255, c = (e) => e <= 0.03928 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4;
|
|
1338
1355
|
return 0.2126 * c(r) + 0.7152 * c(n) + 0.0722 * c(t) > 0.179 ? "#111111" : "#ffffff";
|
|
1339
1356
|
}
|
|
@@ -1367,7 +1384,7 @@ const Y = {
|
|
|
1367
1384
|
shadows: { focusRing: "3px 3px 0 #111111" },
|
|
1368
1385
|
brutalism: { borderWidth: "2px", shadowOffset: "4px" }
|
|
1369
1386
|
};
|
|
1370
|
-
function
|
|
1387
|
+
function Er(o) {
|
|
1371
1388
|
return {
|
|
1372
1389
|
...Y,
|
|
1373
1390
|
colors: {
|
|
@@ -1376,12 +1393,12 @@ function Fr(o) {
|
|
|
1376
1393
|
50: "#fffff0",
|
|
1377
1394
|
500: o,
|
|
1378
1395
|
700: o,
|
|
1379
|
-
contrast:
|
|
1396
|
+
contrast: Sr(o)
|
|
1380
1397
|
}
|
|
1381
1398
|
}
|
|
1382
1399
|
};
|
|
1383
1400
|
}
|
|
1384
|
-
function
|
|
1401
|
+
function Nr({
|
|
1385
1402
|
theme: o = Y,
|
|
1386
1403
|
children: r
|
|
1387
1404
|
}) {
|
|
@@ -1390,19 +1407,19 @@ function Er({
|
|
|
1390
1407
|
export {
|
|
1391
1408
|
co as Badge,
|
|
1392
1409
|
fo as Button,
|
|
1393
|
-
|
|
1410
|
+
mr as CollapsibleCard,
|
|
1394
1411
|
Qo as Form,
|
|
1395
1412
|
or as FormField,
|
|
1396
|
-
|
|
1413
|
+
wo as Input,
|
|
1397
1414
|
cr as Link,
|
|
1398
1415
|
Lo as Modal,
|
|
1399
1416
|
ar as Select,
|
|
1400
|
-
|
|
1417
|
+
Nr as ThemeProvider,
|
|
1401
1418
|
so as Toast,
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1419
|
+
Or as ToastProvider,
|
|
1420
|
+
Er as createNeoBrutalTheme,
|
|
1421
|
+
Fr as defaultTheme,
|
|
1405
1422
|
Y as neoBrutalTheme,
|
|
1406
|
-
|
|
1407
|
-
|
|
1423
|
+
jr as useForm,
|
|
1424
|
+
Lr as useToast
|
|
1408
1425
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blunt-ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"require": "./dist/index.cjs",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
8
|
"files": [
|
|
16
9
|
"dist"
|
|
17
10
|
],
|