blunt-ui 0.1.1 → 0.2.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/README.md +29 -1
- package/dist/components/CollapsibleCard/CollapsibleCard.d.ts +5 -0
- package/dist/components/CollapsibleCard/CollapsibleCard.stories.d.ts +15 -0
- package/dist/components/CollapsibleCard/CollapsibleCard.test.d.ts +0 -0
- package/dist/components/CollapsibleCard/CollapsibleCard.types.d.ts +11 -0
- package/dist/components/CollapsibleCard/index.d.ts +2 -0
- package/dist/index.cjs +132 -57
- package/dist/index.d.ts +2 -0
- package/dist/index.js +553 -413
- package/package.json +8 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# blunt-ui
|
|
2
2
|
|
|
3
|
-
React + TypeScript + styled-components. Thick borders, offset shadows, no fluff.
|
|
3
|
+
React + TypeScript + styled-components. Thick borders, offset shadows, no fluff. 9 components, 2 hooks.
|
|
4
4
|
|
|
5
5
|
**Live demo:** https://blunt-ui.vercel.app/
|
|
6
6
|
|
|
@@ -66,6 +66,34 @@ Sizes: `sm`, `md`, `lg`, `fullscreen`.
|
|
|
66
66
|
</Modal>
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
## CollapsibleCard
|
|
70
|
+
|
|
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
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<CollapsibleCard
|
|
75
|
+
title="blunt-ui"
|
|
76
|
+
subtitle="Subtitle"
|
|
77
|
+
defaultOpen
|
|
78
|
+
>
|
|
79
|
+
React component library in neo-brutalism style.
|
|
80
|
+
</CollapsibleCard>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pass `open` + `onToggle` for controlled mode:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
<CollapsibleCard
|
|
87
|
+
title="Project"
|
|
88
|
+
open={isOpen}
|
|
89
|
+
onToggle={setIsOpen}
|
|
90
|
+
accentColor="#f97316"
|
|
91
|
+
headerActions={<Badge variant="primary">npm</Badge>}
|
|
92
|
+
>
|
|
93
|
+
{children}
|
|
94
|
+
</CollapsibleCard>
|
|
95
|
+
```
|
|
96
|
+
|
|
69
97
|
## Toast
|
|
70
98
|
|
|
71
99
|
Pops up in a portal, auto-dismisses after 4 seconds. Set `duration={0}` to keep it until the user closes it.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CollapsibleCardProps } from './CollapsibleCard.types';
|
|
2
|
+
export declare function CollapsibleCard({ title, children, defaultOpen, open: controlledOpen, onToggle, subtitle, headerActions, accentColor, }: CollapsibleCardProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace CollapsibleCard {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
import { CollapsibleCard } from './CollapsibleCard';
|
|
4
|
+
type StoryArgs = ComponentProps<typeof CollapsibleCard> & {
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
declare const meta: Meta<StoryArgs>;
|
|
8
|
+
export default meta;
|
|
9
|
+
type Story = StoryObj<StoryArgs>;
|
|
10
|
+
export declare const Default: Story;
|
|
11
|
+
export declare const WithSubtitle: Story;
|
|
12
|
+
export declare const WithHeaderActions: Story;
|
|
13
|
+
export declare const Controlled: Story;
|
|
14
|
+
export declare const ClosedByDefault: Story;
|
|
15
|
+
export declare const AccentColor: Story;
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface CollapsibleCardProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
defaultOpen?: boolean;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
onToggle?: (open: boolean) => void;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
headerActions?: ReactNode;
|
|
10
|
+
accentColor?: string;
|
|
11
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),r=require("styled-components"),a=require("react"),A=require("react-dom"),I=(o,s,n)=>r.css`
|
|
2
2
|
background: ${s};
|
|
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
|
+
`,no=r.span`
|
|
7
7
|
display: inline-flex;
|
|
8
8
|
align-items: center;
|
|
9
9
|
font-weight: 700;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
background: ${s.colors.info[50]};
|
|
39
39
|
color: ${s.colors.info[500]};
|
|
40
40
|
`}[o]}
|
|
41
|
-
`;function
|
|
41
|
+
`;function D({variant:o="primary",size:s="md",children:n,...e}){return t.jsx(no,{$variant:o,$size:s,...e,children:n})}D.displayName="Badge";const E=(o,s,n)=>r.css`
|
|
42
42
|
background-color: ${s};
|
|
43
43
|
color: ${n};
|
|
44
44
|
border: ${o.brutalism.borderWidth} solid ${o.colors.neutral[900]};
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
transform: translate(2px, 2px);
|
|
52
52
|
box-shadow: 2px 2px 0 ${o.colors.neutral[900]};
|
|
53
53
|
}
|
|
54
|
-
`,
|
|
54
|
+
`,to=r.button`
|
|
55
55
|
display: inline-flex;
|
|
56
56
|
align-items: center;
|
|
57
57
|
justify-content: center;
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
cursor: not-allowed;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
${({$variant:o,theme:s})=>s.brutalism?{primary:
|
|
73
|
+
${({$variant:o,theme:s})=>s.brutalism?{primary:E(s,s.colors.primary[500],s.colors.primary.contrast),secondary:E(s,s.colors.neutral[100],s.colors.neutral[900]),outline:E(s,s.colors.neutral[0],s.colors.neutral[900])}[o]:{primary:r.css`
|
|
74
74
|
background-color: ${s.colors.primary[500]};
|
|
75
75
|
color: ${s.colors.neutral[0]};
|
|
76
76
|
border: none;
|
|
@@ -103,18 +103,18 @@
|
|
|
103
103
|
padding: ${s.spacing[3]} ${s.spacing[6]};
|
|
104
104
|
font-size: ${s.fontSizes.lg};
|
|
105
105
|
`})[o]}
|
|
106
|
-
`;function
|
|
106
|
+
`;function Y({ref:o,as:s,href:n,variant:e="primary",size:c="md",isLoading:l,disabled:i,children:d,...p}){const u=s??(n?"a":"button");return t.jsx(to,{ref:o,as:u,href:n,$variant:e,$size:c,disabled:l||i,...p,children:l?"Loading...":d})}Y.displayName="Button";const eo=r.div`
|
|
107
107
|
display: flex;
|
|
108
108
|
flex-direction: column;
|
|
109
109
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
110
110
|
width: ${({$fullWidth:o})=>o?"100%":"auto"};
|
|
111
|
-
`,
|
|
111
|
+
`,ao=r.label`
|
|
112
112
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
113
113
|
font-weight: ${({theme:o})=>o.brutalism?"700":"500"};
|
|
114
|
-
`,
|
|
114
|
+
`,io=r.span`
|
|
115
115
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
116
116
|
color: ${({$error:o,theme:s})=>o?s.colors.error[500]:s.colors.neutral[500]};
|
|
117
|
-
`,
|
|
117
|
+
`,lo=r.div`
|
|
118
118
|
display: flex;
|
|
119
119
|
align-items: center;
|
|
120
120
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
&:focus-within {
|
|
160
160
|
box-shadow: ${({theme:o})=>o.shadows.focusRing};
|
|
161
161
|
}
|
|
162
|
-
`,
|
|
162
|
+
`,co=r.input`
|
|
163
163
|
flex: 1;
|
|
164
164
|
border: none;
|
|
165
165
|
outline: none;
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
display: inline-flex;
|
|
175
175
|
align-items: center;
|
|
176
176
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
177
|
-
`,
|
|
177
|
+
`,uo=r.button`
|
|
178
178
|
display: inline-flex;
|
|
179
179
|
align-items: center;
|
|
180
180
|
margin: 0 ${({theme:o})=>o.spacing[1]};
|
|
@@ -187,19 +187,19 @@
|
|
|
187
187
|
&:hover {
|
|
188
188
|
opacity: 0.8;
|
|
189
189
|
}
|
|
190
|
-
`;function
|
|
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:w,id:g,value:$,defaultValue:m,onChange:h,...C}){const k=a.useId(),j=g??k,S=`${j}-hint`,[z,f]=a.useState(m??""),b=$!==void 0,y=b?$:z,v=typeof i=="string"?i:void 0,T=!!(l||i),O=N=>{b||f(N.target.value),h?.(N)},ro=()=>{b||f(""),x?.()};return t.jsxs(eo,{$fullWidth:w,children:[c&&t.jsx(ao,{htmlFor:j,children:c}),t.jsxs(lo,{$size:n,$variant:e,$error:!!i,children:[d&&t.jsx(R,{children:d}),t.jsx(co,{id:j,ref:o,type:s,value:y,onChange:O,...C,"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(R,{children:p})]}),T&&t.jsx(io,{id:S,$error:!!i,children:v??l})]})}H.displayName="Input";const fo=r.keyframes`
|
|
191
191
|
from { opacity: 0; }
|
|
192
192
|
to { opacity: 1; }
|
|
193
|
-
`,
|
|
193
|
+
`,po=r.keyframes`
|
|
194
194
|
from { opacity: 1; }
|
|
195
195
|
to { opacity: 0; }
|
|
196
|
-
`,
|
|
196
|
+
`,bo=r.keyframes`
|
|
197
197
|
from { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
198
198
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
199
|
-
`,
|
|
199
|
+
`,go=r.keyframes`
|
|
200
200
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
201
201
|
to { opacity: 0; transform: scale(0.95) translateY(-8px); }
|
|
202
|
-
|
|
202
|
+
`,$o=r.div`
|
|
203
203
|
position: fixed;
|
|
204
204
|
inset: 0;
|
|
205
205
|
background-color: rgba(0, 0, 0, 0.5);
|
|
@@ -207,9 +207,9 @@
|
|
|
207
207
|
align-items: center;
|
|
208
208
|
justify-content: center;
|
|
209
209
|
z-index: ${({theme:o})=>o.zIndex.modal};
|
|
210
|
-
animation: ${({$closing:o})=>o?
|
|
210
|
+
animation: ${({$closing:o})=>o?po:fo} 0.15s ease
|
|
211
211
|
forwards;
|
|
212
|
-
`,
|
|
212
|
+
`,xo=r.div`
|
|
213
213
|
position: relative;
|
|
214
214
|
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
215
215
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
display: flex;
|
|
219
219
|
flex-direction: column;
|
|
220
220
|
max-height: 90vh;
|
|
221
|
-
animation: ${({$closing:o})=>o?
|
|
221
|
+
animation: ${({$closing:o})=>o?go:bo} 0.15s ease
|
|
222
222
|
forwards;
|
|
223
223
|
|
|
224
224
|
${({$size:o})=>o==="sm"&&r.css`
|
|
@@ -236,19 +236,19 @@
|
|
|
236
236
|
max-height: 100vh;
|
|
237
237
|
border-radius: 0;
|
|
238
238
|
`}
|
|
239
|
-
`,
|
|
239
|
+
`,yo=r.div`
|
|
240
240
|
display: flex;
|
|
241
241
|
align-items: center;
|
|
242
242
|
gap: ${({theme:o})=>o.spacing[2]};
|
|
243
243
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
244
244
|
border-bottom: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
245
245
|
flex-shrink: 0;
|
|
246
|
-
|
|
246
|
+
`,mo=r.h2`
|
|
247
247
|
flex: 1;
|
|
248
248
|
font-size: ${({theme:o})=>o.fontSizes.lg};
|
|
249
249
|
font-weight: 600;
|
|
250
250
|
margin: 0;
|
|
251
|
-
`,
|
|
251
|
+
`,vo=r.button`
|
|
252
252
|
display: inline-flex;
|
|
253
253
|
align-items: center;
|
|
254
254
|
justify-content: center;
|
|
@@ -273,11 +273,11 @@
|
|
|
273
273
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
274
274
|
outline-offset: 2px;
|
|
275
275
|
}
|
|
276
|
-
`,
|
|
276
|
+
`,wo=r.div`
|
|
277
277
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
278
278
|
overflow-y: auto;
|
|
279
279
|
flex: 1;
|
|
280
|
-
`,
|
|
280
|
+
`,ko=r.div`
|
|
281
281
|
display: flex;
|
|
282
282
|
align-items: center;
|
|
283
283
|
justify-content: flex-end;
|
|
@@ -285,16 +285,16 @@
|
|
|
285
285
|
padding: ${({theme:o})=>o.spacing[4]};
|
|
286
286
|
border-top: 1px solid ${({theme:o})=>o.colors.neutral[200]};
|
|
287
287
|
flex-shrink: 0;
|
|
288
|
-
`,
|
|
288
|
+
`,Co=["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(Co))}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),w=a.useId(),g=p??(n?w:void 0),[$,m]=a.useState(o),[h,C]=a.useState(!1);return a.useEffect(()=>{if(o)m(!0),C(!1);else if($){C(!0);const k=setTimeout(()=>{m(!1),C(!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 b=V(k);if(b.length===0){f.preventDefault();return}const y=b[0],v=b[b.length-1];f.shiftKey?document.activeElement===y&&(f.preventDefault(),v.focus()):document.activeElement===v&&(f.preventDefault(),y.focus())};return document.addEventListener("keydown",z),()=>{document.removeEventListener("keydown",z),j?.focus()}},[o,d,s,$]),$?A.createPortal(t.jsx($o,{$closing:h,onClick:i?s:void 0,children:t.jsxs(xo,{ref:x,role:"dialog","aria-modal":"true","aria-labelledby":g,"aria-describedby":u,$size:l,$closing:h,tabIndex:-1,onClick:k=>k.stopPropagation(),children:[t.jsxs(yo,{children:[n&&t.jsx(mo,{id:w,children:n}),t.jsx(vo,{onClick:s,"aria-label":"Close modal",children:"×"})]}),t.jsx(wo,{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 ho=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:w=!1,color:g="currentColor",className:$=""}=Io()??{},m=e??w?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??g,strokeWidth:m,className:_("lucide",$,c),...!l&&!So(d)&&{"aria-hidden":"true"},...d},[...i.map(([h,C])=>a.createElement(h,C)),...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-${ho(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
289
|
from { opacity: 0; transform: translateY(12px); }
|
|
290
290
|
to { opacity: 1; transform: translateY(0); }
|
|
291
|
-
`,
|
|
291
|
+
`,Eo=r.keyframes`
|
|
292
292
|
from { opacity: 0; transform: translateY(-12px); }
|
|
293
293
|
to { opacity: 1; transform: translateY(0); }
|
|
294
|
-
`,
|
|
294
|
+
`,Fo=r.keyframes`
|
|
295
295
|
from { opacity: 1; }
|
|
296
296
|
to { opacity: 0; }
|
|
297
|
-
`,
|
|
297
|
+
`,Lo=r.div`
|
|
298
298
|
position: fixed;
|
|
299
299
|
z-index: ${({theme:o})=>o.zIndex.toast};
|
|
300
300
|
display: flex;
|
|
@@ -304,14 +304,12 @@
|
|
|
304
304
|
max-width: 400px;
|
|
305
305
|
padding: ${({theme:o})=>`${o.spacing[3]} ${o.spacing[4]}`};
|
|
306
306
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
307
|
-
border-left: 4px solid transparent;
|
|
308
|
-
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
309
307
|
animation: ${({$closing:o,$position:s})=>o?r.css`
|
|
310
|
-
${
|
|
308
|
+
${Fo} 0.2s ease forwards
|
|
311
309
|
`:s.startsWith("top")?r.css`
|
|
312
|
-
${
|
|
310
|
+
${Eo} 0.2s ease forwards
|
|
313
311
|
`:r.css`
|
|
314
|
-
${
|
|
312
|
+
${Oo} 0.2s ease forwards
|
|
315
313
|
`};
|
|
316
314
|
|
|
317
315
|
${({$position:o,theme:s})=>({"bottom-right":r.css`
|
|
@@ -327,27 +325,37 @@
|
|
|
327
325
|
top: ${s.spacing[6]};
|
|
328
326
|
left: ${s.spacing[6]};
|
|
329
327
|
`})[o]}
|
|
330
|
-
`,
|
|
331
|
-
${
|
|
328
|
+
`,W=(o,s,n)=>r.css`
|
|
329
|
+
background: ${s};
|
|
330
|
+
border: ${o.brutalism.borderWidth} solid ${n};
|
|
331
|
+
box-shadow: ${o.brutalism.shadowOffset} ${o.brutalism.shadowOffset}
|
|
332
|
+
0 ${n};
|
|
333
|
+
`,No=r(Lo)`
|
|
334
|
+
${({$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`
|
|
332
335
|
background: ${s.colors.success[50]};
|
|
333
|
-
border-left
|
|
336
|
+
border-left: 4px solid ${s.colors.success[500]};
|
|
337
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
334
338
|
`,error:r.css`
|
|
335
339
|
background: ${s.colors.error[50]};
|
|
336
|
-
border-left
|
|
340
|
+
border-left: 4px solid ${s.colors.error[500]};
|
|
341
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
337
342
|
`,warning:r.css`
|
|
338
343
|
background: ${s.colors.warning[50]};
|
|
339
|
-
border-left
|
|
344
|
+
border-left: 4px solid ${s.colors.warning[500]};
|
|
345
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
340
346
|
`,info:r.css`
|
|
341
347
|
background: ${s.colors.info[50]};
|
|
342
|
-
border-left
|
|
343
|
-
|
|
344
|
-
|
|
348
|
+
border-left: 4px solid ${s.colors.info[500]};
|
|
349
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
350
|
+
`}[o]}
|
|
351
|
+
`,Ro=r.p`
|
|
345
352
|
flex: 1;
|
|
346
353
|
margin: 0;
|
|
347
354
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
355
|
+
font-weight: ${({theme:o})=>o.brutalism?600:400};
|
|
348
356
|
line-height: 1.5;
|
|
349
357
|
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
350
|
-
`,
|
|
358
|
+
`,Vo=r.button`
|
|
351
359
|
flex-shrink: 0;
|
|
352
360
|
display: inline-flex;
|
|
353
361
|
align-items: center;
|
|
@@ -358,8 +366,6 @@
|
|
|
358
366
|
background: none;
|
|
359
367
|
cursor: pointer;
|
|
360
368
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
361
|
-
font-size: 18px;
|
|
362
|
-
line-height: 1;
|
|
363
369
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
364
370
|
|
|
365
371
|
&:hover {
|
|
@@ -371,38 +377,38 @@
|
|
|
371
377
|
outline: 2px solid ${({theme:o})=>o.colors.primary[500]};
|
|
372
378
|
outline-offset: 2px;
|
|
373
379
|
}
|
|
374
|
-
`;function L({open:o,onClose:s,message:n,variant:e="info",duration:c=4e3,position:l="bottom-right"}){const[i,d]=
|
|
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(No,{$position:l,$variant:e,$closing:p,role:"alert","aria-live":"polite",children:[t.jsx(Ro,{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`
|
|
375
381
|
display: flex;
|
|
376
382
|
flex-direction: column;
|
|
377
383
|
gap: ${({theme:o})=>o.spacing[4]};
|
|
378
|
-
`,
|
|
384
|
+
`,Po=r.div`
|
|
379
385
|
display: flex;
|
|
380
386
|
flex-direction: column;
|
|
381
387
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
382
|
-
`,
|
|
388
|
+
`,Ao=r.label`
|
|
383
389
|
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
384
390
|
font-weight: 500;
|
|
385
391
|
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
386
|
-
`,
|
|
392
|
+
`,Do=r.span`
|
|
387
393
|
color: ${({theme:o})=>o.colors.error[500]};
|
|
388
394
|
margin-left: 2px;
|
|
389
395
|
aria-hidden: true;
|
|
390
|
-
`,
|
|
396
|
+
`,Yo=r.span`
|
|
391
397
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
392
398
|
color: ${({$error:o,theme:s})=>o?s.colors.error[500]:s.colors.neutral[500]};
|
|
393
|
-
`;function
|
|
399
|
+
`;function X({onSubmit:o,children:s,...n}){return t.jsx(Mo,{onSubmit:e=>{e.preventDefault(),o?.(e)},noValidate:!0,...n,children:s})}X.displayName="Form";function G({label:o,error:s,helperText:n,required:e,children:c}){const l=a.useId(),i=`${l}-hint`,d=!!(s||n),p=typeof s=="string"?s:void 0,u=a.isValidElement(c)?a.cloneElement(c,{id:l,...d&&{"aria-describedby":i},...s&&{"aria-invalid":!0}}):c;return t.jsxs(Po,{children:[o&&t.jsxs(Ao,{htmlFor:l,children:[o,e&&t.jsx(Do,{"aria-hidden":"true",children:" *"})]}),u,d&&t.jsx(Yo,{id:i,$error:!!s,children:p??n})]})}G.displayName="FormField";const Ho=r.div`
|
|
394
400
|
display: inline-flex;
|
|
395
401
|
flex-direction: column;
|
|
396
402
|
gap: ${({theme:o})=>o.spacing[1]};
|
|
397
403
|
width: ${({$fullWidth:o})=>o?"100%":"auto"};
|
|
398
|
-
`,
|
|
404
|
+
`,qo=r.div`
|
|
399
405
|
position: relative;
|
|
400
406
|
display: flex;
|
|
401
407
|
width: 100%;
|
|
402
|
-
`,
|
|
408
|
+
`,_o=r.span`
|
|
403
409
|
font-size: ${({theme:o})=>o.fontSizes.xs};
|
|
404
410
|
color: ${({$error:o,theme:s})=>o?s.colors.error[500]:s.colors.neutral[500]};
|
|
405
|
-
`,
|
|
411
|
+
`,Ko=r.select`
|
|
406
412
|
appearance: none;
|
|
407
413
|
width: 100%;
|
|
408
414
|
border-radius: ${({theme:o})=>o.radius.md};
|
|
@@ -455,7 +461,7 @@
|
|
|
455
461
|
cursor: not-allowed;
|
|
456
462
|
opacity: 0.6;
|
|
457
463
|
}
|
|
458
|
-
`,
|
|
464
|
+
`,Uo=r.button`
|
|
459
465
|
position: absolute;
|
|
460
466
|
right: ${({theme:o})=>o.spacing[3]};
|
|
461
467
|
top: 50%;
|
|
@@ -477,7 +483,7 @@
|
|
|
477
483
|
outline-offset: 2px;
|
|
478
484
|
border-radius: 2px;
|
|
479
485
|
}
|
|
480
|
-
`,
|
|
486
|
+
`,Zo=r.span`
|
|
481
487
|
position: absolute;
|
|
482
488
|
right: ${({theme:o})=>o.spacing[3]};
|
|
483
489
|
top: 50%;
|
|
@@ -486,7 +492,7 @@
|
|
|
486
492
|
display: flex;
|
|
487
493
|
align-items: center;
|
|
488
494
|
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
489
|
-
`;function
|
|
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:w,...g}){const $=a.useId(),m=p??$,h=`${m}-hint`,C=typeof c=="string"?c:void 0,[k,j]=a.useState(x??""),S=u!==void 0,z=S?u:k,f=v=>{S||j(v.target.value),w?.(v)},b=()=>{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":C?h:void 0,value:z,onChange:f,...g,children:[s&&t.jsx("option",{value:"",disabled:!0,children:s}),o.map(v=>t.jsx("option",{value:v.value,disabled:v.disabled,children:v.label},v.value))]}),y?t.jsx(Uo,{type:"button",onClick:b,"aria-label":"Clear selection",children:t.jsx(Z,{size:14})}):t.jsx(Zo,{"aria-hidden":"true",children:t.jsx(U,{size:14})})]}),C&&t.jsx(_o,{id:h,$error:!0,children:C})]})}J.displayName="Select";const Xo=r.a`
|
|
490
496
|
text-decoration: underline;
|
|
491
497
|
text-underline-offset: 2px;
|
|
492
498
|
transition: color 0.15s;
|
|
@@ -508,4 +514,73 @@
|
|
|
508
514
|
color: ${s.colors.neutral[900]};
|
|
509
515
|
}
|
|
510
516
|
`})[o]}
|
|
511
|
-
`;function
|
|
517
|
+
`;function Q({variant:o="default",external:s,children:n,...e}){return t.jsx(Xo,{$variant:o,...s&&{target:"_blank",rel:"noreferrer"},...e,children:n})}Q.displayName="Link";const Go=r.div`
|
|
518
|
+
border-radius: ${({theme:o})=>o.radius.md};
|
|
519
|
+
background: ${({theme:o})=>o.colors.neutral[0]};
|
|
520
|
+
overflow: hidden;
|
|
521
|
+
|
|
522
|
+
${({theme:o,$accentColor:s})=>o.brutalism?r.css`
|
|
523
|
+
border: ${o.brutalism.borderWidth} solid
|
|
524
|
+
${s??o.colors.neutral[900]};
|
|
525
|
+
box-shadow: ${o.brutalism.shadowOffset}
|
|
526
|
+
${o.brutalism.shadowOffset} 0
|
|
527
|
+
${s??o.colors.neutral[900]};
|
|
528
|
+
`:r.css`
|
|
529
|
+
border: 1px solid ${s??o.colors.neutral[200]};
|
|
530
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
|
|
531
|
+
`}
|
|
532
|
+
`,Jo=r.button`
|
|
533
|
+
width: 100%;
|
|
534
|
+
display: flex;
|
|
535
|
+
align-items: center;
|
|
536
|
+
gap: ${({theme:o})=>o.spacing[3]};
|
|
537
|
+
padding: ${({theme:o})=>o.spacing[4]};
|
|
538
|
+
background: ${({theme:o})=>o.brutalism?o.colors.neutral[100]:o.colors.neutral[0]};
|
|
539
|
+
border: none;
|
|
540
|
+
cursor: pointer;
|
|
541
|
+
text-align: left;
|
|
542
|
+
|
|
543
|
+
&:hover {
|
|
544
|
+
background: ${({theme:o})=>o.colors.neutral[100]};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
&:focus-visible {
|
|
548
|
+
outline: 2px solid
|
|
549
|
+
${({theme:o,$accentColor:s})=>s??o.colors.primary[500]};
|
|
550
|
+
outline-offset: -2px;
|
|
551
|
+
}
|
|
552
|
+
`,Qo=r.div`
|
|
553
|
+
flex: 1;
|
|
554
|
+
min-width: 0;
|
|
555
|
+
`,os=r.span`
|
|
556
|
+
display: block;
|
|
557
|
+
font-size: ${({theme:o})=>o.fontSizes.md};
|
|
558
|
+
font-weight: 600;
|
|
559
|
+
color: ${({theme:o})=>o.colors.neutral[900]};
|
|
560
|
+
`,ss=r.span`
|
|
561
|
+
display: block;
|
|
562
|
+
font-size: ${({theme:o})=>o.fontSizes.sm};
|
|
563
|
+
color: ${({theme:o})=>o.colors.neutral[500]};
|
|
564
|
+
margin-top: ${({theme:o})=>o.spacing[1]};
|
|
565
|
+
`,rs=r.div`
|
|
566
|
+
display: flex;
|
|
567
|
+
align-items: center;
|
|
568
|
+
gap: ${({theme:o})=>o.spacing[2]};
|
|
569
|
+
`,ns=r.span`
|
|
570
|
+
display: inline-flex;
|
|
571
|
+
align-items: center;
|
|
572
|
+
justify-content: center;
|
|
573
|
+
flex-shrink: 0;
|
|
574
|
+
transition: transform 0.2s ease;
|
|
575
|
+
transform: ${({$open:o})=>o?"rotate(180deg)":"rotate(0deg)"};
|
|
576
|
+
color: ${({theme:o,$accentColor:s})=>s??o.colors.neutral[500]};
|
|
577
|
+
`,ts=r.div`
|
|
578
|
+
display: grid;
|
|
579
|
+
grid-template-rows: ${({$open:o})=>o?"1fr":"0fr"};
|
|
580
|
+
transition: grid-template-rows 0.2s ease;
|
|
581
|
+
`,es=r.div`
|
|
582
|
+
overflow: hidden;
|
|
583
|
+
`,as=r.div`
|
|
584
|
+
padding: ${({theme:o})=>o.spacing[4]};
|
|
585
|
+
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(),w=e!==void 0,g=w?e:p,$=()=>{const m=!g;w||u(m),c?.(m)};return t.jsxs(Go,{$accentColor:d,children:[t.jsxs(Jo,{type:"button",$open:g,$accentColor:d,"aria-expanded":g,"aria-controls":x,onClick:$,children:[t.jsxs(Qo,{children:[t.jsx(os,{children:o}),l&&t.jsx(ss,{children:l})]}),i&&t.jsx(rs,{onClick:m=>m.stopPropagation(),children:i}),t.jsx(ns,{$open:g,$accentColor:d,"aria-hidden":"true",children:t.jsx(U,{size:18,strokeWidth:2.5})})]}),t.jsx(ts,{$open:g,children:t.jsx(es,{id:x,role:"region","aria-label":o,children:t.jsx(as,{children:s})})})]})}oo.displayName="CollapsibleCard";const so=a.createContext(null);function is({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 ls(){const o=a.useContext(so);if(!o)throw new Error("useToast must be used within a ToastProvider");return o}function cs({initialValues:o,validate:s,onSubmit:n,onError:e}){const[c,l]=a.useState(o),[i,d]=a.useState({}),[p,u]=a.useState({}),[x,w]=a.useState(!1),g=a.useRef(c);g.current=c;const $=a.useCallback(f=>{if(!s)return{};const b=s(f);return Object.fromEntries(Object.entries(b).filter(([,y])=>y!==void 0))},[s]),m=a.useRef(p);m.current=p;const h=a.useCallback(f=>{const{name:b,value:y}=f.target,v={...g.current,[b]:y};l(v),m.current[b]&&d($(v))},[$]),C=a.useCallback(f=>{const{name:b}=f.target;u(y=>({...y,[b]:!0})),d($(g.current))},[$]),k=a.useCallback(f=>{f?.preventDefault();const b=Object.keys(g.current).reduce((T,O)=>({...T,[O]:!0}),{});u(b);const y=$(g.current);if(d(y),Object.keys(y).length>0){e?.(y);return}(async()=>{w(!0);try{await n?.(g.current)}finally{w(!1)}})()},[$,n,e]),j=a.useCallback((f,b)=>{l(y=>({...y,[f]:b}))},[]),S=a.useCallback(()=>{l(o),d({}),u({}),w(!1)},[o]),z=Object.fromEntries(Object.entries(i).filter(([f])=>p[f]));return{values:c,errors:z,touched:p,handleChange:h,handleBlur:C,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"}},ds={1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px"},us={md:"6px"},fs={modal:1e3,toast:1100},ps={xs:"12px",sm:"14px",md:"16px",lg:"18px"},bs={colors:{...P,primary:{...P.primary,contrast:"#ffffff"}},spacing:ds,fontSizes:ps,radius:us,zIndex:fs,shadows:{focusRing:"0 0 0 2px rgba(0, 112, 243, 0.25)"}};function gs(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 $s(o){return{...B,colors:{...B.colors,primary:{50:"#fffff0",500:o,700:o,contrast:gs(o)}}}}function xs({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=xs;exports.Toast=L;exports.ToastProvider=is;exports.createNeoBrutalTheme=$s;exports.defaultTheme=bs;exports.neoBrutalTheme=B;exports.useForm=cs;exports.useToast=ls;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export { Select } from './components/Select';
|
|
|
14
14
|
export type { SelectProps, SelectOption, SelectSizes, SelectVariants, } from './components/Select';
|
|
15
15
|
export { Link } from './components/Link';
|
|
16
16
|
export type { LinkProps, LinkVariants } from './components/Link';
|
|
17
|
+
export { CollapsibleCard } from './components/CollapsibleCard';
|
|
18
|
+
export type { CollapsibleCardProps } from './components/CollapsibleCard';
|
|
17
19
|
export { useToast, ToastProvider } from './hooks';
|
|
18
20
|
export type { ToastOptions, ToastFn, ToastContextValue } from './hooks';
|
|
19
21
|
export { useForm } from './hooks';
|