lucent-ui 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +95 -38
- package/dist/index.d.ts +61 -2
- package/dist/index.js +2623 -2076
- package/dist-cli/cli/entry.js +0 -0
- package/dist-cli/cli/index.js +0 -0
- package/dist-server/server/index.js +0 -0
- package/dist-server/src/components/atoms/ColorPicker/ColorPicker.manifest.js +7 -0
- package/dist-server/src/components/molecules/Menu/Menu.manifest.js +11 -3
- package/dist-server/src/components/molecules/Toast/Toast.manifest.js +233 -0
- package/package.json +13 -15
- package/dist-server/src/manifest/validate.test.js +0 -28
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),p=require("react"),Tt=require("react-dom"),Gt={primary:{background:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"1px solid transparent"},secondary:{background:"color-mix(in srgb, var(--lucent-accent-default) 14%, var(--lucent-surface-secondary))",color:"var(--lucent-text-primary)",border:"1px solid transparent"},outline:{background:"var(--lucent-surface)",color:"var(--lucent-text-primary)",border:"1px solid var(--lucent-border-default)"},ghost:{background:"transparent",color:"var(--lucent-text-primary)",border:"1px solid transparent"},danger:{background:"var(--lucent-danger-default)",color:"#ffffff",border:"1px solid var(--lucent-danger-default)"},"danger-outline":{background:"var(--lucent-surface)",color:"var(--lucent-danger-text)",border:"1px solid var(--lucent-danger-default)"},"danger-ghost":{background:"transparent",color:"var(--lucent-danger-text)",border:"1px solid transparent"}},_t={"2xs":{height:"22px",padding:"0 var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)",borderRadius:"var(--lucent-radius-md)"},xs:{height:"26px",padding:"0 var(--lucent-space-2)",fontSize:"var(--lucent-font-size-xs)"},sm:{height:"calc(var(--lucent-space-8) * 0.5 + 18px)",padding:"0 var(--lucent-space-3)",fontSize:"var(--lucent-font-size-sm)"},md:{height:"calc(var(--lucent-space-10) * 0.5 + 22px)",padding:"0 var(--lucent-space-4)",fontSize:"var(--lucent-font-size-md)"},lg:{height:"calc(var(--lucent-space-12) * 0.5 + 26px)",padding:"0 var(--lucent-space-5)",fontSize:"var(--lucent-font-size-lg)"}},Pe=p.forwardRef(({variant:e="primary",size:n="md",loading:r=!1,fullWidth:o=!1,spread:a=!1,leftIcon:s,rightIcon:i,chevron:l=!1,disableHoverStyles:c=!1,bordered:d=!0,children:u,disabled:h,style:m,...g},C)=>{const y=h??r;return t.jsxs("button",{ref:C,disabled:y,"aria-busy":r,style:{display:"inline-flex",alignItems:"center",justifyContent:a?"space-between":"center",gap:"var(--lucent-space-2)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,letterSpacing:"0.01em",borderRadius:"var(--lucent-radius-lg)",cursor:y?"not-allowed":"pointer",width:o?"100%":void 0,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default), transform 80ms var(--lucent-easing-default)",whiteSpace:"nowrap",boxSizing:"border-box",outline:"none",margin:0,..._t[n],...Gt[e],...m,...y&&{background:"color-mix(in srgb, var(--lucent-surface-secondary) 70%, var(--lucent-border-default))",color:"color-mix(in srgb, var(--lucent-text-disabled) 50%, var(--lucent-border-default))",borderColor:"transparent"},...d===!1&&{border:"none"}},onMouseEnter:f=>{var v;!y&&!c&&Kt(f.currentTarget,e,d),(v=g.onMouseEnter)==null||v.call(g,f)},onMouseLeave:f=>{var v;!y&&!c&&Xt(f.currentTarget,e,d),(v=g.onMouseLeave)==null||v.call(g,f)},onMouseDown:f=>{var v;if(!y){const T=e==="danger"||e==="danger-outline"||e==="danger-ghost"?"var(--lucent-danger-default)":"var(--lucent-accent-default)";f.currentTarget.style.transform="translateY(1px)",f.currentTarget.style.boxShadow=`0 0 0 2px var(--lucent-surface), 0 0 0 4px ${T}`,f.currentTarget.dataset.pressed="1"}(v=g.onMouseDown)==null||v.call(g,f)},onMouseUp:f=>{var v;f.currentTarget.style.transform="",f.currentTarget.style.boxShadow="",delete f.currentTarget.dataset.pressed,(v=g.onMouseUp)==null||v.call(g,f)},onFocus:f=>{var v;f.currentTarget.dataset.pressed||(f.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)"),(v=g.onFocus)==null||v.call(g,f)},onBlur:f=>{var v;f.currentTarget.style.boxShadow="",(v=g.onBlur)==null||v.call(g,f)},...g,children:[s,r?t.jsx(Qt,{}):u,!r&&i,!r&&l&&t.jsx(Zt,{size:n})]})});Pe.displayName="Button";const Yt={primary:"0 4px 14px -2px var(--lucent-accent-subtle)",secondary:"0 4px 14px -2px var(--lucent-accent-subtle)",outline:"0 4px 14px -2px var(--lucent-accent-subtle)",ghost:"0 4px 14px -2px var(--lucent-accent-subtle)",danger:"0 4px 14px -2px var(--lucent-danger-subtle)","danger-outline":"0 4px 14px -2px var(--lucent-danger-subtle)","danger-ghost":"0 4px 14px -2px var(--lucent-danger-subtle)"};function Kt(e,n,r){e.style.transform="translateY(-1px)",e.style.boxShadow=Yt[n],n==="primary"?e.style.background="var(--lucent-accent-hover)":n==="secondary"?e.style.background="color-mix(in srgb, var(--lucent-accent-default) 10%, var(--lucent-surface-secondary))":n==="outline"?e.style.background="color-mix(in srgb, var(--lucent-accent-default) 10%, var(--lucent-surface))":n==="ghost"?e.style.background="color-mix(in srgb, var(--lucent-accent-default) 8%, var(--lucent-surface))":n==="danger"?(e.style.background="var(--lucent-danger-hover)",r!==!1&&(e.style.borderColor="var(--lucent-danger-hover)")):n==="danger-outline"?(e.style.background="color-mix(in srgb, var(--lucent-danger-default) 10%, var(--lucent-surface))",r!==!1&&(e.style.borderColor="var(--lucent-danger-hover)")):n==="danger-ghost"&&(e.style.background="color-mix(in srgb, var(--lucent-danger-default) 8%, var(--lucent-surface))")}function Xt(e,n,r){e.style.transform="",e.style.boxShadow="",n==="primary"?e.style.background="var(--lucent-accent-default)":n==="secondary"?e.style.background="var(--lucent-surface-secondary)":n==="outline"?e.style.background="var(--lucent-surface)":n==="ghost"?e.style.background="transparent":n==="danger"?(e.style.background="var(--lucent-danger-default)",r!==!1&&(e.style.borderColor="var(--lucent-danger-default)")):n==="danger-outline"?(e.style.background="var(--lucent-surface)",r!==!1&&(e.style.borderColor="var(--lucent-danger-default)")):n==="danger-ghost"&&(e.style.background="transparent")}const Jt={"2xs":8,xs:10,sm:12,md:14,lg:16};function Zt({size:e}){const n=Jt[e];return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,marginLeft:-2},children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Qt(){return t.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round","aria-hidden":!0,style:{animation:"lucent-spin 0.7s linear infinite",flexShrink:0},children:[t.jsx("style",{children:"@keyframes lucent-spin { to { transform: rotate(360deg); } }"}),t.jsx("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}const en={id:"button",name:"Button",tier:"atom",domain:"neutral",specVersion:"1.0",description:"A clickable control that triggers an action. The primary interactive primitive in Lucent UI.",designIntent:'Buttons communicate available actions. Variant conveys hierarchy: use "primary" for the single most important action in a view, "secondary" for supporting actions, "ghost" for low-emphasis actions in dense UIs, "outline" for bordered buttons with no fill, and "danger" exclusively for destructive or irreversible operations. Use "danger-ghost" for low-emphasis destructive actions (red text, no fill) and "danger-outline" for bordered destructive buttons. Size should match surrounding content density — prefer "md" as the default, "sm" for toolbars or tables, "xs" for compact UIs like customizer panels, and "2xs" for ultra-dense inline controls (~22px height) such as table-inline actions or toolbar icon triggers.',props:[{name:"variant",type:"enum",required:!1,default:"primary",description:'Visual style conveying action hierarchy. "primary" — filled accent for the single most important action. "secondary" — subtle accent-tinted fill for supporting actions. "outline" — bordered with no fill, for neutral secondary actions. "ghost" — transparent with no border, for low-emphasis or inline actions. "danger" — filled red for irreversible destructive actions (e.g. "Delete account"). "danger-outline" — red border + red text for destructive actions that need visual weight without a filled background. "danger-ghost" — red text only, for low-emphasis destructive actions (e.g. "Remove" in a list row).',enumValues:["primary","secondary","outline","ghost","danger","danger-outline","danger-ghost"]},{name:"size",type:"enum",required:!1,default:"md",description:'Controls height and padding. "lg" (48px) — hero sections, onboarding flows. "md" (42px) — default for most forms and dialogs. "sm" (34px) — toolbars, table headers, card actions. "xs" (26px) — compact UIs like customizer panels, inline controls. "2xs" (22px) — ultra-dense inline icon triggers, table-row actions, dashboard toolbar buttons.',enumValues:["2xs","xs","sm","md","lg"]},{name:"children",type:"ReactNode",required:!0,description:"Button label or content."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and applies disabled styling."},{name:"loading",type:"boolean",required:!1,default:"false",description:"Shows a spinner and prevents interaction while an async action is in progress."},{name:"fullWidth",type:"boolean",required:!1,default:"false",description:"Stretches the button to fill its container width."},{name:"bordered",type:"boolean",required:!1,default:"true",description:"When false removes the button border entirely, producing a flat look."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon element rendered before the label."},{name:"rightIcon",type:"ReactNode",required:!1,description:"Icon element rendered after the label."},{name:"chevron",type:"boolean",required:!1,default:"false",description:"Appends a chevron-down icon after the label. Useful for dropdown triggers."},{name:"spread",type:"boolean",required:!1,default:"false",description:"Spaces content to the edges (justify-content: space-between). Useful with fullWidth + rightIcon/chevron."},{name:"onClick",type:"function",required:!1,description:"Called when the button is clicked and not disabled or loading."},{name:"type",type:"enum",required:!1,default:"button",description:"Native button type attribute.",enumValues:["button","submit","reset"]}],usageExamples:[{title:"Primary action",code:'<Button variant="primary" onClick={handleSave}>Save changes</Button>'},{title:"Destructive action",code:'<Button variant="danger" onClick={handleDelete}>Delete account</Button>'},{title:"Loading state",code:'<Button variant="primary" loading={isSaving}>Save changes</Button>'},{title:"With icon",code:'<Button variant="secondary" leftIcon={<PlusIcon />}>Add member</Button>'},{title:"Ghost in toolbar",code:'<Button variant="ghost" size="sm">Edit</Button>'},{title:"Full-width submit",code:'<Button variant="primary" type="submit" fullWidth>Sign in</Button>'},{title:"Outline with swatch",code:`<Button size="xs" variant="outline" leftIcon={<span style={{ width: 8, height: 8, borderRadius: '50%', background: '#6366f1' }} />}>Indigo</Button>`},{title:"Dropdown trigger",code:'<Button variant="outline" chevron>Options</Button>'},{title:"Bordered destructive action",code:'<Button variant="danger-outline" onClick={handleRevoke}>Revoke access</Button>'},{title:"Low-emphasis destructive action",code:'<Button variant="danger-ghost" onClick={handleRemove}>Remove</Button>'},{title:"Dense inline action",code:'<Button variant="ghost" size="2xs" leftIcon={<RefreshIcon />}>Retry</Button>'}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["aria-disabled","aria-busy"],keyboardInteractions:["Enter — activates the button","Space — activates the button"]}},tn={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},it={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},je={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},re={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},lt={sm:"calc(var(--lucent-space-3) + 14px + var(--lucent-space-2))",md:"calc(var(--lucent-space-4) + 18px + var(--lucent-space-2))",lg:"calc(var(--lucent-space-4) + 20px + var(--lucent-space-3))"},ee=p.forwardRef(({size:e="md",label:n,helperText:r,errorText:o,leftElement:a,rightElement:s,prefix:i,suffix:l,id:c,style:d,...u},h)=>{const m=c??`lucent-input-${Math.random().toString(36).slice(2,7)}`,g=!!o,C=!!u.disabled,[y,f]=p.useState(!1),[v,b]=p.useState(!1),T=C?"transparent":g?"var(--lucent-danger-default)":y?"var(--lucent-focus-ring)":v?"var(--lucent-border-strong)":"var(--lucent-border-default)",D=y?`0 0 0 3px ${g?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none",x={display:"flex",alignItems:"center",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",fontSize:it[e],fontFamily:"var(--lucent-font-family-base)",whiteSpace:"nowrap",userSelect:"none",flexShrink:0},M={...x,paddingLeft:re[e],paddingRight:"2px"},P={...x,paddingLeft:"2px",paddingRight:re[e]};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%",...d},children:[n&&t.jsx("label",{htmlFor:m,style:{fontSize:je[e],fontWeight:"var(--lucent-font-weight-medium)",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:n}),t.jsxs("div",{style:{display:"flex",alignItems:"stretch",height:tn[e],border:`1px solid ${T}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:D,background:C?"var(--lucent-surface-secondary)":"var(--lucent-surface)",overflow:"hidden",cursor:C?"not-allowed":void 0,transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},onMouseEnter:()=>{C||b(!0)},onMouseLeave:()=>b(!1),children:[i&&t.jsx("span",{style:M,children:i}),t.jsxs("div",{style:{position:"relative",flex:1,display:"flex",alignItems:"center",minWidth:0},children:[a&&t.jsx("span",{style:{position:"absolute",left:re[e],color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",display:"flex",alignItems:"center",pointerEvents:"none"},children:a}),t.jsx("input",{ref:h,id:m,"aria-invalid":g,"aria-describedby":g?`${m}-error`:r?`${m}-helper`:void 0,style:{width:"100%",height:"100%",paddingLeft:a?lt[e]:re[e],paddingRight:s?lt[e]:re[e],fontSize:it[e],fontFamily:"var(--lucent-font-family-base)",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:"transparent",border:"none",outline:"none",cursor:C?"not-allowed":void 0,boxSizing:"border-box"},...u,onFocus:k=>{var j;f(!0),(j=u.onFocus)==null||j.call(u,k)},onBlur:k=>{var j;f(!1),(j=u.onBlur)==null||j.call(u,k)}}),s&&t.jsx("span",{style:{position:"absolute",right:re[e],color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",display:"flex",alignItems:"center"},children:s})]}),l&&t.jsx("span",{style:P,children:l})]}),g&&t.jsx("span",{id:`${m}-error`,role:"alert",style:{fontSize:je[e],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:o}),!g&&r&&t.jsx("span",{id:`${m}-helper`,style:{fontSize:je[e],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:r})]})});ee.displayName="Input";const nn={id:"input",name:"Input",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A single-line text field with optional label, helper text, and error state.",designIntent:"Always pair with a visible label — never rely on placeholder text alone as it disappears on input and is inaccessible. Use errorText (not helperText) to surface validation failures; the component applies danger styling automatically. leftElement and rightElement accept icons or small controls (e.g. currency symbol, clear button).",props:[{name:"size",type:"enum",required:!1,default:"md",description:"Controls height, font size, and padding. Label and helper text scale accordingly.",enumValues:["sm","md","lg"]},{name:"type",type:"enum",required:!1,default:"text",description:"HTML input type.",enumValues:["text","number","password","email","tel","url","search","color"]},{name:"label",type:"string",required:!1,description:"Visible label rendered above the input."},{name:"helperText",type:"string",required:!1,description:"Supplementary hint shown below the input."},{name:"errorText",type:"string",required:!1,description:"Validation error message. When set, input renders in error state."},{name:"leftElement",type:"ReactNode",required:!1,description:"Icon or adornment rendered inside the left edge."},{name:"rightElement",type:"ReactNode",required:!1,description:"Icon or adornment rendered inside the right edge."},{name:"placeholder",type:"string",required:!1,description:"Placeholder text. Use as a hint, not a label."},{name:"prefix",type:"ReactNode",required:!1,description:'Inset label attached to the left of the field (e.g. "$", "https://").'},{name:"suffix",type:"ReactNode",required:!1,description:'Inset label attached to the right of the field (e.g. "kg", ".com").'},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the input."},{name:"value",type:"string",required:!1,description:"Controlled value."},{name:"onChange",type:"function",required:!1,description:"Change handler."}],usageExamples:[{title:"Basic",code:'<Input label="Email" type="email" placeholder="you@example.com" />'},{title:"With helper text",code:'<Input label="Username" helperText="3–20 characters, letters and numbers only" />'},{title:"Error state",code:'<Input label="Password" type="password" value={value} errorText="Must be at least 8 characters" />'},{title:"With icon",code:'<Input label="Search" leftElement={<SearchIcon />} placeholder="Search…" />'}],compositionGraph:[],accessibility:{role:"textbox",ariaAttributes:["aria-invalid","aria-describedby","aria-label"],keyboardInteractions:["Tab — focuses the input"]}},an={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},rn={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},on={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},Ct=p.forwardRef(({label:e,helperText:n,errorText:r,autoResize:o=!1,maxLength:a,showCount:s=!1,size:i="md",id:l,value:c,onChange:d,disabled:u,style:h,...m},g)=>{const C=p.useRef(null),y=g??C,f=l??`lucent-textarea-${Math.random().toString(36).slice(2,7)}`,v=!!r,b=!!u,T=typeof c=="string"?c.length:0;p.useEffect(()=>{if(!o)return;const x=y.current;x&&(x.style.height="auto",x.style.height=`${x.scrollHeight}px`)},[c,o,y]);const D=b?"transparent":v?"var(--lucent-danger-default)":"var(--lucent-border-default)";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%"},children:[e&&t.jsx("label",{htmlFor:f,style:{fontSize:rn[i],fontWeight:"var(--lucent-font-weight-medium)",color:b?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:e}),t.jsx("textarea",{ref:y,id:f,maxLength:a,value:c,onChange:d,disabled:u,"aria-invalid":v,"aria-describedby":v?`${f}-error`:n?`${f}-helper`:void 0,style:{width:"100%",minHeight:"100px",padding:on[i],fontSize:an[i],fontFamily:"var(--lucent-font-family-base)",color:b?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:b?"var(--lucent-surface-secondary)":"var(--lucent-surface)",border:`1px solid ${D}`,borderRadius:"var(--lucent-radius-lg)",outline:"none",resize:o?"none":"vertical",boxSizing:"border-box",lineHeight:"var(--lucent-line-height-base)",cursor:b?"not-allowed":void 0,transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),...h},onMouseEnter:x=>{var M;!b&&x.currentTarget!==document.activeElement&&(x.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-strong)"),(M=m.onMouseEnter)==null||M.call(m,x)},onMouseLeave:x=>{var M;!b&&x.currentTarget!==document.activeElement&&(x.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-default)"),(M=m.onMouseLeave)==null||M.call(m,x)},onFocus:x=>{var M;b||(x.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-focus-ring)",x.currentTarget.style.boxShadow=`0 0 0 3px ${v?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`,(M=m.onFocus)==null||M.call(m,x))},onBlur:x=>{var M;b||(x.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-default)",x.currentTarget.style.boxShadow="none",(M=m.onBlur)==null||M.call(m,x))},...m}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[v&&t.jsx("span",{id:`${f}-error`,role:"alert",style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:r}),!v&&n&&t.jsx("span",{id:`${f}-helper`,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:n})]}),(s||a)&&t.jsxs("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:a&&T>=a?"var(--lucent-danger-text)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-mono)",flexShrink:0,marginLeft:"var(--lucent-space-2)"},children:[T,a?`/${a}`:""]})]})]})});Ct.displayName="Textarea";const sn={id:"textarea",name:"Textarea",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A multi-line text input with optional auto-resize and character count.",designIntent:"Use autoResize for open-ended fields (bio, description) where content length is unpredictable. Use maxLength + showCount for fields with hard limits (tweet-style). Behaves identically to Input for label/helper/error patterns.",props:[{name:"label",type:"string",required:!1,description:"Visible label above the textarea."},{name:"helperText",type:"string",required:!1,description:"Hint text shown below."},{name:"errorText",type:"string",required:!1,description:"Validation error. Triggers error styling."},{name:"autoResize",type:"boolean",required:!1,default:"false",description:"Grows with content, disables manual resize handle."},{name:"maxLength",type:"number",required:!1,description:"Character limit. Displays counter when set."},{name:"showCount",type:"boolean",required:!1,default:"false",description:"Always show character counter even without maxLength."},{name:"value",type:"string",required:!1,description:"Controlled value."},{name:"onChange",type:"function",required:!1,description:"Change handler."},{name:"placeholder",type:"string",required:!1,description:"Placeholder text."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls font size and padding.",enumValues:["sm","md","lg"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the textarea."}],usageExamples:[{title:"Basic",code:'<Textarea label="Bio" placeholder="Tell us about yourself…" />'},{title:"Auto-resize",code:'<Textarea label="Description" autoResize value={value} onChange={e => setValue(e.target.value)} />'},{title:"With character count",code:'<Textarea label="Tweet" maxLength={280} showCount value={value} onChange={e => setValue(e.target.value)} />'},{title:"Error state",code:'<Textarea label="Notes" errorText="Required" value="" />'}],compositionGraph:[],accessibility:{role:"textbox",ariaAttributes:["aria-multiline","aria-invalid","aria-describedby"],keyboardInteractions:["Tab — focuses the textarea"]}},ln={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)"},accent:{bg:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"var(--lucent-accent-default)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)"}},cn={sm:{fontSize:"var(--lucent-font-size-xs)",padding:"0 var(--lucent-space-2)",height:"18px"},md:{fontSize:"var(--lucent-font-size-sm)",padding:"0 var(--lucent-space-2)",height:"22px"}};function dn({variant:e="neutral",size:n="md",dot:r=!1,children:o,style:a}){const s=ln[e],i=cn[n];return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",height:i.height,padding:i.padding,fontSize:i.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-full)",background:s.bg,color:s.color,border:`1px solid ${s.border}`,whiteSpace:"nowrap",boxSizing:"border-box",...a},children:[r&&t.jsx("span",{style:{width:6,height:6,borderRadius:"var(--lucent-radius-full)",background:"currentColor",flexShrink:0}}),o]})}const un={id:"badge",name:"Badge",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A small inline label for status, count, or category.",designIntent:'Badges communicate status or category at a glance. Match variant to semantic meaning — never use "danger" for non-critical states or "success" for neutral counts. Use dot=true when a single colour indicator is enough context (e.g. online status). Keep badge text short: 1–3 words maximum.',props:[{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","success","warning","danger","info","accent"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height and font size.",enumValues:["sm","md"]},{name:"dot",type:"boolean",required:!1,default:"false",description:"Prepends a coloured dot indicator."},{name:"children",type:"ReactNode",required:!0,description:"Badge label."}],usageExamples:[{title:"Status",code:'<Badge variant="success" dot>Active</Badge>'},{title:"Count",code:'<Badge variant="danger">12</Badge>'},{title:"Category",code:'<Badge variant="info">Beta</Badge>'},{title:"Neutral tag",code:"<Badge>Draft</Badge>"}],compositionGraph:[],accessibility:{role:"status",notes:"Use aria-label on the parent element when badge meaning depends on context."}},pn={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)",hoverBg:"var(--lucent-surface-hover, #e5e7eb)",hoverBorder:"var(--lucent-border-strong)"},accent:{bg:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"var(--lucent-accent-default)",hoverBg:"var(--lucent-accent-hover)",hoverBorder:"var(--lucent-accent-hover)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-success-default) 15%, var(--lucent-success-subtle))",hoverBorder:"var(--lucent-success-default)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-warning-default) 15%, var(--lucent-warning-subtle))",hoverBorder:"var(--lucent-warning-default)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-danger-default) 15%, var(--lucent-danger-subtle))",hoverBorder:"var(--lucent-danger-default)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-info-default) 15%, var(--lucent-info-subtle))",hoverBorder:"var(--lucent-info-default)"}},fn={sm:{fontSize:"var(--lucent-font-size-xs)",height:"calc(var(--lucent-space-5) * 0.5 + 10px)",padding:"var(--lucent-space-1) var(--lucent-space-2)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-2)",iconSize:12,dotSize:6,gap:"var(--lucent-space-1)"},md:{fontSize:"var(--lucent-font-size-sm)",height:"calc(var(--lucent-space-6) * 0.5 + 12px)",padding:"var(--lucent-space-1) var(--lucent-space-2)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-2)",iconSize:14,dotSize:7,gap:"var(--lucent-space-2)"},lg:{fontSize:"var(--lucent-font-size-md)",height:"calc(var(--lucent-space-8) * 0.5 + 14px)",padding:"var(--lucent-space-1) var(--lucent-space-3)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-2) var(--lucent-space-1) var(--lucent-space-3)",iconSize:16,dotSize:8,gap:"var(--lucent-space-2)"}};function jt({children:e,variant:n="neutral",size:r="md",onDismiss:o,onClick:a,leftIcon:s,swatch:i,dot:l=!1,borderless:c=!1,disabled:d=!1,style:u}){const h=pn[n],m=fn[r],[g,C]=p.useState(!1),y=!d&&(o||a),f={display:"inline-flex",alignItems:"center",gap:m.gap,height:m.height,padding:o?m.paddingDismiss:m.padding,fontSize:m.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-lg)",background:g&&y?h.hoverBg:h.bg,color:h.color,border:c?"1px solid transparent":`1px solid ${g&&y?h.hoverBorder:h.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:d?.5:1,transform:g&&y?"translateY(-1px)":"none",boxShadow:g&&y?`0 2px 4px ${h.hoverBorder}22`:"none",transition:["transform var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)","border-color var(--lucent-duration-fast) var(--lucent-easing-default)","background var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),cursor:y?"pointer":"default",...a?{outline:"none"}:{},...u},v=t.jsxs(t.Fragment,{children:[i&&t.jsx("span",{style:{width:m.dotSize+2,height:m.dotSize+2,borderRadius:"50%",background:i,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),l&&!i&&t.jsx("span",{style:{width:m.dotSize,height:m.dotSize,borderRadius:"50%",background:"currentColor",flexShrink:0}}),s&&!i&&!l&&t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:m.iconSize,height:m.iconSize,flexShrink:0},children:s}),e,o&&t.jsx("button",{type:"button",onClick:d?void 0:T=>{T.stopPropagation(),o()},disabled:d,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:m.iconSize+2,height:m.iconSize+2,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:d?"not-allowed":"pointer",flexShrink:0,lineHeight:1},children:t.jsx("svg",{width:m.iconSize-2,height:m.iconSize-2,viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",children:t.jsx("path",{d:"M2 2L8 8M8 2L2 8"})})})]}),b={onMouseEnter:()=>{d||C(!0)},onMouseLeave:()=>C(!1)};return a?t.jsx("button",{type:"button",onClick:d?void 0:a,disabled:d,style:f,...b,children:v}):t.jsx("span",{style:f,...b,children:v})}const hn={id:"chip",name:"Chip",tier:"atom",domain:"neutral",specVersion:"1.0",description:"A compact label for filters, tags, statuses, and categories. Combines the roles of Badge and Tag into a single flexible component.",designIntent:"Chip is the universal label primitive — use it anywhere you need a compact visual marker. It replaces both Badge (static status) and Tag (dismissible filter) with a single component. Use `onDismiss` for removable chips (filters, multi-select values). Use `onClick` for clickable/selectable chips (filter toggles, category navigation). Use `dot` for status indicators (online/offline). Use `swatch` for color-coded categories. Use `leftIcon` for chips with leading icons (folders, file types, flags). Use `borderless` for a softer, filled-only appearance in dense UIs. Variant conveys semantic meaning — default to neutral for user-generated content.",props:[{name:"children",type:"ReactNode",required:!0,description:"Chip label content."},{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","accent","success","warning","danger","info"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height, font size, and icon size.",enumValues:["sm","md","lg"]},{name:"onDismiss",type:"function",required:!1,description:"Renders an x button that calls this handler. Use for removable filters and multi-select values."},{name:"onClick",type:"function",required:!1,description:"Makes the chip clickable (renders as <button>). Use for filter toggles and category links."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon or element rendered before the label (emoji, flag, avatar)."},{name:"swatch",type:"string",required:!1,description:"Hex color string. Renders a small color dot before the label."},{name:"dot",type:"boolean",required:!1,default:"false",description:"Renders a status dot using the variant colour. Use for online/offline indicators."},{name:"borderless",type:"boolean",required:!1,default:"false",description:"Removes the border for a filled-only look."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Dims the chip and prevents interaction."},{name:"style",type:"object",required:!1,description:"Inline style overrides."}],usageExamples:[{title:"Dismissible filter",code:"<Chip onDismiss={() => removeFilter('react')}>React</Chip>"},{title:"Status with dot",code:'<Chip variant="success" dot>Online</Chip>'},{title:"Color swatch",code:'<Chip swatch="#6366f1" onDismiss={() => {}}>Indigo</Chip>'},{title:"With icon",code:"<Chip leftIcon={<FolderIcon />} onDismiss={() => {}}>Documents</Chip>"},{title:"Clickable category",code:`<Chip variant="accent" onClick={() => navigate('/ux')}>UX</Chip>`},{title:"Borderless",code:'<Chip variant="warning" borderless>Pending</Chip>'},{title:"Static label",code:'<Chip variant="info">Beta</Chip>'}],compositionGraph:[],accessibility:{role:"group",notes:'When onClick is provided, renders as <button> with native button semantics. Dismiss button has aria-label="Dismiss" and stopPropagation to prevent parent click handlers.',keyboardInteractions:["Enter / Space — activates onClick or dismiss button when focused"]}},mn={xs:24,sm:32,md:40,lg:56,xl:80},gn={xs:"var(--lucent-font-size-xs)",sm:"var(--lucent-font-size-xs)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-lg)",xl:"var(--lucent-font-size-xl)"};function bn(e,n){var o,a,s;if(n)return n.slice(0,2).toUpperCase();const r=e.trim().split(/\s+/);return r.length===1?(((o=r[0])==null?void 0:o[0])??"").toUpperCase():((((a=r[0])==null?void 0:a[0])??"")+(((s=r[r.length-1])==null?void 0:s[0])??"")).toUpperCase()}function vn({src:e,alt:n,size:r="md",initials:o,style:a,...s}){const i=mn[r],l=bn(n,o),c={width:i,height:i,borderRadius:"var(--lucent-radius-full)",flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",userSelect:"none",...a};return e?t.jsx("img",{src:e,alt:n,width:i,height:i,style:{...c,objectFit:"cover"},...s}):t.jsx("span",{role:"img","aria-label":n,style:{...c,background:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",fontSize:gn[r],fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)"},children:l})}const yn={id:"avatar",name:"Avatar",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A circular user image with initials fallback.",designIntent:"Always provide alt for accessibility — it is used to derive initials automatically when src is absent or fails. Use initials prop to override auto-derived initials (e.g. for non-Latin names). Size xs/sm suit table rows and compact lists; md is the default for comment threads; lg/xl for profile headers.",props:[{name:"src",type:"string",required:!1,description:"Image URL. Falls back to initials if omitted or fails to load."},{name:"alt",type:"string",required:!0,description:"Alt text and source for auto-derived initials."},{name:"size",type:"enum",required:!1,default:"md",description:"Diameter of the avatar.",enumValues:["xs","sm","md","lg","xl"]},{name:"initials",type:"string",required:!1,description:"Override auto-derived initials (max 2 characters)."}],usageExamples:[{title:"With image",code:'<Avatar src="/avatars/jane.jpg" alt="Jane Doe" />'},{title:"Initials fallback",code:'<Avatar alt="Jane Doe" />'},{title:"Large profile",code:'<Avatar src={user.avatar} alt={user.name} size="lg" />'},{title:"Custom initials",code:'<Avatar alt="张伟" initials="张" size="md" />'}],compositionGraph:[],accessibility:{role:"img",ariaAttributes:["aria-label"],notes:'When src is present, renders as <img> with alt. When showing initials, renders as <span role="img" aria-label>.'}},xn={xs:12,sm:16,md:24,lg:36},wn={xs:2.5,sm:2.5,md:2,lg:2};function It({size:e="md",label:n="Loading…",color:r}){const o=xn[e],a=wn[e];return t.jsxs("span",{role:"status","aria-label":n,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},children:[t.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,style:{animation:"lucent-spin 0.7s linear infinite",color:r??"currentColor"},children:[t.jsx("style",{children:"@keyframes lucent-spin { to { transform: rotate(360deg); } }"}),t.jsx("circle",{cx:12,cy:12,r:10,stroke:"currentColor",strokeWidth:a,strokeOpacity:.2}),t.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round"})]}),t.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"},children:n})]})}const kn={id:"spinner",name:"Spinner",tier:"atom",domain:"neutral",specVersion:"0.1",description:"An animated loading indicator for async operations.",designIntent:"Use Spinner for indeterminate loading states of short duration (< 3s). For full-page or skeleton-level loading, prefer Skeleton instead. The label prop is visually hidden but read by screen readers — always set it to a meaningful description of what is loading.",props:[{name:"size",type:"enum",required:!1,default:"md",description:"Spinner diameter.",enumValues:["xs","sm","md","lg"]},{name:"label",type:"string",required:!1,default:"Loading…",description:"Visually hidden accessible label."},{name:"color",type:"string",required:!1,description:"Override colour (CSS value). Defaults to currentColor."}],usageExamples:[{title:"Default",code:"<Spinner />"},{title:"Inside button",code:'<Button loading><Spinner size="sm" label="Saving…" /></Button>'},{title:"Full-page overlay",code:`<div style={{ display: 'grid', placeItems: 'center', minHeight: '100vh' }}><Spinner size="lg" label="Loading dashboard…" /></div>`}],compositionGraph:[],accessibility:{role:"status",ariaAttributes:["aria-label"],notes:'The visible SVG is aria-hidden. The label is conveyed via a visually-hidden span inside role="status".'}};function Sn({orientation:e="horizontal",label:n,spacing:r="var(--lucent-space-4)",style:o}){return e==="vertical"?t.jsx("span",{role:"separator","aria-orientation":"vertical",style:{display:"inline-block",width:"1px",alignSelf:"stretch",background:"var(--lucent-border-default)",margin:`0 ${r}`,flexShrink:0,...o}}):n?t.jsxs("div",{role:"separator","aria-label":n,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",margin:`${r} 0`,...o},children:[t.jsx("span",{style:{flex:1,height:"1px",background:"var(--lucent-border-default)"}}),t.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)",whiteSpace:"nowrap",letterSpacing:"var(--lucent-letter-spacing-wide)",textTransform:"uppercase"},children:n}),t.jsx("span",{style:{flex:1,height:"1px",background:"var(--lucent-border-default)"}})]}):t.jsx("hr",{role:"separator",style:{border:"none",borderTop:"1px solid var(--lucent-border-default)",margin:`${r} 0`,width:"100%",...o}})}const Tn={id:"divider",name:"Divider",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A visual separator between content sections, horizontal or vertical.",designIntent:'Use horizontal Divider to separate sections in a layout. Use vertical Divider inline between sibling elements (e.g. nav links, toolbar buttons). Use the label prop for "OR" separators in auth flows or form sections — never use a plain text node next to a divider for this.',props:[{name:"orientation",type:"enum",required:!1,default:"horizontal",description:"Direction of the divider line.",enumValues:["horizontal","vertical"]},{name:"label",type:"string",required:!1,description:'Optional centered label (horizontal only). Common use: "OR", "AND", section titles.'},{name:"spacing",type:"string",required:!1,default:"var(--lucent-space-4)",description:"Margin on the axis perpendicular to the line."}],usageExamples:[{title:"Section separator",code:"<Divider />"},{title:"With label",code:'<Divider label="OR" />'},{title:"Vertical in nav",code:`<nav style={{ display: 'flex', alignItems: 'center' }}><a>Home</a><Divider orientation="vertical" /><a>About</a></nav>`}],compositionGraph:[],accessibility:{role:"separator",ariaAttributes:["aria-orientation","aria-label"]}},Cn={sm:14,md:16,lg:20},jn={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},In=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),Fe=require("react-dom"),Xt={primary:{background:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"1px solid transparent"},secondary:{background:"color-mix(in srgb, var(--lucent-accent-default) 14%, var(--lucent-surface-secondary))",color:"var(--lucent-text-primary)",border:"1px solid transparent"},outline:{background:"var(--lucent-surface)",color:"var(--lucent-text-primary)",border:"1px solid var(--lucent-border-default)"},ghost:{background:"transparent",color:"var(--lucent-text-primary)",border:"1px solid transparent"},danger:{background:"var(--lucent-danger-default)",color:"#ffffff",border:"1px solid var(--lucent-danger-default)"},"danger-outline":{background:"var(--lucent-surface)",color:"var(--lucent-danger-text)",border:"1px solid var(--lucent-danger-default)"},"danger-ghost":{background:"transparent",color:"var(--lucent-danger-text)",border:"1px solid transparent"}},Jt={"2xs":{height:"22px",padding:"0 var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)",borderRadius:"var(--lucent-radius-md)"},xs:{height:"26px",padding:"0 var(--lucent-space-2)",fontSize:"var(--lucent-font-size-xs)"},sm:{height:"calc(var(--lucent-space-8) * 0.5 + 18px)",padding:"0 var(--lucent-space-3)",fontSize:"var(--lucent-font-size-sm)"},md:{height:"calc(var(--lucent-space-10) * 0.5 + 22px)",padding:"0 var(--lucent-space-4)",fontSize:"var(--lucent-font-size-md)"},lg:{height:"calc(var(--lucent-space-12) * 0.5 + 26px)",padding:"0 var(--lucent-space-5)",fontSize:"var(--lucent-font-size-lg)"}},Ne=p.forwardRef(({variant:t="primary",size:n="md",loading:r=!1,fullWidth:o=!1,spread:a=!1,leftIcon:i,rightIcon:s,chevron:l=!1,disableHoverStyles:c=!1,bordered:d=!0,children:u,disabled:h,style:m,...g},C)=>{const b=h??r;return e.jsxs("button",{ref:C,disabled:b,"aria-busy":r,style:{display:"inline-flex",alignItems:"center",justifyContent:a?"space-between":"center",gap:"var(--lucent-space-2)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,letterSpacing:"0.01em",borderRadius:"var(--lucent-radius-lg)",cursor:b?"not-allowed":"pointer",width:o?"100%":void 0,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default), transform 80ms var(--lucent-easing-default)",whiteSpace:"nowrap",boxSizing:"border-box",outline:"none",margin:0,...Jt[n],...Xt[t],...m,...b&&{background:"color-mix(in srgb, var(--lucent-surface-secondary) 70%, var(--lucent-border-default))",color:"color-mix(in srgb, var(--lucent-text-disabled) 50%, var(--lucent-border-default))",borderColor:"transparent"},...d===!1&&{border:"none"}},onMouseEnter:f=>{var v;!b&&!c&&Qt(f.currentTarget,t,d),(v=g.onMouseEnter)==null||v.call(g,f)},onMouseLeave:f=>{var v;!b&&!c&&en(f.currentTarget,t,d),(v=g.onMouseLeave)==null||v.call(g,f)},onMouseDown:f=>{var v;if(!b){const x=t==="danger"||t==="danger-outline"||t==="danger-ghost"?"var(--lucent-danger-default)":"var(--lucent-accent-default)";f.currentTarget.style.transform="translateY(1px)",f.currentTarget.style.boxShadow=`0 0 0 2px var(--lucent-surface), 0 0 0 4px ${x}`,f.currentTarget.dataset.pressed="1"}(v=g.onMouseDown)==null||v.call(g,f)},onMouseUp:f=>{var v;f.currentTarget.style.transform="",f.currentTarget.style.boxShadow="",delete f.currentTarget.dataset.pressed,(v=g.onMouseUp)==null||v.call(g,f)},onFocus:f=>{var v;f.currentTarget.dataset.pressed||(f.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)"),(v=g.onFocus)==null||v.call(g,f)},onBlur:f=>{var v;f.currentTarget.style.boxShadow="",(v=g.onBlur)==null||v.call(g,f)},...g,children:[i,r?e.jsx(an,{}):u,!r&&s,!r&&l&&e.jsx(nn,{size:n})]})});Ne.displayName="Button";const Zt={primary:"0 4px 14px -2px var(--lucent-accent-subtle)",secondary:"0 4px 14px -2px var(--lucent-accent-subtle)",outline:"0 4px 14px -2px var(--lucent-accent-subtle)",ghost:"0 4px 14px -2px var(--lucent-accent-subtle)",danger:"0 4px 14px -2px var(--lucent-danger-subtle)","danger-outline":"0 4px 14px -2px var(--lucent-danger-subtle)","danger-ghost":"0 4px 14px -2px var(--lucent-danger-subtle)"};function Qt(t,n,r){t.style.transform="translateY(-1px)",t.style.boxShadow=Zt[n],n==="primary"?t.style.background="var(--lucent-accent-hover)":n==="secondary"?t.style.background="color-mix(in srgb, var(--lucent-accent-default) 10%, var(--lucent-surface-secondary))":n==="outline"?t.style.background="color-mix(in srgb, var(--lucent-accent-default) 10%, var(--lucent-surface))":n==="ghost"?t.style.background="color-mix(in srgb, var(--lucent-accent-default) 8%, var(--lucent-surface))":n==="danger"?(t.style.background="var(--lucent-danger-hover)",r!==!1&&(t.style.borderColor="var(--lucent-danger-hover)")):n==="danger-outline"?(t.style.background="color-mix(in srgb, var(--lucent-danger-default) 10%, var(--lucent-surface))",r!==!1&&(t.style.borderColor="var(--lucent-danger-hover)")):n==="danger-ghost"&&(t.style.background="color-mix(in srgb, var(--lucent-danger-default) 8%, var(--lucent-surface))")}function en(t,n,r){t.style.transform="",t.style.boxShadow="",n==="primary"?t.style.background="var(--lucent-accent-default)":n==="secondary"?t.style.background="var(--lucent-surface-secondary)":n==="outline"?t.style.background="var(--lucent-surface)":n==="ghost"?t.style.background="transparent":n==="danger"?(t.style.background="var(--lucent-danger-default)",r!==!1&&(t.style.borderColor="var(--lucent-danger-default)")):n==="danger-outline"?(t.style.background="var(--lucent-surface)",r!==!1&&(t.style.borderColor="var(--lucent-danger-default)")):n==="danger-ghost"&&(t.style.background="transparent")}const tn={"2xs":8,xs:10,sm:12,md:14,lg:16};function nn({size:t}){const n=tn[t];return e.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,marginLeft:-2},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function an(){return e.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round","aria-hidden":!0,style:{animation:"lucent-spin 0.7s linear infinite",flexShrink:0},children:[e.jsx("style",{children:"@keyframes lucent-spin { to { transform: rotate(360deg); } }"}),e.jsx("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}const rn={id:"button",name:"Button",tier:"atom",domain:"neutral",specVersion:"1.0",description:"A clickable control that triggers an action. The primary interactive primitive in Lucent UI.",designIntent:'Buttons communicate available actions. Variant conveys hierarchy: use "primary" for the single most important action in a view, "secondary" for supporting actions, "ghost" for low-emphasis actions in dense UIs, "outline" for bordered buttons with no fill, and "danger" exclusively for destructive or irreversible operations. Use "danger-ghost" for low-emphasis destructive actions (red text, no fill) and "danger-outline" for bordered destructive buttons. Size should match surrounding content density — prefer "md" as the default, "sm" for toolbars or tables, "xs" for compact UIs like customizer panels, and "2xs" for ultra-dense inline controls (~22px height) such as table-inline actions or toolbar icon triggers.',props:[{name:"variant",type:"enum",required:!1,default:"primary",description:'Visual style conveying action hierarchy. "primary" — filled accent for the single most important action. "secondary" — subtle accent-tinted fill for supporting actions. "outline" — bordered with no fill, for neutral secondary actions. "ghost" — transparent with no border, for low-emphasis or inline actions. "danger" — filled red for irreversible destructive actions (e.g. "Delete account"). "danger-outline" — red border + red text for destructive actions that need visual weight without a filled background. "danger-ghost" — red text only, for low-emphasis destructive actions (e.g. "Remove" in a list row).',enumValues:["primary","secondary","outline","ghost","danger","danger-outline","danger-ghost"]},{name:"size",type:"enum",required:!1,default:"md",description:'Controls height and padding. "lg" (48px) — hero sections, onboarding flows. "md" (42px) — default for most forms and dialogs. "sm" (34px) — toolbars, table headers, card actions. "xs" (26px) — compact UIs like customizer panels, inline controls. "2xs" (22px) — ultra-dense inline icon triggers, table-row actions, dashboard toolbar buttons.',enumValues:["2xs","xs","sm","md","lg"]},{name:"children",type:"ReactNode",required:!0,description:"Button label or content."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and applies disabled styling."},{name:"loading",type:"boolean",required:!1,default:"false",description:"Shows a spinner and prevents interaction while an async action is in progress."},{name:"fullWidth",type:"boolean",required:!1,default:"false",description:"Stretches the button to fill its container width."},{name:"bordered",type:"boolean",required:!1,default:"true",description:"When false removes the button border entirely, producing a flat look."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon element rendered before the label."},{name:"rightIcon",type:"ReactNode",required:!1,description:"Icon element rendered after the label."},{name:"chevron",type:"boolean",required:!1,default:"false",description:"Appends a chevron-down icon after the label. Useful for dropdown triggers."},{name:"spread",type:"boolean",required:!1,default:"false",description:"Spaces content to the edges (justify-content: space-between). Useful with fullWidth + rightIcon/chevron."},{name:"onClick",type:"function",required:!1,description:"Called when the button is clicked and not disabled or loading."},{name:"type",type:"enum",required:!1,default:"button",description:"Native button type attribute.",enumValues:["button","submit","reset"]}],usageExamples:[{title:"Primary action",code:'<Button variant="primary" onClick={handleSave}>Save changes</Button>'},{title:"Destructive action",code:'<Button variant="danger" onClick={handleDelete}>Delete account</Button>'},{title:"Loading state",code:'<Button variant="primary" loading={isSaving}>Save changes</Button>'},{title:"With icon",code:'<Button variant="secondary" leftIcon={<PlusIcon />}>Add member</Button>'},{title:"Ghost in toolbar",code:'<Button variant="ghost" size="sm">Edit</Button>'},{title:"Full-width submit",code:'<Button variant="primary" type="submit" fullWidth>Sign in</Button>'},{title:"Outline with swatch",code:`<Button size="xs" variant="outline" leftIcon={<span style={{ width: 8, height: 8, borderRadius: '50%', background: '#6366f1' }} />}>Indigo</Button>`},{title:"Dropdown trigger",code:'<Button variant="outline" chevron>Options</Button>'},{title:"Bordered destructive action",code:'<Button variant="danger-outline" onClick={handleRevoke}>Revoke access</Button>'},{title:"Low-emphasis destructive action",code:'<Button variant="danger-ghost" onClick={handleRemove}>Remove</Button>'},{title:"Dense inline action",code:'<Button variant="ghost" size="2xs" leftIcon={<RefreshIcon />}>Retry</Button>'}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["aria-disabled","aria-busy"],keyboardInteractions:["Enter — activates the button","Space — activates the button"]}},on={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},lt={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},je={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},re={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},ct={sm:"calc(var(--lucent-space-3) + 14px + var(--lucent-space-2))",md:"calc(var(--lucent-space-4) + 18px + var(--lucent-space-2))",lg:"calc(var(--lucent-space-4) + 20px + var(--lucent-space-3))"},te=p.forwardRef(({size:t="md",label:n,helperText:r,errorText:o,leftElement:a,rightElement:i,prefix:s,suffix:l,id:c,style:d,...u},h)=>{const m=c??`lucent-input-${Math.random().toString(36).slice(2,7)}`,g=!!o,C=!!u.disabled,[b,f]=p.useState(!1),[v,S]=p.useState(!1),x=C?"transparent":g?"var(--lucent-danger-default)":b?"var(--lucent-focus-ring)":v?"var(--lucent-border-strong)":"var(--lucent-border-default)",I=b?`0 0 0 3px ${g?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none",w={display:"flex",alignItems:"center",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",fontSize:lt[t],fontFamily:"var(--lucent-font-family-base)",whiteSpace:"nowrap",userSelect:"none",flexShrink:0},z={...w,paddingLeft:re[t],paddingRight:"2px"},q={...w,paddingLeft:"2px",paddingRight:re[t]};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%",...d},children:[n&&e.jsx("label",{htmlFor:m,style:{fontSize:je[t],fontWeight:"var(--lucent-font-weight-medium)",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"stretch",height:on[t],border:`1px solid ${x}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:I,background:C?"var(--lucent-surface-secondary)":"var(--lucent-surface)",overflow:"hidden",cursor:C?"not-allowed":void 0,transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},onMouseEnter:()=>{C||S(!0)},onMouseLeave:()=>S(!1),children:[s&&e.jsx("span",{style:z,children:s}),e.jsxs("div",{style:{position:"relative",flex:1,display:"flex",alignItems:"center",minWidth:0},children:[a&&e.jsx("span",{style:{position:"absolute",left:re[t],color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",display:"flex",alignItems:"center",pointerEvents:"none"},children:a}),e.jsx("input",{ref:h,id:m,"aria-invalid":g,"aria-describedby":g?`${m}-error`:r?`${m}-helper`:void 0,style:{width:"100%",height:"100%",paddingLeft:a?ct[t]:re[t],paddingRight:i?ct[t]:re[t],fontSize:lt[t],fontFamily:"var(--lucent-font-family-base)",color:C?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:"transparent",border:"none",outline:"none",cursor:C?"not-allowed":void 0,boxSizing:"border-box"},...u,onFocus:T=>{var M;f(!0),(M=u.onFocus)==null||M.call(u,T)},onBlur:T=>{var M;f(!1),(M=u.onBlur)==null||M.call(u,T)}}),i&&e.jsx("span",{style:{position:"absolute",right:re[t],color:C?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",display:"flex",alignItems:"center"},children:i})]}),l&&e.jsx("span",{style:q,children:l})]}),g&&e.jsx("span",{id:`${m}-error`,role:"alert",style:{fontSize:je[t],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:o}),!g&&r&&e.jsx("span",{id:`${m}-helper`,style:{fontSize:je[t],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:r})]})});te.displayName="Input";const sn={id:"input",name:"Input",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A single-line text field with optional label, helper text, and error state.",designIntent:"Always pair with a visible label — never rely on placeholder text alone as it disappears on input and is inaccessible. Use errorText (not helperText) to surface validation failures; the component applies danger styling automatically. leftElement and rightElement accept icons or small controls (e.g. currency symbol, clear button).",props:[{name:"size",type:"enum",required:!1,default:"md",description:"Controls height, font size, and padding. Label and helper text scale accordingly.",enumValues:["sm","md","lg"]},{name:"type",type:"enum",required:!1,default:"text",description:"HTML input type.",enumValues:["text","number","password","email","tel","url","search","color"]},{name:"label",type:"string",required:!1,description:"Visible label rendered above the input."},{name:"helperText",type:"string",required:!1,description:"Supplementary hint shown below the input."},{name:"errorText",type:"string",required:!1,description:"Validation error message. When set, input renders in error state."},{name:"leftElement",type:"ReactNode",required:!1,description:"Icon or adornment rendered inside the left edge."},{name:"rightElement",type:"ReactNode",required:!1,description:"Icon or adornment rendered inside the right edge."},{name:"placeholder",type:"string",required:!1,description:"Placeholder text. Use as a hint, not a label."},{name:"prefix",type:"ReactNode",required:!1,description:'Inset label attached to the left of the field (e.g. "$", "https://").'},{name:"suffix",type:"ReactNode",required:!1,description:'Inset label attached to the right of the field (e.g. "kg", ".com").'},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the input."},{name:"value",type:"string",required:!1,description:"Controlled value."},{name:"onChange",type:"function",required:!1,description:"Change handler."}],usageExamples:[{title:"Basic",code:'<Input label="Email" type="email" placeholder="you@example.com" />'},{title:"With helper text",code:'<Input label="Username" helperText="3–20 characters, letters and numbers only" />'},{title:"Error state",code:'<Input label="Password" type="password" value={value} errorText="Must be at least 8 characters" />'},{title:"With icon",code:'<Input label="Search" leftElement={<SearchIcon />} placeholder="Search…" />'}],compositionGraph:[],accessibility:{role:"textbox",ariaAttributes:["aria-invalid","aria-describedby","aria-label"],keyboardInteractions:["Tab — focuses the input"]}},ln={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},cn={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},dn={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},It=p.forwardRef(({label:t,helperText:n,errorText:r,autoResize:o=!1,maxLength:a,showCount:i=!1,size:s="md",id:l,value:c,onChange:d,disabled:u,style:h,...m},g)=>{const C=p.useRef(null),b=g??C,f=l??`lucent-textarea-${Math.random().toString(36).slice(2,7)}`,v=!!r,S=!!u,x=typeof c=="string"?c.length:0;p.useEffect(()=>{if(!o)return;const w=b.current;w&&(w.style.height="auto",w.style.height=`${w.scrollHeight}px`)},[c,o,b]);const I=S?"transparent":v?"var(--lucent-danger-default)":"var(--lucent-border-default)";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%"},children:[t&&e.jsx("label",{htmlFor:f,style:{fontSize:cn[s],fontWeight:"var(--lucent-font-weight-medium)",color:S?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:t}),e.jsx("textarea",{ref:b,id:f,maxLength:a,value:c,onChange:d,disabled:u,"aria-invalid":v,"aria-describedby":v?`${f}-error`:n?`${f}-helper`:void 0,style:{width:"100%",minHeight:"100px",padding:dn[s],fontSize:ln[s],fontFamily:"var(--lucent-font-family-base)",color:S?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:S?"var(--lucent-surface-secondary)":"var(--lucent-surface)",border:`1px solid ${I}`,borderRadius:"var(--lucent-radius-lg)",outline:"none",resize:o?"none":"vertical",boxSizing:"border-box",lineHeight:"var(--lucent-line-height-base)",cursor:S?"not-allowed":void 0,transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),...h},onMouseEnter:w=>{var z;!S&&w.currentTarget!==document.activeElement&&(w.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-strong)"),(z=m.onMouseEnter)==null||z.call(m,w)},onMouseLeave:w=>{var z;!S&&w.currentTarget!==document.activeElement&&(w.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-default)"),(z=m.onMouseLeave)==null||z.call(m,w)},onFocus:w=>{var z;S||(w.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-focus-ring)",w.currentTarget.style.boxShadow=`0 0 0 3px ${v?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`,(z=m.onFocus)==null||z.call(m,w))},onBlur:w=>{var z;S||(w.currentTarget.style.borderColor=v?"var(--lucent-danger-default)":"var(--lucent-border-default)",w.currentTarget.style.boxShadow="none",(z=m.onBlur)==null||z.call(m,w))},...m}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[v&&e.jsx("span",{id:`${f}-error`,role:"alert",style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:r}),!v&&n&&e.jsx("span",{id:`${f}-helper`,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:n})]}),(i||a)&&e.jsxs("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:a&&x>=a?"var(--lucent-danger-text)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-mono)",flexShrink:0,marginLeft:"var(--lucent-space-2)"},children:[x,a?`/${a}`:""]})]})]})});It.displayName="Textarea";const un={id:"textarea",name:"Textarea",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A multi-line text input with optional auto-resize and character count.",designIntent:"Use autoResize for open-ended fields (bio, description) where content length is unpredictable. Use maxLength + showCount for fields with hard limits (tweet-style). Behaves identically to Input for label/helper/error patterns.",props:[{name:"label",type:"string",required:!1,description:"Visible label above the textarea."},{name:"helperText",type:"string",required:!1,description:"Hint text shown below."},{name:"errorText",type:"string",required:!1,description:"Validation error. Triggers error styling."},{name:"autoResize",type:"boolean",required:!1,default:"false",description:"Grows with content, disables manual resize handle."},{name:"maxLength",type:"number",required:!1,description:"Character limit. Displays counter when set."},{name:"showCount",type:"boolean",required:!1,default:"false",description:"Always show character counter even without maxLength."},{name:"value",type:"string",required:!1,description:"Controlled value."},{name:"onChange",type:"function",required:!1,description:"Change handler."},{name:"placeholder",type:"string",required:!1,description:"Placeholder text."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls font size and padding.",enumValues:["sm","md","lg"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the textarea."}],usageExamples:[{title:"Basic",code:'<Textarea label="Bio" placeholder="Tell us about yourself…" />'},{title:"Auto-resize",code:'<Textarea label="Description" autoResize value={value} onChange={e => setValue(e.target.value)} />'},{title:"With character count",code:'<Textarea label="Tweet" maxLength={280} showCount value={value} onChange={e => setValue(e.target.value)} />'},{title:"Error state",code:'<Textarea label="Notes" errorText="Required" value="" />'}],compositionGraph:[],accessibility:{role:"textbox",ariaAttributes:["aria-multiline","aria-invalid","aria-describedby"],keyboardInteractions:["Tab — focuses the textarea"]}},pn={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)"},accent:{bg:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"var(--lucent-accent-default)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)"}},fn={sm:{fontSize:"var(--lucent-font-size-xs)",padding:"0 var(--lucent-space-2)",height:"18px"},md:{fontSize:"var(--lucent-font-size-sm)",padding:"0 var(--lucent-space-2)",height:"22px"}};function hn({variant:t="neutral",size:n="md",dot:r=!1,children:o,style:a}){const i=pn[t],s=fn[n];return e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",height:s.height,padding:s.padding,fontSize:s.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-full)",background:i.bg,color:i.color,border:`1px solid ${i.border}`,whiteSpace:"nowrap",boxSizing:"border-box",...a},children:[r&&e.jsx("span",{style:{width:6,height:6,borderRadius:"var(--lucent-radius-full)",background:"currentColor",flexShrink:0}}),o]})}const mn={id:"badge",name:"Badge",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A small inline label for status, count, or category.",designIntent:'Badges communicate status or category at a glance. Match variant to semantic meaning — never use "danger" for non-critical states or "success" for neutral counts. Use dot=true when a single colour indicator is enough context (e.g. online status). Keep badge text short: 1–3 words maximum.',props:[{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","success","warning","danger","info","accent"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height and font size.",enumValues:["sm","md"]},{name:"dot",type:"boolean",required:!1,default:"false",description:"Prepends a coloured dot indicator."},{name:"children",type:"ReactNode",required:!0,description:"Badge label."}],usageExamples:[{title:"Status",code:'<Badge variant="success" dot>Active</Badge>'},{title:"Count",code:'<Badge variant="danger">12</Badge>'},{title:"Category",code:'<Badge variant="info">Beta</Badge>'},{title:"Neutral tag",code:"<Badge>Draft</Badge>"}],compositionGraph:[],accessibility:{role:"status",notes:"Use aria-label on the parent element when badge meaning depends on context."}},gn={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)",hoverBg:"var(--lucent-surface-hover, #e5e7eb)",hoverBorder:"var(--lucent-border-strong)"},accent:{bg:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",border:"var(--lucent-accent-default)",hoverBg:"var(--lucent-accent-hover)",hoverBorder:"var(--lucent-accent-hover)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-success-default) 15%, var(--lucent-success-subtle))",hoverBorder:"var(--lucent-success-default)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-warning-default) 15%, var(--lucent-warning-subtle))",hoverBorder:"var(--lucent-warning-default)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-danger-default) 15%, var(--lucent-danger-subtle))",hoverBorder:"var(--lucent-danger-default)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)",hoverBg:"color-mix(in srgb, var(--lucent-info-default) 15%, var(--lucent-info-subtle))",hoverBorder:"var(--lucent-info-default)"}},vn={sm:{fontSize:"var(--lucent-font-size-xs)",height:"calc(var(--lucent-space-5) * 0.5 + 10px)",padding:"var(--lucent-space-1) var(--lucent-space-2)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-2)",iconSize:12,dotSize:6,gap:"var(--lucent-space-1)"},md:{fontSize:"var(--lucent-font-size-sm)",height:"calc(var(--lucent-space-6) * 0.5 + 12px)",padding:"var(--lucent-space-1) var(--lucent-space-2)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-1) var(--lucent-space-2)",iconSize:14,dotSize:7,gap:"var(--lucent-space-2)"},lg:{fontSize:"var(--lucent-font-size-md)",height:"calc(var(--lucent-space-8) * 0.5 + 14px)",padding:"var(--lucent-space-1) var(--lucent-space-3)",paddingDismiss:"var(--lucent-space-1) var(--lucent-space-2) var(--lucent-space-1) var(--lucent-space-3)",iconSize:16,dotSize:8,gap:"var(--lucent-space-2)"}};function Mt({children:t,variant:n="neutral",size:r="md",onDismiss:o,onClick:a,leftIcon:i,swatch:s,dot:l=!1,borderless:c=!1,disabled:d=!1,style:u}){const h=gn[n],m=vn[r],[g,C]=p.useState(!1),b=!d&&(o||a),f={display:"inline-flex",alignItems:"center",gap:m.gap,height:m.height,padding:o?m.paddingDismiss:m.padding,fontSize:m.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-lg)",background:g&&b?h.hoverBg:h.bg,color:h.color,border:c?"1px solid transparent":`1px solid ${g&&b?h.hoverBorder:h.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:d?.5:1,transform:g&&b?"translateY(-1px)":"none",boxShadow:g&&b?`0 2px 4px ${h.hoverBorder}22`:"none",transition:["transform var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)","border-color var(--lucent-duration-fast) var(--lucent-easing-default)","background var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),cursor:b?"pointer":"default",...a?{outline:"none"}:{},...u},v=e.jsxs(e.Fragment,{children:[s&&e.jsx("span",{style:{width:m.dotSize+2,height:m.dotSize+2,borderRadius:"50%",background:s,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),l&&!s&&e.jsx("span",{style:{width:m.dotSize,height:m.dotSize,borderRadius:"50%",background:"currentColor",flexShrink:0}}),i&&!s&&!l&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:m.iconSize,height:m.iconSize,flexShrink:0},children:i}),t,o&&e.jsx("button",{type:"button",onClick:d?void 0:x=>{x.stopPropagation(),o()},disabled:d,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:m.iconSize+2,height:m.iconSize+2,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:d?"not-allowed":"pointer",flexShrink:0,lineHeight:1},children:e.jsx("svg",{width:m.iconSize-2,height:m.iconSize-2,viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",children:e.jsx("path",{d:"M2 2L8 8M8 2L2 8"})})})]}),S={onMouseEnter:()=>{d||C(!0)},onMouseLeave:()=>C(!1)};return a?e.jsx("button",{type:"button",onClick:d?void 0:a,disabled:d,style:f,...S,children:v}):e.jsx("span",{style:f,...S,children:v})}const bn={id:"chip",name:"Chip",tier:"atom",domain:"neutral",specVersion:"1.0",description:"A compact label for filters, tags, statuses, and categories. Combines the roles of Badge and Tag into a single flexible component.",designIntent:"Chip is the universal label primitive — use it anywhere you need a compact visual marker. It replaces both Badge (static status) and Tag (dismissible filter) with a single component. Use `onDismiss` for removable chips (filters, multi-select values). Use `onClick` for clickable/selectable chips (filter toggles, category navigation). Use `dot` for status indicators (online/offline). Use `swatch` for color-coded categories. Use `leftIcon` for chips with leading icons (folders, file types, flags). Use `borderless` for a softer, filled-only appearance in dense UIs. Variant conveys semantic meaning — default to neutral for user-generated content.",props:[{name:"children",type:"ReactNode",required:!0,description:"Chip label content."},{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","accent","success","warning","danger","info"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height, font size, and icon size.",enumValues:["sm","md","lg"]},{name:"onDismiss",type:"function",required:!1,description:"Renders an x button that calls this handler. Use for removable filters and multi-select values."},{name:"onClick",type:"function",required:!1,description:"Makes the chip clickable (renders as <button>). Use for filter toggles and category links."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon or element rendered before the label (emoji, flag, avatar)."},{name:"swatch",type:"string",required:!1,description:"Hex color string. Renders a small color dot before the label."},{name:"dot",type:"boolean",required:!1,default:"false",description:"Renders a status dot using the variant colour. Use for online/offline indicators."},{name:"borderless",type:"boolean",required:!1,default:"false",description:"Removes the border for a filled-only look."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Dims the chip and prevents interaction."},{name:"style",type:"object",required:!1,description:"Inline style overrides."}],usageExamples:[{title:"Dismissible filter",code:"<Chip onDismiss={() => removeFilter('react')}>React</Chip>"},{title:"Status with dot",code:'<Chip variant="success" dot>Online</Chip>'},{title:"Color swatch",code:'<Chip swatch="#6366f1" onDismiss={() => {}}>Indigo</Chip>'},{title:"With icon",code:"<Chip leftIcon={<FolderIcon />} onDismiss={() => {}}>Documents</Chip>"},{title:"Clickable category",code:`<Chip variant="accent" onClick={() => navigate('/ux')}>UX</Chip>`},{title:"Borderless",code:'<Chip variant="warning" borderless>Pending</Chip>'},{title:"Static label",code:'<Chip variant="info">Beta</Chip>'}],compositionGraph:[],accessibility:{role:"group",notes:'When onClick is provided, renders as <button> with native button semantics. Dismiss button has aria-label="Dismiss" and stopPropagation to prevent parent click handlers.',keyboardInteractions:["Enter / Space — activates onClick or dismiss button when focused"]}},yn={xs:24,sm:32,md:40,lg:56,xl:80},xn={xs:"var(--lucent-font-size-xs)",sm:"var(--lucent-font-size-xs)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-lg)",xl:"var(--lucent-font-size-xl)"};function wn(t,n){var o,a,i;if(n)return n.slice(0,2).toUpperCase();const r=t.trim().split(/\s+/);return r.length===1?(((o=r[0])==null?void 0:o[0])??"").toUpperCase():((((a=r[0])==null?void 0:a[0])??"")+(((i=r[r.length-1])==null?void 0:i[0])??"")).toUpperCase()}function kn({src:t,alt:n,size:r="md",initials:o,style:a,...i}){const s=yn[r],l=wn(n,o),c={width:s,height:s,borderRadius:"var(--lucent-radius-full)",flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",overflow:"hidden",boxSizing:"border-box",userSelect:"none",...a};return t?e.jsx("img",{src:t,alt:n,width:s,height:s,style:{...c,objectFit:"cover"},...i}):e.jsx("span",{role:"img","aria-label":n,style:{...c,background:"var(--lucent-accent-default)",color:"var(--lucent-text-on-accent)",fontSize:xn[r],fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)"},children:l})}const Sn={id:"avatar",name:"Avatar",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A circular user image with initials fallback.",designIntent:"Always provide alt for accessibility — it is used to derive initials automatically when src is absent or fails. Use initials prop to override auto-derived initials (e.g. for non-Latin names). Size xs/sm suit table rows and compact lists; md is the default for comment threads; lg/xl for profile headers.",props:[{name:"src",type:"string",required:!1,description:"Image URL. Falls back to initials if omitted or fails to load."},{name:"alt",type:"string",required:!0,description:"Alt text and source for auto-derived initials."},{name:"size",type:"enum",required:!1,default:"md",description:"Diameter of the avatar.",enumValues:["xs","sm","md","lg","xl"]},{name:"initials",type:"string",required:!1,description:"Override auto-derived initials (max 2 characters)."}],usageExamples:[{title:"With image",code:'<Avatar src="/avatars/jane.jpg" alt="Jane Doe" />'},{title:"Initials fallback",code:'<Avatar alt="Jane Doe" />'},{title:"Large profile",code:'<Avatar src={user.avatar} alt={user.name} size="lg" />'},{title:"Custom initials",code:'<Avatar alt="张伟" initials="张" size="md" />'}],compositionGraph:[],accessibility:{role:"img",ariaAttributes:["aria-label"],notes:'When src is present, renders as <img> with alt. When showing initials, renders as <span role="img" aria-label>.'}},Tn={xs:12,sm:16,md:24,lg:36},Cn={xs:2.5,sm:2.5,md:2,lg:2};function Dt({size:t="md",label:n="Loading…",color:r}){const o=Tn[t],a=Cn[t];return e.jsxs("span",{role:"status","aria-label":n,style:{display:"inline-flex",alignItems:"center",justifyContent:"center"},children:[e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,style:{animation:"lucent-spin 0.7s linear infinite",color:r??"currentColor"},children:[e.jsx("style",{children:"@keyframes lucent-spin { to { transform: rotate(360deg); } }"}),e.jsx("circle",{cx:12,cy:12,r:10,stroke:"currentColor",strokeWidth:a,strokeOpacity:.2}),e.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round"})]}),e.jsx("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"},children:n})]})}const jn={id:"spinner",name:"Spinner",tier:"atom",domain:"neutral",specVersion:"0.1",description:"An animated loading indicator for async operations.",designIntent:"Use Spinner for indeterminate loading states of short duration (< 3s). For full-page or skeleton-level loading, prefer Skeleton instead. The label prop is visually hidden but read by screen readers — always set it to a meaningful description of what is loading.",props:[{name:"size",type:"enum",required:!1,default:"md",description:"Spinner diameter.",enumValues:["xs","sm","md","lg"]},{name:"label",type:"string",required:!1,default:"Loading…",description:"Visually hidden accessible label."},{name:"color",type:"string",required:!1,description:"Override colour (CSS value). Defaults to currentColor."}],usageExamples:[{title:"Default",code:"<Spinner />"},{title:"Inside button",code:'<Button loading><Spinner size="sm" label="Saving…" /></Button>'},{title:"Full-page overlay",code:`<div style={{ display: 'grid', placeItems: 'center', minHeight: '100vh' }}><Spinner size="lg" label="Loading dashboard…" /></div>`}],compositionGraph:[],accessibility:{role:"status",ariaAttributes:["aria-label"],notes:'The visible SVG is aria-hidden. The label is conveyed via a visually-hidden span inside role="status".'}};function In({orientation:t="horizontal",label:n,spacing:r="var(--lucent-space-4)",style:o}){return t==="vertical"?e.jsx("span",{role:"separator","aria-orientation":"vertical",style:{display:"inline-block",width:"1px",alignSelf:"stretch",background:"var(--lucent-border-default)",margin:`0 ${r}`,flexShrink:0,...o}}):n?e.jsxs("div",{role:"separator","aria-label":n,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",margin:`${r} 0`,...o},children:[e.jsx("span",{style:{flex:1,height:"1px",background:"var(--lucent-border-default)"}}),e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)",whiteSpace:"nowrap",letterSpacing:"var(--lucent-letter-spacing-wide)",textTransform:"uppercase"},children:n}),e.jsx("span",{style:{flex:1,height:"1px",background:"var(--lucent-border-default)"}})]}):e.jsx("hr",{role:"separator",style:{border:"none",borderTop:"1px solid var(--lucent-border-default)",margin:`${r} 0`,width:"100%",...o}})}const Mn={id:"divider",name:"Divider",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A visual separator between content sections, horizontal or vertical.",designIntent:'Use horizontal Divider to separate sections in a layout. Use vertical Divider inline between sibling elements (e.g. nav links, toolbar buttons). Use the label prop for "OR" separators in auth flows or form sections — never use a plain text node next to a divider for this.',props:[{name:"orientation",type:"enum",required:!1,default:"horizontal",description:"Direction of the divider line.",enumValues:["horizontal","vertical"]},{name:"label",type:"string",required:!1,description:'Optional centered label (horizontal only). Common use: "OR", "AND", section titles.'},{name:"spacing",type:"string",required:!1,default:"var(--lucent-space-4)",description:"Margin on the axis perpendicular to the line."}],usageExamples:[{title:"Section separator",code:"<Divider />"},{title:"With label",code:'<Divider label="OR" />'},{title:"Vertical in nav",code:`<nav style={{ display: 'flex', alignItems: 'center' }}><a>Home</a><Divider orientation="vertical" /><a>About</a></nav>`}],compositionGraph:[],accessibility:{role:"separator",ariaAttributes:["aria-orientation","aria-label"]}},Dn={sm:14,md:16,lg:20},zn={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},En=`
|
|
2
2
|
@keyframes lucent-cb-pop {
|
|
3
3
|
0% { transform: scale(1); }
|
|
4
4
|
35% { transform: scale(0.82); }
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
60% { transform: scale(1.15) rotate(2deg); }
|
|
11
11
|
100% { opacity: 1; transform: scale(1) rotate(0deg); }
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
`,$e=p.forwardRef(({label:t,size:n="md",indeterminate:r=!1,contained:o=!1,helperText:a,checked:i,defaultChecked:s,disabled:l,id:c,onChange:d,style:u,...h},m)=>{const g=p.useRef(null),C=c??`lucent-checkbox-${Math.random().toString(36).slice(2,7)}`,b=Dn[n],f=i!==void 0,[v,S]=p.useState(s??!1),[x,I]=p.useState(!1),w=f?!!i:v,z=p.useRef(w),[q,T]=p.useState(0);p.useEffect(()=>{!l&&z.current!==w&&(z.current=w,T(L=>L+1))},[w,l]);const M=p.useCallback(L=>{g.current=L,typeof m=="function"?m(L):m&&(m.current=L)},[m]);p.useEffect(()=>{g.current&&(g.current.indeterminate=r)},[r]);const F=L=>{f||S(L.target.checked),d==null||d(L)},N=l?"var(--lucent-text-disabled)":"var(--lucent-text-on-accent)",j={width:b,height:b,borderRadius:"4px",border:`1.5px solid ${l?"transparent":w||r?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:l?"var(--lucent-surface-secondary)":w||r?"var(--lucent-accent-default)":"var(--lucent-surface)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default)",animation:q>0?"lucent-cb-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0},B=e.jsxs("label",{style:{display:"inline-flex",alignItems:a?"flex-start":"center",gap:"var(--lucent-space-2)",cursor:l?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:n==="sm"?"var(--lucent-font-size-sm)":"var(--lucent-font-size-md)",color:l?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",userSelect:"none",...o?{}:u},children:[e.jsx("input",{ref:M,type:"checkbox",id:C,checked:f?i:v,disabled:l,onChange:F,style:{position:"absolute",opacity:0,width:0,height:0,margin:0,pointerEvents:"none"},...h}),e.jsxs("span",{"aria-hidden":!0,style:j,children:[w&&!r&&e.jsx("svg",{width:b-4,height:b-4,viewBox:"0 0 10 10",fill:"none",style:{animation:"lucent-cb-mark 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards"},children:e.jsx("path",{d:"M1.5 5L4 7.5L8.5 2.5",stroke:N,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),r&&e.jsx("svg",{width:b-4,height:b-4,viewBox:"0 0 10 10",fill:"none",style:{animation:"lucent-cb-mark 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards"},children:e.jsx("path",{d:"M2 5H8",stroke:N,strokeWidth:1.5,strokeLinecap:"round"})})]},q),(t||a)&&e.jsxs("span",{style:{display:"flex",flexDirection:"column"},children:[t&&e.jsx("span",{style:{fontWeight:a?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",lineHeight:a?1.4:1},children:t}),a&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:l?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",marginTop:"2px"},children:a})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:En}),o?e.jsx("div",{onMouseEnter:()=>{l||I(!0)},onMouseLeave:()=>I(!1),style:{border:`1px solid ${w&&!l?"var(--lucent-accent-default)":x&&!l?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,borderRadius:"var(--lucent-radius-lg)",...a?{}:{minHeight:zn[n]},padding:a?"var(--lucent-space-3)":"0 var(--lucent-space-3)",display:"flex",alignItems:a?"flex-start":"center",background:w&&!l?"var(--lucent-accent-subtle)":"var(--lucent-surface)",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:l?"not-allowed":"pointer",...u},onClick:L=>{var P;l||L.target===L.currentTarget&&((P=g.current)==null||P.click())},children:B}):B]})});$e.displayName="Checkbox";const An={id:"checkbox",name:"Checkbox",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A binary selection control for boolean values or multi-select lists.",designIntent:'Checkboxes represent independent boolean choices — they do not affect each other. Use a Checkbox for settings that take effect immediately (e.g. "Remember me") or for selecting multiple items from a list. When only one option may be active at a time, use Radio instead. The indeterminate state communicates a "select all" parent whose children are partially checked — never use it for a third logical state. Use the contained variant when you want to add visual emphasis to individual options — for example, plan selection cards, feature toggles, or consent checkboxes. Contained is especially useful when checkboxes are standalone or unrelated to each other, since the border gives each option its own visual weight. Pair with helperText to provide additional context without cluttering the label.',props:[{name:"checked",type:"boolean",required:!1,description:"Controlled checked state. Pair with onChange for controlled usage."},{name:"defaultChecked",type:"boolean",required:!1,default:"false",description:"Initial checked state for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called when the checked state changes."},{name:"label",type:"string",required:!1,description:"Visible label rendered beside the checkbox."},{name:"indeterminate",type:"boolean",required:!1,default:"false",description:"Displays a dash to indicate a partially-checked parent state."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and dims the control."},{name:"size",type:"enum",required:!1,default:"md",description:"Size of the checkbox box and label text.",enumValues:["sm","md","lg"]},{name:"contained",type:"boolean",required:!1,default:"false",description:"Wraps the checkbox in a bordered container. Use for standalone choices that need visual emphasis — plan cards, feature toggles, consent items. The border highlights with the accent colour when checked."},{name:"helperText",type:"string",required:!1,description:"Secondary text below the label for additional context. The label becomes medium-weight for visual hierarchy."}],usageExamples:[{title:"Controlled",code:'<Checkbox checked={agreed} onChange={e => setAgreed(e.target.checked)} label="I agree to the terms" />'},{title:"Uncontrolled",code:'<Checkbox defaultChecked label="Send me updates" />'},{title:"Indeterminate",code:'<Checkbox indeterminate label="Select all" />'},{title:"Disabled",code:'<Checkbox disabled label="Unavailable option" />'},{title:"Contained with helper",code:'<Checkbox contained label="Pro plan" helperText="Unlimited projects, 100 GB storage" />'},{title:"Contained standalone",code:'<Checkbox contained label="I accept the terms and conditions" />'}],compositionGraph:[],accessibility:{role:"checkbox",ariaAttributes:["aria-checked","aria-disabled"],keyboardInteractions:["Space — toggles checked state"]}},Rn=`
|
|
14
14
|
@keyframes lucent-radio-pop {
|
|
15
15
|
0% { transform: scale(1); }
|
|
16
16
|
35% { transform: scale(0.82); }
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
60% { transform: scale(1.2); }
|
|
23
23
|
100% { opacity: 1; transform: scale(1); }
|
|
24
24
|
}
|
|
25
|
-
`,
|
|
25
|
+
`,zt=p.createContext(null);function Et({name:t,value:n,onChange:r,disabled:o,orientation:a="vertical",label:i,children:s}){return e.jsx(zt.Provider,{value:{name:t,value:n,onChange:r,disabled:o??!1},children:e.jsx("div",{role:"radiogroup","aria-label":i,style:{display:"flex",flexDirection:a==="vertical"?"column":"row",gap:a==="vertical"?"var(--lucent-space-3)":"var(--lucent-space-4)",flexWrap:"wrap"},children:s})})}const qn={sm:14,md:16,lg:20},Bn={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},Ln={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"};function Pn({value:t,label:n,size:r="md",contained:o=!1,helperText:a,disabled:i,id:s,onChange:l,checked:c,style:d,...u}){const h=p.useContext(zt),m=s??`lucent-radio-${Math.random().toString(36).slice(2,7)}`,g=qn[r],[C,b]=p.useState(!1),f=i??(h==null?void 0:h.disabled)??!1,v=h?h.value===t:!!c,S=p.useRef(v),[x,I]=p.useState(0);p.useEffect(()=>{!f&&S.current!==v&&(S.current=v,I(M=>M+1))},[v,f]);const w=M=>{h==null||h.onChange(t),l==null||l(M)},z={width:g/2,height:g/2,borderRadius:"50%",background:f?"var(--lucent-text-disabled)":"var(--lucent-text-on-accent)",animation:v?"lucent-radio-dot 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0,opacity:v?1:0},q={width:g,height:g,borderRadius:"50%",border:`1.5px solid ${f?"transparent":v?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:f?"var(--lucent-surface-secondary)":v?"var(--lucent-accent-default)":"var(--lucent-surface)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default)",animation:x>0?"lucent-radio-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0},T=e.jsxs("label",{style:{display:"inline-flex",alignItems:a?"flex-start":"center",gap:"var(--lucent-space-2)",cursor:f?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:Ln[r],color:f?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",userSelect:"none",...o?{}:d},children:[e.jsx("input",{type:"radio",id:m,value:t,name:(h==null?void 0:h.name)??u.name,checked:v,disabled:f,onChange:w,style:{position:"absolute",opacity:0,width:0,height:0,margin:0,pointerEvents:"none"},...u}),e.jsx("span",{"aria-hidden":!0,style:q,children:e.jsx("span",{style:z})},x),n||a?e.jsxs("span",{style:{display:"flex",flexDirection:"column"},children:[n&&e.jsx("span",{style:{fontWeight:a?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",lineHeight:a?1.3:1},children:n}),a&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:f?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",marginTop:"2px"},children:a})]}):null]});return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Rn}),o?e.jsx("div",{onMouseEnter:()=>{f||b(!0)},onMouseLeave:()=>b(!1),style:{border:`1px solid ${v&&!f?"var(--lucent-accent-default)":C&&!f?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,borderRadius:"var(--lucent-radius-lg)",...a?{padding:"var(--lucent-space-3)"}:{minHeight:Bn[r],padding:"0 var(--lucent-space-3)",display:"flex",alignItems:"center"},background:v&&!f?"var(--lucent-accent-subtle)":"var(--lucent-surface)",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:f?"not-allowed":"pointer",...d},onClick:M=>{if(!f&&M.target===M.currentTarget){const F=M.currentTarget.querySelector("input");F==null||F.click()}},children:T}):T]})}function Fn({defaultValue:t="",onChange:n,...r}){const[o,a]=p.useState(t);return e.jsx(Et,{...r,value:o,onChange:i=>{a(i),n==null||n(i)}})}const Nn={id:"radio",name:"Radio",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A mutually exclusive selection control. Use RadioGroup to manage a set of options.",designIntent:"Radio buttons enforce a single selection from a small set of options (typically 2–6). Always wrap Radio in a RadioGroup so name and selection state are shared automatically. For larger option sets (7+) prefer a Select. For independent true/false choices, use a Checkbox. RadioGroup orientation should match how the options relate — vertical for distinct choices, horizontal for brief inline options (e.g. Yes / No).",props:[{name:"value",type:"string",required:!0,description:"The value submitted when this radio is selected."},{name:"label",type:"string",required:!1,description:"Visible label rendered beside the radio button."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction. Inherits group-level disabled when inside RadioGroup."},{name:"size",type:"enum",required:!1,default:"md",description:"Size of the radio button circle and label text.",enumValues:["sm","md","lg"]},{name:"contained",type:"boolean",required:!1,default:"false",description:"Wraps the radio in a bordered container. Highlights with accent border and subtle background when selected. Use for plan/option cards where each choice needs visual emphasis."},{name:"helperText",type:"string",required:!1,description:"Secondary text below the label for additional context. Label becomes medium-weight for visual hierarchy."}],usageExamples:[{title:"Controlled RadioGroup",code:`
|
|
26
26
|
<RadioGroup name="plan" value={plan} onChange={setPlan}>
|
|
27
27
|
<Radio value="free" label="Free" />
|
|
28
28
|
<Radio value="pro" label="Pro" />
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
<RadioGroup name="tier" value="basic" onChange={() => {}} disabled>
|
|
41
41
|
<Radio value="basic" label="Basic" />
|
|
42
42
|
<Radio value="advanced" label="Advanced" />
|
|
43
|
-
</RadioGroup>`.trim()}],compositionGraph:[{componentId:"radio-group",componentName:"RadioGroup",role:"container",required:!0},{componentId:"radio",componentName:"Radio",role:"item",required:!0}],accessibility:{role:"radio",ariaAttributes:["aria-checked","aria-disabled"],keyboardInteractions:["Arrow keys — move selection within the group","Space — selects the focused radio"]}}
|
|
43
|
+
</RadioGroup>`.trim()}],compositionGraph:[{componentId:"radio-group",componentName:"RadioGroup",role:"container",required:!0},{componentId:"radio",componentName:"Radio",role:"item",required:!0}],accessibility:{role:"radio",ariaAttributes:["aria-checked","aria-disabled"],keyboardInteractions:["Arrow keys — move selection within the group","Space — selects the focused radio"]}},$n={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},Wn={sm:{track:[28,16],thumb:12},md:{track:[36,20],thumb:16},lg:{track:[44,24],thumb:20}},dt="cubic-bezier(0.34, 1.56, 0.64, 1)",On=`
|
|
44
44
|
@keyframes lucent-toggle-pop {
|
|
45
45
|
0% { transform: scale(1); }
|
|
46
46
|
35% { transform: scale(0.94); }
|
|
47
47
|
70% { transform: scale(1.06); }
|
|
48
48
|
100% { transform: scale(1); }
|
|
49
49
|
}
|
|
50
|
-
`;function
|
|
50
|
+
`;function Hn({label:t,size:n="md",checked:r,defaultChecked:o,contained:a=!1,helperText:i,align:s="left",disabled:l,id:c,onChange:d,style:u,...h}){const m=c??`lucent-toggle-${Math.random().toString(36).slice(2,7)}`,g=r!==void 0,[C,b]=p.useState(o??!1),f=g?!!r:C,[v,S]=p.useState(!1),x=p.useRef(f),[I,w]=p.useState(0),[z,q]=p.useState(!1);p.useEffect(()=>{if(!l&&x.current!==f){x.current=f,w($=>$+1),q(!0);const P=setTimeout(()=>q(!1),150);return()=>clearTimeout(P)}},[f,l]);const{track:[T,M],thumb:F}=Wn[n],N=f?T-F-2:2,j=P=>{g||b(P.target.checked),d==null||d(P)},B=e.jsxs("span",{"aria-hidden":!0,style:{position:"relative",width:T,height:M,borderRadius:M/2,flexShrink:0},children:[e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"inherit",background:l?"var(--lucent-surface-secondary)":f?"var(--lucent-accent-default)":"var(--lucent-control-track)",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)",animation:I>0?`lucent-toggle-pop 240ms ${dt} forwards`:void 0}},I),e.jsx("span",{style:{position:"absolute",top:2,left:N,width:z?F*1.3:F,height:F,borderRadius:F,background:"#ffffff",boxShadow:"0 1px 3px rgb(0 0 0 / 0.2)",transition:`left 260ms ${dt}, width 200ms cubic-bezier(0.22, 1, 0.36, 1)`}})]}),L=e.jsxs("label",{style:{display:s==="right"?"flex":"inline-flex",alignItems:i?"flex-start":"center",gap:"var(--lucent-space-2)",...s==="right"?{width:"100%"}:{},cursor:l?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:n==="sm"?"var(--lucent-font-size-sm)":"var(--lucent-font-size-md)",color:l?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",userSelect:"none",...a?{}:u},children:[e.jsx("input",{type:"checkbox",role:"switch",id:m,checked:g?r:C,disabled:l,onChange:j,"aria-checked":f,style:{position:"absolute",opacity:0,width:0,height:0,margin:0,pointerEvents:"none"},...h}),s==="left"&&B,t||i?e.jsxs("span",{style:{display:"flex",flexDirection:"column",flex:s==="right"?1:void 0},children:[t&&e.jsx("span",{style:{fontWeight:i?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",lineHeight:i?1.3:1},children:t}),i&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:l?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",marginTop:"2px"},children:i})]}):null,s==="right"&&B]});return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:On}),a?e.jsx("div",{onMouseEnter:()=>{l||S(!0)},onMouseLeave:()=>S(!1),style:{border:`1px solid ${f&&!l?"var(--lucent-accent-default)":v&&!l?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,borderRadius:"var(--lucent-radius-lg)",...i?{padding:"var(--lucent-space-3)"}:{minHeight:$n[n],padding:"0 var(--lucent-space-3)",display:"flex",alignItems:"center"},background:f&&!l?"var(--lucent-accent-subtle)":"var(--lucent-surface)",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:l?"not-allowed":"pointer",...u},onClick:P=>{if(!l&&P.target===P.currentTarget){const $=P.currentTarget.querySelector("input");$==null||$.click()}},children:L}):L]})}const Vn={id:"toggle",name:"Toggle",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A sliding switch for immediately-applied binary settings.",designIntent:'Toggles are for settings that take effect the moment they are flipped — no Save button needed. If the action requires a confirmation step or only applies on form submit, use a Checkbox instead. The "on" state is visually represented by the accent colour so the meaning is clear without relying on text alone. Keep the label short (2–4 words) and phrase it as the enabled state (e.g. "Dark mode", not "Enable dark mode").',props:[{name:"checked",type:"boolean",required:!1,description:"Controlled on/off state. Pair with onChange for controlled usage."},{name:"defaultChecked",type:"boolean",required:!1,default:"false",description:"Initial state for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called when the toggle is flipped."},{name:"label",type:"string",required:!1,description:"Visible label rendered beside the toggle."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls the track and thumb size.",enumValues:["sm","md","lg"]},{name:"contained",type:"boolean",required:!1,default:"false",description:"Wraps the toggle in a bordered container. Highlights with accent border and subtle background when checked."},{name:"helperText",type:"string",required:!1,description:"Secondary text below the label for additional context. Label becomes medium-weight for visual hierarchy."},{name:"align",type:"enum",required:!1,default:"left",description:'Position of the toggle track relative to the label. Use "right" to push the track to the far end of the container.',enumValues:["left","right"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and dims the control."}],usageExamples:[{title:"Controlled",code:'<Toggle checked={darkMode} onChange={e => setDarkMode(e.target.checked)} label="Dark mode" />'},{title:"Uncontrolled",code:'<Toggle defaultChecked label="Email notifications" />'},{title:"Sizes",code:`<Toggle size="sm" label="Compact" />
|
|
51
51
|
<Toggle size="md" label="Default" />
|
|
52
|
-
<Toggle size="lg" label="Large" />`},{title:"Contained with helper",code:'<Toggle contained label="Dark mode" helperText="Use dark colour scheme across the app" />'},{title:"Right-aligned",code:'<Toggle align="right" contained label="Notifications" helperText="Receive email alerts" />'},{title:"Disabled",code:'<Toggle disabled label="Unavailable setting" />'}],compositionGraph:[],accessibility:{role:"switch",ariaAttributes:["aria-checked","aria-disabled"],keyboardInteractions:["Space — toggles the switch state"]}},
|
|
52
|
+
<Toggle size="lg" label="Large" />`},{title:"Contained with helper",code:'<Toggle contained label="Dark mode" helperText="Use dark colour scheme across the app" />'},{title:"Right-aligned",code:'<Toggle align="right" contained label="Notifications" helperText="Receive email alerts" />'},{title:"Disabled",code:'<Toggle disabled label="Unavailable setting" />'}],compositionGraph:[],accessibility:{role:"switch",ariaAttributes:["aria-checked","aria-disabled"],keyboardInteractions:["Space — toggles the switch state"]}},Un={sm:"calc(var(--lucent-space-8) * 0.5 + 16px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px)"},Gn={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},Ie={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},ut={sm:"var(--lucent-space-2)",md:"var(--lucent-space-3)",lg:"var(--lucent-space-3)"},We=p.forwardRef(({options:t,size:n="md",label:r,helperText:o,errorText:a,placeholder:i,disabled:s,id:l,style:c,...d},u)=>{const h=l??`lucent-select-${Math.random().toString(36).slice(2,7)}`,m=!!a,g=!!s,[C,b]=p.useState(!1),[f,v]=p.useState(!1),S=g?"transparent":m?"var(--lucent-danger-default)":C?"var(--lucent-focus-ring)":f?"var(--lucent-border-strong)":"var(--lucent-border-default)",x=C?`0 0 0 3px ${m?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%",...c},children:[r&&e.jsx("label",{htmlFor:h,style:{fontSize:Ie[n],fontWeight:"var(--lucent-font-weight-medium)",color:g?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:r}),e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",height:Un[n],border:`1px solid ${S}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:x,background:g?"var(--lucent-surface-secondary)":"var(--lucent-surface)",cursor:g?"not-allowed":"pointer",transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},onMouseEnter:()=>{g||v(!0)},onMouseLeave:()=>v(!1),children:[e.jsxs("select",{ref:u,id:h,disabled:s,"aria-invalid":m,"aria-describedby":m?`${h}-error`:o?`${h}-helper`:void 0,style:{width:"100%",height:"100%",padding:`0 var(--lucent-space-8) 0 ${ut[n]}`,fontSize:Gn[n],fontFamily:"var(--lucent-font-family-base)",color:g?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:"transparent",border:"none",borderRadius:"var(--lucent-radius-lg)",outline:"none",appearance:"none",cursor:g?"not-allowed":"pointer",boxSizing:"border-box"},onFocus:I=>{var w;g||b(!0),(w=d.onFocus)==null||w.call(d,I)},onBlur:I=>{var w;b(!1),(w=d.onBlur)==null||w.call(d,I)},onMouseDown:()=>{g||b(!0)},...d,children:[i&&e.jsx("option",{value:"",disabled:!0,children:i}),t.map(I=>e.jsx("option",{value:I.value,disabled:I.disabled,children:I.label},I.value))]}),e.jsx("span",{"aria-hidden":!0,style:{position:"absolute",right:ut[n],pointerEvents:"none",color:g?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",display:"flex",alignItems:"center"},children:e.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),m&&e.jsx("span",{id:`${h}-error`,role:"alert",style:{fontSize:Ie[n],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:a}),!m&&o&&e.jsx("span",{id:`${h}-helper`,style:{fontSize:Ie[n],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:o})]})});We.displayName="Select";const _n={id:"select",name:"Select",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A dropdown for choosing one option from a list.",designIntent:"Select is best for 5–15 options where showing all at once would be too noisy. For fewer than 5 options, prefer RadioGroup (always-visible, faster to scan). For search-filtered or async options, a Combobox (Wave 3) is more appropriate. Always provide a placeholder when no default is sensible — this communicates the field is required and prevents silent zero-state submissions.",props:[{name:"options",type:"array",required:!0,description:"Array of { value, label, disabled? } option objects."},{name:"value",type:"string",required:!1,description:"Controlled selected value. Pair with onChange."},{name:"onChange",type:"function",required:!1,description:"Called when the selected value changes."},{name:"placeholder",type:"string",required:!1,description:"Disabled first option shown when no value is selected."},{name:"label",type:"string",required:!1,description:"Visible label rendered above the select."},{name:"helperText",type:"string",required:!1,description:"Supplementary hint shown below the select."},{name:"errorText",type:"string",required:!1,description:"Validation error message. Replaces helperText and applies error styling."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls the height of the select control.",enumValues:["sm","md","lg"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction."}],usageExamples:[{title:"Controlled",code:`
|
|
53
53
|
<Select
|
|
54
54
|
label="Country"
|
|
55
55
|
placeholder="Choose a country"
|
|
56
56
|
options={countries}
|
|
57
57
|
value={country}
|
|
58
58
|
onChange={e => setCountry(e.target.value)}
|
|
59
|
-
/>`.trim()},{title:"With validation error",code:'<Select label="Role" options={roles} errorText="Please select a role" />'},{title:"With helper text",code:'<Select label="Timezone" options={timezones} helperText="Used for scheduling notifications" />'}],compositionGraph:[],accessibility:{role:"combobox",ariaAttributes:["aria-invalid","aria-describedby"],keyboardInteractions:["Enter / Space — opens the option list","Arrow keys — navigate options","Escape — closes the list"]}},Vn={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)",dismissHover:"var(--lucent-border-strong)"},accent:{bg:"var(--lucent-accent-subtle)",color:"var(--lucent-accent-active)",border:"var(--lucent-accent-subtle)",dismissHover:"var(--lucent-accent-default)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)",dismissHover:"var(--lucent-success-default)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)",dismissHover:"var(--lucent-warning-default)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)",dismissHover:"var(--lucent-danger-default)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)",dismissHover:"var(--lucent-info-default)"}},Un={sm:{fontSize:"var(--lucent-font-size-xs)",height:"20px",padding:"0 var(--lucent-space-3)",iconSize:10,gap:"var(--lucent-space-1)"},md:{fontSize:"var(--lucent-font-size-sm)",height:"24px",padding:"0 var(--lucent-space-3)",iconSize:12,gap:"var(--lucent-space-1)"},lg:{fontSize:"var(--lucent-font-size-md)",height:"28px",padding:"0 var(--lucent-space-4)",iconSize:14,gap:"var(--lucent-space-2)"}};function Gn({children:e,variant:n="neutral",size:r="md",onDismiss:o,disabled:a}){const s=Vn[n],i=Un[r],[l,c]=p.useState(!1),d=!a&&o;return t.jsxs("span",{onMouseEnter:()=>{a||c(!0)},onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:i.gap,height:i.height,padding:o?`0 var(--lucent-space-2) 0 ${i.padding.split(" ")[1]}`:i.padding,fontSize:i.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-lg)",background:s.bg,color:s.color,border:`1px solid ${l&&!a?s.dismissHover:s.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:a?.5:1,transform:l&&d?"translateY(-1px)":"none",boxShadow:l&&d?`0 2px 4px ${s.dismissHover}22`:"none",transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:d?"pointer":"default"},children:[e,o&&t.jsx("button",{type:"button",onClick:a?void 0:u=>{u.stopPropagation(),o==null||o()},disabled:a,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i.iconSize+4,height:i.iconSize+4,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:a?"not-allowed":"pointer",flexShrink:0,lineHeight:1},onMouseEnter:u=>{a||(u.currentTarget.style.background=s.dismissHover+"33")},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:t.jsx("svg",{width:i.iconSize,height:i.iconSize,viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",children:t.jsx("path",{d:"M2 2L8 8M8 2L2 8"})})})]})}const _n={id:"tag",name:"Tag",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A dismissible label for applied filters, selected values, or categorisation.",designIntent:"Tags represent user-applied selections that can be removed — filters, multi-select values, categories. They differ from Badge in that they are interactive: provide onDismiss when the user should be able to remove the tag. Without onDismiss they render as a static pill (identical to Badge in purpose). Use semantic variants to match meaning; default to neutral for user-generated content where no semantic applies.",props:[{name:"children",type:"ReactNode",required:!0,description:"Tag label content."},{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","accent","success","warning","danger","info"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height and font size.",enumValues:["sm","md","lg"]},{name:"onDismiss",type:"function",required:!1,description:"When provided, renders an × button that calls this handler on click."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Dims the tag and prevents the dismiss action."}],usageExamples:[{title:"Dismissible filter",code:"<Tag onDismiss={() => removeFilter('react')}>React</Tag>"},{title:"Multi-select value",code:'<Tag variant="accent" onDismiss={() => deselect(id)}>Jane Doe</Tag>'},{title:"Static category",code:'<Tag variant="info">Beta</Tag>'},{title:"Danger (removable)",code:'<Tag variant="danger" onDismiss={handleRemove}>Blocked</Tag>'}],compositionGraph:[],accessibility:{role:"group",notes:'The dismiss button has aria-label="Dismiss" and is keyboard-focusable.',keyboardInteractions:["Enter / Space — activates the dismiss button when focused"]}},_=5,Yn={top:{bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:_+3},bottom:{top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:_+3},left:{right:"100%",top:"50%",transform:"translateY(-50%)",marginRight:_+3},right:{left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:_+3}},Kn={top:{bottom:-_,left:"50%",transform:"translateX(-50%)",borderWidth:`${_}px ${_}px 0 ${_}px`,borderColor:"var(--lucent-text-primary) transparent transparent transparent"},bottom:{top:-_,left:"50%",transform:"translateX(-50%)",borderWidth:`0 ${_}px ${_}px ${_}px`,borderColor:"transparent transparent var(--lucent-text-primary) transparent"},left:{right:-_,top:"50%",transform:"translateY(-50%)",borderWidth:`${_}px 0 ${_}px ${_}px`,borderColor:"transparent transparent transparent var(--lucent-text-primary)"},right:{left:-_,top:"50%",transform:"translateY(-50%)",borderWidth:`${_}px ${_}px ${_}px 0`,borderColor:"transparent var(--lucent-text-primary) transparent transparent"}};function Xn({content:e,children:n,placement:r="top",delay:o=300}){const[a,s]=p.useState(!1),i=p.useRef(null),l=()=>{i.current=setTimeout(()=>s(!0),o)},c=()=>{i.current&&clearTimeout(i.current),s(!1)};return e?t.jsxs("span",{style:{position:"relative",display:"inline-flex"},onMouseEnter:l,onMouseLeave:c,onFocus:l,onBlur:c,children:[n,a&&t.jsxs("span",{role:"tooltip",style:{position:"absolute",...Yn[r],background:"var(--lucent-text-primary)",color:"var(--lucent-bg-base)",padding:"5px 10px",borderRadius:"var(--lucent-radius-md)",fontSize:"var(--lucent-font-size-xs)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:"var(--lucent-line-height-base)",whiteSpace:"nowrap",zIndex:9999,pointerEvents:"none",boxShadow:"var(--lucent-shadow-md)"},children:[e,t.jsx("span",{"aria-hidden":!0,style:{position:"absolute",width:0,height:0,borderStyle:"solid",...Kn[r]}})]})]}):t.jsx(t.Fragment,{children:n})}const Jn={id:"tooltip",name:"Tooltip",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A transient label that appears on hover or focus to explain an element.",designIntent:'Tooltips surface supplementary context that would clutter the UI if shown permanently — keyboard shortcut hints, icon button labels, truncated text expansions. They must never contain critical information (errors, required actions) because they are invisible until hovered. Keep content to one short phrase; avoid wrapping. Use placement to avoid viewport edges — "top" is the default and works in most cases.',props:[{name:"content",type:"ReactNode",required:!0,description:"Text or element shown inside the tooltip. Keep it short (under 80 chars)."},{name:"children",type:"ReactNode",required:!0,description:"The element that triggers the tooltip on hover/focus."},{name:"placement",type:"enum",required:!1,default:"top",description:"Position of the tooltip relative to the trigger.",enumValues:["top","bottom","left","right"]},{name:"delay",type:"number",required:!1,default:"300",description:"Milliseconds before the tooltip appears. Prevents flicker on fast cursor movement."}],usageExamples:[{title:"Icon button label",code:'<Tooltip content="Copy to clipboard"><IconButton icon={<CopyIcon />} /></Tooltip>'},{title:"Keyboard shortcut hint",code:'<Tooltip content="⌘K"><Button variant="ghost">Search</Button></Tooltip>'},{title:"Bottom placement",code:'<Tooltip content="Opens in a new tab" placement="bottom"><a href="…">Link</a></Tooltip>'},{title:"No delay (instant)",code:'<Tooltip content="Delete" delay={0}><Button variant="ghost">🗑</Button></Tooltip>'}],compositionGraph:[],accessibility:{role:"tooltip",ariaAttributes:['role="tooltip"'],notes:'The tooltip is shown on both hover and focus, making it accessible to keyboard users. Content is exposed via role="tooltip".'}},Zn={xs:12,sm:14,md:16,lg:20,xl:24};function Qn({children:e,size:n="md",label:r,color:o,style:a}){const s=Zn[n];return t.jsx("span",{role:r?"img":void 0,"aria-label":r,"aria-hidden":r?void 0:!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:s,height:s,flexShrink:0,color:o??"currentColor",...a},children:e})}const ea={id:"icon",name:"Icon",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A sized, accessible wrapper for any SVG or icon-set component.",designIntent:"Icon is intentionally icon-set agnostic — pass any SVG or third-party icon as children and it handles sizing and accessibility automatically. Use label for standalone icons that convey meaning without adjacent text (e.g. a close button). Omit label for decorative icons next to text, where the text already provides context. colour inherits from the parent by default via currentColor — override only when the icon must differ from its surrounding text.",props:[{name:"children",type:"ReactNode",required:!0,description:"The icon to render — any SVG element or icon-set component."},{name:"size",type:"enum",required:!1,default:"md",description:"Constrains the icon to a fixed square (xs=12, sm=14, md=16, lg=20, xl=24).",enumValues:["xs","sm","md","lg","xl"]},{name:"label",type:"string",required:!1,description:"Accessible label (aria-label). Provide for meaningful standalone icons; omit for decorative ones."},{name:"color",type:"string",required:!1,description:"CSS colour value. Defaults to currentColor (inherits from parent)."}],usageExamples:[{title:"Decorative (next to text)",code:'<Icon size="md"><SearchIcon /></Icon>'},{title:"Meaningful (standalone)",code:'<Icon size="lg" label="Close dialog"><XIcon /></Icon>'},{title:"Coloured",code:'<Icon color="var(--lucent-danger-default)"><AlertIcon /></Icon>'},{title:"Inside a button",code:'<Button leftIcon={<Icon size="sm"><PlusIcon /></Icon>}>Add item</Button>'}],compositionGraph:[],accessibility:{role:"img",ariaAttributes:["aria-label","aria-hidden"],notes:'aria-hidden="true" is applied automatically when no label is given, hiding the icon from screen readers.'}},ta={primary:"var(--lucent-text-primary)",secondary:"var(--lucent-text-secondary)",disabled:"var(--lucent-text-disabled)",inverse:"var(--lucent-text-inverse)",onAccent:"var(--lucent-text-on-accent)",success:"var(--lucent-success-text)",warning:"var(--lucent-warning-text)",danger:"var(--lucent-danger-text)",info:"var(--lucent-info-text)"},na={xs:"var(--lucent-font-size-xs)",sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)",xl:"var(--lucent-font-size-xl)","2xl":"var(--lucent-font-size-2xl)","3xl":"var(--lucent-font-size-3xl)"},aa={regular:"var(--lucent-font-weight-regular)",medium:"var(--lucent-font-weight-medium)",semibold:"var(--lucent-font-weight-semibold)",bold:"var(--lucent-font-weight-bold)"},ra={tight:"var(--lucent-line-height-tight)",base:"var(--lucent-line-height-base)",relaxed:"var(--lucent-line-height-relaxed)"},oa={base:"var(--lucent-font-family-base)",mono:"var(--lucent-font-family-mono)",display:"var(--lucent-font-family-display)"};function O({as:e="p",size:n="md",weight:r="regular",color:o="primary",align:a="left",lineHeight:s="base",family:i="base",truncate:l=!1,children:c,style:d,...u}){const h={fontSize:na[n],fontWeight:aa[r],color:ta[o],textAlign:a,lineHeight:ra[s],fontFamily:oa[i],margin:0,...l&&{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},...d},m=e;return t.jsx(m,{style:h,...u,children:c})}const sa={id:"text",name:"Text",tier:"atom",domain:"neutral",specVersion:"0.1",description:"Polymorphic typography primitive that maps semantic HTML elements to design-system type scales.",designIntent:"Text is the single source of truth for typography in Lucent UI. Rather than hard-coding font sizes and colors directly in components, every piece of rendered text should pass through this atom. The `as` prop controls the HTML element (and therefore semantic meaning), while `size`, `weight`, `color`, and `lineHeight` control appearance independently — decoupling semantics from style. Use `truncate` only in constrained-width containers where overflow must be prevented; it applies overflow: hidden + text-overflow: ellipsis. The `family` prop enables inline code or monospaced content without switching components.",props:[{name:"as",type:"enum",required:!1,default:"p",description:"HTML element to render. Controls semantic meaning independently of visual style.",enumValues:["p","h1","h2","h3","h4","h5","h6","span","div","label","strong","em","code"]},{name:"size",type:"enum",required:!1,default:"md",description:"Font size from the type scale. Maps to the corresponding --lucent-font-size-* token.",enumValues:["xs","sm","md","lg","xl","2xl","3xl"]},{name:"weight",type:"enum",required:!1,default:"regular",description:"Font weight. Maps to --lucent-font-weight-* tokens.",enumValues:["regular","medium","semibold","bold"]},{name:"color",type:"enum",required:!1,default:"primary",description:"Semantic text color. All values adapt automatically in light and dark themes.",enumValues:["primary","secondary","disabled","inverse","onAccent","success","warning","danger","info"]},{name:"align",type:"enum",required:!1,default:"left",description:"Text alignment.",enumValues:["left","center","right"]},{name:"lineHeight",type:"enum",required:!1,default:"base",description:"Line height. tight=1.25, base=1.5, relaxed=1.75.",enumValues:["tight","base","relaxed"]},{name:"family",type:"enum",required:!1,default:"base",description:"Font family. Use mono for code or tabular data. Use display (Unbounded) for headings and marketing copy.",enumValues:["base","mono","display"]},{name:"truncate",type:"boolean",required:!1,default:"false",description:"Clips overflow text with an ellipsis. Requires the container to have a constrained width."},{name:"children",type:"ReactNode",required:!0,description:"The text content to render."},{name:"style",type:"object",required:!1,description:"Inline style overrides. Applied after computed token styles."}],usageExamples:[{title:"Heading",code:'<Text as="h1" size="3xl" weight="bold">Page title</Text>'},{title:"Body paragraph",code:'<Text size="md" color="secondary">Supporting copy goes here.</Text>'},{title:"Label",code:'<Text as="label" size="sm" weight="medium" htmlFor="email">Email</Text>'},{title:"Inline code",code:'<Text as="code" family="mono" size="sm">const x = 1;</Text>'},{title:"Truncated",code:"<Text truncate style={{ maxWidth: 200 }}>Very long text that will be clipped</Text>"},{title:"Status color",code:'<Text color="danger" size="xs">This field is required</Text>'}],compositionGraph:[],accessibility:{notes:'The rendered element determines the implicit ARIA role. Use heading elements (h1–h6) for document headings so screen readers can navigate the page structure. Use `as="label"` with `htmlFor` to associate labels with form controls. Decorative text needs no additional ARIA.'}};function ia({children:e,href:n,isActive:r=!1,icon:o,disabled:a=!1,inverse:s=!1,onClick:i,as:l,style:c}){const d=l??"a";return t.jsxs(d,{href:a?void 0:n,onClick:a?void 0:i,"aria-current":r?"page":void 0,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",padding:"var(--lucent-space-2) var(--lucent-space-3) var(--lucent-space-2) var(--lucent-space-4)",borderRadius:"var(--lucent-radius-md)",background:a?"transparent":r?s?"var(--lucent-surface)":"var(--lucent-accent-default)":"transparent",color:a?"var(--lucent-text-disabled)":r?s?"var(--lucent-text-primary)":"var(--lucent-text-on-accent)":"var(--lucent-text-secondary)",border:r&&s?"1px solid var(--lucent-border-default)":"1px solid transparent",borderRight:r&&s?"3px solid var(--lucent-accent-default)":"3px solid transparent",boxShadow:r&&s?"var(--lucent-shadow-md)":"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:r?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textDecoration:"none",cursor:a?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), color var(--lucent-duration-fast) var(--lucent-easing-default)",userSelect:"none",boxSizing:"border-box",...c},onMouseEnter:u=>{!a&&!r&&(u.currentTarget.style.background="var(--lucent-surface-secondary)")},onMouseLeave:u=>{!a&&!r&&(u.currentTarget.style.background="transparent")},children:[o!=null&&t.jsx("span",{style:{display:"flex",flexShrink:0,color:"inherit"},children:o}),e]})}const la={sm:"3px",md:"4px",lg:"5px"},ca={sm:"14px",md:"18px",lg:"22px"},da=`
|
|
59
|
+
/>`.trim()},{title:"With validation error",code:'<Select label="Role" options={roles} errorText="Please select a role" />'},{title:"With helper text",code:'<Select label="Timezone" options={timezones} helperText="Used for scheduling notifications" />'}],compositionGraph:[],accessibility:{role:"combobox",ariaAttributes:["aria-invalid","aria-describedby"],keyboardInteractions:["Enter / Space — opens the option list","Arrow keys — navigate options","Escape — closes the list"]}},Yn={neutral:{bg:"var(--lucent-surface-secondary)",color:"var(--lucent-text-secondary)",border:"var(--lucent-border-default)",dismissHover:"var(--lucent-border-strong)"},accent:{bg:"var(--lucent-accent-subtle)",color:"var(--lucent-accent-active)",border:"var(--lucent-accent-subtle)",dismissHover:"var(--lucent-accent-default)"},success:{bg:"var(--lucent-success-subtle)",color:"var(--lucent-success-text)",border:"var(--lucent-success-subtle)",dismissHover:"var(--lucent-success-default)"},warning:{bg:"var(--lucent-warning-subtle)",color:"var(--lucent-warning-text)",border:"var(--lucent-warning-subtle)",dismissHover:"var(--lucent-warning-default)"},danger:{bg:"var(--lucent-danger-subtle)",color:"var(--lucent-danger-text)",border:"var(--lucent-danger-subtle)",dismissHover:"var(--lucent-danger-default)"},info:{bg:"var(--lucent-info-subtle)",color:"var(--lucent-info-text)",border:"var(--lucent-info-subtle)",dismissHover:"var(--lucent-info-default)"}},Kn={sm:{fontSize:"var(--lucent-font-size-xs)",height:"20px",padding:"0 var(--lucent-space-3)",iconSize:10,gap:"var(--lucent-space-1)"},md:{fontSize:"var(--lucent-font-size-sm)",height:"24px",padding:"0 var(--lucent-space-3)",iconSize:12,gap:"var(--lucent-space-1)"},lg:{fontSize:"var(--lucent-font-size-md)",height:"28px",padding:"0 var(--lucent-space-4)",iconSize:14,gap:"var(--lucent-space-2)"}};function Xn({children:t,variant:n="neutral",size:r="md",onDismiss:o,disabled:a}){const i=Yn[n],s=Kn[r],[l,c]=p.useState(!1),d=!a&&o;return e.jsxs("span",{onMouseEnter:()=>{a||c(!0)},onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:s.gap,height:s.height,padding:o?`0 var(--lucent-space-2) 0 ${s.padding.split(" ")[1]}`:s.padding,fontSize:s.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:"var(--lucent-radius-lg)",background:i.bg,color:i.color,border:`1px solid ${l&&!a?i.dismissHover:i.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:a?.5:1,transform:l&&d?"translateY(-1px)":"none",boxShadow:l&&d?`0 2px 4px ${i.dismissHover}22`:"none",transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default), border-color var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:d?"pointer":"default"},children:[t,o&&e.jsx("button",{type:"button",onClick:a?void 0:u=>{u.stopPropagation(),o==null||o()},disabled:a,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:s.iconSize+4,height:s.iconSize+4,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:a?"not-allowed":"pointer",flexShrink:0,lineHeight:1},onMouseEnter:u=>{a||(u.currentTarget.style.background=i.dismissHover+"33")},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:e.jsx("svg",{width:s.iconSize,height:s.iconSize,viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",children:e.jsx("path",{d:"M2 2L8 8M8 2L2 8"})})})]})}const Jn={id:"tag",name:"Tag",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A dismissible label for applied filters, selected values, or categorisation.",designIntent:"Tags represent user-applied selections that can be removed — filters, multi-select values, categories. They differ from Badge in that they are interactive: provide onDismiss when the user should be able to remove the tag. Without onDismiss they render as a static pill (identical to Badge in purpose). Use semantic variants to match meaning; default to neutral for user-generated content where no semantic applies.",props:[{name:"children",type:"ReactNode",required:!0,description:"Tag label content."},{name:"variant",type:"enum",required:!1,default:"neutral",description:"Colour scheme conveying semantic meaning.",enumValues:["neutral","accent","success","warning","danger","info"]},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height and font size.",enumValues:["sm","md","lg"]},{name:"onDismiss",type:"function",required:!1,description:"When provided, renders an × button that calls this handler on click."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Dims the tag and prevents the dismiss action."}],usageExamples:[{title:"Dismissible filter",code:"<Tag onDismiss={() => removeFilter('react')}>React</Tag>"},{title:"Multi-select value",code:'<Tag variant="accent" onDismiss={() => deselect(id)}>Jane Doe</Tag>'},{title:"Static category",code:'<Tag variant="info">Beta</Tag>'},{title:"Danger (removable)",code:'<Tag variant="danger" onDismiss={handleRemove}>Blocked</Tag>'}],compositionGraph:[],accessibility:{role:"group",notes:'The dismiss button has aria-label="Dismiss" and is keyboard-focusable.',keyboardInteractions:["Enter / Space — activates the dismiss button when focused"]}},Y=5,Zn={top:{bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:Y+3},bottom:{top:"100%",left:"50%",transform:"translateX(-50%)",marginTop:Y+3},left:{right:"100%",top:"50%",transform:"translateY(-50%)",marginRight:Y+3},right:{left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:Y+3}},Qn={top:{bottom:-Y,left:"50%",transform:"translateX(-50%)",borderWidth:`${Y}px ${Y}px 0 ${Y}px`,borderColor:"var(--lucent-text-primary) transparent transparent transparent"},bottom:{top:-Y,left:"50%",transform:"translateX(-50%)",borderWidth:`0 ${Y}px ${Y}px ${Y}px`,borderColor:"transparent transparent var(--lucent-text-primary) transparent"},left:{right:-Y,top:"50%",transform:"translateY(-50%)",borderWidth:`${Y}px 0 ${Y}px ${Y}px`,borderColor:"transparent transparent transparent var(--lucent-text-primary)"},right:{left:-Y,top:"50%",transform:"translateY(-50%)",borderWidth:`${Y}px ${Y}px ${Y}px 0`,borderColor:"transparent var(--lucent-text-primary) transparent transparent"}};function ea({content:t,children:n,placement:r="top",delay:o=300}){const[a,i]=p.useState(!1),s=p.useRef(null),l=()=>{s.current=setTimeout(()=>i(!0),o)},c=()=>{s.current&&clearTimeout(s.current),i(!1)};return t?e.jsxs("span",{style:{position:"relative",display:"inline-flex"},onMouseEnter:l,onMouseLeave:c,onFocus:l,onBlur:c,children:[n,a&&e.jsxs("span",{role:"tooltip",style:{position:"absolute",...Zn[r],background:"var(--lucent-text-primary)",color:"var(--lucent-bg-base)",padding:"5px 10px",borderRadius:"var(--lucent-radius-md)",fontSize:"var(--lucent-font-size-xs)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:"var(--lucent-line-height-base)",whiteSpace:"nowrap",zIndex:9999,pointerEvents:"none",boxShadow:"var(--lucent-shadow-md)"},children:[t,e.jsx("span",{"aria-hidden":!0,style:{position:"absolute",width:0,height:0,borderStyle:"solid",...Qn[r]}})]})]}):e.jsx(e.Fragment,{children:n})}const ta={id:"tooltip",name:"Tooltip",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A transient label that appears on hover or focus to explain an element.",designIntent:'Tooltips surface supplementary context that would clutter the UI if shown permanently — keyboard shortcut hints, icon button labels, truncated text expansions. They must never contain critical information (errors, required actions) because they are invisible until hovered. Keep content to one short phrase; avoid wrapping. Use placement to avoid viewport edges — "top" is the default and works in most cases.',props:[{name:"content",type:"ReactNode",required:!0,description:"Text or element shown inside the tooltip. Keep it short (under 80 chars)."},{name:"children",type:"ReactNode",required:!0,description:"The element that triggers the tooltip on hover/focus."},{name:"placement",type:"enum",required:!1,default:"top",description:"Position of the tooltip relative to the trigger.",enumValues:["top","bottom","left","right"]},{name:"delay",type:"number",required:!1,default:"300",description:"Milliseconds before the tooltip appears. Prevents flicker on fast cursor movement."}],usageExamples:[{title:"Icon button label",code:'<Tooltip content="Copy to clipboard"><IconButton icon={<CopyIcon />} /></Tooltip>'},{title:"Keyboard shortcut hint",code:'<Tooltip content="⌘K"><Button variant="ghost">Search</Button></Tooltip>'},{title:"Bottom placement",code:'<Tooltip content="Opens in a new tab" placement="bottom"><a href="…">Link</a></Tooltip>'},{title:"No delay (instant)",code:'<Tooltip content="Delete" delay={0}><Button variant="ghost">🗑</Button></Tooltip>'}],compositionGraph:[],accessibility:{role:"tooltip",ariaAttributes:['role="tooltip"'],notes:'The tooltip is shown on both hover and focus, making it accessible to keyboard users. Content is exposed via role="tooltip".'}},na={xs:12,sm:14,md:16,lg:20,xl:24};function aa({children:t,size:n="md",label:r,color:o,style:a}){const i=na[n];return e.jsx("span",{role:r?"img":void 0,"aria-label":r,"aria-hidden":r?void 0:!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i,height:i,flexShrink:0,color:o??"currentColor",...a},children:t})}const ra={id:"icon",name:"Icon",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A sized, accessible wrapper for any SVG or icon-set component.",designIntent:"Icon is intentionally icon-set agnostic — pass any SVG or third-party icon as children and it handles sizing and accessibility automatically. Use label for standalone icons that convey meaning without adjacent text (e.g. a close button). Omit label for decorative icons next to text, where the text already provides context. colour inherits from the parent by default via currentColor — override only when the icon must differ from its surrounding text.",props:[{name:"children",type:"ReactNode",required:!0,description:"The icon to render — any SVG element or icon-set component."},{name:"size",type:"enum",required:!1,default:"md",description:"Constrains the icon to a fixed square (xs=12, sm=14, md=16, lg=20, xl=24).",enumValues:["xs","sm","md","lg","xl"]},{name:"label",type:"string",required:!1,description:"Accessible label (aria-label). Provide for meaningful standalone icons; omit for decorative ones."},{name:"color",type:"string",required:!1,description:"CSS colour value. Defaults to currentColor (inherits from parent)."}],usageExamples:[{title:"Decorative (next to text)",code:'<Icon size="md"><SearchIcon /></Icon>'},{title:"Meaningful (standalone)",code:'<Icon size="lg" label="Close dialog"><XIcon /></Icon>'},{title:"Coloured",code:'<Icon color="var(--lucent-danger-default)"><AlertIcon /></Icon>'},{title:"Inside a button",code:'<Button leftIcon={<Icon size="sm"><PlusIcon /></Icon>}>Add item</Button>'}],compositionGraph:[],accessibility:{role:"img",ariaAttributes:["aria-label","aria-hidden"],notes:'aria-hidden="true" is applied automatically when no label is given, hiding the icon from screen readers.'}},oa={primary:"var(--lucent-text-primary)",secondary:"var(--lucent-text-secondary)",disabled:"var(--lucent-text-disabled)",inverse:"var(--lucent-text-inverse)",onAccent:"var(--lucent-text-on-accent)",success:"var(--lucent-success-text)",warning:"var(--lucent-warning-text)",danger:"var(--lucent-danger-text)",info:"var(--lucent-info-text)"},ia={xs:"var(--lucent-font-size-xs)",sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)",xl:"var(--lucent-font-size-xl)","2xl":"var(--lucent-font-size-2xl)","3xl":"var(--lucent-font-size-3xl)"},sa={regular:"var(--lucent-font-weight-regular)",medium:"var(--lucent-font-weight-medium)",semibold:"var(--lucent-font-weight-semibold)",bold:"var(--lucent-font-weight-bold)"},la={tight:"var(--lucent-line-height-tight)",base:"var(--lucent-line-height-base)",relaxed:"var(--lucent-line-height-relaxed)"},ca={base:"var(--lucent-font-family-base)",mono:"var(--lucent-font-family-mono)",display:"var(--lucent-font-family-display)"};function O({as:t="p",size:n="md",weight:r="regular",color:o="primary",align:a="left",lineHeight:i="base",family:s="base",truncate:l=!1,children:c,style:d,...u}){const h={fontSize:ia[n],fontWeight:sa[r],color:oa[o],textAlign:a,lineHeight:la[i],fontFamily:ca[s],margin:0,...l&&{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},...d},m=t;return e.jsx(m,{style:h,...u,children:c})}const da={id:"text",name:"Text",tier:"atom",domain:"neutral",specVersion:"0.1",description:"Polymorphic typography primitive that maps semantic HTML elements to design-system type scales.",designIntent:"Text is the single source of truth for typography in Lucent UI. Rather than hard-coding font sizes and colors directly in components, every piece of rendered text should pass through this atom. The `as` prop controls the HTML element (and therefore semantic meaning), while `size`, `weight`, `color`, and `lineHeight` control appearance independently — decoupling semantics from style. Use `truncate` only in constrained-width containers where overflow must be prevented; it applies overflow: hidden + text-overflow: ellipsis. The `family` prop enables inline code or monospaced content without switching components.",props:[{name:"as",type:"enum",required:!1,default:"p",description:"HTML element to render. Controls semantic meaning independently of visual style.",enumValues:["p","h1","h2","h3","h4","h5","h6","span","div","label","strong","em","code"]},{name:"size",type:"enum",required:!1,default:"md",description:"Font size from the type scale. Maps to the corresponding --lucent-font-size-* token.",enumValues:["xs","sm","md","lg","xl","2xl","3xl"]},{name:"weight",type:"enum",required:!1,default:"regular",description:"Font weight. Maps to --lucent-font-weight-* tokens.",enumValues:["regular","medium","semibold","bold"]},{name:"color",type:"enum",required:!1,default:"primary",description:"Semantic text color. All values adapt automatically in light and dark themes.",enumValues:["primary","secondary","disabled","inverse","onAccent","success","warning","danger","info"]},{name:"align",type:"enum",required:!1,default:"left",description:"Text alignment.",enumValues:["left","center","right"]},{name:"lineHeight",type:"enum",required:!1,default:"base",description:"Line height. tight=1.25, base=1.5, relaxed=1.75.",enumValues:["tight","base","relaxed"]},{name:"family",type:"enum",required:!1,default:"base",description:"Font family. Use mono for code or tabular data. Use display (Unbounded) for headings and marketing copy.",enumValues:["base","mono","display"]},{name:"truncate",type:"boolean",required:!1,default:"false",description:"Clips overflow text with an ellipsis. Requires the container to have a constrained width."},{name:"children",type:"ReactNode",required:!0,description:"The text content to render."},{name:"style",type:"object",required:!1,description:"Inline style overrides. Applied after computed token styles."}],usageExamples:[{title:"Heading",code:'<Text as="h1" size="3xl" weight="bold">Page title</Text>'},{title:"Body paragraph",code:'<Text size="md" color="secondary">Supporting copy goes here.</Text>'},{title:"Label",code:'<Text as="label" size="sm" weight="medium" htmlFor="email">Email</Text>'},{title:"Inline code",code:'<Text as="code" family="mono" size="sm">const x = 1;</Text>'},{title:"Truncated",code:"<Text truncate style={{ maxWidth: 200 }}>Very long text that will be clipped</Text>"},{title:"Status color",code:'<Text color="danger" size="xs">This field is required</Text>'}],compositionGraph:[],accessibility:{notes:'The rendered element determines the implicit ARIA role. Use heading elements (h1–h6) for document headings so screen readers can navigate the page structure. Use `as="label"` with `htmlFor` to associate labels with form controls. Decorative text needs no additional ARIA.'}};function ua({children:t,href:n,isActive:r=!1,icon:o,disabled:a=!1,inverse:i=!1,onClick:s,as:l,style:c}){const d=l??"a";return e.jsxs(d,{href:a?void 0:n,onClick:a?void 0:s,"aria-current":r?"page":void 0,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",padding:"var(--lucent-space-2) var(--lucent-space-3) var(--lucent-space-2) var(--lucent-space-4)",borderRadius:"var(--lucent-radius-md)",background:a?"transparent":r?i?"var(--lucent-surface)":"var(--lucent-accent-default)":"transparent",color:a?"var(--lucent-text-disabled)":r?i?"var(--lucent-text-primary)":"var(--lucent-text-on-accent)":"var(--lucent-text-secondary)",border:r&&i?"1px solid var(--lucent-border-default)":"1px solid transparent",borderRight:r&&i?"3px solid var(--lucent-accent-default)":"3px solid transparent",boxShadow:r&&i?"var(--lucent-shadow-md)":"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:r?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textDecoration:"none",cursor:a?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), color var(--lucent-duration-fast) var(--lucent-easing-default)",userSelect:"none",boxSizing:"border-box",...c},onMouseEnter:u=>{!a&&!r&&(u.currentTarget.style.background="var(--lucent-surface-secondary)")},onMouseLeave:u=>{!a&&!r&&(u.currentTarget.style.background="transparent")},children:[o!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,color:"inherit"},children:o}),t]})}const pa={sm:"3px",md:"4px",lg:"5px"},fa={sm:"14px",md:"18px",lg:"22px"},ha=`
|
|
60
60
|
.lucent-slider {
|
|
61
61
|
-webkit-appearance: none;
|
|
62
62
|
appearance: none;
|
|
@@ -149,9 +149,9 @@
|
|
|
149
149
|
border-color: var(--lucent-border-default);
|
|
150
150
|
cursor: not-allowed;
|
|
151
151
|
}
|
|
152
|
-
`;function
|
|
152
|
+
`;function ma({label:t,showValue:n=!1,size:r="md",min:o=0,max:a=100,step:i=1,value:s,defaultValue:l,disabled:c,id:d,onChange:u,style:h,...m}){const g=d??`lucent-slider-${Math.random().toString(36).slice(2,7)}`,C=s!==void 0,[b,f]=p.useState(l??Math.round((o+a)/2)),v=C?s:b,S=`${(v-o)/(a-o)*100}%`,x=I=>{C||f(Number(I.target.value)),u==null||u(I)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ha}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",width:"100%",fontFamily:"var(--lucent-font-family-base)",...h},children:[(t||n)&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline"},children:[t&&e.jsx("label",{htmlFor:g,style:{fontSize:"var(--lucent-font-size-sm)",fontWeight:"var(--lucent-font-weight-medium)",color:c?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",cursor:c?"not-allowed":"default"},children:t}),n&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-sm)",color:c?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",fontVariantNumeric:"tabular-nums"},children:v})]}),e.jsx("input",{type:"range",id:g,className:"lucent-slider",min:o,max:a,step:i,disabled:c,value:C?s:b,onChange:x,style:{"--ls-track-h":pa[r],"--ls-thumb":fa[r],"--ls-fill":S},...m})]})]})}const ga={id:"slider",name:"Slider",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A range input styled with Lucent tokens for selecting a numeric value within a bounded range.",designIntent:'Use Slider for continuous or stepped numeric inputs where the relative position matters — volume, brightness, border radius, spacing scale. Pair with showValue when the exact number is meaningful to the user. For precise numeric entry, use Input with type="number" instead. Disabled state uses muted colours without opacity hacks.',props:[{name:"min",type:"number",required:!1,default:"0",description:"Minimum value."},{name:"max",type:"number",required:!1,default:"100",description:"Maximum value."},{name:"step",type:"number",required:!1,default:"1",description:"Increment step between values."},{name:"value",type:"number",required:!1,description:"Controlled current value. Pair with onChange."},{name:"defaultValue",type:"number",required:!1,description:"Initial value for uncontrolled usage. Defaults to the midpoint of min/max."},{name:"onChange",type:"function",required:!1,description:"Called on every value change."},{name:"label",type:"string",required:!1,description:"Visible label rendered above the track."},{name:"showValue",type:"boolean",required:!1,default:"false",description:"Displays the current numeric value to the right of the label."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls track thickness and thumb diameter.",enumValues:["sm","md","lg"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and dims the control."}],usageExamples:[{title:"Basic",code:'<Slider label="Volume" showValue />'},{title:"Controlled",code:'<Slider label="Opacity" min={0} max={1} step={0.01} value={opacity} onChange={e => setOpacity(Number(e.target.value))} showValue />'},{title:"Sizes",code:`<Slider size="sm" label="Small" />
|
|
153
153
|
<Slider size="md" label="Medium" />
|
|
154
|
-
<Slider size="lg" label="Large" />`},{title:"Disabled",code:'<Slider label="Locked" disabled defaultValue={40} />'}],compositionGraph:[],accessibility:{role:"slider",ariaAttributes:["aria-valuemin","aria-valuemax","aria-valuenow","aria-disabled"],keyboardInteractions:["ArrowRight / ArrowUp — increase value by step","ArrowLeft / ArrowDown — decrease value by step","Home — jump to min","End — jump to max"]}},
|
|
154
|
+
<Slider size="lg" label="Large" />`},{title:"Disabled",code:'<Slider label="Locked" disabled defaultValue={40} />'}],compositionGraph:[],accessibility:{role:"slider",ariaAttributes:["aria-valuemin","aria-valuemax","aria-valuenow","aria-disabled"],keyboardInteractions:["ArrowRight / ArrowUp — increase value by step","ArrowLeft / ArrowDown — decrease value by step","Home — jump to min","End — jump to max"]}},va=2e3;function ba(){return e.jsxs("svg",{width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})}function ya(){return e.jsx("svg",{width:13,height:13,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("path",{d:"M20 6L9 17l-5-5"})})}function xa({code:t,language:n,tabs:r,variant:o="code",helperText:a,showCopyButton:i=!0,style:s}){var v,S;const l=!!(r!=null&&r.length),[c,d]=p.useState(0),[u,h]=p.useState(!1),m=l?((v=r[c])==null?void 0:v.code)??"":t??"",g=l?(S=r[c])==null?void 0:S.language:n,C=async()=>{try{await navigator.clipboard.writeText(m),h(!0),setTimeout(()=>h(!1),va)}catch{}},b={display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",padding:"3px var(--lucent-space-2)",border:"1px solid transparent",borderRadius:"var(--lucent-radius-md)",background:"transparent",color:u?"var(--lucent-success-default)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",cursor:"pointer",flexShrink:0,transition:"color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)"},f=()=>e.jsxs("button",{onClick:C,"aria-label":u?"Copied!":"Copy code",style:b,onMouseEnter:x=>{u||(x.currentTarget.style.background="var(--lucent-surface-secondary)",x.currentTarget.style.color="var(--lucent-text-primary)")},onMouseLeave:x=>{u||(x.currentTarget.style.background="transparent",x.currentTarget.style.color="var(--lucent-text-secondary)")},children:[u?e.jsx(ya,{}):e.jsx(ba,{}),u?"Copied!":"Copy"]});return e.jsxs("div",{style:{borderRadius:"var(--lucent-radius-lg)",border:"1px solid var(--lucent-border-default)",overflow:"hidden",...s},children:[l&&e.jsx("div",{style:{display:"flex",alignItems:"flex-end",background:"var(--lucent-surface)",borderBottom:"1px solid var(--lucent-border-default)",padding:"0 var(--lucent-space-2)"},children:r.map((x,I)=>{const w=I===c;return e.jsxs("button",{onClick:()=>{d(I),h(!1)},style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",padding:"var(--lucent-space-2) var(--lucent-space-3)",border:"none",borderBottom:w?"2px solid var(--lucent-accent-default)":"2px solid transparent",marginBottom:-1,background:"transparent",color:w?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)",fontWeight:w?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",cursor:"pointer",transition:"color var(--lucent-duration-fast) var(--lucent-easing-default)",whiteSpace:"nowrap"},onMouseEnter:z=>{w||(z.currentTarget.style.color="var(--lucent-text-primary)")},onMouseLeave:z=>{w||(z.currentTarget.style.color="var(--lucent-text-secondary)")},children:[x.icon!==void 0&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:x.icon}),x.label]},x.label)})}),!l&&(!!g||i)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:g?"space-between":"flex-end",padding:"0 var(--lucent-space-3)",height:36,background:"var(--lucent-surface-secondary)",borderBottom:"1px solid var(--lucent-border-default)"},children:[g&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",fontFamily:"var(--lucent-font-family-mono)",color:"var(--lucent-text-secondary)",letterSpacing:"var(--lucent-letter-spacing-wide)"},children:g}),i&&e.jsx(f,{})]}),a&&e.jsx("div",{style:{padding:"var(--lucent-space-2) var(--lucent-space-4)",fontSize:"var(--lucent-font-size-xs)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",background:"var(--lucent-surface-secondary)",borderBottom:"1px solid var(--lucent-border-default)"},children:a}),o==="code"?e.jsxs("div",{style:{position:"relative"},children:[e.jsx("pre",{style:{margin:0,padding:"var(--lucent-space-4)",paddingRight:l&&i?"var(--lucent-space-16)":"var(--lucent-space-4)",background:"var(--lucent-surface-secondary)",overflowX:"auto",lineHeight:1.65},children:e.jsx("code",{style:{fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-primary)"},children:m})}),l&&i&&e.jsx("div",{style:{position:"absolute",top:"var(--lucent-space-2)",right:"var(--lucent-space-3)"},children:e.jsx(f,{})})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-3) var(--lucent-space-4)",background:"var(--lucent-surface-secondary)"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-primary)"},children:m}),i&&e.jsx(f,{})]})]})}const wa={id:"code-block",name:"CodeBlock",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A styled code display with optional tabs, a language label, copy-to-clipboard, and an AI prompt variant.",designIntent:"Use CodeBlock for static code snippets, install commands, API examples, and AI prompt sharing. The tabs prop switches between related snippets (e.g. pnpm / npm / yarn). The prompt variant renders a single-line truncated display suited to AI tool prompts — the full text is always copied even when visually clipped. Zero-dependency — no syntax highlighting library is bundled.",props:[{name:"code",type:"string",required:!1,description:"Code string — used in single (non-tabbed) mode."},{name:"language",type:"string",required:!1,description:"Language label shown in the header (non-tabbed mode only). Purely cosmetic."},{name:"tabs",type:"array",required:!1,description:"Tabbed mode. Each entry has { label, code, language?, icon? }. Switching tabs resets the copied state."},{name:"variant",type:"enum",required:!1,default:"code",enumValues:["code","prompt"],description:'"code" renders a <pre><code> block with horizontal scroll. "prompt" renders a single-line truncated span suited to AI prompts.'},{name:"helperText",type:"string",required:!1,description:"Descriptive text rendered between the tab bar and the code area."},{name:"showCopyButton",type:"boolean",required:!1,default:"true",description:'Renders a copy-to-clipboard button. Shows a "Copied!" confirmation for 2 s on success.'}],usageExamples:[{title:"Single snippet",code:'<CodeBlock language="tsx" code={`<Button variant="primary">Save</Button>`} />'},{title:"Tabbed install commands",code:`<CodeBlock tabs={[
|
|
155
155
|
{ label: 'pnpm', code: 'pnpm add lucent-ui', language: 'bash' },
|
|
156
156
|
{ label: 'npm', code: 'npm install lucent-ui', language: 'bash' },
|
|
157
157
|
]} />`},{title:"AI prompt",code:`<CodeBlock
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
{ label: 'Claude', icon: '♦', code: '"Add a Button with variant=\\"primary\\"."' },
|
|
162
162
|
{ label: 'Cursor', icon: '↖', code: '@lucent-ui Add a primary Button.' },
|
|
163
163
|
]}
|
|
164
|
-
/>`}],compositionGraph:[],accessibility:{role:"region",ariaAttributes:["aria-label (copy button)"],keyboardInteractions:["Tab — focuses the copy button","Enter / Space — copies the code"]}},
|
|
164
|
+
/>`}],compositionGraph:[],accessibility:{role:"region",ariaAttributes:["aria-label (copy button)"],keyboardInteractions:["Tab — focuses the copy button","Enter / Space — copies the code"]}},ka=`
|
|
165
165
|
.lucent-table-row:hover > td,
|
|
166
166
|
.lucent-table-row:hover > th {
|
|
167
167
|
background: var(--lucent-surface-secondary) !important;
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
.lucent-table-striped tbody .lucent-table-row:nth-child(even) > th {
|
|
171
171
|
background: var(--lucent-surface-secondary);
|
|
172
172
|
}
|
|
173
|
-
`;function
|
|
173
|
+
`;function Sa({children:t,style:n,...r}){return e.jsx("thead",{style:{background:"var(--lucent-surface-secondary)",...n},...r,children:t})}function Ta({children:t,...n}){return e.jsx("tbody",{...n,children:t})}function Ca({children:t,style:n,...r}){return e.jsx("tfoot",{style:{background:"var(--lucent-surface-secondary)",...n},...r,children:t})}function ja({children:t,className:n,...r}){return e.jsx("tr",{className:["lucent-table-row",n].filter(Boolean).join(" "),...r,children:t})}function Ia({as:t,children:n,style:r,...o}){const a=t==="th",i={padding:"var(--lucent-space-3) var(--lucent-space-4)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)",borderBottom:"1px solid var(--lucent-border-default)",textAlign:"left",verticalAlign:"middle",color:a?"var(--lucent-text-secondary)":"var(--lucent-text-primary)",fontWeight:a?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",whiteSpace:a?"nowrap":void 0,...r};return a?e.jsx("th",{scope:"col",style:i,...o,children:n}):e.jsx("td",{style:i,...o,children:n})}function oe({striped:t=!1,children:n,className:r,style:o,...a}){const i=["lucent-table",t&&"lucent-table-striped",r].filter(Boolean).join(" ");return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:ka}),e.jsx("div",{style:{overflowX:"auto",width:"100%"},children:e.jsx("table",{className:i,style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)",...o},...a,children:n})})]})}oe.Head=Sa;oe.Body=Ta;oe.Foot=Ca;oe.Row=ja;oe.Cell=Ia;const Ma={id:"table",name:"Table",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A lightweight, token-styled HTML table primitive with compound sub-components. Distinct from DataTable — no sorting, filtering, or pagination.",designIntent:"Use Table for static or lightly dynamic tabular data where full DataTable features are not needed — props tables, changelog entries, comparison grids, reference docs. The compound API (Table.Head, Table.Body, Table.Row, Table.Cell) maps directly to semantic HTML so screen readers get the full table structure. Horizontal overflow is handled automatically by a scroll wrapper.",props:[{name:"striped",type:"boolean",required:!1,default:"false",description:"Applies alternating surfaceSecondary backgrounds to even tbody rows."},{name:"Table.Head",type:"component",required:!1,description:"Renders <thead> with surfaceSecondary background. Accepts Table.Row children."},{name:"Table.Body",type:"component",required:!1,description:"Renders <tbody>. Accepts Table.Row children."},{name:"Table.Foot",type:"component",required:!1,description:"Renders <tfoot> with surfaceSecondary background."},{name:"Table.Row",type:"component",required:!1,description:"Renders <tr> with a hover highlight. Accepts Table.Cell children."},{name:"Table.Cell",type:"component",required:!1,description:'Renders <td> by default or <th scope="col"> when as="th". Header cells are semibold + secondary colour; data cells are regular + primary.'}],usageExamples:[{title:"Basic",code:`<Table>
|
|
174
174
|
<Table.Head>
|
|
175
175
|
<Table.Row>
|
|
176
176
|
<Table.Cell as="th">Name</Table.Cell>
|
|
@@ -188,19 +188,19 @@
|
|
|
188
188
|
<Table.Body>…</Table.Body>
|
|
189
189
|
</Table>`},{title:"Custom cell content",code:`<Table.Cell>
|
|
190
190
|
<Badge variant="success">Active</Badge>
|
|
191
|
-
</Table.Cell>`}],compositionGraph:[{componentId:"table-head",componentName:"Table.Head",role:"head",required:!1},{componentId:"table-body",componentName:"Table.Body",role:"body",required:!1},{componentId:"table-foot",componentName:"Table.Foot",role:"foot",required:!1},{componentId:"table-row",componentName:"Table.Row",role:"row",required:!1},{componentId:"table-cell",componentName:"Table.Cell",role:"cell",required:!1}],accessibility:{role:"table",ariaAttributes:['scope="col" on th cells'],keyboardInteractions:["Standard browser table navigation"]}},ut={sm:"calc(var(--lucent-space-8) * 0.5 + 18px)",md:"calc(var(--lucent-space-10) * 0.5 + 22px)",lg:"calc(var(--lucent-space-12) * 0.5 + 26px)"},Ca={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)"},ja={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-5)"};function We({options:e,value:n,defaultValue:r,onChange:o,size:a="md",disabled:s=!1,fullWidth:i=!0,id:l,style:c}){var v;const[d,u]=p.useState(r??((v=e[0])==null?void 0:v.value)??""),h=n!==void 0?n:d,m=p.useRef(null),[g,C]=p.useState(null),y=p.useRef(!1);p.useLayoutEffect(()=>{const b=m.current;if(!b)return;const T=()=>{const x=b.querySelector(`[data-sc-value="${h}"]`);x&&(C({left:x.offsetLeft,width:x.offsetWidth,animate:y.current}),y.current=!0)};T();const D=new ResizeObserver(T);return D.observe(b),()=>D.disconnect()},[h,e]);const f=b=>{s||b.disabled||(n===void 0&&u(b.value),o==null||o(b.value))};return t.jsxs("div",{id:l,ref:m,role:"group",style:{position:"relative",display:"flex",alignItems:"center",width:i?"100%":"fit-content",height:ut[a],background:"var(--lucent-surface-secondary)",borderRadius:"var(--lucent-radius-lg)",padding:0,gap:0,opacity:s?.5:1,...c},children:[g&&t.jsx("span",{"aria-hidden":!0,style:{position:"absolute",top:3,left:g.left+3,width:g.width-6,height:"calc(100% - 6px)",background:"var(--lucent-surface)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-sm)",transition:g.animate?"left var(--lucent-duration-base) cubic-bezier(0.34, 1.56, 0.64, 1), width var(--lucent-duration-base) cubic-bezier(0.22, 1, 0.36, 1)":"none",zIndex:0,pointerEvents:"none"}}),e.map(b=>{const T=b.value===h,D=s||!!b.disabled;return t.jsx("button",{"data-sc-value":b.value,type:"button",role:"radio","aria-checked":T,disabled:D,onClick:()=>f(b),style:{position:"relative",zIndex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--lucent-space-1)",flex:1,height:ut[a],padding:`0 ${ja[a]}`,fontSize:Ca[a],fontFamily:"var(--lucent-font-family-base)",fontWeight:T?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",color:D?"var(--lucent-text-disabled)":T?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",background:"transparent",border:"none",borderRadius:"var(--lucent-radius-lg)",cursor:D?"not-allowed":"pointer",outline:"none",whiteSpace:"nowrap",transition:["color var(--lucent-duration-fast) var(--lucent-easing-default)","font-weight var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},onFocus:x=>{x.currentTarget.matches(":focus-visible")&&(x.currentTarget.style.boxShadow="0 0 0 2px var(--lucent-accent-subtle)")},onBlur:x=>{x.currentTarget.style.boxShadow=""},children:b.label},b.value)})]})}We.displayName="SegmentedControl";const Ia={xs:12,sm:16,md:22,lg:28,xl:36,"2xl":48},Ma={xs:"var(--lucent-radius-sm)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-md)",xl:"var(--lucent-radius-lg)","2xl":"var(--lucent-radius-lg)"},pt="inset 0 0 0 1px rgba(0,0,0,0.2)",ft="inset 0 0 0 2px rgba(0,0,0,0.5)",Da="inset 0 0 0 1px rgba(0,0,0,0.2), 0 0 0 3px var(--lucent-accent-subtle)";function za(e){return{backgroundImage:[`linear-gradient(${e}, ${e})`,"linear-gradient(45deg, #e5e5e5 25%, transparent 25%)","linear-gradient(-45deg, #e5e5e5 25%, transparent 25%)","linear-gradient(45deg, transparent 75%, #e5e5e5 75%)","linear-gradient(-45deg, transparent 75%, #e5e5e5 75%)"].join(", "),backgroundSize:"auto, 8px 8px, 8px 8px, 8px 8px, 8px 8px",backgroundPosition:"0 0, 0 0, 0 4px, 4px -4px, -4px 0",backgroundColor:"#fff"}}const le=p.forwardRef(({color:e,size:n="md",shape:r="circle",showCheckerboard:o=!1,selected:a=!1,disabled:s=!1,style:i,onFocus:l,onBlur:c,onClick:d,...u},h)=>{const m=Ia[n],g=r==="circle"?"50%":Ma[n];return t.jsx("button",{ref:h,type:"button",disabled:s,onClick:d,style:{width:m,height:m,flexShrink:0,...o?za(e):{background:e},border:"none",borderRadius:g,cursor:s?"not-allowed":d?"pointer":"default",padding:0,outline:"none",opacity:s?.4:1,boxShadow:a?ft:pt,transition:"box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)",...i},onFocus:C=>{s||(C.currentTarget.style.boxShadow=Da),l==null||l(C)},onBlur:C=>{C.currentTarget.style.boxShadow=a?ft:pt,c==null||c(C)},...u})});le.displayName="ColorSwatch";function we(e,n,r){return Math.max(n,Math.min(r,e))}function Ea(e,n,r){const o=n/100,a=r/100,s=a*o,i=s*(1-Math.abs(e/60%2-1)),l=a-s;let c=0,d=0,u=0;return e<60?(c=s,d=i):e<120?(c=i,d=s):e<180?(d=s,u=i):e<240?(d=i,u=s):e<300?(c=i,u=s):(c=s,u=i),{r:Math.round((c+l)*255),g:Math.round((d+l)*255),b:Math.round((u+l)*255)}}function Aa(e,n,r){const o=e/255,a=n/255,s=r/255,i=Math.max(o,a,s),l=Math.min(o,a,s),c=i-l,d=i,u=i===0?0:c/i;let h=0;return c!==0&&(i===o?h=((a-s)/c+(a<s?6:0))/6:i===a?h=((s-o)/c+2)/6:h=((o-a)/c+4)/6),{h:Math.round(h*360),s:Math.round(u*100),v:Math.round(d*100)}}function Ra(e,n,r){const o=e/255,a=n/255,s=r/255,i=Math.max(o,a,s),l=Math.min(o,a,s),c=(i+l)/2;if(i===l)return{h:0,s:0,l:Math.round(c*100)};const d=i-l,u=c>.5?d/(2-i-l):d/(i+l);let h=0;return i===o?h=((a-s)/d+(a<s?6:0))/6:i===a?h=((s-o)/d+2)/6:h=((o-a)/d+4)/6,{h:Math.round(h*360),s:Math.round(u*100),l:Math.round(c*100)}}function xe(e,n,r){const o=n/100,a=r/100,s=(1-Math.abs(2*a-1))*o,i=s*(1-Math.abs(e/60%2-1)),l=a-s/2;let c=0,d=0,u=0;return e<60?(c=s,d=i):e<120?(c=i,d=s):e<180?(d=s,u=i):e<240?(d=i,u=s):e<300?(c=i,u=s):(c=s,u=i),{r:Math.round((c+l)*255),g:Math.round((d+l)*255),b:Math.round((u+l)*255)}}function Oe(e){const n=e.replace("#","");return n.length===3?`#${n[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`:n.length===6||n.length===8?`#${n}`:"#000000"}function zt(e){const n=Oe(e);return{r:parseInt(n.slice(1,3),16),g:parseInt(n.slice(3,5),16),b:parseInt(n.slice(5,7),16),a:n.length===9?+(parseInt(n.slice(7,9),16)/255).toFixed(2):1}}function qe({r:e,g:n,b:r,a:o}){const a=i=>we(Math.round(i),0,255).toString(16).padStart(2,"0"),s=`#${a(e)}${a(n)}${a(r)}`;return o<1?`${s}${a(Math.round(o*255))}`:s}function Et({h:e,s:n,v:r,a:o}){return{...Ea(e,n,r),a:o}}function J({r:e,g:n,b:r,a:o}){return{...Aa(e,n,r),a:o}}function pe(e){return qe(Et(e))}function fe(e){const n=e.trim();if(n.startsWith("#")){const a=Oe(n);return/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(a)?zt(a):null}const r=n.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([\d.]+))?\s*\)$/);if(r){const a=+(r[1]??"0"),s=+(r[2]??"0"),i=+(r[3]??"0"),l=r[4]!==void 0?+r[4]:1;return[a,s,i].every(c=>c<=255)&&l>=0&&l<=1?{r:a,g:s,b:i,a:l}:null}const o=n.match(/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%?\s*,\s*(\d{1,3})%?\s*\)$/);if(o){const a=+(o[1]??"0"),s=+(o[2]??"0"),i=+(o[3]??"0");return a<=360&&s<=100&&i<=100?{...xe(a,s,i),a:1}:null}return null}const Ba=[{label:"Presets",colors:["#000000","#2563eb","#16a34a","#ca8a04","#dc2626","#0ea5e9","#9333ea","#4f46e5","#e11d48"]}],qa=["linear-gradient(45deg, #c0c0c0 25%, transparent 25%)","linear-gradient(-45deg, #c0c0c0 25%, transparent 25%)","linear-gradient(45deg, transparent 75%, #c0c0c0 75%)","linear-gradient(-45deg, transparent 75%, #c0c0c0 75%)"].join(", ");function ht({value:e,min:n,max:r,onChange:o,trackStyle:a,formatTooltip:s}){const i=p.useRef(null),[l,c]=p.useState(!1),d=p.useCallback(h=>{const m=i.current.getBoundingClientRect(),g=we((h.clientX-m.left)/m.width,0,1);o(n+g*(r-n))},[n,r,o]),u=(e-n)/(r-n)*100;return t.jsx("div",{ref:i,style:{position:"relative",height:12,borderRadius:6,cursor:"crosshair",userSelect:"none",...a},onPointerDown:h=>{h.currentTarget.setPointerCapture(h.pointerId),c(!0),d(h)},onPointerMove:h=>{h.buttons>0&&d(h)},onPointerUp:()=>c(!1),onPointerCancel:()=>c(!1),children:t.jsx("div",{style:{position:"absolute",left:`${u}%`,top:"50%",transform:"translate(-50%, -50%)",width:14,height:14,borderRadius:"50%",background:"white",border:"2px solid rgba(0,0,0,0.22)",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",zIndex:1,pointerEvents:"none"},children:l&&s&&t.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,background:"rgba(0,0,0,0.75)",color:"#fff",fontSize:11,fontFamily:"var(--lucent-font-family-base)",fontWeight:500,borderRadius:4,padding:"2px 6px",whiteSpace:"nowrap",pointerEvents:"none"},children:s(e)})})})}function La(){return t.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[t.jsx("path",{d:"M2 22l1-1h3l9-9"}),t.jsx("path",{d:"M3 21v-3l9-9"}),t.jsx("path",{d:"M15 6l3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z"})]})}function At({value:e,onChange:n,label:r,size:o="md",inline:a=!1,disabled:s=!1,presetGroups:i=Ba,id:l,style:c}){var E,L;const d=o==="sm"?24:40,u=p.useId(),h=l??u,[m,g]=p.useState(!1),[C,y]=p.useState("hex"),[f,v]=p.useState(0),[b,T]=p.useState(()=>{const w=e?fe(e)??{r:0,g:0,b:0,a:1}:{r:0,g:0,b:0,a:1};return J(w)}),[D,x]=p.useState(()=>pe(b).slice(1).toUpperCase()),M=p.useRef(null),P=p.useRef(null),k=p.useRef(null),[j,W]=p.useState({top:0,left:0});p.useLayoutEffect(()=>{if(!m||!M.current)return;const w=M.current.getBoundingClientRect();let A=w.left;const q=w.bottom+8;if(k.current){const H=k.current.offsetWidth;A+H>window.innerWidth&&(A=w.right-H)}W({top:q,left:A})},[m]),p.useEffect(()=>{if(!e)return;const w=fe(e);w&&(T(J(w)),x(qe(w).slice(1).toUpperCase()))},[e]),p.useEffect(()=>{if(!m)return;const w=A=>{var H,Y;const q=A.target;(H=M.current)!=null&&H.contains(q)||(Y=k.current)!=null&&Y.contains(q)||g(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[m]);const R=p.useCallback(w=>{T(w);const A=pe(w);x(A.slice(1).toUpperCase()),n==null||n(A)},[n]),z=p.useCallback(w=>{const A=P.current.getBoundingClientRect(),q=Math.round(we((w.clientX-A.left)/A.width,0,1)*100),H=Math.round((1-we((w.clientY-A.top)/A.height,0,1))*100);R({...b,s:q,v:H})},[b,R]),F=p.useCallback(async()=>{if("EyeDropper"in window)try{const w=await new window.EyeDropper().open(),A=fe(w.sRGBHex);A&&R(J(A))}catch{}},[R]),B=Et(b),$=Ra(B.r,B.g,B.b),U=pe(b),K=pe({...b,a:1}),I=Math.round(b.a*100),N=[{id:"hex",label:"Hex"},{id:"rgb",label:"RGB"},{id:"hsl",label:"HSL"},{id:"hsb",label:"HSB"}],S=typeof window<"u"&&"EyeDropper"in window;return t.jsxs("div",{ref:M,style:{display:"inline-flex",flexDirection:a?"row":"column",alignItems:a?"center":void 0,gap:"var(--lucent-space-1)",position:"relative",...c},children:[t.jsx("style",{children:`
|
|
191
|
+
</Table.Cell>`}],compositionGraph:[{componentId:"table-head",componentName:"Table.Head",role:"head",required:!1},{componentId:"table-body",componentName:"Table.Body",role:"body",required:!1},{componentId:"table-foot",componentName:"Table.Foot",role:"foot",required:!1},{componentId:"table-row",componentName:"Table.Row",role:"row",required:!1},{componentId:"table-cell",componentName:"Table.Cell",role:"cell",required:!1}],accessibility:{role:"table",ariaAttributes:['scope="col" on th cells'],keyboardInteractions:["Standard browser table navigation"]}},pt={sm:"calc(var(--lucent-space-8) * 0.5 + 18px)",md:"calc(var(--lucent-space-10) * 0.5 + 22px)",lg:"calc(var(--lucent-space-12) * 0.5 + 26px)"},Da={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)"},za={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-5)"};function Oe({options:t,value:n,defaultValue:r,onChange:o,size:a="md",disabled:i=!1,fullWidth:s=!0,id:l,style:c}){var v;const[d,u]=p.useState(r??((v=t[0])==null?void 0:v.value)??""),h=n!==void 0?n:d,m=p.useRef(null),[g,C]=p.useState(null),b=p.useRef(!1);p.useLayoutEffect(()=>{const S=m.current;if(!S)return;const x=()=>{const w=S.querySelector(`[data-sc-value="${h}"]`);w&&(C({left:w.offsetLeft,width:w.offsetWidth,animate:b.current}),b.current=!0)};x();const I=new ResizeObserver(x);return I.observe(S),()=>I.disconnect()},[h,t]);const f=S=>{i||S.disabled||(n===void 0&&u(S.value),o==null||o(S.value))};return e.jsxs("div",{id:l,ref:m,role:"group",style:{position:"relative",display:"flex",alignItems:"center",width:s?"100%":"fit-content",height:pt[a],background:"var(--lucent-surface-secondary)",borderRadius:"var(--lucent-radius-lg)",padding:0,gap:0,opacity:i?.5:1,...c},children:[g&&e.jsx("span",{"aria-hidden":!0,style:{position:"absolute",top:3,left:g.left+3,width:g.width-6,height:"calc(100% - 6px)",background:"var(--lucent-surface)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-sm)",transition:g.animate?"left var(--lucent-duration-base) cubic-bezier(0.34, 1.56, 0.64, 1), width var(--lucent-duration-base) cubic-bezier(0.22, 1, 0.36, 1)":"none",zIndex:0,pointerEvents:"none"}}),t.map(S=>{const x=S.value===h,I=i||!!S.disabled;return e.jsx("button",{"data-sc-value":S.value,type:"button",role:"radio","aria-checked":x,disabled:I,onClick:()=>f(S),style:{position:"relative",zIndex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"var(--lucent-space-1)",flex:1,height:pt[a],padding:`0 ${za[a]}`,fontSize:Da[a],fontFamily:"var(--lucent-font-family-base)",fontWeight:x?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",color:I?"var(--lucent-text-disabled)":x?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",background:"transparent",border:"none",borderRadius:"var(--lucent-radius-lg)",cursor:I?"not-allowed":"pointer",outline:"none",whiteSpace:"nowrap",transition:["color var(--lucent-duration-fast) var(--lucent-easing-default)","font-weight var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},onFocus:w=>{w.currentTarget.matches(":focus-visible")&&(w.currentTarget.style.boxShadow="0 0 0 2px var(--lucent-accent-subtle)")},onBlur:w=>{w.currentTarget.style.boxShadow=""},children:S.label},S.value)})]})}Oe.displayName="SegmentedControl";const Ea={xs:12,sm:16,md:22,lg:28,xl:36,"2xl":48},Aa={xs:"var(--lucent-radius-sm)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-md)",xl:"var(--lucent-radius-lg)","2xl":"var(--lucent-radius-lg)"},ft="inset 0 0 0 1px rgba(0,0,0,0.2)",ht="inset 0 0 0 2px rgba(0,0,0,0.5)",Ra="inset 0 0 0 1px rgba(0,0,0,0.2), 0 0 0 3px var(--lucent-accent-subtle)";function qa(t){return{backgroundImage:[`linear-gradient(${t}, ${t})`,"linear-gradient(45deg, #e5e5e5 25%, transparent 25%)","linear-gradient(-45deg, #e5e5e5 25%, transparent 25%)","linear-gradient(45deg, transparent 75%, #e5e5e5 75%)","linear-gradient(-45deg, transparent 75%, #e5e5e5 75%)"].join(", "),backgroundSize:"auto, 8px 8px, 8px 8px, 8px 8px, 8px 8px",backgroundPosition:"0 0, 0 0, 0 4px, 4px -4px, -4px 0",backgroundColor:"#fff"}}const le=p.forwardRef(({color:t,size:n="md",shape:r="circle",showCheckerboard:o=!1,selected:a=!1,disabled:i=!1,style:s,onFocus:l,onBlur:c,onClick:d,...u},h)=>{const m=Ea[n],g=r==="circle"?"50%":Aa[n];return e.jsx("button",{ref:h,type:"button",disabled:i,onClick:d,style:{width:m,height:m,flexShrink:0,...o?qa(t):{background:t},border:"none",borderRadius:g,cursor:i?"not-allowed":d?"pointer":"default",padding:0,outline:"none",opacity:i?.4:1,boxShadow:a?ht:ft,transition:"box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)",...s},onFocus:C=>{i||(C.currentTarget.style.boxShadow=Ra),l==null||l(C)},onBlur:C=>{C.currentTarget.style.boxShadow=a?ht:ft,c==null||c(C)},...u})});le.displayName="ColorSwatch";function we(t,n,r){return Math.max(n,Math.min(r,t))}function Ba(t,n,r){const o=n/100,a=r/100,i=a*o,s=i*(1-Math.abs(t/60%2-1)),l=a-i;let c=0,d=0,u=0;return t<60?(c=i,d=s):t<120?(c=s,d=i):t<180?(d=i,u=s):t<240?(d=s,u=i):t<300?(c=s,u=i):(c=i,u=s),{r:Math.round((c+l)*255),g:Math.round((d+l)*255),b:Math.round((u+l)*255)}}function La(t,n,r){const o=t/255,a=n/255,i=r/255,s=Math.max(o,a,i),l=Math.min(o,a,i),c=s-l,d=s,u=s===0?0:c/s;let h=0;return c!==0&&(s===o?h=((a-i)/c+(a<i?6:0))/6:s===a?h=((i-o)/c+2)/6:h=((o-a)/c+4)/6),{h:Math.round(h*360),s:Math.round(u*100),v:Math.round(d*100)}}function Pa(t,n,r){const o=t/255,a=n/255,i=r/255,s=Math.max(o,a,i),l=Math.min(o,a,i),c=(s+l)/2;if(s===l)return{h:0,s:0,l:Math.round(c*100)};const d=s-l,u=c>.5?d/(2-s-l):d/(s+l);let h=0;return s===o?h=((a-i)/d+(a<i?6:0))/6:s===a?h=((i-o)/d+2)/6:h=((o-a)/d+4)/6,{h:Math.round(h*360),s:Math.round(u*100),l:Math.round(c*100)}}function xe(t,n,r){const o=n/100,a=r/100,i=(1-Math.abs(2*a-1))*o,s=i*(1-Math.abs(t/60%2-1)),l=a-i/2;let c=0,d=0,u=0;return t<60?(c=i,d=s):t<120?(c=s,d=i):t<180?(d=i,u=s):t<240?(d=s,u=i):t<300?(c=s,u=i):(c=i,u=s),{r:Math.round((c+l)*255),g:Math.round((d+l)*255),b:Math.round((u+l)*255)}}function He(t){const n=t.replace("#","");return n.length===3?`#${n[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`:n.length===6||n.length===8?`#${n}`:"#000000"}function At(t){const n=He(t);return{r:parseInt(n.slice(1,3),16),g:parseInt(n.slice(3,5),16),b:parseInt(n.slice(5,7),16),a:n.length===9?+(parseInt(n.slice(7,9),16)/255).toFixed(2):1}}function Be({r:t,g:n,b:r,a:o}){const a=s=>we(Math.round(s),0,255).toString(16).padStart(2,"0"),i=`#${a(t)}${a(n)}${a(r)}`;return o<1?`${i}${a(Math.round(o*255))}`:i}function Rt({h:t,s:n,v:r,a:o}){return{...Ba(t,n,r),a:o}}function Z({r:t,g:n,b:r,a:o}){return{...La(t,n,r),a:o}}function pe(t){return Be(Rt(t))}function fe(t){const n=t.trim();if(n.startsWith("#")){const a=He(n);return/^#[0-9a-f]{6}([0-9a-f]{2})?$/i.test(a)?At(a):null}const r=n.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([\d.]+))?\s*\)$/);if(r){const a=+(r[1]??"0"),i=+(r[2]??"0"),s=+(r[3]??"0"),l=r[4]!==void 0?+r[4]:1;return[a,i,s].every(c=>c<=255)&&l>=0&&l<=1?{r:a,g:i,b:s,a:l}:null}const o=n.match(/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%?\s*,\s*(\d{1,3})%?\s*\)$/);if(o){const a=+(o[1]??"0"),i=+(o[2]??"0"),s=+(o[3]??"0");return a<=360&&i<=100&&s<=100?{...xe(a,i,s),a:1}:null}return null}const Fa=[{label:"Presets",colors:["#000000","#2563eb","#16a34a","#ca8a04","#dc2626","#0ea5e9","#9333ea","#4f46e5","#e11d48"]}],Na=["linear-gradient(45deg, #c0c0c0 25%, transparent 25%)","linear-gradient(-45deg, #c0c0c0 25%, transparent 25%)","linear-gradient(45deg, transparent 75%, #c0c0c0 75%)","linear-gradient(-45deg, transparent 75%, #c0c0c0 75%)"].join(", ");function mt({value:t,min:n,max:r,onChange:o,trackStyle:a,formatTooltip:i}){const s=p.useRef(null),[l,c]=p.useState(!1),d=p.useCallback(h=>{const m=s.current.getBoundingClientRect(),g=we((h.clientX-m.left)/m.width,0,1);o(n+g*(r-n))},[n,r,o]),u=(t-n)/(r-n)*100;return e.jsx("div",{ref:s,style:{position:"relative",height:12,borderRadius:6,cursor:"crosshair",userSelect:"none",...a},onPointerDown:h=>{h.currentTarget.setPointerCapture(h.pointerId),c(!0),d(h)},onPointerMove:h=>{h.buttons>0&&d(h)},onPointerUp:()=>c(!1),onPointerCancel:()=>c(!1),children:e.jsx("div",{style:{position:"absolute",left:`${u}%`,top:"50%",transform:"translate(-50%, -50%)",width:14,height:14,borderRadius:"50%",background:"white",border:"2px solid rgba(0,0,0,0.22)",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",zIndex:1,pointerEvents:"none"},children:l&&i&&e.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:6,background:"rgba(0,0,0,0.75)",color:"#fff",fontSize:11,fontFamily:"var(--lucent-font-family-base)",fontWeight:500,borderRadius:4,padding:"2px 6px",whiteSpace:"nowrap",pointerEvents:"none"},children:i(t)})})})}function $a(){return e.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e.jsx("path",{d:"M2 22l1-1h3l9-9"}),e.jsx("path",{d:"M3 21v-3l9-9"}),e.jsx("path",{d:"M15 6l3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z"})]})}function qt({value:t,onChange:n,label:r,size:o="md",inline:a=!1,disabled:i=!1,presetGroups:s=Fa,portalContainer:l,id:c,style:d}){var E,U;const u=o==="sm"?24:40,h=p.useId(),m=c??h,[g,C]=p.useState(!1),[b,f]=p.useState("hex"),[v,S]=p.useState(0),[x,I]=p.useState(()=>{const k=t?fe(t)??{r:0,g:0,b:0,a:1}:{r:0,g:0,b:0,a:1};return Z(k)}),[w,z]=p.useState(()=>pe(x).slice(1).toUpperCase()),q=p.useRef(null),T=p.useRef(null),M=p.useRef(null),[F,N]=p.useState({top:0,left:0});p.useLayoutEffect(()=>{if(!g||!q.current)return;const k=q.current.getBoundingClientRect();let D=k.left;const W=k.bottom+8;if(M.current){const G=M.current.offsetWidth;D+G>window.innerWidth&&(D=k.right-G)}N({top:W,left:D})},[g]),p.useEffect(()=>{if(!t)return;const k=fe(t);k&&(I(Z(k)),z(Be(k).slice(1).toUpperCase()))},[t]),p.useEffect(()=>{if(!g)return;const k=D=>{var G,K;const W=D.target;(G=q.current)!=null&&G.contains(W)||(K=M.current)!=null&&K.contains(W)||C(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[g]);const j=p.useCallback(k=>{I(k);const D=pe(k);z(D.slice(1).toUpperCase()),n==null||n(D)},[n]),B=p.useCallback(k=>{const D=T.current.getBoundingClientRect(),W=Math.round(we((k.clientX-D.left)/D.width,0,1)*100),G=Math.round((1-we((k.clientY-D.top)/D.height,0,1))*100);j({...x,s:W,v:G})},[x,j]),L=p.useCallback(async()=>{if("EyeDropper"in window)try{const k=await new window.EyeDropper().open(),D=fe(k.sRGBHex);D&&j(Z(D))}catch{}},[j]),P=Rt(x),$=Pa(P.r,P.g,P.b),X=pe(x),H=pe({...x,a:1}),R=Math.round(x.a*100),y=[{id:"hex",label:"Hex"},{id:"rgb",label:"RGB"},{id:"hsl",label:"HSL"},{id:"hsb",label:"HSB"}],A=typeof window<"u"&&"EyeDropper"in window;return e.jsxs("div",{ref:q,style:{display:"inline-flex",flexDirection:a?"row":"column",alignItems:a?"center":void 0,gap:"var(--lucent-space-1)",position:"relative",...d},children:[e.jsx("style",{children:`
|
|
192
192
|
.lucent-cp-field::-webkit-outer-spin-button,
|
|
193
193
|
.lucent-cp-field::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
|
194
194
|
.lucent-cp-field { -moz-appearance: textfield; }
|
|
195
|
-
`}),r&&!a&&
|
|
195
|
+
`}),r&&!a&&e.jsx("label",{htmlFor:`${m}-swatch`,style:{fontSize:o==="sm"?"var(--lucent-font-size-xs)":"var(--lucent-font-size-sm)",fontWeight:"var(--lucent-font-weight-medium)",color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:r}),e.jsx(le,{id:`${m}-swatch`,color:`rgba(${P.r},${P.g},${P.b},${x.a})`,shape:"square",showCheckerboard:!0,disabled:i,onClick:()=>C(k=>!k),"aria-expanded":g,"aria-haspopup":"dialog",style:{width:u,height:u,borderRadius:o==="sm"?"var(--lucent-radius-md)":"var(--lucent-radius-lg)",boxShadow:g?"inset 0 0 0 2px var(--lucent-focus-ring), 0 0 0 3px var(--lucent-accent-subtle)":"inset 0 0 0 1px rgba(0,0,0,0.2)"}}),r&&a&&e.jsx("label",{htmlFor:`${m}-swatch`,style:{fontSize:o==="sm"?"var(--lucent-font-size-xs)":"var(--lucent-font-size-sm)",fontWeight:"var(--lucent-font-weight-medium)",color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",cursor:"pointer"},children:r}),g&&Fe.createPortal(e.jsxs("div",{ref:M,role:"dialog","aria-label":"Color picker",style:{position:"fixed",top:F.top,left:F.left,zIndex:1e3,background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-xl)",boxShadow:"var(--lucent-shadow-md)",width:280,overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{ref:T,style:{position:"relative",height:160,background:`hsl(${x.h}, 100%, 50%)`,cursor:"crosshair",userSelect:"none",flexShrink:0},onPointerDown:k=>{k.currentTarget.setPointerCapture(k.pointerId),B(k)},onPointerMove:k=>{k.buttons>0&&B(k)},children:[e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(to right, #fff, transparent)"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:"linear-gradient(to bottom, transparent, #000)"}}),e.jsx("div",{style:{position:"absolute",left:`${x.s}%`,top:`${100-x.v}%`,transform:"translate(-50%, -50%)",width:14,height:14,borderRadius:"50%",border:"2px solid #fff",boxShadow:"0 0 0 1px rgba(0,0,0,0.25), 0 2px 4px rgba(0,0,0,0.35)",pointerEvents:"none"}})]}),e.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[e.jsx(le,{color:`rgba(${P.r},${P.g},${P.b},${x.a})`,shape:"square",showCheckerboard:!0,style:{width:44,height:44,borderRadius:8}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:8},children:[e.jsx(mt,{value:x.h,min:0,max:360,onChange:k=>j({...x,h:Math.round(k)}),trackStyle:{background:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)"},formatTooltip:k=>`${Math.round(k)}°`}),e.jsxs("div",{style:{position:"relative",borderRadius:6,overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",inset:0,backgroundImage:Na,backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0",backgroundColor:"#fff"}}),e.jsx("div",{style:{position:"absolute",inset:0,background:`linear-gradient(to right, transparent, ${H})`}}),e.jsx(mt,{value:x.a,min:0,max:1,onChange:k=>j({...x,a:Math.round(k*100)/100}),trackStyle:{background:"transparent",position:"relative",zIndex:1},formatTooltip:k=>`${Math.round(k*100)}%`})]})]})]}),e.jsx(Oe,{size:"sm",value:b,onChange:k=>f(k),options:y.map(({id:k,label:D})=>({value:k,label:D}))}),b==="hex"&&e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[e.jsx(Ne,{variant:"secondary",size:"sm",onClick:L,disabled:!A,title:A?"Pick color from screen":"Not supported in this browser",leftIcon:e.jsx($a,{}),style:{flexShrink:0,paddingLeft:8,paddingRight:8}}),e.jsx(te,{size:"sm",prefix:"#",value:w,onChange:k=>{const D=k.target.value.replace("#","");z(D.toUpperCase());const W=fe(`#${D}`);if(W){const G=Z(W);I(G),n==null||n(Be(W))}},spellCheck:!1,placeholder:"000000",maxLength:8,style:{flex:1}}),e.jsx(te,{size:"sm",type:"number",suffix:"%",value:R,min:0,max:100,onChange:k=>{const D=+k.target.value;!isNaN(D)&&D>=0&&D<=100&&j({...x,a:D/100})},className:"lucent-cp-field",style:{width:68,flexShrink:0}})]}),b==="rgb"&&e.jsx("div",{style:{display:"flex",gap:6},children:[{label:"R",val:P.r,max:255,fn:k=>j(Z({...P,r:k}))},{label:"G",val:P.g,max:255,fn:k=>j(Z({...P,g:k}))},{label:"B",val:P.b,max:255,fn:k=>j(Z({...P,b:k}))},{label:"A",val:R,max:100,fn:k=>j({...x,a:k/100})}].map(({label:k,val:D,max:W,fn:G})=>e.jsx(te,{size:"sm",type:"number",prefix:k,value:D,min:0,max:W,onChange:K=>{const _=+K.target.value;!isNaN(_)&&_>=0&&_<=W&&G(_)},className:"lucent-cp-field",style:{flex:1}},k))}),b==="hsl"&&e.jsx("div",{style:{display:"flex",gap:6},children:[{label:"H",val:$.h,max:360,fn:k=>{const{r:D,g:W,b:G}=xe(k,$.s,$.l);j(Z({r:D,g:W,b:G,a:x.a}))}},{label:"S",val:$.s,max:100,fn:k=>{const{r:D,g:W,b:G}=xe($.h,k,$.l);j(Z({r:D,g:W,b:G,a:x.a}))}},{label:"L",val:$.l,max:100,fn:k=>{const{r:D,g:W,b:G}=xe($.h,$.s,k);j(Z({r:D,g:W,b:G,a:x.a}))}},{label:"A",val:R,max:100,fn:k=>j({...x,a:k/100})}].map(({label:k,val:D,max:W,fn:G})=>e.jsx(te,{size:"sm",type:"number",prefix:k,value:D,min:0,max:W,onChange:K=>{const _=+K.target.value;!isNaN(_)&&_>=0&&_<=W&&G(_)},className:"lucent-cp-field",style:{flex:1}},k))}),b==="hsb"&&e.jsx("div",{style:{display:"flex",gap:6},children:[{label:"H",val:x.h,max:360,fn:k=>j({...x,h:k})},{label:"S",val:x.s,max:100,fn:k=>j({...x,s:k})},{label:"B",val:x.v,max:100,fn:k=>j({...x,v:k})},{label:"A",val:R,max:100,fn:k=>j({...x,a:k/100})}].map(({label:k,val:D,max:W,fn:G})=>e.jsx(te,{size:"sm",type:"number",prefix:k,value:D,min:0,max:W,onChange:K=>{const _=+K.target.value;!isNaN(_)&&_>=0&&_<=W&&G(_)},className:"lucent-cp-field",style:{flex:1}},k))}),s.length>0&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[s.length>1&&e.jsx(We,{size:"sm",value:String(v),onChange:k=>S(Number(k.target.value)),options:s.map((k,D)=>({value:String(D),label:k.label}))}),s.length===1&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:(E=s[0])==null?void 0:E.label}),e.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:(((U=s[v])==null?void 0:U.colors)??[]).map(k=>{const D=He(k).toLowerCase()===X.slice(0,7).toLowerCase();return e.jsx(le,{color:k,selected:D,onClick:()=>j(Z(At(k)))},k)})})]})]})]}),l??document.body)]})}qt.displayName="ColorPicker";const Wa={id:"color-picker",name:"ColorPicker",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A color swatch button that opens a popover with preset swatches and HEX / RGB / RGBA / HSL inputs.",designIntent:"ColorPicker surfaces color selection without navigating away. The swatch button shows the current color at a glance; the popover provides precise input through four format modes. Presets accelerate common choices — provide a curated palette relevant to the product. Always pair with a visible label so the purpose of the picker is clear.",props:[{name:"value",type:"string",required:!1,description:"Controlled color value. Accepts hex (#rrggbb / #rrggbbaa), rgb(), rgba(), or hsl() strings."},{name:"onChange",type:"function",required:!1,description:"Called with the new hex string (#rrggbb, or #rrggbbaa when alpha < 1) whenever the color changes."},{name:"label",type:"string",required:!1,description:"Visible label rendered above the swatch button."},{name:"presets",type:"string[]",required:!1,description:"Array of hex color strings shown as clickable swatches. Defaults to a 16-color palette."},{name:"size",type:"string",required:!1,default:'"md"',description:'Swatch trigger size. "sm" renders a 24px swatch, "md" renders 40px.'},{name:"inline",type:"boolean",required:!1,default:"false",description:"Places the label beside the swatch instead of above it. Useful for compact layouts."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Prevents interaction and dims the label."},{name:"portalContainer",type:"HTMLElement | null",required:!1,description:"DOM element to portal the popover into. Defaults to document.body. Set this to a wrapper element to preserve CSS custom property inheritance for per-section theming."},{name:"id",type:"string",required:!1,description:"HTML id for the swatch button. Auto-generated if omitted."},{name:"style",type:"CSSProperties",required:!1,description:"Inline styles applied to the outer wrapper."}],usageExamples:[{title:"Basic controlled",code:`const [color, setColor] = useState('#3b82f6');
|
|
196
196
|
<ColorPicker value={color} onChange={setColor} label="Brand color" />`},{title:"Custom presets",code:`<ColorPicker
|
|
197
197
|
value={accent}
|
|
198
198
|
onChange={setAccent}
|
|
199
199
|
label="Accent"
|
|
200
200
|
presets={['#111827', '#3b82f6', '#8b5cf6', '#ec4899', '#ef4444', '#f97316', '#22c55e']}
|
|
201
|
-
/>`},{title:"No presets",code:'<ColorPicker value={color} onChange={setColor} presets={[]} label="Custom color" />'},{title:"Disabled",code:'<ColorPicker value="#6b7280" disabled label="Theme color" />'}],compositionGraph:[],accessibility:{role:"button (trigger) + dialog (popover)",ariaAttributes:["aria-expanded","aria-haspopup","aria-label"],keyboardInteractions:["Enter / Space — opens the color picker popover","Escape / click outside — closes the popover","Tab — moves through format tabs and input fields within the popover"]}},
|
|
201
|
+
/>`},{title:"No presets",code:'<ColorPicker value={color} onChange={setColor} presets={[]} label="Custom color" />'},{title:"Disabled",code:'<ColorPicker value="#6b7280" disabled label="Theme color" />'}],compositionGraph:[],accessibility:{role:"button (trigger) + dialog (popover)",ariaAttributes:["aria-expanded","aria-haspopup","aria-label"],keyboardInteractions:["Enter / Space — opens the color picker popover","Escape / click outside — closes the popover","Tab — moves through format tabs and input fields within the popover"]}},Oa={id:"color-swatch",name:"ColorSwatch",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A circular color swatch that can be static or interactive.",designIntent:"ColorSwatch is the smallest unit of color representation in the system. Use it wherever a color needs to be shown at a glance — palette pickers, token lists, or inline color indicators. The selected state shows an accent-colored ring to indicate the active choice.",props:[{name:"color",type:"string",required:!0,description:"CSS color value to display."},{name:"size",type:"'sm' | 'md' | 'lg'",required:!1,default:"'md'",description:"Swatch diameter: sm=16px, md=22px, lg=28px."},{name:"selected",type:"boolean",required:!1,default:"false",description:"Shows an accent ring when true."},{name:"onClick",type:"function",required:!1,description:"Click handler. Omit for a non-interactive display swatch."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Dims the swatch and prevents interaction."},{name:"title",type:"string",required:!1,description:"Tooltip text. Defaults to the color value."},{name:"style",type:"CSSProperties",required:!1,description:"Inline styles applied to the swatch button."}],usageExamples:[{title:"Static palette",code:`['#ef4444', '#f97316', '#22c55e'].map(c => (
|
|
202
202
|
<ColorSwatch key={c} color={c} />
|
|
203
|
-
))`},{title:"Selectable swatch",code:`<ColorSwatch color="#3b82f6" selected={active === '#3b82f6'} onClick={() => setActive('#3b82f6')} />`}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["title (tooltip)"],keyboardInteractions:["Enter / Space — triggers onClick"]}},
|
|
203
|
+
))`},{title:"Selectable swatch",code:`<ColorSwatch color="#3b82f6" selected={active === '#3b82f6'} onClick={() => setActive('#3b82f6')} />`}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["title (tooltip)"],keyboardInteractions:["Enter / Space — triggers onClick"]}},Ha={id:"segmented-control",name:"SegmentedControl",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A pill-group selector where exactly one option is always active, with a sliding indicator.",designIntent:"Use SegmentedControl for mutually exclusive view switches or mode selectors that have 2–5 options and where all options should be visible simultaneously (unlike Select). Common uses: view mode (Grid / List / Table), time range (Day / Week / Month), format picker (Hex / RGB / HSL). Keep labels short (1–2 words) so the control stays compact. For more than 5 options or dynamic option lists, prefer Select.",props:[{name:"options",type:"SegmentedOption[]",required:!0,description:"Array of { value, label, disabled? }. 2–5 options recommended."},{name:"value",type:"string",required:!1,description:"Controlled selected value. Pair with onChange."},{name:"defaultValue",type:"string",required:!1,description:"Initial value for uncontrolled usage. Defaults to the first option."},{name:"onChange",type:"function",required:!1,description:"Called with the newly selected value."},{name:"size",type:"enum",required:!1,default:"md",description:"Height and font size of the control.",enumValues:["sm","md","lg"]},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables all options."},{name:"fullWidth",type:"boolean",required:!1,default:"false",description:"Stretches the control to fill its container, distributing options equally."}],usageExamples:[{title:"Controlled",code:`const [view, setView] = useState('grid');
|
|
204
204
|
<SegmentedControl
|
|
205
205
|
value={view}
|
|
206
206
|
onChange={setView}
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
]}
|
|
219
219
|
/>`},{title:"Full-width, sizes",code:`<SegmentedControl fullWidth size="sm" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />
|
|
220
220
|
<SegmentedControl fullWidth size="md" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />
|
|
221
|
-
<SegmentedControl fullWidth size="lg" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />`}],compositionGraph:[],accessibility:{role:"group (radiogroup)",ariaAttributes:["aria-checked",'role="radio"',"disabled"],keyboardInteractions:["Tab — focuses the group","Click — selects an option"]}};function
|
|
221
|
+
<SegmentedControl fullWidth size="lg" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />`}],compositionGraph:[],accessibility:{role:"group (radiogroup)",ariaAttributes:["aria-checked",'role="radio"',"disabled"],keyboardInteractions:["Tab — focuses the group","Click — selects an option"]}};function Va({label:t,htmlFor:n,required:r=!1,helperText:o,errorMessage:a,children:i,style:s}){const l=a??o,c=a?"danger":"secondary";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)",...s},children:[t&&e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--lucent-space-1)"},children:[e.jsx(O,{as:"label",size:"sm",weight:"medium",lineHeight:"tight",...n!==void 0&&{htmlFor:n},children:t}),r&&e.jsx(O,{as:"span",size:"sm",color:"danger",lineHeight:"tight","aria-hidden":"true",children:"*"})]}),i,l&&e.jsx(O,{size:"xs",color:c,lineHeight:"tight",children:l})]})}const Ua={id:"form-field",name:"FormField",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"Wraps any form control (Input, Select, Textarea) with a label, helper text, and validation message.",designIntent:"FormField standardises the vertical rhythm around form controls. A label is linked to the control via htmlFor so screen readers announce it correctly. The required asterisk is decorative (aria-hidden) because the actual required state should be communicated on the input via aria-required. Helper text provides proactive guidance; errorMessage replaces it when validation fails, using danger color to draw attention. The gap between elements uses space-2 to create a tight but breathable stack.",props:[{name:"label",type:"string",required:!1,description:"Label text rendered above the control as a <label> element."},{name:"htmlFor",type:"string",required:!1,description:"ID of the form control this label describes. Forwarded to the label htmlFor attribute."},{name:"required",type:"boolean",required:!1,default:"false",description:"Appends a danger-colored asterisk after the label text."},{name:"helperText",type:"string",required:!1,description:"Secondary text below the control providing guidance. Hidden when errorMessage is set."},{name:"errorMessage",type:"string",required:!1,description:"Validation error shown in danger color below the control. Replaces helperText when set."},{name:"children",type:"ReactNode",required:!0,description:"The form control to wrap — typically Input, Select, or Textarea."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Basic field",code:`<FormField label="Email" htmlFor="email">
|
|
222
222
|
<Input id="email" placeholder="you@example.com" />
|
|
223
223
|
</FormField>`},{title:"Required with helper",code:`<FormField label="Username" htmlFor="username" required helperText="Letters and numbers only">
|
|
224
224
|
<Input id="username" />
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
<Input id="pw" type="password" />
|
|
227
227
|
</FormField>`},{title:"Wrapping a Select",code:`<FormField label="Country" htmlFor="country">
|
|
228
228
|
<Select id="country" options={countryOptions} />
|
|
229
|
-
</FormField>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Label, helper text, and error message",required:!1}],accessibility:{ariaAttributes:["aria-required","aria-describedby"],notes:'Link the wrapped control to an error message using aria-describedby on the control and a matching id on the error element for full screen reader support. The required asterisk is aria-hidden; set aria-required="true" on the control itself.'}},
|
|
229
|
+
</FormField>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Label, helper text, and error message",required:!1}],accessibility:{ariaAttributes:["aria-required","aria-describedby"],notes:'Link the wrapped control to an error message using aria-describedby on the control and a matching id on the error element for full screen reader support. The required asterisk is aria-hidden; set aria-required="true" on the control itself.'}},Ga={sm:14,md:18,lg:20},_a=({size:t=16})=>e.jsxs("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"6.5",cy:"6.5",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M9.5 9.5L13 13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ya=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M3 3L11 11M11 3L3 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function Ka({value:t,onChange:n,placeholder:r="Search…",size:o="md",label:a,helperText:i,errorText:s,results:l=[],onResultSelect:c,isLoading:d=!1,disabled:u=!1,id:h,style:m}){const[g,C]=p.useState(!1),[b,f]=p.useState(null),v=p.useRef(null),S=g&&l.length>0,x=()=>{n("")},I=T=>{c==null||c(T),C(!1)},w=()=>{v.current=setTimeout(()=>C(!1),150)},z=()=>{v.current&&clearTimeout(v.current),C(!0)},q=d?e.jsx(Dt,{size:"sm"}):t?e.jsx("button",{type:"button","aria-label":"Clear search",onClick:x,style:{display:"flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",padding:2,borderRadius:"var(--lucent-radius-sm)",color:"var(--lucent-text-secondary)"},onMouseEnter:T=>{T.currentTarget.style.color="var(--lucent-text-primary)"},onMouseLeave:T=>{T.currentTarget.style.color="var(--lucent-text-secondary)"},children:e.jsx(Ya,{})}):null;return e.jsxs("div",{style:{position:"relative",...m},children:[e.jsx(te,{id:h,type:"search",size:o,value:t,onChange:T=>n(T.target.value),placeholder:r,disabled:u,leftElement:e.jsx(_a,{size:Ga[o]}),rightElement:q??void 0,onFocus:z,onBlur:w,...a!==void 0&&{label:a},...i!==void 0&&{helperText:i},...s!==void 0&&{errorText:s}}),S&&e.jsx("div",{role:"listbox",style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,right:0,zIndex:50,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-md)",boxShadow:"var(--lucent-shadow-md)",overflow:"hidden"},children:l.map((T,M)=>e.jsx("div",{role:"option","aria-selected":!1,onMouseDown:()=>I(T),onMouseEnter:()=>f(M),onMouseLeave:()=>f(null),style:{padding:"var(--lucent-space-2) var(--lucent-space-3)",cursor:"pointer",background:b===M?"var(--lucent-surface-secondary)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:e.jsx(O,{as:"span",size:"md",children:T.label})},T.id))})]})}const Xa={id:"search-input",name:"SearchInput",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A search field with a built-in magnifier icon, clear button, and an optional results dropdown.",designIntent:"SearchInput is intentionally dumb about filtering — the consumer passes already-filtered results so the component stays stateless and flexible. The clear button appears only when the input has a value, keeping the right side clean at rest. The results dropdown is rendered absolutely below the input and closes after a 150ms delay on blur to allow result clicks to register before focus is lost. Spinner replaces the clear button during loading to communicate async state without layout shift.",props:[{name:"value",type:"string",required:!0,description:"Controlled input value."},{name:"onChange",type:"function",required:!0,description:"Called with the new string value whenever the input changes."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls height and font size. Passed to the underlying Input.",enumValues:["sm","md","lg"]},{name:"label",type:"string",required:!1,description:"Visible label above the search field. Passed to the underlying Input."},{name:"helperText",type:"string",required:!1,description:"Hint text below the field. Passed to the underlying Input."},{name:"errorText",type:"string",required:!1,description:"Validation error text. Triggers error styling on the underlying Input."},{name:"placeholder",type:"string",required:!1,default:'"Search…"',description:"Placeholder text for the input."},{name:"results",type:"array",required:!1,default:"[]",description:"Pre-filtered list of SearchResult objects ({ id, label }) to display in the dropdown."},{name:"onResultSelect",type:"function",required:!1,description:"Called with the selected SearchResult when a dropdown item is clicked."},{name:"isLoading",type:"boolean",required:!1,default:"false",description:"Shows a spinner in the right slot to indicate async search in progress."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the input."},{name:"id",type:"string",required:!1,description:"HTML id forwarded to the underlying input element."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Basic controlled search",code:`const [query, setQuery] = useState('');
|
|
230
230
|
const [results, setResults] = useState([]);
|
|
231
231
|
|
|
232
232
|
<SearchInput
|
|
@@ -234,7 +234,7 @@ const [results, setResults] = useState([]);
|
|
|
234
234
|
onChange={(v) => { setQuery(v); setResults(filter(v)); }}
|
|
235
235
|
results={results}
|
|
236
236
|
onResultSelect={(r) => console.log(r)}
|
|
237
|
-
/>`},{title:"Loading state",code:"<SearchInput value={query} onChange={setQuery} isLoading={isFetching} results={[]} />"}],compositionGraph:[{componentId:"input",componentName:"Input",role:"Search text field with icon slots",required:!0},{componentId:"spinner",componentName:"Spinner",role:"Loading indicator in the right slot",required:!1}],accessibility:{role:"combobox",ariaAttributes:["aria-expanded","aria-haspopup","aria-label"],keyboardInteractions:["Enter to select focused result","Escape to close dropdown"],notes:'The results list uses role="listbox" with role="option" items. For full keyboard navigation (arrow keys to move between results), wire up onKeyDown on the Input and manage an activeIndex state.'}},Rt=p.createContext("0"),_a={none:{py:"0",px:"0"},sm:{py:"var(--lucent-space-2)",px:"var(--lucent-space-3)"},md:{py:"var(--lucent-space-4)",px:"var(--lucent-space-5)"},lg:{py:"var(--lucent-space-6)",px:"var(--lucent-space-8)"}},he={none:"var(--lucent-shadow-none)",sm:"var(--lucent-shadow-sm)",md:"var(--lucent-shadow-md)",lg:"var(--lucent-shadow-lg)"},Ya={none:"var(--lucent-radius-none)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-lg)"},Ka={success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"},Xa={ghost:{background:"transparent",border:"none",shadowDefault:"none",dividers:!0},outline:{background:"transparent",border:"1px solid var(--lucent-border-default)",shadowDefault:"none",dividers:!0},filled:{background:"var(--lucent-surface-tint)",border:"none",shadowDefault:"none",dividers:!0},elevated:{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",shadowDefault:"md",dividers:!0},combo:{background:"var(--lucent-surface-tint)",border:"none",shadowDefault:"none",dividers:!1}},Ja=["transform 80ms var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)","border-color var(--lucent-duration-fast) var(--lucent-easing-default)","background var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),Za="0 4px 14px -2px var(--lucent-accent-subtle)",Qa="0 0 0 3px var(--lucent-accent-subtle)",er="0 0 0 2px var(--lucent-surface), 0 0 0 4px var(--lucent-accent-default)",tr="0 0 0 3px var(--lucent-accent-subtle)";function se(...e){const n=e.filter(r=>r!=null&&r!=="none"&&r!=="var(--lucent-shadow-none)");return n.length>0?n.join(", "):void 0}function nr(e,n,r){return!n||r?e.background:e.background==="transparent"?"var(--lucent-accent-subtle)":`color-mix(in srgb, var(--lucent-accent-default) 6%, ${e.background})`}function ar({variant:e="outline",header:n,footer:r,children:o,padding:a="md",shadow:s,radius:i="md",style:l,onClick:c,href:d,target:u,rel:h,disabled:m,status:g,selected:C,media:y}){const f=Xa[e],v=e==="combo",b=s??(v?"md":f.shadowDefault),{py:T,px:D}=_a[a],x=`${T} ${D}`,M=Ya[i],P=d!=null,k=c!=null||P,j=(m??!1)&&k,W=P?"a":k?"button":"div",[R,z]=p.useState(!1),[F,B]=p.useState(!1),[$,U]=p.useState(!1),K=(C??!1)&&!j,I=K?tr:void 0,N=nr(f,C??!1,j);let S;v?S=I:k&&!j?$?S=se(er,I):F?S=se(Qa,I):R?S=se(Za,he[b],I):S=se(he[b],I):S=se(he[b],I);const E={display:"flex",flexDirection:"column",background:N,border:f.border,borderRadius:M,overflow:K||k&&F?"visible":"hidden",boxSizing:"border-box",position:"relative",...S!==void 0&&{boxShadow:S},...k&&!j&&$&&{transform:"translateY(1px)"},...k&&!j&&R&&!$&&{transform:"translateY(-1px)"},...k&&{cursor:j?"not-allowed":"pointer",outline:"none",transition:Ja},...k&&!P&&{padding:0,font:"inherit",textAlign:"inherit",width:"100%",background:N},...P&&{textDecoration:"none",color:"inherit"},...j&&{opacity:.6,pointerEvents:"none"},...l},L=k&&!j?{onMouseEnter:()=>z(!0),onMouseLeave:()=>{z(!1),U(!1)},onMouseDown:()=>U(!0),onMouseUp:()=>U(!1),onFocus:()=>B(!0),onBlur:()=>{B(!1),U(!1)}}:{};return t.jsxs(W,{style:E,...L,...P&&{href:j?void 0:d,...u!==void 0&&{target:u},...h!==void 0&&{rel:h}},...!P&&k&&{type:"button",...j&&{disabled:!0}},...c!==void 0&&!j&&{onClick:c},...k&&C!==void 0&&{"aria-pressed":C},...P&&j&&{"aria-disabled":!0},children:[y!=null&&t.jsx("div",{style:{lineHeight:0},children:y}),g!=null&&t.jsx("div",{"aria-hidden":!0,style:{position:"absolute",top:0,left:0,bottom:0,width:3,background:Ka[g],zIndex:1}}),n!=null&&t.jsx("div",{style:{padding:x,...f.dividers?{borderBottom:"1px solid var(--lucent-border-default)"}:{}},children:n}),t.jsx(Rt.Provider,{value:D,children:t.jsx("div",{style:{padding:x,flex:1,...v?{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:M,boxShadow:he[b],marginLeft:`calc(${D} / 3)`,marginRight:`calc(${D} / 3)`}:{}},children:o})}),r!=null&&t.jsx("div",{style:{padding:x,...f.dividers?{borderTop:"1px solid var(--lucent-border-default)"}:{}},children:r})]})}function rr({children:e,style:n}){const r=p.useContext(Rt);return t.jsx("div",{style:{marginLeft:`calc(-1 * ${r})`,marginRight:`calc(-1 * ${r})`,paddingLeft:r,paddingRight:r,...n},children:e})}const or={id:"card",name:"Card",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A surface container with five elevation variants that form a visual importance hierarchy. Supports optional header, body, and footer slots with configurable padding, shadow, and radius. Includes a CardBleed sub-component for edge-to-edge content.",designIntent:'Card provides a configurable surface with an explicit elevation hierarchy. Each variant maps to a distinct level of visual prominence, giving consumers a single prop to express how much attention a surface should command relative to its surroundings.\n\n## Elevation hierarchy (lowest → highest)\n\n1. **ghost** — transparent background, no border, no shadow.\n The card is invisible as a container — content floats directly against the page or parent surface. Use for logical groupings that shouldn\'t compete visually: sidebar sections, form regions, or layout slots where structure exists conceptually but not visually. Header/footer dividers still render if those slots are used, providing minimal internal structure.\n\n2. **outline** (default) — transparent background with `border-default` border, no shadow.\n Like ghost, the card inherits its container\'s background — the border alone defines the boundary. This is the workhorse variant for lists of items, form sections, data panels, and any content that needs a visible container without drawing excessive attention. Header and footer slots are separated from the body by matching `border-default` dividers.\n\n3. **filled** — semi-transparent tinted background, no border, no shadow.\n Differentiates the card from its surroundings by darkening (light mode) or lightening (dark mode) whatever surface it sits on. Uses `color-mix(in srgb, textPrimary 6%, transparent)` so the tint is always relative to the container — never a fixed color. Use for secondary content areas, inset panels, summary blocks, or anywhere a border would feel heavy but the card needs to be visually distinct. Effective for nesting (e.g., a filled card inside an elevated card creates a recessed region).\n\n4. **elevated** — `surface` background with medium shadow, no border.\n The card lifts off the page through depth. The shadow creates a physical metaphor: this content sits above the surface it rests on. Use for primary content areas, feature highlights, pricing cards, or any surface that should feel physically elevated. The lack of border keeps the silhouette soft — the shadow alone defines the boundary.\n\n5. **combo** — transparent wrapper with an elevated body inset.\n The header and footer are flat — they blend into the page background as if they were part of it. Only the body section is elevated: it gets `surface` background, border-radius, and shadow, appearing as a raised card sitting between the flat header/footer regions. This draws the eye to the primary content while keeping supporting info (header) and actions (footer) visually subordinate — they frame the elevated body without competing with it. No dividers are rendered — the elevation change IS the visual separator. Use for detail panels, profile cards, or settings forms where the body content is the focal point.\n\n## Shadow override\nThe `shadow` prop overrides whatever shadow the variant implies. This allows fine-tuning without changing the variant. For example, `variant="elevated" shadow="lg"` gives an elevated card with extra depth, while `variant="outline" shadow="none"` gives a flat bordered card.\n\n## Token rules\n- `elevated` and `combo` body use `surface` (the primary component surface — white in light mode).\n- `filled` uses a semi-transparent tint of `textPrimary` — contextually darker/lighter than its container.\n- `combo` wrapper is transparent (header/footer blend with page); only the body is elevated with `surface`.\n- `ghost` and `outline` use `transparent` — they inherit from whatever they\'re placed on. The border is the only visual differentiator for `outline`.\n- Never use `bgBase` or `bgSubtle` on a Card — those tokens are reserved for the page canvas.\n- Content nested inside a Card that needs a tinted fill should use `surfaceSecondary`.',props:[{name:"variant",type:"enum",required:!1,default:"outline",description:"The elevation variant. Controls background color, border, and default shadow. Ordered from lowest to highest visual prominence: ghost → outline → filled → elevated → combo.",enumValues:["ghost","outline","filled","elevated","combo"]},{name:"children",type:"ReactNode",required:!0,description:"The card body content."},{name:"header",type:"ReactNode",required:!1,description:"Content rendered in the header slot. Separated from the body by a divider in all variants except combo, where the background-color change provides the separation."},{name:"footer",type:"ReactNode",required:!1,description:"Content rendered in the footer slot. Separated from the body by a divider in all variants except combo, where the background-color change provides the separation."},{name:"padding",type:"enum",required:!1,default:"md",description:"Inner padding applied equally to header, body, and footer.",enumValues:["none","sm","md","lg"]},{name:"shadow",type:"enum",required:!1,description:"Box shadow elevation. When omitted, uses the variant's default: ghost=none, outline=none, filled=none, elevated=md, combo=md. When set explicitly, overrides the variant's default.",enumValues:["none","sm","md","lg"]},{name:"radius",type:"enum",required:!1,default:"md",description:"Border radius of the card.",enumValues:["none","sm","md","lg"]},{name:"style",type:"object",required:!1,description:"Inline style overrides for the card wrapper."},{name:"onClick",type:"function",required:!1,description:"Click handler. When provided, the card renders as a <button> with hover lift, focus ring, and active press states matching the Button component."},{name:"href",type:"string",required:!1,description:"Link URL. When provided, the card renders as an <a>. Takes precedence over onClick for the element type, but onClick is still attached as a handler."},{name:"target",type:"string",required:!1,description:'Passed to <a> when href is set (e.g. "_blank").'},{name:"rel",type:"string",required:!1,description:'Passed to <a> when href is set (e.g. "noopener noreferrer").'},{name:"disabled",type:"boolean",required:!1,description:"Disables interactive behavior. Reduces opacity, removes hover/focus/active states, and sets cursor to not-allowed. Only applies when onClick or href is set."},{name:"status",type:"enum",required:!1,description:"Adds a 3px colored accent bar on the left edge of the card. Uses the corresponding status token (successDefault, warningDefault, dangerDefault, infoDefault). Works with all variants.",enumValues:["success","warning","danger","info"]},{name:"selected",type:"boolean",required:!1,description:"Adds an inset accent ring and subtle background tint to indicate selection. Used for card grids where cards act as radio/checkbox options. Pairs with onClick for toggle behavior. Sets aria-pressed on interactive cards. Disabled takes precedence — ring is hidden when disabled."},{name:"media",type:"ReactNode",required:!1,description:"Full-bleed content rendered at the top of the card (before header). No padding is applied. Use for hero images, illustrations, or any edge-to-edge top content. The card's overflow:hidden clips media to the border-radius."}],usageExamples:[{title:"Ghost — invisible container",code:`<Card variant="ghost">
|
|
237
|
+
/>`},{title:"Loading state",code:"<SearchInput value={query} onChange={setQuery} isLoading={isFetching} results={[]} />"}],compositionGraph:[{componentId:"input",componentName:"Input",role:"Search text field with icon slots",required:!0},{componentId:"spinner",componentName:"Spinner",role:"Loading indicator in the right slot",required:!1}],accessibility:{role:"combobox",ariaAttributes:["aria-expanded","aria-haspopup","aria-label"],keyboardInteractions:["Enter to select focused result","Escape to close dropdown"],notes:'The results list uses role="listbox" with role="option" items. For full keyboard navigation (arrow keys to move between results), wire up onKeyDown on the Input and manage an activeIndex state.'}},Bt=p.createContext("0"),Ja={none:{py:"0",px:"0"},sm:{py:"var(--lucent-space-2)",px:"var(--lucent-space-3)"},md:{py:"var(--lucent-space-4)",px:"var(--lucent-space-5)"},lg:{py:"var(--lucent-space-6)",px:"var(--lucent-space-8)"}},he={none:"var(--lucent-shadow-none)",sm:"var(--lucent-shadow-sm)",md:"var(--lucent-shadow-md)",lg:"var(--lucent-shadow-lg)"},Za={none:"var(--lucent-radius-none)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-lg)"},Qa={success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"},er={ghost:{background:"transparent",border:"none",shadowDefault:"none",dividers:!0},outline:{background:"transparent",border:"1px solid var(--lucent-border-default)",shadowDefault:"none",dividers:!0},filled:{background:"var(--lucent-surface-tint)",border:"none",shadowDefault:"none",dividers:!0},elevated:{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",shadowDefault:"md",dividers:!0},combo:{background:"var(--lucent-surface-tint)",border:"none",shadowDefault:"none",dividers:!1}},tr=["transform 80ms var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)","border-color var(--lucent-duration-fast) var(--lucent-easing-default)","background var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", "),nr="0 4px 14px -2px var(--lucent-accent-subtle)",ar="0 0 0 3px var(--lucent-accent-subtle)",rr="0 0 0 2px var(--lucent-surface), 0 0 0 4px var(--lucent-accent-default)",or="0 0 0 3px var(--lucent-accent-subtle)";function ie(...t){const n=t.filter(r=>r!=null&&r!=="none"&&r!=="var(--lucent-shadow-none)");return n.length>0?n.join(", "):void 0}function ir(t,n,r){return!n||r?t.background:t.background==="transparent"?"var(--lucent-accent-subtle)":`color-mix(in srgb, var(--lucent-accent-default) 6%, ${t.background})`}function sr({variant:t="outline",header:n,footer:r,children:o,padding:a="md",shadow:i,radius:s="md",style:l,onClick:c,href:d,target:u,rel:h,disabled:m,status:g,selected:C,media:b}){const f=er[t],v=t==="combo",S=i??(v?"md":f.shadowDefault),{py:x,px:I}=Ja[a],w=`${x} ${I}`,z=Za[s],q=d!=null,T=c!=null||q,M=(m??!1)&&T,F=q?"a":T?"button":"div",[N,j]=p.useState(!1),[B,L]=p.useState(!1),[P,$]=p.useState(!1),X=(C??!1)&&!M,H=X?or:void 0,R=ir(f,C??!1,M);let y;v?y=H:T&&!M?P?y=ie(rr,H):B?y=ie(ar,H):N?y=ie(nr,he[S],H):y=ie(he[S],H):y=ie(he[S],H);const A={display:"flex",flexDirection:"column",background:R,border:f.border,borderRadius:z,overflow:X||T&&B?"visible":"hidden",boxSizing:"border-box",position:"relative",...y!==void 0&&{boxShadow:y},...T&&!M&&P&&{transform:"translateY(1px)"},...T&&!M&&N&&!P&&{transform:"translateY(-1px)"},...T&&{cursor:M?"not-allowed":"pointer",outline:"none",transition:tr},...T&&!q&&{padding:0,font:"inherit",textAlign:"inherit",width:"100%",background:R},...q&&{textDecoration:"none",color:"inherit"},...M&&{opacity:.6,pointerEvents:"none"},...l},E=T&&!M?{onMouseEnter:()=>j(!0),onMouseLeave:()=>{j(!1),$(!1)},onMouseDown:()=>$(!0),onMouseUp:()=>$(!1),onFocus:()=>L(!0),onBlur:()=>{L(!1),$(!1)}}:{};return e.jsxs(F,{style:A,...E,...q&&{href:M?void 0:d,...u!==void 0&&{target:u},...h!==void 0&&{rel:h}},...!q&&T&&{type:"button",...M&&{disabled:!0}},...c!==void 0&&!M&&{onClick:c},...T&&C!==void 0&&{"aria-pressed":C},...q&&M&&{"aria-disabled":!0},children:[b!=null&&e.jsx("div",{style:{lineHeight:0},children:b}),g!=null&&e.jsx("div",{"aria-hidden":!0,style:{position:"absolute",top:0,left:0,bottom:0,width:3,background:Qa[g],zIndex:1}}),n!=null&&e.jsx("div",{style:{padding:w,...f.dividers?{borderBottom:"1px solid var(--lucent-border-default)"}:{}},children:n}),e.jsx(Bt.Provider,{value:I,children:e.jsx("div",{style:{padding:w,flex:1,...v?{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:z,boxShadow:he[S],marginLeft:`calc(${I} / 3)`,marginRight:`calc(${I} / 3)`}:{}},children:o})}),r!=null&&e.jsx("div",{style:{padding:w,...f.dividers?{borderTop:"1px solid var(--lucent-border-default)"}:{}},children:r})]})}function lr({children:t,style:n}){const r=p.useContext(Bt);return e.jsx("div",{style:{marginLeft:`calc(-1 * ${r})`,marginRight:`calc(-1 * ${r})`,paddingLeft:r,paddingRight:r,...n},children:t})}const cr={id:"card",name:"Card",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A surface container with five elevation variants that form a visual importance hierarchy. Supports optional header, body, and footer slots with configurable padding, shadow, and radius. Includes a CardBleed sub-component for edge-to-edge content.",designIntent:'Card provides a configurable surface with an explicit elevation hierarchy. Each variant maps to a distinct level of visual prominence, giving consumers a single prop to express how much attention a surface should command relative to its surroundings.\n\n## Elevation hierarchy (lowest → highest)\n\n1. **ghost** — transparent background, no border, no shadow.\n The card is invisible as a container — content floats directly against the page or parent surface. Use for logical groupings that shouldn\'t compete visually: sidebar sections, form regions, or layout slots where structure exists conceptually but not visually. Header/footer dividers still render if those slots are used, providing minimal internal structure.\n\n2. **outline** (default) — transparent background with `border-default` border, no shadow.\n Like ghost, the card inherits its container\'s background — the border alone defines the boundary. This is the workhorse variant for lists of items, form sections, data panels, and any content that needs a visible container without drawing excessive attention. Header and footer slots are separated from the body by matching `border-default` dividers.\n\n3. **filled** — semi-transparent tinted background, no border, no shadow.\n Differentiates the card from its surroundings by darkening (light mode) or lightening (dark mode) whatever surface it sits on. Uses `color-mix(in srgb, textPrimary 6%, transparent)` so the tint is always relative to the container — never a fixed color. Use for secondary content areas, inset panels, summary blocks, or anywhere a border would feel heavy but the card needs to be visually distinct. Effective for nesting (e.g., a filled card inside an elevated card creates a recessed region).\n\n4. **elevated** — `surface` background with medium shadow, no border.\n The card lifts off the page through depth. The shadow creates a physical metaphor: this content sits above the surface it rests on. Use for primary content areas, feature highlights, pricing cards, or any surface that should feel physically elevated. The lack of border keeps the silhouette soft — the shadow alone defines the boundary.\n\n5. **combo** — transparent wrapper with an elevated body inset.\n The header and footer are flat — they blend into the page background as if they were part of it. Only the body section is elevated: it gets `surface` background, border-radius, and shadow, appearing as a raised card sitting between the flat header/footer regions. This draws the eye to the primary content while keeping supporting info (header) and actions (footer) visually subordinate — they frame the elevated body without competing with it. No dividers are rendered — the elevation change IS the visual separator. Use for detail panels, profile cards, or settings forms where the body content is the focal point.\n\n## Shadow override\nThe `shadow` prop overrides whatever shadow the variant implies. This allows fine-tuning without changing the variant. For example, `variant="elevated" shadow="lg"` gives an elevated card with extra depth, while `variant="outline" shadow="none"` gives a flat bordered card.\n\n## Token rules\n- `elevated` and `combo` body use `surface` (the primary component surface — white in light mode).\n- `filled` uses a semi-transparent tint of `textPrimary` — contextually darker/lighter than its container.\n- `combo` wrapper is transparent (header/footer blend with page); only the body is elevated with `surface`.\n- `ghost` and `outline` use `transparent` — they inherit from whatever they\'re placed on. The border is the only visual differentiator for `outline`.\n- Never use `bgBase` or `bgSubtle` on a Card — those tokens are reserved for the page canvas.\n- Content nested inside a Card that needs a tinted fill should use `surfaceSecondary`.',props:[{name:"variant",type:"enum",required:!1,default:"outline",description:"The elevation variant. Controls background color, border, and default shadow. Ordered from lowest to highest visual prominence: ghost → outline → filled → elevated → combo.",enumValues:["ghost","outline","filled","elevated","combo"]},{name:"children",type:"ReactNode",required:!0,description:"The card body content."},{name:"header",type:"ReactNode",required:!1,description:"Content rendered in the header slot. Separated from the body by a divider in all variants except combo, where the background-color change provides the separation."},{name:"footer",type:"ReactNode",required:!1,description:"Content rendered in the footer slot. Separated from the body by a divider in all variants except combo, where the background-color change provides the separation."},{name:"padding",type:"enum",required:!1,default:"md",description:"Inner padding applied equally to header, body, and footer.",enumValues:["none","sm","md","lg"]},{name:"shadow",type:"enum",required:!1,description:"Box shadow elevation. When omitted, uses the variant's default: ghost=none, outline=none, filled=none, elevated=md, combo=md. When set explicitly, overrides the variant's default.",enumValues:["none","sm","md","lg"]},{name:"radius",type:"enum",required:!1,default:"md",description:"Border radius of the card.",enumValues:["none","sm","md","lg"]},{name:"style",type:"object",required:!1,description:"Inline style overrides for the card wrapper."},{name:"onClick",type:"function",required:!1,description:"Click handler. When provided, the card renders as a <button> with hover lift, focus ring, and active press states matching the Button component."},{name:"href",type:"string",required:!1,description:"Link URL. When provided, the card renders as an <a>. Takes precedence over onClick for the element type, but onClick is still attached as a handler."},{name:"target",type:"string",required:!1,description:'Passed to <a> when href is set (e.g. "_blank").'},{name:"rel",type:"string",required:!1,description:'Passed to <a> when href is set (e.g. "noopener noreferrer").'},{name:"disabled",type:"boolean",required:!1,description:"Disables interactive behavior. Reduces opacity, removes hover/focus/active states, and sets cursor to not-allowed. Only applies when onClick or href is set."},{name:"status",type:"enum",required:!1,description:"Adds a 3px colored accent bar on the left edge of the card. Uses the corresponding status token (successDefault, warningDefault, dangerDefault, infoDefault). Works with all variants.",enumValues:["success","warning","danger","info"]},{name:"selected",type:"boolean",required:!1,description:"Adds an inset accent ring and subtle background tint to indicate selection. Used for card grids where cards act as radio/checkbox options. Pairs with onClick for toggle behavior. Sets aria-pressed on interactive cards. Disabled takes precedence — ring is hidden when disabled."},{name:"media",type:"ReactNode",required:!1,description:"Full-bleed content rendered at the top of the card (before header). No padding is applied. Use for hero images, illustrations, or any edge-to-edge top content. The card's overflow:hidden clips media to the border-radius."}],usageExamples:[{title:"Ghost — invisible container",code:`<Card variant="ghost">
|
|
238
238
|
<Text>Content sits directly on the page background.</Text>
|
|
239
239
|
</Card>`},{title:"Outline — bordered card (default)",code:`<Card
|
|
240
240
|
header={<Text weight="semibold">Card title</Text>}
|
|
@@ -280,11 +280,11 @@ const [results, setResults] = useState([]);
|
|
|
280
280
|
>
|
|
281
281
|
<Text weight="semibold">Article title</Text>
|
|
282
282
|
<Text color="secondary" size="sm">A card with a full-bleed hero image.</Text>
|
|
283
|
-
</Card>`}],compositionGraph:[],accessibility:{notes:"Non-interactive cards have no implicit ARIA role — wrap in <section> or <article> if needed. Interactive cards with onClick render as <button> with focus ring. Interactive cards with href render as <a> with focus ring. Selected cards set aria-pressed on the interactive element. The status accent bar is aria-hidden (decorative). Media slot images should include alt text."}},
|
|
283
|
+
</Card>`}],compositionGraph:[],accessibility:{notes:"Non-interactive cards have no implicit ARIA role — wrap in <section> or <article> if needed. Interactive cards with onClick render as <button> with focus ring. Interactive cards with href render as <a> with focus ring. Selected cards set aria-pressed on the interactive element. The status accent bar is aria-hidden (decorative). Media slot images should include alt text."}},dr={info:{bg:"var(--lucent-info-subtle)",border:"var(--lucent-info-default)",iconColor:"var(--lucent-info-text)",textColor:"info"},success:{bg:"var(--lucent-success-subtle)",border:"var(--lucent-success-default)",iconColor:"var(--lucent-success-text)",textColor:"success"},warning:{bg:"var(--lucent-warning-subtle)",border:"var(--lucent-warning-default)",iconColor:"var(--lucent-warning-text)",textColor:"warning"},danger:{bg:"var(--lucent-danger-subtle)",border:"var(--lucent-danger-default)",iconColor:"var(--lucent-danger-text)",textColor:"danger"}},ur=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 5.5V8.5M8 10.5V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),pr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M5 8L7 10L11 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),fr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M8 2L14.5 13H1.5L8 2Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),hr=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M5.5 5.5L10.5 10.5M10.5 5.5L5.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),mr={info:e.jsx(ur,{}),success:e.jsx(pr,{}),warning:e.jsx(fr,{}),danger:e.jsx(hr,{})},gr=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M3 3L11 11M11 3L3 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})});function vr({variant:t="info",title:n,children:r,onDismiss:o,icon:a,style:i}){const s=dr[t],l=a??mr[t];return e.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-3) var(--lucent-space-4)",background:s.bg,border:`1px solid ${s.border}`,borderRadius:"var(--lucent-radius-md)",boxSizing:"border-box",...i},children:[e.jsx("span",{style:{flexShrink:0,color:s.iconColor,display:"flex",alignItems:"center",paddingTop:2},children:l}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)"},children:[n&&e.jsx(O,{as:"span",size:"sm",weight:"semibold",color:s.textColor,lineHeight:"tight",children:n}),r&&e.jsx(O,{as:"span",size:"sm",color:s.textColor,lineHeight:"base",children:r})]}),o&&e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:o,style:{flexShrink:0,display:"flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",padding:2,borderRadius:"var(--lucent-radius-sm)",color:s.iconColor,opacity:.7},onMouseEnter:c=>{c.currentTarget.style.opacity="1"},onMouseLeave:c=>{c.currentTarget.style.opacity="0.7"},children:e.jsx(gr,{})})]})}const br={id:"alert",name:"Alert",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"An inline feedback banner with info, success, warning, and danger variants, optional title, and dismiss button.",designIntent:'Alert uses role="alert" so screen readers announce the message immediately when it appears. Each variant has a built-in icon that communicates intent visually; the icon can be overridden for custom scenarios. Title and body are both optional — you can show either, both, or just an icon with a body. The dismiss button is only rendered when onDismiss is provided, keeping the layout clean for non-dismissible alerts. All colors use status semantic tokens so they adapt correctly between light and dark themes.',props:[{name:"variant",type:"enum",required:!1,default:"info",description:"Visual and semantic variant of the alert.",enumValues:["info","success","warning","danger"]},{name:"title",type:"string",required:!1,description:"Bold title line rendered above the body."},{name:"children",type:"ReactNode",required:!1,description:"Alert body content — typically a short sentence or ReactNode."},{name:"onDismiss",type:"function",required:!1,description:"When provided, renders a dismiss (×) button and calls this handler on click."},{name:"icon",type:"ReactNode",required:!1,description:"Custom icon to replace the built-in variant icon."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the alert wrapper."}],usageExamples:[{title:"Info with body",code:'<Alert variant="info">Your changes have been saved as a draft.</Alert>'},{title:"With title and dismiss",code:`<Alert variant="danger" title="Payment failed" onDismiss={() => setVisible(false)}>
|
|
284
284
|
Check your card details and try again.
|
|
285
285
|
</Alert>`},{title:"Success confirmation",code:`<Alert variant="success" title="Order placed!">
|
|
286
286
|
You'll receive a confirmation email shortly.
|
|
287
|
-
</Alert>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Title and body content",required:!1}],accessibility:{role:"alert",ariaAttributes:["aria-label"],notes:'role="alert" causes screen readers to announce the content immediately when rendered. For non-urgent status messages, consider using role="status" instead by overriding via style/wrapper.'}};function
|
|
287
|
+
</Alert>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Title and body content",required:!1}],accessibility:{role:"alert",ariaAttributes:["aria-label"],notes:'role="alert" causes screen readers to announce the content immediately when rendered. For non-urgent status messages, consider using role="status" instead by overriding via style/wrapper.'}};function yr({illustration:t,title:n,description:r,action:o,style:a}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--lucent-space-4)",padding:"var(--lucent-space-8)",textAlign:"center",...a},children:[t!=null&&e.jsx("div",{style:{width:64,height:64,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--lucent-text-secondary)"},children:t}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)"},children:[e.jsx(O,{as:"h3",size:"lg",weight:"semibold",align:"center",lineHeight:"tight",children:n}),r&&e.jsx(O,{size:"sm",color:"secondary",align:"center",lineHeight:"relaxed",children:r})]}),o!=null&&e.jsx("div",{children:o})]})}const xr={id:"empty-state",name:"EmptyState",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A centered placeholder shown when a list or page has no content, with an optional illustration, title, description, and CTA.",designIntent:"EmptyState communicates the absence of data in a constructive way. The illustration slot accepts any ReactNode — an Icon atom, a custom SVG, or an image — and constrains it to a 64px square to maintain visual consistency. Title is required to ensure the state is always named; description is optional for additional context. The action slot accepts any ReactNode (typically a Button) so the consumer controls variant and label without prescribing them. The entire layout is center-aligned and padded to sit naturally inside a Card or page section.",props:[{name:"title",type:"string",required:!0,description:'Short headline naming the empty state (e.g. "No results found").'},{name:"illustration",type:"ReactNode",required:!1,description:"Icon, SVG, or image rendered above the title. Constrained to a 64px container."},{name:"description",type:"string",required:!1,description:"Secondary text below the title providing context or next steps."},{name:"action",type:"ReactNode",required:!1,description:"Call-to-action rendered below the description — typically a Button."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"No search results",code:`<EmptyState
|
|
288
288
|
illustration={<Icon size="xl"><SearchIcon /></Icon>}
|
|
289
289
|
title="No results found"
|
|
290
290
|
description="Try adjusting your search or filter to find what you're looking for."
|
|
@@ -295,23 +295,23 @@ const [results, setResults] = useState([]);
|
|
|
295
295
|
action={<Button variant="primary">New project</Button>}
|
|
296
296
|
/>`},{title:"Inside a Card",code:`<Card>
|
|
297
297
|
<EmptyState title="Nothing here" description="Add items to see them listed." />
|
|
298
|
-
</Card>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Title and description",required:!0}],accessibility:{notes:"The title renders as an h3 by default. If EmptyState appears inside a section with its own heading hierarchy, override by passing a Text component as part of a custom layout. Ensure the action element has a descriptive label for screen readers."}},
|
|
298
|
+
</Card>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Title and description",required:!0}],accessibility:{notes:"The title renders as an h3 by default. If EmptyState appears inside a section with its own heading hierarchy, override by passing a Text component as part of a custom layout. Ensure the action element has a descriptive label for screen readers."}},wr={text:"1em",circle:40,rectangle:40},kr={text:"var(--lucent-radius-sm)",circle:"var(--lucent-radius-full)",rectangle:"var(--lucent-radius-md)"};function gt({width:t,height:n,radius:r,animate:o,style:a}){return e.jsx("span",{style:{display:"block",width:typeof t=="number"?`${t}px`:t,height:typeof n=="number"?`${n}px`:n,borderRadius:r,background:o?"linear-gradient(90deg, var(--lucent-surface-secondary) 25%, var(--lucent-surface) 50%, var(--lucent-surface-secondary) 75%)":"var(--lucent-surface-secondary)",backgroundSize:o?"200% 100%":void 0,animation:o?"lucent-skeleton-shimmer 1.6s ease-in-out infinite":void 0,flexShrink:0,...a}})}function Sr({variant:t="rectangle",width:n="100%",height:r,lines:o=1,animate:a=!0,radius:i,style:s}){const l=r??wr[t],c=i??kr[t],d=a?e.jsx("style",{children:`
|
|
299
299
|
@keyframes lucent-skeleton-shimmer {
|
|
300
300
|
0% { background-position: 200% 0; }
|
|
301
301
|
100% { background-position: -200% 0; }
|
|
302
302
|
}
|
|
303
|
-
`}):null;return
|
|
303
|
+
`}):null;return t==="text"&&o>1?e.jsxs(e.Fragment,{children:[d,e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)",...s},children:Array.from({length:o}).map((u,h)=>e.jsx(gt,{width:h===o-1?"70%":n,height:l,radius:c,animate:a},h))})]}):e.jsxs(e.Fragment,{children:[d,e.jsx(gt,{width:t==="circle"?r??40:n,height:l,radius:c,animate:a,...s!==void 0&&{style:s}})]})}const Tr={id:"skeleton",name:"Skeleton",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"Animated placeholder that matches the shape of content while it loads.",designIntent:"Skeleton uses a shimmer animation to communicate that content is loading without showing a spinner. The three variants (text, circle, rectangle) cover the most common content shapes: inline text, avatars/thumbnails, and generic content blocks. The text variant with lines > 1 mimics a paragraph by stacking multiple text skeletons and shortening the last line to 70%, which is a widely recognised convention for body copy placeholders. The shimmer gradient uses bg-muted and bg-subtle so it adapts correctly in both light and dark themes without hard-coded colors.",props:[{name:"variant",type:"enum",required:!1,default:"rectangle",description:"Shape of the skeleton — text (1em tall), circle (equal width/height), or rectangle.",enumValues:["text","circle","rectangle"]},{name:"width",type:"string",required:!1,default:'"100%"',description:"Width of the skeleton. Accepts any CSS value or a number (interpreted as px)."},{name:"height",type:"string",required:!1,description:"Height of the skeleton. Defaults: text=1em, circle=40px, rectangle=40px."},{name:"lines",type:"number",required:!1,default:"1",description:"Number of stacked text lines to render. Only applies to the text variant."},{name:"animate",type:"boolean",required:!1,default:"true",description:"Enables the shimmer animation. Set to false to render a static placeholder."},{name:"radius",type:"string",required:!1,description:"Override the default border-radius for the variant."},{name:"style",type:"object",required:!1,description:"Inline style overrides."}],usageExamples:[{title:"Paragraph placeholder",code:'<Skeleton variant="text" lines={3} />'},{title:"Avatar placeholder",code:'<Skeleton variant="circle" width={40} height={40} />'},{title:"Card placeholder",code:`<Card>
|
|
304
304
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
305
305
|
<Skeleton variant="rectangle" height={160} />
|
|
306
306
|
<Skeleton variant="text" lines={2} />
|
|
307
307
|
<Skeleton variant="text" width="40%" />
|
|
308
308
|
</div>
|
|
309
|
-
</Card>`},{title:"Static (no animation)",code:'<Skeleton variant="rectangle" width={200} height={32} animate={false} />'}],compositionGraph:[],accessibility:{ariaAttributes:["aria-busy","aria-label"],notes:'Wrap loading regions with aria-busy="true" on the container so screen readers know content is loading. Individual Skeleton elements are presentational and do not need ARIA attributes themselves.'}};function
|
|
309
|
+
</Card>`},{title:"Static (no animation)",code:'<Skeleton variant="rectangle" width={200} height={32} animate={false} />'}],compositionGraph:[],accessibility:{ariaAttributes:["aria-busy","aria-label"],notes:'Wrap loading regions with aria-busy="true" on the container so screen readers know content is loading. Individual Skeleton elements are presentational and do not need ARIA attributes themselves.'}};function Cr({items:t,separator:n="/",style:r}){return e.jsx("nav",{"aria-label":"Breadcrumb",style:r,children:e.jsx("ol",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:"var(--lucent-space-1)",listStyle:"none",margin:0,padding:0,fontFamily:"var(--lucent-font-family-base)"},children:t.map((o,a)=>{const i=a===t.length-1;return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[i?e.jsx(O,{size:"sm",color:"primary",as:"span","aria-current":"page",children:o.label}):o.href!=null?e.jsx("a",{href:o.href,onClick:o.onClick,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",textDecoration:"none",fontFamily:"var(--lucent-font-family-base)",transition:"color var(--lucent-duration-fast) var(--lucent-easing-default)"},onMouseEnter:s=>{s.currentTarget.style.color="var(--lucent-text-primary)"},onMouseLeave:s=>{s.currentTarget.style.color="var(--lucent-text-secondary)"},children:o.label}):e.jsx("button",{onClick:o.onClick,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",background:"none",border:"none",padding:0,cursor:"pointer",transition:"color var(--lucent-duration-fast) var(--lucent-easing-default)"},onMouseEnter:s=>{s.currentTarget.style.color="var(--lucent-text-primary)"},onMouseLeave:s=>{s.currentTarget.style.color="var(--lucent-text-secondary)"},children:o.label}),!i&&e.jsx("span",{"aria-hidden":!0,style:{color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)",userSelect:"none"},children:n})]},a)})})})}function jr({tabs:t,defaultValue:n,value:r,onChange:o,variant:a="underline",style:i}){var R;const s=r!==void 0,[l,c]=p.useState(n??((R=t[0])==null?void 0:R.value)??""),d=s?r:l,[u,h]=p.useState(null),m=p.useRef([]),[g,C]=p.useState(null),b=p.useRef(!1),f=a==="pills",v=p.useRef(null),S=p.useRef(null),x=p.useRef(null),[I,w]=p.useState(t.length),[z,q]=p.useState(!1),[T,M]=p.useState(!1),[F,N]=p.useState(null),j=t.slice(0,I),B=t.slice(I),L=B.length>0,P=B.some(y=>y.value===d),$=()=>{if(P){C(null);return}const y=t.findIndex((E,U)=>U<I&&E.value===d),A=m.current[y];if(A){if(f){const E=A.querySelector("span");if(!E)return;C({left:E.offsetLeft+A.offsetLeft,width:E.offsetWidth,animate:b.current})}else C({left:A.offsetLeft,width:A.offsetWidth,animate:b.current});b.current=!0}};p.useLayoutEffect(()=>{$(),document.fonts.ready.then($)},[d,I,f]),p.useEffect(()=>{const y=v.current;if(!y)return;const A=()=>{const D=y.clientWidth,W=70;let G=0,K=0;for(let _=0;_<t.length;_++){const ne=m.current[_];if(!ne){K++;continue}const ae=ne.offsetWidth;if(_<t.length-1){if(G+ae+W>D)break}else if(G+ae>D)break;G+=ae,K++}if(K>=t.length-1&&K<t.length){let _=0;for(let ne=0;ne<t.length;ne++){const ae=m.current[ne];ae&&(_+=ae.offsetWidth)}_<=D&&(K=t.length)}w(K<1?1:K)};let E;(()=>{E=requestAnimationFrame(()=>{E=requestAnimationFrame(A)})})();const k=new ResizeObserver(A);return k.observe(y),()=>{k.disconnect(),cancelAnimationFrame(E)}},[t]),p.useEffect(()=>{if(!z)return;const y=A=>{x.current&&!x.current.contains(A.target)&&S.current&&!S.current.contains(A.target)&&(q(!1),N(null))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[z]);const X=y=>{s||c(y),o==null||o(y)},H=(y,A)=>{var D;const E=j.map((W,G)=>W.disabled?-1:G).filter(W=>W!==-1),U=E.indexOf(A);let k=-1;y.key==="ArrowRight"&&(k=E[(U+1)%E.length]??-1),y.key==="ArrowLeft"&&(k=E[(U-1+E.length)%E.length]??-1),y.key==="Home"&&(k=E[0]??-1),y.key==="End"&&(k=E[E.length-1]??-1),k!==-1&&(y.preventDefault(),(D=m.current[k])==null||D.focus(),X(j[k].value))};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",position:"relative",...i},children:[e.jsxs("div",{ref:v,role:"tablist",style:{position:"relative",display:"flex",overflow:"hidden",...f?{padding:"var(--lucent-space-1)"}:{borderBottom:"1px solid var(--lucent-border-default)"}},children:[t.map((y,A)=>{const E=A<I,U=y.value===d,k=y.disabled??!1;return e.jsxs("button",{ref:D=>{m.current[A]=D},role:"tab","aria-selected":U,"aria-controls":`lucent-tabpanel-${y.value}`,id:`lucent-tab-${y.value}`,disabled:k,tabIndex:U&&E?0:-1,onClick:()=>{k||X(y.value)},onKeyDown:D=>H(D,A),onMouseEnter:()=>{!k&&E&&h(A)},onMouseLeave:()=>h(null),style:{padding:f?"var(--lucent-space-1) var(--lucent-space-2)":"var(--lucent-space-1) var(--lucent-space-2) var(--lucent-space-3)",background:"none",border:"none",cursor:k?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:U?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",color:k?"var(--lucent-text-disabled)":f&&U?"var(--lucent-text-on-accent)":U?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",transition:"color var(--lucent-duration-fast) var(--lucent-easing-default)",whiteSpace:"nowrap",outline:"none",position:E?"relative":"absolute",zIndex:U?1:0,...E?{}:{visibility:"hidden",pointerEvents:"none",left:-9999}},children:[e.jsx("span",{style:{display:"block",padding:"var(--lucent-space-1) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",background:!f&&u===A&&!U&&!k?"var(--lucent-surface-secondary)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:y.label}),f&&u===A&&!U&&!k&&E&&e.jsx("span",{"aria-hidden":!0,style:{position:"absolute",top:0,bottom:0,left:0,right:0,borderRadius:"var(--lucent-radius-md)",background:"var(--lucent-surface-secondary)",zIndex:-1,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"}})]},y.value)}),L&&e.jsx("button",{ref:S,onClick:()=>q(y=>!y),onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1),style:{padding:f?"var(--lucent-space-1) var(--lucent-space-2)":"var(--lucent-space-1) var(--lucent-space-2) var(--lucent-space-3)",background:"none",border:"none",cursor:"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:P?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",color:P?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",whiteSpace:"nowrap",outline:"none",position:"relative",flexShrink:0},children:e.jsx("span",{style:{display:"block",padding:"var(--lucent-space-1) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",background:T?"var(--lucent-surface-secondary)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:"More…"})}),g!=null&&e.jsx("span",{"aria-hidden":!0,style:f?{position:"absolute",top:"var(--lucent-space-1)",bottom:"var(--lucent-space-1)",left:g.left,width:g.width,background:"var(--lucent-accent-default)",borderRadius:"var(--lucent-radius-md)",transition:g.animate?"left 220ms var(--lucent-easing-default), width 220ms var(--lucent-easing-default)":"none"}:{position:"absolute",bottom:0,left:g.left,width:g.width,height:2,background:"var(--lucent-accent-default)",borderRadius:"var(--lucent-radius-sm)",transition:g.animate?"left 220ms var(--lucent-easing-default), width 220ms var(--lucent-easing-default)":"none"}})]}),L&&z&&e.jsx("div",{ref:x,style:{position:"absolute",top:"100%",right:0,zIndex:50,marginTop:"var(--lucent-space-1)",background:"var(--lucent-surface-primary)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-md)",boxShadow:"var(--lucent-shadow-md)",padding:"var(--lucent-space-1) 0",minWidth:140},children:B.map((y,A)=>{const E=y.value===d,U=y.disabled??!1,k=F===A;return e.jsx("button",{disabled:U,onClick:()=>{U||(X(y.value),q(!1))},onMouseEnter:()=>{U||N(A)},onMouseLeave:()=>N(null),style:{display:"block",width:"100%",padding:"var(--lucent-space-2) var(--lucent-space-4)",background:E||k?"var(--lucent-surface-secondary)":"none",border:"none",cursor:U?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:E?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",color:U?"var(--lucent-text-disabled)":E||k?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",textAlign:"left",outline:"none",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), color var(--lucent-duration-fast) var(--lucent-easing-default)"},children:y.label},y.value)})}),t.map(y=>e.jsx("div",{role:"tabpanel",id:`lucent-tabpanel-${y.value}`,"aria-labelledby":`lucent-tab-${y.value}`,hidden:y.value!==d,style:{padding:"var(--lucent-space-4) 0",outline:"none"},tabIndex:0,children:y.content},y.value))]})}const Ir=`
|
|
310
310
|
@keyframes lucent-collapsible-open {
|
|
311
311
|
from { opacity: 0; transform: translateY(-4px); }
|
|
312
312
|
to { opacity: 1; transform: translateY(0); }
|
|
313
313
|
}
|
|
314
|
-
`;function Tr({trigger:e,children:n,defaultOpen:r=!1,open:o,onOpenChange:a,style:s}){const i=o!==void 0,[l,c]=p.useState(r),d=i?o:l,u=p.useRef(null),[h,m]=p.useState(d?void 0:0),g=p.useRef(!1);p.useEffect(()=>{const y=u.current;if(y)if(d){const f=y.scrollHeight;m(f),g.current=!0;const v=setTimeout(()=>{m(void 0),g.current=!1},220);return()=>clearTimeout(v)}else m(y.scrollHeight),y.getBoundingClientRect(),m(0)},[d]);const C=()=>{const y=!d;i||c(y),a==null||a(y)};return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:Sr}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",...s},children:[t.jsxs("button",{onClick:C,"aria-expanded":d,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",padding:"var(--lucent-space-3) var(--lucent-space-4)",cursor:"pointer",textAlign:"left",outline:"none",fontFamily:"inherit",fontSize:"inherit"},children:[t.jsx("span",{style:{flex:1},children:e}),t.jsx(Cr,{open:d})]}),t.jsx("div",{ref:u,"aria-hidden":!d,style:{overflow:"hidden",height:h!==void 0?h:"auto",transition:"height 200ms var(--lucent-easing-default)"},children:t.jsx("div",{style:{padding:"var(--lucent-space-2) var(--lucent-space-4) var(--lucent-space-3)",animation:d?"lucent-collapsible-open 200ms var(--lucent-easing-default) forwards":void 0},children:n})})]})]})}function Cr({open:e}){return t.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,color:"var(--lucent-text-secondary)",transform:e?"rotate(180deg)":"rotate(0deg)",transition:"transform 200ms var(--lucent-easing-default)"},children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})}const ce="lucent-pl-no-scrollbar",jr=`.${ce}{scrollbar-width:none}.${ce}::-webkit-scrollbar{display:none}`;function me(e){return typeof e=="number"?`${e}px`:e}function Ir({children:e,header:n,sidebar:r,sidebarWidth:o=240,headerHeight:a=48,sidebarCollapsed:s=!1,rightSidebar:i,rightSidebarWidth:l=240,rightSidebarCollapsed:c=!1,footer:d,footerHeight:u=28,chromeBackground:h="bgBase",mainStyle:m,style:g}){const C=me(a),y=me(o),f=me(l),v=me(u),b=h==="bgBase"?"var(--lucent-bg-base)":h==="bgSubtle"?"var(--lucent-bg-subtle)":"var(--lucent-surface)";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",background:b,fontFamily:"var(--lucent-font-family-base)",...g},children:[t.jsx("style",{children:jr}),n!=null&&t.jsx("div",{style:{flexShrink:0,height:C,zIndex:10,background:b},children:n}),t.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[r!=null&&t.jsx("div",{className:ce,style:{width:s?0:y,flexShrink:0,overflow:"hidden",overflowY:s?"hidden":"auto",background:b,transition:"width 200ms var(--lucent-easing-default)"},children:r}),t.jsx("main",{className:ce,style:{flex:1,overflowY:"auto",minWidth:0,margin:i!=null?"0 0 var(--lucent-space-3) 0":"0 var(--lucent-space-3) var(--lucent-space-3) 0",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-sm)",background:"var(--lucent-surface)",...m},children:e}),i!=null&&t.jsx("aside",{className:ce,style:{width:c?0:f,flexShrink:0,overflow:"hidden",overflowY:c?"hidden":"auto",background:b,transition:"width 200ms var(--lucent-easing-default)"},children:i})]}),d!=null&&t.jsx("div",{style:{flexShrink:0,height:v,zIndex:10,background:b},children:d})]})}function Mr({state:e}){return t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":!0,style:{flexShrink:0,opacity:e==="none"?.35:1},children:[t.jsx("path",{d:"M6 2L9 5H3L6 2Z",fill:"currentColor",opacity:e==="desc"?.35:1}),t.jsx("path",{d:"M6 10L3 7H9L6 10Z",fill:"currentColor",opacity:e==="asc"?.35:1})]})}function gt({dir:e}){return t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:t.jsx("path",{d:e==="left"?"M10 12L6 8l4-4":"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Dr({columns:e,rows:n,pageSize:r=10,page:o,onPageChange:a,onFilterChange:s,emptyState:i,style:l}){const[c,d]=p.useState(null),[u,h]=p.useState(0),[m,g]=p.useState(null),[C,y]=p.useState({}),f=o!==void 0,v=f?o:u,b=e.some(z=>z.filterable),T=b?n.filter(z=>e.every(F=>{if(!F.filterable)return!0;const B=C[F.key];if(!B||B.length===0)return!0;const $=String(z[F.key]??"");return B.includes($)})):n,D=c?[...T].sort((z,F)=>{const B=z[c.key],$=F[c.key],U=String(B??"").localeCompare(String($??""),void 0,{numeric:!0});return c.dir==="asc"?U:-U}):T,x=r>0?D.slice(v*r,(v+1)*r):D,M=r>0?Math.max(1,Math.ceil(D.length/r)):1,P=z=>{f||h(z),a==null||a(z)},k=z=>{d(F=>!F||F.key!==z?{key:z,dir:"asc"}:F.dir==="asc"?{key:z,dir:"desc"}:null),f||h(0),a==null||a(0)},j=(z,F)=>{const B={...C,[z]:F};F.length===0&&delete B[z],y(B),f||h(0),a==null||a(0),s==null||s(B)},W=()=>{y({}),f||h(0),a==null||a(0),s==null||s({})},R=[];if(M<=7)for(let z=0;z<M;z++)R.push(z);else{R.push(0),v>2&&R.push("…");for(let z=Math.max(1,v-1);z<=Math.min(M-2,v+1);z++)R.push(z);v<M-3&&R.push("…"),R.push(M-1)}return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...l},children:[b&&t.jsx("div",{style:{position:"relative",zIndex:1},children:t.jsx(zr,{columns:e,rows:n,filters:C,onFilter:j,onClearAll:W})}),t.jsx("div",{style:{overflowX:"auto",borderRadius:"var(--lucent-radius-lg)",border:"1px solid var(--lucent-border-default)"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)"},children:[t.jsx("thead",{children:t.jsx("tr",{style:{borderBottom:"1px solid var(--lucent-border-default)"},children:e.map(z=>{const F=(c==null?void 0:c.key)===z.key?c.dir:"none";return t.jsx("th",{onClick:z.sortable?()=>k(z.key):void 0,style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",textAlign:z.align??"left",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",background:"var(--lucent-surface-secondary)",borderBottom:"1px solid var(--lucent-border-default)",cursor:z.sortable?"pointer":"default",userSelect:"none",whiteSpace:"nowrap",...z.width?{width:z.width}:{}},children:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[z.header,z.sortable&&t.jsx(Mr,{state:F})]})},z.key)})})}),t.jsx("tbody",{children:x.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:e.length,style:{padding:"var(--lucent-space-12)",textAlign:"center"},children:i??t.jsx(O,{color:"secondary",children:"No data"})})}):x.map((z,F)=>t.jsx("tr",{onMouseEnter:()=>g(F),onMouseLeave:()=>g(null),style:{borderBottom:F<x.length-1?"1px solid var(--lucent-border-subtle)":"none",background:m===F?"var(--lucent-surface-secondary)":"var(--lucent-surface)",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:e.map(B=>t.jsx("td",{style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",color:"var(--lucent-text-primary)",textAlign:B.align??"left",verticalAlign:"middle"},children:B.render?B.render(z,F):String(z[B.key]??"")},B.key))},F))})]})}),r>0&&D.length>0&&t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--lucent-space-3)",flexWrap:"wrap"},children:[t.jsx(O,{color:"secondary",size:"sm",children:D.length===0?`0 rows${n.length>0?` (filtered from ${n.length})`:""}`:D.length===1?`1 row${D.length<n.length?` (filtered from ${n.length})`:""}`:`${v*r+1}–${Math.min((v+1)*r,D.length)} of ${D.length} rows${D.length<n.length?` (filtered from ${n.length})`:""}`}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[t.jsx(Me,{onClick:()=>P(v-1),disabled:v===0,"aria-label":"Previous page",children:t.jsx(gt,{dir:"left"})}),R.map((z,F)=>z==="…"?t.jsx("span",{style:{padding:"0 var(--lucent-space-1)",color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)"},children:"…"},`ellipsis-${F}`):t.jsx(Me,{onClick:()=>P(z),active:z===v,"aria-label":`Page ${z+1}`,"aria-current":z===v?"page":void 0,children:z+1},z)),t.jsx(Me,{onClick:()=>P(v+1),disabled:v>=M-1,"aria-label":"Next page",children:t.jsx(gt,{dir:"right"})})]})]})]})}function zr({columns:e,rows:n,filters:r,onFilter:o,onClearAll:a}){const s=e.filter(l=>l.filterable),i=Object.keys(r).length;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",flexWrap:"wrap"},children:[s.map(l=>{const c=Array.from(new Set(n.map(d=>String(d[l.key]??"")))).sort();return t.jsx(Er,{label:l.header,values:c,value:r[l.key]??[],onChange:d=>o(l.key,d)},l.key)}),i>0&&t.jsx("button",{onClick:a,style:{display:"inline-flex",alignItems:"center",height:30,padding:"0 var(--lucent-space-2)",border:"none",borderRadius:"var(--lucent-radius-md)",background:"transparent",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",cursor:"pointer"},children:"Clear all"})]})}function Er({label:e,values:n,value:r,onChange:o}){const[a,s]=p.useState(!1),[i,l]=p.useState(!1),[c,d]=p.useState(""),u=p.useRef(null),h=p.useRef(null),m=r.length>0;p.useEffect(()=>{if(!a){d("");return}setTimeout(()=>{var b;return(b=h.current)==null?void 0:b.focus()},0);const f=b=>{u.current&&!u.current.contains(b.target)&&s(!1)},v=b=>{b.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",v)}},[a]);const g=c?n.filter(f=>f.toLowerCase().includes(c.toLowerCase())):n,C=f=>o(r.includes(f)?r.filter(v=>v!==f):[...r,f]),y=r.length===0?null:r.length===1?t.jsxs("span",{style:{color:"var(--lucent-text-secondary)",fontWeight:"var(--lucent-font-weight-regular)"},children:[": ",r[0]]}):t.jsxs("span",{style:{color:"var(--lucent-accent-default)"},children:["(",r.length,")"]});return t.jsxs("div",{ref:u,style:{position:"relative"},children:[t.jsxs("button",{onClick:()=>s(f=>!f),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",height:30,padding:"0 var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",border:`1px solid ${m?"var(--lucent-accent-default)":i?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,background:m?"var(--lucent-accent-subtle)":"var(--lucent-surface)",color:m?"var(--lucent-accent-default)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:m?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:"pointer",outline:"none",whiteSpace:"nowrap",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:[e,y,t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,style:{transform:a?"rotate(180deg)":"none",transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),a&&t.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:180,maxHeight:280,display:"flex",flexDirection:"column",background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 4px 16px color-mix(in srgb, var(--lucent-text-primary) 8%, transparent)",zIndex:50},children:[t.jsx("div",{style:{padding:"var(--lucent-space-2)",paddingBottom:0},children:t.jsx("input",{ref:h,type:"text",value:c,onChange:f=>d(f.target.value),placeholder:"Search…",style:{width:"100%",boxSizing:"border-box",height:26,padding:"0 var(--lucent-space-2)",borderRadius:"var(--lucent-radius-md)",border:"1px solid var(--lucent-border-default)",background:"var(--lucent-surface-secondary)",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",outline:"none"}})}),r.length>0&&t.jsx("div",{style:{padding:"var(--lucent-space-1) var(--lucent-space-2) 0"},children:t.jsx("button",{onClick:()=>o([]),style:{display:"inline-flex",padding:"2px var(--lucent-space-2)",border:"none",borderRadius:"var(--lucent-radius-sm)",background:"transparent",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",cursor:"pointer",textDecoration:"underline"},children:"Clear selection"})}),t.jsx("div",{style:{overflowY:"auto",padding:"var(--lucent-space-1)",borderTop:"1px solid var(--lucent-border-subtle)",marginTop:"var(--lucent-space-2)"},children:g.length===0?t.jsx("div",{style:{padding:"var(--lucent-space-3)",color:"var(--lucent-text-disabled)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",textAlign:"center"},children:"No results"}):g.map(f=>t.jsx(Ar,{label:f,isSelected:r.includes(f),onClick:()=>C(f)},f))})]})]})}function Ar({label:e,isSelected:n,onClick:r}){const[o,a]=p.useState(!1);return t.jsxs("button",{onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",width:"100%",textAlign:"left",padding:"var(--lucent-space-2) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",border:"none",background:o?"var(--lucent-surface-secondary)":"transparent",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:n?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:"pointer",outline:"none",whiteSpace:"nowrap"},children:[t.jsx("span",{style:{flexShrink:0,width:14,height:14,borderRadius:"var(--lucent-radius-sm)",border:`1.5px solid ${n?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:n?"var(--lucent-accent-default)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color var(--lucent-duration-fast), background var(--lucent-duration-fast)"},children:n&&t.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none","aria-hidden":!0,children:t.jsx("path",{d:"M1 4L3 6L7 2",stroke:"var(--lucent-text-on-accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e]})}function Me({children:e,onClick:n,disabled:r,active:o,...a}){const[s,i]=p.useState(!1);return t.jsx("button",{...a,onClick:n,disabled:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:32,height:32,padding:"0 var(--lucent-space-2)",borderRadius:"var(--lucent-radius-md)",border:o?"1px solid var(--lucent-accent-default)":"1px solid transparent",background:o?"var(--lucent-accent-default)":s&&!r?"var(--lucent-surface-secondary)":"transparent",color:o?"var(--lucent-text-on-accent)":r?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:"var(--lucent-font-size-sm)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-regular)",cursor:r?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:e})}const Rr={id:"data-table",name:"DataTable",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A sortable, filterable, paginated data table with configurable columns, custom cell renderers, and keyboard-accessible pagination controls.",designIntent:'DataTable is generic over row type T so TypeScript consumers get full type safety on column keys and renderers. Sorting is client-side and composable — each column opts in via sortable:true; clicking a sorted column cycles asc → desc → unsorted. Filtering is per-column — each column opts in via filterable:true, which adds a dropdown button above the table. Each dropdown is searchable and multi-select: a search input filters the option list, and each option is a checkbox that toggles membership in the active set. Filtering uses set-membership: a row passes if its column value is included in the selected values array. A "Clear selection" link inside each dropdown clears that column; a "Clear all" button in the bar appears when any filter is active. Filter → sort → paginate is the fixed pipeline order; any filter change resets the page to 0. Pagination is either controlled (page prop + onPageChange) or uncontrolled (internal state). A pageSize of 0 disables pagination entirely, useful when the parent manages windowing. Row hover uses bg-subtle, not a border change, so the visual weight stays low for dense data views.',props:[{name:"columns",type:"array",required:!0,description:"Column definitions. Each column has a key, header, optional render function, optional sortable flag, optional filterable flag (renders a text filter input below the header), optional width, and optional text align."},{name:"rows",type:"array",required:!0,description:"Array of data objects to display. The generic type T is inferred from this prop."},{name:"pageSize",type:"number",required:!1,default:"10",description:"Number of rows per page. Set to 0 to disable pagination."},{name:"page",type:"number",required:!1,description:"Controlled current page (0-indexed). When provided, the component is fully controlled."},{name:"onPageChange",type:"function",required:!1,description:"Called with the new page index whenever the page changes (from pagination controls or after a sort/filter reset)."},{name:"onFilterChange",type:"function",required:!1,description:"Called with the current filter map (Record<string, string[]>) whenever any column filter changes. Keys are column keys; columns with no selection are omitted from the map."},{name:"emptyState",type:"ReactNode",required:!1,description:'Content to render when rows is empty. Defaults to a "No data" text.'},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Basic sortable table",code:`<DataTable
|
|
314
|
+
`;function Mr({trigger:t,children:n,defaultOpen:r=!1,open:o,onOpenChange:a,style:i}){const s=o!==void 0,[l,c]=p.useState(r),d=s?o:l,u=p.useRef(null),[h,m]=p.useState(d?void 0:0),g=p.useRef(!1);p.useEffect(()=>{const b=u.current;if(b)if(d){const f=b.scrollHeight;m(f),g.current=!0;const v=setTimeout(()=>{m(void 0),g.current=!1},220);return()=>clearTimeout(v)}else m(b.scrollHeight),b.getBoundingClientRect(),m(0)},[d]);const C=()=>{const b=!d;s||c(b),a==null||a(b)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ir}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",...i},children:[e.jsxs("button",{onClick:C,"aria-expanded":d,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",padding:"var(--lucent-space-3) var(--lucent-space-4)",cursor:"pointer",textAlign:"left",outline:"none",fontFamily:"inherit",fontSize:"inherit"},children:[e.jsx("span",{style:{flex:1},children:t}),e.jsx(Dr,{open:d})]}),e.jsx("div",{ref:u,"aria-hidden":!d,style:{overflow:"hidden",height:h!==void 0?h:"auto",transition:"height 200ms var(--lucent-easing-default)"},children:e.jsx("div",{style:{padding:"var(--lucent-space-2) var(--lucent-space-4) var(--lucent-space-3)",animation:d?"lucent-collapsible-open 200ms var(--lucent-easing-default) forwards":void 0},children:n})})]})]})}function Dr({open:t}){return e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,color:"var(--lucent-text-secondary)",transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 200ms var(--lucent-easing-default)"},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const ce="lucent-pl-no-scrollbar",zr=`.${ce}{scrollbar-width:none}.${ce}::-webkit-scrollbar{display:none}`;function me(t){return typeof t=="number"?`${t}px`:t}function Er({children:t,header:n,sidebar:r,sidebarWidth:o=240,headerHeight:a=48,sidebarCollapsed:i=!1,rightSidebar:s,rightSidebarWidth:l=240,rightSidebarCollapsed:c=!1,footer:d,footerHeight:u=28,chromeBackground:h="bgBase",mainStyle:m,style:g}){const C=me(a),b=me(o),f=me(l),v=me(u),S=h==="bgBase"?"var(--lucent-bg-base)":h==="bgSubtle"?"var(--lucent-bg-subtle)":"var(--lucent-surface)";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",background:S,fontFamily:"var(--lucent-font-family-base)",...g},children:[e.jsx("style",{children:zr}),n!=null&&e.jsx("div",{style:{flexShrink:0,height:C,zIndex:10,background:S},children:n}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[r!=null&&e.jsx("div",{className:ce,style:{width:i?0:b,flexShrink:0,overflow:"hidden",overflowY:i?"hidden":"auto",background:S,transition:"width 200ms var(--lucent-easing-default)"},children:r}),e.jsx("main",{className:ce,style:{flex:1,overflowY:"auto",minWidth:0,margin:s!=null?"0 0 var(--lucent-space-3) 0":"0 var(--lucent-space-3) var(--lucent-space-3) 0",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-sm)",background:"var(--lucent-surface)",...m},children:t}),s!=null&&e.jsx("aside",{className:ce,style:{width:c?0:f,flexShrink:0,overflow:"hidden",overflowY:c?"hidden":"auto",background:S,transition:"width 200ms var(--lucent-easing-default)"},children:s})]}),d!=null&&e.jsx("div",{style:{flexShrink:0,height:v,zIndex:10,background:S},children:d})]})}function Ar({state:t}){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":!0,style:{flexShrink:0,opacity:t==="none"?.35:1},children:[e.jsx("path",{d:"M6 2L9 5H3L6 2Z",fill:"currentColor",opacity:t==="desc"?.35:1}),e.jsx("path",{d:"M6 10L3 7H9L6 10Z",fill:"currentColor",opacity:t==="asc"?.35:1})]})}function vt({dir:t}){return e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:t==="left"?"M10 12L6 8l4-4":"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rr({columns:t,rows:n,pageSize:r=10,page:o,onPageChange:a,onFilterChange:i,emptyState:s,style:l}){const[c,d]=p.useState(null),[u,h]=p.useState(0),[m,g]=p.useState(null),[C,b]=p.useState({}),f=o!==void 0,v=f?o:u,S=t.some(j=>j.filterable),x=S?n.filter(j=>t.every(B=>{if(!B.filterable)return!0;const L=C[B.key];if(!L||L.length===0)return!0;const P=String(j[B.key]??"");return L.includes(P)})):n,I=c?[...x].sort((j,B)=>{const L=j[c.key],P=B[c.key],$=String(L??"").localeCompare(String(P??""),void 0,{numeric:!0});return c.dir==="asc"?$:-$}):x,w=r>0?I.slice(v*r,(v+1)*r):I,z=r>0?Math.max(1,Math.ceil(I.length/r)):1,q=j=>{f||h(j),a==null||a(j)},T=j=>{d(B=>!B||B.key!==j?{key:j,dir:"asc"}:B.dir==="asc"?{key:j,dir:"desc"}:null),f||h(0),a==null||a(0)},M=(j,B)=>{const L={...C,[j]:B};B.length===0&&delete L[j],b(L),f||h(0),a==null||a(0),i==null||i(L)},F=()=>{b({}),f||h(0),a==null||a(0),i==null||i({})},N=[];if(z<=7)for(let j=0;j<z;j++)N.push(j);else{N.push(0),v>2&&N.push("…");for(let j=Math.max(1,v-1);j<=Math.min(z-2,v+1);j++)N.push(j);v<z-3&&N.push("…"),N.push(z-1)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...l},children:[S&&e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsx(qr,{columns:t,rows:n,filters:C,onFilter:M,onClearAll:F})}),e.jsx("div",{style:{overflowX:"auto",borderRadius:"var(--lucent-radius-lg)",border:"1px solid var(--lucent-border-default)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--lucent-border-default)"},children:t.map(j=>{const B=(c==null?void 0:c.key)===j.key?c.dir:"none";return e.jsx("th",{onClick:j.sortable?()=>T(j.key):void 0,style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",textAlign:j.align??"left",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",background:"var(--lucent-surface-secondary)",borderBottom:"1px solid var(--lucent-border-default)",cursor:j.sortable?"pointer":"default",userSelect:"none",whiteSpace:"nowrap",...j.width?{width:j.width}:{}},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[j.header,j.sortable&&e.jsx(Ar,{state:B})]})},j.key)})})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,style:{padding:"var(--lucent-space-12)",textAlign:"center"},children:s??e.jsx(O,{color:"secondary",children:"No data"})})}):w.map((j,B)=>e.jsx("tr",{onMouseEnter:()=>g(B),onMouseLeave:()=>g(null),style:{borderBottom:B<w.length-1?"1px solid var(--lucent-border-subtle)":"none",background:m===B?"var(--lucent-surface-secondary)":"var(--lucent-surface)",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t.map(L=>e.jsx("td",{style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",color:"var(--lucent-text-primary)",textAlign:L.align??"left",verticalAlign:"middle"},children:L.render?L.render(j,B):String(j[L.key]??"")},L.key))},B))})]})}),r>0&&I.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--lucent-space-3)",flexWrap:"wrap"},children:[e.jsx(O,{color:"secondary",size:"sm",children:I.length===0?`0 rows${n.length>0?` (filtered from ${n.length})`:""}`:I.length===1?`1 row${I.length<n.length?` (filtered from ${n.length})`:""}`:`${v*r+1}–${Math.min((v+1)*r,I.length)} of ${I.length} rows${I.length<n.length?` (filtered from ${n.length})`:""}`}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[e.jsx(Me,{onClick:()=>q(v-1),disabled:v===0,"aria-label":"Previous page",children:e.jsx(vt,{dir:"left"})}),N.map((j,B)=>j==="…"?e.jsx("span",{style:{padding:"0 var(--lucent-space-1)",color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)"},children:"…"},`ellipsis-${B}`):e.jsx(Me,{onClick:()=>q(j),active:j===v,"aria-label":`Page ${j+1}`,"aria-current":j===v?"page":void 0,children:j+1},j)),e.jsx(Me,{onClick:()=>q(v+1),disabled:v>=z-1,"aria-label":"Next page",children:e.jsx(vt,{dir:"right"})})]})]})]})}function qr({columns:t,rows:n,filters:r,onFilter:o,onClearAll:a}){const i=t.filter(l=>l.filterable),s=Object.keys(r).length;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",flexWrap:"wrap"},children:[i.map(l=>{const c=Array.from(new Set(n.map(d=>String(d[l.key]??"")))).sort();return e.jsx(Br,{label:l.header,values:c,value:r[l.key]??[],onChange:d=>o(l.key,d)},l.key)}),s>0&&e.jsx("button",{onClick:a,style:{display:"inline-flex",alignItems:"center",height:30,padding:"0 var(--lucent-space-2)",border:"none",borderRadius:"var(--lucent-radius-md)",background:"transparent",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",cursor:"pointer"},children:"Clear all"})]})}function Br({label:t,values:n,value:r,onChange:o}){const[a,i]=p.useState(!1),[s,l]=p.useState(!1),[c,d]=p.useState(""),u=p.useRef(null),h=p.useRef(null),m=r.length>0;p.useEffect(()=>{if(!a){d("");return}setTimeout(()=>{var S;return(S=h.current)==null?void 0:S.focus()},0);const f=S=>{u.current&&!u.current.contains(S.target)&&i(!1)},v=S=>{S.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",v)}},[a]);const g=c?n.filter(f=>f.toLowerCase().includes(c.toLowerCase())):n,C=f=>o(r.includes(f)?r.filter(v=>v!==f):[...r,f]),b=r.length===0?null:r.length===1?e.jsxs("span",{style:{color:"var(--lucent-text-secondary)",fontWeight:"var(--lucent-font-weight-regular)"},children:[": ",r[0]]}):e.jsxs("span",{style:{color:"var(--lucent-accent-default)"},children:["(",r.length,")"]});return e.jsxs("div",{ref:u,style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>i(f=>!f),onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",height:30,padding:"0 var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",border:`1px solid ${m?"var(--lucent-accent-default)":s?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,background:m?"var(--lucent-accent-subtle)":"var(--lucent-surface)",color:m?"var(--lucent-accent-default)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:m?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:"pointer",outline:"none",whiteSpace:"nowrap",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:[t,b,e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,style:{transform:a?"rotate(180deg)":"none",transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default)"},children:e.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),a&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:180,maxHeight:280,display:"flex",flexDirection:"column",background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 4px 16px color-mix(in srgb, var(--lucent-text-primary) 8%, transparent)",zIndex:50},children:[e.jsx("div",{style:{padding:"var(--lucent-space-2)",paddingBottom:0},children:e.jsx("input",{ref:h,type:"text",value:c,onChange:f=>d(f.target.value),placeholder:"Search…",style:{width:"100%",boxSizing:"border-box",height:26,padding:"0 var(--lucent-space-2)",borderRadius:"var(--lucent-radius-md)",border:"1px solid var(--lucent-border-default)",background:"var(--lucent-surface-secondary)",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",outline:"none"}})}),r.length>0&&e.jsx("div",{style:{padding:"var(--lucent-space-1) var(--lucent-space-2) 0"},children:e.jsx("button",{onClick:()=>o([]),style:{display:"inline-flex",padding:"2px var(--lucent-space-2)",border:"none",borderRadius:"var(--lucent-radius-sm)",background:"transparent",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",cursor:"pointer",textDecoration:"underline"},children:"Clear selection"})}),e.jsx("div",{style:{overflowY:"auto",padding:"var(--lucent-space-1)",borderTop:"1px solid var(--lucent-border-subtle)",marginTop:"var(--lucent-space-2)"},children:g.length===0?e.jsx("div",{style:{padding:"var(--lucent-space-3)",color:"var(--lucent-text-disabled)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",textAlign:"center"},children:"No results"}):g.map(f=>e.jsx(Lr,{label:f,isSelected:r.includes(f),onClick:()=>C(f)},f))})]})]})}function Lr({label:t,isSelected:n,onClick:r}){const[o,a]=p.useState(!1);return e.jsxs("button",{onClick:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",width:"100%",textAlign:"left",padding:"var(--lucent-space-2) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",border:"none",background:o?"var(--lucent-surface-secondary)":"transparent",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:n?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:"pointer",outline:"none",whiteSpace:"nowrap"},children:[e.jsx("span",{style:{flexShrink:0,width:14,height:14,borderRadius:"var(--lucent-radius-sm)",border:`1.5px solid ${n?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:n?"var(--lucent-accent-default)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color var(--lucent-duration-fast), background var(--lucent-duration-fast)"},children:n&&e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M1 4L3 6L7 2",stroke:"var(--lucent-text-on-accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t]})}function Me({children:t,onClick:n,disabled:r,active:o,...a}){const[i,s]=p.useState(!1);return e.jsx("button",{...a,onClick:n,disabled:r,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",minWidth:32,height:32,padding:"0 var(--lucent-space-2)",borderRadius:"var(--lucent-radius-md)",border:o?"1px solid var(--lucent-accent-default)":"1px solid transparent",background:o?"var(--lucent-accent-default)":i&&!r?"var(--lucent-surface-secondary)":"transparent",color:o?"var(--lucent-text-on-accent)":r?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:"var(--lucent-font-size-sm)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-regular)",cursor:r?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t})}const Pr={id:"data-table",name:"DataTable",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A sortable, filterable, paginated data table with configurable columns, custom cell renderers, and keyboard-accessible pagination controls.",designIntent:'DataTable is generic over row type T so TypeScript consumers get full type safety on column keys and renderers. Sorting is client-side and composable — each column opts in via sortable:true; clicking a sorted column cycles asc → desc → unsorted. Filtering is per-column — each column opts in via filterable:true, which adds a dropdown button above the table. Each dropdown is searchable and multi-select: a search input filters the option list, and each option is a checkbox that toggles membership in the active set. Filtering uses set-membership: a row passes if its column value is included in the selected values array. A "Clear selection" link inside each dropdown clears that column; a "Clear all" button in the bar appears when any filter is active. Filter → sort → paginate is the fixed pipeline order; any filter change resets the page to 0. Pagination is either controlled (page prop + onPageChange) or uncontrolled (internal state). A pageSize of 0 disables pagination entirely, useful when the parent manages windowing. Row hover uses bg-subtle, not a border change, so the visual weight stays low for dense data views.',props:[{name:"columns",type:"array",required:!0,description:"Column definitions. Each column has a key, header, optional render function, optional sortable flag, optional filterable flag (renders a text filter input below the header), optional width, and optional text align."},{name:"rows",type:"array",required:!0,description:"Array of data objects to display. The generic type T is inferred from this prop."},{name:"pageSize",type:"number",required:!1,default:"10",description:"Number of rows per page. Set to 0 to disable pagination."},{name:"page",type:"number",required:!1,description:"Controlled current page (0-indexed). When provided, the component is fully controlled."},{name:"onPageChange",type:"function",required:!1,description:"Called with the new page index whenever the page changes (from pagination controls or after a sort/filter reset)."},{name:"onFilterChange",type:"function",required:!1,description:"Called with the current filter map (Record<string, string[]>) whenever any column filter changes. Keys are column keys; columns with no selection are omitted from the map."},{name:"emptyState",type:"ReactNode",required:!1,description:'Content to render when rows is empty. Defaults to a "No data" text.'},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Basic sortable table",code:`<DataTable
|
|
315
315
|
columns={[
|
|
316
316
|
{ key: 'name', header: 'Name', sortable: true },
|
|
317
317
|
{ key: 'role', header: 'Role', sortable: true },
|
|
@@ -333,12 +333,12 @@ const [results, setResults] = useState([]);
|
|
|
333
333
|
pageSize={20}
|
|
334
334
|
page={page}
|
|
335
335
|
onPageChange={setPage}
|
|
336
|
-
/>`},{title:"No pagination",code:"<DataTable columns={columns} rows={rows} pageSize={0} />"}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Row count and empty state labels",required:!1},{componentId:"badge",componentName:"Badge",role:"Typical cell content for status columns",required:!1}],accessibility:{role:"table",ariaAttributes:["aria-label","aria-sort","aria-current"],keyboardInteractions:["Tab to pagination controls","Enter/Space to activate buttons"],notes:'Column headers with sortable:true are interactive buttons with aria-sort reflecting the current sort direction. Pagination buttons include aria-label and aria-current="page" for the active page.'}},
|
|
336
|
+
/>`},{title:"No pagination",code:"<DataTable columns={columns} rows={rows} pageSize={0} />"}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Row count and empty state labels",required:!1},{componentId:"badge",componentName:"Badge",role:"Typical cell content for status columns",required:!1}],accessibility:{role:"table",ariaAttributes:["aria-label","aria-sort","aria-current"],keyboardInteractions:["Tab to pagination controls","Enter/Space to activate buttons"],notes:'Column headers with sortable:true are interactive buttons with aria-sort reflecting the current sort direction. Pagination buttons include aria-label and aria-current="page" for the active page.'}},Fr=`
|
|
337
337
|
@keyframes lucent-palette-in {
|
|
338
338
|
from { opacity: 0; transform: scale(0.96) translateY(-8px); }
|
|
339
339
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
340
340
|
}
|
|
341
|
-
`;function
|
|
341
|
+
`;function Nr(t,n){var o;const r=n.toLowerCase();return t.label.toLowerCase().includes(r)||(((o=t.description)==null?void 0:o.toLowerCase().includes(r))??!1)}function $r({commands:t,placeholder:n="Search commands…",shortcutKey:r="k",open:o,onOpenChange:a,style:i}){const s=o!==void 0,[l,c]=p.useState(!1),d=s?o:l,[u,h]=p.useState(""),[m,g]=p.useState(0),C=p.useRef(null),b=p.useRef(null),f=p.useRef(!1);if(!f.current){const T=document.createElement("style");T.textContent=Fr,document.head.appendChild(T),f.current=!0}const v=p.useCallback(T=>{s||c(T),a==null||a(T)},[s,a]);p.useEffect(()=>{const T=M=>{(M.metaKey||M.ctrlKey)&&M.key===r&&(M.preventDefault(),v(!d))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[d,r,v]),p.useEffect(()=>{d&&(h(""),g(0),setTimeout(()=>{var T;return(T=C.current)==null?void 0:T.focus()},10))},[d]);const S=u?t.filter(T=>Nr(T,u)):t,x=S.filter(T=>!T.disabled);p.useEffect(()=>{const T=b.current;if(!T)return;const M=T.querySelector('[data-active="true"]');M==null||M.scrollIntoView({block:"nearest"})},[m]);const I=T=>{T.disabled||(T.onSelect(),v(!1))},w=T=>{if(T.key==="Escape"){v(!1);return}if(T.key==="ArrowDown"&&(T.preventDefault(),g(M=>Math.min(M+1,x.length-1))),T.key==="ArrowUp"&&(T.preventDefault(),g(M=>Math.max(M-1,0))),T.key==="Enter"){const M=x[m];M&&I(M)}},z=[];for(const T of S){const M=z[z.length-1];M&&M.group===T.group?M.items.push(T):z.push({group:T.group,items:[T]})}if(!d)return null;let q=0;return e.jsx("div",{role:"dialog","aria-label":"Command palette","aria-modal":"true",onClick:()=>v(!1),style:{position:"fixed",inset:0,zIndex:9e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"15vh",background:"var(--lucent-bg-overlay)",...i},children:e.jsxs("div",{role:"combobox","aria-haspopup":"listbox","aria-expanded":"true",onClick:T=>T.stopPropagation(),style:{width:"100%",maxWidth:560,margin:"0 var(--lucent-space-4)",background:"var(--lucent-surface-overlay)",borderRadius:"var(--lucent-radius-xl)",border:"1px solid var(--lucent-border-default)",boxShadow:"var(--lucent-shadow-xl)",overflow:"hidden",animation:"lucent-palette-in 150ms var(--lucent-easing-decelerate)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-3) var(--lucent-space-4)",borderBottom:S.length>0?"1px solid var(--lucent-border-subtle)":"none"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,style:{flexShrink:0,color:"var(--lucent-text-secondary)"},children:[e.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M10.5 10.5L13.5 13.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),e.jsx("input",{ref:C,role:"searchbox","aria-autocomplete":"list","aria-controls":"lucent-command-list",value:u,onChange:T=>{h(T.target.value),g(0)},onKeyDown:w,placeholder:n,style:{flex:1,border:"none",outline:"none",background:"transparent",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",color:"var(--lucent-text-primary)",lineHeight:"var(--lucent-line-height-base)"}}),e.jsx("kbd",{style:{display:"inline-flex",alignItems:"center",padding:"2px 6px",borderRadius:"var(--lucent-radius-sm)",border:"1px solid var(--lucent-border-default)",background:"var(--lucent-surface-secondary)",fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-xs)",color:"var(--lucent-text-secondary)"},children:"Esc"})]}),e.jsx("div",{id:"lucent-command-list",role:"listbox",ref:b,style:{maxHeight:360,overflowY:"auto",padding:"var(--lucent-space-1) 0"},children:S.length===0?e.jsx("div",{style:{padding:"var(--lucent-space-8)",textAlign:"center"},children:e.jsxs(O,{color:"secondary",children:['No results for "',u,'"']})}):z.map(({group:T,items:M},F)=>e.jsxs("div",{children:[T&&e.jsx("div",{style:{padding:"var(--lucent-space-2) var(--lucent-space-4) var(--lucent-space-1)",...F>0?{borderTop:"1px solid var(--lucent-border-subtle)",marginTop:"var(--lucent-space-1)"}:{}},children:e.jsx(O,{size:"xs",color:"secondary",weight:"medium",children:T})}),M.map(N=>{const j=N.disabled??!1;let B=!1;return j||(B=q===m,q++),e.jsxs("div",{role:"option","aria-selected":B,"aria-disabled":j,"data-active":B,onClick:()=>I(N),onMouseEnter:()=>{if(!j){const L=x.indexOf(N);L!==-1&&g(L)}},style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-2) var(--lucent-space-4)",cursor:j?"not-allowed":"pointer",background:B?"var(--lucent-surface-secondary)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)",opacity:j?.5:1},children:[N.icon&&e.jsx("span",{style:{flexShrink:0,color:"var(--lucent-text-secondary)",display:"flex"},children:N.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(O,{size:"sm",weight:"medium",truncate:!0,children:N.label}),N.description&&e.jsx(O,{size:"xs",color:"secondary",truncate:!0,children:N.description})]})]},N.id)})]},F))}),e.jsx("div",{style:{display:"flex",gap:"var(--lucent-space-4)",padding:"var(--lucent-space-2) var(--lucent-space-4)",borderTop:"1px solid var(--lucent-border-subtle)",background:"var(--lucent-surface-secondary)"},children:[["↑↓","Navigate"],["↵","Select"],["Esc","Close"]].map(([T,M])=>e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[e.jsx("kbd",{style:{padding:"1px 5px",borderRadius:"var(--lucent-radius-sm)",border:"1px solid var(--lucent-border-default)",background:"var(--lucent-surface)",fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-xs)",color:"var(--lucent-text-secondary)"},children:T}),e.jsx(O,{size:"xs",color:"secondary",children:M})]},T))})]})})}const Wr={id:"command-palette",name:"CommandPalette",tier:"overlay",domain:"neutral",specVersion:"1.0",description:"A keyboard-driven modal command palette with fuzzy search, grouped results, and a built-in ⌘K / Ctrl+K global shortcut.",designIntent:"CommandPalette renders as a portal-style overlay (fixed, full-viewport) with a centred panel that animates in with a subtle scale+fade. The ⌘K shortcut is registered as a global window listener so it works regardless of focus — consumers can override the key via shortcutKey prop. Clicking the backdrop dismisses the palette; Escape also closes it. Results are filtered client-side against label and description using simple substring match — no fuzzy library needed. Navigation is purely keyboard-driven: ↑↓ move the active index, Enter selects, mouse hover syncs the active index so mouse and keyboard stay in sync. Groups are derived from the group field on each CommandItem; the order of groups follows the order they first appear in the commands array. The component is controlled-or-uncontrolled: pass open + onOpenChange for controlled use, or omit both to use internal state.",props:[{name:"commands",type:"array",required:!0,description:"Array of CommandItem objects. Each has id, label, onSelect, and optional description, icon, group, disabled."},{name:"placeholder",type:"string",required:!1,default:'"Search commands…"',description:"Placeholder text for the search input."},{name:"shortcutKey",type:"string",required:!1,default:'"k"',description:'Key that opens the palette when pressed with Meta (Mac) or Ctrl (Windows). Defaults to "k" for ⌘K.'},{name:"open",type:"boolean",required:!1,description:"Controlled open state. When provided, the component is fully controlled."},{name:"onOpenChange",type:"function",required:!1,description:"Called when the palette requests an open/close state change."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the backdrop element."}],usageExamples:[{title:"Uncontrolled with ⌘K",code:`<CommandPalette
|
|
342
342
|
commands={[
|
|
343
343
|
{ id: 'new', label: 'New document', icon: <PlusIcon />, onSelect: () => router.push('/new') },
|
|
344
344
|
{ id: 'settings', label: 'Settings', description: 'Open app settings', onSelect: () => router.push('/settings') },
|
|
@@ -353,7 +353,7 @@ const [results, setResults] = useState([]);
|
|
|
353
353
|
onOpenChange={setOpen}
|
|
354
354
|
shortcutKey="p"
|
|
355
355
|
/>
|
|
356
|
-
</>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Group labels, item labels, descriptions, and empty state",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-label","aria-modal","aria-expanded","aria-selected","aria-disabled","aria-controls","aria-autocomplete"],keyboardInteractions:["⌘K / Ctrl+K to open","↑↓ to navigate","Enter to select","Escape to close"],notes:'The backdrop and panel use role="dialog" with aria-modal="true". The input is role="searchbox". The result list is role="listbox" with role="option" items. Focus is moved to the search input on open.'}},
|
|
356
|
+
</>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Group labels, item labels, descriptions, and empty state",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-label","aria-modal","aria-expanded","aria-selected","aria-disabled","aria-controls","aria-autocomplete"],keyboardInteractions:["⌘K / Ctrl+K to open","↑↓ to navigate","Enter to select","Escape to close"],notes:'The backdrop and panel use role="dialog" with aria-modal="true". The input is role="searchbox". The result list is role="listbox" with role="option" items. Focus is moved to the search input on open.'}},Or={sm:"calc(var(--lucent-space-8) * 0.5 + 16px + 2px)",md:"calc(var(--lucent-space-10) * 0.5 + 20px + 2px)",lg:"calc(var(--lucent-space-12) * 0.5 + 24px + 2px)"},Hr={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)"},Vr={sm:"var(--lucent-space-1) var(--lucent-space-2)",md:"var(--lucent-space-1) var(--lucent-space-2)",lg:"var(--lucent-space-2) var(--lucent-space-3)"},ge={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},De={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},bt={sm:"sm",md:"md",lg:"lg"},Ur={sm:"sm",md:"md",lg:"lg"};function Gr({options:t,value:n,defaultValue:r=[],onChange:o,placeholder:a="Select…",disabled:i=!1,max:s,size:l="md",label:c,helperText:d,errorText:u,style:h}){const m=n!==void 0,[g,C]=p.useState(r),b=m?n:g,[f,v]=p.useState(!1),[S,x]=p.useState(""),[I,w]=p.useState(0),[z,q]=p.useState(!1),T=p.useRef(null),M=p.useRef(null),F=p.useId();p.useEffect(()=>{if(!f)return;const y=A=>{var E;(E=T.current)!=null&&E.contains(A.target)||(v(!1),x(""))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[f]);const N=y=>{const A=b.includes(y)?b.filter(E=>E!==y):s!==void 0&&b.length>=s?b:[...b,y];m||C(A),o==null||o(A)},j=y=>{const A=b.filter(E=>E!==y);m||C(A),o==null||o(A)},B=t.filter(y=>y.label.toLowerCase().includes(S.toLowerCase())),L=y=>{if(y.key==="Escape"){v(!1),x("");return}if(y.key==="ArrowDown"&&(y.preventDefault(),v(!0),w(A=>Math.min(A+1,B.length-1))),y.key==="ArrowUp"&&(y.preventDefault(),w(A=>Math.max(A-1,0))),y.key==="Enter"){y.preventDefault();const A=B[I];A&&!A.disabled&&N(A.value)}y.key==="Backspace"&&S===""&&b.length>0&&j(b[b.length-1])},P=s!==void 0&&b.length>=s,$=!!u,X=i?"var(--lucent-border-default)":$?"var(--lucent-danger-default)":z?"var(--lucent-focus-ring)":"var(--lucent-border-default)",H=z?`0 0 0 3px ${$?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none",R=`lucent-multiselect-${p.useId()}`;return e.jsxs("div",{ref:T,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",...h},children:[c&&e.jsx("label",{htmlFor:R,style:{fontSize:De[l],fontWeight:"var(--lucent-font-weight-medium)",color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:c}),e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{onClick:()=>{var y;i||(v(!0),(y=M.current)==null||y.focus())},style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:ge[l],minHeight:Or[l],boxSizing:"border-box",padding:Vr[l],borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${X}`,background:i?"var(--lucent-surface-secondary)":"var(--lucent-surface)",cursor:i?"not-allowed":"text",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)",boxShadow:H},children:[b.map(y=>{const A=t.find(E=>E.value===y);return A?e.jsx(Mt,{size:Ur[l],onDismiss:()=>j(y),disabled:i,children:A.label},y):null}),e.jsx("input",{id:R,ref:M,value:S,onChange:y=>{x(y.target.value),v(!0),w(0)},onKeyDown:L,onFocus:()=>q(!0),onBlur:()=>q(!1),disabled:i,placeholder:b.length===0?a:"","aria-autocomplete":"list","aria-controls":F,"aria-expanded":f,"aria-describedby":$?`${R}-error`:d?`${R}-helper`:void 0,role:"combobox",style:{flex:"1 1 80px",minWidth:80,border:"none",outline:"none",background:"transparent",fontFamily:"var(--lucent-font-family-base)",fontSize:Hr[l],color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",cursor:i?"not-allowed":"text",padding:b.length===0?"2px 0 2px var(--lucent-space-1)":"2px 0"}})]}),f&&!i&&e.jsxs("div",{id:F,role:"listbox","aria-multiselectable":"true",style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,right:0,zIndex:1e3,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",maxHeight:240,overflowY:"auto",padding:ge[l]},children:[B.length===0?e.jsx("div",{style:{padding:"var(--lucent-space-2)"},children:e.jsx(O,{color:"secondary",size:bt[l],children:"No options"})}):B.map((y,A)=>{const E=b.includes(y.value),U=A===I,k=y.disabled??!1,D=P&&!E;return e.jsxs("div",{role:"option","aria-selected":E,"aria-disabled":k||D,onClick:()=>{!k&&!D&&N(y.value)},onMouseEnter:()=>w(A),style:{display:"flex",alignItems:"center",gap:ge[l],padding:ge[l],borderRadius:"var(--lucent-radius-md)",cursor:k||D?"not-allowed":"pointer",background:U?"var(--lucent-surface-secondary)":"transparent",opacity:k||D?.5:1},children:[e.jsx($e,{checked:E,disabled:k||D,size:l,style:{margin:0,pointerEvents:"none"},"aria-hidden":!0,readOnly:!0}),e.jsx(O,{size:bt[l],children:y.label})]},y.value)}),P&&e.jsx("div",{style:{padding:"var(--lucent-space-2)",borderTop:"1px solid var(--lucent-border-subtle)"},children:e.jsxs(O,{size:l==="lg"?"sm":"xs",color:"secondary",children:["Max ",s," selected"]})})]})]}),$&&e.jsx("span",{id:`${R}-error`,role:"alert",style:{fontSize:De[l],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:u}),!$&&d&&e.jsx("span",{id:`${R}-helper`,style:{fontSize:De[l],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:d})]})}const _r={id:"multi-select",name:"MultiSelect",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A tag-based multi-option selector with inline search, keyboard navigation, and an optional selection cap.",designIntent:"MultiSelect renders selected values as removable tags inside the trigger area, giving immediate visual feedback on what is selected. The search input sits inline with the tags so there is no separate search field to discover. Backspace with an empty query removes the last selected tag — a standard UX pattern in multi-select inputs. The max prop caps selection without disabling the entire component: unselected options beyond the cap are grayed out and show a hint. The dropdown closes on outside click, Escape, or when focus leaves. Checkbox indicators in the dropdown make the selected state scannable at a glance without relying solely on background color.",props:[{name:"options",type:"array",required:!0,description:"Array of { value, label, disabled? } option objects."},{name:"value",type:"array",required:!1,description:"Controlled array of selected values."},{name:"defaultValue",type:"array",required:!1,default:"[]",description:"Initial selected values for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called with the updated array of selected values on each change."},{name:"placeholder",type:"string",required:!1,default:'"Select…"',description:"Placeholder shown when nothing is selected."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables interaction and dims the component."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls trigger height and font size to match Input/Select.",enumValues:["sm","md","lg"]},{name:"max",type:"number",required:!1,description:"Maximum number of selectable options. Unselected options beyond the cap are grayed out."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Uncontrolled",code:`<MultiSelect
|
|
357
357
|
options={[
|
|
358
358
|
{ value: 'react', label: 'React' },
|
|
359
359
|
{ value: 'vue', label: 'Vue' },
|
|
@@ -367,14 +367,14 @@ const [results, setResults] = useState([]);
|
|
|
367
367
|
onChange={setTags}
|
|
368
368
|
max={3}
|
|
369
369
|
placeholder="Up to 3 tags"
|
|
370
|
-
/>`}],compositionGraph:[{componentId:"chip",componentName:"Chip",role:"Selected value chips with dismiss button",required:!0},{componentId:"checkbox",componentName:"Checkbox",role:"Selection indicator in dropdown options",required:!0},{componentId:"text",componentName:"Text",role:"Option labels, empty state, and max hint",required:!0}],accessibility:{role:"combobox",ariaAttributes:["aria-autocomplete","aria-controls","aria-expanded","aria-multiselectable","aria-selected","aria-disabled"],keyboardInteractions:["↑↓ to navigate options","Enter to toggle selection","Escape to close","Backspace to remove last tag"],notes:'The input carries role="combobox" with aria-expanded and aria-controls pointing to the listbox. Each option has role="option" with aria-selected. Remove buttons on tags have descriptive aria-label.'}};function Vr(e,n){return new Date(e,n+1,0).getDate()}function Ur(e,n){return new Date(e,n,1).getDay()}function ke(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Se(e,n){return new Date(e.getFullYear(),e.getMonth(),e.getDate())<new Date(n.getFullYear(),n.getMonth(),n.getDate())}function vt(e,n){return new Date(e.getFullYear(),e.getMonth(),e.getDate())>new Date(n.getFullYear(),n.getMonth(),n.getDate())}const Gr=["January","February","March","April","May","June","July","August","September","October","November","December"],_r=["Su","Mo","Tu","We","Th","Fr","Sa"];function de(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}const Yr={sm:"calc(var(--lucent-space-8) * 0.5 + 18px)",md:"calc(var(--lucent-space-10) * 0.5 + 22px)",lg:"calc(var(--lucent-space-12) * 0.5 + 26px)"},Kr={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},ze={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Xr={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},Jr={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"};function yt({dir:e,onClick:n,disabled:r}){const[o,a]=p.useState(!1);return t.jsx("button",{type:"button",onClick:n,disabled:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),"aria-label":e==="prev"?"Previous month":"Next month",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:"none",borderRadius:"var(--lucent-radius-md)",background:o&&!r?"var(--lucent-surface-secondary)":"transparent",color:r?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",cursor:r?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:t.jsx("path",{d:e==="prev"?"M10 12L6 8l4-4":"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Le({year:e,month:n,selected:r,today:o,min:a,max:s,onSelect:i,onPrevMonth:l,onNextMonth:c,highlightRange:d,onDayHover:u}){const h=Vr(e,n),m=Ur(e,n),[g,C]=p.useState(null),y=[...Array(m).fill(null),...Array.from({length:h},(f,v)=>v+1)];for(;y.length%7!==0;)y.push(null);return t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"var(--lucent-space-3)"},children:[t.jsx(yt,{dir:"prev",onClick:l}),t.jsxs(O,{weight:"medium",size:"sm",children:[Gr[n]," ",e]}),t.jsx(yt,{dir:"next",onClick:c})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2,marginBottom:"var(--lucent-space-1)"},children:_r.map(f=>t.jsx("div",{style:{textAlign:"center"},children:t.jsx(O,{size:"xs",color:"secondary",children:f})},f))}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2},children:y.map((f,v)=>{if(!f)return t.jsx("div",{},v);const b=new Date(e,n,f),T=r?ke(b,r):!1,D=ke(b,o),x=(a?Se(b,a):!1)||(s?vt(b,s):!1);let M=!1;return d!=null&&d.start&&(d!=null&&d.end)&&(M=!Se(b,d.start)&&!vt(b,d.end)),t.jsx("button",{type:"button",disabled:x,onClick:()=>!x&&i(b),onMouseEnter:()=>{C(f),u==null||u(b)},onMouseLeave:()=>{C(null),u==null||u(null)},"aria-label":de(b),"aria-pressed":T,style:{display:"flex",alignItems:"center",justifyContent:"center",height:32,width:"100%",border:D&&!T?"1px solid var(--lucent-border-strong)":"1px solid transparent",borderRadius:"var(--lucent-radius-md)",background:T?"var(--lucent-accent-default)":M?"var(--lucent-accent-subtle)":g===f&&!x?"var(--lucent-surface-secondary)":"transparent",color:T?"var(--lucent-text-on-accent)":x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:"var(--lucent-font-size-sm)",fontFamily:"var(--lucent-font-family-base)",fontWeight:D?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:x?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:f},v)})})]})}function Zr({value:e,defaultValue:n,onChange:r,placeholder:o="Pick a date",disabled:a=!1,min:s,max:i,size:l="md",label:c,helperText:d,errorText:u,style:h}){const m=e!==void 0,[g,C]=p.useState(n),y=m?e:g,f=!!u,v=a,b=`lucent-datepicker-${Math.random().toString(36).slice(2,7)}`,T=new Date,[D,x]=p.useState((y??T).getFullYear()),[M,P]=p.useState((y??T).getMonth()),[k,j]=p.useState(!1),[W,R]=p.useState(!1),z=p.useRef(null);p.useEffect(()=>{if(!k)return;const I=N=>{var S;(S=z.current)!=null&&S.contains(N.target)||j(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[k]);const F=I=>{m||C(I),r==null||r(I),j(!1)},B=()=>{M===0?(P(11),x(I=>I-1)):P(I=>I-1)},$=()=>{M===11?(P(0),x(I=>I+1)):P(I=>I+1)},U=v?"transparent":f?"var(--lucent-danger-default)":W?"var(--lucent-focus-ring)":"var(--lucent-border-default)",K=W?`0 0 0 3px ${f?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none";return t.jsxs("div",{ref:z,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",position:"relative",...h},children:[c&&t.jsx("label",{htmlFor:b,style:{fontSize:ze[l],fontWeight:"var(--lucent-font-weight-medium)",color:v?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:c}),t.jsxs("button",{type:"button",id:b,disabled:a,onClick:()=>!a&&j(I=>!I),onFocus:()=>R(!0),onBlur:()=>R(!1),"aria-haspopup":"dialog","aria-expanded":k,"aria-invalid":f,style:{display:"flex",alignItems:"center",gap:Jr[l],width:"100%",height:Yr[l],boxSizing:"border-box",padding:`0 ${Xr[l]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${U}`,boxShadow:K,background:v?"var(--lucent-surface-secondary)":"var(--lucent-surface)",color:y?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:Kr[l],cursor:v?"not-allowed":"pointer",outline:"none",transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,style:{flexShrink:0},children:[t.jsx("rect",{x:"1",y:"2",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.3"}),t.jsx("path",{d:"M1 6h12",stroke:"currentColor",strokeWidth:"1.3"}),t.jsx("path",{d:"M4 1v2M10 1v2",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),t.jsx("span",{style:{flex:1,textAlign:"left"},children:y?de(y):o})]}),f&&t.jsx("span",{role:"alert",style:{fontSize:ze[l],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:u}),!f&&d&&t.jsx("span",{style:{fontSize:ze[l],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),k&&t.jsx("div",{role:"dialog","aria-label":"Date picker",style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,zIndex:1e3,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",padding:"var(--lucent-space-4)",minWidth:260},children:t.jsx(Le,{year:D,month:M,...y!==void 0&&{selected:y},today:T,...s!==void 0&&{min:s},...i!==void 0&&{max:i},onSelect:F,onPrevMonth:B,onNextMonth:$})})]})}const Qr={id:"date-picker",name:"DatePicker",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A single-date picker with a calendar popover, month navigation, today highlight, min/max constraints, and controlled or uncontrolled modes.",designIntent:`DatePicker deliberately avoids native <input type="date"> to guarantee consistent cross-browser appearance that matches the Lucent token system. The trigger button shows the selected date in YYYY-MM-DD format (ISO-sortable, unambiguous locale-wise) or a placeholder. The calendar popover renders as a role="dialog" and closes on outside click. Today is outlined rather than filled so it doesn't compete visually with the selected date. Disabled dates (outside min/max) are grayed out and non-interactive. The Calendar primitive is exported separately so DateRangePicker can compose two calendars side by side.`,props:[{name:"value",type:"object",required:!1,description:"Controlled selected Date. When provided the component is fully controlled."},{name:"defaultValue",type:"object",required:!1,description:"Initial selected Date for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called with the newly selected Date when the user picks a day."},{name:"placeholder",type:"string",required:!1,default:'"Pick a date"',description:"Trigger button text when no date is selected."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls trigger height and font size to match Input/Select.",enumValues:["sm","md","lg"]},{name:"label",type:"string",required:!1,description:"Label text rendered above the trigger, with size-aware font sizing matching Input/Select."},{name:"helperText",type:"string",required:!1,description:"Helper text rendered below the trigger. Hidden when errorText is present."},{name:"errorText",type:"string",required:!1,description:"Error text rendered below the trigger in danger color. Takes precedence over helperText."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the trigger button and all interaction."},{name:"min",type:"object",required:!1,description:"Earliest selectable Date. Days before this are grayed out."},{name:"max",type:"object",required:!1,description:"Latest selectable Date. Days after this are grayed out."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Uncontrolled",code:"<DatePicker onChange={(d) => console.log(d)} />"},{title:"Controlled with constraints",code:`const [date, setDate] = useState<Date>();
|
|
370
|
+
/>`}],compositionGraph:[{componentId:"chip",componentName:"Chip",role:"Selected value chips with dismiss button",required:!0},{componentId:"checkbox",componentName:"Checkbox",role:"Selection indicator in dropdown options",required:!0},{componentId:"text",componentName:"Text",role:"Option labels, empty state, and max hint",required:!0}],accessibility:{role:"combobox",ariaAttributes:["aria-autocomplete","aria-controls","aria-expanded","aria-multiselectable","aria-selected","aria-disabled"],keyboardInteractions:["↑↓ to navigate options","Enter to toggle selection","Escape to close","Backspace to remove last tag"],notes:'The input carries role="combobox" with aria-expanded and aria-controls pointing to the listbox. Each option has role="option" with aria-selected. Remove buttons on tags have descriptive aria-label.'}};function Yr(t,n){return new Date(t,n+1,0).getDate()}function Kr(t,n){return new Date(t,n,1).getDay()}function ke(t,n){return t.getFullYear()===n.getFullYear()&&t.getMonth()===n.getMonth()&&t.getDate()===n.getDate()}function Se(t,n){return new Date(t.getFullYear(),t.getMonth(),t.getDate())<new Date(n.getFullYear(),n.getMonth(),n.getDate())}function yt(t,n){return new Date(t.getFullYear(),t.getMonth(),t.getDate())>new Date(n.getFullYear(),n.getMonth(),n.getDate())}const Xr=["January","February","March","April","May","June","July","August","September","October","November","December"],Jr=["Su","Mo","Tu","We","Th","Fr","Sa"];function de(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}const Zr={sm:"calc(var(--lucent-space-8) * 0.5 + 18px)",md:"calc(var(--lucent-space-10) * 0.5 + 22px)",lg:"calc(var(--lucent-space-12) * 0.5 + 26px)"},Qr={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},ze={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},eo={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},to={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"};function xt({dir:t,onClick:n,disabled:r}){const[o,a]=p.useState(!1);return e.jsx("button",{type:"button",onClick:n,disabled:r,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),"aria-label":t==="prev"?"Previous month":"Next month",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,border:"none",borderRadius:"var(--lucent-radius-md)",background:o&&!r?"var(--lucent-surface-secondary)":"transparent",color:r?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",cursor:r?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:t==="prev"?"M10 12L6 8l4-4":"M6 4l4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})}function Le({year:t,month:n,selected:r,today:o,min:a,max:i,onSelect:s,onPrevMonth:l,onNextMonth:c,highlightRange:d,onDayHover:u}){const h=Yr(t,n),m=Kr(t,n),[g,C]=p.useState(null),b=[...Array(m).fill(null),...Array.from({length:h},(f,v)=>v+1)];for(;b.length%7!==0;)b.push(null);return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"var(--lucent-space-3)"},children:[e.jsx(xt,{dir:"prev",onClick:l}),e.jsxs(O,{weight:"medium",size:"sm",children:[Xr[n]," ",t]}),e.jsx(xt,{dir:"next",onClick:c})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2,marginBottom:"var(--lucent-space-1)"},children:Jr.map(f=>e.jsx("div",{style:{textAlign:"center"},children:e.jsx(O,{size:"xs",color:"secondary",children:f})},f))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2},children:b.map((f,v)=>{if(!f)return e.jsx("div",{},v);const S=new Date(t,n,f),x=r?ke(S,r):!1,I=ke(S,o),w=(a?Se(S,a):!1)||(i?yt(S,i):!1);let z=!1;return d!=null&&d.start&&(d!=null&&d.end)&&(z=!Se(S,d.start)&&!yt(S,d.end)),e.jsx("button",{type:"button",disabled:w,onClick:()=>!w&&s(S),onMouseEnter:()=>{C(f),u==null||u(S)},onMouseLeave:()=>{C(null),u==null||u(null)},"aria-label":de(S),"aria-pressed":x,style:{display:"flex",alignItems:"center",justifyContent:"center",height:32,width:"100%",border:I&&!x?"1px solid var(--lucent-border-strong)":"1px solid transparent",borderRadius:"var(--lucent-radius-md)",background:x?"var(--lucent-accent-default)":z?"var(--lucent-accent-subtle)":g===f&&!w?"var(--lucent-surface-secondary)":"transparent",color:x?"var(--lucent-text-on-accent)":w?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:"var(--lucent-font-size-sm)",fontFamily:"var(--lucent-font-family-base)",fontWeight:I?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:w?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:f},v)})})]})}function no({value:t,defaultValue:n,onChange:r,placeholder:o="Pick a date",disabled:a=!1,min:i,max:s,size:l="md",label:c,helperText:d,errorText:u,style:h}){const m=t!==void 0,[g,C]=p.useState(n),b=m?t:g,f=!!u,v=a,S=`lucent-datepicker-${Math.random().toString(36).slice(2,7)}`,x=new Date,[I,w]=p.useState((b??x).getFullYear()),[z,q]=p.useState((b??x).getMonth()),[T,M]=p.useState(!1),[F,N]=p.useState(!1),j=p.useRef(null);p.useEffect(()=>{if(!T)return;const H=R=>{var y;(y=j.current)!=null&&y.contains(R.target)||M(!1)};return document.addEventListener("mousedown",H),()=>document.removeEventListener("mousedown",H)},[T]);const B=H=>{m||C(H),r==null||r(H),M(!1)},L=()=>{z===0?(q(11),w(H=>H-1)):q(H=>H-1)},P=()=>{z===11?(q(0),w(H=>H+1)):q(H=>H+1)},$=v?"transparent":f?"var(--lucent-danger-default)":F?"var(--lucent-focus-ring)":"var(--lucent-border-default)",X=F?`0 0 0 3px ${f?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none";return e.jsxs("div",{ref:j,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",position:"relative",...h},children:[c&&e.jsx("label",{htmlFor:S,style:{fontSize:ze[l],fontWeight:"var(--lucent-font-weight-medium)",color:v?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:c}),e.jsxs("button",{type:"button",id:S,disabled:a,onClick:()=>!a&&M(H=>!H),onFocus:()=>N(!0),onBlur:()=>N(!1),"aria-haspopup":"dialog","aria-expanded":T,"aria-invalid":f,style:{display:"flex",alignItems:"center",gap:to[l],width:"100%",height:Zr[l],boxSizing:"border-box",padding:`0 ${eo[l]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${$}`,boxShadow:X,background:v?"var(--lucent-surface-secondary)":"var(--lucent-surface)",color:b?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:Qr[l],cursor:v?"not-allowed":"pointer",outline:"none",transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,style:{flexShrink:0},children:[e.jsx("rect",{x:"1",y:"2",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M1 6h12",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M4 1v2M10 1v2",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:b?de(b):o})]}),f&&e.jsx("span",{role:"alert",style:{fontSize:ze[l],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:u}),!f&&d&&e.jsx("span",{style:{fontSize:ze[l],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),T&&e.jsx("div",{role:"dialog","aria-label":"Date picker",style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,zIndex:1e3,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",padding:"var(--lucent-space-4)",minWidth:260},children:e.jsx(Le,{year:I,month:z,...b!==void 0&&{selected:b},today:x,...i!==void 0&&{min:i},...s!==void 0&&{max:s},onSelect:B,onPrevMonth:L,onNextMonth:P})})]})}const ao={id:"date-picker",name:"DatePicker",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A single-date picker with a calendar popover, month navigation, today highlight, min/max constraints, and controlled or uncontrolled modes.",designIntent:`DatePicker deliberately avoids native <input type="date"> to guarantee consistent cross-browser appearance that matches the Lucent token system. The trigger button shows the selected date in YYYY-MM-DD format (ISO-sortable, unambiguous locale-wise) or a placeholder. The calendar popover renders as a role="dialog" and closes on outside click. Today is outlined rather than filled so it doesn't compete visually with the selected date. Disabled dates (outside min/max) are grayed out and non-interactive. The Calendar primitive is exported separately so DateRangePicker can compose two calendars side by side.`,props:[{name:"value",type:"object",required:!1,description:"Controlled selected Date. When provided the component is fully controlled."},{name:"defaultValue",type:"object",required:!1,description:"Initial selected Date for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called with the newly selected Date when the user picks a day."},{name:"placeholder",type:"string",required:!1,default:'"Pick a date"',description:"Trigger button text when no date is selected."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls trigger height and font size to match Input/Select.",enumValues:["sm","md","lg"]},{name:"label",type:"string",required:!1,description:"Label text rendered above the trigger, with size-aware font sizing matching Input/Select."},{name:"helperText",type:"string",required:!1,description:"Helper text rendered below the trigger. Hidden when errorText is present."},{name:"errorText",type:"string",required:!1,description:"Error text rendered below the trigger in danger color. Takes precedence over helperText."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the trigger button and all interaction."},{name:"min",type:"object",required:!1,description:"Earliest selectable Date. Days before this are grayed out."},{name:"max",type:"object",required:!1,description:"Latest selectable Date. Days after this are grayed out."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Uncontrolled",code:"<DatePicker onChange={(d) => console.log(d)} />"},{title:"Controlled with constraints",code:`const [date, setDate] = useState<Date>();
|
|
371
371
|
<DatePicker
|
|
372
372
|
value={date}
|
|
373
373
|
onChange={setDate}
|
|
374
374
|
min={new Date()}
|
|
375
375
|
placeholder="Select a future date"
|
|
376
|
-
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Month/year header and weekday labels",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-haspopup","aria-expanded","aria-invalid","aria-label","aria-pressed"],keyboardInteractions:["Enter/Space to open calendar","Click day to select","Escape closes popover (click outside)"],notes:'The calendar popover is role="dialog". Each day button has aria-label with the full date and aria-pressed for selected state. Full arrow-key navigation within the calendar grid is a planned enhancement.'}},
|
|
377
|
-
<DateRangePicker value={range} onChange={setRange} min={new Date()} />`}],compositionGraph:[{componentId:"date-picker",componentName:"DatePicker",role:"Calendar primitive (two instances, left and right)",required:!0},{componentId:"text",componentName:"Text",role:"Mid-selection hint and calendar headers",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-haspopup","aria-expanded","aria-invalid","aria-label","aria-pressed"],keyboardInteractions:["Enter/Space to open","Click first day to set start","Click second day to set end","Escape/click outside to cancel"],notes:'Inherits Calendar accessibility from DatePicker. The two-step selection flow is reinforced with a visible "Now pick the end date" hint.'}};function
|
|
376
|
+
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Month/year header and weekday labels",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-haspopup","aria-expanded","aria-invalid","aria-label","aria-pressed"],keyboardInteractions:["Enter/Space to open calendar","Click day to select","Escape closes popover (click outside)"],notes:'The calendar popover is role="dialog". Each day button has aria-label with the full date and aria-pressed for selected state. Full arrow-key navigation within the calendar grid is a planned enhancement.'}},ro={sm:"calc(var(--lucent-space-8) * 0.5 + 18px)",md:"calc(var(--lucent-space-10) * 0.5 + 22px)",lg:"calc(var(--lucent-space-12) * 0.5 + 26px)"},oo={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},io={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},so={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"},Ee={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"};function lo(t,n){return t?ke(t.start,t.end)?de(t.start):`${de(t.start)} → ${de(t.end)}`:n}function co({value:t,defaultValue:n,onChange:r,placeholder:o="Pick a date range",disabled:a=!1,min:i,max:s,size:l="md",label:c,helperText:d,errorText:u,style:h}){const m=t!==void 0,[g,C]=p.useState(n),b=m?t:g,f=!!u,v=a,S=`lucent-daterangepicker-${Math.random().toString(36).slice(2,7)}`,[x,I]=p.useState(null),[w,z]=p.useState(null),q=new Date,[T,M]=p.useState(((b==null?void 0:b.start)??q).getFullYear()),[F,N]=p.useState(((b==null?void 0:b.start)??q).getMonth()),j=F===11?0:F+1,B=F===11?T+1:T,[L,P]=p.useState(!1),[$,X]=p.useState(!1),H=p.useRef(null);p.useEffect(()=>{if(!L)return;const D=W=>{var G;(G=H.current)!=null&&G.contains(W.target)||(P(!1),I(null))};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[L]);const R=D=>{if(!x)I(D);else{const[W,G]=Se(D,x)||ke(D,x)?[D,x]:[x,D],K={start:W,end:G};m||C(K),r==null||r(K),I(null),P(!1)}},y=()=>{F===0?(N(11),M(D=>D-1)):N(D=>D-1)},A=()=>{F===11?(N(0),M(D=>D+1)):N(D=>D+1)};let E;if(x&&w){const[D,W]=Se(w,x)?[w,x]:[x,w];E={start:D,end:W}}else x?E={start:x,end:x}:b&&(E={start:b.start,end:b.end});const U=v?"transparent":f?"var(--lucent-danger-default)":$?"var(--lucent-focus-ring)":"var(--lucent-border-default)",k=$?`0 0 0 3px ${f?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none";return e.jsxs("div",{ref:H,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",position:"relative",...h},children:[c&&e.jsx("label",{htmlFor:S,style:{fontSize:Ee[l],fontWeight:"var(--lucent-font-weight-medium)",color:v?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:c}),e.jsxs("button",{type:"button",id:S,disabled:a,onClick:()=>!a&&P(D=>!D),onFocus:()=>X(!0),onBlur:()=>X(!1),"aria-haspopup":"dialog","aria-expanded":L,"aria-invalid":f,style:{display:"flex",alignItems:"center",gap:so[l],width:"100%",height:ro[l],boxSizing:"border-box",padding:`0 ${io[l]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${U}`,boxShadow:k,background:v?"var(--lucent-surface-secondary)":"var(--lucent-surface)",color:b?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:oo[l],cursor:v?"not-allowed":"pointer",outline:"none",transition:["border-color var(--lucent-duration-fast) var(--lucent-easing-default)","box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)"].join(", ")},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":!0,style:{flexShrink:0},children:[e.jsx("rect",{x:"1",y:"2",width:"12",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M1 6h12",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M4 1v2M10 1v2",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"})]}),e.jsx("span",{style:{flex:1,textAlign:"left"},children:lo(b,o)})]}),f&&e.jsx("span",{role:"alert",style:{fontSize:Ee[l],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:u}),!f&&d&&e.jsx("span",{style:{fontSize:Ee[l],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),L&&e.jsxs("div",{role:"dialog","aria-label":"Date range picker",style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,zIndex:1e3,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",padding:"var(--lucent-space-4)",display:"flex",gap:"var(--lucent-space-6)"},children:[e.jsx("div",{style:{minWidth:220},children:e.jsx(Le,{year:T,month:F,...(b==null?void 0:b.start)!==void 0&&{selected:b.start},today:q,...i!==void 0&&{min:i},...s!==void 0&&{max:s},onSelect:R,onPrevMonth:y,onNextMonth:A,...E!==void 0&&{highlightRange:E},...x&&{onDayHover:z}})}),e.jsx("div",{style:{width:1,background:"var(--lucent-border-subtle)",flexShrink:0}}),e.jsx("div",{style:{minWidth:220},children:e.jsx(Le,{year:B,month:j,...(b==null?void 0:b.end)!==void 0&&{selected:b.end},today:q,...i!==void 0&&{min:i},...s!==void 0&&{max:s},onSelect:R,onPrevMonth:y,onNextMonth:A,...E!==void 0&&{highlightRange:E},...x&&{onDayHover:z}})})]}),x&&L&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,zIndex:1001,pointerEvents:"none"}}),x&&L&&e.jsx("div",{style:{position:"absolute",bottom:-24,left:0},children:e.jsx(O,{size:"xs",color:"secondary",children:"Now pick the end date"})})]})}const uo={id:"date-range-picker",name:"DateRangePicker",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A two-calendar date range picker. First click sets the start date, second click sets the end; the selected interval is highlighted across both calendars.",designIntent:'DateRangePicker composes two Calendar primitives from DatePicker side by side, advancing in lockstep (left = current month, right = next month). Selection is a two-click flow: first click anchors the start, a hint appears ("Now pick the end date"), second click resolves the range with automatic start/end ordering so users can click in either direction. The highlight range (accent-subtle background) spans both calendars to give clear visual feedback for the selected interval. Navigation (prev/next month) advances both calendars together to maintain the one-month-apart constraint.',props:[{name:"value",type:"object",required:!1,description:"Controlled DateRange { start: Date; end: Date }. When provided the component is fully controlled."},{name:"defaultValue",type:"object",required:!1,description:"Initial DateRange for uncontrolled usage."},{name:"onChange",type:"function",required:!1,description:"Called with the completed DateRange after the user picks both start and end."},{name:"placeholder",type:"string",required:!1,default:'"Pick a date range"',description:"Trigger button text when no range is selected."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls trigger height and font size to match Input/Select.",enumValues:["sm","md","lg"]},{name:"label",type:"string",required:!1,description:"Label text rendered above the trigger, with size-aware font sizing matching Input/Select."},{name:"helperText",type:"string",required:!1,description:"Helper text rendered below the trigger. Hidden when errorText is present."},{name:"errorText",type:"string",required:!1,description:"Error text rendered below the trigger in danger color. Takes precedence over helperText."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the trigger button and all interaction."},{name:"min",type:"object",required:!1,description:"Earliest selectable Date."},{name:"max",type:"object",required:!1,description:"Latest selectable Date."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Uncontrolled",code:"<DateRangePicker onChange={({ start, end }) => console.log(start, end)} />"},{title:"Controlled",code:`const [range, setRange] = useState<DateRange>();
|
|
377
|
+
<DateRangePicker value={range} onChange={setRange} min={new Date()} />`}],compositionGraph:[{componentId:"date-picker",componentName:"DatePicker",role:"Calendar primitive (two instances, left and right)",required:!0},{componentId:"text",componentName:"Text",role:"Mid-selection hint and calendar headers",required:!0}],accessibility:{role:"dialog",ariaAttributes:["aria-haspopup","aria-expanded","aria-invalid","aria-label","aria-pressed"],keyboardInteractions:["Enter/Space to open","Click first day to set start","Click second day to set end","Escape/click outside to cancel"],notes:'Inherits Calendar accessibility from DatePicker. The two-step selection flow is reinforced with a visible "Now pick the end date" hint.'}};function Pe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function po(){return Math.random().toString(36).slice(2)}function fo({item:t,onRemove:n}){const[r,o]=p.useState(!1),a=t.progress,i=!!t.error;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-2) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",border:`1px solid ${i?"var(--lucent-danger-default)":"var(--lucent-border-default)"}`,background:"var(--lucent-surface)"},children:[e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":!0,style:{flexShrink:0,color:"var(--lucent-text-secondary)"},children:[e.jsx("path",{d:"M5 2h7l4 4v12a1 1 0 01-1 1H5a1 1 0 01-1-1V3a1 1 0 011-1z",stroke:"currentColor",strokeWidth:"1.3"}),e.jsx("path",{d:"M12 2v4h4",stroke:"currentColor",strokeWidth:"1.3"})]}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(O,{size:"sm",truncate:!0,children:t.file.name}),i?e.jsx(O,{size:"xs",color:"danger",children:t.error}):e.jsx(O,{size:"xs",color:"secondary",children:Pe(t.file.size)}),a!==void 0&&!i&&e.jsx("div",{style:{marginTop:4,height:3,borderRadius:"var(--lucent-radius-full)",background:"var(--lucent-surface-secondary)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${a}%`,borderRadius:"var(--lucent-radius-full)",background:a===100?"var(--lucent-success-default)":"var(--lucent-accent-default)",transition:"width 200ms var(--lucent-easing-default)"}})})]}),e.jsx("button",{type:"button",onClick:()=>n(t.id),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),"aria-label":`Remove ${t.file.name}`,style:{flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",width:24,height:24,border:"none",borderRadius:"var(--lucent-radius-md)",background:r?"var(--lucent-surface-secondary)":"transparent",color:"var(--lucent-text-secondary)",cursor:"pointer",transition:"background var(--lucent-duration-fast)"},children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})}function ho({accept:t,multiple:n=!1,maxSize:r,value:o,onChange:a,onError:i,disabled:s=!1,style:l}){const c=o!==void 0,[d,u]=p.useState([]),h=c?o:d,[m,g]=p.useState(!1),[C,b]=p.useState(!1),f=p.useRef(null),v=p.useCallback(w=>{if(!w||s)return;const z=[];for(const T of Array.from(w)){if(r&&T.size>r){i==null||i(`"${T.name}" exceeds the ${Pe(r)} limit.`);continue}if(!n&&h.length+z.length>=1)break;z.push({id:po(),file:T})}if(z.length===0)return;const q=n?[...h,...z]:z;c||u(q),a==null||a(q)},[s,h,c,r,n,a,i]),S=w=>{const z=h.filter(q=>q.id!==w);c||u(z),a==null||a(z)},x=w=>{w.preventDefault(),g(!1),v(w.dataTransfer.files)},I=w=>{v(w.target.files),w.target.value=""};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...l},children:[e.jsxs("div",{role:"button",tabIndex:s?-1:0,"aria-label":"Upload files","aria-disabled":s,onClick:()=>{var w;return!s&&((w=f.current)==null?void 0:w.click())},onKeyDown:w=>{var z;(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),(z=f.current)==null||z.click())},onFocus:()=>b(!0),onBlur:()=>b(!1),onDragOver:w=>{w.preventDefault(),s||g(!0)},onDragLeave:()=>g(!1),onDrop:x,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"var(--lucent-space-2)",padding:"var(--lucent-space-8) var(--lucent-space-6)",borderRadius:"var(--lucent-radius-lg)",border:`2px dashed ${s?"var(--lucent-border-default)":m||C?"var(--lucent-accent-default)":"var(--lucent-border-default)"}`,background:m?"var(--lucent-accent-subtle)":"var(--lucent-surface-secondary)",cursor:s?"not-allowed":"pointer",transition:"border-color var(--lucent-duration-fast), background var(--lucent-duration-fast)",outline:"none"},children:[e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 32 32",fill:"none","aria-hidden":!0,style:{color:s?"var(--lucent-text-disabled)":m?"var(--lucent-accent-default)":"var(--lucent-text-secondary)"},children:[e.jsx("path",{d:"M16 20V10M16 10l-4 4M16 10l4 4",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 24h16",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx(O,{color:s?"disabled":"primary",weight:"medium",children:m?"Drop to upload":"Drop files here or click to browse"}),(t||r)&&e.jsx(O,{size:"xs",color:"secondary",children:[t&&`Accepted: ${t}`,r&&`Max size: ${Pe(r)}`].filter(Boolean).join(" · ")})]}),e.jsx("input",{ref:f,type:"file",accept:t,multiple:n,disabled:s,onChange:I,style:{display:"none"},tabIndex:-1})]}),h.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)"},children:h.map(w=>e.jsx(fo,{item:w,onRemove:S},w.id))})]})}const mo={id:"file-upload",name:"FileUpload",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A drag-and-drop file upload zone with a file list, per-file progress bars, error display, and size/type validation.",designIntent:'FileUpload separates concerns between the drop zone (entry point) and the file list (status display). The drop zone uses a dashed border and an upload arrow icon to communicate droppability without words. Progress is modelled as a field on UploadFile rather than as a callback so the parent controls upload logic — this component is purely presentational for the upload state. The progress bar turns success-green at 100% to give clear completion feedback. Errors are shown inline on each file row (not as a toast) so the user knows exactly which file failed and why. The hidden <input type="file"> is triggered programmatically on click/keyboard so the drop zone can have a fully custom appearance.',props:[{name:"accept",type:"string",required:!1,description:'Accepted MIME types or extensions passed to the file input, e.g. "image/*,.pdf".'},{name:"multiple",type:"boolean",required:!1,default:"false",description:"Allow selecting multiple files at once."},{name:"maxSize",type:"number",required:!1,description:"Maximum file size in bytes. Files exceeding this trigger onError and are not added."},{name:"value",type:"array",required:!1,description:"Controlled array of UploadFile objects. Each has id, file (File), optional progress (0–100), and optional error string."},{name:"onChange",type:"function",required:!1,description:"Called with the updated UploadFile array after files are added or removed."},{name:"onError",type:"function",required:!1,description:"Called with an error message string when a file fails validation (e.g. exceeds maxSize)."},{name:"disabled",type:"boolean",required:!1,default:"false",description:"Disables the drop zone and all file interaction."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer wrapper."}],usageExamples:[{title:"Uncontrolled multi-file upload",code:`<FileUpload
|
|
378
378
|
multiple
|
|
379
379
|
accept="image/*,.pdf"
|
|
380
380
|
maxSize={5 * 1024 * 1024}
|
|
@@ -393,7 +393,7 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
393
393
|
}
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
-
<FileUpload value={files} onChange={handleChange} multiple />`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Drop zone label, file name, file size, and error messages",required:!0}],accessibility:{role:"button",ariaAttributes:["aria-label","aria-disabled"],keyboardInteractions:["Enter/Space to open file picker","Tab to focus drop zone"],notes:'The drop zone has role="button" with tabIndex=0 and responds to Enter/Space. Remove buttons on file rows have aria-label including the filename.'}},
|
|
396
|
+
<FileUpload value={files} onChange={handleChange} multiple />`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Drop zone label, file name, file size, and error messages",required:!0}],accessibility:{role:"button",ariaAttributes:["aria-label","aria-disabled"],keyboardInteractions:["Enter/Space to open file picker","Tab to focus drop zone"],notes:'The drop zone has role="button" with tabIndex=0 and responds to Enter/Space. Remove buttons on file rows have aria-label including the filename.'}},go={default:"var(--lucent-border-strong)",success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"},vo={default:"var(--lucent-surface-secondary)",success:"var(--lucent-success-subtle)",warning:"var(--lucent-warning-subtle)",danger:"var(--lucent-danger-subtle)",info:"var(--lucent-info-subtle)"};function bo({status:t}){return t==="success"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M2 5l2 2 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}):t==="danger"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M2 2l6 6M8 2L2 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}):t==="warning"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,children:e.jsx("path",{d:"M5 2v4M5 7.5v.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}):null}function yo({items:t,style:n}){return e.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",...n},children:t.map((r,o)=>{const a=r.status??"default",i=go[a],s=vo[a],l=o===t.length-1;return e.jsxs("li",{style:{display:"flex",gap:"var(--lucent-space-4)",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:28},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"var(--lucent-radius-full)",border:`2px solid ${i}`,background:s,display:"flex",alignItems:"center",justifyContent:"center",color:i,flexShrink:0,zIndex:1},children:r.icon??e.jsx(bo,{status:a})}),!l&&e.jsx("div",{style:{flex:1,width:2,background:"var(--lucent-border-subtle)",minHeight:"var(--lucent-space-4)",margin:"2px 0"}})]}),e.jsxs("div",{style:{flex:1,paddingBottom:l?0:"var(--lucent-space-6)",paddingTop:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:"var(--lucent-space-3)",flexWrap:"wrap"},children:[e.jsx(O,{weight:"medium",size:"sm",children:r.title}),r.date&&e.jsx(O,{size:"xs",color:"secondary",children:r.date})]}),r.description&&e.jsx("div",{style:{marginTop:"var(--lucent-space-1)"},children:e.jsx(O,{size:"sm",color:"secondary",children:r.description})})]})]},r.id)})})}const xo={id:"timeline",name:"Timeline",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A vertical ordered event list with status-colored dots, connector lines, optional dates, and custom icons.",designIntent:"Timeline renders as a semantic <ol> with each event as a <li>, preserving document order for assistive technologies. The dot and connector are rendered in a fixed-width left column so content in the right column can wrap freely without misaligning the spine. The connector line is omitted on the last item — there is nothing to connect to. Status colors follow the same semantic token set as Alert and Badge so danger/success/warning/info carry consistent meaning across the design system. Default status (no explicit icon) renders a plain dot; success/danger/warning get built-in iconography inside the dot. Custom icons slot in via the icon prop to handle domain-specific event types (e.g. a deploy icon, a payment icon).",props:[{name:"items",type:"array",required:!0,description:"Array of TimelineItem objects. Each has id, title, optional description, optional date string, optional status, and optional icon."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer <ol> wrapper."}],usageExamples:[{title:"Basic event log",code:`<Timeline
|
|
397
397
|
items={[
|
|
398
398
|
{ id: '1', title: 'Order placed', date: 'Mar 1, 2026', status: 'success' },
|
|
399
399
|
{ id: '2', title: 'Payment processed', date: 'Mar 1, 2026', status: 'success' },
|
|
@@ -406,7 +406,7 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
406
406
|
{ id: 'review', title: 'PR #47 merged', icon: <GitMergeIcon />, date: '3h ago' },
|
|
407
407
|
{ id: 'alert', title: 'Error rate spike', status: 'warning', icon: <AlertIcon />, date: '4h ago' },
|
|
408
408
|
]}
|
|
409
|
-
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Event title, description, and date label",required:!0}],accessibility:{role:"list",ariaAttributes:[],keyboardInteractions:["Standard document flow — no interactive elements unless custom icons include them"],notes:"Timeline is a semantic <ol> with <li> items. It is non-interactive by default. If items contain interactive elements (links, buttons), those elements carry their own keyboard behaviour."}},Ae=120,
|
|
409
|
+
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Event title, description, and date label",required:!0}],accessibility:{role:"list",ariaAttributes:[],keyboardInteractions:["Standard document flow — no interactive elements unless custom icons include them"],notes:"Timeline is a semantic <ol> with <li> items. It is non-interactive by default. If items contain interactive elements (links, buttons), those elements carry their own keyboard behaviour."}},Ae=120,wo=`
|
|
410
410
|
@keyframes lucent-menu-in {
|
|
411
411
|
from { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
412
412
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
@@ -415,7 +415,7 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
415
415
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
416
416
|
to { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
417
417
|
}
|
|
418
|
-
`,He={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},vo={sm:"sm",md:"md",lg:"lg"},yo={sm:"xs",md:"sm",lg:"md"},xo={sm:12,md:14,lg:16},Ve=p.createContext(null),be=4;function wo(e,n,r){const o=n.offsetWidth,a=n.offsetHeight,s=window.innerWidth,i=window.innerHeight;let l=0,c=0,d=r;const u={top:e.top-a-be,bottom:e.bottom+be,left:e.left-o-be,right:e.right+be};d.startsWith("bottom")?(l=u.bottom,l+a>i&&u.top>=0&&(l=u.top,d=d.replace("bottom","top"))):d.startsWith("top")?(l=u.top,l<0&&u.bottom+a<=i&&(l=u.bottom,d=d.replace("top","bottom"))):d==="left"?(l=e.top+e.height/2-a/2,c=u.left,c<0&&u.right+o<=s&&(c=u.right,d="right")):d==="right"&&(l=e.top+e.height/2-a/2,c=u.right,c+o>s&&u.left>=0&&(c=u.left,d="left")),(d.startsWith("top")||d.startsWith("bottom"))&&(d.endsWith("-start")?c=e.left:d.endsWith("-end")?c=e.right-o:c=e.left+e.width/2-o/2),c+o>s&&(c=s-o-8),c<0&&(c=8),l+a>i&&(l=i-a-8),l<0&&(l=8);let h="top left";return d.startsWith("top")?h=d.endsWith("-end")?"bottom right":d.endsWith("-start")?"bottom left":"bottom center":d.startsWith("bottom")?h=d.endsWith("-end")?"top right":d.endsWith("-start")?"top left":"top center":d==="left"?h="center right":d==="right"&&(h="center left"),{top:l,left:c,transformOrigin:h}}function ko({onSelect:e,children:n,icon:r,shortcut:o,disabled:a=!1,danger:s=!1,selected:i=!1,style:l}){const c=p.useContext(Ve),d=p.useRef(-1);d.current===-1&&c&&(d.current=c.getItemIndex(),c.registerItem(d.current,a));const u=c?c.activeIndex===d.current:!1,h=(c==null?void 0:c.size)??"md",m=He[h],g=vo[h],C=xo[h],y=()=>{a||(e(),c==null||c.close())},f=()=>{!a&&c&&c.setActiveIndex(d.current)},v=a?"var(--lucent-text-disabled)":s?"var(--lucent-danger-text)":"var(--lucent-text-primary)";return t.jsxs("div",{role:"menuitemcheckbox","aria-checked":i,"aria-disabled":a||void 0,"data-active":u||void 0,tabIndex:-1,onClick:y,onMouseEnter:f,style:{display:"flex",alignItems:"center",gap:m,padding:m,borderRadius:"var(--lucent-radius-md)",cursor:a?"not-allowed":"pointer",background:i?"color-mix(in srgb, var(--lucent-accent-default) 12%, var(--lucent-surface-overlay))":u?"var(--lucent-surface-secondary)":"transparent",boxShadow:i?"var(--lucent-shadow-sm)":"none",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)",opacity:a?.5:1,outline:"none",...l},children:[r&&t.jsx("span",{style:{flexShrink:0,display:"flex",color:a?"var(--lucent-text-disabled)":s?"var(--lucent-danger-text)":"var(--lucent-text-secondary)"},children:r}),t.jsx("span",{style:{flex:1,minWidth:0},children:t.jsx(O,{size:g,style:{color:v},children:n})}),o&&t.jsx(O,{size:h==="lg"?"sm":"xs",style:{color:"var(--lucent-text-secondary)",flexShrink:0},children:o}),i&&t.jsx("span",{style:{flexShrink:0,display:"flex",color:"var(--lucent-accent-default)"},children:t.jsx("svg",{width:C,height:C,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})})]})}function So({style:e}){return t.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)",...e}})}function To({label:e,children:n,style:r}){const o=p.useContext(Ve),a=(o==null?void 0:o.size)??"md",s=He[a];return t.jsxs("div",{role:"group","aria-label":e,style:r,children:[t.jsx("div",{style:{padding:`${s} ${s} var(--lucent-space-1)`},children:t.jsx(O,{size:yo[a],color:"secondary",weight:"medium",children:e})}),n]})}function Co({trigger:e,children:n,placement:r="bottom-start",size:o="md",open:a,onOpenChange:s,style:i}){const l=a!==void 0,[c,d]=p.useState(!1),u=l?a:c,[h,m]=p.useState(!1),[g,C]=p.useState("idle"),y=p.useRef(null),f=p.useRef(null),v=p.useRef(null),b=p.useRef(!1),[T,D]=p.useState(null),x=p.useRef(0),M=p.useRef(new Map),[P,k]=p.useState(-1);if(!b.current&&typeof document<"u"){const I=document.createElement("style");I.textContent=bo,document.head.appendChild(I),b.current=!0}p.useEffect(()=>{if(u)x.current=0,M.current.clear(),m(!0),C("entering");else if(h){C("exiting");const I=setTimeout(()=>{m(!1),C("idle")},Ae);return()=>clearTimeout(I)}},[u]);const j=p.useCallback(I=>{l||d(I),s==null||s(I)},[l,s]),W=p.useCallback(()=>{const I=v.current;I&&(I.querySelector("button, [tabindex]")??I).focus()},[]),R=p.useCallback(()=>{j(!1),W()},[j,W]);p.useLayoutEffect(()=>{if(!h||g!=="entering"||!y.current)return;const I=requestAnimationFrame(()=>{const N=f.current,S=y.current;if(!N||!S)return;const E=S.getBoundingClientRect();D(wo(E,N,r))});return()=>cancelAnimationFrame(I)},[h,g,r]),p.useEffect(()=>{if(!h||g!=="entering")return;const I=setTimeout(()=>{const S=Array.from(M.current.entries()).sort((E,L)=>E[0]-L[0]).find(([,E])=>!E.disabled);k(S?S[0]:-1)},0);return()=>clearTimeout(I)},[h,g]),p.useEffect(()=>{if(!u)return;const I=S=>{var L,w;const E=S.target;(L=y.current)!=null&&L.contains(E)||(w=f.current)!=null&&w.contains(E)||R()},N=requestAnimationFrame(()=>{document.addEventListener("mousedown",I)});return()=>{cancelAnimationFrame(N),document.removeEventListener("mousedown",I)}},[u,R]),p.useEffect(()=>{if(!u)return;let I=!1;const N=setTimeout(()=>{I=!0},50),S=()=>{I&&R()};return window.addEventListener("scroll",S,{passive:!0,capture:!0}),()=>{clearTimeout(N),window.removeEventListener("scroll",S,{capture:!0})}},[u,R]);const z=p.useCallback(()=>Array.from(M.current.entries()).filter(([,I])=>!I.disabled).map(([I])=>I).sort((I,N)=>I-N),[]),F=p.useCallback(I=>{if(!u)return;const N=z();if(N.length!==0)switch(I.key){case"Escape":I.preventDefault(),R();break;case"ArrowDown":{I.preventDefault(),k(S=>{const E=N.indexOf(S);return E<N.length-1?N[E+1]:N[0]});break}case"ArrowUp":{I.preventDefault(),k(S=>{const E=N.indexOf(S);return E>0?N[E-1]:N[N.length-1]});break}case"Home":{I.preventDefault(),k(N[0]);break}case"End":{I.preventDefault(),k(N[N.length-1]);break}case"Enter":case" ":{I.preventDefault();const S=f.current;if(S){const E=S.querySelector('[data-active="true"]');E==null||E.click()}break}case"Tab":{R();break}}},[u,R,z]);p.useEffect(()=>{if(u)return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[u,F]),p.useEffect(()=>{if(!u)return;const I=f.current;if(!I)return;const N=I.querySelector('[data-active="true"]');N==null||N.scrollIntoView({block:"nearest"})},[P,u]);const B=()=>{j(!u)},$=I=>{(I.key==="Enter"||I.key===" "||I.key==="ArrowDown")&&(I.preventDefault(),u||j(!0)),I.key==="ArrowUp"&&(I.preventDefault(),u||(j(!0),setTimeout(()=>{const N=z();N.length>0&&k(N[N.length-1])},0)))},U={activeIndex:P,setActiveIndex:k,registerItem:(I,N)=>{M.current.set(I,{disabled:N})},close:R,getItemIndex:()=>x.current++,size:o},K=p.useId();return t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:y,style:{display:"inline-flex"},children:t.jsx("span",{ref:v,onClick:B,onKeyDown:$,"aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?K:void 0,style:{display:"inline-flex",cursor:"pointer"},children:e})}),h&&Tt.createPortal(t.jsx(Ve.Provider,{value:U,children:t.jsx("div",{ref:f,id:K,role:"menu",style:{position:"fixed",top:(T==null?void 0:T.top)??-9999,left:(T==null?void 0:T.left)??-9999,zIndex:1e3,minWidth:180,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",padding:He[o],maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:g==="exiting"?`lucent-menu-out ${Ae}ms var(--lucent-easing-default) forwards`:`lucent-menu-in ${Ae}ms var(--lucent-easing-decelerate)`,transformOrigin:(T==null?void 0:T.transformOrigin)??"top left",outline:"none",pointerEvents:g==="exiting"?"none":"auto",...i},children:n})}),document.body)]})}const jo={id:"menu",name:"Menu",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A dropdown menu triggered by clicking a host element. Renders in a portal to avoid overflow clipping, supports placement with auto-flip, keyboard navigation (arrow keys, Enter, Escape), and outside-click dismissal.",designIntent:'Menu provides a contextual action list that appears from a trigger element. It is a foundational overlay primitive — Select dropdowns, notification feeds, and context menus can all be composed from this building block.\n\n## Compound component API\nMenu uses a compound component pattern (`Menu`, `MenuItem`, `MenuSeparator`, `MenuGroup`) rather than a flat data array. Menu items have divergent structures — actions, separators, groups, icons, shortcut hints, danger state — that compose naturally as JSX children rather than discriminated union objects.\n\n## Sizing\nThe `size` prop (`sm` | `md` | `lg`) flows from the root `Menu` through context to all sub-components. Font sizes are aligned with Button: sm → `font-size-sm`, md → `font-size-md`, lg → `font-size-lg`. Item padding and gap use `space-2` for sm/md and `space-3` for lg, matching MultiSelect dropdown spacing. Group labels stay one step smaller than item text. Checkmark icons scale from 12px to 16px.\n\n## Placement & auto-flip\nThe `placement` prop sets the preferred position (default `bottom-start`). When the popover would overflow the viewport, it automatically flips to the opposite side. Horizontal alignment (`-start`, `-end`, or centered) is preserved during the flip. Position is computed with `getBoundingClientRect` on mount and rendered via `position: fixed` in a portal.\n\n## Portal rendering\nThe popover is portaled to `document.body` via `createPortal`. This prevents overflow clipping from parent containers with `overflow: hidden`. The trigger wrapper stays inline in the DOM tree so it participates in layout normally.\n\n## Keyboard navigation\nFollows WAI-ARIA Menu Button pattern. Arrow keys cycle through enabled items (wrapping). Enter/Space selects the active item and closes the menu. Escape closes without selection. Tab closes and lets focus move naturally. Home/End jump to first/last enabled item.\n\n## Dismissal\nMenus close on outside click (mousedown, deferred via `requestAnimationFrame` to avoid catching the opening click), Escape, Tab, and scroll (armed after 50ms to skip mount-triggered scroll events). After close, focus returns to the trigger element.\n\n## Selected state\nMenuItem accepts a `selected` prop that renders a trailing accent-colored checkmark. The selected item gets a `color-mix(in srgb, accent-default 12%, surface-overlay)` background with `shadow-sm` elevation, making it visually stronger than the hover state (`surface-secondary`). Uses `role="menuitemcheckbox"` with `aria-checked` for accessibility.\n\n## Animation\nBoth entrance and exit use a subtle scale + fade (`scale(0.97) ↔ 1`, `opacity 0 ↔ 1`) over 120ms. Entrance uses `easing-decelerate`, exit uses `easing-default`. `transform-origin` is set based on the actual placement (after auto-flip). The portal stays mounted during the exit animation via a `visible` state with `pointerEvents: none` to prevent interaction while fading out.',props:[{name:"trigger",type:"ReactNode",required:!0,description:"The element that toggles the menu on click. Typically a Button with a chevron. Wrapped in a <span> that receives click, keyboard, and ARIA attributes."},{name:"children",type:"ReactNode",required:!0,description:"MenuItem, MenuSeparator, and/or MenuGroup elements."},{name:"size",type:"enum",required:!1,default:"md",description:"Size of the menu panel. Controls item padding, gap, font size, and checkmark icon size. Font sizes match Button at each tier: sm → font-size-sm, md → font-size-md, lg → font-size-lg.",enumValues:["sm","md","lg"]},{name:"placement",type:"enum",required:!1,default:"bottom-start",description:"Preferred placement relative to the trigger. Auto-flips when near viewport edges.",enumValues:["top","top-start","top-end","bottom","bottom-start","bottom-end","left","right"]},{name:"open",type:"boolean",required:!1,description:"Controlled open state. When provided, the menu becomes controlled."},{name:"onOpenChange",type:"function",required:!1,description:"Callback fired when the menu opens or closes. Receives the new open state."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the popover panel."},{name:"MenuItem.onSelect",type:"function",required:!0,description:"Fires when the item is selected via click or Enter/Space."},{name:"MenuItem.children",type:"ReactNode",required:!0,description:"Label content. Rendered via the Text atom at the size determined by the parent Menu."},{name:"MenuItem.icon",type:"ReactNode",required:!1,description:"Leading icon rendered before the label."},{name:"MenuItem.shortcut",type:"string",required:!1,description:'Trailing shortcut hint (e.g. "Cmd+D"). Displayed in secondary text.'},{name:"MenuItem.disabled",type:"boolean",required:!1,default:"false",description:"Disables selection, grays out the item, and skips it during keyboard navigation."},{name:"MenuItem.danger",type:"boolean",required:!1,default:"false",description:"Renders the item in danger color for destructive actions."},{name:"MenuItem.selected",type:"boolean",required:!1,default:"false",description:"Marks the item as currently selected. Shows a trailing checkmark in accent color, accent-tinted background via color-mix, and shadow-sm elevation. Visually stronger than hover."},{name:"MenuItem.style",type:"object",required:!1,description:"Inline style overrides for the item."},{name:"MenuSeparator.style",type:"object",required:!1,description:"Inline style overrides for the separator line."},{name:"MenuGroup.label",type:"string",required:!0,description:"Label shown above the group. Rendered one font step smaller than item text."},{name:"MenuGroup.children",type:"ReactNode",required:!0,description:"MenuItem elements within the group."},{name:"MenuGroup.style",type:"object",required:!1,description:"Inline style overrides for the group wrapper."}],usageExamples:[{title:"Basic menu",code:`<Menu trigger={<Button chevron>Actions</Button>}>
|
|
418
|
+
`,Ve={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},ko={sm:"sm",md:"md",lg:"lg"},So={sm:"xs",md:"sm",lg:"md"},To={sm:12,md:14,lg:16},Ue=p.createContext(null),ve=4;function Co(t,n,r){const o=n.offsetWidth,a=n.offsetHeight,i=window.innerWidth,s=window.innerHeight;let l=0,c=0,d=r;const u={top:t.top-a-ve,bottom:t.bottom+ve,left:t.left-o-ve,right:t.right+ve};d.startsWith("bottom")?(l=u.bottom,l+a>s&&u.top>=0&&(l=u.top,d=d.replace("bottom","top"))):d.startsWith("top")?(l=u.top,l<0&&u.bottom+a<=s&&(l=u.bottom,d=d.replace("top","bottom"))):d==="left"?(l=t.top+t.height/2-a/2,c=u.left,c<0&&u.right+o<=i&&(c=u.right,d="right")):d==="right"&&(l=t.top+t.height/2-a/2,c=u.right,c+o>i&&u.left>=0&&(c=u.left,d="left")),(d.startsWith("top")||d.startsWith("bottom"))&&(d.endsWith("-start")?c=t.left:d.endsWith("-end")?c=t.right-o:c=t.left+t.width/2-o/2),c+o>i&&(c=i-o-8),c<0&&(c=8),l+a>s&&(l=s-a-8),l<0&&(l=8);let h="top left";return d.startsWith("top")?h=d.endsWith("-end")?"bottom right":d.endsWith("-start")?"bottom left":"bottom center":d.startsWith("bottom")?h=d.endsWith("-end")?"top right":d.endsWith("-start")?"top left":"top center":d==="left"?h="center right":d==="right"&&(h="center left"),{top:l,left:c,transformOrigin:h}}function jo({onSelect:t,children:n,icon:r,shortcut:o,disabled:a=!1,danger:i=!1,selected:s=!1,style:l}){const c=p.useContext(Ue),d=p.useRef(-1);d.current===-1&&c&&(d.current=c.getItemIndex(),c.registerItem(d.current,a));const u=c?c.activeIndex===d.current:!1,h=(c==null?void 0:c.size)??"md",m=Ve[h],g=ko[h],C=To[h],b=()=>{a||(t(),c==null||c.close())},f=()=>{!a&&c&&c.setActiveIndex(d.current)},v=a?"var(--lucent-text-disabled)":i?"var(--lucent-danger-text)":"var(--lucent-text-primary)";return e.jsxs("div",{role:"menuitemcheckbox","aria-checked":s,"aria-disabled":a||void 0,"data-active":u||void 0,tabIndex:-1,onClick:b,onMouseEnter:f,style:{display:"flex",alignItems:"center",gap:m,padding:m,borderRadius:"var(--lucent-radius-md)",cursor:a?"not-allowed":"pointer",background:s?"color-mix(in srgb, var(--lucent-accent-default) 12%, var(--lucent-surface-overlay))":u?"var(--lucent-surface-secondary)":"transparent",boxShadow:s?"var(--lucent-shadow-sm)":"none",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default), box-shadow var(--lucent-duration-fast) var(--lucent-easing-default)",opacity:a?.5:1,outline:"none",...l},children:[r&&e.jsx("span",{style:{flexShrink:0,display:"flex",color:a?"var(--lucent-text-disabled)":i?"var(--lucent-danger-text)":"var(--lucent-text-secondary)"},children:r}),e.jsx("span",{style:{flex:1,minWidth:0},children:e.jsx(O,{size:g,style:{color:v},children:n})}),o&&e.jsx(O,{size:h==="lg"?"sm":"xs",style:{color:"var(--lucent-text-secondary)",flexShrink:0},children:o}),s&&e.jsx("span",{style:{flexShrink:0,display:"flex",color:"var(--lucent-accent-default)"},children:e.jsx("svg",{width:C,height:C,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})})]})}function Io({style:t}){return e.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)",...t}})}function Mo({label:t,children:n,style:r}){const o=p.useContext(Ue),a=(o==null?void 0:o.size)??"md",i=Ve[a];return e.jsxs("div",{role:"group","aria-label":t,style:r,children:[e.jsx("div",{style:{padding:`${i} ${i} var(--lucent-space-1)`},children:e.jsx(O,{size:So[a],color:"secondary",weight:"medium",children:t})}),n]})}function Do({trigger:t,children:n,placement:r="bottom-start",size:o="md",open:a,onOpenChange:i,portalContainer:s,style:l}){const c=a!==void 0,[d,u]=p.useState(!1),h=c?a:d,[m,g]=p.useState(!1),[C,b]=p.useState("idle"),f=p.useRef(null),v=p.useRef(null),S=p.useRef(null),x=p.useRef(!1),[I,w]=p.useState(null),z=p.useRef(0),q=p.useRef(new Map),[T,M]=p.useState(-1);if(!x.current&&typeof document<"u"){const R=document.createElement("style");R.textContent=wo,document.head.appendChild(R),x.current=!0}p.useEffect(()=>{if(h)z.current=0,q.current.clear(),g(!0),b("entering");else if(m){b("exiting");const R=setTimeout(()=>{g(!1),b("idle")},Ae);return()=>clearTimeout(R)}},[h]);const F=p.useCallback(R=>{c||u(R),i==null||i(R)},[c,i]),N=p.useCallback(()=>{const R=S.current;R&&(R.querySelector("button, [tabindex]")??R).focus()},[]),j=p.useCallback(()=>{F(!1),N()},[F,N]);p.useLayoutEffect(()=>{if(!m||C!=="entering"||!f.current)return;const R=requestAnimationFrame(()=>{const y=v.current,A=f.current;if(!y||!A)return;const E=A.getBoundingClientRect();w(Co(E,y,r))});return()=>cancelAnimationFrame(R)},[m,C,r]),p.useEffect(()=>{if(!m||C!=="entering")return;const R=setTimeout(()=>{const A=Array.from(q.current.entries()).sort((E,U)=>E[0]-U[0]).find(([,E])=>!E.disabled);M(A?A[0]:-1)},0);return()=>clearTimeout(R)},[m,C]),p.useEffect(()=>{if(!h)return;const R=A=>{var U,k;const E=A.target;(U=f.current)!=null&&U.contains(E)||(k=v.current)!=null&&k.contains(E)||j()},y=requestAnimationFrame(()=>{document.addEventListener("mousedown",R)});return()=>{cancelAnimationFrame(y),document.removeEventListener("mousedown",R)}},[h,j]),p.useEffect(()=>{if(!h)return;let R=!1;const y=setTimeout(()=>{R=!0},50),A=()=>{R&&j()};return window.addEventListener("scroll",A,{passive:!0,capture:!0}),()=>{clearTimeout(y),window.removeEventListener("scroll",A,{capture:!0})}},[h,j]);const B=p.useCallback(()=>Array.from(q.current.entries()).filter(([,R])=>!R.disabled).map(([R])=>R).sort((R,y)=>R-y),[]),L=p.useCallback(R=>{if(!h)return;const y=B();if(y.length!==0)switch(R.key){case"Escape":R.preventDefault(),j();break;case"ArrowDown":{R.preventDefault(),M(A=>{const E=y.indexOf(A);return E<y.length-1?y[E+1]:y[0]});break}case"ArrowUp":{R.preventDefault(),M(A=>{const E=y.indexOf(A);return E>0?y[E-1]:y[y.length-1]});break}case"Home":{R.preventDefault(),M(y[0]);break}case"End":{R.preventDefault(),M(y[y.length-1]);break}case"Enter":case" ":{R.preventDefault();const A=v.current;if(A){const E=A.querySelector('[data-active="true"]');E==null||E.click()}break}case"Tab":{j();break}}},[h,j,B]);p.useEffect(()=>{if(h)return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[h,L]),p.useEffect(()=>{if(!h)return;const R=v.current;if(!R)return;const y=R.querySelector('[data-active="true"]');y==null||y.scrollIntoView({block:"nearest"})},[T,h]);const P=()=>{F(!h)},$=R=>{(R.key==="Enter"||R.key===" "||R.key==="ArrowDown")&&(R.preventDefault(),h||F(!0)),R.key==="ArrowUp"&&(R.preventDefault(),h||(F(!0),setTimeout(()=>{const y=B();y.length>0&&M(y[y.length-1])},0)))},X={activeIndex:T,setActiveIndex:M,registerItem:(R,y)=>{q.current.set(R,{disabled:y})},close:j,getItemIndex:()=>z.current++,size:o},H=p.useId();return e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:f,style:{display:"inline-flex"},children:e.jsx("span",{ref:S,onClick:P,onKeyDown:$,"aria-haspopup":"menu","aria-expanded":h,"aria-controls":h?H:void 0,style:{display:"inline-flex",cursor:"pointer"},children:t})}),m&&Fe.createPortal(e.jsx(Ue.Provider,{value:X,children:e.jsx("div",{ref:v,id:H,role:"menu",style:{position:"fixed",top:(I==null?void 0:I.top)??-9999,left:(I==null?void 0:I.left)??-9999,zIndex:1e3,minWidth:180,background:"var(--lucent-surface-overlay)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-md)",padding:Ve[o],maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:C==="exiting"?`lucent-menu-out ${Ae}ms var(--lucent-easing-default) forwards`:`lucent-menu-in ${Ae}ms var(--lucent-easing-decelerate)`,transformOrigin:(I==null?void 0:I.transformOrigin)??"top left",outline:"none",pointerEvents:C==="exiting"?"none":"auto",...l},children:n})}),s??document.body)]})}const zo={id:"menu",name:"Menu",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A dropdown menu triggered by clicking a host element. Renders in a portal to avoid overflow clipping, supports placement with auto-flip, keyboard navigation (arrow keys, Enter, Escape), and outside-click dismissal.",designIntent:'Menu provides a contextual action list that appears from a trigger element. It is a foundational overlay primitive — Select dropdowns, notification feeds, and context menus can all be composed from this building block.\n\n## Compound component API\nMenu uses a compound component pattern (`Menu`, `MenuItem`, `MenuSeparator`, `MenuGroup`) rather than a flat data array. Menu items have divergent structures — actions, separators, groups, icons, shortcut hints, danger state — that compose naturally as JSX children rather than discriminated union objects.\n\n## Sizing\nThe `size` prop (`sm` | `md` | `lg`) flows from the root `Menu` through context to all sub-components. Font sizes are aligned with Button: sm → `font-size-sm`, md → `font-size-md`, lg → `font-size-lg`. Item padding and gap use `space-2` for sm/md and `space-3` for lg, matching MultiSelect dropdown spacing. Group labels stay one step smaller than item text. Checkmark icons scale from 12px to 16px.\n\n## Placement & auto-flip\nThe `placement` prop sets the preferred position (default `bottom-start`). When the popover would overflow the viewport, it automatically flips to the opposite side. Horizontal alignment (`-start`, `-end`, or centered) is preserved during the flip. Position is computed with `getBoundingClientRect` on mount and rendered via `position: fixed` in a portal.\n\n## Portal rendering\nThe popover is portaled via `createPortal` (default: `document.body`). This prevents overflow clipping from parent containers with `overflow: hidden`. The trigger wrapper stays inline in the DOM tree so it participates in layout normally. The `portalContainer` prop lets consumers render the portal inside a wrapper element that sets `--lucent-*` CSS custom property overrides, preserving per-section theming.\n\n## Keyboard navigation\nFollows WAI-ARIA Menu Button pattern. Arrow keys cycle through enabled items (wrapping). Enter/Space selects the active item and closes the menu. Escape closes without selection. Tab closes and lets focus move naturally. Home/End jump to first/last enabled item.\n\n## Dismissal\nMenus close on outside click (mousedown, deferred via `requestAnimationFrame` to avoid catching the opening click), Escape, Tab, and scroll (armed after 50ms to skip mount-triggered scroll events). After close, focus returns to the trigger element.\n\n## Selected state\nMenuItem accepts a `selected` prop that renders a trailing accent-colored checkmark. The selected item gets a `color-mix(in srgb, accent-default 12%, surface-overlay)` background with `shadow-sm` elevation, making it visually stronger than the hover state (`surface-secondary`). Uses `role="menuitemcheckbox"` with `aria-checked` for accessibility.\n\n## Animation\nBoth entrance and exit use a subtle scale + fade (`scale(0.97) ↔ 1`, `opacity 0 ↔ 1`) over 120ms. Entrance uses `easing-decelerate`, exit uses `easing-default`. `transform-origin` is set based on the actual placement (after auto-flip). The portal stays mounted during the exit animation via a `visible` state with `pointerEvents: none` to prevent interaction while fading out.',props:[{name:"trigger",type:"ReactNode",required:!0,description:"The element that toggles the menu on click. Typically a Button with a chevron. Wrapped in a <span> that receives click, keyboard, and ARIA attributes."},{name:"children",type:"ReactNode",required:!0,description:"MenuItem, MenuSeparator, and/or MenuGroup elements."},{name:"size",type:"enum",required:!1,default:"md",description:"Size of the menu panel. Controls item padding, gap, font size, and checkmark icon size. Font sizes match Button at each tier: sm → font-size-sm, md → font-size-md, lg → font-size-lg.",enumValues:["sm","md","lg"]},{name:"placement",type:"enum",required:!1,default:"bottom-start",description:"Preferred placement relative to the trigger. Auto-flips when near viewport edges.",enumValues:["top","top-start","top-end","bottom","bottom-start","bottom-end","left","right"]},{name:"open",type:"boolean",required:!1,description:"Controlled open state. When provided, the menu becomes controlled."},{name:"onOpenChange",type:"function",required:!1,description:"Callback fired when the menu opens or closes. Receives the new open state."},{name:"portalContainer",type:"HTMLElement | null",required:!1,description:"DOM element to portal the popover into. Defaults to document.body. Set this to a wrapper element to preserve CSS custom property inheritance for per-section theming."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the popover panel."},{name:"MenuItem.onSelect",type:"function",required:!0,description:"Fires when the item is selected via click or Enter/Space."},{name:"MenuItem.children",type:"ReactNode",required:!0,description:"Label content. Rendered via the Text atom at the size determined by the parent Menu."},{name:"MenuItem.icon",type:"ReactNode",required:!1,description:"Leading icon rendered before the label."},{name:"MenuItem.shortcut",type:"string",required:!1,description:'Trailing shortcut hint (e.g. "Cmd+D"). Displayed in secondary text.'},{name:"MenuItem.disabled",type:"boolean",required:!1,default:"false",description:"Disables selection, grays out the item, and skips it during keyboard navigation."},{name:"MenuItem.danger",type:"boolean",required:!1,default:"false",description:"Renders the item in danger color for destructive actions."},{name:"MenuItem.selected",type:"boolean",required:!1,default:"false",description:"Marks the item as currently selected. Shows a trailing checkmark in accent color, accent-tinted background via color-mix, and shadow-sm elevation. Visually stronger than hover."},{name:"MenuItem.style",type:"object",required:!1,description:"Inline style overrides for the item."},{name:"MenuSeparator.style",type:"object",required:!1,description:"Inline style overrides for the separator line."},{name:"MenuGroup.label",type:"string",required:!0,description:"Label shown above the group. Rendered one font step smaller than item text."},{name:"MenuGroup.children",type:"ReactNode",required:!0,description:"MenuItem elements within the group."},{name:"MenuGroup.style",type:"object",required:!1,description:"Inline style overrides for the group wrapper."}],usageExamples:[{title:"Basic menu",code:`<Menu trigger={<Button chevron>Actions</Button>}>
|
|
419
419
|
<MenuItem onSelect={() => console.log('edit')}>Edit</MenuItem>
|
|
420
420
|
<MenuItem onSelect={() => console.log('duplicate')}>Duplicate</MenuItem>
|
|
421
421
|
<MenuSeparator />
|
|
@@ -452,11 +452,68 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
452
452
|
<Menu trigger={<Button>Menu</Button>} open={open} onOpenChange={setOpen}>
|
|
453
453
|
<MenuItem onSelect={() => {}}>Option A</MenuItem>
|
|
454
454
|
<MenuItem onSelect={() => {}}>Option B</MenuItem>
|
|
455
|
-
</Menu>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Item labels and group headers",required:!0}],accessibility:{role:"menu",ariaAttributes:['role="menu" on the popover panel','role="menuitemcheckbox" with aria-checked on each MenuItem','role="separator" on MenuSeparator','role="group" with aria-label on MenuGroup','aria-haspopup="menu" on the trigger wrapper',"aria-expanded on the trigger wrapper","aria-controls linking trigger to popover via id","aria-disabled on disabled MenuItems"],keyboardInteractions:["Enter/Space on trigger — toggle menu","ArrowDown on trigger — open menu, focus first item","ArrowUp on trigger — open menu, focus last item","ArrowDown — focus next enabled item (wraps)","ArrowUp — focus previous enabled item (wraps)","Enter/Space — select focused item, close menu","Escape — close menu, return focus to trigger","Tab — close menu, let focus move naturally","Home — focus first enabled item","End — focus last enabled item"],notes:'Focus returns to the trigger element after the menu is dismissed via Escape or selection. Disabled items are skipped during keyboard navigation and have aria-disabled. Selected items use role="menuitemcheckbox" with aria-checked for screen reader announcement. The popover is portaled to document.body but remains semantically linked to the trigger via aria-controls.'}},Io={fontFamilyBase:'"DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:'"DM Mono", "Fira Code", "Cascadia Code", monospace',fontFamilyDisplay:'"Georama", "DM Sans", sans-serif',fontSizeXs:"0.75rem",fontSizeSm:"0.875rem",fontSizeMd:"1rem",fontSizeLg:"1.125rem",fontSizeXl:"1.25rem",fontSize2xl:"1.5rem",fontSize3xl:"1.875rem",fontWeightRegular:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightBase:"1.5",lineHeightRelaxed:"1.75",letterSpacingTight:"-0.02em",letterSpacingBase:"0em",letterSpacingWide:"0.04em"},Mo={space0:"0px",space1:"0.25rem",space2:"0.5rem",space3:"0.75rem",space4:"1rem",space5:"1.25rem",space6:"1.5rem",space8:"2rem",space10:"2.5rem",space12:"3rem",space16:"4rem",space20:"5rem",space24:"6rem"},Do={radiusNone:"0px",radiusSm:"0.25rem",radiusMd:"0.375rem",radiusLg:"0.5rem",radiusXl:"0.75rem",radiusFull:"9999px"},zo={durationFast:"100ms",durationBase:"200ms",durationSlow:"350ms",easingDefault:"cubic-bezier(0.4, 0, 0.2, 1)",easingEmphasized:"cubic-bezier(0.2, 0, 0, 1)",easingDecelerate:"cubic-bezier(0, 0, 0.2, 1)"},Eo={shadowNone:"none",shadowSm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",shadowMd:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",shadowLg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",shadowXl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)"},Ao={shadowNone:"none",shadowSm:"0 1px 2px 0 rgb(0 0 0 / 0.3)",shadowMd:"0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4)",shadowLg:"0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4)",shadowXl:"0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5)"},ue={...Io,...Mo,...Do,...zo,...Eo,bgBase:"#ffffff",bgSubtle:"#f9fafb",bgOverlay:"rgb(0 0 0 / 0.4)",surface:"#ffffff",surfaceSecondary:"#f3f4f6",surfaceRaised:"#ffffff",surfaceOverlay:"#ffffff",surfaceTint:"#f2f2f2",borderDefault:"#e5e7eb",borderSubtle:"#f3f4f6",borderStrong:"#9ca3af",controlTrack:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",textDisabled:"#9ca3af",textInverse:"#ffffff",textOnAccent:"#ffffff",accentDefault:"#111827",accentHover:"#1f2937",accentActive:"#374151",accentSubtle:"#f3f4f6",accentBorder:"#111827",successDefault:"#16a34a",successSubtle:"#f0fdf4",successText:"#15803d",warningDefault:"#d97706",warningSubtle:"#fffbeb",warningText:"#b45309",dangerDefault:"#dc2626",dangerHover:"#b91c1c",dangerSubtle:"#fef2f2",dangerText:"#b91c1c",infoDefault:"#2563eb",infoSubtle:"#eff6ff",infoText:"#1d4ed8",focusRing:"#111827"};function Ro(e){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),o=parseInt(e.slice(5,7),16);return{r:n,g:r,b:o}}function Bo({r:e,g:n,b:r}){const o=a=>a.toString(16).padStart(2,"0");return`#${o(e)}${o(n)}${o(r)}`}function Q(e){const{r:n,g:r,b:o}=Ro(e),a=n/255,s=r/255,i=o/255,l=Math.max(a,s,i),c=Math.min(a,s,i);let d=0,u=0;const h=(l+c)/2;if(l!==c){const m=l-c;switch(u=h>.5?m/(2-l-c):m/(l+c),l){case a:d=(s-i)/m+(s<i?6:0);break;case s:d=(i-a)/m+2;break;case i:d=(a-s)/m+4;break}d/=6}return[d*360,u,h]}function Z(e,n,r){e=(e%360+360)%360,n=Math.min(1,Math.max(0,n)),r=Math.min(1,Math.max(0,r));const o=(1-Math.abs(2*r-1))*n,a=o*(1-Math.abs(e/60%2-1)),s=r-o/2;let i=0,l=0,c=0;return e<60?(i=o,l=a):e<120?(i=a,l=o):e<180?(l=o,c=a):e<240?(l=a,c=o):e<300?(i=a,c=o):(i=o,c=a),Bo({r:Math.round((i+s)*255),g:Math.round((l+s)*255),b:Math.round((c+s)*255)})}function V(e,n){const[r,o,a]=Q(e);return Z(r,o,Math.min(1,Math.max(0,a+n)))}const qo=222,Lo=.12;function Bt(e,n){return n<.04?[qo,Lo]:[e,n]}function Fo(e){const[n,r,o]=Q(e),[a,s]=Bt(n,r);return Z(a,s,Math.max(.04,Math.min(.2,.07+(1-o))))}function Re(e){const[n,r,o]=Q(e),[a,s]=Bt(n,r);return Z(a,s,Math.max(.06,Math.min(.5,(1-o)*.6+.06)))}function Be(e){const[n,r,o]=Q(e);return Z(n,r,Math.max(.04,Math.min(.97,1-o+.04)))}function ie(e){const[n,r,o]=Q(e);return Z(n,r,Math.max(.02,Math.min(.98,1-o)))}function qt(e){const n=Fo(e.bgBase),[r,o,a]=Q(n),s=i=>Z(r,o,Math.min(.25,a+i));return{...e,...Ao,bgBase:n,bgSubtle:s(.02),bgOverlay:"rgb(0 0 0 / 0.6)",surface:s(.02),surfaceSecondary:s(.05),surfaceRaised:s(.08),surfaceOverlay:s(.08),surfaceTint:s(.03),borderDefault:Re(e.borderDefault),borderSubtle:Re(e.borderSubtle),borderStrong:Re(e.borderStrong),controlTrack:s(.1),textPrimary:Be(e.textPrimary),textSecondary:Be(e.textSecondary),textDisabled:Be(e.textDisabled),textInverse:n,textOnAccent:e.textOnAccent,accentDefault:ie(e.accentDefault),accentHover:ie(e.accentHover),accentActive:ie(e.accentActive),accentSubtle:ie(e.accentSubtle),accentBorder:e.accentBorder,successDefault:V(e.successDefault,.1),successSubtle:V(e.successDefault,-.25),successText:V(e.successText,.15),warningDefault:V(e.warningDefault,.1),warningSubtle:V(e.warningDefault,-.25),warningText:V(e.warningText,.15),dangerDefault:V(e.dangerDefault,.1),dangerHover:V(e.dangerHover,.1),dangerSubtle:V(e.dangerDefault,-.25),dangerText:V(e.dangerText,.15),infoDefault:V(e.infoDefault,.1),infoSubtle:V(e.infoDefault,-.25),infoText:V(e.infoText,.15),focusRing:ie(e.focusRing)}}const Ue=qt(ue);function Po(e){return"--lucent-"+e.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`).replace(/([a-z])(\d)/g,(n,r,o)=>`${r}-${o}`)}function Lt(e,n=":root"){const r=Object.entries(e).map(([o,a])=>` ${Po(o)}: ${a};`).join(`
|
|
455
|
+
</Menu>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Item labels and group headers",required:!0}],accessibility:{role:"menu",ariaAttributes:['role="menu" on the popover panel','role="menuitemcheckbox" with aria-checked on each MenuItem','role="separator" on MenuSeparator','role="group" with aria-label on MenuGroup','aria-haspopup="menu" on the trigger wrapper',"aria-expanded on the trigger wrapper","aria-controls linking trigger to popover via id","aria-disabled on disabled MenuItems"],keyboardInteractions:["Enter/Space on trigger — toggle menu","ArrowDown on trigger — open menu, focus first item","ArrowUp on trigger — open menu, focus last item","ArrowDown — focus next enabled item (wraps)","ArrowUp — focus previous enabled item (wraps)","Enter/Space — select focused item, close menu","Escape — close menu, return focus to trigger","Tab — close menu, let focus move naturally","Home — focus first enabled item","End — focus last enabled item"],notes:'Focus returns to the trigger element after the menu is dismissed via Escape or selection. Disabled items are skipped during keyboard navigation and have aria-disabled. Selected items use role="menuitemcheckbox" with aria-checked for screen reader announcement. The popover is portaled to document.body (or portalContainer) but remains semantically linked to the trigger via aria-controls.'}},Lt=p.createContext(null);function Eo(){const t=p.useContext(Lt);if(!t)throw new Error("useToast must be used inside <ToastProvider>");return t}const Ao=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 5.5V8.5M8 10.5V11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ro=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M5 8L7 10L11 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),qo=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M8 2L14.5 13H1.5L8 2Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 6V9M8 11V11.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Bo=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6.5",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M5.5 5.5L10.5 10.5M10.5 5.5L5.5 10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Lo=()=>e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M3 3L11 11M11 3L3 11",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),Po={info:e.jsx(Ao,{}),success:e.jsx(Ro,{}),warning:e.jsx(qo,{}),danger:e.jsx(Bo,{})},Fo={default:{border:"var(--lucent-border-default)",iconColor:"var(--lucent-text-secondary)"},info:{border:"var(--lucent-info-default)",iconColor:"var(--lucent-info-text)"},success:{border:"var(--lucent-success-default)",iconColor:"var(--lucent-success-text)"},warning:{border:"var(--lucent-warning-default)",iconColor:"var(--lucent-warning-text)"},danger:{border:"var(--lucent-danger-default)",iconColor:"var(--lucent-danger-text)"}};let No=0;function $o(){return`lucent-toast-${++No}`}function Pt(t){return t.startsWith("top")}const Wo=200,Oo=8,Ho=.04,Vo=.2,Uo=3,Go=356;function wt({entry:t,onDismiss:n,hideContent:r,fixedHeight:o}){const{id:a,title:i,description:s,variant:l,action:c,icon:d}=t,u=Fo[l],h=d??(l!=="default"?Po[l]:null),m=(c==null?void 0:c.style)??"button";return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-3) var(--lucent-space-4)",background:"var(--lucent-surface-raised)",border:`1px solid ${u.border}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:r?"none":"var(--lucent-shadow-lg)",boxSizing:"border-box",width:Go,maxWidth:"calc(100vw - var(--lucent-space-8))",fontFamily:"var(--lucent-font-family-base)",transition:"height var(--lucent-duration-base) var(--lucent-easing-emphasized), box-shadow var(--lucent-duration-base) var(--lucent-easing-default)",...o!==void 0&&{height:o,overflow:"hidden"}},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",width:"100%",opacity:r?0:1,transition:"opacity var(--lucent-duration-base) var(--lucent-easing-default)"},children:[h&&e.jsx("span",{style:{flexShrink:0,color:u.iconColor,display:"flex",alignItems:"center"},children:h}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)"},children:[e.jsx(O,{as:"span",size:"sm",weight:"semibold",color:"primary",lineHeight:"tight",children:i}),s&&e.jsx(O,{as:"span",size:"sm",color:"secondary",lineHeight:"base",style:{whiteSpace:"pre-line"},children:s})]}),c&&m==="button"&&e.jsx(_o,{label:c.label,onClick:()=>{c.onClick(),n(a)}}),c&&m==="link"&&e.jsx(Yo,{label:c.label,iconColor:u.iconColor,onClick:()=>{c.onClick(),n(a)}}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>n(a),style:{flexShrink:0,display:"flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",padding:2,borderRadius:"var(--lucent-radius-sm)",color:"var(--lucent-text-secondary)",opacity:r?0:.6},onMouseEnter:g=>{r||(g.currentTarget.style.opacity="1")},onMouseLeave:g=>{r||(g.currentTarget.style.opacity="0.6")},children:e.jsx(Lo,{})})]})})}function _o({label:t,onClick:n}){return e.jsx("button",{type:"button",onClick:n,style:{flexShrink:0,padding:"var(--lucent-space-1) var(--lucent-space-3)",background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-strong)",borderRadius:"var(--lucent-radius-md)",cursor:"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-primary)",lineHeight:"var(--lucent-line-height-tight)",whiteSpace:"nowrap",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},onMouseEnter:r=>{r.currentTarget.style.background="var(--lucent-surface-secondary)"},onMouseLeave:r=>{r.currentTarget.style.background="var(--lucent-surface)"},children:t})}function Yo({label:t,iconColor:n,onClick:r}){return e.jsx("button",{type:"button",onClick:r,style:{flexShrink:0,padding:0,background:"none",border:"none",cursor:"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)",fontWeight:"var(--lucent-font-weight-semibold)",color:n==="var(--lucent-text-secondary)"?"var(--lucent-accent-default)":n,textDecoration:"underline",textUnderlineOffset:2,whiteSpace:"nowrap"},children:t})}const kt="var(--lucent-space-6)",Ko=40,Xo=120;function Jo(t){const n={position:"fixed",zIndex:9999,pointerEvents:"none",boxSizing:"border-box"};return Pt(t)?n.top=Ko:n.top=`calc(100vh - ${Xo}px)`,t.endsWith("left")?n.left=kt:t.endsWith("right")?n.right=kt:(n.left="50%",n.transform="translateX(-50%)"),n}function Zo({toasts:t,position:n,onDismiss:r,portalContainer:o}){const[a,i]=p.useState(!1),[s,l]=p.useState(void 0),c=p.useCallback(f=>{f&&l(f.offsetHeight)},[]),d=Pt(n),u=t.filter(f=>f.phase!=="exiting"),h=t.filter(f=>f.phase==="exiting");p.useEffect(()=>{u.length<=1&&i(!1)},[u.length]);const m=p.useRef(null),g=p.useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null),u.length>1&&i(!0)},[u.length]),C=p.useCallback(()=>{m.current=setTimeout(()=>{i(!1),m.current=null},150)},[]),b=e.jsx("div",{style:Jo(n),children:e.jsx("div",{onMouseEnter:g,onMouseLeave:C,style:{margin:"calc(-1 * var(--lucent-space-2))",padding:"var(--lucent-space-2)"},children:e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:d?"column-reverse":"column",gap:a?"var(--lucent-space-2)":0,transform:a&&!d?"translateY(-100%)":void 0,marginTop:a&&!d?s??0:0,transition:"transform var(--lucent-duration-base) var(--lucent-easing-emphasized), margin var(--lucent-duration-base) var(--lucent-easing-emphasized), gap var(--lucent-duration-base) var(--lucent-easing-emphasized)"},children:[u.map((f,v)=>{const S=u.length-1-v,x=!a&&S>Uo,I=S*Oo,w=d?I:-I,z=a?1:1-S*Ho,q=a?1:Math.max(0,1-S*Vo),T=f.phase==="entering",M=S===0,F=!a&&!M;return e.jsx("div",{ref:M?c:void 0,role:"status","aria-live":"polite","aria-hidden":x,style:{position:M||a?"relative":"absolute",...!a&&!M&&(d?{bottom:0}:{top:0}),zIndex:100-S,transform:T?`translateY(${d?"-20px":"20px"}) scale(0.96)`:a?void 0:`translateY(${w}px) scaleX(${z})`,opacity:T||f.phase==="exiting"?0:q,transformOrigin:d?"bottom center":"top center",transition:T?"none":"transform var(--lucent-duration-base) var(--lucent-easing-emphasized), opacity var(--lucent-duration-base) var(--lucent-easing-default)",pointerEvents:x?"none":"auto",visibility:x?"hidden":"visible"},children:e.jsx(wt,{entry:f,onDismiss:r,hideContent:F,...F&&s!==void 0&&{fixedHeight:s}})},f.id)}),h.map(f=>e.jsx("div",{role:"status","aria-live":"polite",style:{position:"absolute",...d?{bottom:0}:{top:0},zIndex:200,transform:`translateY(${d?"20px":"-20px"}) scale(0.96)`,opacity:0,transformOrigin:d?"bottom center":"top center",transition:"transform var(--lucent-duration-base) var(--lucent-easing-default), opacity var(--lucent-duration-base) var(--lucent-easing-default)",pointerEvents:"none"},children:e.jsx(wt,{entry:f,onDismiss:r})},f.id))]})})});return Fe.createPortal(b,o??document.body)}function Qo({children:t,position:n="bottom-right",duration:r=5e3,max:o=5,portalContainer:a}){const[i,s]=p.useState([]),l=p.useCallback(u=>{s(h=>{const m=h.find(g=>g.id===u);return!m||m.phase==="exiting"?h:h.map(g=>g.id===u?{...g,phase:"exiting"}:g)}),setTimeout(()=>{s(h=>h.filter(m=>m.id!==u))},Wo)},[]),c=p.useCallback(u=>{const h=$o(),m={id:h,title:u.title,variant:u.variant??"default",duration:u.duration??r,...u.description!==void 0&&{description:u.description},...u.action!==void 0&&{action:u.action},...u.icon!==void 0&&{icon:u.icon},phase:"entering"};return s(g=>{const C=[...g,m],b=C.filter(f=>f.phase!=="exiting");if(b.length>o){const f=b.slice(0,b.length-o);for(const v of f)setTimeout(()=>l(v.id),0)}return C}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{s(g=>g.map(C=>C.id===h&&C.phase==="entering"?{...C,phase:"visible"}:C))})}),h},[r,o,l]);p.useEffect(()=>{const u=[];for(const h of i)if(h.phase==="visible"&&h.duration!==1/0){const m=setTimeout(()=>l(h.id),h.duration);u.push(m)}return()=>u.forEach(clearTimeout)},[i,l]);const d={toast:c,dismiss:l};return e.jsxs(Lt.Provider,{value:d,children:[t,i.length>0&&e.jsx(Zo,{toasts:i,position:n,onDismiss:l,...a!==void 0&&{portalContainer:a}})]})}const ei={id:"toast",name:"Toast",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"Ephemeral notification system with auto-dismiss, cascading card-stack, hover-to-expand, action buttons/links, and animated enter/exit transitions. Comprises ToastProvider (context + portal), useToast hook, and toast card rendering.",designIntent:`Toast provides ephemeral feedback for actions that don't require the user to navigate away or acknowledge inline. It fills the gap between Alert (persistent, inline) and Modal (blocking).
|
|
456
|
+
|
|
457
|
+
**Architecture**: ToastProvider wraps the app and manages a queue of toast entries. It renders toasts into a React portal (document.body by default, configurable via portalContainer) so they float above all page content regardless of stacking contexts. The useToast() hook exposes an imperative \`toast()\` function that returns a dismissible id, and a \`dismiss()\` function.
|
|
458
|
+
|
|
459
|
+
**Positioning**: The viewport is fixed-positioned with a stable anchor edge. For bottom positions, the toast's top edge is pinned 120px from the viewport bottom (ANCHOR_INSET_BOTTOM), so taller toasts extend downward toward the screen edge — the top never jumps. For top positions, the top edge is pinned 40px from the viewport top (ANCHOR_INSET), keeping toasts close to the top bar or header area. Both distances are separate constants to allow independent tuning. Six positions are supported: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right.
|
|
460
|
+
|
|
461
|
+
**Cascading stack**: When multiple toasts are active, only the newest (front) toast shows its full content. Older toasts render as empty card shells (border + background, no content) that peek behind the front toast with progressive scaleX reduction and opacity fade. Each shell is height-matched to the front toast via measurement so the peek gaps are perfectly uniform. Up to 3 stacked shells are visible behind the front toast.
|
|
462
|
+
|
|
463
|
+
**Hover to expand**: Hovering the stack smoothly expands all toasts into a full vertical list with content fading in, card heights animating to natural size, and shadows appearing. The expanded stack uses flex column-reverse for bottom positions so older toasts fan upward into the viewport. A 150ms debounced collapse timer prevents flicker when the cursor moves between toasts in the expanded list.
|
|
464
|
+
|
|
465
|
+
**Enter/exit animations**: New toasts slide in from the screen edge with opacity fade and slight scale-up (requestAnimationFrame double-raf triggers the CSS transition). Dismissed toasts slide back toward the edge and fade out over 200ms.
|
|
466
|
+
|
|
467
|
+
**Auto-dismiss**: Each toast auto-dismisses after a configurable duration (default 5s). Pass Infinity to disable. The timer is managed per-toast via useEffect, so each toast dismisses independently.
|
|
468
|
+
|
|
469
|
+
**Actions**: Toasts support an inline action rendered as either a bordered button (default, matching the Undo pattern from Sonner/Google) or an underlined link. Clicking the action fires the callback and auto-dismisses the toast.
|
|
470
|
+
|
|
471
|
+
**Variants**: default (neutral border), success, warning, danger, info — matching Alert's semantic token usage. Each variant sets border color and icon color from status tokens. Non-default variants include a built-in 16×16 SVG icon (same as Alert).
|
|
472
|
+
|
|
473
|
+
**Multi-line text**: title is always shown (semibold). Optional description supports newlines via white-space: pre-line. All text uses the Text atom.`,props:[{name:"position",type:"enum",required:!1,default:"bottom-right",description:"Screen edge and alignment where the toast stack appears.",enumValues:["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right"]},{name:"duration",type:"number",required:!1,default:"5000",description:"Default auto-dismiss duration in milliseconds. Applies to all toasts unless overridden per-toast."},{name:"max",type:"number",required:!1,default:"5",description:"Maximum number of toasts in the queue. When exceeded, the oldest toast is dismissed with an exit animation."},{name:"portalContainer",type:"object",required:!1,description:"DOM element to render the toast portal into. Defaults to document.body. Useful for scoping toasts to a specific container (e.g. inside an iframe or shadow DOM)."},{name:"title",type:"string",required:!0,description:"Primary message line, rendered in semibold. Always visible."},{name:"description",type:"string",required:!1,description:"Secondary description text below the title. Supports multi-line via newline characters (\\n). Rendered in secondary color."},{name:"variant",type:"enum",required:!1,default:"default",description:"Visual variant controlling border color, icon, and icon color. Matches Alert's semantic status tokens.",enumValues:["default","success","warning","danger","info"]},{name:"duration (per-toast)",type:"number",required:!1,default:"5000",description:"Override the provider-level auto-dismiss duration for this specific toast. Pass Infinity to disable auto-dismiss."},{name:"action",type:"object",required:!1,description:'Inline action rendered beside the dismiss button. Object with { label: string, onClick: () => void, style?: "button" | "link" }. Button style renders a bordered pill button (default). Link style renders an underlined text link. Clicking fires onClick and auto-dismisses the toast.'},{name:"icon",type:"ReactNode",required:!1,description:'Custom icon to replace the built-in variant icon. Only used when variant is not "default". Pass null to suppress the icon entirely.'}],usageExamples:[{title:"Provider setup",description:"Wrap your app with ToastProvider inside LucentProvider. Position and duration are configurable at the provider level.",code:`<LucentProvider>
|
|
474
|
+
<ToastProvider position="bottom-right" duration={5000}>
|
|
475
|
+
<App />
|
|
476
|
+
</ToastProvider>
|
|
477
|
+
</LucentProvider>`},{title:"Basic toast",description:"Minimal toast with just a title. Uses the default variant (neutral border, no icon).",code:`const { toast } = useToast();
|
|
478
|
+
toast({ title: 'Changes saved' });`},{title:"Success with description",description:"Two-line toast with a success variant. The description supports newlines via \\n.",code:`toast({
|
|
479
|
+
title: 'Order placed!',
|
|
480
|
+
description: 'You\\'ll receive a confirmation email shortly.',
|
|
481
|
+
variant: 'success',
|
|
482
|
+
});`},{title:"Danger with undo button",description:"Destructive action feedback with an inline undo button. Clicking the action auto-dismisses.",code:`toast({
|
|
483
|
+
title: 'Message deleted',
|
|
484
|
+
variant: 'danger',
|
|
485
|
+
action: {
|
|
486
|
+
label: 'Undo',
|
|
487
|
+
onClick: () => restoreMessage(id),
|
|
488
|
+
},
|
|
489
|
+
});`},{title:"Action as link",description:"Action rendered as an underlined link instead of a bordered button.",code:`toast({
|
|
490
|
+
title: 'Event created',
|
|
491
|
+
description: 'Sunday, December 03, 2023 at 9:00 AM',
|
|
492
|
+
action: {
|
|
493
|
+
label: 'View',
|
|
494
|
+
style: 'link',
|
|
495
|
+
onClick: () => navigate('/events/123'),
|
|
496
|
+
},
|
|
497
|
+
});`},{title:"Multi-line description",description:"Description with embedded newlines rendered via white-space: pre-line.",code:`toast({
|
|
498
|
+
title: 'Approaching limit',
|
|
499
|
+
description: 'You have used 80% of your monthly quota.\\nConsider upgrading your plan.',
|
|
500
|
+
variant: 'warning',
|
|
501
|
+
});`},{title:"Persistent (no auto-dismiss)",description:"Pass Infinity as duration to keep the toast visible until manually dismissed.",code:`toast({
|
|
502
|
+
title: 'Upload in progress',
|
|
503
|
+
description: 'Please do not close this tab.',
|
|
504
|
+
duration: Infinity,
|
|
505
|
+
});`},{title:"Programmatic dismiss",description:"toast() returns an id that can be passed to dismiss() to remove it programmatically.",code:`const { toast, dismiss } = useToast();
|
|
506
|
+
const id = toast({ title: 'Processing...', duration: Infinity });
|
|
507
|
+
// Later:
|
|
508
|
+
dismiss(id);`},{title:"Custom icon",description:"Override the built-in variant icon with a custom SVG.",code:`toast({
|
|
509
|
+
title: 'Synced',
|
|
510
|
+
variant: 'success',
|
|
511
|
+
icon: <CloudSyncIcon />,
|
|
512
|
+
});`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Renders title and description text with correct typography",required:!0},{componentId:"icon",componentName:"Icon (built-in SVGs)",role:"Status variant icons (info, success, warning, danger)",required:!1}],accessibility:{role:"status",ariaAttributes:["aria-live","aria-hidden","aria-label"],keyboardInteractions:["Tab: focuses the dismiss button and action button within the toast","Enter/Space: activates the focused dismiss or action button","Escape: no default behavior (consider adding dismiss-on-escape if needed)"],notes:'Each toast uses role="status" with aria-live="polite" so screen readers announce the content without interrupting the current task. This is appropriate for non-urgent status messages like "Changes saved" or "Profile updated". For truly urgent errors that must interrupt the user, consider wrapping the ToastProvider output in a role="alert" region or using the Alert component instead. The dismiss button carries aria-label="Dismiss" for screen reader clarity. Stacked toasts behind the front toast are marked aria-hidden="true" to prevent screen readers from announcing duplicate or hidden content. When the stack expands on hover, aria-hidden is removed so all toasts become accessible.'}},ti={fontFamilyBase:'"DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontFamilyMono:'"DM Mono", "Fira Code", "Cascadia Code", monospace',fontFamilyDisplay:'"Georama", "DM Sans", sans-serif',fontSizeXs:"0.75rem",fontSizeSm:"0.875rem",fontSizeMd:"1rem",fontSizeLg:"1.125rem",fontSizeXl:"1.25rem",fontSize2xl:"1.5rem",fontSize3xl:"1.875rem",fontWeightRegular:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightBase:"1.5",lineHeightRelaxed:"1.75",letterSpacingTight:"-0.02em",letterSpacingBase:"0em",letterSpacingWide:"0.04em"},ni={space0:"0px",space1:"0.25rem",space2:"0.5rem",space3:"0.75rem",space4:"1rem",space5:"1.25rem",space6:"1.5rem",space8:"2rem",space10:"2.5rem",space12:"3rem",space16:"4rem",space20:"5rem",space24:"6rem"},ai={radiusNone:"0px",radiusSm:"0.25rem",radiusMd:"0.375rem",radiusLg:"0.5rem",radiusXl:"0.75rem",radiusFull:"9999px"},ri={durationFast:"100ms",durationBase:"200ms",durationSlow:"350ms",easingDefault:"cubic-bezier(0.4, 0, 0.2, 1)",easingEmphasized:"cubic-bezier(0.2, 0, 0, 1)",easingDecelerate:"cubic-bezier(0, 0, 0.2, 1)"},oi={shadowNone:"none",shadowSm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",shadowMd:"0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",shadowLg:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",shadowXl:"0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)"},ii={shadowNone:"none",shadowSm:"0 1px 2px 0 rgb(0 0 0 / 0.3)",shadowMd:"0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4)",shadowLg:"0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4)",shadowXl:"0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5)"},ue={...ti,...ni,...ai,...ri,...oi,bgBase:"#ffffff",bgSubtle:"#f9fafb",bgOverlay:"rgb(0 0 0 / 0.4)",surface:"#ffffff",surfaceSecondary:"#f3f4f6",surfaceRaised:"#ffffff",surfaceOverlay:"#ffffff",surfaceTint:"#f2f2f2",borderDefault:"#e5e7eb",borderSubtle:"#f3f4f6",borderStrong:"#9ca3af",controlTrack:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",textDisabled:"#9ca3af",textInverse:"#ffffff",textOnAccent:"#ffffff",accentDefault:"#111827",accentHover:"#1f2937",accentActive:"#374151",accentSubtle:"#f3f4f6",accentBorder:"#111827",successDefault:"#16a34a",successSubtle:"#f0fdf4",successText:"#15803d",warningDefault:"#d97706",warningSubtle:"#fffbeb",warningText:"#b45309",dangerDefault:"#dc2626",dangerHover:"#b91c1c",dangerSubtle:"#fef2f2",dangerText:"#b91c1c",infoDefault:"#2563eb",infoSubtle:"#eff6ff",infoText:"#1d4ed8",focusRing:"#111827"};function si(t){const n=parseInt(t.slice(1,3),16),r=parseInt(t.slice(3,5),16),o=parseInt(t.slice(5,7),16);return{r:n,g:r,b:o}}function li({r:t,g:n,b:r}){const o=a=>a.toString(16).padStart(2,"0");return`#${o(t)}${o(n)}${o(r)}`}function ee(t){const{r:n,g:r,b:o}=si(t),a=n/255,i=r/255,s=o/255,l=Math.max(a,i,s),c=Math.min(a,i,s);let d=0,u=0;const h=(l+c)/2;if(l!==c){const m=l-c;switch(u=h>.5?m/(2-l-c):m/(l+c),l){case a:d=(i-s)/m+(i<s?6:0);break;case i:d=(s-a)/m+2;break;case s:d=(a-i)/m+4;break}d/=6}return[d*360,u,h]}function Q(t,n,r){t=(t%360+360)%360,n=Math.min(1,Math.max(0,n)),r=Math.min(1,Math.max(0,r));const o=(1-Math.abs(2*r-1))*n,a=o*(1-Math.abs(t/60%2-1)),i=r-o/2;let s=0,l=0,c=0;return t<60?(s=o,l=a):t<120?(s=a,l=o):t<180?(l=o,c=a):t<240?(l=a,c=o):t<300?(s=a,c=o):(s=o,c=a),li({r:Math.round((s+i)*255),g:Math.round((l+i)*255),b:Math.round((c+i)*255)})}function V(t,n){const[r,o,a]=ee(t);return Q(r,o,Math.min(1,Math.max(0,a+n)))}const ci=222,di=.12;function Ft(t,n){return n<.04?[ci,di]:[t,n]}function ui(t){const[n,r,o]=ee(t),[a,i]=Ft(n,r);return Q(a,i,Math.max(.04,Math.min(.2,.07+(1-o))))}function Re(t){const[n,r,o]=ee(t),[a,i]=Ft(n,r);return Q(a,i,Math.max(.06,Math.min(.5,(1-o)*.6+.06)))}function qe(t){const[n,r,o]=ee(t);return Q(n,r,Math.max(.04,Math.min(.97,1-o+.04)))}function se(t){const[n,r,o]=ee(t);return Q(n,r,Math.max(.02,Math.min(.98,1-o)))}function Nt(t){const n=ui(t.bgBase),[r,o,a]=ee(n),i=s=>Q(r,o,Math.min(.25,a+s));return{...t,...ii,bgBase:n,bgSubtle:i(.02),bgOverlay:"rgb(0 0 0 / 0.6)",surface:i(.02),surfaceSecondary:i(.05),surfaceRaised:i(.08),surfaceOverlay:i(.08),surfaceTint:i(.03),borderDefault:Re(t.borderDefault),borderSubtle:Re(t.borderSubtle),borderStrong:Re(t.borderStrong),controlTrack:i(.1),textPrimary:qe(t.textPrimary),textSecondary:qe(t.textSecondary),textDisabled:qe(t.textDisabled),textInverse:n,textOnAccent:t.textOnAccent,accentDefault:se(t.accentDefault),accentHover:se(t.accentHover),accentActive:se(t.accentActive),accentSubtle:se(t.accentSubtle),accentBorder:t.accentBorder,successDefault:V(t.successDefault,.1),successSubtle:V(t.successDefault,-.25),successText:V(t.successText,.15),warningDefault:V(t.warningDefault,.1),warningSubtle:V(t.warningDefault,-.25),warningText:V(t.warningText,.15),dangerDefault:V(t.dangerDefault,.1),dangerHover:V(t.dangerHover,.1),dangerSubtle:V(t.dangerDefault,-.25),dangerText:V(t.dangerText,.15),infoDefault:V(t.infoDefault,.1),infoSubtle:V(t.infoDefault,-.25),infoText:V(t.infoText,.15),focusRing:se(t.focusRing)}}const Ge=Nt(ue);function pi(t){return"--lucent-"+t.replace(/([A-Z])/g,n=>`-${n.toLowerCase()}`).replace(/([a-z])(\d)/g,(n,r,o)=>`${r}-${o}`)}function $t(t,n=":root"){const r=Object.entries(t).map(([o,a])=>` ${pi(o)}: ${a};`).join(`
|
|
456
513
|
`);return`${n} {
|
|
457
514
|
${r}
|
|
458
|
-
}`}function No(e){const n=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,a=s=>s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4);return .2126*a(n)+.7152*a(r)+.0722*a(o)}const $o=.2126729,Wo=.7151522,Oo=.072175,Ho=.56,Vo=.57,Uo=.65,Go=.62,xt=.022,_o=1.414,Yo=1.14,Ko=1.14,wt=.027,kt=.027;function St(e){const n=parseInt(e.slice(1,3),16)/255,r=parseInt(e.slice(3,5),16)/255,o=parseInt(e.slice(5,7),16)/255,a=Math.pow(n,2.4),s=Math.pow(r,2.4),i=Math.pow(o,2.4);let l=$o*a+Wo*s+Oo*i;return l<0&&(l=0),l<xt?l+Math.pow(xt-l,_o):l}function Te(e,n){const r=St(e),o=St(n);let a;if(r>o){const s=(Math.pow(r,Ho)-Math.pow(o,Vo))*Yo;a=s<wt?0:s-wt}else{const s=(Math.pow(r,Uo)-Math.pow(o,Go))*Ko;a=s>-kt?0:s+kt}return a*100}function Ge(e){const n=Math.abs(Te(e,"#ffffff")),r=Math.abs(Te(e,"#000000"));return n>=r?"#ffffff":"#000000"}function Xo(e,n,r=60){if(Math.abs(Te(e,n))>=r)return e;const o=parseInt(e.slice(1,3),16)/255,a=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,i=Math.max(o,a,s),l=Math.min(o,a,s);let c=0,d=0,u=(i+l)/2;if(i!==l){const g=i-l;d=u>.5?g/(2-i-l):g/(i+l),i===o?c=((a-s)/g+(a<s?6:0))/6:i===a?c=((s-o)/g+2)/6:c=((o-a)/g+4)/6}const m=No(n)>.5?-.005:.005;for(let g=0;g<100;g++){u=Math.min(1,Math.max(0,u+m));const C=Jo(c,d,u);if(Math.abs(Te(C,n))>=r)return C}return e}function Jo(e,n,r){const o=(c,d,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<.16666666666666666?c+(d-c)*6*u:u<.5?d:u<.6666666666666666?c+(d-c)*(.6666666666666666-u)*6:c);let a,s,i;if(n===0)a=s=i=r;else{const c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;a=o(d,c,e+1/3),s=o(d,c,e),i=o(d,c,e-1/3)}const l=c=>Math.round(c*255).toString(16).padStart(2,"0");return`#${l(a)}${l(s)}${l(i)}`}function Zo(e,n){const[r,o,a]=Q(e);return n?Z(r,o*.3,Math.min(1,a+(1-a)*.85)):Z(r,o,Math.min(.25,a+.04))}const Ce={subtle:{light:.95,dark:.12},text:{light:.28,dark:.78}};function ve(e,n){const[r,o]=Q(e);return Z(r,o*.5,n?Ce.subtle.light:Ce.subtle.dark)}function ye(e,n){const[r,o]=Q(e);return Z(r,o,n?Ce.text.light:Ce.text.dark)}function _e(e,n,r){const o={},a=r==="light";if("borderDefault"in e&&("borderSubtle"in e||(o.borderSubtle=V(n.borderDefault,a?.05:-.02)),"borderStrong"in e||(o.borderStrong=V(n.borderDefault,a?-.27:.19))),"bgBase"in e&&("bgSubtle"in e||(o.bgSubtle=V(n.bgBase,a?-.02:.02)),"surfaceTint"in e||(o.surfaceTint=V(n.bgBase,a?-.04:.03)),!("surface"in e))){const s=Zo(n.bgBase,a);o.surface=s,"surfaceSecondary"in e||(o.surfaceSecondary=V(s,a?-.04:.03)),"surfaceRaised"in e||(o.surfaceRaised=V(s,a?0:.06)),"surfaceOverlay"in e||(o.surfaceOverlay=V(s,a?0:.06))}return"surface"in e&&("surfaceSecondary"in e||(o.surfaceSecondary=V(n.surface,a?-.04:.03)),"surfaceRaised"in e||(o.surfaceRaised=V(n.surface,a?0:.06)),"surfaceOverlay"in e||(o.surfaceOverlay=V(n.surface,a?0:.06))),"textPrimary"in e&&("textSecondary"in e||(o.textSecondary=V(n.textPrimary,a?.2:-.15)),"textDisabled"in e||(o.textDisabled=V(n.textPrimary,a?.35:-.4))),"accentDefault"in e&&("accentHover"in e||(o.accentHover=V(n.accentDefault,a?.05:-.07)),"accentActive"in e||(o.accentActive=V(n.accentDefault,a?.13:-.14)),"accentSubtle"in e||(o.accentSubtle=V(n.accentDefault,a?.85:-.6))),"successDefault"in e&&("successSubtle"in e||(o.successSubtle=ve(n.successDefault,a)),"successText"in e||(o.successText=ye(n.successDefault,a))),"warningDefault"in e&&("warningSubtle"in e||(o.warningSubtle=ve(n.warningDefault,a)),"warningText"in e||(o.warningText=ye(n.warningDefault,a))),"dangerDefault"in e&&("dangerHover"in e||(o.dangerHover=V(n.dangerDefault,a?.05:-.07)),"dangerSubtle"in e||(o.dangerSubtle=ve(n.dangerDefault,a)),"dangerText"in e||(o.dangerText=ye(n.dangerDefault,a))),"infoDefault"in e&&("infoSubtle"in e||(o.infoSubtle=ve(n.infoDefault,a)),"infoText"in e||(o.infoText=ye(n.infoDefault,a))),o}function Ye(e,n="light"){const o={...n==="dark"?Ue:ue,...e},a=_e(e,o,n),s=n==="light"?V(o.accentDefault,-.15):V(o.accentDefault,.15);return{...o,...a,textOnAccent:Ge(o.accentDefault),accentBorder:s}}const Ke={name:"default",light:{bgBase:"#ffffff",surface:"#ffffff",borderDefault:"#e5e7eb",accentDefault:"#111827",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#111318",surface:"#181a20",borderDefault:"#2e3039",accentDefault:"#f9fafb",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ft={name:"brand",light:{bgBase:"#fffefb",surface:"#fffdf7",borderDefault:"#e8e3d6",accentDefault:"#e9c96b",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#151310",surface:"#1c1a15",borderDefault:"#33302a",accentDefault:"#e9c96b",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Xe={name:"indigo",light:{bgBase:"#fdfcff",surface:"#faf9fe",borderDefault:"#e0dde9",accentDefault:"#6366f1",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#12111a",surface:"#191820",borderDefault:"#2e2d3a",accentDefault:"#818cf8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Qo={name:"violet",light:{bgBase:"#fdfcfe",surface:"#faf8fd",borderDefault:"#e2dce9",accentDefault:"#8b5cf6",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#13111a",surface:"#1a1822",borderDefault:"#302d3b",accentDefault:"#a78bfa",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Pt={name:"emerald",light:{bgBase:"#fbfefc",surface:"#f7fcf9",borderDefault:"#dbe8df",accentDefault:"#10b981",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1512",surface:"#151c18",borderDefault:"#263330",accentDefault:"#34d399",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},es={name:"teal",light:{bgBase:"#fbfefd",surface:"#f6fcfa",borderDefault:"#d4e5e0",accentDefault:"#0d9488",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1514",surface:"#161d1c",borderDefault:"#283836",accentDefault:"#2dd4bf",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Je={name:"rose",light:{bgBase:"#fffcfd",surface:"#fef9fa",borderDefault:"#ecdde1",accentDefault:"#f43f5e",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#161012",surface:"#1d1518",borderDefault:"#3a282e",accentDefault:"#fb7185",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},ts={name:"coral",light:{bgBase:"#fffcfb",surface:"#fef9f7",borderDefault:"#e9ddd8",accentDefault:"#e8624a",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#b91c1c",infoDefault:"#2563eb"},dark:{bgBase:"#171210",surface:"#1e1816",borderDefault:"#3b312c",accentDefault:"#f38b76",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},ns={name:"amber",light:{bgBase:"#fffefb",surface:"#fefcf6",borderDefault:"#e8e1d0",accentDefault:"#d97706",successDefault:"#16a34a",warningDefault:"#b45309",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#171310",surface:"#1e1a15",borderDefault:"#3a3329",accentDefault:"#f59e0b",successDefault:"#22c55e",warningDefault:"#d97706",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Nt={name:"ocean",light:{bgBase:"#fbfdff",surface:"#f6fafd",borderDefault:"#d9e4ec",accentDefault:"#0ea5e9",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0e1318",surface:"#141a20",borderDefault:"#243038",accentDefault:"#38bdf8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},as={name:"slate",light:{bgBase:"#fafbfc",surface:"#f7f8fa",borderDefault:"#dde1e6",accentDefault:"#475569",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1116",surface:"#161920",borderDefault:"#2b3040",accentDefault:"#94a3b8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},rs={name:"sage",light:{bgBase:"#fbfcfb",surface:"#f5f7f5",borderDefault:"#d8ddd6",accentDefault:"#5f8c6e",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#101410",surface:"#171c17",borderDefault:"#2c372c",accentDefault:"#86b394",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ze={name:"sharp",tokens:{radiusNone:"0px",radiusSm:"0.125rem",radiusMd:"0.1875rem",radiusLg:"0.25rem",radiusXl:"0.375rem",radiusFull:"9999px"}},Qe={name:"rounded",tokens:{radiusNone:"0px",radiusSm:"0.25rem",radiusMd:"0.375rem",radiusLg:"0.5rem",radiusXl:"0.75rem",radiusFull:"9999px"}},et={name:"pill",tokens:{radiusNone:"0px",radiusSm:"0.5rem",radiusMd:"0.75rem",radiusLg:"1rem",radiusXl:"1.5rem",radiusFull:"9999px"}},tt={name:"compact",tokens:{space0:"0px",space1:"0.1rem",space2:"0.25rem",space3:"0.6rem",space4:"0.8rem",space5:"1rem",space6:"1.2rem",space8:"1.6rem",space10:"2rem",space12:"2.4rem",space16:"3.2rem",space20:"4rem",space24:"4.8rem"}},nt={name:"default",tokens:{space0:"0px",space1:"0.25rem",space2:"0.5rem",space3:"0.75rem",space4:"1rem",space5:"1.25rem",space6:"1.5rem",space8:"2rem",space10:"2.5rem",space12:"3rem",space16:"4rem",space20:"5rem",space24:"6rem"}},at={name:"spacious",tokens:{space0:"0px",space1:"0.375rem",space2:"0.75rem",space3:"1.125rem",space4:"1.25rem",space5:"1.5625rem",space6:"1.875rem",space8:"2.5rem",space10:"3.125rem",space12:"3.75rem",space16:"5rem",space20:"6.25rem",space24:"7.5rem"}},rt={name:"flat",light:{shadowNone:"none",shadowSm:"none",shadowMd:"none",shadowLg:"none",shadowXl:"none"},dark:{shadowNone:"none",shadowSm:"none",shadowMd:"none",shadowLg:"none",shadowXl:"none"}},ot={name:"subtle",light:{shadowNone:"none",shadowSm:"rgba(17, 17, 26, 0.04) 0px 2px 8px, rgba(17, 17, 26, 0.02) 0px 4px 16px",shadowMd:"rgba(17, 17, 26, 0.06) 0px 4px 16px, rgba(17, 17, 26, 0.03) 0px 8px 32px",shadowLg:"rgba(17, 17, 26, 0.06) 0px 8px 24px, rgba(17, 17, 26, 0.04) 0px 16px 48px",shadowXl:"rgba(17, 17, 26, 0.08) 0px 12px 32px, rgba(17, 17, 26, 0.05) 0px 24px 64px"},dark:{shadowNone:"none",shadowSm:"rgba(0, 0, 0, 0.12) 0px 2px 8px, rgba(0, 0, 0, 0.08) 0px 4px 16px",shadowMd:"rgba(0, 0, 0, 0.18) 0px 4px 16px, rgba(0, 0, 0, 0.1) 0px 8px 32px",shadowLg:"rgba(0, 0, 0, 0.18) 0px 8px 24px, rgba(0, 0, 0, 0.12) 0px 16px 48px",shadowXl:"rgba(0, 0, 0, 0.2) 0px 12px 32px, rgba(0, 0, 0, 0.15) 0px 24px 64px"}},st={name:"elevated",light:{shadowNone:"none",shadowSm:"rgba(17, 17, 26, 0.05) 0px 2px 8px, rgba(17, 17, 26, 0.03) 0px 4px 16px",shadowMd:"rgba(17, 17, 26, 0.1) 0px 4px 16px, rgba(17, 17, 26, 0.05) 0px 8px 32px",shadowLg:"rgba(17, 17, 26, 0.1) 0px 8px 24px, rgba(17, 17, 26, 0.08) 0px 16px 48px",shadowXl:"rgba(17, 17, 26, 0.12) 0px 12px 32px, rgba(17, 17, 26, 0.1) 0px 24px 64px"},dark:{shadowNone:"none",shadowSm:"rgba(0, 0, 0, 0.2) 0px 2px 8px, rgba(0, 0, 0, 0.15) 0px 4px 16px",shadowMd:"rgba(0, 0, 0, 0.3) 0px 4px 16px, rgba(0, 0, 0, 0.2) 0px 8px 32px",shadowLg:"rgba(0, 0, 0, 0.3) 0px 8px 24px, rgba(0, 0, 0, 0.25) 0px 16px 48px",shadowXl:"rgba(0, 0, 0, 0.35) 0px 12px 32px, rgba(0, 0, 0, 0.3) 0px 24px 64px"}},$t={name:"modern",palette:Xe,shape:Qe,density:nt,shadow:ot},Wt={name:"enterprise",palette:Ke,shape:Ze,density:tt,shadow:rt},Ot={name:"playful",palette:Je,shape:et,density:at,shadow:st},os={default:Ke,brand:Ft,indigo:Xe,violet:Qo,emerald:Pt,teal:es,rose:Je,coral:ts,amber:ns,ocean:Nt,slate:as,sage:rs},ss={sharp:Ze,rounded:Qe,pill:et},is={compact:tt,default:nt,spacious:at},ls={flat:rt,subtle:ot,elevated:st},cs={modern:$t,enterprise:Wt,playful:Ot};function ds(e){return typeof e=="string"?os[e]:e}function us(e){return typeof e=="string"?ss[e]:e}function ps(e){return typeof e=="string"?is[e]:e}function fs(e){return typeof e=="string"?ls[e]:e}function Ht(e,n){let r,o,a,s;if(typeof e=="string"){const l=cs[e];if(!l)return{};r=l.palette,o=l.shape,a=l.density,s=l.shadow}else e.palette!==void 0&&(r=ds(e.palette)),e.shape!==void 0&&(o=us(e.shape)),e.density!==void 0&&(a=ps(e.density)),e.shadow!==void 0&&(s=fs(e.shadow));const i={};if(r){const l=Ye(r[n],n);Object.assign(i,l)}return o&&Object.assign(i,o.tokens),a&&Object.assign(i,a.tokens),s&&Object.assign(i,s[n]),i}const Vt=p.createContext({theme:"light",tokens:ue});function hs({theme:e="light",preset:n,tokens:r,anchors:o,children:a}){const s=p.useId().replace(/:/g,""),i=n?Ht(n,e):void 0,l=(()=>{if(o){const f=Ye(o,e);if(i){const v={};for(const[b,T]of Object.entries(i))(b.startsWith("space")||b.startsWith("radius")||b.startsWith("shadow")||b.startsWith("duration")||b.startsWith("easing"))&&(v[b]=T);return{...f,...v}}return f}const d=e==="dark"?Ue:ue,u=i?{...i,...r}:r,h=u?{...d,...u}:d,m=u?_e(u,h,e):{},g=(u==null?void 0:u.accentBorder)??(e==="light"?V(h.accentDefault,-.15):V(h.accentDefault,.15)),C=(u==null?void 0:u.textOnAccent)??Ge(h.accentDefault),y=Xo(h.accentDefault,C);return{...h,...m,accentDefault:y,textOnAccent:C,accentBorder:g}})(),c=`html { font-size: 14px; }
|
|
459
|
-
|
|
515
|
+
}`}function fi(t){const n=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,o=parseInt(t.slice(5,7),16)/255,a=i=>i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4);return .2126*a(n)+.7152*a(r)+.0722*a(o)}const hi=.2126729,mi=.7151522,gi=.072175,vi=.56,bi=.57,yi=.65,xi=.62,St=.022,wi=1.414,ki=1.14,Si=1.14,Tt=.027,Ct=.027;function jt(t){const n=parseInt(t.slice(1,3),16)/255,r=parseInt(t.slice(3,5),16)/255,o=parseInt(t.slice(5,7),16)/255,a=Math.pow(n,2.4),i=Math.pow(r,2.4),s=Math.pow(o,2.4);let l=hi*a+mi*i+gi*s;return l<0&&(l=0),l<St?l+Math.pow(St-l,wi):l}function Te(t,n){const r=jt(t),o=jt(n);let a;if(r>o){const i=(Math.pow(r,vi)-Math.pow(o,bi))*ki;a=i<Tt?0:i-Tt}else{const i=(Math.pow(r,yi)-Math.pow(o,xi))*Si;a=i>-Ct?0:i+Ct}return a*100}function _e(t){const n=Math.abs(Te(t,"#ffffff")),r=Math.abs(Te(t,"#000000"));return n>=r?"#ffffff":"#000000"}function Ti(t,n,r=60){if(Math.abs(Te(t,n))>=r)return t;const o=parseInt(t.slice(1,3),16)/255,a=parseInt(t.slice(3,5),16)/255,i=parseInt(t.slice(5,7),16)/255,s=Math.max(o,a,i),l=Math.min(o,a,i);let c=0,d=0,u=(s+l)/2;if(s!==l){const g=s-l;d=u>.5?g/(2-s-l):g/(s+l),s===o?c=((a-i)/g+(a<i?6:0))/6:s===a?c=((i-o)/g+2)/6:c=((o-a)/g+4)/6}const m=fi(n)>.5?-.005:.005;for(let g=0;g<100;g++){u=Math.min(1,Math.max(0,u+m));const C=Ci(c,d,u);if(Math.abs(Te(C,n))>=r)return C}return t}function Ci(t,n,r){const o=(c,d,u)=>(u<0&&(u+=1),u>1&&(u-=1),u<.16666666666666666?c+(d-c)*6*u:u<.5?d:u<.6666666666666666?c+(d-c)*(.6666666666666666-u)*6:c);let a,i,s;if(n===0)a=i=s=r;else{const c=r<.5?r*(1+n):r+n-r*n,d=2*r-c;a=o(d,c,t+1/3),i=o(d,c,t),s=o(d,c,t-1/3)}const l=c=>Math.round(c*255).toString(16).padStart(2,"0");return`#${l(a)}${l(i)}${l(s)}`}function ji(t,n){const[r,o,a]=ee(t);return n?Q(r,o*.3,Math.min(1,a+(1-a)*.85)):Q(r,o,Math.min(.25,a+.04))}const Ce={subtle:{light:.95,dark:.12},text:{light:.28,dark:.78}};function be(t,n){const[r,o]=ee(t);return Q(r,o*.5,n?Ce.subtle.light:Ce.subtle.dark)}function ye(t,n){const[r,o]=ee(t);return Q(r,o,n?Ce.text.light:Ce.text.dark)}function Ye(t,n,r){const o={},a=r==="light";if("borderDefault"in t&&("borderSubtle"in t||(o.borderSubtle=V(n.borderDefault,a?.05:-.02)),"borderStrong"in t||(o.borderStrong=V(n.borderDefault,a?-.27:.19))),"bgBase"in t&&("bgSubtle"in t||(o.bgSubtle=V(n.bgBase,a?-.02:.02)),"surfaceTint"in t||(o.surfaceTint=V(n.bgBase,a?-.04:.03)),!("surface"in t))){const i=ji(n.bgBase,a);o.surface=i,"surfaceSecondary"in t||(o.surfaceSecondary=V(i,a?-.04:.03)),"surfaceRaised"in t||(o.surfaceRaised=V(i,a?0:.06)),"surfaceOverlay"in t||(o.surfaceOverlay=V(i,a?0:.06))}return"surface"in t&&("surfaceSecondary"in t||(o.surfaceSecondary=V(n.surface,a?-.04:.03)),"surfaceRaised"in t||(o.surfaceRaised=V(n.surface,a?0:.06)),"surfaceOverlay"in t||(o.surfaceOverlay=V(n.surface,a?0:.06))),"textPrimary"in t&&("textSecondary"in t||(o.textSecondary=V(n.textPrimary,a?.2:-.15)),"textDisabled"in t||(o.textDisabled=V(n.textPrimary,a?.35:-.4))),"accentDefault"in t&&("accentHover"in t||(o.accentHover=V(n.accentDefault,a?.05:-.07)),"accentActive"in t||(o.accentActive=V(n.accentDefault,a?.13:-.14)),"accentSubtle"in t||(o.accentSubtle=V(n.accentDefault,a?.85:-.6))),"successDefault"in t&&("successSubtle"in t||(o.successSubtle=be(n.successDefault,a)),"successText"in t||(o.successText=ye(n.successDefault,a))),"warningDefault"in t&&("warningSubtle"in t||(o.warningSubtle=be(n.warningDefault,a)),"warningText"in t||(o.warningText=ye(n.warningDefault,a))),"dangerDefault"in t&&("dangerHover"in t||(o.dangerHover=V(n.dangerDefault,a?.05:-.07)),"dangerSubtle"in t||(o.dangerSubtle=be(n.dangerDefault,a)),"dangerText"in t||(o.dangerText=ye(n.dangerDefault,a))),"infoDefault"in t&&("infoSubtle"in t||(o.infoSubtle=be(n.infoDefault,a)),"infoText"in t||(o.infoText=ye(n.infoDefault,a))),o}function Ke(t,n="light"){const o={...n==="dark"?Ge:ue,...t},a=Ye(t,o,n),i=n==="light"?V(o.accentDefault,-.15):V(o.accentDefault,.15);return{...o,...a,textOnAccent:_e(o.accentDefault),accentBorder:i}}const Xe={name:"default",light:{bgBase:"#ffffff",surface:"#ffffff",borderDefault:"#e5e7eb",accentDefault:"#111827",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#111318",surface:"#181a20",borderDefault:"#2e3039",accentDefault:"#f9fafb",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Wt={name:"brand",light:{bgBase:"#fffefb",surface:"#fffdf7",borderDefault:"#e8e3d6",accentDefault:"#e9c96b",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#151310",surface:"#1c1a15",borderDefault:"#33302a",accentDefault:"#e9c96b",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Je={name:"indigo",light:{bgBase:"#fdfcff",surface:"#faf9fe",borderDefault:"#e0dde9",accentDefault:"#6366f1",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#12111a",surface:"#191820",borderDefault:"#2e2d3a",accentDefault:"#818cf8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ii={name:"violet",light:{bgBase:"#fdfcfe",surface:"#faf8fd",borderDefault:"#e2dce9",accentDefault:"#8b5cf6",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#13111a",surface:"#1a1822",borderDefault:"#302d3b",accentDefault:"#a78bfa",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ot={name:"emerald",light:{bgBase:"#fbfefc",surface:"#f7fcf9",borderDefault:"#dbe8df",accentDefault:"#10b981",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1512",surface:"#151c18",borderDefault:"#263330",accentDefault:"#34d399",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Mi={name:"teal",light:{bgBase:"#fbfefd",surface:"#f6fcfa",borderDefault:"#d4e5e0",accentDefault:"#0d9488",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1514",surface:"#161d1c",borderDefault:"#283836",accentDefault:"#2dd4bf",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ze={name:"rose",light:{bgBase:"#fffcfd",surface:"#fef9fa",borderDefault:"#ecdde1",accentDefault:"#f43f5e",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#161012",surface:"#1d1518",borderDefault:"#3a282e",accentDefault:"#fb7185",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Di={name:"coral",light:{bgBase:"#fffcfb",surface:"#fef9f7",borderDefault:"#e9ddd8",accentDefault:"#e8624a",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#b91c1c",infoDefault:"#2563eb"},dark:{bgBase:"#171210",surface:"#1e1816",borderDefault:"#3b312c",accentDefault:"#f38b76",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},zi={name:"amber",light:{bgBase:"#fffefb",surface:"#fefcf6",borderDefault:"#e8e1d0",accentDefault:"#d97706",successDefault:"#16a34a",warningDefault:"#b45309",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#171310",surface:"#1e1a15",borderDefault:"#3a3329",accentDefault:"#f59e0b",successDefault:"#22c55e",warningDefault:"#d97706",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ht={name:"ocean",light:{bgBase:"#fbfdff",surface:"#f6fafd",borderDefault:"#d9e4ec",accentDefault:"#0ea5e9",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0e1318",surface:"#141a20",borderDefault:"#243038",accentDefault:"#38bdf8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ei={name:"slate",light:{bgBase:"#fafbfc",surface:"#f7f8fa",borderDefault:"#dde1e6",accentDefault:"#475569",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#0f1116",surface:"#161920",borderDefault:"#2b3040",accentDefault:"#94a3b8",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Ai={name:"sage",light:{bgBase:"#fbfcfb",surface:"#f5f7f5",borderDefault:"#d8ddd6",accentDefault:"#5f8c6e",successDefault:"#16a34a",warningDefault:"#d97706",dangerDefault:"#dc2626",infoDefault:"#2563eb"},dark:{bgBase:"#101410",surface:"#171c17",borderDefault:"#2c372c",accentDefault:"#86b394",successDefault:"#22c55e",warningDefault:"#f59e0b",dangerDefault:"#ef4444",infoDefault:"#3b82f6"}},Qe={name:"sharp",tokens:{radiusNone:"0px",radiusSm:"0.125rem",radiusMd:"0.1875rem",radiusLg:"0.25rem",radiusXl:"0.375rem",radiusFull:"9999px"}},et={name:"rounded",tokens:{radiusNone:"0px",radiusSm:"0.25rem",radiusMd:"0.375rem",radiusLg:"0.5rem",radiusXl:"0.75rem",radiusFull:"9999px"}},tt={name:"pill",tokens:{radiusNone:"0px",radiusSm:"0.5rem",radiusMd:"0.75rem",radiusLg:"1rem",radiusXl:"1.5rem",radiusFull:"9999px"}},nt={name:"compact",tokens:{space0:"0px",space1:"0.1rem",space2:"0.25rem",space3:"0.6rem",space4:"0.8rem",space5:"1rem",space6:"1.2rem",space8:"1.6rem",space10:"2rem",space12:"2.4rem",space16:"3.2rem",space20:"4rem",space24:"4.8rem"}},at={name:"default",tokens:{space0:"0px",space1:"0.25rem",space2:"0.5rem",space3:"0.75rem",space4:"1rem",space5:"1.25rem",space6:"1.5rem",space8:"2rem",space10:"2.5rem",space12:"3rem",space16:"4rem",space20:"5rem",space24:"6rem"}},rt={name:"spacious",tokens:{space0:"0px",space1:"0.375rem",space2:"0.75rem",space3:"1.125rem",space4:"1.25rem",space5:"1.5625rem",space6:"1.875rem",space8:"2.5rem",space10:"3.125rem",space12:"3.75rem",space16:"5rem",space20:"6.25rem",space24:"7.5rem"}},ot={name:"flat",light:{shadowNone:"none",shadowSm:"none",shadowMd:"none",shadowLg:"none",shadowXl:"none"},dark:{shadowNone:"none",shadowSm:"none",shadowMd:"none",shadowLg:"none",shadowXl:"none"}},it={name:"subtle",light:{shadowNone:"none",shadowSm:"rgba(17, 17, 26, 0.04) 0px 2px 8px, rgba(17, 17, 26, 0.02) 0px 4px 16px",shadowMd:"rgba(17, 17, 26, 0.06) 0px 4px 16px, rgba(17, 17, 26, 0.03) 0px 8px 32px",shadowLg:"rgba(17, 17, 26, 0.06) 0px 8px 24px, rgba(17, 17, 26, 0.04) 0px 16px 48px",shadowXl:"rgba(17, 17, 26, 0.08) 0px 12px 32px, rgba(17, 17, 26, 0.05) 0px 24px 64px"},dark:{shadowNone:"none",shadowSm:"rgba(0, 0, 0, 0.12) 0px 2px 8px, rgba(0, 0, 0, 0.08) 0px 4px 16px",shadowMd:"rgba(0, 0, 0, 0.18) 0px 4px 16px, rgba(0, 0, 0, 0.1) 0px 8px 32px",shadowLg:"rgba(0, 0, 0, 0.18) 0px 8px 24px, rgba(0, 0, 0, 0.12) 0px 16px 48px",shadowXl:"rgba(0, 0, 0, 0.2) 0px 12px 32px, rgba(0, 0, 0, 0.15) 0px 24px 64px"}},st={name:"elevated",light:{shadowNone:"none",shadowSm:"rgba(17, 17, 26, 0.05) 0px 2px 8px, rgba(17, 17, 26, 0.03) 0px 4px 16px",shadowMd:"rgba(17, 17, 26, 0.1) 0px 4px 16px, rgba(17, 17, 26, 0.05) 0px 8px 32px",shadowLg:"rgba(17, 17, 26, 0.1) 0px 8px 24px, rgba(17, 17, 26, 0.08) 0px 16px 48px",shadowXl:"rgba(17, 17, 26, 0.12) 0px 12px 32px, rgba(17, 17, 26, 0.1) 0px 24px 64px"},dark:{shadowNone:"none",shadowSm:"rgba(0, 0, 0, 0.2) 0px 2px 8px, rgba(0, 0, 0, 0.15) 0px 4px 16px",shadowMd:"rgba(0, 0, 0, 0.3) 0px 4px 16px, rgba(0, 0, 0, 0.2) 0px 8px 32px",shadowLg:"rgba(0, 0, 0, 0.3) 0px 8px 24px, rgba(0, 0, 0, 0.25) 0px 16px 48px",shadowXl:"rgba(0, 0, 0, 0.35) 0px 12px 32px, rgba(0, 0, 0, 0.3) 0px 24px 64px"}},Vt={name:"modern",palette:Je,shape:et,density:at,shadow:it},Ut={name:"enterprise",palette:Xe,shape:Qe,density:nt,shadow:ot},Gt={name:"playful",palette:Ze,shape:tt,density:rt,shadow:st},Ri={default:Xe,brand:Wt,indigo:Je,violet:Ii,emerald:Ot,teal:Mi,rose:Ze,coral:Di,amber:zi,ocean:Ht,slate:Ei,sage:Ai},qi={sharp:Qe,rounded:et,pill:tt},Bi={compact:nt,default:at,spacious:rt},Li={flat:ot,subtle:it,elevated:st},Pi={modern:Vt,enterprise:Ut,playful:Gt};function Fi(t){return typeof t=="string"?Ri[t]:t}function Ni(t){return typeof t=="string"?qi[t]:t}function $i(t){return typeof t=="string"?Bi[t]:t}function Wi(t){return typeof t=="string"?Li[t]:t}function _t(t,n){let r,o,a,i;if(typeof t=="string"){const l=Pi[t];if(!l)return{};r=l.palette,o=l.shape,a=l.density,i=l.shadow}else t.palette!==void 0&&(r=Fi(t.palette)),t.shape!==void 0&&(o=Ni(t.shape)),t.density!==void 0&&(a=$i(t.density)),t.shadow!==void 0&&(i=Wi(t.shadow));const s={};if(r){const l=Ke(r[n],n);Object.assign(s,l)}return o&&Object.assign(s,o.tokens),a&&Object.assign(s,a.tokens),i&&Object.assign(s,i[n]),s}const Yt=p.createContext({theme:"light",tokens:ue});function Oi({theme:t="light",preset:n,tokens:r,anchors:o,children:a}){const i=p.useId().replace(/:/g,""),s=n?_t(n,t):void 0,l=(()=>{if(o){const f=Ke(o,t);if(s){const v={};for(const[S,x]of Object.entries(s))(S.startsWith("space")||S.startsWith("radius")||S.startsWith("shadow")||S.startsWith("duration")||S.startsWith("easing"))&&(v[S]=x);return{...f,...v}}return f}const d=t==="dark"?Ge:ue,u=s?{...s,...r}:r,h=u?{...d,...u}:d,m=u?Ye(u,h,t):{},g=(u==null?void 0:u.accentBorder)??(t==="light"?V(h.accentDefault,-.15):V(h.accentDefault,.15)),C=(u==null?void 0:u.textOnAccent)??_e(h.accentDefault),b=Ti(h.accentDefault,C);return{...h,...m,accentDefault:b,textOnAccent:C,accentBorder:g}})(),c=`html { font-size: 14px; }
|
|
516
|
+
`+$t(l,":root");return p.useLayoutEffect(()=>{let d=document.getElementById(`lucent-tokens-${i}`);return d||(d=document.createElement("style"),d.id=`lucent-tokens-${i}`,document.head.appendChild(d)),d.textContent=c,()=>{var u;(u=document.getElementById(`lucent-tokens-${i}`))==null||u.remove()}},[i,c]),e.jsx(Yt.Provider,{value:{theme:t,tokens:l},children:a})}function Hi(){return p.useContext(Yt)}const Vi={bgBase:{description:"Main page/canvas background. The lowest elevation layer — everything sits on top of this. When bgBase is customized, `surface` and `surfaceTint` are auto-derived so the entire card elevation hierarchy (ghost → outline → filled → elevated → combo) adapts automatically.",lightGuidance:"Near-white. Typically #ffffff or a very faint tint (L > 0.96).",darkGuidance:"Near-black with a subtle cool or warm tint. Typically L 0.07–0.10 (e.g. #0f0f11, #111318).",derives:["bgSubtle","surfaceTint","surface","surfaceSecondary","surfaceRaised","surfaceOverlay"]},surface:{description:"Component surface color for elevated cards, input backgrounds, table rows, list items. Optional — when omitted, auto-derived from bgBase (pushed 85% toward white in light mode, +0.04 lightness in dark mode, with 30% saturation retention). Only set explicitly when you need a surface color that doesn't match the bgBase hue.",lightGuidance:"Very slightly off-white — just enough to read as distinct from bgBase. Typically L 0.96–0.98 (e.g. #f9fafb, #f8f8f8).",darkGuidance:"Slightly lighter than bgBase. Typically L 0.11–0.15 (e.g. #1a1a1e, #18181b).",derives:["surfaceSecondary","surfaceRaised","surfaceOverlay"]},borderDefault:{description:"Default border and divider color. Used on input outlines, card borders, table cell borders, section dividers.",lightGuidance:"A mid-light gray. Enough contrast to be legible on bgBase, not so dark it draws attention. Typically L 0.85–0.92 (e.g. #e5e7eb, #d1d5db).",darkGuidance:"A dim gray that reads against dark surfaces. Typically L 0.18–0.26 (e.g. #2d2d35, #374151).",derives:["borderSubtle","borderStrong"]},textPrimary:{description:"Primary body text. High contrast against bgBase — the default color for headings, labels, and body copy.",lightGuidance:"Very dark — near-black. Typically L 0.04–0.15 (e.g. #111827, #0f172a). Must pass WCAG AA against bgBase.",darkGuidance:"Very light — near-white. Typically L 0.88–0.96 (e.g. #f9fafb, #e2e8f0). Must pass WCAG AA against bgBase.",derives:["textSecondary","textDisabled"]},accentDefault:{description:"Primary brand/action color. Drives the visual identity — used on primary buttons, active nav links, focus rings, badges, and progress indicators.",lightGuidance:"Pick a color with enough contrast against both bgBase (white) and textOnAccent (computed automatically). Saturated mid-tones work well. E.g. indigo #6366f1, violet #8b5cf6, emerald #10b981. Monochrome default is #111827 (near-black).",darkGuidance:"In dark mode the accent typically lightens so it stays visible. This is handled automatically via deriveDarkFromLight() — you can supply the same light-mode accent and the dark variant is computed.",derives:["accentHover","accentActive","accentSubtle","accentBorder","textOnAccent"]},successDefault:{description:'Positive/success state color. Used on success alerts, completed step indicators, "online" status badges, and confirmation toasts.',lightGuidance:"A readable green in the mid-to-dark range. E.g. #22c55e (Tailwind green-500), #16a34a (green-600). Avoid very pale greens — they fail WCAG against white.",darkGuidance:"Slightly lighter than the light-mode value so it reads against dark surfaces. createTheme() handles this automatically.",derives:["successSubtle","successText"]},warningDefault:{description:'Cautionary/warning state color. Used on warning banners, pending/in-review badges, and "needs attention" indicators.',lightGuidance:"An amber or orange-yellow. E.g. #f59e0b (Tailwind amber-500), #d97706 (amber-600). Avoid pure yellow — insufficient contrast on white.",darkGuidance:"Slightly lighter than light-mode. createTheme() handles this automatically.",derives:["warningSubtle","warningText"]},dangerDefault:{description:'Error/destructive state color. Used on error messages, delete-confirmation buttons, form field errors, and "offline" or "failed" status.',lightGuidance:"A mid-to-dark red. E.g. #ef4444 (Tailwind red-500), #dc2626 (red-600).",darkGuidance:"Slightly lighter than light-mode. createTheme() handles this automatically.",derives:["dangerHover","dangerSubtle","dangerText"]},infoDefault:{description:'Neutral informational state color. Used on info banners, help tooltips, "new feature" callouts, and link colors in some contexts.',lightGuidance:"A mid blue. E.g. #3b82f6 (Tailwind blue-500), #2563eb (blue-600).",darkGuidance:"Slightly lighter than light-mode. createTheme() handles this automatically.",derives:["infoSubtle","infoText"]}},Ui={id:"lucent-provider",name:"LucentProvider",tier:"provider",domain:"neutral",specVersion:"1.0",description:"Root configuration wrapper that injects Lucent design tokens as CSS custom properties. Accepts a design preset for instant theming, 9 anchor colors (via `anchors`) for zero-config theming, or granular token overrides (via `tokens`) for full control.",designIntent:'LucentProvider is the single source of truth for the visual identity of any Lucent-powered UI. Its primary design goal is to make custom theming accessible to both humans and LLMs with minimal effort.\n\nPRESET MODE (fastest path): Pass `preset` with a named preset ("modern", "enterprise", "playful") or an object mixing dimensions: `{ palette: "indigo", shape: "pill", density: "compact", shadow: "elevated" }`. Presets bundle palette colors, border radius, spacing, and shadows into one cohesive design. Available palettes: default, brand, indigo, emerald, rose, ocean. Shapes: sharp, rounded, pill. Densities: compact, default, spacious. Shadows: flat, subtle, elevated. Presets work with both light and dark themes automatically.\n\nANCHOR MODE (recommended for LLMs building custom themes): Pass `anchors` with 9 semantic colors and the provider automatically derives all 30+ variant tokens — hover/active/subtle states, WCAG-compliant contrast text, status subtle tints, surface elevation steps, and more. An LLM generating a themed UI only needs to reason about 9 colors, not the full token surface.\n\nTOKEN MODE (for granular control): Pass `tokens` as a partial override object. Any token not supplied falls back to the base light or dark theme. Derivation still runs — e.g. if you supply only `accentDefault`, the provider auto-derives `accentHover`, `accentActive`, `accentSubtle`, `accentBorder`, and `textOnAccent`.\n\nPRECEDENCE (later wins): base theme → preset → anchors → tokens. You can combine preset with tokens to start from a preset and tweak individual values.\n\nWCAG auto-computation: `textOnAccent` is always computed from the resolved accent color via relative luminance — it will be #000000 or #ffffff, whichever passes AA contrast. Consumers can override it if they have brand-specific requirements.\n\nDARK MODE: Pass `theme="dark"` alongside any prop. Presets include both light and dark palettes. Anchor colors are applied to the dark base palette; derivation runs with dark-calibrated lightness deltas.\n\nDO NOT nest multiple LucentProviders unless intentionally theming a sub-tree differently (e.g. an inverted sidebar). The outermost provider wins for `:root` CSS vars.',props:[{name:"preset",type:"PresetProp",required:!1,description:'Design preset for instant theming. Pass a combined name ("modern", "enterprise", "playful") or an object to mix dimensions: { palette?: "default"|"brand"|"indigo"|"emerald"|"rose"|"ocean", shape?: "sharp"|"rounded"|"pill", density?: "compact"|"default"|"spacious", shadow?: "flat"|"subtle"|"elevated" }. You can also pass imported preset objects directly for tree-shaking. Precedence: base theme → preset → anchors → tokens.'},{name:"anchors",type:"ThemeAnchors",required:!1,description:"Minimal theming API: supply 9 semantic anchor colors and all variant tokens are derived automatically. See ThemeAnchorsSpec for guidance on each key. When provided alongside a preset, anchors override the preset's palette colors but preset shape/density/shadow tokens are preserved. When provided without a preset, the `tokens` prop is ignored. Required keys: bgBase, borderDefault, accentDefault, successDefault, warningDefault, dangerDefault, infoDefault. Optional keys: textPrimary (defaults to near-black/white), surface (auto-derived from bgBase)."},{name:"theme",type:"enum",required:!1,default:'"light"',enumValues:["light","dark"],description:'Selects the base token palette. "light" uses lightTokens as the starting point; "dark" uses darkTokens. Applies to both anchor-mode and token-mode.'},{name:"tokens",type:"Partial<LucentTokens>",required:!1,description:"Granular token overrides. Any token not supplied falls back to the base theme. Variant derivation still runs for anchor tokens found in this object (e.g. supplying `accentDefault` auto-derives hover/active/subtle variants). Ignored when `anchors` is provided."},{name:"children",type:"ReactNode",required:!0,description:"The subtree to theme. Typically your entire app, or a section that needs independent theming."}],usageExamples:[{title:"Preset mode — combined preset (simplest)",description:"Pick a curated preset that bundles palette, shape, density, and shadow tokens. Works with both light and dark themes.",code:`import { LucentProvider } from 'lucent-ui';
|
|
460
517
|
|
|
461
518
|
<LucentProvider preset="modern">
|
|
462
519
|
<App />
|
|
@@ -546,6 +603,6 @@ const myTheme = createTheme({
|
|
|
546
603
|
<App />
|
|
547
604
|
</main>
|
|
548
605
|
</div>
|
|
549
|
-
</LucentProvider>`}],compositionGraph:[]},
|
|
606
|
+
</LucentProvider>`}],compositionGraph:[]},Gi={accentDefault:"#e9c96b",accentHover:"#ddb84e",accentActive:"#c9a33b",accentSubtle:"#fef9ec",focusRing:"#e9c96b"};function J(t,n){return{field:t,message:n}}function Kt(t){const n=[];if(typeof t!="object"||t===null)return{valid:!1,errors:[J("manifest","Must be a non-null object")]};const r=t,o=["id","name","description","designIntent","specVersion"];for(const i of o)(typeof r[i]!="string"||r[i].trim()==="")&&n.push(J(i,"Must be a non-empty string"));typeof r.id=="string"&&!/^[a-z][a-z0-9-]*$/.test(r.id)&&n.push(J("id",'Must be kebab-case (e.g. "button", "form-field")'));const a=["atom","molecule","block","flow","overlay","provider"];return a.includes(r.tier)||n.push(J("tier",`Must be one of: ${a.join(", ")}`)),(typeof r.domain!="string"||r.domain.trim()==="")&&n.push(J("domain","Must be a non-empty string")),Array.isArray(r.props)?r.props.forEach((i,s)=>{const l=i,c=`props[${s}]`;(typeof l.name!="string"||l.name==="")&&n.push(J(`${c}.name`,"Must be a non-empty string")),(typeof l.type!="string"||l.type==="")&&n.push(J(`${c}.type`,"Must be a non-empty string")),typeof l.required!="boolean"&&n.push(J(`${c}.required`,"Must be a boolean")),(typeof l.description!="string"||l.description==="")&&n.push(J(`${c}.description`,"Must be a non-empty string"))}):n.push(J("props","Must be an array")),Array.isArray(r.usageExamples)?r.usageExamples.length===0?n.push(J("usageExamples","Must have at least one example")):r.usageExamples.forEach((i,s)=>{const l=i,c=`usageExamples[${s}]`;(typeof l.title!="string"||l.title==="")&&n.push(J(`${c}.title`,"Must be a non-empty string")),(typeof l.code!="string"||l.code==="")&&n.push(J(`${c}.code`,"Must be a non-empty string"))}):n.push(J("usageExamples","Must be an array")),Array.isArray(r.compositionGraph)||n.push(J("compositionGraph","Must be an array (empty array is fine for atoms)")),typeof r.specVersion=="string"&&!/^\d+\.\d+$/.test(r.specVersion)&&n.push(J("specVersion",'Must be "MAJOR.MINOR" format, e.g. "0.1"')),{valid:n.length===0,errors:n}}function _i(t){const n=Kt(t);if(!n.valid){const r=n.errors.map(o=>` ${o.field}: ${o.message}`).join(`
|
|
550
607
|
`);throw new Error(`Invalid ComponentManifest:
|
|
551
|
-
${r}`)}}function
|
|
608
|
+
${r}`)}}function Yi(t){if(typeof t!="object"||t===null)return!1;const n=t;return typeof n.name=="string"&&typeof n.type=="string"&&typeof n.required=="boolean"&&typeof n.description=="string"}const Ki="1.0",Xi="0.1.0";exports.Alert=vr;exports.AlertManifest=br;exports.Avatar=kn;exports.AvatarManifest=Sn;exports.Badge=hn;exports.BadgeManifest=mn;exports.Breadcrumb=Cr;exports.Button=Ne;exports.ButtonManifest=rn;exports.CHIP_MANIFEST=bn;exports.COLOR_PICKER_MANIFEST=Wa;exports.COLOR_SWATCH_MANIFEST=Oa;exports.COMMAND_PALETTE_MANIFEST=Wr;exports.Card=sr;exports.CardBleed=lr;exports.CardManifest=cr;exports.Checkbox=$e;exports.CheckboxManifest=An;exports.Chip=Mt;exports.CodeBlock=xa;exports.CodeBlockManifest=wa;exports.Collapsible=Mr;exports.ColorPicker=qt;exports.ColorSwatch=le;exports.CommandPalette=$r;exports.DATA_TABLE_MANIFEST=Pr;exports.DATE_PICKER_MANIFEST=ao;exports.DATE_RANGE_PICKER_MANIFEST=uo;exports.DataTable=Rr;exports.DatePicker=no;exports.DateRangePicker=co;exports.Divider=In;exports.DividerManifest=Mn;exports.EmptyState=yr;exports.EmptyStateManifest=xr;exports.FILE_UPLOAD_MANIFEST=mo;exports.FileUpload=ho;exports.FormField=Va;exports.FormFieldManifest=Ua;exports.Icon=aa;exports.IconManifest=ra;exports.Input=te;exports.InputManifest=sn;exports.LUCENT_UI_VERSION=Xi;exports.LucentProvider=Oi;exports.LucentProviderManifest=Ui;exports.MANIFEST_SPEC_VERSION=Ki;exports.MULTI_SELECT_MANIFEST=_r;exports.Menu=Do;exports.MenuGroup=Mo;exports.MenuItem=jo;exports.MenuManifest=zo;exports.MenuSeparator=Io;exports.MultiSelect=Gr;exports.NavLink=ua;exports.PageLayout=Er;exports.Radio=Pn;exports.RadioGroup=Et;exports.RadioGroupUncontrolled=Fn;exports.RadioManifest=Nn;exports.SEGMENTED_CONTROL_MANIFEST=Ha;exports.SearchInput=Ka;exports.SearchInputManifest=Xa;exports.SegmentedControl=Oe;exports.Select=We;exports.SelectManifest=_n;exports.Skeleton=Sr;exports.SkeletonManifest=Tr;exports.Slider=ma;exports.SliderManifest=ga;exports.Spinner=Dt;exports.SpinnerManifest=jn;exports.TIMELINE_MANIFEST=xo;exports.Table=oe;exports.TableManifest=Ma;exports.Tabs=jr;exports.Tag=Xn;exports.TagManifest=Jn;exports.Text=O;exports.TextManifest=da;exports.Textarea=It;exports.TextareaManifest=un;exports.ThemeAnchorsSpec=Vi;exports.Timeline=yo;exports.ToastManifest=ei;exports.ToastProvider=Qo;exports.Toggle=Hn;exports.ToggleManifest=Vn;exports.Tooltip=ea;exports.TooltipManifest=ta;exports.assertManifest=_i;exports.brandPalette=Wt;exports.brandTokens=Gi;exports.compactDensity=nt;exports.createTheme=Ke;exports.darkTokens=Ge;exports.defaultDensity=at;exports.defaultPalette=Xe;exports.deriveDarkFromLight=Nt;exports.deriveTokens=Ye;exports.elevatedShadow=st;exports.emeraldPalette=Ot;exports.enterprisePreset=Ut;exports.flatShadow=ot;exports.getContrastText=_e;exports.indigoPalette=Je;exports.isValidPropDescriptor=Yi;exports.lightTokens=ue;exports.makeLibraryCSS=$t;exports.modernPreset=Vt;exports.oceanPalette=Ht;exports.pillShape=tt;exports.playfulPreset=Gt;exports.resolvePreset=_t;exports.rosePalette=Ze;exports.roundedShape=et;exports.sharpShape=Qe;exports.spaciousDensity=rt;exports.subtleShadow=it;exports.useLucent=Hi;exports.useToast=Eo;exports.validateManifest=Kt;
|