lucent-ui 0.37.0 → 0.38.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/{LucentProvider-F0EN_7TD.js → LucentProvider-Bm39MMvv.js} +550 -532
- package/dist/{LucentProvider-LqNc0AxD.cjs → LucentProvider-CzEDW5SL.cjs} +6 -6
- package/dist/devtools.cjs +1 -1
- package/dist/devtools.js +1 -1
- package/dist/index.cjs +87 -41
- package/dist/index.d.ts +92 -5
- package/dist/index.js +1519 -1285
- package/dist-server/src/components/atoms/Row/Row.manifest.js +10 -2
- package/dist-server/src/components/atoms/Stack/Stack.manifest.js +6 -2
- package/dist-server/src/components/molecules/Breadcrumb/Breadcrumb.manifest.js +27 -0
- package/dist-server/src/components/molecules/PageHeader/PageHeader.manifest.js +144 -0
- package/dist-server/src/manifest/examples/button.manifest.js +39 -1
- package/dist-server/src/manifest/patterns/action-bar.pattern.js +34 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("./LucentProvider-LqNc0AxD.cjs"),c=require("react"),J=require("react-dom"),wt={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 transparent background, 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 (also transparent background). 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. Icon-only buttons (leftIcon/rightIcon without children) automatically render as square with aspect-ratio: 1.',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:!1,description:"Button label or content. Omit for icon-only buttons (provide leftIcon or rightIcon instead)."},{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>'},{title:"Icon-only (square)",code:'<Button variant="outline" size="2xs" leftIcon={<CloseIcon />} aria-label="Close" />',description:"Omitting children auto-sizes the button as a square via aspect-ratio: 1."}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["aria-disabled","aria-busy"],keyboardInteractions:["Enter — activates the button","Space — activates the button"]}},kt={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"]}},St={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},Tt={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Ct={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},nt=c.forwardRef(({label:t,helperText:r,errorText:n,autoResize:o=!1,maxLength:a,showCount:i=!1,size:s="md",id:l,value:d,onChange:p,disabled:m,style:f,...w},y)=>{const g=c.useRef(null),h=y??g,u=l??`lucent-textarea-${Math.random().toString(36).slice(2,7)}`,b=!!n,x=!!m,k=typeof d=="string"?d.length:0;c.useEffect(()=>{if(!o)return;const C=h.current;C&&(C.style.height="auto",C.style.height=`${C.scrollHeight}px`)},[d,o,h]);const S=x?"transparent":b?"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:u,style:{fontSize:Tt[s],fontWeight:"var(--lucent-font-weight-medium)",color:x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:t}),e.jsx("textarea",{ref:h,id:u,maxLength:a,value:d,onChange:p,disabled:m,"aria-invalid":b,"aria-describedby":b?`${u}-error`:r?`${u}-helper`:void 0,style:{width:"100%",minHeight:"100px",padding:Ct[s],fontSize:St[s],fontFamily:"var(--lucent-font-family-base)",color:x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:x?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"var(--lucent-surface)",border:`1px solid ${S}`,borderRadius:"var(--lucent-radius-lg)",outline:"none",resize:o?"none":"vertical",boxSizing:"border-box",lineHeight:"var(--lucent-line-height-base)",cursor:x?"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(", "),...f},onMouseEnter:C=>{var v;!x&&C.currentTarget!==document.activeElement&&(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-strong)"),(v=w.onMouseEnter)==null||v.call(w,C)},onMouseLeave:C=>{var v;!x&&C.currentTarget!==document.activeElement&&(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-default)"),(v=w.onMouseLeave)==null||v.call(w,C)},onFocus:C=>{var v;x||(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-accent-border)",C.currentTarget.style.boxShadow=`0 0 0 3px ${b?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`,(v=w.onFocus)==null||v.call(w,C))},onBlur:C=>{var v;x||(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-default)",C.currentTarget.style.boxShadow="none",(v=w.onBlur)==null||v.call(w,C))},...w}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[b&&e.jsx("span",{id:`${u}-error`,role:"alert",style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:n}),!b&&r&&e.jsx("span",{id:`${u}-helper`,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:r})]}),(i||a)&&e.jsxs("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:a&&k>=a?"var(--lucent-danger-text)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-mono)",flexShrink:0,marginLeft:"var(--lucent-space-2)"},children:[k,a?`/${a}`:""]})]})]})});nt.displayName="Textarea";const It={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"]}},jt={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."}},Mt={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-accent-fg)",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)"}},zt={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)"}},Et=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),I=require("./LucentProvider-CzEDW5SL.cjs"),c=require("react"),J=require("react-dom"),It={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 transparent background, 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 (also transparent background). 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. Icon-only buttons (leftIcon/rightIcon without children) automatically render as square with aspect-ratio: 1.',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:!1,description:"Button label or content. Omit for icon-only buttons (provide leftIcon or rightIcon instead)."},{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. Ignored when `href` is set.",enumValues:["button","submit","reset"]},{name:"href",type:"string",required:!1,description:'When set, renders the Button as an `<a href={href}>` instead of a native `<button>`. Preserves native anchor affordances (middle-click, cmd/ctrl-click, right-click "copy link address", open in new tab) that an onClick handler cannot. Use for `mailto:` / `tel:` quick actions, external links styled as buttons, or in-app routes where users legitimately expect anchor semantics. When combined with `disabled`, the anchor renders with `aria-disabled="true"` and its `href` is stripped so navigation is neutralised.'},{name:"target",type:"string",required:!1,description:'Forwarded to the rendered `<a>` when `href` is set (e.g. `"_blank"` to open in a new tab). Ignored when rendering as a button.'},{name:"rel",type:"string",required:!1,description:'Forwarded to the rendered `<a>` when `href` is set (e.g. `"noopener noreferrer"` for external links). Ignored when rendering as a button.'}],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>'},{title:"Icon-only (square)",code:'<Button variant="outline" size="2xs" leftIcon={<CloseIcon />} aria-label="Close" />',description:"Omitting children auto-sizes the button as a square via aspect-ratio: 1."},{title:"Mailto quick action",code:'<Button variant="ghost" size="sm" href="mailto:foo@example.com" leftIcon={<MailIcon />} aria-label="Email" />',description:'Renders as <a href="mailto:..."> so middle-click, cmd/ctrl-click, and right-click "copy link" all work.'},{title:"External link as button",code:'<Button variant="primary" href="https://example.com" target="_blank" rel="noopener noreferrer" rightIcon={<ExternalIcon />}>View docs</Button>',description:"Use href + target + rel for external links that should look like a primary call-to-action."},{title:"Disabled link",code:'<Button variant="outline" href="/settings" disabled>Settings</Button>',description:'When disabled, the anchor is rendered with aria-disabled="true" and its href is stripped.'}],compositionGraph:[],accessibility:{role:"button",ariaAttributes:["aria-disabled","aria-busy"],keyboardInteractions:["Enter — activates the button","Space — activates the button"]}},jt={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"]}},Mt={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},zt={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Et={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},ot=c.forwardRef(({label:t,helperText:r,errorText:n,autoResize:o=!1,maxLength:a,showCount:i=!1,size:l="md",id:s,value:d,onChange:p,disabled:h,style:f,...w},y)=>{const g=c.useRef(null),m=y??g,u=s??`lucent-textarea-${Math.random().toString(36).slice(2,7)}`,b=!!n,x=!!h,k=typeof d=="string"?d.length:0;c.useEffect(()=>{if(!o)return;const C=m.current;C&&(C.style.height="auto",C.style.height=`${C.scrollHeight}px`)},[d,o,m]);const S=x?"transparent":b?"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:u,style:{fontSize:zt[l],fontWeight:"var(--lucent-font-weight-medium)",color:x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:t}),e.jsx("textarea",{ref:m,id:u,maxLength:a,value:d,onChange:p,disabled:h,"aria-invalid":b,"aria-describedby":b?`${u}-error`:r?`${u}-helper`:void 0,style:{width:"100%",minHeight:"100px",padding:Et[l],fontSize:Mt[l],fontFamily:"var(--lucent-font-family-base)",color:x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",background:x?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"var(--lucent-surface)",border:`1px solid ${S}`,borderRadius:"var(--lucent-radius-lg)",outline:"none",resize:o?"none":"vertical",boxSizing:"border-box",lineHeight:"var(--lucent-line-height-base)",cursor:x?"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(", "),...f},onMouseEnter:C=>{var v;!x&&C.currentTarget!==document.activeElement&&(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-strong)"),(v=w.onMouseEnter)==null||v.call(w,C)},onMouseLeave:C=>{var v;!x&&C.currentTarget!==document.activeElement&&(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-default)"),(v=w.onMouseLeave)==null||v.call(w,C)},onFocus:C=>{var v;x||(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-accent-border)",C.currentTarget.style.boxShadow=`0 0 0 3px ${b?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`,(v=w.onFocus)==null||v.call(w,C))},onBlur:C=>{var v;x||(C.currentTarget.style.borderColor=b?"var(--lucent-danger-default)":"var(--lucent-border-default)",C.currentTarget.style.boxShadow="none",(v=w.onBlur)==null||v.call(w,C))},...w}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[b&&e.jsx("span",{id:`${u}-error`,role:"alert",style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:n}),!b&&r&&e.jsx("span",{id:`${u}-helper`,style:{fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:r})]}),(i||a)&&e.jsxs("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:a&&k>=a?"var(--lucent-danger-text)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-mono)",flexShrink:0,marginLeft:"var(--lucent-space-2)"},children:[k,a?`/${a}`:""]})]})]})});ot.displayName="Textarea";const At={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"]}},qt={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."}},Dt={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-accent-fg)",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)"}},Rt={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)"}},Bt=`
|
|
2
2
|
@keyframes lucent-chip-pulse {
|
|
3
3
|
0% { transform: scale(1); opacity: 0.6; }
|
|
4
4
|
100% { transform: scale(2.8); opacity: 0; }
|
|
5
|
-
}`;function se({children:t,variant:r="neutral",size:n="md",onDismiss:o,onClick:a,leftIcon:i,swatch:s,dot:l=!1,pulse:d=!1,borderless:p=!1,ghost:m=!1,disabled:f=!1,style:w}){const y=Mt[r],g=zt[n],[h,u]=c.useState(!1),b=l&&d,x=l&&!t,k=!f&&(o||a),S=`color-mix(in srgb, ${y.color} 8%, transparent)`,C=g.dotSize*3,v={display:"inline-flex",alignItems:"center",justifyContent:x?"center":void 0,gap:x?void 0:g.gap,height:x?C:g.height,width:x?C:void 0,padding:x?0:o?g.paddingDismiss:g.padding,fontSize:g.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:x?"var(--lucent-radius-full)":"var(--lucent-radius-lg)",background:m?h&&k?S:"transparent":h&&k?y.hoverBg:y.bg,color:y.color,border:m||p?"1px solid transparent":`1px solid ${h&&k?y.hoverBorder:y.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:f?.5:1,transform:h&&k?"translateY(-1px)":"none",boxShadow:h&&k&&!m?`0 2px 4px ${y.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:k?"pointer":"default",...a?{outline:"none"}:{},...w},z=e.jsxs(e.Fragment,{children:[b&&e.jsx("style",{children:Et}),s&&e.jsx("span",{style:{width:g.dotSize+2,height:g.dotSize+2,borderRadius:"50%",background:s,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),l&&!s&&e.jsxs("span",{style:{position:"relative",width:g.dotSize,height:g.dotSize,flexShrink:0},children:[e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"currentColor"}}),b&&e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"currentColor",animation:"lucent-chip-pulse 1.5s ease-out infinite"}})]}),i&&!s&&!l&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:g.iconSize,height:g.iconSize,flexShrink:0},children:i}),t,o&&e.jsx("button",{type:"button",onClick:f?void 0:E=>{E.stopPropagation(),o()},disabled:f,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:g.iconSize+2,height:g.iconSize+2,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:f?"not-allowed":"pointer",flexShrink:0,lineHeight:1},children:e.jsx("svg",{width:g.iconSize-2,height:g.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"})})})]}),T={onMouseEnter:()=>{f||u(!0)},onMouseLeave:()=>u(!1)};return a?e.jsx("button",{type:"button",onClick:f?void 0:a,disabled:f,style:v,...T,children:z}):e.jsx("span",{style:v,...T,children:z})}const At={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 `dot` + `pulse` to show in-progress or live states (deploying, syncing, live incident). Use `ghost` + `dot` for subtle inline status that blends into surrounding text or table rows. Omit `children` with `dot` for a minimal dot-only indicator — great for table cells or avatar badges. 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:!1,description:"Chip label content. When omitted with dot=true, renders as a compact dot-only indicator."},{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. Omit children for a compact dot-only indicator."},{name:"pulse",type:"boolean",required:!1,default:"false",description:"Adds a pulsing ring animation to the status dot. Only applies when dot=true. Use for running, deploying, or live states."},{name:"borderless",type:"boolean",required:!1,default:"false",description:"Removes the border for a filled-only look."},{name:"ghost",type:"boolean",required:!1,default:"false",description:"Transparent background with text color only. Pairs well with dot for subtle inline statuses in tables or lists."},{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:"Status dot",code:'<Chip variant="success" dot>Online</Chip>'},{title:"Pulsing status (in-progress)",code:'<Chip variant="warning" dot pulse>Deploying</Chip>'},{title:"Ghost status (inline/table)",code:'<Chip variant="success" ghost dot>Active</Chip>'},{title:"Ghost pulsing",code:'<Chip variant="danger" ghost dot pulse>Live incident</Chip>'},{title:"Dot only (minimal)",code:'<Chip variant="success" dot />'},{title:"Dot only pulsing",code:'<Chip variant="danger" dot pulse />'},{title:"Dismissible filter",code:"<Chip onDismiss={() => removeFilter('react')}>React</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"]}},qt={xs:24,sm:32,md:40,lg:56,xl:80},Dt={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 Rt(t,r){var o,a,i;if(r)return r.slice(0,2).toUpperCase();const n=t.trim().split(/\s+/);return n.length===1?(((o=n[0])==null?void 0:o[0])??"").toUpperCase():((((a=n[0])==null?void 0:a[0])??"")+(((i=n[n.length-1])==null?void 0:i[0])??"")).toUpperCase()}function Bt({src:t,alt:r,size:n="md",initials:o,style:a,...i}){const s=qt[n],l=Rt(r,o),d={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:r,width:s,height:s,style:{...d,objectFit:"cover"},...i}):e.jsx("span",{role:"img","aria-label":r,style:{...d,background:"var(--lucent-accent-default)",color:"var(--lucent-accent-fg)",fontSize:Dt[n],fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)"},children:l})}const Pt={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>.'}},Lt={xs:12,sm:16,md:24,lg:36},Ft={xs:2.5,sm:2.5,md:2,lg:2};function rt({size:t="md",label:r="Loading…",color:n}){const o=Lt[t],a=Ft[t];return e.jsxs("span",{role:"status","aria-label":r,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:n??"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:r})]})}const Nt={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 $t({orientation:t="horizontal",label:r,spacing:n="0",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 ${n}`,flexShrink:0,...o}}):r?e.jsxs("div",{role:"separator","aria-label":r,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",margin:`${n} 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:r}),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:`${n} 0`,width:"100%",...o}})}const Wt={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:"0",description:'Margin on the axis perpendicular to the line. Defaults to 0 so parent gap-based layouts (Stack, Row) control spacing. Pass an explicit value like "var(--lucent-space-4)" for standalone use outside flex/grid containers.'}],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"]}},Ot={sm:14,md:16,lg:20},Vt={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)"},Ht=`
|
|
5
|
+
}`;function se({children:t,variant:r="neutral",size:n="md",onDismiss:o,onClick:a,leftIcon:i,swatch:l,dot:s=!1,pulse:d=!1,borderless:p=!1,ghost:h=!1,disabled:f=!1,style:w}){const y=Dt[r],g=Rt[n],[m,u]=c.useState(!1),b=s&&d,x=s&&!t,k=!f&&(o||a),S=`color-mix(in srgb, ${y.color} 8%, transparent)`,C=g.dotSize*3,v={display:"inline-flex",alignItems:"center",justifyContent:x?"center":void 0,gap:x?void 0:g.gap,height:x?C:g.height,width:x?C:void 0,padding:x?0:o?g.paddingDismiss:g.padding,fontSize:g.fontSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,borderRadius:x?"var(--lucent-radius-full)":"var(--lucent-radius-lg)",background:h?m&&k?S:"transparent":m&&k?y.hoverBg:y.bg,color:y.color,border:h||p?"1px solid transparent":`1px solid ${m&&k?y.hoverBorder:y.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:f?.5:1,transform:m&&k?"translateY(-1px)":"none",boxShadow:m&&k&&!h?`0 2px 4px ${y.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:k?"pointer":"default",...a?{outline:"none"}:{},...w},z=e.jsxs(e.Fragment,{children:[b&&e.jsx("style",{children:Bt}),l&&e.jsx("span",{style:{width:g.dotSize+2,height:g.dotSize+2,borderRadius:"50%",background:l,border:"1px solid rgba(0,0,0,0.1)",flexShrink:0}}),s&&!l&&e.jsxs("span",{style:{position:"relative",width:g.dotSize,height:g.dotSize,flexShrink:0},children:[e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"currentColor"}}),b&&e.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",background:"currentColor",animation:"lucent-chip-pulse 1.5s ease-out infinite"}})]}),i&&!l&&!s&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:g.iconSize,height:g.iconSize,flexShrink:0},children:i}),t,o&&e.jsx("button",{type:"button",onClick:f?void 0:E=>{E.stopPropagation(),o()},disabled:f,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:g.iconSize+2,height:g.iconSize+2,padding:0,border:"none",borderRadius:"var(--lucent-radius-lg)",background:"transparent",color:"inherit",cursor:f?"not-allowed":"pointer",flexShrink:0,lineHeight:1},children:e.jsx("svg",{width:g.iconSize-2,height:g.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"})})})]}),T={onMouseEnter:()=>{f||u(!0)},onMouseLeave:()=>u(!1)};return a?e.jsx("button",{type:"button",onClick:f?void 0:a,disabled:f,style:v,...T,children:z}):e.jsx("span",{style:v,...T,children:z})}const Pt={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 `dot` + `pulse` to show in-progress or live states (deploying, syncing, live incident). Use `ghost` + `dot` for subtle inline status that blends into surrounding text or table rows. Omit `children` with `dot` for a minimal dot-only indicator — great for table cells or avatar badges. 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:!1,description:"Chip label content. When omitted with dot=true, renders as a compact dot-only indicator."},{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. Omit children for a compact dot-only indicator."},{name:"pulse",type:"boolean",required:!1,default:"false",description:"Adds a pulsing ring animation to the status dot. Only applies when dot=true. Use for running, deploying, or live states."},{name:"borderless",type:"boolean",required:!1,default:"false",description:"Removes the border for a filled-only look."},{name:"ghost",type:"boolean",required:!1,default:"false",description:"Transparent background with text color only. Pairs well with dot for subtle inline statuses in tables or lists."},{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:"Status dot",code:'<Chip variant="success" dot>Online</Chip>'},{title:"Pulsing status (in-progress)",code:'<Chip variant="warning" dot pulse>Deploying</Chip>'},{title:"Ghost status (inline/table)",code:'<Chip variant="success" ghost dot>Active</Chip>'},{title:"Ghost pulsing",code:'<Chip variant="danger" ghost dot pulse>Live incident</Chip>'},{title:"Dot only (minimal)",code:'<Chip variant="success" dot />'},{title:"Dot only pulsing",code:'<Chip variant="danger" dot pulse />'},{title:"Dismissible filter",code:"<Chip onDismiss={() => removeFilter('react')}>React</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"]}},Lt={xs:24,sm:32,md:40,lg:56,xl:80},Ft={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 Nt(t,r){var o,a,i;if(r)return r.slice(0,2).toUpperCase();const n=t.trim().split(/\s+/);return n.length===1?(((o=n[0])==null?void 0:o[0])??"").toUpperCase():((((a=n[0])==null?void 0:a[0])??"")+(((i=n[n.length-1])==null?void 0:i[0])??"")).toUpperCase()}function $t({src:t,alt:r,size:n="md",initials:o,style:a,...i}){const l=Lt[n],s=Nt(r,o),d={width:l,height:l,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:r,width:l,height:l,style:{...d,objectFit:"cover"},...i}):e.jsx("span",{role:"img","aria-label":r,style:{...d,background:"var(--lucent-accent-default)",color:"var(--lucent-accent-fg)",fontSize:Ft[n],fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)"},children:s})}const Wt={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>.'}},Ot={xs:12,sm:16,md:24,lg:36},Vt={xs:2.5,sm:2.5,md:2,lg:2};function it({size:t="md",label:r="Loading…",color:n}){const o=Ot[t],a=Vt[t];return e.jsxs("span",{role:"status","aria-label":r,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:n??"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:r})]})}const Ht={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 st({orientation:t="horizontal",label:r,spacing:n="0",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 ${n}`,flexShrink:0,...o}}):r?e.jsxs("div",{role:"separator","aria-label":r,style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",margin:`${n} 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:r}),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:`${n} 0`,width:"100%",...o}})}const Gt={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:"0",description:'Margin on the axis perpendicular to the line. Defaults to 0 so parent gap-based layouts (Stack, Row) control spacing. Pass an explicit value like "var(--lucent-space-4)" for standalone use outside flex/grid containers.'}],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"]}},Ut={sm:14,md:16,lg:20},_t={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)"},Yt=`
|
|
6
6
|
@keyframes lucent-cb-pop {
|
|
7
7
|
0% { transform: scale(1); }
|
|
8
8
|
35% { transform: scale(0.82); }
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
60% { transform: scale(1.15) rotate(2deg); }
|
|
15
15
|
100% { opacity: 1; transform: scale(1) rotate(0deg); }
|
|
16
16
|
}
|
|
17
|
-
`,be=c.forwardRef(({label:t,size:r="md",indeterminate:n=!1,contained:o=!1,helperText:a,checked:i,defaultChecked:
|
|
17
|
+
`,be=c.forwardRef(({label:t,size:r="md",indeterminate:n=!1,contained:o=!1,helperText:a,checked:i,defaultChecked:l,disabled:s,id:d,onChange:p,style:h,...f},w)=>{const y=c.useRef(null),g=d??`lucent-checkbox-${Math.random().toString(36).slice(2,7)}`,m=Ut[r],u=i!==void 0,[b,x]=c.useState(l??!1),k=u?!!i:b,S=c.useRef(k),[C,v]=c.useState(0);c.useEffect(()=>{!s&&S.current!==k&&(S.current=k,v(j=>j+1))},[k,s]);const z=c.useCallback(j=>{y.current=j,typeof w=="function"?w(j):w&&(w.current=j)},[w]);c.useEffect(()=>{y.current&&(y.current.indeterminate=n)},[n]);const T=j=>{u||x(j.target.checked),p==null||p(j)},E=s?"var(--lucent-text-disabled)":"var(--lucent-accent-fg)",F={width:m,height:m,borderRadius:"4px",border:`1.5px solid ${s?"transparent":k||n?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:s?"var(--lucent-surface-secondary)":k||n?"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:C>0?"lucent-cb-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0},R=e.jsxs("label",{style:{display:"inline-flex",alignItems:a?"flex-start":"center",gap:"var(--lucent-space-2)",cursor:s?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:r==="sm"?"var(--lucent-font-size-sm)":"var(--lucent-font-size-md)",color:s?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",userSelect:"none",...o?{}:h},children:[e.jsx("input",{ref:z,type:"checkbox",id:g,checked:u?i:b,disabled:s,onChange:T,style:{position:"absolute",opacity:0,width:0,height:0,margin:0,pointerEvents:"none"},...f}),e.jsxs("span",{"aria-hidden":!0,style:F,children:[k&&!n&&e.jsx("svg",{width:m-4,height:m-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:E,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})}),n&&e.jsx("svg",{width:m-4,height:m-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:E,strokeWidth:1.5,strokeLinecap:"round"})})]},C),(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:s?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",marginTop:"2px"},children:a})]})]});return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Yt}),o?e.jsx("div",{style:{border:"1px solid var(--lucent-border-strong)",borderRadius:"var(--lucent-radius-lg)",...a?{}:{minHeight:_t[r]},padding:a?"var(--lucent-space-3)":"0 var(--lucent-space-3)",display:"flex",alignItems:a?"flex-start":"center",background:k&&!s?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"transparent",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:s?"not-allowed":"pointer",...h},onClick:j=>{var P;s||j.target===j.currentTarget&&((P=y.current)==null||P.click())},children:R}):R]})});be.displayName="Checkbox";const Kt={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"]}},Xt=`
|
|
18
18
|
@keyframes lucent-radio-pop {
|
|
19
19
|
0% { transform: scale(1); }
|
|
20
20
|
35% { transform: scale(0.82); }
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
60% { transform: scale(1.2); }
|
|
27
27
|
100% { opacity: 1; transform: scale(1); }
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,lt=c.createContext(null);function ct({name:t,value:r,onChange:n,disabled:o,orientation:a="vertical",label:i,children:l}){return e.jsx(lt.Provider,{value:{name:t,value:r,onChange:n,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:l})})}const Jt={sm:14,md:16,lg:20},Zt={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)"},Qt={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"};function en({value:t,label:r,size:n="md",contained:o=!1,helperText:a,disabled:i,id:l,onChange:s,checked:d,style:p,...h}){const f=c.useContext(lt),w=l??`lucent-radio-${Math.random().toString(36).slice(2,7)}`,y=Jt[n],g=i??(f==null?void 0:f.disabled)??!1,m=f?f.value===t:!!d,u=c.useRef(m),[b,x]=c.useState(0);c.useEffect(()=>{!g&&u.current!==m&&(u.current=m,x(z=>z+1))},[m,g]);const k=z=>{f==null||f.onChange(t),s==null||s(z)},S={width:y/2,height:y/2,borderRadius:"50%",background:g?"var(--lucent-text-disabled)":"var(--lucent-accent-fg)",animation:m?"lucent-radio-dot 200ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0,opacity:m?1:0},C={width:y,height:y,borderRadius:"50%",border:`1.5px solid ${g?"transparent":m?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:g?"var(--lucent-surface-secondary)":m?"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:b>0?"lucent-radio-pop 220ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards":void 0},v=e.jsxs("label",{style:{display:"inline-flex",alignItems:a?"flex-start":"center",gap:"var(--lucent-space-2)",cursor:g?"not-allowed":"pointer",fontFamily:"var(--lucent-font-family-base)",fontSize:Qt[n],color:g?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",userSelect:"none",...o?{}:p},children:[e.jsx("input",{type:"radio",id:w,value:t,name:(f==null?void 0:f.name)??h.name,checked:m,disabled:g,onChange:k,style:{position:"absolute",opacity:0,width:0,height:0,margin:0,pointerEvents:"none"},...h}),e.jsx("span",{"aria-hidden":!0,style:C,children:e.jsx("span",{style:S})},b),r||a?e.jsxs("span",{style:{display:"flex",flexDirection:"column"},children:[r&&e.jsx("span",{style:{fontWeight:a?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",lineHeight:a?1.3:1},children:r}),a&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-xs)",color:g?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",marginTop:"2px"},children:a})]}):null]});return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Xt}),o?e.jsx("div",{style:{border:"1px solid var(--lucent-border-strong)",borderRadius:"var(--lucent-radius-lg)",...a?{padding:"var(--lucent-space-3)"}:{minHeight:Zt[n],padding:"0 var(--lucent-space-3)",display:"flex",alignItems:"center"},background:m&&!g?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"transparent",transition:"border-color var(--lucent-duration-fast) var(--lucent-easing-default), background var(--lucent-duration-fast) var(--lucent-easing-default)",cursor:g?"not-allowed":"pointer",...p},onClick:z=>{if(!g&&z.target===z.currentTarget){const T=z.currentTarget.querySelector("input");T==null||T.click()}},children:v}):v]})}function tn({defaultValue:t="",onChange:r,...n}){const[o,a]=c.useState(t);return e.jsx(ct,{...n,value:o,onChange:i=>{a(i),r==null||r(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:`
|
|
30
30
|
<RadioGroup name="plan" value={plan} onChange={setPlan}>
|
|
31
31
|
<Radio value="free" label="Free" />
|
|
32
32
|
<Radio value="pro" label="Pro" />
|
|
@@ -44,18 +44,18 @@
|
|
|
44
44
|
<RadioGroup name="tier" value="basic" onChange={() => {}} disabled>
|
|
45
45
|
<Radio value="basic" label="Basic" />
|
|
46
46
|
<Radio value="advanced" label="Advanced" />
|
|
47
|
-
</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"]}},
|
|
47
|
+
</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"]}},rn={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" />
|
|
48
48
|
<Toggle size="md" label="Default" />
|
|
49
|
-
<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"]}},
|
|
49
|
+
<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"]}},an={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:`
|
|
50
50
|
<Select
|
|
51
51
|
label="Country"
|
|
52
52
|
placeholder="Choose a country"
|
|
53
53
|
options={countries}
|
|
54
54
|
value={country}
|
|
55
55
|
onChange={e => setCountry(e.target.value)}
|
|
56
|
-
/>`.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"]}},tn={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-default)",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)"}},nn={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 rn({children:t,variant:r="neutral",size:n="md",onDismiss:o,disabled:a}){const i=tn[r],s=nn[n],[l,d]=c.useState(!1),p=!a&&o;return e.jsxs("span",{onMouseEnter:()=>{a||d(!0)},onMouseLeave:()=>d(!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&&p?"translateY(-1px)":"none",boxShadow:l&&p?`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:p?"pointer":"default"},children:[t,o&&e.jsx("button",{type:"button",onClick:a?void 0:m=>{m.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:m=>{a||(m.currentTarget.style.background=i.dismissHover+"33")},onMouseLeave:m=>{m.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 an={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,on={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}},sn={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 ln({content:t,children:r,placement:n="top",delay:o=300}){const[a,i]=c.useState(!1),s=c.useRef(null),l=()=>{s.current=setTimeout(()=>i(!0),o)},d=()=>{s.current&&clearTimeout(s.current),i(!1)};return t?e.jsxs("span",{style:{position:"relative",display:"inline-flex"},onMouseEnter:l,onMouseLeave:d,onFocus:l,onBlur:d,children:[r,a&&e.jsxs("span",{role:"tooltip",style:{position:"absolute",...on[n],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",...sn[n]}})]})]}):e.jsx(e.Fragment,{children:r})}const cn={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".'}},dn={xs:12,sm:14,md:16,lg:20,xl:24};function un({children:t,size:r="md",label:n,color:o,style:a}){const i=dn[r];return e.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i,height:i,flexShrink:0,color:o??"currentColor",...a},children:t})}const pn={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.'}},fn={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, so any property you set here wins. This is the official escape hatch for one-off styling outside the token system — e.g. a custom color via style={{ color: "var(--my-green)" }}. See docs/style-escape-hatch.md.'}],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>'},{title:"Custom color via style escape hatch",code:"<Text style={{ color: 'var(--chart-series-a)' }}>Revenue</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 hn({children:t,href:r,isActive:n=!1,icon:o,disabled:a=!1,inverse:i=!1,onClick:s,as:l,style:d}){const p=l??"a";return e.jsxs(p,{href:a?void 0:r,onClick:a?void 0:s,"aria-current":n?"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":n?i?"var(--lucent-surface)":"var(--lucent-accent-default)":"transparent",color:a?"var(--lucent-text-disabled)":n?i?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",border:n&&i?"1px solid var(--lucent-border-default)":"1px solid transparent",borderRight:n&&i?"3px solid var(--lucent-accent-default)":"3px solid transparent",boxShadow:n&&i?"var(--lucent-shadow-md)":"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:n?"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",...d},onMouseEnter:m=>{!a&&!n&&(m.currentTarget.style.background="var(--lucent-surface-secondary)")},onMouseLeave:m=>{!a&&!n&&(m.currentTarget.style.background="transparent")},children:[o!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,color:"inherit"},children:o}),t]})}const mn={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" />
|
|
56
|
+
/>`.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"]}},on={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-default)",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)"}},sn={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 ln({children:t,variant:r="neutral",size:n="md",onDismiss:o,disabled:a}){const i=on[r],l=sn[n],[s,d]=c.useState(!1),p=!a&&o;return e.jsxs("span",{onMouseEnter:()=>{a||d(!0)},onMouseLeave:()=>d(!1),style:{display:"inline-flex",alignItems:"center",gap:l.gap,height:l.height,padding:o?`0 var(--lucent-space-2) 0 ${l.padding.split(" ")[1]}`:l.padding,fontSize:l.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 ${s&&!a?i.dismissHover:i.border}`,whiteSpace:"nowrap",boxSizing:"border-box",opacity:a?.5:1,transform:s&&p?"translateY(-1px)":"none",boxShadow:s&&p?`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:p?"pointer":"default"},children:[t,o&&e.jsx("button",{type:"button",onClick:a?void 0:h=>{h.stopPropagation(),o==null||o()},disabled:a,"aria-label":"Dismiss",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:l.iconSize+4,height:l.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:h=>{a||(h.currentTarget.style.background=i.dismissHover+"33")},onMouseLeave:h=>{h.currentTarget.style.background="transparent"},children:e.jsx("svg",{width:l.iconSize,height:l.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 cn={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,dn={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}},un={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 pn({content:t,children:r,placement:n="top",delay:o=300}){const[a,i]=c.useState(!1),l=c.useRef(null),s=()=>{l.current=setTimeout(()=>i(!0),o)},d=()=>{l.current&&clearTimeout(l.current),i(!1)};return t?e.jsxs("span",{style:{position:"relative",display:"inline-flex"},onMouseEnter:s,onMouseLeave:d,onFocus:s,onBlur:d,children:[r,a&&e.jsxs("span",{role:"tooltip",style:{position:"absolute",...dn[n],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",...un[n]}})]})]}):e.jsx(e.Fragment,{children:r})}const hn={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".'}},fn={xs:12,sm:14,md:16,lg:20,xl:24};function mn({children:t,size:r="md",label:n,color:o,style:a}){const i=fn[r];return e.jsx("span",{role:n?"img":void 0,"aria-label":n,"aria-hidden":n?void 0:!0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:i,height:i,flexShrink:0,color:o??"currentColor",...a},children:t})}const gn={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.'}},vn={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, so any property you set here wins. This is the official escape hatch for one-off styling outside the token system — e.g. a custom color via style={{ color: "var(--my-green)" }}. See docs/style-escape-hatch.md.'}],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>'},{title:"Custom color via style escape hatch",code:"<Text style={{ color: 'var(--chart-series-a)' }}>Revenue</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 bn({children:t,href:r,isActive:n=!1,icon:o,disabled:a=!1,inverse:i=!1,onClick:l,as:s,style:d}){const p=s??"a";return e.jsxs(p,{href:a?void 0:r,onClick:a?void 0:l,"aria-current":n?"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":n?i?"var(--lucent-surface)":"var(--lucent-accent-default)":"transparent",color:a?"var(--lucent-text-disabled)":n?i?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",border:n&&i?"1px solid var(--lucent-border-default)":"1px solid transparent",borderRight:n&&i?"3px solid var(--lucent-accent-default)":"3px solid transparent",boxShadow:n&&i?"var(--lucent-shadow-md)":"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",fontWeight:n?"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",...d},onMouseEnter:h=>{!a&&!n&&(h.currentTarget.style.background="var(--lucent-surface-secondary)")},onMouseLeave:h=>{!a&&!n&&(h.currentTarget.style.background="transparent")},children:[o!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,color:"inherit"},children:o}),t]})}const yn={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" />
|
|
57
57
|
<Slider size="md" label="Medium" />
|
|
58
|
-
<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"]}},
|
|
58
|
+
<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"]}},xn=2e3;function wn(){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 kn(){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 Sn({code:t,language:r,tabs:n,variant:o="code",wrap:a,minimal:i,helperText:l,showCopyButton:s=!0,style:d}){var k,S;const p=!!(n!=null&&n.length),[h,f]=c.useState(0),[w,y]=c.useState(!1),g=p?((k=n[h])==null?void 0:k.code)??"":t??"",m=p?(S=n[h])==null?void 0:S.language:r,u=async()=>{try{await navigator.clipboard.writeText(g),y(!0),setTimeout(()=>y(!1),xn)}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:w?"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)"},x=()=>e.jsxs("button",{onClick:u,"aria-label":w?"Copied!":"Copy code",style:b,onMouseEnter:C=>{w||(C.currentTarget.style.background="var(--lucent-surface-secondary)",C.currentTarget.style.color="var(--lucent-text-primary)")},onMouseLeave:C=>{w||(C.currentTarget.style.background="transparent",C.currentTarget.style.color="var(--lucent-text-secondary)")},children:[w?e.jsx(kn,{}):e.jsx(wn,{}),w?"Copied!":"Copy"]});return e.jsxs("div",{style:{borderRadius:"var(--lucent-radius-lg)",border:"1px solid var(--lucent-border-default)",overflow:"hidden",...d},children:[p&&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:n.map((C,v)=>{const z=v===h;return e.jsxs("button",{onClick:()=>{f(v),y(!1)},style:{display:"inline-flex",alignItems:"center",gap:"var(--lucent-space-1)",padding:"var(--lucent-space-2) var(--lucent-space-3)",border:"none",borderBottom:z?"2px solid var(--lucent-accent-default)":"2px solid transparent",marginBottom:-1,background:"transparent",color:z?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-sm)",fontWeight:z?"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:T=>{z||(T.currentTarget.style.color="var(--lucent-text-primary)")},onMouseLeave:T=>{z||(T.currentTarget.style.color="var(--lucent-text-secondary)")},children:[C.icon!==void 0&&e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:C.icon}),C.label]},C.label)})}),!i&&!p&&(!!m||s)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:m?"space-between":"flex-end",padding:"0 var(--lucent-space-3)",height:36,background:"var(--lucent-surface)",borderBottom:"1px solid var(--lucent-border-default)"},children:[m&&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:m}),s&&e.jsx(x,{})]}),l&&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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",borderBottom:"1px solid var(--lucent-border-default)"},children:l}),o==="code"?e.jsxs("div",{style:{position:"relative"},children:[e.jsx("pre",{style:{margin:0,padding:"var(--lucent-space-4)",paddingRight:(p||i)&&s?"var(--lucent-space-16)":"var(--lucent-space-4)",background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",overflowX:a?"hidden":"auto",lineHeight:1.65,...a&&{whiteSpace:"pre-wrap",wordBreak:"break-word"}},children:e.jsx("code",{style:{fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-primary)"},children:g})}),(p||i)&&s&&e.jsx("div",{style:{position:"absolute",top:i?0:"var(--lucent-space-2)",bottom:i?0:void 0,right:"var(--lucent-space-3)",display:"flex",alignItems:"center"},children:e.jsx(x,{})})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-3) var(--lucent-space-4)",background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)"},children:[e.jsx("span",{style:{flex:1,overflow:"hidden",...a?{whiteSpace:"pre-wrap",wordBreak:"break-word"}:{whiteSpace:"nowrap",textOverflow:"ellipsis"},fontFamily:"var(--lucent-font-family-mono)",fontSize:"var(--lucent-font-size-sm)",color:"var(--lucent-text-primary)"},children:g}),s&&e.jsx(x,{})]})]})}const Tn={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:"minimal",type:"boolean",required:!1,default:"false",description:"Hides the header bar and shows only a corner copy button overlay."},{name:"wrap",type:"boolean",required:!1,default:"false",description:"When true, wraps long lines instead of scrolling horizontally."},{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={[
|
|
59
59
|
{ label: 'pnpm', code: 'pnpm add lucent-ui', language: 'bash' },
|
|
60
60
|
{ label: 'npm', code: 'npm install lucent-ui', language: 'bash' },
|
|
61
61
|
]} />`},{title:"AI prompt",code:`<CodeBlock
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
{ label: 'Claude', icon: '♦', code: '"Add a Button with variant=\\"primary\\"."' },
|
|
66
66
|
{ label: 'Cursor', icon: '↖', code: '@lucent-ui Add a primary Button.' },
|
|
67
67
|
]}
|
|
68
|
-
/>`}],compositionGraph:[],accessibility:{role:"region",ariaAttributes:["aria-label (copy button)"],keyboardInteractions:["Tab — focuses the copy button","Enter / Space — copies the code"]}},
|
|
68
|
+
/>`}],compositionGraph:[],accessibility:{role:"region",ariaAttributes:["aria-label (copy button)"],keyboardInteractions:["Tab — focuses the copy button","Enter / Space — copies the code"]}},Cn=`
|
|
69
69
|
.lucent-table-row:hover > td,
|
|
70
70
|
.lucent-table-row:hover > th {
|
|
71
71
|
background: color-mix(in srgb, var(--lucent-text-primary) 5%, transparent) !important;
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
.lucent-table-striped tbody .lucent-table-row:nth-child(even) > th {
|
|
75
75
|
background: color-mix(in srgb, var(--lucent-text-primary) 4%, transparent);
|
|
76
76
|
}
|
|
77
|
-
`;function
|
|
77
|
+
`;function In({children:t,style:r,...n}){return e.jsx("thead",{style:{background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",...r},...n,children:t})}function jn({children:t,...r}){return e.jsx("tbody",{...r,children:t})}function Mn({children:t,style:r,...n}){return e.jsx("tfoot",{style:{background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",...r},...n,children:t})}function zn({children:t,className:r,...n}){return e.jsx("tr",{className:["lucent-table-row",r].filter(Boolean).join(" "),...n,children:t})}function En({as:t,children:r,style:n,...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,...n};return a?e.jsx("th",{scope:"col",style:i,...o,children:r}):e.jsx("td",{style:i,...o,children:r})}function ne({striped:t=!1,children:r,className:n,style:o,...a}){const i=["lucent-table",t&&"lucent-table-striped",n].filter(Boolean).join(" ");return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Cn}),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:r})})]})}ne.Head=In;ne.Body=jn;ne.Foot=Mn;ne.Row=zn;ne.Cell=En;const An={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 tinted backgrounds to even tbody rows via color-mix(transparent)."},{name:"Table.Head",type:"component",required:!1,description:"Renders <thead> with a subtle tinted 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 a subtle tinted 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>
|
|
78
78
|
<Table.Head>
|
|
79
79
|
<Table.Row>
|
|
80
80
|
<Table.Cell as="th">Name</Table.Cell>
|
|
@@ -92,15 +92,15 @@
|
|
|
92
92
|
<Table.Body>…</Table.Body>
|
|
93
93
|
</Table>`},{title:"Custom cell content",code:`<Table.Cell>
|
|
94
94
|
<Badge variant="success">Active</Badge>
|
|
95
|
-
</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"]}},
|
|
95
|
+
</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"]}},qn={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');
|
|
96
96
|
<ColorPicker value={color} onChange={setColor} label="Brand color" />`},{title:"Custom presets",code:`<ColorPicker
|
|
97
97
|
value={accent}
|
|
98
98
|
onChange={setAccent}
|
|
99
99
|
label="Accent"
|
|
100
100
|
presets={['#111827', '#3b82f6', '#8b5cf6', '#ec4899', '#ef4444', '#f97316', '#22c55e']}
|
|
101
|
-
/>`},{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"]}},
|
|
101
|
+
/>`},{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"]}},Dn={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 => (
|
|
102
102
|
<ColorSwatch key={c} color={c} />
|
|
103
|
-
))`},{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"]}},
|
|
103
|
+
))`},{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"]}},Rn={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');
|
|
104
104
|
<SegmentedControl
|
|
105
105
|
value={view}
|
|
106
106
|
onChange={setView}
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
]}
|
|
119
119
|
/>`},{title:"Full-width, sizes",code:`<SegmentedControl fullWidth size="sm" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />
|
|
120
120
|
<SegmentedControl fullWidth size="md" defaultValue="a" options={[{ value: 'a', label: 'Alpha' }, { value: 'b', label: 'Beta' }]} />
|
|
121
|
-
<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"]}},
|
|
121
|
+
<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"]}},Bn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},Pn={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around"};function ze({gap:t="4",align:r="stretch",justify:n="start",as:o="div",wrap:a=!1,children:i,style:l,...s}){const d=o==="ul"||o==="ol",p={display:"flex",flexDirection:"column",gap:`var(--lucent-space-${t})`,alignItems:Bn[r],justifyContent:Pn[n],...a&&{flexWrap:"wrap"},...d&&{listStyle:"none",margin:0,padding:0},...l},h=o;return e.jsx(h,{style:p,...s,children:i})}const Ln={id:"stack",name:"Stack",tier:"atom",domain:"neutral",specVersion:"0.1",description:"Vertical flex layout primitive that spaces children using design-system gap tokens.",designIntent:"Stack is the primary vertical layout container. Use it any time you need to arrange elements in a column with consistent spacing — form fields, card content, page sections, sidebar navigation. The gap prop maps to spacing tokens (--lucent-space-*), enforcing consistent vertical rhythm without manual margin management. Prefer Stack over raw inline flex styles for maintainability and readability. Use Row (the horizontal counterpart) when items should flow left-to-right. Stack does not add padding — wrap it in a Card or apply padding on a parent container instead.",props:[{name:"gap",type:"enum",required:!1,default:"4",description:"Spacing between children. Maps to --lucent-space-{n} tokens.",enumValues:["0","1","2","3","4","5","6","8","10","12","16","20","24"]},{name:"align",type:"enum",required:!1,default:"stretch",description:'Cross-axis alignment (alignItems). "stretch" fills the container width.',enumValues:["start","center","end","stretch","baseline"]},{name:"justify",type:"enum",required:!1,default:"start",description:"Main-axis distribution (justifyContent).",enumValues:["start","center","end","between","around"]},{name:"as",type:"enum",required:!1,default:"div",description:"HTML element to render. Use semantic elements when appropriate (nav for navigation, ul/ol for lists, section/header/footer/main/aside/article for landmarks). When rendering as ul/ol, list-style/margin/padding are auto-reset; consumers pass <li> children.",enumValues:["div","section","nav","header","footer","main","aside","article","form","fieldset","ul","ol"]},{name:"wrap",type:"boolean",required:!1,default:"false",description:"Whether children should wrap to the next line when they exceed the container width."},{name:"children",type:"ReactNode",required:!0,description:"The elements to arrange vertically."},{name:"style",type:"object",required:!1,description:"Inline style overrides. Applied after computed layout styles."},{name:"className",type:"string",required:!1,description:"CSS class name passthrough."}],usageExamples:[{title:"Form layout",code:`<Stack gap="4">
|
|
122
122
|
<FormField label="Name"><Input /></FormField>
|
|
123
123
|
<FormField label="Email"><Input type="email" /></FormField>
|
|
124
124
|
<Button variant="primary">Submit</Button>
|
|
@@ -137,7 +137,13 @@
|
|
|
137
137
|
</Stack>`},{title:"Semantic nav",code:`<Stack as="nav" gap="1">
|
|
138
138
|
<NavLink href="/home">Home</NavLink>
|
|
139
139
|
<NavLink href="/settings">Settings</NavLink>
|
|
140
|
-
</Stack>`}
|
|
140
|
+
</Stack>`},{title:"Semantic list (ul)",code:`<Stack as="ul" gap="3" aria-label="Recent notes">
|
|
141
|
+
{notes.map(note => (
|
|
142
|
+
<li key={note.id}>
|
|
143
|
+
<Text size="sm">{note.body}</Text>
|
|
144
|
+
</li>
|
|
145
|
+
))}
|
|
146
|
+
</Stack>`}],compositionGraph:[],accessibility:{notes:"Stack renders a <div> by default, which has no implicit ARIA role. Use the `as` prop to render semantic elements (nav, section, form) when the content has a specific structural purpose. Add aria-label or aria-labelledby when using landmark elements."}},Fn={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch",baseline:"baseline"},Nn={start:"flex-start",center:"center",end:"flex-end",between:"space-between",around:"space-around"};function Ee({gap:t="3",align:r="center",justify:n="start",as:o="div",wrap:a=!1,children:i,style:l,...s}){const d=o==="ul"||o==="ol",p={display:"flex",flexDirection:"row",gap:`var(--lucent-space-${t})`,alignItems:Fn[r],justifyContent:Nn[n],...a&&{flexWrap:"wrap"},...d&&{listStyle:"none",margin:0,padding:0},...l},h=o;return e.jsx(h,{style:p,...s,children:i})}const $n={id:"row",name:"Row",tier:"atom",domain:"neutral",specVersion:"0.1",description:"Horizontal flex layout primitive that spaces children using design-system gap tokens.",designIntent:'Row is the primary horizontal layout container. Use it any time you need to arrange elements side by side — button groups, label-value pairs, icon + text combos, toolbar actions. Default align is "center" (vertical centering), which is the most common horizontal layout need. Use justify="between" for space-between patterns like a header with title on the left and actions on the right. Set wrap=true when items should flow to the next line on narrow screens. Row does not add padding — wrap it in a Card or apply padding on a parent container instead. For vertical arrangement, use Stack instead.',props:[{name:"gap",type:"enum",required:!1,default:"3",description:"Spacing between children. Maps to --lucent-space-{n} tokens.",enumValues:["0","1","2","3","4","5","6","8","10","12","16","20","24"]},{name:"align",type:"enum",required:!1,default:"center",description:'Cross-axis alignment (alignItems). "center" vertically centers items, which is the most common need.',enumValues:["start","center","end","stretch","baseline"]},{name:"justify",type:"enum",required:!1,default:"start",description:'Main-axis distribution (justifyContent). Use "between" for label/action pairs.',enumValues:["start","center","end","between","around"]},{name:"as",type:"enum",required:!1,default:"div",description:"HTML element to render. Use semantic elements when appropriate (nav for navigation, ul/ol for lists, section/header/footer/main/aside/article for landmarks). When rendering as ul/ol, list-style/margin/padding are auto-reset; consumers pass <li> children.",enumValues:["div","section","nav","header","footer","main","aside","article","form","fieldset","ul","ol"]},{name:"wrap",type:"boolean",required:!1,default:"false",description:"Whether children should wrap to the next line when they exceed the container width."},{name:"children",type:"ReactNode",required:!0,description:"The elements to arrange horizontally."},{name:"style",type:"object",required:!1,description:"Inline style overrides. Applied after computed layout styles."},{name:"className",type:"string",required:!1,description:"CSS class name passthrough."}],usageExamples:[{title:"Settings toggle",code:`<Row gap="3" justify="between">
|
|
141
147
|
<Text size="sm">Push notifications</Text>
|
|
142
148
|
<Toggle />
|
|
143
149
|
</Row>`},{title:"Button group",code:`<Row gap="2">
|
|
@@ -161,7 +167,15 @@
|
|
|
161
167
|
<Button variant="outline" size="sm">Export</Button>
|
|
162
168
|
<Button variant="primary" size="sm">New report</Button>
|
|
163
169
|
</Row>
|
|
164
|
-
</Row>`}
|
|
170
|
+
</Row>`},{title:"Semantic nav",code:`<Row as="nav" gap="4" aria-label="Primary">
|
|
171
|
+
<a href="/home">Home</a>
|
|
172
|
+
<a href="/about">About</a>
|
|
173
|
+
<a href="/contact">Contact</a>
|
|
174
|
+
</Row>`},{title:"Horizontal list (ul)",code:`<Row as="ul" gap="2" aria-label="Tags">
|
|
175
|
+
{tags.map(tag => (
|
|
176
|
+
<li key={tag}><Tag>{tag}</Tag></li>
|
|
177
|
+
))}
|
|
178
|
+
</Row>`}],compositionGraph:[],accessibility:{notes:'Row renders a <div> by default, which has no implicit ARIA role. Use the `as` prop to render semantic elements (nav, section) when the content has a specific structural purpose. For toolbar patterns, consider adding role="toolbar" via the role prop.'}},Wn={sm:{height:4,radius:"var(--lucent-radius-sm)"},md:{height:8,radius:"var(--lucent-radius-md)"},lg:{height:12,radius:"var(--lucent-radius-md)"}},On={accent:"var(--lucent-accent-default)",success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)"};function Vn(t,r,n,o,a){return o!==void 0&&a!==void 0?o<=a?t>=a?"danger":t>=o?"warning":"success":t<=a?"danger":t<=o?"warning":"success":o!==void 0?o<=r/2?t<=o?"warning":n??"accent":t>=o?"warning":n??"accent":a!==void 0?a<=r/2?t<=a?"danger":n??"accent":t>=a?"danger":n??"accent":n??"accent"}function Hn({value:t,max:r=100,variant:n,size:o="md",warnAt:a,dangerAt:i,label:l,style:s}){const d=Math.max(0,Math.min(t,r)),p=r>0?d/r*100:0,h=Vn(d,r,n,a,i),f=Wn[o],w=On[h],y=l===!0?`${Math.round(p)}%`:l||null;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",fontFamily:"var(--lucent-font-family-base)",...s},children:[e.jsx("div",{role:"progressbar","aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":r,style:{flex:1,height:f.height,borderRadius:f.radius,background:"color-mix(in srgb, var(--lucent-text-primary) 8%, transparent)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${p}%`,height:"100%",borderRadius:f.radius,background:w,transition:"width var(--lucent-duration-base) var(--lucent-easing-default), background var(--lucent-duration-base) var(--lucent-easing-default)"}})}),y!=null&&e.jsx("span",{style:{fontSize:"var(--lucent-font-size-sm)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",whiteSpace:"nowrap",flexShrink:0},children:y})]})}const Gn={id:"progress",name:"Progress",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A horizontal bar indicating completion, progress, or resource usage.",designIntent:'Use Progress to visualise a bounded numeric value — task completion, disk usage, health bars, etc. Set warnAt/dangerAt thresholds for automatic colour shifts instead of hardcoding variants. Ascending thresholds (warnAt < dangerAt) suit "high is bad" metrics like CPU; descending thresholds (warnAt > dangerAt) suit "low is bad" metrics like battery.',props:[{name:"value",type:"number",required:!0,description:"Current progress value."},{name:"max",type:"number",required:!1,default:"100",description:"Maximum value."},{name:"variant",type:"enum",required:!1,default:"accent",description:"Colour variant. Overridden when thresholds are set.",enumValues:["accent","success","warning","danger"]},{name:"size",type:"enum",required:!1,default:"md",description:"Bar height.",enumValues:["sm","md","lg"]},{name:"warnAt",type:"number",required:!1,description:"Value at which variant auto-switches to warning."},{name:"dangerAt",type:"number",required:!1,description:"Value at which variant auto-switches to danger."},{name:"label",type:"union",required:!1,description:"true shows percentage; ReactNode shows custom label."}],usageExamples:[{title:"Basic",code:"<Progress value={60} />"},{title:"With label",code:"<Progress value={42} label />"},{title:"Thresholds",code:"<Progress value={85} warnAt={70} dangerAt={90} label />"},{title:"Danger variant",code:'<Progress value={95} variant="danger" size="lg" label />'}],compositionGraph:[],accessibility:{role:"progressbar",ariaAttributes:["aria-valuenow","aria-valuemin","aria-valuemax"],notes:"Uses native progressbar role. Add aria-label on the wrapping element for screen-reader context."}},we=120,Un=`
|
|
165
179
|
@keyframes lucent-menu-in {
|
|
166
180
|
from { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
167
181
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
@@ -170,7 +184,7 @@
|
|
|
170
184
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
171
185
|
to { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
172
186
|
}
|
|
173
|
-
`,Be={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},Gn={sm:"sm",md:"md",lg:"lg"},Un={sm:"xs",md:"sm",lg:"md"},_n={sm:12,md:14,lg:16},Pe=c.createContext(null),de=4;function Yn(t,r,n){const o=r.offsetWidth,a=r.offsetHeight,i=window.innerWidth,s=window.innerHeight;let l=0,d=0,p=n;const m={top:t.top-a-de,bottom:t.bottom+de,left:t.left-o-de,right:t.right+de};p.startsWith("bottom")?(l=m.bottom,l+a>s&&m.top>=0&&(l=m.top,p=p.replace("bottom","top"))):p.startsWith("top")?(l=m.top,l<0&&m.bottom+a<=s&&(l=m.bottom,p=p.replace("top","bottom"))):p==="left"?(l=t.top+t.height/2-a/2,d=m.left,d<0&&m.right+o<=i&&(d=m.right,p="right")):p==="right"&&(l=t.top+t.height/2-a/2,d=m.right,d+o>i&&m.left>=0&&(d=m.left,p="left")),(p.startsWith("top")||p.startsWith("bottom"))&&(p.endsWith("-start")?d=t.left:p.endsWith("-end")?d=t.right-o:d=t.left+t.width/2-o/2),d+o>i&&(d=i-o-8),d<0&&(d=8),l+a>s&&(l=s-a-8),l<0&&(l=8);let f="top left";return p.startsWith("top")?f=p.endsWith("-end")?"bottom right":p.endsWith("-start")?"bottom left":"bottom center":p.startsWith("bottom")?f=p.endsWith("-end")?"top right":p.endsWith("-start")?"top left":"top center":p==="left"?f="center right":p==="right"&&(f="center left"),{top:l,left:d,transformOrigin:f}}function me({onSelect:t,children:r,icon:n,shortcut:o,disabled:a=!1,danger:i=!1,selected:s=!1,style:l}){const d=c.useContext(Pe),p=c.useRef(-1);p.current===-1&&d&&(p.current=d.getItemIndex(),d.registerItem(p.current,a));const m=d?d.activeIndex===p.current:!1,f=(d==null?void 0:d.size)??"md",w=Be[f],y=Gn[f],g=_n[f],h=()=>{a||(t(),d==null||d.close())},u=()=>{!a&&d&&d.setActiveIndex(p.current)},b=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":m||void 0,tabIndex:-1,onClick:h,onMouseEnter:u,style:{display:"flex",alignItems:"center",gap:w,padding:w,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))":m?"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:[n&&e.jsx("span",{style:{flexShrink:0,display:"flex",color:a?"var(--lucent-text-disabled)":i?"var(--lucent-danger-text)":"var(--lucent-text-secondary)"},children:n}),e.jsx("span",{style:{flex:1,minWidth:0},children:e.jsx(I.Text,{size:y,style:{color:b},children:r})}),o&&e.jsx(I.Text,{size:f==="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:g,height:g,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 it({style:t}){return e.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)",...t}})}function Kn({label:t,children:r,style:n}){const o=c.useContext(Pe),a=(o==null?void 0:o.size)??"md",i=Be[a];return e.jsxs("div",{role:"group","aria-label":t,style:n,children:[e.jsx("div",{style:{padding:`${i} ${i} var(--lucent-space-1)`},children:e.jsx(I.Text,{size:Un[a],color:"secondary",weight:"medium",children:t})}),r]})}function Le({trigger:t,children:r,placement:n="bottom-start",size:o="md",open:a,onOpenChange:i,portalContainer:s,style:l}){const d=a!==void 0,[p,m]=c.useState(!1),f=d?a:p,[w,y]=c.useState(!1),[g,h]=c.useState("idle"),u=c.useRef(null),b=c.useRef(null),x=c.useRef(null),k=c.useRef(!1),[S,C]=c.useState(null),v=c.useRef(0),z=c.useRef(new Map),[T,E]=c.useState(-1);if(!k.current&&typeof document<"u"){const A=document.createElement("style");A.textContent=Hn,document.head.appendChild(A),k.current=!0}c.useEffect(()=>{if(f)v.current=0,z.current.clear(),y(!0),h("entering");else if(w){h("exiting");const A=setTimeout(()=>{y(!1),h("idle")},we);return()=>clearTimeout(A)}},[f]);const F=c.useCallback(A=>{d||m(A),i==null||i(A)},[d,i]),R=c.useCallback(()=>{const A=x.current;A&&(A.querySelector("button, [tabindex]")??A).focus()},[]),j=c.useCallback(()=>{F(!1),R()},[F,R]);c.useLayoutEffect(()=>{if(!w||g!=="entering"||!u.current)return;const A=requestAnimationFrame(()=>{const B=b.current,M=u.current;if(!B||!M)return;const $=M.getBoundingClientRect();C(Yn($,B,n))});return()=>cancelAnimationFrame(A)},[w,g,n]),c.useEffect(()=>{if(!w||g!=="entering")return;const A=setTimeout(()=>{const M=Array.from(z.current.entries()).sort(($,V)=>$[0]-V[0]).find(([,$])=>!$.disabled);E(M?M[0]:-1)},0);return()=>clearTimeout(A)},[w,g]),c.useEffect(()=>{if(!f)return;const A=M=>{var V,L;const $=M.target;(V=u.current)!=null&&V.contains($)||(L=b.current)!=null&&L.contains($)||j()},B=requestAnimationFrame(()=>{document.addEventListener("mousedown",A)});return()=>{cancelAnimationFrame(B),document.removeEventListener("mousedown",A)}},[f,j]),c.useEffect(()=>{if(!f)return;let A=!1;const B=setTimeout(()=>{A=!0},50),M=()=>{A&&j()};return window.addEventListener("scroll",M,{passive:!0,capture:!0}),()=>{clearTimeout(B),window.removeEventListener("scroll",M,{capture:!0})}},[f,j]);const P=c.useCallback(()=>Array.from(z.current.entries()).filter(([,A])=>!A.disabled).map(([A])=>A).sort((A,B)=>A-B),[]),D=c.useCallback(A=>{if(!f)return;const B=P();if(B.length!==0)switch(A.key){case"Escape":A.preventDefault(),j();break;case"ArrowDown":{A.preventDefault(),E(M=>{const $=B.indexOf(M);return $<B.length-1?B[$+1]:B[0]});break}case"ArrowUp":{A.preventDefault(),E(M=>{const $=B.indexOf(M);return $>0?B[$-1]:B[B.length-1]});break}case"Home":{A.preventDefault(),E(B[0]);break}case"End":{A.preventDefault(),E(B[B.length-1]);break}case"Enter":case" ":{A.preventDefault();const M=b.current;if(M){const $=M.querySelector('[data-active="true"]');$==null||$.click()}break}case"Tab":{j();break}}},[f,j,P]);c.useEffect(()=>{if(f)return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[f,D]),c.useEffect(()=>{if(!f)return;const A=b.current;if(!A)return;const B=A.querySelector('[data-active="true"]');B==null||B.scrollIntoView({block:"nearest"})},[T,f]);const W=()=>{F(!f)},q=A=>{(A.key==="Enter"||A.key===" "||A.key==="ArrowDown")&&(A.preventDefault(),f||F(!0)),A.key==="ArrowUp"&&(A.preventDefault(),f||(F(!0),setTimeout(()=>{const B=P();B.length>0&&E(B[B.length-1])},0)))},N={activeIndex:T,setActiveIndex:E,registerItem:(A,B)=>{z.current.set(A,{disabled:B})},close:j,getItemIndex:()=>v.current++,size:o},H=c.useId();return e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:u,style:{display:"inline-flex"},children:e.jsx("span",{ref:x,onClick:W,onKeyDown:q,"aria-haspopup":"menu","aria-expanded":f,"aria-controls":f?H:void 0,style:{display:"inline-flex",cursor:"pointer"},children:t})}),w&&J.createPortal(e.jsx(Pe.Provider,{value:N,children:e.jsx("div",{ref:b,id:H,role:"menu",style:{position:"fixed",top:(S==null?void 0:S.top)??-9999,left:(S==null?void 0:S.left)??-9999,zIndex:1e3,minWidth:180,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:Be[o],maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:g==="exiting"?`lucent-menu-out ${we}ms var(--lucent-easing-default) forwards`:`lucent-menu-in ${we}ms var(--lucent-easing-decelerate)`,transformOrigin:(S==null?void 0:S.transformOrigin)??"top left",outline:"none",pointerEvents:g==="exiting"?"none":"auto",...l},children:r})}),s??document.body)]})}const Xn={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 (subtle `color-mix` tint). 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>}>
|
|
187
|
+
`,Le={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},_n={sm:"sm",md:"md",lg:"lg"},Yn={sm:"xs",md:"sm",lg:"md"},Kn={sm:12,md:14,lg:16},Fe=c.createContext(null),de=4;function Xn(t,r,n){const o=r.offsetWidth,a=r.offsetHeight,i=window.innerWidth,l=window.innerHeight;let s=0,d=0,p=n;const h={top:t.top-a-de,bottom:t.bottom+de,left:t.left-o-de,right:t.right+de};p.startsWith("bottom")?(s=h.bottom,s+a>l&&h.top>=0&&(s=h.top,p=p.replace("bottom","top"))):p.startsWith("top")?(s=h.top,s<0&&h.bottom+a<=l&&(s=h.bottom,p=p.replace("top","bottom"))):p==="left"?(s=t.top+t.height/2-a/2,d=h.left,d<0&&h.right+o<=i&&(d=h.right,p="right")):p==="right"&&(s=t.top+t.height/2-a/2,d=h.right,d+o>i&&h.left>=0&&(d=h.left,p="left")),(p.startsWith("top")||p.startsWith("bottom"))&&(p.endsWith("-start")?d=t.left:p.endsWith("-end")?d=t.right-o:d=t.left+t.width/2-o/2),d+o>i&&(d=i-o-8),d<0&&(d=8),s+a>l&&(s=l-a-8),s<0&&(s=8);let f="top left";return p.startsWith("top")?f=p.endsWith("-end")?"bottom right":p.endsWith("-start")?"bottom left":"bottom center":p.startsWith("bottom")?f=p.endsWith("-end")?"top right":p.endsWith("-start")?"top left":"top center":p==="left"?f="center right":p==="right"&&(f="center left"),{top:s,left:d,transformOrigin:f}}function me({onSelect:t,children:r,icon:n,shortcut:o,disabled:a=!1,danger:i=!1,selected:l=!1,style:s}){const d=c.useContext(Fe),p=c.useRef(-1);p.current===-1&&d&&(p.current=d.getItemIndex(),d.registerItem(p.current,a));const h=d?d.activeIndex===p.current:!1,f=(d==null?void 0:d.size)??"md",w=Le[f],y=_n[f],g=Kn[f],m=()=>{a||(t(),d==null||d.close())},u=()=>{!a&&d&&d.setActiveIndex(p.current)},b=a?"var(--lucent-text-disabled)":i?"var(--lucent-danger-text)":"var(--lucent-text-primary)";return e.jsxs("div",{role:"menuitemcheckbox","aria-checked":l,"aria-disabled":a||void 0,"data-active":h||void 0,tabIndex:-1,onClick:m,onMouseEnter:u,style:{display:"flex",alignItems:"center",gap:w,padding:w,borderRadius:"var(--lucent-radius-md)",cursor:a?"not-allowed":"pointer",background:l?"color-mix(in srgb, var(--lucent-accent-default) 12%, var(--lucent-surface-overlay))":h?"var(--lucent-surface-secondary)":"transparent",boxShadow:l?"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",...s},children:[n&&e.jsx("span",{style:{flexShrink:0,display:"flex",color:a?"var(--lucent-text-disabled)":i?"var(--lucent-danger-text)":"var(--lucent-text-secondary)"},children:n}),e.jsx("span",{style:{flex:1,minWidth:0},children:e.jsx(I.Text,{size:y,style:{color:b},children:r})}),o&&e.jsx(I.Text,{size:f==="lg"?"sm":"xs",style:{color:"var(--lucent-text-secondary)",flexShrink:0},children:o}),l&&e.jsx("span",{style:{flexShrink:0,display:"flex",color:"var(--lucent-accent-default)"},children:e.jsx("svg",{width:g,height:g,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 dt({style:t}){return e.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)",...t}})}function Jn({label:t,children:r,style:n}){const o=c.useContext(Fe),a=(o==null?void 0:o.size)??"md",i=Le[a];return e.jsxs("div",{role:"group","aria-label":t,style:n,children:[e.jsx("div",{style:{padding:`${i} ${i} var(--lucent-space-1)`},children:e.jsx(I.Text,{size:Yn[a],color:"secondary",weight:"medium",children:t})}),r]})}function Ne({trigger:t,children:r,placement:n="bottom-start",size:o="md",open:a,onOpenChange:i,portalContainer:l,style:s}){const d=a!==void 0,[p,h]=c.useState(!1),f=d?a:p,[w,y]=c.useState(!1),[g,m]=c.useState("idle"),u=c.useRef(null),b=c.useRef(null),x=c.useRef(null),k=c.useRef(!1),[S,C]=c.useState(null),v=c.useRef(0),z=c.useRef(new Map),[T,E]=c.useState(-1);if(!k.current&&typeof document<"u"){const A=document.createElement("style");A.textContent=Un,document.head.appendChild(A),k.current=!0}c.useEffect(()=>{if(f)v.current=0,z.current.clear(),y(!0),m("entering");else if(w){m("exiting");const A=setTimeout(()=>{y(!1),m("idle")},we);return()=>clearTimeout(A)}},[f]);const F=c.useCallback(A=>{d||h(A),i==null||i(A)},[d,i]),R=c.useCallback(()=>{const A=x.current;A&&(A.querySelector("button, [tabindex]")??A).focus()},[]),j=c.useCallback(()=>{F(!1),R()},[F,R]);c.useLayoutEffect(()=>{if(!w||g!=="entering"||!u.current)return;const A=requestAnimationFrame(()=>{const B=b.current,M=u.current;if(!B||!M)return;const $=M.getBoundingClientRect();C(Xn($,B,n))});return()=>cancelAnimationFrame(A)},[w,g,n]),c.useEffect(()=>{if(!w||g!=="entering")return;const A=setTimeout(()=>{const M=Array.from(z.current.entries()).sort(($,V)=>$[0]-V[0]).find(([,$])=>!$.disabled);E(M?M[0]:-1)},0);return()=>clearTimeout(A)},[w,g]),c.useEffect(()=>{if(!f)return;const A=M=>{var V,L;const $=M.target;(V=u.current)!=null&&V.contains($)||(L=b.current)!=null&&L.contains($)||j()},B=requestAnimationFrame(()=>{document.addEventListener("mousedown",A)});return()=>{cancelAnimationFrame(B),document.removeEventListener("mousedown",A)}},[f,j]),c.useEffect(()=>{if(!f)return;let A=!1;const B=setTimeout(()=>{A=!0},50),M=()=>{A&&j()};return window.addEventListener("scroll",M,{passive:!0,capture:!0}),()=>{clearTimeout(B),window.removeEventListener("scroll",M,{capture:!0})}},[f,j]);const P=c.useCallback(()=>Array.from(z.current.entries()).filter(([,A])=>!A.disabled).map(([A])=>A).sort((A,B)=>A-B),[]),D=c.useCallback(A=>{if(!f)return;const B=P();if(B.length!==0)switch(A.key){case"Escape":A.preventDefault(),j();break;case"ArrowDown":{A.preventDefault(),E(M=>{const $=B.indexOf(M);return $<B.length-1?B[$+1]:B[0]});break}case"ArrowUp":{A.preventDefault(),E(M=>{const $=B.indexOf(M);return $>0?B[$-1]:B[B.length-1]});break}case"Home":{A.preventDefault(),E(B[0]);break}case"End":{A.preventDefault(),E(B[B.length-1]);break}case"Enter":case" ":{A.preventDefault();const M=b.current;if(M){const $=M.querySelector('[data-active="true"]');$==null||$.click()}break}case"Tab":{j();break}}},[f,j,P]);c.useEffect(()=>{if(f)return document.addEventListener("keydown",D),()=>document.removeEventListener("keydown",D)},[f,D]),c.useEffect(()=>{if(!f)return;const A=b.current;if(!A)return;const B=A.querySelector('[data-active="true"]');B==null||B.scrollIntoView({block:"nearest"})},[T,f]);const W=()=>{F(!f)},q=A=>{(A.key==="Enter"||A.key===" "||A.key==="ArrowDown")&&(A.preventDefault(),f||F(!0)),A.key==="ArrowUp"&&(A.preventDefault(),f||(F(!0),setTimeout(()=>{const B=P();B.length>0&&E(B[B.length-1])},0)))},N={activeIndex:T,setActiveIndex:E,registerItem:(A,B)=>{z.current.set(A,{disabled:B})},close:j,getItemIndex:()=>v.current++,size:o},H=c.useId();return e.jsxs(e.Fragment,{children:[e.jsx("span",{ref:u,style:{display:"inline-flex"},children:e.jsx("span",{ref:x,onClick:W,onKeyDown:q,"aria-haspopup":"menu","aria-expanded":f,"aria-controls":f?H:void 0,style:{display:"inline-flex",cursor:"pointer"},children:t})}),w&&J.createPortal(e.jsx(Fe.Provider,{value:N,children:e.jsx("div",{ref:b,id:H,role:"menu",style:{position:"fixed",top:(S==null?void 0:S.top)??-9999,left:(S==null?void 0:S.left)??-9999,zIndex:1e3,minWidth:180,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:Le[o],maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:g==="exiting"?`lucent-menu-out ${we}ms var(--lucent-easing-default) forwards`:`lucent-menu-in ${we}ms var(--lucent-easing-decelerate)`,transformOrigin:(S==null?void 0:S.transformOrigin)??"top left",outline:"none",pointerEvents:g==="exiting"?"none":"auto",...s},children:r})}),l??document.body)]})}const Zn={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 (subtle `color-mix` tint). 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>}>
|
|
174
188
|
<MenuItem onSelect={() => console.log('edit')}>Edit</MenuItem>
|
|
175
189
|
<MenuItem onSelect={() => console.log('duplicate')}>Duplicate</MenuItem>
|
|
176
190
|
<MenuSeparator />
|
|
@@ -207,7 +221,7 @@
|
|
|
207
221
|
<Menu trigger={<Button>Menu</Button>} open={open} onOpenChange={setOpen}>
|
|
208
222
|
<MenuItem onSelect={() => {}}>Option A</MenuItem>
|
|
209
223
|
<MenuItem onSelect={() => {}}>Option B</MenuItem>
|
|
210
|
-
</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.'}},st={primary:{background:"var(--lucent-accent-default)",color:"var(--lucent-accent-fg)",border:"1px solid transparent"},secondary:{background:"color-mix(in srgb, var(--lucent-accent-default) 16%, transparent)",color:"var(--lucent-text-primary)",border:"1px solid transparent"},outline:{background:"transparent",color:"var(--lucent-text-primary)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 35%, 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:"transparent",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"}},Jn={"2xs":{height:"22px",paddingOuter:"var(--lucent-space-2)",paddingInner:"var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)",borderRadius:"var(--lucent-radius-md)"},xs:{height:"26px",paddingOuter:"var(--lucent-space-3)",paddingInner:"var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)"},sm:{height:"calc(var(--lucent-space-8) * 0.5 + 18px)",paddingOuter:"var(--lucent-space-4)",paddingInner:"var(--lucent-space-2)",fontSize:"var(--lucent-font-size-sm)"},md:{height:"calc(var(--lucent-space-10) * 0.5 + 22px)",paddingOuter:"var(--lucent-space-5)",paddingInner:"var(--lucent-space-3)",fontSize:"var(--lucent-font-size-md)"},lg:{height:"calc(var(--lucent-space-12) * 0.5 + 26px)",paddingOuter:"var(--lucent-space-6)",paddingInner:"var(--lucent-space-3)",fontSize:"var(--lucent-font-size-lg)"}},Zn={"2xs":8,xs:10,sm:12,md:14,lg:16},Qn={"2xs":"24px",xs:"30px",sm:"34px",md:"36px",lg:"42px"},er={"2xs":"sm",xs:"sm",sm:"sm",md:"md",lg:"lg"},tr={primary:"var(--lucent-accent-hover)",secondary:"color-mix(in srgb, var(--lucent-accent-default) 22%, transparent)",outline:"color-mix(in srgb, var(--lucent-accent-default) 10%, transparent)",ghost:"color-mix(in srgb, var(--lucent-accent-default) 8%, transparent)",danger:"var(--lucent-danger-hover)","danger-outline":"color-mix(in srgb, var(--lucent-danger-default) 10%, transparent)","danger-ghost":"color-mix(in srgb, var(--lucent-danger-default) 8%, transparent)"},nr={primary:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 25%, transparent)",secondary:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 20%, transparent)",outline:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 20%, transparent)",ghost:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 15%, transparent)",danger:"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 25%, transparent)","danger-outline":"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 20%, transparent)","danger-ghost":"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 15%, transparent)"};function Ne(t,r,n){t.style.transform="translateY(-1px)",t.style.boxShadow=nr[r],t.style.background=tr[r],(r==="danger"&&n!==!1||r==="danger-outline"&&n!==!1)&&(t.style.borderColor="var(--lucent-danger-hover)")}function $e(t,r,n){t.style.transform="",t.style.boxShadow="",t.style.background=st[r].background,(r==="danger"&&n!==!1||r==="danger-outline"&&n!==!1)&&(t.style.borderColor="var(--lucent-danger-default)")}function We(t,r){const o=r==="danger"||r==="danger-outline"||r==="danger-ghost"?"color-mix(in srgb, var(--lucent-danger-default) 40%, transparent)":"color-mix(in srgb, var(--lucent-accent-default) 40%, transparent)";t.style.transform="translateY(1px)",t.style.boxShadow=`0 0 0 4px ${o}`,t.dataset.pressed="1"}function Oe(t){t.style.transform="",t.style.boxShadow="",delete t.dataset.pressed}function lt({children:t,onClick:r,menuItems:n,variant:o="primary",size:a="md",bordered:i=!0,menuPlacement:s="bottom-end",disabled:l,loading:d=!1,leftIcon:p,style:m}){const f=l??d,[w,y]=c.useState(!1),g=Jn[a],h=g.borderRadius??"var(--lucent-radius-lg)",u=Zn[a],b=f?{background:"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)",color:"var(--lucent-text-disabled)",borderColor:"transparent"}:{},x={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"var(--lucent-space-2)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,letterSpacing:"0.01em",cursor:f?"not-allowed":"pointer",outline:"none",margin:0,boxSizing:"border-box",whiteSpace:"nowrap",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)",height:g.height,fontSize:g.fontSize,...st[o],...i===!1&&{border:"none"},...b},k="var(--lucent-radius-sm)",S=`${h} ${k} ${k} ${h}`,C=`${k} ${h} ${h} ${k}`;return e.jsxs("div",{role:"group","aria-label":typeof t=="string"?t:"Split button",style:{display:"inline-flex",alignItems:"center",gap:"calc(var(--lucent-space-1) / 2)",...m},children:[e.jsxs("button",{type:"button",disabled:f,"aria-busy":d,onClick:r,onMouseEnter:v=>{f||Ne(v.currentTarget,o,i)},onMouseLeave:v=>{f||$e(v.currentTarget,o,i)},onMouseDown:v=>{f||We(v.currentTarget,o)},onMouseUp:v=>{Oe(v.currentTarget)},onFocus:v=>{v.currentTarget.dataset.pressed||(v.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)")},onBlur:v=>{v.currentTarget.style.boxShadow=""},style:{...x,borderRadius:S,padding:o==="ghost"||o==="danger-ghost"?`0 ${g.paddingInner} 0 ${g.paddingOuter}`:`0 ${g.paddingOuter}`},children:[p,d?e.jsx(rr,{}):t]}),e.jsx(Le,{open:w,onOpenChange:y,placement:s,size:er[a],trigger:e.jsx("button",{type:"button",disabled:f,"aria-label":"More actions",onMouseEnter:v=>{f||Ne(v.currentTarget,o,i)},onMouseLeave:v=>{f||$e(v.currentTarget,o,i)},onMouseDown:v=>{f||We(v.currentTarget,o)},onMouseUp:v=>{Oe(v.currentTarget)},onFocus:v=>{v.currentTarget.dataset.pressed||(v.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)")},onBlur:v=>{v.currentTarget.style.boxShadow=""},style:{...x,borderRadius:C,padding:0,width:Qn[a]},children:e.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default)",...w&&{transform:"rotate(180deg)"}},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}),children:n.map((v,z)=>e.jsx(me,{onSelect:v.onSelect,...v.disabled!==void 0&&{disabled:v.disabled},...v.danger!==void 0&&{danger:v.danger},...v.icon!==void 0&&{icon:v.icon},children:v.label},z))})]})}lt.displayName="SplitButton";function rr(){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 ar={id:"split-button",name:"SplitButton",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A compound button pairing a primary action with a chevron dropdown for secondary actions.",designIntent:'Use SplitButton when there is one dominant action alongside a small set of related alternatives (e.g. "Save" + "Save as draft", "Deploy" + "Deploy to staging"). Each half is a fully independent button separated by a small token-based gap, with a subtle inner corner radius (radius-sm) so the pair reads as a unit without sharing a border. Hover lift and press ring apply independently per half. Ghost variants use tighter inner padding to keep the halves visually close. The chevron half opens a Menu molecule; all dropdown keyboard navigation is inherited.',props:[{name:"children",type:"ReactNode",required:!0,description:"Label content for the primary action button."},{name:"onClick",type:"function",required:!0,description:"Handler fired when the primary (left) half is clicked."},{name:"menuItems",type:"array",required:!0,description:"Array of { label, onSelect, disabled?, danger?, icon? } for the dropdown."},{name:"variant",type:"enum",required:!1,default:"primary",description:"Visual variant applied to both halves.",enumValues:["primary","secondary","outline","ghost","danger","danger-outline","danger-ghost"]},{name:"size",type:"enum",required:!1,default:"md",description:"Size applied to both halves.",enumValues:["2xs","xs","sm","md","lg"]},{name:"bordered",type:"boolean",required:!1,default:"true",description:"If false, removes the border on both halves."},{name:"menuPlacement",type:"enum",required:!1,default:"bottom-end",description:"Dropdown placement relative to the chevron trigger.",enumValues:["top","top-start","top-end","bottom","bottom-start","bottom-end","left","right"]},{name:"disabled",type:"boolean",required:!1,description:"Disables both halves."},{name:"loading",type:"boolean",required:!1,default:"false",description:"Shows a spinner in the primary half and disables both."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon rendered before the label in the primary half."},{name:"style",type:"object",required:!1,description:"Style overrides for the wrapper div."}],usageExamples:[{title:"Basic",code:"<SplitButton onClick={handleSave} menuItems={[{ label: 'Save as draft', onSelect: handleDraft }]}>Save</SplitButton>"},{title:"Outline with leftIcon",code:`<SplitButton variant="outline" leftIcon={<Icon name="deploy" />} onClick={deploy} menuItems={[{ label: 'Deploy to staging', onSelect: deployStaging }, { label: 'Rollback', onSelect: rollback, danger: true }]}>Deploy</SplitButton>`},{title:"Menu items with icons",code:`<SplitButton onClick={handleSave} menuItems={[{ label: 'Save as draft', onSelect: handleDraft, icon: <Icon name="file" /> }, { label: 'Export', onSelect: handleExport, icon: <Icon name="download" /> }]}>Save</SplitButton>`},{title:"Small ghost bordered (issue #90 use case)",code:`<SplitButton variant="ghost" size="2xs" bordered onClick={toggle} menuItems={[{ label: 'Reset layout', onSelect: reset }]}>Collapse all</SplitButton>`},{title:"Danger outline with disabled item",code:`<SplitButton variant="danger-outline" onClick={handleDelete} menuItems={[{ label: 'Move to trash', onSelect: trash }, { label: 'Delete forever', onSelect: nuke, danger: true }, { label: 'Archive (unavailable)', onSelect: archive, disabled: true }]}>Delete</SplitButton>`},{title:"Disabled",code:"<SplitButton disabled onClick={handleSave} menuItems={[{ label: 'Option', onSelect: fn }]}>Save</SplitButton>"},{title:"Loading",code:"<SplitButton loading onClick={handleSave} menuItems={[{ label: 'Option', onSelect: fn }]}>Saving...</SplitButton>"}],compositionGraph:[{componentId:"menu",componentName:"Menu",role:"Dropdown container for secondary actions",required:!0},{componentId:"menu-item",componentName:"MenuItem",role:"Individual dropdown action",required:!0}],accessibility:{role:"group",ariaAttributes:["aria-label","aria-haspopup","aria-expanded","aria-busy"],keyboardInteractions:["Enter/Space on primary button fires onClick","Enter/Space/ArrowDown on chevron opens dropdown","ArrowDown/ArrowUp cycles dropdown items","Home/End jumps to first/last item","Escape closes dropdown and returns focus to chevron","Tab closes dropdown"],notes:'The wrapper uses role="group" with aria-label derived from children. The chevron button carries aria-haspopup="menu" and aria-expanded via Menu. Primary button has aria-busy when loading.'}},ae="var(--lucent-radius-sm)";function ct({children:t,style:r}){const n=c.Children.toArray(t).filter(c.isValidElement),o=n.length;return e.jsx("div",{role:"group",style:{display:"inline-flex",alignItems:"center",gap:"calc(var(--lucent-space-1) / 2)",...r},children:n.map((a,i)=>{const s=i===0,l=i===o-1;if(o===1)return a;const p=a.props.style??{},m=p.borderRadius??"var(--lucent-radius-lg)";let f;return s?f=`${m} ${ae} ${ae} ${m}`:l?f=`${ae} ${m} ${m} ${ae}`:f=ae,c.cloneElement(a,{key:i,style:{...p,borderRadius:f}})})})}ct.displayName="ButtonGroup";const or={id:"button-group",name:"ButtonGroup",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A layout wrapper that visually groups multiple Button or SplitButton children into a related strip.",designIntent:"Use ButtonGroup for peer actions that belong together visually — toolbars, action bars, toggle groups. Unlike SegmentedControl (single-select with indicator), ButtonGroup has no built-in selection state; each child handles its own behaviour. Items are separated by a small token-based gap with subtle inner corner radius so the group reads as a unit while each button retains its own border and hover states.",props:[{name:"children",type:"ReactNode",required:!0,description:"Button or SplitButton elements to group."},{name:"style",type:"object",required:!1,description:"Style overrides for the wrapper div."}],usageExamples:[{title:"Toolbar",code:`<ButtonGroup>
|
|
224
|
+
</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.'}},ut={primary:{background:"var(--lucent-accent-default)",color:"var(--lucent-accent-fg)",border:"1px solid transparent"},secondary:{background:"color-mix(in srgb, var(--lucent-accent-default) 16%, transparent)",color:"var(--lucent-text-primary)",border:"1px solid transparent"},outline:{background:"transparent",color:"var(--lucent-text-primary)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 35%, 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:"transparent",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"}},Qn={"2xs":{height:"22px",paddingOuter:"var(--lucent-space-2)",paddingInner:"var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)",borderRadius:"var(--lucent-radius-md)"},xs:{height:"26px",paddingOuter:"var(--lucent-space-3)",paddingInner:"var(--lucent-space-1)",fontSize:"var(--lucent-font-size-xs)"},sm:{height:"calc(var(--lucent-space-8) * 0.5 + 18px)",paddingOuter:"var(--lucent-space-4)",paddingInner:"var(--lucent-space-2)",fontSize:"var(--lucent-font-size-sm)"},md:{height:"calc(var(--lucent-space-10) * 0.5 + 22px)",paddingOuter:"var(--lucent-space-5)",paddingInner:"var(--lucent-space-3)",fontSize:"var(--lucent-font-size-md)"},lg:{height:"calc(var(--lucent-space-12) * 0.5 + 26px)",paddingOuter:"var(--lucent-space-6)",paddingInner:"var(--lucent-space-3)",fontSize:"var(--lucent-font-size-lg)"}},er={"2xs":8,xs:10,sm:12,md:14,lg:16},tr={"2xs":"24px",xs:"30px",sm:"34px",md:"36px",lg:"42px"},nr={"2xs":"sm",xs:"sm",sm:"sm",md:"md",lg:"lg"},rr={primary:"var(--lucent-accent-hover)",secondary:"color-mix(in srgb, var(--lucent-accent-default) 22%, transparent)",outline:"color-mix(in srgb, var(--lucent-accent-default) 10%, transparent)",ghost:"color-mix(in srgb, var(--lucent-accent-default) 8%, transparent)",danger:"var(--lucent-danger-hover)","danger-outline":"color-mix(in srgb, var(--lucent-danger-default) 10%, transparent)","danger-ghost":"color-mix(in srgb, var(--lucent-danger-default) 8%, transparent)"},ar={primary:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 25%, transparent)",secondary:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 20%, transparent)",outline:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 20%, transparent)",ghost:"0 4px 14px -2px color-mix(in srgb, var(--lucent-accent-default) 15%, transparent)",danger:"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 25%, transparent)","danger-outline":"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 20%, transparent)","danger-ghost":"0 4px 14px -2px color-mix(in srgb, var(--lucent-danger-default) 15%, transparent)"};function We(t,r,n){t.style.transform="translateY(-1px)",t.style.boxShadow=ar[r],t.style.background=rr[r],(r==="danger"&&n!==!1||r==="danger-outline"&&n!==!1)&&(t.style.borderColor="var(--lucent-danger-hover)")}function Oe(t,r,n){t.style.transform="",t.style.boxShadow="",t.style.background=ut[r].background,(r==="danger"&&n!==!1||r==="danger-outline"&&n!==!1)&&(t.style.borderColor="var(--lucent-danger-default)")}function Ve(t,r){const o=r==="danger"||r==="danger-outline"||r==="danger-ghost"?"color-mix(in srgb, var(--lucent-danger-default) 40%, transparent)":"color-mix(in srgb, var(--lucent-accent-default) 40%, transparent)";t.style.transform="translateY(1px)",t.style.boxShadow=`0 0 0 4px ${o}`,t.dataset.pressed="1"}function He(t){t.style.transform="",t.style.boxShadow="",delete t.dataset.pressed}function pt({children:t,onClick:r,menuItems:n,variant:o="primary",size:a="md",bordered:i=!0,menuPlacement:l="bottom-end",disabled:s,loading:d=!1,leftIcon:p,style:h}){const f=s??d,[w,y]=c.useState(!1),g=Qn[a],m=g.borderRadius??"var(--lucent-radius-lg)",u=er[a],b=f?{background:"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)",color:"var(--lucent-text-disabled)",borderColor:"transparent"}:{},x={display:"inline-flex",alignItems:"center",justifyContent:"center",gap:"var(--lucent-space-2)",fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",lineHeight:1,letterSpacing:"0.01em",cursor:f?"not-allowed":"pointer",outline:"none",margin:0,boxSizing:"border-box",whiteSpace:"nowrap",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)",height:g.height,fontSize:g.fontSize,...ut[o],...i===!1&&{border:"none"},...b},k="var(--lucent-radius-sm)",S=`${m} ${k} ${k} ${m}`,C=`${k} ${m} ${m} ${k}`;return e.jsxs("div",{role:"group","aria-label":typeof t=="string"?t:"Split button",style:{display:"inline-flex",alignItems:"center",gap:"calc(var(--lucent-space-1) / 2)",...h},children:[e.jsxs("button",{type:"button",disabled:f,"aria-busy":d,onClick:r,onMouseEnter:v=>{f||We(v.currentTarget,o,i)},onMouseLeave:v=>{f||Oe(v.currentTarget,o,i)},onMouseDown:v=>{f||Ve(v.currentTarget,o)},onMouseUp:v=>{He(v.currentTarget)},onFocus:v=>{v.currentTarget.dataset.pressed||(v.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)")},onBlur:v=>{v.currentTarget.style.boxShadow=""},style:{...x,borderRadius:S,padding:o==="ghost"||o==="danger-ghost"?`0 ${g.paddingInner} 0 ${g.paddingOuter}`:`0 ${g.paddingOuter}`},children:[p,d?e.jsx(or,{}):t]}),e.jsx(Ne,{open:w,onOpenChange:y,placement:l,size:nr[a],trigger:e.jsx("button",{type:"button",disabled:f,"aria-label":"More actions",onMouseEnter:v=>{f||We(v.currentTarget,o,i)},onMouseLeave:v=>{f||Oe(v.currentTarget,o,i)},onMouseDown:v=>{f||Ve(v.currentTarget,o)},onMouseUp:v=>{He(v.currentTarget)},onFocus:v=>{v.currentTarget.dataset.pressed||(v.currentTarget.style.boxShadow="0 0 0 3px var(--lucent-accent-subtle)")},onBlur:v=>{v.currentTarget.style.boxShadow=""},style:{...x,borderRadius:C,padding:0,width:tr[a]},children:e.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,style:{flexShrink:0,transition:"transform var(--lucent-duration-fast) var(--lucent-easing-default)",...w&&{transform:"rotate(180deg)"}},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}),children:n.map((v,z)=>e.jsx(me,{onSelect:v.onSelect,...v.disabled!==void 0&&{disabled:v.disabled},...v.danger!==void 0&&{danger:v.danger},...v.icon!==void 0&&{icon:v.icon},children:v.label},z))})]})}pt.displayName="SplitButton";function or(){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 ir={id:"split-button",name:"SplitButton",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A compound button pairing a primary action with a chevron dropdown for secondary actions.",designIntent:'Use SplitButton when there is one dominant action alongside a small set of related alternatives (e.g. "Save" + "Save as draft", "Deploy" + "Deploy to staging"). Each half is a fully independent button separated by a small token-based gap, with a subtle inner corner radius (radius-sm) so the pair reads as a unit without sharing a border. Hover lift and press ring apply independently per half. Ghost variants use tighter inner padding to keep the halves visually close. The chevron half opens a Menu molecule; all dropdown keyboard navigation is inherited.',props:[{name:"children",type:"ReactNode",required:!0,description:"Label content for the primary action button."},{name:"onClick",type:"function",required:!0,description:"Handler fired when the primary (left) half is clicked."},{name:"menuItems",type:"array",required:!0,description:"Array of { label, onSelect, disabled?, danger?, icon? } for the dropdown."},{name:"variant",type:"enum",required:!1,default:"primary",description:"Visual variant applied to both halves.",enumValues:["primary","secondary","outline","ghost","danger","danger-outline","danger-ghost"]},{name:"size",type:"enum",required:!1,default:"md",description:"Size applied to both halves.",enumValues:["2xs","xs","sm","md","lg"]},{name:"bordered",type:"boolean",required:!1,default:"true",description:"If false, removes the border on both halves."},{name:"menuPlacement",type:"enum",required:!1,default:"bottom-end",description:"Dropdown placement relative to the chevron trigger.",enumValues:["top","top-start","top-end","bottom","bottom-start","bottom-end","left","right"]},{name:"disabled",type:"boolean",required:!1,description:"Disables both halves."},{name:"loading",type:"boolean",required:!1,default:"false",description:"Shows a spinner in the primary half and disables both."},{name:"leftIcon",type:"ReactNode",required:!1,description:"Icon rendered before the label in the primary half."},{name:"style",type:"object",required:!1,description:"Style overrides for the wrapper div."}],usageExamples:[{title:"Basic",code:"<SplitButton onClick={handleSave} menuItems={[{ label: 'Save as draft', onSelect: handleDraft }]}>Save</SplitButton>"},{title:"Outline with leftIcon",code:`<SplitButton variant="outline" leftIcon={<Icon name="deploy" />} onClick={deploy} menuItems={[{ label: 'Deploy to staging', onSelect: deployStaging }, { label: 'Rollback', onSelect: rollback, danger: true }]}>Deploy</SplitButton>`},{title:"Menu items with icons",code:`<SplitButton onClick={handleSave} menuItems={[{ label: 'Save as draft', onSelect: handleDraft, icon: <Icon name="file" /> }, { label: 'Export', onSelect: handleExport, icon: <Icon name="download" /> }]}>Save</SplitButton>`},{title:"Small ghost bordered (issue #90 use case)",code:`<SplitButton variant="ghost" size="2xs" bordered onClick={toggle} menuItems={[{ label: 'Reset layout', onSelect: reset }]}>Collapse all</SplitButton>`},{title:"Danger outline with disabled item",code:`<SplitButton variant="danger-outline" onClick={handleDelete} menuItems={[{ label: 'Move to trash', onSelect: trash }, { label: 'Delete forever', onSelect: nuke, danger: true }, { label: 'Archive (unavailable)', onSelect: archive, disabled: true }]}>Delete</SplitButton>`},{title:"Disabled",code:"<SplitButton disabled onClick={handleSave} menuItems={[{ label: 'Option', onSelect: fn }]}>Save</SplitButton>"},{title:"Loading",code:"<SplitButton loading onClick={handleSave} menuItems={[{ label: 'Option', onSelect: fn }]}>Saving...</SplitButton>"}],compositionGraph:[{componentId:"menu",componentName:"Menu",role:"Dropdown container for secondary actions",required:!0},{componentId:"menu-item",componentName:"MenuItem",role:"Individual dropdown action",required:!0}],accessibility:{role:"group",ariaAttributes:["aria-label","aria-haspopup","aria-expanded","aria-busy"],keyboardInteractions:["Enter/Space on primary button fires onClick","Enter/Space/ArrowDown on chevron opens dropdown","ArrowDown/ArrowUp cycles dropdown items","Home/End jumps to first/last item","Escape closes dropdown and returns focus to chevron","Tab closes dropdown"],notes:'The wrapper uses role="group" with aria-label derived from children. The chevron button carries aria-haspopup="menu" and aria-expanded via Menu. Primary button has aria-busy when loading.'}},ae="var(--lucent-radius-sm)";function ht({children:t,style:r}){const n=c.Children.toArray(t).filter(c.isValidElement),o=n.length;return e.jsx("div",{role:"group",style:{display:"inline-flex",alignItems:"center",gap:"calc(var(--lucent-space-1) / 2)",...r},children:n.map((a,i)=>{const l=i===0,s=i===o-1;if(o===1)return a;const p=a.props.style??{},h=p.borderRadius??"var(--lucent-radius-lg)";let f;return l?f=`${h} ${ae} ${ae} ${h}`:s?f=`${ae} ${h} ${h} ${ae}`:f=ae,c.cloneElement(a,{key:i,style:{...p,borderRadius:f}})})})}ht.displayName="ButtonGroup";const sr={id:"button-group",name:"ButtonGroup",tier:"atom",domain:"neutral",specVersion:"0.1",description:"A layout wrapper that visually groups multiple Button or SplitButton children into a related strip.",designIntent:"Use ButtonGroup for peer actions that belong together visually — toolbars, action bars, toggle groups. Unlike SegmentedControl (single-select with indicator), ButtonGroup has no built-in selection state; each child handles its own behaviour. Items are separated by a small token-based gap with subtle inner corner radius so the group reads as a unit while each button retains its own border and hover states.",props:[{name:"children",type:"ReactNode",required:!0,description:"Button or SplitButton elements to group."},{name:"style",type:"object",required:!1,description:"Style overrides for the wrapper div."}],usageExamples:[{title:"Toolbar",code:`<ButtonGroup>
|
|
211
225
|
<Button variant="outline" leftIcon={<Icon name="bold" />} />
|
|
212
226
|
<Button variant="outline" leftIcon={<Icon name="italic" />} />
|
|
213
227
|
<Button variant="outline" leftIcon={<Icon name="underline" />} />
|
|
@@ -217,7 +231,7 @@
|
|
|
217
231
|
</ButtonGroup>`},{title:"With SplitButton",code:`<ButtonGroup>
|
|
218
232
|
<SplitButton onClick={deploy} menuItems={[{ label: 'Staging', onSelect: staging }]}>Deploy</SplitButton>
|
|
219
233
|
<Button variant="outline">Logs</Button>
|
|
220
|
-
</ButtonGroup>`}],compositionGraph:[{componentId:"button",componentName:"Button",role:"Grouped action item",required:!1},{componentId:"split-button",componentName:"SplitButton",role:"Grouped split action item",required:!1}],accessibility:{role:"group",ariaAttributes:[],keyboardInteractions:["Tab moves focus between buttons in the group"],notes:'Uses role="group" on the wrapper. Individual button accessibility is inherited from the children.'}};function
|
|
234
|
+
</ButtonGroup>`}],compositionGraph:[{componentId:"button",componentName:"Button",role:"Grouped action item",required:!1},{componentId:"split-button",componentName:"SplitButton",role:"Grouped split action item",required:!1}],accessibility:{role:"group",ariaAttributes:[],keyboardInteractions:["Tab moves focus between buttons in the group"],notes:'Uses role="group" on the wrapper. Individual button accessibility is inherited from the children.'}};function lr({label:t,htmlFor:r,required:n=!1,helperText:o,errorMessage:a,children:i,style:l}){const s=a??o,d=a?"danger":"secondary";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)",...l},children:[t&&e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--lucent-space-1)"},children:[e.jsx(I.Text,{as:"label",size:"sm",weight:"medium",lineHeight:"tight",...r!==void 0&&{htmlFor:r},children:t}),n&&e.jsx(I.Text,{as:"span",size:"sm",color:"danger",lineHeight:"tight","aria-hidden":"true",children:"*"})]}),i,s&&e.jsx(I.Text,{size:"xs",color:d,lineHeight:"tight",children:s})]})}const cr={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">
|
|
221
235
|
<Input id="email" placeholder="you@example.com" />
|
|
222
236
|
</FormField>`},{title:"Required with helper",code:`<FormField label="Username" htmlFor="username" required helperText="Letters and numbers only">
|
|
223
237
|
<Input id="username" />
|
|
@@ -225,7 +239,7 @@
|
|
|
225
239
|
<Input id="pw" type="password" />
|
|
226
240
|
</FormField>`},{title:"Wrapping a Select",code:`<FormField label="Country" htmlFor="country">
|
|
227
241
|
<Select id="country" options={countryOptions} />
|
|
228
|
-
</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.'}},
|
|
242
|
+
</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.'}},Ge={sm:14,md:18,lg:20},dr={sm:"sm",md:"md",lg:"md"},ur={sm:"var(--lucent-space-1)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-2)"},pr=({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"})]}),hr=({size:t=16})=>e.jsx("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M2 3h12M4 8h8M6 13h4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})}),fr=()=>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 mr({value:t,onChange:r,mode:n="search",placeholder:o,size:a="md",label:i,helperText:l,errorText:s,results:d=[],onResultSelect:p,isLoading:h=!1,disabled:f=!1,id:w,style:y}){const g=o??(n==="filter"?"Filter…":"Search…"),[m,u]=c.useState(!1),[b,x]=c.useState(null),k=c.useRef(null),S=c.useRef(null),C=c.useRef(null),[v,z]=c.useState({top:0,left:0,width:0}),T=n==="search"&&m&&d.length>0;c.useLayoutEffect(()=>{if(!T||!S.current)return;const D=S.current.getBoundingClientRect();z({top:D.bottom+4,left:D.left,width:D.width})},[T]);const E=()=>{r("")},F=D=>{p==null||p(D),u(!1)},R=()=>{k.current=setTimeout(()=>u(!1),150)},j=()=>{k.current&&clearTimeout(k.current),u(!0)},P=h?e.jsx(it,{size:"sm"}):t?e.jsx("button",{type:"button","aria-label":n==="filter"?"Clear filter":"Clear search",onClick:E,style:{display:"flex",alignItems:"center",background:"none",border:"none",cursor:"pointer",padding:2,borderRadius:"var(--lucent-radius-sm)",color:"var(--lucent-text-secondary)"},onMouseEnter:D=>{D.currentTarget.style.color="var(--lucent-text-primary)"},onMouseLeave:D=>{D.currentTarget.style.color="var(--lucent-text-secondary)"},children:e.jsx(fr,{})}):null;return e.jsxs("div",{ref:S,style:{...y},children:[e.jsx(I.Input,{id:w,type:"text",size:a,value:t,onChange:D=>r(D.target.value),placeholder:g,disabled:f,leftElement:n==="filter"?e.jsx(hr,{size:Ge[a]}):e.jsx(pr,{size:Ge[a]}),rightElement:P??void 0,onFocus:j,onBlur:R,...i!==void 0&&{label:i},...l!==void 0&&{helperText:l},...s!==void 0&&{errorText:s}}),T&&J.createPortal(e.jsx("div",{ref:C,role:"listbox",style:{position:"fixed",top:v.top,left:v.left,width:v.width,zIndex:1e3,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:ur[a]},children:d.map((D,W)=>e.jsx("div",{role:"option","aria-selected":!1,onMouseDown:()=>F(D),onMouseEnter:()=>x(W),onMouseLeave:()=>x(null),style:{padding:"var(--lucent-space-2)",borderRadius:"var(--lucent-radius-md)",cursor:"pointer",background:b===W?"color-mix(in srgb, var(--lucent-accent-default) 14%, transparent)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:e.jsx(I.Text,{as:"span",size:dr[a],children:D.label})},D.id))}),document.body)]})}const gr={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. Use mode="filter" for a simple filter input with a funnel icon and no 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. Use mode="filter" when you only need a text input with a funnel icon and clear button — no dropdown, no results array, just a clean filter field.',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:"mode",type:"enum",required:!1,default:"search",description:'Controls variant. "filter" swaps the magnifier for a funnel icon and disables the results dropdown.',enumValues:["search","filter"]},{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…" (or "Filter…" in filter mode)',description:'Placeholder text for the input. Defaults to "Search…" in search mode and "Filter…" in filter mode.'},{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('');
|
|
229
243
|
const [results, setResults] = useState([]);
|
|
230
244
|
|
|
231
245
|
<SearchInput
|
|
@@ -233,7 +247,7 @@ const [results, setResults] = useState([]);
|
|
|
233
247
|
onChange={(v) => { setQuery(v); setResults(filter(v)); }}
|
|
234
248
|
results={results}
|
|
235
249
|
onResultSelect={(r) => console.log(r)}
|
|
236
|
-
/>`},{title:"Filter mode (no dropdown)",code:'<SearchInput mode="filter" value={filter} onChange={setFilter} placeholder="Filter items…" />'},{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.'}},ye=c.createContext({px:"0",py:"0"}),mr={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)"}},ue={none:"var(--lucent-shadow-none)",sm:"var(--lucent-shadow-sm)",md:"var(--lucent-shadow-md)",lg:"var(--lucent-shadow-lg)"},gr={none:"var(--lucent-radius-none)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-lg)"},vr={success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"},br={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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",border:"none",shadowDefault:"none",dividers:!0},elevated:{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",shadowDefault:"md",dividers:!0},combo:{background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",border:"none",shadowDefault:"none",dividers:!1}},yr=["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(", "),xr="0 4px 14px -2px var(--lucent-accent-subtle)",wr="0 4px 14px -2px color-mix(in srgb, var(--lucent-text-primary) 12%, transparent)",kr="0 0 0 3px var(--lucent-accent-subtle)",Sr="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 ee(...t){const r=t.filter(n=>n!=null&&n!=="none"&&n!=="var(--lucent-shadow-none)");return r.length>0?r.join(", "):void 0}function Cr(t,r,n){return!r||n?t.background:"var(--lucent-accent-subtle)"}function Ir({variant:t="outline",header:r,footer:n,children:o,padding:a="md",shadow:i,radius:s="lg",style:l,onClick:d,href:p,target:m,rel:f,disabled:w,status:y,selected:g,hoverable:h,media:u}){const b=br[t],x=t==="combo",k=i??(x?"md":b.shadowDefault),{py:S,px:C}=mr[a],v=`${S} ${C}`,z=gr[s],T=p!=null,E=d!=null||T,F=E||(h??!1),R=(w??!1)&&E,j=T?"a":E?"button":"div",[P,D]=c.useState(!1),[W,q]=c.useState(!1),[N,H]=c.useState(!1),A=(g??!1)&&!R,B=A?Tr:void 0,M=Cr(b,g??!1,R),$=y!=null?`inset 3px 0 0 ${vr[y]}`:void 0;let V;x?V=ee(B,$):F&&!R?N?V=ee(Sr,B,$):W?V=ee(kr,B,$):P?V=ee(E?xr:wr,ue[k],B,$):V=ee(ue[k],B,$):V=ee(ue[k],B,$);const L={display:"flex",flexDirection:"column",background:M,border:b.border,borderRadius:z,overflow:u!=null&&!(A||F&&W)?"hidden":"visible",boxSizing:"border-box",position:"relative",...V!==void 0&&{boxShadow:V},...F&&!R&&N&&{transform:"translateY(1px)"},...F&&!R&&P&&!N&&{transform:"translateY(-1px)"},...F&&{cursor:R?"not-allowed":"pointer",transition:yr},...E&&!T&&{padding:0,font:"inherit",textAlign:"inherit",width:"100%",background:M},...T&&{textDecoration:"none",color:"inherit"},...R&&{opacity:.6,pointerEvents:"none"},...l},G=F&&!R?{onMouseEnter:()=>D(!0),onMouseLeave:()=>{D(!1),H(!1)},onMouseDown:()=>H(!0),onMouseUp:()=>H(!1),onFocus:()=>q(!0),onBlur:()=>{q(!1),H(!1)}}:{};return e.jsxs(j,{style:L,...G,...T&&{href:R?void 0:p,...m!==void 0&&{target:m},...f!==void 0&&{rel:f}},...!T&&E&&{type:"button",...R&&{disabled:!0}},...d!==void 0&&!R&&{onClick:d},...E&&g!==void 0&&{"aria-pressed":g},...T&&R&&{"aria-disabled":!0},children:[u!=null&&e.jsx("div",{style:{lineHeight:0,overflow:"hidden",borderRadius:`${z} ${z} 0 0`},children:u}),r!=null&&e.jsx("div",{style:{padding:v,...b.dividers?{borderBottom:"1px solid var(--lucent-border-default)"}:{}},children:r}),e.jsx(ye.Provider,{value:{px:C,py:S},children:e.jsx("div",{style:{padding:v,flex:1,...x?{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:z,boxShadow:ue[k],marginLeft:`calc(${C} / 3)`,marginRight:`calc(${C} / 3)`}:{}},children:o})}),n!=null&&e.jsx("div",{style:{padding:v,...b.dividers?{borderTop:"1px solid var(--lucent-border-default)"}:{}},children:n})]})}function jr({children:t,style:r}){const{px:n}=c.useContext(ye);return e.jsx("div",{style:{marginLeft:`calc(-1 * ${n})`,marginRight:`calc(-1 * ${n})`,paddingLeft:n,paddingRight:n,...r},children:t})}const Mr={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 `navigation`, `bgBase`, or `bgSubtle` on a Card — those tokens are reserved for the page chrome and content area.\n- Content nested inside a Card that needs a tinted fill should use `color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)` for accent-neutral insets.',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:"lg",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 inset box-shadow on the left edge of the card. Rendered as an inset shadow (same technique as NavMenu inverse highlight) so it naturally follows the card's border-radius. 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:"hoverable",type:"boolean",required:!1,description:"Enables hover lift (translateY -1px) and neutral glow shadow without making the card a button or link. Use when the card contains its own interactive content (e.g. a Collapsible trigger) and the whole card surface should hint at interactivity. Interactive cards (onClick/href) get accent-colored hover glow; hoverable-only cards get a neutral glow (12% text-primary)."},{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 media slot self-clips to the card's top border-radius. Cards without media default to overflow:visible so nested child shadows (e.g. an elevated Card inside a Collapsible) are never cut off."}],usageExamples:[{title:"Ghost — invisible container",code:`<Card variant="ghost">
|
|
250
|
+
/>`},{title:"Filter mode (no dropdown)",code:'<SearchInput mode="filter" value={filter} onChange={setFilter} placeholder="Filter items…" />'},{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.'}},ye=c.createContext({px:"0",py:"0"}),vr={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)"}},ue={none:"var(--lucent-shadow-none)",sm:"var(--lucent-shadow-sm)",md:"var(--lucent-shadow-md)",lg:"var(--lucent-shadow-lg)"},br={none:"var(--lucent-radius-none)",sm:"var(--lucent-radius-sm)",md:"var(--lucent-radius-md)",lg:"var(--lucent-radius-lg)"},yr={success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"},xr={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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",border:"none",shadowDefault:"none",dividers:!0},elevated:{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",shadowDefault:"md",dividers:!0},combo:{background:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",border:"none",shadowDefault:"none",dividers:!1}},wr=["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(", "),kr="0 4px 14px -2px var(--lucent-accent-subtle)",Sr="0 4px 14px -2px color-mix(in srgb, var(--lucent-text-primary) 12%, transparent)",Tr="0 0 0 3px var(--lucent-accent-subtle)",Cr="0 0 0 2px var(--lucent-surface), 0 0 0 4px var(--lucent-accent-default)",Ir="0 0 0 3px var(--lucent-accent-subtle)";function ee(...t){const r=t.filter(n=>n!=null&&n!=="none"&&n!=="var(--lucent-shadow-none)");return r.length>0?r.join(", "):void 0}function jr(t,r,n){return!r||n?t.background:"var(--lucent-accent-subtle)"}function Mr({variant:t="outline",header:r,footer:n,children:o,padding:a="md",shadow:i,radius:l="lg",style:s,onClick:d,href:p,target:h,rel:f,disabled:w,status:y,selected:g,hoverable:m,media:u}){const b=xr[t],x=t==="combo",k=i??(x?"md":b.shadowDefault),{py:S,px:C}=vr[a],v=`${S} ${C}`,z=br[l],T=p!=null,E=d!=null||T,F=E||(m??!1),R=(w??!1)&&E,j=T?"a":E?"button":"div",[P,D]=c.useState(!1),[W,q]=c.useState(!1),[N,H]=c.useState(!1),A=(g??!1)&&!R,B=A?Ir:void 0,M=jr(b,g??!1,R),$=y!=null?`inset 3px 0 0 ${yr[y]}`:void 0;let V;x?V=ee(B,$):F&&!R?N?V=ee(Cr,B,$):W?V=ee(Tr,B,$):P?V=ee(E?kr:Sr,ue[k],B,$):V=ee(ue[k],B,$):V=ee(ue[k],B,$);const L={display:"flex",flexDirection:"column",background:M,border:b.border,borderRadius:z,overflow:u!=null&&!(A||F&&W)?"hidden":"visible",boxSizing:"border-box",position:"relative",...V!==void 0&&{boxShadow:V},...F&&!R&&N&&{transform:"translateY(1px)"},...F&&!R&&P&&!N&&{transform:"translateY(-1px)"},...F&&{cursor:R?"not-allowed":"pointer",transition:wr},...E&&!T&&{padding:0,font:"inherit",textAlign:"inherit",width:"100%",background:M},...T&&{textDecoration:"none",color:"inherit"},...R&&{opacity:.6,pointerEvents:"none"},...s},G=F&&!R?{onMouseEnter:()=>D(!0),onMouseLeave:()=>{D(!1),H(!1)},onMouseDown:()=>H(!0),onMouseUp:()=>H(!1),onFocus:()=>q(!0),onBlur:()=>{q(!1),H(!1)}}:{};return e.jsxs(j,{style:L,...G,...T&&{href:R?void 0:p,...h!==void 0&&{target:h},...f!==void 0&&{rel:f}},...!T&&E&&{type:"button",...R&&{disabled:!0}},...d!==void 0&&!R&&{onClick:d},...E&&g!==void 0&&{"aria-pressed":g},...T&&R&&{"aria-disabled":!0},children:[u!=null&&e.jsx("div",{style:{lineHeight:0,overflow:"hidden",borderRadius:`${z} ${z} 0 0`},children:u}),r!=null&&e.jsx("div",{style:{padding:v,...b.dividers?{borderBottom:"1px solid var(--lucent-border-default)"}:{}},children:r}),e.jsx(ye.Provider,{value:{px:C,py:S},children:e.jsx("div",{style:{padding:v,flex:1,...x?{background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:z,boxShadow:ue[k],marginLeft:`calc(${C} / 3)`,marginRight:`calc(${C} / 3)`}:{}},children:o})}),n!=null&&e.jsx("div",{style:{padding:v,...b.dividers?{borderTop:"1px solid var(--lucent-border-default)"}:{}},children:n})]})}function zr({children:t,style:r}){const{px:n}=c.useContext(ye);return e.jsx("div",{style:{marginLeft:`calc(-1 * ${n})`,marginRight:`calc(-1 * ${n})`,paddingLeft:n,paddingRight:n,...r},children:t})}const Er={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 `navigation`, `bgBase`, or `bgSubtle` on a Card — those tokens are reserved for the page chrome and content area.\n- Content nested inside a Card that needs a tinted fill should use `color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)` for accent-neutral insets.',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:"lg",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 inset box-shadow on the left edge of the card. Rendered as an inset shadow (same technique as NavMenu inverse highlight) so it naturally follows the card's border-radius. 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:"hoverable",type:"boolean",required:!1,description:"Enables hover lift (translateY -1px) and neutral glow shadow without making the card a button or link. Use when the card contains its own interactive content (e.g. a Collapsible trigger) and the whole card surface should hint at interactivity. Interactive cards (onClick/href) get accent-colored hover glow; hoverable-only cards get a neutral glow (12% text-primary)."},{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 media slot self-clips to the card's top border-radius. Cards without media default to overflow:visible so nested child shadows (e.g. an elevated Card inside a Collapsible) are never cut off."}],usageExamples:[{title:"Ghost — invisible container",code:`<Card variant="ghost">
|
|
237
251
|
<Text>Content sits directly on the page background.</Text>
|
|
238
252
|
</Card>`},{title:"Outline — bordered card (default)",code:`<Card
|
|
239
253
|
header={<Text weight="semibold">Card title</Text>}
|
|
@@ -289,11 +303,11 @@ const [results, setResults] = useState([]);
|
|
|
289
303
|
<Text size="sm" color="secondary">Two-tone: flat trigger on filled surface, content in elevated body.</Text>
|
|
290
304
|
</Card>
|
|
291
305
|
</Collapsible>
|
|
292
|
-
</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."}},
|
|
306
|
+
</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."}},Ar={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"}},qr=()=>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"})]}),Dr=()=>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"})]}),Rr=()=>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"})]}),Br=()=>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"})]}),Pr={info:e.jsx(qr,{}),success:e.jsx(Dr,{}),warning:e.jsx(Rr,{}),danger:e.jsx(Br,{})},Lr=()=>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 Fr({variant:t="info",title:r,children:n,onDismiss:o,icon:a,style:i}){const l=Ar[t],s=a??Pr[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:l.bg,border:`1px solid ${l.border}`,borderRadius:"var(--lucent-radius-md)",boxSizing:"border-box",...i},children:[e.jsx("span",{style:{flexShrink:0,color:l.iconColor,display:"flex",alignItems:"center",paddingTop:2},children:s}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)"},children:[r&&e.jsx(I.Text,{as:"span",size:"sm",weight:"semibold",color:l.textColor,lineHeight:"tight",children:r}),n&&e.jsx(I.Text,{as:"span",size:"sm",color:l.textColor,lineHeight:"base",children:n})]}),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:l.iconColor,opacity:.7},onMouseEnter:d=>{d.currentTarget.style.opacity="1"},onMouseLeave:d=>{d.currentTarget.style.opacity="0.7"},children:e.jsx(Lr,{})})]})}const Nr={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)}>
|
|
293
307
|
Check your card details and try again.
|
|
294
308
|
</Alert>`},{title:"Success confirmation",code:`<Alert variant="success" title="Order placed!">
|
|
295
309
|
You'll receive a confirmation email shortly.
|
|
296
|
-
</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
|
|
310
|
+
</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 $r({illustration:t,title:r,description:n,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(I.Text,{as:"h3",size:"lg",weight:"semibold",align:"center",lineHeight:"tight",children:r}),n&&e.jsx(I.Text,{size:"sm",color:"secondary",align:"center",lineHeight:"relaxed",children:n})]}),o!=null&&e.jsx("div",{children:o})]})}const Wr={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
|
|
297
311
|
illustration={<Icon size="xl"><SearchIcon /></Icon>}
|
|
298
312
|
title="No results found"
|
|
299
313
|
description="Try adjusting your search or filter to find what you're looking for."
|
|
@@ -304,18 +318,18 @@ const [results, setResults] = useState([]);
|
|
|
304
318
|
action={<Button variant="primary">New project</Button>}
|
|
305
319
|
/>`},{title:"Inside a Card",code:`<Card>
|
|
306
320
|
<EmptyState title="Nothing here" description="Add items to see them listed." />
|
|
307
|
-
</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."}}
|
|
321
|
+
</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."}},Or={text:"1em",circle:40,rectangle:40},Vr={text:"var(--lucent-radius-sm)",circle:"var(--lucent-radius-full)",rectangle:"var(--lucent-radius-md)"};function Ue({width:t,height:r,radius:n,animate:o,style:a}){return e.jsx("span",{style:{display:"block",width:typeof t=="number"?`${t}px`:t,height:typeof r=="number"?`${r}px`:r,borderRadius:n,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 Hr({variant:t="rectangle",width:r="100%",height:n,lines:o=1,animate:a=!0,radius:i,style:l}){const s=n??Or[t],d=i??Vr[t],p=a?e.jsx("style",{children:`
|
|
308
322
|
@keyframes lucent-skeleton-shimmer {
|
|
309
323
|
0% { background-position: 200% 0; }
|
|
310
324
|
100% { background-position: -200% 0; }
|
|
311
325
|
}
|
|
312
|
-
`}):null;return t==="text"&&o>1?e.jsxs(e.Fragment,{children:[p,e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)",...
|
|
326
|
+
`}):null;return t==="text"&&o>1?e.jsxs(e.Fragment,{children:[p,e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)",...l},children:Array.from({length:o}).map((h,f)=>e.jsx(Ue,{width:f===o-1?"70%":r,height:s,radius:d,animate:a},f))})]}):e.jsxs(e.Fragment,{children:[p,e.jsx(Ue,{width:t==="circle"?n??40:r,height:s,radius:d,animate:a,...l!==void 0&&{style:l}})]})}const Gr={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>
|
|
313
327
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
|
|
314
328
|
<Skeleton variant="rectangle" height={160} />
|
|
315
329
|
<Skeleton variant="text" lines={2} />
|
|
316
330
|
<Skeleton variant="text" width="40%" />
|
|
317
331
|
</div>
|
|
318
|
-
</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
|
|
332
|
+
</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 ft({items:t,separator:r="/",style:n,LinkComponent:o}){return e.jsx("nav",{"aria-label":"Breadcrumb",style:n,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((a,i)=>{const l=i===t.length-1,s={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)"},d=h=>{h.currentTarget.style.color="var(--lucent-text-primary)"},p=h=>{h.currentTarget.style.color="var(--lucent-text-secondary)"};return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[l?e.jsx(I.Text,{size:"sm",color:"primary",as:"span","aria-current":"page",children:a.label}):a.href!=null?o?e.jsx(o,{href:a.href,style:s,onMouseEnter:d,onMouseLeave:p,...a.onClick&&{onClick:a.onClick},children:a.label}):e.jsx("a",{href:a.href,onClick:a.onClick,style:s,onMouseEnter:d,onMouseLeave:p,children:a.label}):e.jsx("button",{onClick:a.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:h=>{h.currentTarget.style.color="var(--lucent-text-primary)"},onMouseLeave:h=>{h.currentTarget.style.color="var(--lucent-text-secondary)"},children:a.label}),!l&&e.jsx("span",{"aria-hidden":!0,style:{color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)",userSelect:"none"},children:r})]},i)})})})}const _e=80,mt=180,te="var(--lucent-easing-default)",Ae="var(--lucent-duration-fast)",Ye=`height ${mt}ms ${te}`,Ur=`
|
|
319
333
|
[data-lucent-collapsible-trigger]:hover:not(:disabled) {
|
|
320
334
|
background: color-mix(in srgb, var(--lucent-text-primary) 5%, transparent) !important;
|
|
321
335
|
}
|
|
@@ -325,7 +339,7 @@ const [results, setResults] = useState([]);
|
|
|
325
339
|
[data-lucent-collapsible-trigger]:focus-visible {
|
|
326
340
|
box-shadow: 0 0 0 2px var(--lucent-surface), 0 0 0 4px var(--lucent-accent-default) !important;
|
|
327
341
|
}
|
|
328
|
-
`;let _e=!1;function Ur(){if(_e||typeof document>"u")return;const t=document.createElement("style");t.setAttribute("data-lucent-collapsible",""),t.textContent=Gr,document.head.appendChild(t),_e=!0}function _r({trigger:t,children:r,defaultOpen:n=!1,open:o,onOpenChange:a,padded:i=!0,disabled:s=!1,style:l}){const d=c.useContext(ye),p=d.px!=="0"||d.py!=="0",m=o!==void 0,[f,w]=c.useState(n),y=m?o:f,g=c.useRef(null),h=c.useRef(!1),u=c.useRef();c.useEffect(Ur,[]),c.useEffect(()=>{h.current=!0},[]),c.useLayoutEffect(()=>{const x=g.current;if(x)if(y){x.style.overflow="hidden";const k=x.scrollHeight;x.style.height=`${k}px`,x.style.transition=Ue,clearTimeout(u.current),u.current=setTimeout(()=>{x.style.height="auto",x.style.overflow="visible",x.style.transition=""},dt+20)}else h.current&&(clearTimeout(u.current),x.style.overflow="hidden",x.style.transition="",x.style.height=`${x.scrollHeight}px`,x.getBoundingClientRect(),x.style.transition=Ue,x.style.height="0px")},[y]),c.useEffect(()=>{const x=g.current;x&&!y&&!h.current&&(x.style.height="0px")},[]),c.useEffect(()=>()=>clearTimeout(u.current),[]);const b=()=>{if(s)return;const x=!y;m||w(x),a==null||a(x)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",...p&&{margin:`calc(-1 * ${d.py}) calc(-1 * ${d.px})`},...l},children:[e.jsxs("button",{"data-lucent-collapsible-trigger":!0,onClick:b,disabled:s,"aria-expanded":y,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",borderRadius:"var(--lucent-radius-md)",padding:"var(--lucent-space-4)",cursor:s?"not-allowed":"pointer",textAlign:"left",outline:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",opacity:s?.5:1,transition:`background ${ze} ${te}`},children:[e.jsx("span",{style:{flex:1},children:t}),e.jsx(Yr,{open:y})]}),e.jsx("div",{ref:g,"aria-hidden":!y,style:{overflow:y?"visible":"hidden"},children:e.jsx("div",{style:{...i?{padding:"var(--lucent-space-3) var(--lucent-space-4) var(--lucent-space-4)"}:{},opacity:y?1:0,transform:y?"translateY(0)":"translateY(-4px)",transition:`opacity ${Ge}ms ${te}, transform ${Ge}ms ${te}`},children:r})})]})}function Yr({open:t}){return e.jsx("svg",{"data-lucent-collapsible-chevron":!0,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 ${ze} ${te}, color ${ze} ${te}`},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const oe="lucent-pl-no-scrollbar",Kr=`.${oe}{scrollbar-width:none}.${oe}::-webkit-scrollbar{display:none}`;function pe(t){return typeof t=="number"?`${t}px`:t}function Xr({children:t,header:r,sidebar:n,sidebarWidth:o=240,headerHeight:a=48,sidebarCollapsed:i=!1,rightSidebar:s,rightSidebarWidth:l=240,rightSidebarCollapsed:d=!1,footer:p,footerHeight:m=28,chromeBackground:f="navigation",mainStyle:w,style:y}){const g=pe(a),h=pe(o),u=pe(l),b=pe(m),k={navigation:"var(--lucent-navigation)",bgBase:"var(--lucent-bg-base)",bgSubtle:"var(--lucent-bg-subtle)",surface:"var(--lucent-surface)",surfaceSecondary:"var(--lucent-surface-secondary)"}[f]??"var(--lucent-navigation)";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",background:k,fontFamily:"var(--lucent-font-family-base)",...y},children:[e.jsx("style",{children:Kr}),r!=null&&e.jsx("div",{style:{flexShrink:0,height:g,zIndex:10,background:k},children:r}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[n!=null&&e.jsx("div",{className:oe,style:{width:i?0:h,flexShrink:0,overflow:"hidden",overflowY:i?"hidden":"auto",background:k,transition:"width 200ms var(--lucent-easing-default)"},children:n}),e.jsx("main",{className:oe,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-bg-base)",...w},children:t}),s!=null&&e.jsx("aside",{className:oe,style:{width:d?0:u,flexShrink:0,overflow:"hidden",overflowY:d?"hidden":"auto",background:k,transition:"width 200ms var(--lucent-easing-default)"},children:s})]}),p!=null&&e.jsx("div",{style:{flexShrink:0,height:b,zIndex:10,background:k},children:p})]})}function Jr({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 Ye({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 Zr({columns:t,rows:r,pageSize:n=10,page:o,onPageChange:a,onFilterChange:i,emptyState:s,style:l}){const[d,p]=c.useState(null),[m,f]=c.useState(0),[w,y]=c.useState(null),[g,h]=c.useState({}),u=o!==void 0,b=u?o:m,x=t.some(j=>j.filterable),k=x?r.filter(j=>t.every(P=>{if(!P.filterable)return!0;const D=g[P.key];if(!D||D.length===0)return!0;const W=String(j[P.key]??"");return D.includes(W)})):r,S=d?[...k].sort((j,P)=>{const D=j[d.key],W=P[d.key],q=String(D??"").localeCompare(String(W??""),void 0,{numeric:!0});return d.dir==="asc"?q:-q}):k,C=n>0?S.slice(b*n,(b+1)*n):S,v=n>0?Math.max(1,Math.ceil(S.length/n)):1,z=j=>{u||f(j),a==null||a(j)},T=j=>{p(P=>!P||P.key!==j?{key:j,dir:"asc"}:P.dir==="asc"?{key:j,dir:"desc"}:null),u||f(0),a==null||a(0)},E=(j,P)=>{const D={...g,[j]:P};P.length===0&&delete D[j],h(D),u||f(0),a==null||a(0),i==null||i(D)},F=()=>{h({}),u||f(0),a==null||a(0),i==null||i({})},R=[];if(v<=7)for(let j=0;j<v;j++)R.push(j);else{R.push(0),b>2&&R.push("…");for(let j=Math.max(1,b-1);j<=Math.min(v-2,b+1);j++)R.push(j);b<v-3&&R.push("…"),R.push(v-1)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...l},children:[x&&e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsx(Qr,{columns:t,rows:r,filters:g,onFilter:E,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 P=(d==null?void 0:d.key)===j.key?d.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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",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(Jr,{state:P}),j.headerFilter&&e.jsx("span",{onClick:D=>D.stopPropagation(),style:{display:"inline-flex",marginLeft:"var(--lucent-space-1)"},children:j.headerFilter})]})},j.key)})})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,style:{padding:"var(--lucent-space-12)",textAlign:"center"},children:s??e.jsx(I.Text,{color:"secondary",children:"No data"})})}):C.map((j,P)=>e.jsx("tr",{onMouseEnter:()=>y(P),onMouseLeave:()=>y(null),style:{borderBottom:P<C.length-1?"1px solid var(--lucent-border-subtle)":"none",background:w===P?"color-mix(in srgb, var(--lucent-text-primary) 4%, transparent)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t.map(D=>e.jsx("td",{style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",color:"var(--lucent-text-primary)",textAlign:D.align??"left",verticalAlign:"middle"},children:D.render?D.render(j,P):String(j[D.key]??"")},D.key))},P))})]})}),n>0&&S.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--lucent-space-3)",flexWrap:"wrap"},children:[e.jsx(I.Text,{color:"secondary",size:"sm",children:S.length===0?`0 rows${r.length>0?` (filtered from ${r.length})`:""}`:S.length===1?`1 row${S.length<r.length?` (filtered from ${r.length})`:""}`:`${b*n+1}–${Math.min((b+1)*n,S.length)} of ${S.length} rows${S.length<r.length?` (filtered from ${r.length})`:""}`}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[e.jsx(ke,{onClick:()=>z(b-1),disabled:b===0,"aria-label":"Previous page",children:e.jsx(Ye,{dir:"left"})}),R.map((j,P)=>j==="…"?e.jsx("span",{style:{padding:"0 var(--lucent-space-1)",color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)"},children:"…"},`ellipsis-${P}`):e.jsx(ke,{onClick:()=>z(j),active:j===b,"aria-label":`Page ${j+1}`,"aria-current":j===b?"page":void 0,children:j+1},j)),e.jsx(ke,{onClick:()=>z(b+1),disabled:b>=v-1,"aria-label":"Next page",children:e.jsx(Ye,{dir:"right"})})]})]})]})}function Qr({columns:t,rows:r,filters:n,onFilter:o,onClearAll:a}){const i=t.filter(l=>l.filterable),s=Object.keys(n).length;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",flexWrap:"wrap"},children:[i.map(l=>{const d=Array.from(new Set(r.map(p=>String(p[l.key]??"")))).sort();return e.jsx(ea,{label:l.header,values:d,value:n[l.key]??[],onChange:p=>o(l.key,p)},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 ea({label:t,values:r,value:n,onChange:o}){const[a,i]=c.useState(!1),[s,l]=c.useState(!1),[d,p]=c.useState(""),m=c.useRef(null),f=c.useRef(null),w=n.length>0;c.useEffect(()=>{if(!a){p("");return}setTimeout(()=>{var x;return(x=f.current)==null?void 0:x.focus()},0);const u=x=>{m.current&&!m.current.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",b)}},[a]);const y=d?r.filter(u=>u.toLowerCase().includes(d.toLowerCase())):r,g=u=>o(n.includes(u)?n.filter(b=>b!==u):[...n,u]),h=n.length===0?null:n.length===1?e.jsxs("span",{style:{color:"var(--lucent-text-secondary)",fontWeight:"var(--lucent-font-weight-regular)"},children:[": ",n[0]]}):e.jsxs("span",{style:{color:"var(--lucent-accent-default)"},children:["(",n.length,")"]});return e.jsxs("div",{ref:m,style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>i(u=>!u),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 ${w?"var(--lucent-accent-default)":s?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,background:w?"var(--lucent-accent-subtle)":"var(--lucent-surface)",color:w?"var(--lucent-accent-default)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:w?"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,h,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:f,type:"text",value:d,onChange:u=>p(u.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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",outline:"none"}})}),n.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:y.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"}):y.map(u=>e.jsx(ta,{label:u,isSelected:n.includes(u),onClick:()=>g(u)},u))})]})]})}function ta({label:t,isSelected:r,onClick:n}){const[o,a]=c.useState(!1);return e.jsxs("button",{onClick:n,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?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:r?"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 ${r?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:r?"var(--lucent-accent-default)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color var(--lucent-duration-fast), background var(--lucent-duration-fast)"},children:r&&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-accent-fg)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t]})}function ke({children:t,onClick:r,disabled:n,active:o,...a}){const[i,s]=c.useState(!1);return e.jsx("button",{...a,onClick:r,disabled:n,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&&!n?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:o?"var(--lucent-accent-fg)":n?"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:n?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t})}const na={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
|
|
342
|
+
`;let Ke=!1;function _r(){if(Ke||typeof document>"u")return;const t=document.createElement("style");t.setAttribute("data-lucent-collapsible",""),t.textContent=Ur,document.head.appendChild(t),Ke=!0}function Yr({trigger:t,children:r,defaultOpen:n=!1,open:o,onOpenChange:a,padded:i=!0,disabled:l=!1,style:s}){const d=c.useContext(ye),p=d.px!=="0"||d.py!=="0",h=o!==void 0,[f,w]=c.useState(n),y=h?o:f,g=c.useRef(null),m=c.useRef(!1),u=c.useRef();c.useEffect(_r,[]),c.useEffect(()=>{m.current=!0},[]),c.useLayoutEffect(()=>{const x=g.current;if(x)if(y){x.style.overflow="hidden";const k=x.scrollHeight;x.style.height=`${k}px`,x.style.transition=Ye,clearTimeout(u.current),u.current=setTimeout(()=>{x.style.height="auto",x.style.overflow="visible",x.style.transition=""},mt+20)}else m.current&&(clearTimeout(u.current),x.style.overflow="hidden",x.style.transition="",x.style.height=`${x.scrollHeight}px`,x.getBoundingClientRect(),x.style.transition=Ye,x.style.height="0px")},[y]),c.useEffect(()=>{const x=g.current;x&&!y&&!m.current&&(x.style.height="0px")},[]),c.useEffect(()=>()=>clearTimeout(u.current),[]);const b=()=>{if(l)return;const x=!y;h||w(x),a==null||a(x)};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-md)",...p&&{margin:`calc(-1 * ${d.py}) calc(-1 * ${d.px})`},...s},children:[e.jsxs("button",{"data-lucent-collapsible-trigger":!0,onClick:b,disabled:l,"aria-expanded":y,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",background:"none",border:"none",borderRadius:"var(--lucent-radius-md)",padding:"var(--lucent-space-4)",cursor:l?"not-allowed":"pointer",textAlign:"left",outline:"none",color:"inherit",fontFamily:"inherit",fontSize:"inherit",opacity:l?.5:1,transition:`background ${Ae} ${te}`},children:[e.jsx("span",{style:{flex:1},children:t}),e.jsx(Kr,{open:y})]}),e.jsx("div",{ref:g,"aria-hidden":!y,style:{overflow:y?"visible":"hidden"},children:e.jsx("div",{style:{...i?{padding:"var(--lucent-space-3) var(--lucent-space-4) var(--lucent-space-4)"}:{},opacity:y?1:0,transform:y?"translateY(0)":"translateY(-4px)",transition:`opacity ${_e}ms ${te}, transform ${_e}ms ${te}`},children:r})})]})}function Kr({open:t}){return e.jsx("svg",{"data-lucent-collapsible-chevron":!0,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 ${Ae} ${te}, color ${Ae} ${te}`},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}const oe="lucent-pl-no-scrollbar",Xr=`.${oe}{scrollbar-width:none}.${oe}::-webkit-scrollbar{display:none}`;function pe(t){return typeof t=="number"?`${t}px`:t}function Jr({children:t,header:r,sidebar:n,sidebarWidth:o=240,headerHeight:a=48,sidebarCollapsed:i=!1,rightSidebar:l,rightSidebarWidth:s=240,rightSidebarCollapsed:d=!1,footer:p,footerHeight:h=28,chromeBackground:f="navigation",mainStyle:w,style:y}){const g=pe(a),m=pe(o),u=pe(s),b=pe(h),k={navigation:"var(--lucent-navigation)",bgBase:"var(--lucent-bg-base)",bgSubtle:"var(--lucent-bg-subtle)",surface:"var(--lucent-surface)",surfaceSecondary:"var(--lucent-surface-secondary)"}[f]??"var(--lucent-navigation)";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",background:k,fontFamily:"var(--lucent-font-family-base)",...y},children:[e.jsx("style",{children:Xr}),r!=null&&e.jsx("div",{style:{flexShrink:0,height:g,zIndex:10,background:k},children:r}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[n!=null&&e.jsx("div",{className:oe,style:{width:i?0:m,flexShrink:0,overflow:"hidden",overflowY:i?"hidden":"auto",background:k,transition:"width 200ms var(--lucent-easing-default)"},children:n}),e.jsx("main",{className:oe,style:{flex:1,overflowY:"auto",minWidth:0,margin:l!=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-bg-base)",...w},children:t}),l!=null&&e.jsx("aside",{className:oe,style:{width:d?0:u,flexShrink:0,overflow:"hidden",overflowY:d?"hidden":"auto",background:k,transition:"width 200ms var(--lucent-easing-default)"},children:l})]}),p!=null&&e.jsx("div",{style:{flexShrink:0,height:b,zIndex:10,background:k},children:p})]})}function Zr({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 Xe({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 Qr({columns:t,rows:r,pageSize:n=10,page:o,onPageChange:a,onFilterChange:i,emptyState:l,style:s}){const[d,p]=c.useState(null),[h,f]=c.useState(0),[w,y]=c.useState(null),[g,m]=c.useState({}),u=o!==void 0,b=u?o:h,x=t.some(j=>j.filterable),k=x?r.filter(j=>t.every(P=>{if(!P.filterable)return!0;const D=g[P.key];if(!D||D.length===0)return!0;const W=String(j[P.key]??"");return D.includes(W)})):r,S=d?[...k].sort((j,P)=>{const D=j[d.key],W=P[d.key],q=String(D??"").localeCompare(String(W??""),void 0,{numeric:!0});return d.dir==="asc"?q:-q}):k,C=n>0?S.slice(b*n,(b+1)*n):S,v=n>0?Math.max(1,Math.ceil(S.length/n)):1,z=j=>{u||f(j),a==null||a(j)},T=j=>{p(P=>!P||P.key!==j?{key:j,dir:"asc"}:P.dir==="asc"?{key:j,dir:"desc"}:null),u||f(0),a==null||a(0)},E=(j,P)=>{const D={...g,[j]:P};P.length===0&&delete D[j],m(D),u||f(0),a==null||a(0),i==null||i(D)},F=()=>{m({}),u||f(0),a==null||a(0),i==null||i({})},R=[];if(v<=7)for(let j=0;j<v;j++)R.push(j);else{R.push(0),b>2&&R.push("…");for(let j=Math.max(1,b-1);j<=Math.min(v-2,b+1);j++)R.push(j);b<v-3&&R.push("…"),R.push(v-1)}return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...s},children:[x&&e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsx(ea,{columns:t,rows:r,filters:g,onFilter:E,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 P=(d==null?void 0:d.key)===j.key?d.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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",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(Zr,{state:P}),j.headerFilter&&e.jsx("span",{onClick:D=>D.stopPropagation(),style:{display:"inline-flex",marginLeft:"var(--lucent-space-1)"},children:j.headerFilter})]})},j.key)})})}),e.jsx("tbody",{children:C.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,style:{padding:"var(--lucent-space-12)",textAlign:"center"},children:l??e.jsx(I.Text,{color:"secondary",children:"No data"})})}):C.map((j,P)=>e.jsx("tr",{onMouseEnter:()=>y(P),onMouseLeave:()=>y(null),style:{borderBottom:P<C.length-1?"1px solid var(--lucent-border-subtle)":"none",background:w===P?"color-mix(in srgb, var(--lucent-text-primary) 4%, transparent)":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t.map(D=>e.jsx("td",{style:{padding:"var(--lucent-space-3) var(--lucent-space-4)",color:"var(--lucent-text-primary)",textAlign:D.align??"left",verticalAlign:"middle"},children:D.render?D.render(j,P):String(j[D.key]??"")},D.key))},P))})]})}),n>0&&S.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--lucent-space-3)",flexWrap:"wrap"},children:[e.jsx(I.Text,{color:"secondary",size:"sm",children:S.length===0?`0 rows${r.length>0?` (filtered from ${r.length})`:""}`:S.length===1?`1 row${S.length<r.length?` (filtered from ${r.length})`:""}`:`${b*n+1}–${Math.min((b+1)*n,S.length)} of ${S.length} rows${S.length<r.length?` (filtered from ${r.length})`:""}`}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[e.jsx(ke,{onClick:()=>z(b-1),disabled:b===0,"aria-label":"Previous page",children:e.jsx(Xe,{dir:"left"})}),R.map((j,P)=>j==="…"?e.jsx("span",{style:{padding:"0 var(--lucent-space-1)",color:"var(--lucent-text-disabled)",fontSize:"var(--lucent-font-size-sm)"},children:"…"},`ellipsis-${P}`):e.jsx(ke,{onClick:()=>z(j),active:j===b,"aria-label":`Page ${j+1}`,"aria-current":j===b?"page":void 0,children:j+1},j)),e.jsx(ke,{onClick:()=>z(b+1),disabled:b>=v-1,"aria-label":"Next page",children:e.jsx(Xe,{dir:"right"})})]})]})]})}function ea({columns:t,rows:r,filters:n,onFilter:o,onClearAll:a}){const i=t.filter(s=>s.filterable),l=Object.keys(n).length;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",flexWrap:"wrap"},children:[i.map(s=>{const d=Array.from(new Set(r.map(p=>String(p[s.key]??"")))).sort();return e.jsx(ta,{label:s.header,values:d,value:n[s.key]??[],onChange:p=>o(s.key,p)},s.key)}),l>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 ta({label:t,values:r,value:n,onChange:o}){const[a,i]=c.useState(!1),[l,s]=c.useState(!1),[d,p]=c.useState(""),h=c.useRef(null),f=c.useRef(null),w=n.length>0;c.useEffect(()=>{if(!a){p("");return}setTimeout(()=>{var x;return(x=f.current)==null?void 0:x.focus()},0);const u=x=>{h.current&&!h.current.contains(x.target)&&i(!1)},b=x=>{x.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",b),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",b)}},[a]);const y=d?r.filter(u=>u.toLowerCase().includes(d.toLowerCase())):r,g=u=>o(n.includes(u)?n.filter(b=>b!==u):[...n,u]),m=n.length===0?null:n.length===1?e.jsxs("span",{style:{color:"var(--lucent-text-secondary)",fontWeight:"var(--lucent-font-weight-regular)"},children:[": ",n[0]]}):e.jsxs("span",{style:{color:"var(--lucent-accent-default)"},children:["(",n.length,")"]});return e.jsxs("div",{ref:h,style:{position:"relative"},children:[e.jsxs("button",{onClick:()=>i(u=>!u),onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!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 ${w?"var(--lucent-accent-default)":l?"var(--lucent-border-strong)":"var(--lucent-border-default)"}`,background:w?"var(--lucent-accent-subtle)":"var(--lucent-surface)",color:w?"var(--lucent-accent-default)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:w?"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,m,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:f,type:"text",value:d,onChange:u=>p(u.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:"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",outline:"none"}})}),n.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:y.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"}):y.map(u=>e.jsx(na,{label:u,isSelected:n.includes(u),onClick:()=>g(u)},u))})]})]})}function na({label:t,isSelected:r,onClick:n}){const[o,a]=c.useState(!1);return e.jsxs("button",{onClick:n,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?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:r?"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 ${r?"var(--lucent-accent-default)":"var(--lucent-border-strong)"}`,background:r?"var(--lucent-accent-default)":"transparent",display:"flex",alignItems:"center",justifyContent:"center",transition:"border-color var(--lucent-duration-fast), background var(--lucent-duration-fast)"},children:r&&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-accent-fg)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),t]})}function ke({children:t,onClick:r,disabled:n,active:o,...a}){const[i,l]=c.useState(!1);return e.jsx("button",{...a,onClick:r,disabled:n,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!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&&!n?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:o?"var(--lucent-accent-fg)":n?"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:n?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:t})}const ra={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
|
|
329
343
|
columns={[
|
|
330
344
|
{ key: 'name', header: 'Name', sortable: true },
|
|
331
345
|
{ key: 'role', header: 'Role', sortable: true },
|
|
@@ -347,12 +361,12 @@ const [results, setResults] = useState([]);
|
|
|
347
361
|
pageSize={20}
|
|
348
362
|
page={page}
|
|
349
363
|
onPageChange={setPage}
|
|
350
|
-
/>`},{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.'}},
|
|
364
|
+
/>`},{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.'}},aa=`
|
|
351
365
|
@keyframes lucent-palette-in {
|
|
352
366
|
from { opacity: 0; transform: scale(0.96) translateY(-8px); }
|
|
353
367
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
354
368
|
}
|
|
355
|
-
`;function
|
|
369
|
+
`;function oa(t,r){var o;const n=r.toLowerCase();return t.label.toLowerCase().includes(n)||(((o=t.description)==null?void 0:o.toLowerCase().includes(n))??!1)}function ia({commands:t,placeholder:r="Search commands…",shortcutKey:n="k",open:o,onOpenChange:a,style:i}){const l=o!==void 0,[s,d]=c.useState(!1),p=l?o:s,[h,f]=c.useState(""),[w,y]=c.useState(0),g=c.useRef(null),m=c.useRef(null),u=c.useRef(!1);if(!u.current){const T=document.createElement("style");T.textContent=aa,document.head.appendChild(T),u.current=!0}const b=c.useCallback(T=>{l||d(T),a==null||a(T)},[l,a]);c.useEffect(()=>{const T=E=>{(E.metaKey||E.ctrlKey)&&E.key===n&&(E.preventDefault(),b(!p))};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[p,n,b]),c.useEffect(()=>{p&&(f(""),y(0),setTimeout(()=>{var T;return(T=g.current)==null?void 0:T.focus()},10))},[p]);const x=h?t.filter(T=>oa(T,h)):t,k=x.filter(T=>!T.disabled);c.useEffect(()=>{const T=m.current;if(!T)return;const E=T.querySelector('[data-active="true"]');E==null||E.scrollIntoView({block:"nearest"})},[w]);const S=T=>{T.disabled||(T.onSelect(),b(!1))},C=T=>{if(T.key==="Escape"){b(!1);return}if(T.key==="ArrowDown")T.preventDefault(),k.length>0&&y(E=>(E+1)%k.length);else if(T.key==="ArrowUp")T.preventDefault(),k.length>0&&y(E=>(E-1+k.length)%k.length);else if(T.key==="Enter"){const E=k[w];E&&S(E)}},v=[];for(const T of x){const E=v[v.length-1];E&&E.group===T.group?E.items.push(T):v.push({group:T.group,items:[T]})}if(!p)return null;let z=0;return e.jsx("div",{role:"dialog","aria-label":"Command palette","aria-modal":"true",onClick:()=>b(!1),style:{position:"fixed",inset:0,zIndex:9e3,display:"flex",alignItems:"flex-start",justifyContent:"center",paddingTop:"15vh",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",background:"rgba(0, 0, 0, 0.15)",...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:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",borderRadius:"var(--lucent-radius-xl)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), 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:x.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:g,role:"searchbox","aria-autocomplete":"list","aria-controls":"lucent-command-list",value:h,onChange:T=>{f(T.target.value),y(0)},onKeyDown:C,placeholder:r,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(I.Button,{size:"xs",variant:"outline",tabIndex:-1,style:{pointerEvents:"none",flexShrink:0},children:"Esc"})]}),e.jsx("div",{id:"lucent-command-list",role:"listbox",ref:m,style:{maxHeight:360,overflowY:"auto",padding:"var(--lucent-space-1) var(--lucent-space-2)"},children:x.length===0?e.jsx("div",{style:{padding:"var(--lucent-space-8)",textAlign:"center"},children:e.jsxs(I.Text,{color:"secondary",children:['No results for "',h,'"']})}):v.map(({group:T,items:E},F)=>e.jsxs("div",{children:[T&&e.jsx("div",{style:{padding:"var(--lucent-space-2) var(--lucent-space-2) var(--lucent-space-1)",...F>0?{borderTop:"1px solid var(--lucent-border-subtle)",marginTop:"var(--lucent-space-2)"}:{}},children:e.jsx(I.Text,{size:"xs",color:"secondary",weight:"medium",children:T})}),E.map(R=>{const j=R.disabled??!1;let P=!1;return j||(P=z===w,z++),e.jsxs("div",{role:"option","aria-selected":P,"aria-disabled":j,"data-active":P,onClick:()=>S(R),onMouseEnter:()=>{if(!j){const D=k.indexOf(R);D!==-1&&y(D)}},style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-3)",padding:"var(--lucent-space-2) var(--lucent-space-3)",borderRadius:"var(--lucent-radius-md)",cursor:j?"not-allowed":"pointer",background:P?"color-mix(in srgb, var(--lucent-accent-default) 20%, var(--lucent-surface-secondary))":"transparent",transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)",opacity:j?.5:1},children:[R.icon&&e.jsx("span",{style:{flexShrink:0,color:"var(--lucent-text-secondary)",display:"flex"},children:R.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx(I.Text,{size:"sm",weight:"medium",truncate:!0,children:R.label}),R.description&&e.jsx(I.Text,{size:"xs",color:"secondary",truncate:!0,children:R.description})]})]},R.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,E])=>e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-1)"},children:[e.jsx(I.Button,{size:"xs",variant:"outline",tabIndex:-1,style:{pointerEvents:"none"},children:T}),e.jsx(I.Text,{size:"xs",color:"secondary",children:E})]},T))})]})})}const sa={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
|
|
356
370
|
commands={[
|
|
357
371
|
{ id: 'new', label: 'New document', icon: <PlusIcon />, onSelect: () => router.push('/new') },
|
|
358
372
|
{ id: 'settings', label: 'Settings', description: 'Open app settings', onSelect: () => router.push('/settings') },
|
|
@@ -367,7 +381,7 @@ const [results, setResults] = useState([]);
|
|
|
367
381
|
onOpenChange={setOpen}
|
|
368
382
|
shortcutKey="p"
|
|
369
383
|
/>
|
|
370
|
-
</>`}],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.'}},
|
|
384
|
+
</>`}],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.'}},la={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)"},ca={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-lg)"},da={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)"},he={sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},Se={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Je={sm:"sm",md:"md",lg:"lg"},ua={sm:"sm",md:"md",lg:"lg"};function pa({options:t,value:r,defaultValue:n=[],onChange:o,placeholder:a="Select…",disabled:i=!1,max:l,size:s="md",label:d,helperText:p,errorText:h,style:f}){const w=r!==void 0,[y,g]=c.useState(n),m=w?r:y,[u,b]=c.useState(!1),[x,k]=c.useState(""),[S,C]=c.useState(0),[v,z]=c.useState(!1),T=c.useRef(null),E=c.useRef(null),F=c.useRef(null),R=c.useRef(null),[j,P]=c.useState({top:0,left:0,width:0}),D=c.useId();c.useEffect(()=>{if(!u)return;const L=G=>{var U,Z;!((U=T.current)!=null&&U.contains(G.target))&&!((Z=R.current)!=null&&Z.contains(G.target))&&(b(!1),k(""))};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[u]),c.useLayoutEffect(()=>{if(!u||!F.current)return;const L=F.current.getBoundingClientRect();P({top:L.bottom+4,left:L.left,width:L.width})},[u,m,x]);const W=L=>{const G=m.includes(L)?m.filter(U=>U!==L):l!==void 0&&m.length>=l?m:[...m,L];w||g(G),o==null||o(G)},q=L=>{const G=m.filter(U=>U!==L);w||g(G),o==null||o(G)},N=t.filter(L=>L.label.toLowerCase().includes(x.toLowerCase())),H=L=>{if(L.key==="Escape"){b(!1),k("");return}if(L.key==="ArrowDown"&&(L.preventDefault(),b(!0),C(G=>Math.min(G+1,N.length-1))),L.key==="ArrowUp"&&(L.preventDefault(),C(G=>Math.max(G-1,0))),L.key==="Enter"){L.preventDefault();const G=N[S];G&&!G.disabled&&W(G.value)}L.key==="Backspace"&&x===""&&m.length>0&&q(m[m.length-1])},A=l!==void 0&&m.length>=l,B=!!h,M=i?"var(--lucent-border-default)":B?"var(--lucent-danger-default)":v?"var(--lucent-accent-border)":"var(--lucent-border-default)",$=v?`0 0 0 3px ${B?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none",V=`lucent-multiselect-${c.useId()}`;return e.jsxs("div",{ref:T,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",...f},children:[d&&e.jsx("label",{htmlFor:V,style:{fontSize:Se[s],fontWeight:"var(--lucent-font-weight-medium)",color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),e.jsxs("div",{ref:F,children:[e.jsxs("div",{onClick:()=>{var L;i||(b(!0),(L=E.current)==null||L.focus())},style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:he[s],minHeight:la[s],boxSizing:"border-box",padding:da[s],borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${M}`,background:i?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"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:$},children:[m.map(L=>{const G=t.find(U=>U.value===L);return G?e.jsx(se,{size:ua[s],onDismiss:()=>q(L),disabled:i,children:G.label},L):null}),e.jsx("input",{id:V,ref:E,value:x,onChange:L=>{k(L.target.value),b(!0),C(0)},onKeyDown:H,onFocus:()=>z(!0),onBlur:()=>z(!1),disabled:i,placeholder:m.length===0?a:"","aria-autocomplete":"list","aria-controls":D,"aria-expanded":u,"aria-describedby":B?`${V}-error`:p?`${V}-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:ca[s],color:i?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",cursor:i?"not-allowed":"text",padding:m.length===0?"2px 0 2px var(--lucent-space-1)":"2px 0"}})]}),u&&!i&&J.createPortal(e.jsxs("div",{ref:R,id:D,role:"listbox","aria-multiselectable":"true",style:{position:"fixed",top:j.top,left:j.left,width:j.width,zIndex:1e3,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",maxHeight:240,overflowY:"auto",padding:he[s]},children:[N.length===0?e.jsx("div",{style:{padding:"var(--lucent-space-2)"},children:e.jsx(I.Text,{color:"secondary",size:Je[s],children:"No options"})}):N.map((L,G)=>{const U=m.includes(L.value),Z=G===S,K=L.disabled??!1,O=A&&!U;return e.jsxs("div",{role:"option","aria-selected":U,"aria-disabled":K||O,onClick:()=>{!K&&!O&&W(L.value)},onMouseEnter:()=>C(G),style:{display:"flex",alignItems:"center",gap:he[s],padding:he[s],borderRadius:"var(--lucent-radius-md)",cursor:K||O?"not-allowed":"pointer",background:Z?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",opacity:K||O?.5:1},children:[e.jsx(be,{checked:U,disabled:K||O,size:s,style:{margin:0,pointerEvents:"none"},"aria-hidden":!0,readOnly:!0}),e.jsx(I.Text,{size:Je[s],children:L.label})]},L.value)}),A&&e.jsx("div",{style:{padding:"var(--lucent-space-2)",borderTop:"1px solid var(--lucent-border-subtle)"},children:e.jsxs(I.Text,{size:s==="lg"?"sm":"xs",color:"secondary",children:["Max ",l," selected"]})})]}),document.body)]}),B&&e.jsx("span",{id:`${V}-error`,role:"alert",style:{fontSize:Se[s],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:h}),!B&&p&&e.jsx("span",{id:`${V}-helper`,style:{fontSize:Se[s],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:p})]})}const ha={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
|
|
371
385
|
options={[
|
|
372
386
|
{ value: 'react', label: 'React' },
|
|
373
387
|
{ value: 'vue', label: 'Vue' },
|
|
@@ -381,14 +395,14 @@ const [results, setResults] = useState([]);
|
|
|
381
395
|
onChange={setTags}
|
|
382
396
|
max={3}
|
|
383
397
|
placeholder="Up to 3 tags"
|
|
384
|
-
/>`}],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 fa(t,r){return new Date(t,r+1,0).getDate()}function ha(t,r){return new Date(t,r,1).getDay()}function ge(t,r){return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()}function ve(t,r){return new Date(t.getFullYear(),t.getMonth(),t.getDate())<new Date(r.getFullYear(),r.getMonth(),r.getDate())}function Xe(t,r){return new Date(t.getFullYear(),t.getMonth(),t.getDate())>new Date(r.getFullYear(),r.getMonth(),r.getDate())}const ma=["January","February","March","April","May","June","July","August","September","October","November","December"],ga=["Su","Mo","Tu","We","Th","Fr","Sa"];function ie(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}const va={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)"},ba={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},Te={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},ya={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},xa={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"},wa={sm:28,md:32,lg:38},ka={sm:"var(--lucent-font-size-xs)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Sa={sm:"xs",md:"sm",lg:"md"},Ta={sm:"xs",md:"xs",lg:"sm"},Ca={sm:24,md:28,lg:32},Ia={sm:14,md:16,lg:18},ut={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-5)"},Ee={sm:220,md:260,lg:300};function Je({dir:t,onClick:r,disabled:n,size:o="md"}){const[a,i]=c.useState(!1),s=Ca[o],l=Ia[o];return e.jsx("button",{type:"button",onClick:r,disabled:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":t==="prev"?"Previous month":"Next month",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:s,height:s,border:"none",borderRadius:"var(--lucent-radius-md)",background:a&&!n?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:n?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",cursor:n?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:e.jsx("svg",{width:l,height:l,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 Ae({year:t,month:r,selected:n,today:o,min:a,max:i,onSelect:s,onPrevMonth:l,onNextMonth:d,highlightRange:p,onDayHover:m,size:f="md"}){const w=fa(t,r),y=ha(t,r),[g,h]=c.useState(null),u=[...Array(y).fill(null),...Array.from({length:w},(b,x)=>x+1)];for(;u.length%7!==0;)u.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(Je,{dir:"prev",onClick:l,size:f}),e.jsxs(I.Text,{weight:"medium",size:Sa[f],children:[ma[r]," ",t]}),e.jsx(Je,{dir:"next",onClick:d,size:f})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2,marginBottom:"var(--lucent-space-1)"},children:ga.map(b=>e.jsx("div",{style:{textAlign:"center"},children:e.jsx(I.Text,{size:Ta[f],color:"secondary",children:b})},b))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2},children:u.map((b,x)=>{if(!b)return e.jsx("div",{},x);const k=new Date(t,r,b),S=n?ge(k,n):!1,C=ge(k,o),v=(a?ve(k,a):!1)||(i?Xe(k,i):!1);let z=!1;return p!=null&&p.start&&(p!=null&&p.end)&&(z=!ve(k,p.start)&&!Xe(k,p.end)),e.jsx("button",{type:"button",disabled:v,onClick:()=>!v&&s(k),onMouseEnter:()=>{h(b),m==null||m(k)},onMouseLeave:()=>{h(null),m==null||m(null)},"aria-label":ie(k),"aria-pressed":S,style:{display:"flex",alignItems:"center",justifyContent:"center",height:wa[f],width:"100%",border:C&&!S?"1px solid var(--lucent-border-strong)":"1px solid transparent",borderRadius:"var(--lucent-radius-md)",background:S?"var(--lucent-accent-default)":z?"var(--lucent-accent-subtle)":g===b&&!v?"color-mix(in srgb, var(--lucent-accent-default) 14%, transparent)":"transparent",color:S?"var(--lucent-accent-fg)":v?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:ka[f],fontFamily:"var(--lucent-font-family-base)",fontWeight:C?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:v?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:b},x)})})]})}function ja({value:t,defaultValue:r,onChange:n,placeholder:o="Pick a date",disabled:a=!1,min:i,max:s,size:l="md",label:d,helperText:p,errorText:m,style:f}){const w=t!==void 0,[y,g]=c.useState(r),h=w?t:y,u=!!m,b=a,x=`lucent-datepicker-${Math.random().toString(36).slice(2,7)}`,k=new Date,[S,C]=c.useState((h??k).getFullYear()),[v,z]=c.useState((h??k).getMonth()),[T,E]=c.useState(!1),[F,R]=c.useState(!1),j=c.useRef(null),P=c.useRef(null),[D,W]=c.useState({top:0,left:0});c.useEffect(()=>{if(!T)return;const M=$=>{var V,L;!((V=j.current)!=null&&V.contains($.target))&&!((L=P.current)!=null&&L.contains($.target))&&E(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[T]),c.useLayoutEffect(()=>{if(!T||!j.current)return;const M=j.current.getBoundingClientRect();W({top:M.bottom+4,left:M.left})},[T]);const q=M=>{w||g(M),n==null||n(M),E(!1)},N=()=>{v===0?(z(11),C(M=>M-1)):z(M=>M-1)},H=()=>{v===11?(z(0),C(M=>M+1)):z(M=>M+1)},A=b?"transparent":u?"var(--lucent-danger-default)":F?"var(--lucent-accent-border)":"var(--lucent-border-default)",B=F?`0 0 0 3px ${u?"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)",...f},children:[d&&e.jsx("label",{htmlFor:x,style:{fontSize:Te[l],fontWeight:"var(--lucent-font-weight-medium)",color:b?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),e.jsxs("button",{type:"button",id:x,disabled:a,onClick:()=>!a&&E(M=>!M),onFocus:()=>R(!0),onBlur:()=>R(!1),"aria-haspopup":"dialog","aria-expanded":T,"aria-invalid":u,style:{display:"flex",alignItems:"center",gap:xa[l],width:"100%",height:va[l],boxSizing:"border-box",padding:`0 ${ya[l]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${A}`,boxShadow:B,background:b?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"var(--lucent-surface)",color:h?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:ba[l],cursor:b?"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:h?ie(h):o})]}),u&&e.jsx("span",{role:"alert",style:{fontSize:Te[l],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:m}),!u&&p&&e.jsx("span",{style:{fontSize:Te[l],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:p}),T&&J.createPortal(e.jsx("div",{ref:P,role:"dialog","aria-label":"Date picker",style:{position:"fixed",top:D.top,left:D.left,zIndex:1e3,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:ut[l],minWidth:Ee[l]},children:e.jsx(Ae,{year:S,month:v,...h!==void 0&&{selected:h},today:k,...i!==void 0&&{min:i},...s!==void 0&&{max:s},onSelect:q,onPrevMonth:N,onNextMonth:H,size:l})}),document.body)]})}const Ma={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>();
|
|
398
|
+
/>`}],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 fa(t,r){return new Date(t,r+1,0).getDate()}function ma(t,r){return new Date(t,r,1).getDay()}function ge(t,r){return t.getFullYear()===r.getFullYear()&&t.getMonth()===r.getMonth()&&t.getDate()===r.getDate()}function ve(t,r){return new Date(t.getFullYear(),t.getMonth(),t.getDate())<new Date(r.getFullYear(),r.getMonth(),r.getDate())}function Ze(t,r){return new Date(t.getFullYear(),t.getMonth(),t.getDate())>new Date(r.getFullYear(),r.getMonth(),r.getDate())}const ga=["January","February","March","April","May","June","July","August","September","October","November","December"],va=["Su","Mo","Tu","We","Th","Fr","Sa"];function ie(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}const ba={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)"},ya={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},Te={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},xa={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},wa={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"},ka={sm:28,md:32,lg:38},Sa={sm:"var(--lucent-font-size-xs)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"},Ta={sm:"xs",md:"sm",lg:"md"},Ca={sm:"xs",md:"xs",lg:"sm"},Ia={sm:24,md:28,lg:32},ja={sm:14,md:16,lg:18},gt={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-5)"},qe={sm:220,md:260,lg:300};function Qe({dir:t,onClick:r,disabled:n,size:o="md"}){const[a,i]=c.useState(!1),l=Ia[o],s=ja[o];return e.jsx("button",{type:"button",onClick:r,disabled:n,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":t==="prev"?"Previous month":"Next month",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:l,height:l,border:"none",borderRadius:"var(--lucent-radius-md)",background:a&&!n?"color-mix(in srgb, var(--lucent-text-primary) 5%, transparent)":"transparent",color:n?"var(--lucent-text-disabled)":"var(--lucent-text-secondary)",cursor:n?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:e.jsx("svg",{width:s,height:s,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 De({year:t,month:r,selected:n,today:o,min:a,max:i,onSelect:l,onPrevMonth:s,onNextMonth:d,highlightRange:p,onDayHover:h,size:f="md"}){const w=fa(t,r),y=ma(t,r),[g,m]=c.useState(null),u=[...Array(y).fill(null),...Array.from({length:w},(b,x)=>x+1)];for(;u.length%7!==0;)u.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(Qe,{dir:"prev",onClick:s,size:f}),e.jsxs(I.Text,{weight:"medium",size:Ta[f],children:[ga[r]," ",t]}),e.jsx(Qe,{dir:"next",onClick:d,size:f})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2,marginBottom:"var(--lucent-space-1)"},children:va.map(b=>e.jsx("div",{style:{textAlign:"center"},children:e.jsx(I.Text,{size:Ca[f],color:"secondary",children:b})},b))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:2},children:u.map((b,x)=>{if(!b)return e.jsx("div",{},x);const k=new Date(t,r,b),S=n?ge(k,n):!1,C=ge(k,o),v=(a?ve(k,a):!1)||(i?Ze(k,i):!1);let z=!1;return p!=null&&p.start&&(p!=null&&p.end)&&(z=!ve(k,p.start)&&!Ze(k,p.end)),e.jsx("button",{type:"button",disabled:v,onClick:()=>!v&&l(k),onMouseEnter:()=>{m(b),h==null||h(k)},onMouseLeave:()=>{m(null),h==null||h(null)},"aria-label":ie(k),"aria-pressed":S,style:{display:"flex",alignItems:"center",justifyContent:"center",height:ka[f],width:"100%",border:C&&!S?"1px solid var(--lucent-border-strong)":"1px solid transparent",borderRadius:"var(--lucent-radius-md)",background:S?"var(--lucent-accent-default)":z?"var(--lucent-accent-subtle)":g===b&&!v?"color-mix(in srgb, var(--lucent-accent-default) 14%, transparent)":"transparent",color:S?"var(--lucent-accent-fg)":v?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontSize:Sa[f],fontFamily:"var(--lucent-font-family-base)",fontWeight:C?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",cursor:v?"not-allowed":"pointer",transition:"background var(--lucent-duration-fast)"},children:b},x)})})]})}function Ma({value:t,defaultValue:r,onChange:n,placeholder:o="Pick a date",disabled:a=!1,min:i,max:l,size:s="md",label:d,helperText:p,errorText:h,style:f}){const w=t!==void 0,[y,g]=c.useState(r),m=w?t:y,u=!!h,b=a,x=`lucent-datepicker-${Math.random().toString(36).slice(2,7)}`,k=new Date,[S,C]=c.useState((m??k).getFullYear()),[v,z]=c.useState((m??k).getMonth()),[T,E]=c.useState(!1),[F,R]=c.useState(!1),j=c.useRef(null),P=c.useRef(null),[D,W]=c.useState({top:0,left:0});c.useEffect(()=>{if(!T)return;const M=$=>{var V,L;!((V=j.current)!=null&&V.contains($.target))&&!((L=P.current)!=null&&L.contains($.target))&&E(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[T]),c.useLayoutEffect(()=>{if(!T||!j.current)return;const M=j.current.getBoundingClientRect();W({top:M.bottom+4,left:M.left})},[T]);const q=M=>{w||g(M),n==null||n(M),E(!1)},N=()=>{v===0?(z(11),C(M=>M-1)):z(M=>M-1)},H=()=>{v===11?(z(0),C(M=>M+1)):z(M=>M+1)},A=b?"transparent":u?"var(--lucent-danger-default)":F?"var(--lucent-accent-border)":"var(--lucent-border-default)",B=F?`0 0 0 3px ${u?"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)",...f},children:[d&&e.jsx("label",{htmlFor:x,style:{fontSize:Te[s],fontWeight:"var(--lucent-font-weight-medium)",color:b?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),e.jsxs("button",{type:"button",id:x,disabled:a,onClick:()=>!a&&E(M=>!M),onFocus:()=>R(!0),onBlur:()=>R(!1),"aria-haspopup":"dialog","aria-expanded":T,"aria-invalid":u,style:{display:"flex",alignItems:"center",gap:wa[s],width:"100%",height:ba[s],boxSizing:"border-box",padding:`0 ${xa[s]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${A}`,boxShadow:B,background:b?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"var(--lucent-surface)",color:m?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:ya[s],cursor:b?"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:m?ie(m):o})]}),u&&e.jsx("span",{role:"alert",style:{fontSize:Te[s],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:h}),!u&&p&&e.jsx("span",{style:{fontSize:Te[s],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:p}),T&&J.createPortal(e.jsx("div",{ref:P,role:"dialog","aria-label":"Date picker",style:{position:"fixed",top:D.top,left:D.left,zIndex:1e3,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:gt[s],minWidth:qe[s]},children:e.jsx(De,{year:S,month:v,...m!==void 0&&{selected:m},today:k,...i!==void 0&&{min:i},...l!==void 0&&{max:l},onSelect:q,onPrevMonth:N,onNextMonth:H,size:s})}),document.body)]})}const za={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>();
|
|
385
399
|
<DatePicker
|
|
386
400
|
value={date}
|
|
387
401
|
onChange={setDate}
|
|
388
402
|
min={new Date()}
|
|
389
403
|
placeholder="Select a future date"
|
|
390
|
-
/>`}],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.'}},
|
|
391
|
-
<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
|
|
404
|
+
/>`}],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.'}},Ea={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)"},Aa={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-md)",lg:"var(--lucent-font-size-md)"},qa={sm:"var(--lucent-space-3)",md:"var(--lucent-space-4)",lg:"var(--lucent-space-4)"},Da={sm:"var(--lucent-space-2)",md:"calc((var(--lucent-space-2) + var(--lucent-space-3)) / 2)",lg:"var(--lucent-space-3)"},Ce={sm:"var(--lucent-font-size-sm)",md:"var(--lucent-font-size-sm)",lg:"var(--lucent-font-size-md)"};function Ra(t,r){return t?ge(t.start,t.end)?ie(t.start):`${ie(t.start)} → ${ie(t.end)}`:r}function vt({value:t,defaultValue:r,onChange:n,placeholder:o="Pick a date range",disabled:a=!1,min:i,max:l,size:s="md",label:d,helperText:p,errorText:h,trigger:f,style:w}){const y=t!==void 0,[g,m]=c.useState(r),u=y?t:g,b=!!h,x=a,k=`lucent-daterangepicker-${Math.random().toString(36).slice(2,7)}`,[S,C]=c.useState(null),[v,z]=c.useState(null),T=new Date,[E,F]=c.useState(((u==null?void 0:u.start)??T).getFullYear()),[R,j]=c.useState(((u==null?void 0:u.start)??T).getMonth()),P=R===11?0:R+1,D=R===11?E+1:E,[W,q]=c.useState(!1),[N,H]=c.useState(!1),A=c.useRef(null),B=c.useRef(null),[M,$]=c.useState({top:0,left:0});c.useEffect(()=>{if(!W)return;const O=Q=>{var ce,re;!((ce=A.current)!=null&&ce.contains(Q.target))&&!((re=B.current)!=null&&re.contains(Q.target))&&(q(!1),C(null))};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[W]),c.useLayoutEffect(()=>{if(!W||!A.current)return;const O=A.current.getBoundingClientRect();$({top:O.bottom+4,left:O.left})},[W]);const V=O=>{if(!S)C(O);else{const[Q,ce]=ve(O,S)||ge(O,S)?[O,S]:[S,O],re={start:Q,end:ce};y||m(re),n==null||n(re),C(null),q(!1)}},L=()=>{R===0?(j(11),F(O=>O-1)):j(O=>O-1)},G=()=>{R===11?(j(0),F(O=>O+1)):j(O=>O+1)};let U;if(S&&v){const[O,Q]=ve(v,S)?[v,S]:[S,v];U={start:O,end:Q}}else S?U={start:S,end:S}:u&&(U={start:u.start,end:u.end});const Z=x?"transparent":b?"var(--lucent-danger-default)":N?"var(--lucent-accent-border)":"var(--lucent-border-default)",K=N?`0 0 0 3px ${b?"var(--lucent-danger-subtle)":"var(--lucent-accent-subtle)"}`:"none";return e.jsxs("div",{ref:A,style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)",...w},children:[d&&e.jsx("label",{htmlFor:k,style:{fontSize:Ce[s],fontWeight:"var(--lucent-font-weight-medium)",color:x?"var(--lucent-text-disabled)":"var(--lucent-text-primary)",fontFamily:"var(--lucent-font-family-base)"},children:d}),f?e.jsx("span",{onClick:()=>!a&&q(O=>!O),"aria-haspopup":"dialog","aria-expanded":W,style:{display:"inline-flex",cursor:a?"not-allowed":"pointer"},children:f}):e.jsxs("button",{type:"button",id:k,disabled:a,onClick:()=>!a&&q(O=>!O),onFocus:()=>H(!0),onBlur:()=>H(!1),"aria-haspopup":"dialog","aria-expanded":W,"aria-invalid":b,style:{display:"flex",alignItems:"center",gap:Da[s],width:"100%",height:Ea[s],boxSizing:"border-box",padding:`0 ${qa[s]}`,borderRadius:"var(--lucent-radius-lg)",border:`1px solid ${Z}`,boxShadow:K,background:x?"color-mix(in srgb, var(--lucent-text-primary) 6%, transparent)":"var(--lucent-surface)",color:u?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)",fontSize:Aa[s],cursor:x?"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:Ra(u,o)})]}),b&&e.jsx("span",{role:"alert",style:{fontSize:Ce[s],color:"var(--lucent-danger-text)",fontFamily:"var(--lucent-font-family-base)"},children:h}),!b&&p&&e.jsx("span",{style:{fontSize:Ce[s],color:"var(--lucent-text-secondary)",fontFamily:"var(--lucent-font-family-base)"},children:p}),W&&J.createPortal(e.jsxs("div",{ref:B,role:"dialog","aria-label":"Date range picker",style:{position:"fixed",top:M.top,left:M.left,zIndex:1e3,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:gt[s],display:"flex",gap:"var(--lucent-space-6)"},children:[e.jsx("div",{style:{minWidth:qe[s]},children:e.jsx(De,{year:E,month:R,...(u==null?void 0:u.start)!==void 0&&{selected:u.start},today:T,...i!==void 0&&{min:i},...l!==void 0&&{max:l},onSelect:V,onPrevMonth:L,onNextMonth:G,...U!==void 0&&{highlightRange:U},...S&&{onDayHover:z},size:s})}),e.jsx("div",{style:{width:1,background:"var(--lucent-border-subtle)",flexShrink:0}}),e.jsx("div",{style:{minWidth:qe[s]},children:e.jsx(De,{year:D,month:P,...(u==null?void 0:u.end)!==void 0&&{selected:u.end},today:T,...i!==void 0&&{min:i},...l!==void 0&&{max:l},onSelect:V,onPrevMonth:L,onNextMonth:G,...U!==void 0&&{highlightRange:U},...S&&{onDayHover:z},size:s})})]}),document.body),S&&W&&e.jsx("div",{style:{position:"absolute",top:"calc(100% + var(--lucent-space-1))",left:0,zIndex:1001,pointerEvents:"none"}}),S&&W&&e.jsx("div",{style:{position:"absolute",bottom:-24,left:0},children:e.jsx(I.Text,{size:"xs",color:"secondary",children:"Now pick the end date"})})]})}const Ba={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>();
|
|
405
|
+
<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 Re(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Pa(){return Math.random().toString(36).slice(2)}function La({item:t,onRemove:r}){const[n,o]=c.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(I.Text,{size:"sm",truncate:!0,children:t.file.name}),i?e.jsx(I.Text,{size:"xs",color:"danger",children:t.error}):e.jsx(I.Text,{size:"xs",color:"secondary",children:Re(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:()=>r(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:n?"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 Fa({accept:t,multiple:r=!1,maxSize:n,value:o,onChange:a,onError:i,disabled:l=!1,style:s}){const d=o!==void 0,[p,h]=c.useState([]),f=d?o:p,[w,y]=c.useState(!1),[g,m]=c.useState(!1),u=c.useRef(null),b=c.useCallback(C=>{if(!C||l)return;const v=[];for(const T of Array.from(C)){if(n&&T.size>n){i==null||i(`"${T.name}" exceeds the ${Re(n)} limit.`);continue}if(!r&&f.length+v.length>=1)break;v.push({id:Pa(),file:T})}if(v.length===0)return;const z=r?[...f,...v]:v;d||h(z),a==null||a(z)},[l,f,d,n,r,a,i]),x=C=>{const v=f.filter(z=>z.id!==C);d||h(v),a==null||a(v)},k=C=>{C.preventDefault(),y(!1),b(C.dataTransfer.files)},S=C=>{b(C.target.files),C.target.value=""};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-3)",...s},children:[e.jsxs("div",{role:"button",tabIndex:l?-1:0,"aria-label":"Upload files","aria-disabled":l,onClick:()=>{var C;return!l&&((C=u.current)==null?void 0:C.click())},onKeyDown:C=>{var v;(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),(v=u.current)==null||v.click())},onFocus:()=>m(!0),onBlur:()=>m(!1),onDragOver:C=>{C.preventDefault(),l||y(!0)},onDragLeave:()=>y(!1),onDrop:k,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 ${l?"var(--lucent-border-default)":w||g?"var(--lucent-accent-default)":"var(--lucent-border-default)"}`,background:w?"var(--lucent-accent-subtle)":"var(--lucent-surface-secondary)",cursor:l?"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:l?"var(--lucent-text-disabled)":w?"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",width:"100%"},children:[e.jsx(I.Text,{color:l?"disabled":"primary",weight:"medium",align:"center",children:w?"Drop to upload":"Drop files here or click to browse"}),(t||n)&&e.jsx(I.Text,{size:"xs",color:"secondary",align:"center",children:[t&&`Accepted: ${t}`,n&&`Max size: ${Re(n)}`].filter(Boolean).join(" · ")})]}),e.jsx("input",{ref:u,type:"file",accept:t,multiple:r,disabled:l,onChange:S,style:{display:"none"},tabIndex:-1})]}),f.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--lucent-space-2)"},children:f.map(C=>e.jsx(La,{item:C,onRemove:x},C.id))})]})}const Na={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
|
|
392
406
|
multiple
|
|
393
407
|
accept="image/*,.pdf"
|
|
394
408
|
maxSize={5 * 1024 * 1024}
|
|
@@ -407,7 +421,7 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
407
421
|
}
|
|
408
422
|
};
|
|
409
423
|
|
|
410
|
-
<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.'}}
|
|
424
|
+
<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.'}},$a={default:"var(--lucent-text-disabled)",success:"var(--lucent-success-default)",warning:"var(--lucent-warning-default)",danger:"var(--lucent-danger-default)",info:"var(--lucent-info-default)"};function Wa({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.5 5.2l1.8 1.8L7.5 3.5",stroke:"#fff",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:"M3 3l4 4M7 3L3 7",stroke:"#fff",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 2.5v3M5 7.5v.01",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round"})}):t==="info"?e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none","aria-hidden":!0,children:[e.jsx("circle",{cx:"5",cy:"3",r:"0.75",fill:"#fff"}),e.jsx("path",{d:"M5 5v2.5",stroke:"#fff",strokeWidth:"1.5",strokeLinecap:"round"})]}):e.jsx("svg",{width:"6",height:"6",viewBox:"0 0 6 6","aria-hidden":!0,children:e.jsx("circle",{cx:"3",cy:"3",r:"3",fill:"#fff"})})}function Oa({items:t,style:r}){return e.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",...r},children:t.map((n,o)=>{const a=n.status??"default",i=$a[a],l=o===t.length-1;return e.jsxs("li",{style:{display:"flex",gap:"var(--lucent-space-3)",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0,width:20},children:[e.jsx("div",{style:{width:20,height:20,borderRadius:"var(--lucent-radius-full)",background:i,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,zIndex:1},children:n.icon??e.jsx(Wa,{status:a})}),!l&&e.jsx("div",{style:{flex:1,width:1.5,background:"var(--lucent-border-subtle)",minHeight:"var(--lucent-space-3)"}})]}),e.jsxs("div",{style:{flex:1,paddingBottom:l?0:"var(--lucent-space-5)",paddingTop:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"var(--lucent-space-2)",flexWrap:"wrap"},children:[e.jsx(I.Text,{weight:"medium",size:"sm",children:n.title}),n.date&&e.jsx(I.Text,{size:"xs",color:"secondary",children:n.date})]}),n.description&&e.jsx("div",{style:{marginTop:"var(--lucent-space-1)"},children:e.jsx(I.Text,{size:"sm",color:"secondary",children:n.description})}),n.content&&e.jsx("div",{style:{marginTop:"var(--lucent-space-3)"},children:n.content})]})]},n.id)})})}const Va={id:"timeline",name:"Timeline",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A vertical activity feed with filled status dots, inline timestamps, optional nested content blocks, and custom icons.",designIntent:"Timeline renders as a semantic <ol> with each event as a <li>, preserving document order for assistive technologies. Dots are compact (20px) and filled with the status color, with white iconography for high contrast — this mirrors modern activity-feed patterns. Title and date sit inline (date follows title) to keep the eye on a single reading line, rather than splitting attention across the row. Each item supports an optional content slot for embedded blocks — comment cards, review notes, nested detail panels — placed below the title/description. The connector line is thin (1.5px) and omitted on the last item. Status colors follow the same semantic token set as Alert and Badge so danger/success/warning/info carry consistent meaning across the design system. 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 content (ReactNode for embedded blocks), 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
|
|
411
425
|
items={[
|
|
412
426
|
{ id: '1', title: 'Order placed', date: 'Mar 1, 2026', status: 'success' },
|
|
413
427
|
{ id: '2', title: 'Payment processed', date: 'Mar 1, 2026', status: 'success' },
|
|
@@ -432,7 +446,7 @@ const handleChange = async (updated: UploadFile[]) => {
|
|
|
432
446
|
{ id: '3', title: 'Resubmitted', date: 'Mar 28', status: 'info' },
|
|
433
447
|
{ id: '4', title: 'Approved', date: 'Mar 29', status: 'success' },
|
|
434
448
|
]}
|
|
435
|
-
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Event title, description, and date label",required:!0},{componentId:"card",componentName:"Card",role:"Container for nested content blocks in the content slot",required:!1}],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."}},ft=c.createContext(null);function Va(){const t=c.useContext(ft);if(!t)throw new Error("useToast must be used inside <ToastProvider>");return t}const Ha=()=>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"})]}),Ga=()=>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"})]}),Ua=()=>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"})]}),_a=()=>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"})]}),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"})}),Ka={info:e.jsx(Ha,{}),success:e.jsx(Ga,{}),warning:e.jsx(Ua,{}),danger:e.jsx(_a,{})},Xa={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 Ja=0;function Za(){return`lucent-toast-${++Ja}`}function ht(t){return t.startsWith("top")}const Qa=200,eo=8,to=.04,no=.2,ro=3,ao=356;function Ze({entry:t,onDismiss:r,hideContent:n,fixedHeight:o}){const{id:a,title:i,description:s,variant:l,action:d,icon:p}=t,m=Xa[l],f=p??(l!=="default"?Ka[l]:null),w=(d==null?void 0:d.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 ${m.border}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:n?"none":"var(--lucent-shadow-lg)",boxSizing:"border-box",width:ao,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:n?0:1,transition:"opacity var(--lucent-duration-base) var(--lucent-easing-default)"},children:[f&&e.jsx("span",{style:{flexShrink:0,color:m.iconColor,display:"flex",alignItems:"center"},children:f}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)"},children:[e.jsx(I.Text,{as:"span",size:"sm",weight:"semibold",color:"primary",lineHeight:"tight",children:i}),s&&e.jsx(I.Text,{as:"span",size:"sm",color:"secondary",lineHeight:"base",style:{whiteSpace:"pre-line"},children:s})]}),d&&w==="button"&&e.jsx(oo,{label:d.label,onClick:()=>{d.onClick(),r(a)}}),d&&w==="link"&&e.jsx(io,{label:d.label,iconColor:m.iconColor,onClick:()=>{d.onClick(),r(a)}}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(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:n?0:.6},onMouseEnter:y=>{n||(y.currentTarget.style.opacity="1")},onMouseLeave:y=>{n||(y.currentTarget.style.opacity="0.6")},children:e.jsx(Ya,{})})]})})}function oo({label:t,onClick:r}){return e.jsx("button",{type:"button",onClick:r,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:n=>{n.currentTarget.style.background="var(--lucent-surface-secondary)"},onMouseLeave:n=>{n.currentTarget.style.background="var(--lucent-surface)"},children:t})}function io({label:t,iconColor:r,onClick:n}){return e.jsx("button",{type:"button",onClick:n,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:r==="var(--lucent-text-secondary)"?"var(--lucent-accent-default)":r,textDecoration:"underline",textUnderlineOffset:2,whiteSpace:"nowrap"},children:t})}const Qe="var(--lucent-space-6)",so=40,lo=120;function co(t){const r={position:"fixed",zIndex:9999,pointerEvents:"none",boxSizing:"border-box"};return ht(t)?r.top=so:r.top=`calc(100vh - ${lo}px)`,t.endsWith("left")?r.left=Qe:t.endsWith("right")?r.right=Qe:(r.left="50%",r.transform="translateX(-50%)"),r}function uo({toasts:t,position:r,onDismiss:n,portalContainer:o}){const[a,i]=c.useState(!1),[s,l]=c.useState(void 0),d=c.useCallback(u=>{u&&l(u.offsetHeight)},[]),p=ht(r),m=t.filter(u=>u.phase!=="exiting"),f=t.filter(u=>u.phase==="exiting");c.useEffect(()=>{m.length<=1&&i(!1)},[m.length]);const w=c.useRef(null),y=c.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null),m.length>1&&i(!0)},[m.length]),g=c.useCallback(()=>{w.current=setTimeout(()=>{i(!1),w.current=null},150)},[]),h=e.jsx("div",{style:co(r),children:e.jsx("div",{onMouseEnter:y,onMouseLeave:g,style:{margin:"calc(-1 * var(--lucent-space-2))",padding:"var(--lucent-space-2)"},children:e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:p?"column-reverse":"column",gap:a?"var(--lucent-space-2)":0,transform:a&&!p?"translateY(-100%)":void 0,marginTop:a&&!p?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:[m.map((u,b)=>{const x=m.length-1-b,k=!a&&x>ro,S=x*eo,C=p?S:-S,v=a?1:1-x*to,z=a?1:Math.max(0,1-x*no),T=u.phase==="entering",E=x===0,F=!a&&!E;return e.jsx("div",{ref:E?d:void 0,role:"status","aria-live":"polite","aria-hidden":k,style:{position:E||a?"relative":"absolute",...!a&&!E&&(p?{bottom:0}:{top:0}),zIndex:100-x,transform:T?`translateY(${p?"-20px":"20px"}) scale(0.96)`:a?void 0:`translateY(${C}px) scaleX(${v})`,opacity:T||u.phase==="exiting"?0:z,transformOrigin:p?"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:k?"none":"auto",visibility:k?"hidden":"visible"},children:e.jsx(Ze,{entry:u,onDismiss:n,hideContent:F,...F&&s!==void 0&&{fixedHeight:s}})},u.id)}),f.map(u=>e.jsx("div",{role:"status","aria-live":"polite",style:{position:"absolute",...p?{bottom:0}:{top:0},zIndex:200,transform:`translateY(${p?"20px":"-20px"}) scale(0.96)`,opacity:0,transformOrigin:p?"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(Ze,{entry:u,onDismiss:n})},u.id))]})})});return J.createPortal(h,o??document.body)}function po({children:t,position:r="bottom-right",duration:n=5e3,max:o=5,portalContainer:a}){const[i,s]=c.useState([]),l=c.useCallback(m=>{s(f=>{const w=f.find(y=>y.id===m);return!w||w.phase==="exiting"?f:f.map(y=>y.id===m?{...y,phase:"exiting"}:y)}),setTimeout(()=>{s(f=>f.filter(w=>w.id!==m))},Qa)},[]),d=c.useCallback(m=>{const f=Za(),w={id:f,title:m.title,variant:m.variant??"default",duration:m.duration??n,...m.description!==void 0&&{description:m.description},...m.action!==void 0&&{action:m.action},...m.icon!==void 0&&{icon:m.icon},phase:"entering"};return s(y=>{const g=[...y,w],h=g.filter(u=>u.phase!=="exiting");if(h.length>o){const u=h.slice(0,h.length-o);for(const b of u)setTimeout(()=>l(b.id),0)}return g}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{s(y=>y.map(g=>g.id===f&&g.phase==="entering"?{...g,phase:"visible"}:g))})}),f},[n,o,l]);c.useEffect(()=>{const m=[];for(const f of i)if(f.phase==="visible"&&f.duration!==1/0){const w=setTimeout(()=>l(f.id),f.duration);m.push(w)}return()=>m.forEach(clearTimeout)},[i,l]);const p={toast:d,dismiss:l};return e.jsxs(ft.Provider,{value:p,children:[t,i.length>0&&e.jsx(uo,{toasts:i,position:r,onDismiss:l,...a!==void 0&&{portalContainer:a}})]})}const fo={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).
|
|
449
|
+
/>`}],compositionGraph:[{componentId:"text",componentName:"Text",role:"Event title, description, and date label",required:!0},{componentId:"card",componentName:"Card",role:"Container for nested content blocks in the content slot",required:!1}],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."}},bt=c.createContext(null);function Ha(){const t=c.useContext(bt);if(!t)throw new Error("useToast must be used inside <ToastProvider>");return t}const Ga=()=>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"})]}),Ua=()=>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"})]}),_a=()=>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"})]}),Ya=()=>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"})]}),Ka=()=>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"})}),Xa={info:e.jsx(Ga,{}),success:e.jsx(Ua,{}),warning:e.jsx(_a,{}),danger:e.jsx(Ya,{})},Ja={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 Za=0;function Qa(){return`lucent-toast-${++Za}`}function yt(t){return t.startsWith("top")}const eo=200,to=8,no=.04,ro=.2,ao=3,oo=356;function et({entry:t,onDismiss:r,hideContent:n,fixedHeight:o}){const{id:a,title:i,description:l,variant:s,action:d,icon:p}=t,h=Ja[s],f=p??(s!=="default"?Xa[s]:null),w=(d==null?void 0:d.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 ${h.border}`,borderRadius:"var(--lucent-radius-lg)",boxShadow:n?"none":"var(--lucent-shadow-lg)",boxSizing:"border-box",width:oo,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:n?0:1,transition:"opacity var(--lucent-duration-base) var(--lucent-easing-default)"},children:[f&&e.jsx("span",{style:{flexShrink:0,color:h.iconColor,display:"flex",alignItems:"center"},children:f}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"var(--lucent-space-1)"},children:[e.jsx(I.Text,{as:"span",size:"sm",weight:"semibold",color:"primary",lineHeight:"tight",children:i}),l&&e.jsx(I.Text,{as:"span",size:"sm",color:"secondary",lineHeight:"base",style:{whiteSpace:"pre-line"},children:l})]}),d&&w==="button"&&e.jsx(io,{label:d.label,onClick:()=>{d.onClick(),r(a)}}),d&&w==="link"&&e.jsx(so,{label:d.label,iconColor:h.iconColor,onClick:()=>{d.onClick(),r(a)}}),e.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>r(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:n?0:.6},onMouseEnter:y=>{n||(y.currentTarget.style.opacity="1")},onMouseLeave:y=>{n||(y.currentTarget.style.opacity="0.6")},children:e.jsx(Ka,{})})]})})}function io({label:t,onClick:r}){return e.jsx("button",{type:"button",onClick:r,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:n=>{n.currentTarget.style.background="var(--lucent-surface-secondary)"},onMouseLeave:n=>{n.currentTarget.style.background="var(--lucent-surface)"},children:t})}function so({label:t,iconColor:r,onClick:n}){return e.jsx("button",{type:"button",onClick:n,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:r==="var(--lucent-text-secondary)"?"var(--lucent-accent-default)":r,textDecoration:"underline",textUnderlineOffset:2,whiteSpace:"nowrap"},children:t})}const tt="var(--lucent-space-6)",lo=40,co=120;function uo(t){const r={position:"fixed",zIndex:9999,pointerEvents:"none",boxSizing:"border-box"};return yt(t)?r.top=lo:r.top=`calc(100vh - ${co}px)`,t.endsWith("left")?r.left=tt:t.endsWith("right")?r.right=tt:(r.left="50%",r.transform="translateX(-50%)"),r}function po({toasts:t,position:r,onDismiss:n,portalContainer:o}){const[a,i]=c.useState(!1),[l,s]=c.useState(void 0),d=c.useCallback(u=>{u&&s(u.offsetHeight)},[]),p=yt(r),h=t.filter(u=>u.phase!=="exiting"),f=t.filter(u=>u.phase==="exiting");c.useEffect(()=>{h.length<=1&&i(!1)},[h.length]);const w=c.useRef(null),y=c.useCallback(()=>{w.current&&(clearTimeout(w.current),w.current=null),h.length>1&&i(!0)},[h.length]),g=c.useCallback(()=>{w.current=setTimeout(()=>{i(!1),w.current=null},150)},[]),m=e.jsx("div",{style:uo(r),children:e.jsx("div",{onMouseEnter:y,onMouseLeave:g,style:{margin:"calc(-1 * var(--lucent-space-2))",padding:"var(--lucent-space-2)"},children:e.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:p?"column-reverse":"column",gap:a?"var(--lucent-space-2)":0,transform:a&&!p?"translateY(-100%)":void 0,marginTop:a&&!p?l??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:[h.map((u,b)=>{const x=h.length-1-b,k=!a&&x>ao,S=x*to,C=p?S:-S,v=a?1:1-x*no,z=a?1:Math.max(0,1-x*ro),T=u.phase==="entering",E=x===0,F=!a&&!E;return e.jsx("div",{ref:E?d:void 0,role:"status","aria-live":"polite","aria-hidden":k,style:{position:E||a?"relative":"absolute",...!a&&!E&&(p?{bottom:0}:{top:0}),zIndex:100-x,transform:T?`translateY(${p?"-20px":"20px"}) scale(0.96)`:a?void 0:`translateY(${C}px) scaleX(${v})`,opacity:T||u.phase==="exiting"?0:z,transformOrigin:p?"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:k?"none":"auto",visibility:k?"hidden":"visible"},children:e.jsx(et,{entry:u,onDismiss:n,hideContent:F,...F&&l!==void 0&&{fixedHeight:l}})},u.id)}),f.map(u=>e.jsx("div",{role:"status","aria-live":"polite",style:{position:"absolute",...p?{bottom:0}:{top:0},zIndex:200,transform:`translateY(${p?"20px":"-20px"}) scale(0.96)`,opacity:0,transformOrigin:p?"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(et,{entry:u,onDismiss:n})},u.id))]})})});return J.createPortal(m,o??document.body)}function ho({children:t,position:r="bottom-right",duration:n=5e3,max:o=5,portalContainer:a}){const[i,l]=c.useState([]),s=c.useCallback(h=>{l(f=>{const w=f.find(y=>y.id===h);return!w||w.phase==="exiting"?f:f.map(y=>y.id===h?{...y,phase:"exiting"}:y)}),setTimeout(()=>{l(f=>f.filter(w=>w.id!==h))},eo)},[]),d=c.useCallback(h=>{const f=Qa(),w={id:f,title:h.title,variant:h.variant??"default",duration:h.duration??n,...h.description!==void 0&&{description:h.description},...h.action!==void 0&&{action:h.action},...h.icon!==void 0&&{icon:h.icon},phase:"entering"};return l(y=>{const g=[...y,w],m=g.filter(u=>u.phase!=="exiting");if(m.length>o){const u=m.slice(0,m.length-o);for(const b of u)setTimeout(()=>s(b.id),0)}return g}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{l(y=>y.map(g=>g.id===f&&g.phase==="entering"?{...g,phase:"visible"}:g))})}),f},[n,o,s]);c.useEffect(()=>{const h=[];for(const f of i)if(f.phase==="visible"&&f.duration!==1/0){const w=setTimeout(()=>s(f.id),f.duration);h.push(w)}return()=>h.forEach(clearTimeout)},[i,s]);const p={toast:d,dismiss:s};return e.jsxs(bt.Provider,{value:p,children:[t,i.length>0&&e.jsx(po,{toasts:i,position:r,onDismiss:s,...a!==void 0&&{portalContainer:a}})]})}const fo={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).
|
|
436
450
|
|
|
437
451
|
**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.
|
|
438
452
|
|
|
@@ -489,7 +503,7 @@ dismiss(id);`},{title:"Custom icon",description:"Override the built-in variant i
|
|
|
489
503
|
title: 'Synced',
|
|
490
504
|
variant: 'success',
|
|
491
505
|
icon: <CloudSyncIcon />,
|
|
492
|
-
});`}],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.'}},Ie=120,
|
|
506
|
+
});`}],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.'}},Ie=120,mo=`
|
|
493
507
|
@keyframes lucent-navmenu-open {
|
|
494
508
|
from { opacity: 0; transform: translateY(-4px); }
|
|
495
509
|
to { opacity: 1; transform: translateY(0); }
|
|
@@ -506,7 +520,7 @@ dismiss(id);`},{title:"Custom icon",description:"Override the built-in variant i
|
|
|
506
520
|
background: color-mix(in srgb, var(--lucent-text-primary) 5%, transparent) !important;
|
|
507
521
|
color: var(--lucent-text-primary) !important;
|
|
508
522
|
}
|
|
509
|
-
`,he="cubic-bezier(0.34, 1.56, 0.64, 1)",xe={sm:{fontSize:"var(--lucent-font-size-sm)",paddingY:"5px",paddingX:"var(--lucent-space-3)",gap:"var(--lucent-space-2)",itemGap:"0px",iconWidth:"var(--lucent-space-5)",nestedFontSize:"var(--lucent-font-size-xs)"},md:{fontSize:"var(--lucent-font-size-md)",paddingY:"6px",paddingX:"var(--lucent-space-3)",gap:"var(--lucent-space-2)",itemGap:"2px",iconWidth:"var(--lucent-space-5)",nestedFontSize:"var(--lucent-font-size-sm)"},lg:{fontSize:"var(--lucent-font-size-lg)",paddingY:"var(--lucent-space-2)",paddingX:"var(--lucent-space-4)",gap:"var(--lucent-space-3)",itemGap:"var(--lucent-space-1)",iconWidth:"var(--lucent-space-6)",nestedFontSize:"var(--lucent-font-size-md)"}},X=c.createContext({orientation:"vertical",depth:0,inverse:!1,size:"md",hasIcons:!1,parentHasIcon:!1,requestMeasure:()=>{}});function le({children:t,orientation:r="vertical",inverse:n=!1,size:o="md",hasIcons:a=!1,style:i,"aria-label":s="Navigation"}){const l=c.useRef(!1);if(!l.current&&typeof document<"u"){const h=document.createElement("style");h.textContent=ho,document.head.appendChild(h),l.current=!0}const d=xe[o],p=c.useRef(null),m=c.useRef(null),f=c.useRef(!1),w=c.useRef(0),y=c.useCallback(()=>{const h=p.current,u=m.current;if(!h||!u)return;const b=h.querySelector('[data-active="true"]'),x=h.querySelector('[data-active-parent="true"]');let k=null,S=!1;if(b&&!b.closest('[aria-hidden="true"]')?k=b:x&&!x.closest('[aria-hidden="true"]')&&(k=x,S=!0),!k){u.style.opacity="0";return}const C=h.getBoundingClientRect(),v=k.getBoundingClientRect();f.current?u.style.transition=[`top 150ms ${he}`,`left 150ms ${he}`,`width 150ms ${he}`,`height 150ms ${he}`,"opacity 100ms ease","background 150ms ease","box-shadow 150ms ease"].join(", "):(u.style.transition="none",f.current=!0),u.style.top=`${v.top-C.top}px`,u.style.left=`${v.left-C.left}px`,u.style.width=`${v.width}px`,u.style.height=`${v.height}px`,u.style.opacity="1",S?(u.style.background=n?"var(--lucent-surface-secondary)":"color-mix(in srgb, var(--lucent-accent-default) 12%, transparent)",u.style.boxShadow="none"):(u.style.background=n?"var(--lucent-surface)":"var(--lucent-accent-default)",u.style.boxShadow=n?"inset -3px 0 0 var(--lucent-accent-default), var(--lucent-shadow-sm)":"none")},[n]),g=c.useCallback(()=>{cancelAnimationFrame(w.current),w.current=requestAnimationFrame(y)},[y]);return c.useEffect(()=>{const h=p.current;if(!h)return;const u=new MutationObserver(g);return u.observe(h,{attributes:!0,attributeFilter:["data-active","data-active-parent","aria-hidden"],subtree:!0}),()=>u.disconnect()},[g]),c.useEffect(()=>{const h=p.current;if(!h)return;const u=new ResizeObserver(g);return u.observe(h),()=>u.disconnect()},[g]),c.useEffect(()=>{document.fonts.ready.then(g)},[g]),c.useEffect(()=>{g()},[t,n,o,g]),e.jsx(X.Provider,{value:{orientation:r,depth:0,inverse:n,size:o,hasIcons:a,parentHasIcon:!1,requestMeasure:g},children:e.jsxs("nav",{ref:p,"aria-label":s,style:{display:"flex",flexDirection:r==="vertical"?"column":"row",gap:d.itemGap,fontFamily:"var(--lucent-font-family-base)",fontSize:d.fontSize,position:"relative",...i},children:[e.jsx("div",{ref:m,"aria-hidden":!0,style:{position:"absolute",borderRadius:"var(--lucent-radius-md)",pointerEvents:"none",zIndex:0,opacity:0,top:0,left:0,width:0,height:0}}),t]})})}function mt({children:t,href:r,isActive:n=!1,icon:o,badge:a,disabled:i=!1,onClick:s,as:l,style:d}){const{orientation:p,depth:m,inverse:f,size:w,parentHasIcon:y,requestMeasure:g}=c.useContext(X),h=xe[w];c.useEffect(()=>{g()},[n,g]);let u=null;const b=[],x=Array.isArray(t)?t:[t];for(const S of x)S!=null&&typeof S=="object"&&"type"in S&&S.type===Fe?u=S:b.push(S);if(u)return e.jsx(mo,{subMenu:u,orientation:p,depth:m,inverse:f,size:w,isActive:n,disabled:i,...o!==void 0&&{icon:o},...a!==void 0&&{badge:a},...s!==void 0&&{onClick:s},...d!==void 0&&{style:d},children:b});const k=l??"a";return e.jsxs(k,{"data-lucent-navitem":"","data-active":n||void 0,href:i?void 0:r,onClick:i?void 0:s,"aria-current":n?"page":void 0,"aria-disabled":i||void 0,style:{display:"flex",alignItems:"center",gap:h.gap,padding:p==="vertical"?`${h.paddingY} ${h.paddingX} ${h.paddingY} ${o!=null||y?"var(--lucent-space-2)":"var(--lucent-space-4)"}`:`${h.paddingY} ${h.paddingX}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:i?"var(--lucent-text-disabled)":n?f?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",border:0,borderBottom:n&&p==="horizontal"?"2px solid var(--lucent-accent-default)":p==="horizontal"?"2px solid transparent":0,boxShadow:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:h.fontSize,fontWeight:n?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textDecoration:"none",cursor:i?"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",position:"relative",zIndex:1,whiteSpace:p==="horizontal"?"nowrap":void 0,width:p==="vertical"?"100%":void 0,textAlign:"left",outline:"none",...d},children:[o!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:h.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:o}),e.jsx("span",{style:{flex:1},children:b}),a!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,marginLeft:"auto"},children:a})]})}function mo({children:t,icon:r,badge:n,isActive:o=!1,disabled:a=!1,onClick:i,style:s,subMenu:l,orientation:d,depth:p,inverse:m,size:f}){const{hasIcons:w,requestMeasure:y}=c.useContext(X),g=xe[f],[h,u]=c.useState(!1),b=c.useRef(null),[x,k]=c.useState(0),S=c.useRef(null),C=c.useRef(null),v=c.useRef(),z=go(l),T=o&&!z,E=!T&&!h&&z,F=o||z;c.useEffect(()=>{y()},[h,o,z,y]),c.useEffect(()=>{if(d!=="vertical")return;const M=b.current;if(M)if(h){const $=M.scrollHeight;k($);const V=setTimeout(()=>{k(void 0)},130);return()=>clearTimeout(V)}else k(M.scrollHeight),M.getBoundingClientRect(),k(0)},[h,d]),c.useEffect(()=>{if(d!=="horizontal"||!h)return;const M=$=>{S.current&&!S.current.contains($.target)&&q()};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[d,h]),c.useLayoutEffect(()=>{if(d!=="horizontal"||!h)return;const M=C.current;if(!M)return;const $=M.getBoundingClientRect();$.right>window.innerWidth&&(M.style.left="auto",M.style.right="0"),$.bottom>window.innerHeight&&(M.style.top="auto",M.style.bottom="100%",M.style.marginTop="0",M.style.marginBottom="var(--lucent-space-1)")},[d,h]);const[R,j]=c.useState("idle"),[P,D]=c.useState(!1),W=()=>{a||(D(!0),j("entering"),u(!0))},q=()=>{j("exiting"),setTimeout(()=>{u(!1),D(!1),j("idle")},Ie)},N=()=>{a||(d==="horizontal"?h?q():W():u(!h))},H=M=>{a||(d==="vertical"?(M.key==="ArrowRight"&&!h&&(M.preventDefault(),u(!0)),M.key==="ArrowLeft"&&h&&(M.preventDefault(),u(!1))):(M.key==="ArrowDown"&&!h&&(M.preventDefault(),W()),M.key==="ArrowUp"&&h&&(M.preventDefault(),q())),(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),N()),M.key==="Escape"&&h&&(M.preventDefault(),d==="horizontal"?q():u(!1)))},A=()=>{d==="horizontal"&&!a&&(clearTimeout(v.current),W())},B=()=>{d==="horizontal"&&(v.current=setTimeout(()=>q(),150))};return d==="horizontal"?e.jsxs("div",{ref:S,style:{position:"relative"},onMouseEnter:A,onMouseLeave:B,children:[e.jsxs("button",{"data-lucent-navitem":"","data-hint":F||void 0,onClick:M=>{N(),i==null||i(M)},onKeyDown:H,"aria-expanded":h,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:g.gap,padding:`${g.paddingY} ${g.paddingX}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:a?"var(--lucent-text-disabled)":F?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",border:0,borderBottom:F?"2px solid var(--lucent-accent-default)":"2px solid transparent",fontFamily:"var(--lucent-font-family-base)",fontSize:g.fontSize,fontWeight:F?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",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",whiteSpace:"nowrap",outline:"none",boxSizing:"border-box",...s},children:[r!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:g.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:r}),e.jsx("span",{children:t}),n!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0},children:n})]}),P&&e.jsx(X.Provider,{value:{orientation:"vertical",depth:0,inverse:m,size:f,hasIcons:w,parentHasIcon:!1,requestMeasure:y},children:e.jsx("div",{ref:C,style:{position:"absolute",top:"100%",left:0,marginTop:"var(--lucent-space-1)",minWidth:180,background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-lg)",padding:"var(--lucent-space-1)",zIndex:100,animation:R==="exiting"?`lucent-navmenu-dropdown-out ${Ie}ms var(--lucent-easing-default) forwards`:`lucent-navmenu-dropdown-in ${Ie}ms var(--lucent-easing-default) forwards`},children:l})})]}):e.jsxs("div",{style:{position:"relative",zIndex:1},children:[e.jsxs("button",{"data-lucent-navitem":"","data-active":T||void 0,"data-active-parent":E||void 0,"data-hint":!T&&!E&&F||void 0,onClick:M=>{N(),i==null||i(M)},onKeyDown:H,"aria-expanded":h,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:g.gap,width:"100%",padding:`${g.paddingY} ${g.paddingX} ${g.paddingY} ${r!=null?"var(--lucent-space-2)":"var(--lucent-space-4)"}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:a?"var(--lucent-text-disabled)":T?m?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":E||F?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",border:0,boxShadow:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:g.fontSize,fontWeight:F?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textAlign:"left",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",outline:"none",...s},children:[r!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:g.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:r}),e.jsx("span",{style:{flex:1},children:t}),n!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0},children:n})]}),e.jsx("div",{ref:b,"aria-hidden":!h,style:{overflow:"hidden",height:x!==void 0?x:"auto",transition:"height 120ms var(--lucent-easing-default)"},children:e.jsx(X.Provider,{value:{orientation:d,depth:p+1,inverse:m,size:f,hasIcons:w,parentHasIcon:r!=null,requestMeasure:y},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:g.itemGap,padding:"var(--lucent-space-1) 0",marginLeft:r!=null?`calc(${g.iconWidth} + ${g.gap})`:"var(--lucent-space-3)",animation:h?"lucent-navmenu-open 200ms var(--lucent-easing-default) forwards":void 0},children:l})})})]})}function go(t){return De(t)}function De(t){if(t==null)return!1;if(Array.isArray(t))return t.some(De);if(typeof t=="object"&&"props"in t){const r=t;if(r.props.isActive)return!0;if(r.props.children)return De(r.props.children)}return!1}function Fe({children:t}){return e.jsx(e.Fragment,{children:t})}function gt({children:t,label:r,defaultOpen:n=!0,open:o,onOpenChange:a,collapsible:i,style:s}){const{orientation:l,inverse:d,size:p,hasIcons:m}=c.useContext(X),f=xe[p],w=i??r!=null,y=m?"var(--lucent-space-2)":"var(--lucent-space-4)";if(l==="horizontal")return e.jsx(e.Fragment,{children:t});const g=o!==void 0,[h,u]=c.useState(n),b=g?o:h,x=c.useRef(null),[k,S]=c.useState(b?void 0:0);c.useEffect(()=>{if(!w)return;const v=x.current;if(v)if(b){const z=v.scrollHeight;S(z);const T=setTimeout(()=>{S(void 0)},130);return()=>clearTimeout(T)}else S(v.scrollHeight),v.getBoundingClientRect(),S(0)},[b,w]);const C=c.useCallback(()=>{const v=!b;g||u(v),a==null||a(v)},[b,g,a]);return r?e.jsxs("div",{style:{display:"flex",flexDirection:"column",marginTop:"var(--lucent-space-3)",...s},children:[w?e.jsxs("button",{onClick:C,"aria-expanded":b,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:`var(--lucent-space-1) var(--lucent-space-3) var(--lucent-space-1) ${y}`,background:"none",border:0,cursor:"pointer",outline:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-semibold)",color:"var(--lucent-text-secondary)",letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left",userSelect:"none",marginBottom:b?"var(--lucent-space-1)":"0",transition:"margin-bottom 200ms var(--lucent-easing-default)"},children:[e.jsx("span",{children:r}),e.jsx(vo,{open:b,size:12})]}):e.jsx("div",{style:{padding:`var(--lucent-space-1) var(--lucent-space-3) var(--lucent-space-1) ${y}`,fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-semibold)",color:"var(--lucent-text-secondary)",letterSpacing:"0.05em",textTransform:"uppercase",userSelect:"none",marginBottom:"var(--lucent-space-1)"},children:r}),w?e.jsx("div",{ref:x,"aria-hidden":!b,style:{overflow:"hidden",height:k!==void 0?k:"auto",transition:"height 120ms var(--lucent-easing-default)"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap},children:t})}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap},children:t})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap,...s},children:t})}function vt({style:t}){const{orientation:r}=c.useContext(X);return e.jsx("div",{role:"separator",style:{...r==="vertical"?{height:1,margin:"var(--lucent-space-2) var(--lucent-space-4)"}:{width:1,alignSelf:"stretch",margin:"var(--lucent-space-1) var(--lucent-space-1)"},background:"var(--lucent-border-default)",flexShrink:0,...t}})}function vo({open:t,size:r=14}){return e.jsx("svg",{width:r,height:r,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"})})}le.Item=mt;le.Group=gt;le.Sub=Fe;le.Separator=vt;const je=120,bo=`
|
|
523
|
+
`,fe="cubic-bezier(0.34, 1.56, 0.64, 1)",xe={sm:{fontSize:"var(--lucent-font-size-sm)",paddingY:"5px",paddingX:"var(--lucent-space-3)",gap:"var(--lucent-space-2)",itemGap:"0px",iconWidth:"var(--lucent-space-5)",nestedFontSize:"var(--lucent-font-size-xs)"},md:{fontSize:"var(--lucent-font-size-md)",paddingY:"6px",paddingX:"var(--lucent-space-3)",gap:"var(--lucent-space-2)",itemGap:"2px",iconWidth:"var(--lucent-space-5)",nestedFontSize:"var(--lucent-font-size-sm)"},lg:{fontSize:"var(--lucent-font-size-lg)",paddingY:"var(--lucent-space-2)",paddingX:"var(--lucent-space-4)",gap:"var(--lucent-space-3)",itemGap:"var(--lucent-space-1)",iconWidth:"var(--lucent-space-6)",nestedFontSize:"var(--lucent-font-size-md)"}},X=c.createContext({orientation:"vertical",depth:0,inverse:!1,size:"md",hasIcons:!1,parentHasIcon:!1,requestMeasure:()=>{}});function le({children:t,orientation:r="vertical",inverse:n=!1,size:o="md",hasIcons:a=!1,style:i,"aria-label":l="Navigation"}){const s=c.useRef(!1);if(!s.current&&typeof document<"u"){const m=document.createElement("style");m.textContent=mo,document.head.appendChild(m),s.current=!0}const d=xe[o],p=c.useRef(null),h=c.useRef(null),f=c.useRef(!1),w=c.useRef(0),y=c.useCallback(()=>{const m=p.current,u=h.current;if(!m||!u)return;const b=m.querySelector('[data-active="true"]'),x=m.querySelector('[data-active-parent="true"]');let k=null,S=!1;if(b&&!b.closest('[aria-hidden="true"]')?k=b:x&&!x.closest('[aria-hidden="true"]')&&(k=x,S=!0),!k){u.style.opacity="0";return}const C=m.getBoundingClientRect(),v=k.getBoundingClientRect();f.current?u.style.transition=[`top 150ms ${fe}`,`left 150ms ${fe}`,`width 150ms ${fe}`,`height 150ms ${fe}`,"opacity 100ms ease","background 150ms ease","box-shadow 150ms ease"].join(", "):(u.style.transition="none",f.current=!0),u.style.top=`${v.top-C.top}px`,u.style.left=`${v.left-C.left}px`,u.style.width=`${v.width}px`,u.style.height=`${v.height}px`,u.style.opacity="1",S?(u.style.background=n?"var(--lucent-surface-secondary)":"color-mix(in srgb, var(--lucent-accent-default) 12%, transparent)",u.style.boxShadow="none"):(u.style.background=n?"var(--lucent-surface)":"var(--lucent-accent-default)",u.style.boxShadow=n?"inset -3px 0 0 var(--lucent-accent-default), var(--lucent-shadow-sm)":"none")},[n]),g=c.useCallback(()=>{cancelAnimationFrame(w.current),w.current=requestAnimationFrame(y)},[y]);return c.useEffect(()=>{const m=p.current;if(!m)return;const u=new MutationObserver(g);return u.observe(m,{attributes:!0,attributeFilter:["data-active","data-active-parent","aria-hidden"],subtree:!0}),()=>u.disconnect()},[g]),c.useEffect(()=>{const m=p.current;if(!m)return;const u=new ResizeObserver(g);return u.observe(m),()=>u.disconnect()},[g]),c.useEffect(()=>{document.fonts.ready.then(g)},[g]),c.useEffect(()=>{g()},[t,n,o,g]),e.jsx(X.Provider,{value:{orientation:r,depth:0,inverse:n,size:o,hasIcons:a,parentHasIcon:!1,requestMeasure:g},children:e.jsxs("nav",{ref:p,"aria-label":l,style:{display:"flex",flexDirection:r==="vertical"?"column":"row",gap:d.itemGap,fontFamily:"var(--lucent-font-family-base)",fontSize:d.fontSize,position:"relative",...i},children:[e.jsx("div",{ref:h,"aria-hidden":!0,style:{position:"absolute",borderRadius:"var(--lucent-radius-md)",pointerEvents:"none",zIndex:0,opacity:0,top:0,left:0,width:0,height:0}}),t]})})}function xt({children:t,href:r,isActive:n=!1,icon:o,badge:a,disabled:i=!1,onClick:l,as:s,style:d}){const{orientation:p,depth:h,inverse:f,size:w,parentHasIcon:y,requestMeasure:g}=c.useContext(X),m=xe[w];c.useEffect(()=>{g()},[n,g]);let u=null;const b=[],x=Array.isArray(t)?t:[t];for(const S of x)S!=null&&typeof S=="object"&&"type"in S&&S.type===$e?u=S:b.push(S);if(u)return e.jsx(go,{subMenu:u,orientation:p,depth:h,inverse:f,size:w,isActive:n,disabled:i,...o!==void 0&&{icon:o},...a!==void 0&&{badge:a},...l!==void 0&&{onClick:l},...d!==void 0&&{style:d},children:b});const k=s??"a";return e.jsxs(k,{"data-lucent-navitem":"","data-active":n||void 0,href:i?void 0:r,onClick:i?void 0:l,"aria-current":n?"page":void 0,"aria-disabled":i||void 0,style:{display:"flex",alignItems:"center",gap:m.gap,padding:p==="vertical"?`${m.paddingY} ${m.paddingX} ${m.paddingY} ${o!=null||y?"var(--lucent-space-2)":"var(--lucent-space-4)"}`:`${m.paddingY} ${m.paddingX}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:i?"var(--lucent-text-disabled)":n?f?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",border:0,borderBottom:n&&p==="horizontal"?"2px solid var(--lucent-accent-default)":p==="horizontal"?"2px solid transparent":0,boxShadow:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:m.fontSize,fontWeight:n?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textDecoration:"none",cursor:i?"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",position:"relative",zIndex:1,whiteSpace:p==="horizontal"?"nowrap":void 0,width:p==="vertical"?"100%":void 0,textAlign:"left",outline:"none",...d},children:[o!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:m.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:o}),e.jsx("span",{style:{flex:1},children:b}),a!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,marginLeft:"auto"},children:a})]})}function go({children:t,icon:r,badge:n,isActive:o=!1,disabled:a=!1,onClick:i,style:l,subMenu:s,orientation:d,depth:p,inverse:h,size:f}){const{hasIcons:w,requestMeasure:y}=c.useContext(X),g=xe[f],[m,u]=c.useState(!1),b=c.useRef(null),[x,k]=c.useState(0),S=c.useRef(null),C=c.useRef(null),v=c.useRef(),z=vo(s),T=o&&!z,E=!T&&!m&&z,F=o||z;c.useEffect(()=>{y()},[m,o,z,y]),c.useEffect(()=>{if(d!=="vertical")return;const M=b.current;if(M)if(m){const $=M.scrollHeight;k($);const V=setTimeout(()=>{k(void 0)},130);return()=>clearTimeout(V)}else k(M.scrollHeight),M.getBoundingClientRect(),k(0)},[m,d]),c.useEffect(()=>{if(d!=="horizontal"||!m)return;const M=$=>{S.current&&!S.current.contains($.target)&&q()};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[d,m]),c.useLayoutEffect(()=>{if(d!=="horizontal"||!m)return;const M=C.current;if(!M)return;const $=M.getBoundingClientRect();$.right>window.innerWidth&&(M.style.left="auto",M.style.right="0"),$.bottom>window.innerHeight&&(M.style.top="auto",M.style.bottom="100%",M.style.marginTop="0",M.style.marginBottom="var(--lucent-space-1)")},[d,m]);const[R,j]=c.useState("idle"),[P,D]=c.useState(!1),W=()=>{a||(D(!0),j("entering"),u(!0))},q=()=>{j("exiting"),setTimeout(()=>{u(!1),D(!1),j("idle")},Ie)},N=()=>{a||(d==="horizontal"?m?q():W():u(!m))},H=M=>{a||(d==="vertical"?(M.key==="ArrowRight"&&!m&&(M.preventDefault(),u(!0)),M.key==="ArrowLeft"&&m&&(M.preventDefault(),u(!1))):(M.key==="ArrowDown"&&!m&&(M.preventDefault(),W()),M.key==="ArrowUp"&&m&&(M.preventDefault(),q())),(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),N()),M.key==="Escape"&&m&&(M.preventDefault(),d==="horizontal"?q():u(!1)))},A=()=>{d==="horizontal"&&!a&&(clearTimeout(v.current),W())},B=()=>{d==="horizontal"&&(v.current=setTimeout(()=>q(),150))};return d==="horizontal"?e.jsxs("div",{ref:S,style:{position:"relative"},onMouseEnter:A,onMouseLeave:B,children:[e.jsxs("button",{"data-lucent-navitem":"","data-hint":F||void 0,onClick:M=>{N(),i==null||i(M)},onKeyDown:H,"aria-expanded":m,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:g.gap,padding:`${g.paddingY} ${g.paddingX}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:a?"var(--lucent-text-disabled)":F?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",border:0,borderBottom:F?"2px solid var(--lucent-accent-default)":"2px solid transparent",fontFamily:"var(--lucent-font-family-base)",fontSize:g.fontSize,fontWeight:F?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",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",whiteSpace:"nowrap",outline:"none",boxSizing:"border-box",...l},children:[r!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:g.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:r}),e.jsx("span",{children:t}),n!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0},children:n})]}),P&&e.jsx(X.Provider,{value:{orientation:"vertical",depth:0,inverse:h,size:f,hasIcons:w,parentHasIcon:!1,requestMeasure:y},children:e.jsx("div",{ref:C,style:{position:"absolute",top:"100%",left:0,marginTop:"var(--lucent-space-1)",minWidth:180,background:"var(--lucent-surface)",border:"1px solid var(--lucent-border-default)",borderRadius:"var(--lucent-radius-lg)",boxShadow:"var(--lucent-shadow-lg)",padding:"var(--lucent-space-1)",zIndex:100,animation:R==="exiting"?`lucent-navmenu-dropdown-out ${Ie}ms var(--lucent-easing-default) forwards`:`lucent-navmenu-dropdown-in ${Ie}ms var(--lucent-easing-default) forwards`},children:s})})]}):e.jsxs("div",{style:{position:"relative",zIndex:1},children:[e.jsxs("button",{"data-lucent-navitem":"","data-active":T||void 0,"data-active-parent":E||void 0,"data-hint":!T&&!E&&F||void 0,onClick:M=>{N(),i==null||i(M)},onKeyDown:H,"aria-expanded":m,"aria-disabled":a||void 0,style:{display:"flex",alignItems:"center",gap:g.gap,width:"100%",padding:`${g.paddingY} ${g.paddingX} ${g.paddingY} ${r!=null?"var(--lucent-space-2)":"var(--lucent-space-4)"}`,borderRadius:"var(--lucent-radius-md)",background:"transparent",color:a?"var(--lucent-text-disabled)":T?h?"var(--lucent-text-primary)":"var(--lucent-accent-fg)":E||F?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",border:0,boxShadow:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:g.fontSize,fontWeight:F?"var(--lucent-font-weight-medium)":"var(--lucent-font-weight-regular)",textAlign:"left",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",outline:"none",...l},children:[r!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0,width:g.iconWidth,minWidth:14,minHeight:14,alignItems:"center",justifyContent:"center",color:"inherit"},children:r}),e.jsx("span",{style:{flex:1},children:t}),n!=null&&e.jsx("span",{style:{display:"flex",flexShrink:0},children:n})]}),e.jsx("div",{ref:b,"aria-hidden":!m,style:{overflow:"hidden",height:x!==void 0?x:"auto",transition:"height 120ms var(--lucent-easing-default)"},children:e.jsx(X.Provider,{value:{orientation:d,depth:p+1,inverse:h,size:f,hasIcons:w,parentHasIcon:r!=null,requestMeasure:y},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:g.itemGap,padding:"var(--lucent-space-1) 0",marginLeft:r!=null?`calc(${g.iconWidth} + ${g.gap})`:"var(--lucent-space-3)",animation:m?"lucent-navmenu-open 200ms var(--lucent-easing-default) forwards":void 0},children:s})})})]})}function vo(t){return Be(t)}function Be(t){if(t==null)return!1;if(Array.isArray(t))return t.some(Be);if(typeof t=="object"&&"props"in t){const r=t;if(r.props.isActive)return!0;if(r.props.children)return Be(r.props.children)}return!1}function $e({children:t}){return e.jsx(e.Fragment,{children:t})}function wt({children:t,label:r,defaultOpen:n=!0,open:o,onOpenChange:a,collapsible:i,style:l}){const{orientation:s,inverse:d,size:p,hasIcons:h}=c.useContext(X),f=xe[p],w=i??r!=null,y=h?"var(--lucent-space-2)":"var(--lucent-space-4)";if(s==="horizontal")return e.jsx(e.Fragment,{children:t});const g=o!==void 0,[m,u]=c.useState(n),b=g?o:m,x=c.useRef(null),[k,S]=c.useState(b?void 0:0);c.useEffect(()=>{if(!w)return;const v=x.current;if(v)if(b){const z=v.scrollHeight;S(z);const T=setTimeout(()=>{S(void 0)},130);return()=>clearTimeout(T)}else S(v.scrollHeight),v.getBoundingClientRect(),S(0)},[b,w]);const C=c.useCallback(()=>{const v=!b;g||u(v),a==null||a(v)},[b,g,a]);return r?e.jsxs("div",{style:{display:"flex",flexDirection:"column",marginTop:"var(--lucent-space-3)",...l},children:[w?e.jsxs("button",{onClick:C,"aria-expanded":b,style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:`var(--lucent-space-1) var(--lucent-space-3) var(--lucent-space-1) ${y}`,background:"none",border:0,cursor:"pointer",outline:"none",fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-semibold)",color:"var(--lucent-text-secondary)",letterSpacing:"0.05em",textTransform:"uppercase",textAlign:"left",userSelect:"none",marginBottom:b?"var(--lucent-space-1)":"0",transition:"margin-bottom 200ms var(--lucent-easing-default)"},children:[e.jsx("span",{children:r}),e.jsx(bo,{open:b,size:12})]}):e.jsx("div",{style:{padding:`var(--lucent-space-1) var(--lucent-space-3) var(--lucent-space-1) ${y}`,fontFamily:"var(--lucent-font-family-base)",fontSize:"var(--lucent-font-size-xs)",fontWeight:"var(--lucent-font-weight-semibold)",color:"var(--lucent-text-secondary)",letterSpacing:"0.05em",textTransform:"uppercase",userSelect:"none",marginBottom:"var(--lucent-space-1)"},children:r}),w?e.jsx("div",{ref:x,"aria-hidden":!b,style:{overflow:"hidden",height:k!==void 0?k:"auto",transition:"height 120ms var(--lucent-easing-default)"},children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap},children:t})}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap},children:t})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.itemGap,...l},children:t})}function kt({style:t}){const{orientation:r}=c.useContext(X);return e.jsx("div",{role:"separator",style:{...r==="vertical"?{height:1,margin:"var(--lucent-space-2) var(--lucent-space-4)"}:{width:1,alignSelf:"stretch",margin:"var(--lucent-space-1) var(--lucent-space-1)"},background:"var(--lucent-border-default)",flexShrink:0,...t}})}function bo({open:t,size:r=14}){return e.jsx("svg",{width:r,height:r,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"})})}le.Item=xt;le.Group=wt;le.Sub=$e;le.Separator=kt;const je=120,yo=`
|
|
510
524
|
@keyframes lucent-filter-ms-in {
|
|
511
525
|
from { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
512
526
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
|
@@ -515,7 +529,7 @@ dismiss(id);`},{title:"Custom icon",description:"Override the built-in variant i
|
|
|
515
529
|
from { opacity: 1; transform: scale(1) translateY(0); }
|
|
516
530
|
to { opacity: 0; transform: scale(0.97) translateY(-2px); }
|
|
517
531
|
}
|
|
518
|
-
`;let et=!1;const yo={xs:"var(--lucent-space-1)",sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},xo={xs:"sm",sm:"sm",md:"md",lg:"lg"},Me=4;function wo(t,r){const n=r.offsetHeight,o=r.offsetWidth,a=window.innerWidth,i=window.innerHeight;let s=t.bottom+Me,l=t.left,d="top left";return s+n>i&&t.top-n-Me>=0&&(s=t.top-n-Me,d="bottom left"),l+o>a&&(l=a-o-8),l<0&&(l=8),{top:s,left:l,transformOrigin:d}}function ko({label:t,options:r,value:n,defaultValue:o=[],onChange:a,variant:i="secondary",size:s="sm",disabled:l=!1,icon:d,style:p}){const m=n!==void 0,[f,w]=c.useState(o),y=m?n:f,[g,h]=c.useState(!1),[u,b]=c.useState(!1),[x,k]=c.useState("idle"),[S,C]=c.useState(null),[v,z]=c.useState(-1),T=c.useRef(null),E=c.useRef(null);if(!et&&typeof document<"u"){const q=document.createElement("style");q.textContent=bo,document.head.appendChild(q),et=!0}c.useEffect(()=>{if(g)b(!0),k("entering"),z(-1);else if(u){k("exiting");const q=setTimeout(()=>{b(!1),k("idle")},je);return()=>clearTimeout(q)}},[g]),c.useLayoutEffect(()=>{if(!u||x!=="entering"||!T.current)return;const q=requestAnimationFrame(()=>{const N=E.current,H=T.current;!N||!H||C(wo(H.getBoundingClientRect(),N))});return()=>cancelAnimationFrame(q)},[u,x]);const F=c.useCallback(()=>h(!1),[]);c.useEffect(()=>{if(!g)return;const q=H=>{var B,M;const A=H.target;(B=T.current)!=null&&B.contains(A)||(M=E.current)!=null&&M.contains(A)||F()},N=requestAnimationFrame(()=>{document.addEventListener("mousedown",q)});return()=>{cancelAnimationFrame(N),document.removeEventListener("mousedown",q)}},[g,F]),c.useEffect(()=>{if(!g)return;const q=N=>{N.key==="Escape"&&F()};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[g,F]);const R=q=>{const N=y.includes(q)?y.filter(H=>H!==q):[...y,q];m||w(N),a==null||a(N)},j=()=>{m||w([]),a==null||a([]),F()},P=q=>{if(q.key==="ArrowDown")q.preventDefault(),z(N=>(N+1)%r.length);else if(q.key==="ArrowUp")q.preventDefault(),z(N=>(N-1+r.length)%r.length);else if((q.key==="Enter"||q.key===" ")&&v>=0){q.preventDefault();const N=r[v];N&&!N.disabled&&R(N.value)}},D=yo[s],W=xo[s];return e.jsxs("span",{ref:T,style:{display:"inline-flex",...p},children:[e.jsxs(I.Button,{variant:i==="outline"&&y.length>0?"secondary":i==="ghost"?"ghost":i,size:s,...t?{chevron:!0}:{},disabled:l,onClick:()=>!l&&h(q=>!q),...d!==void 0&&{leftIcon:d},children:[t||void 0,y.length>0&&e.jsx(se,{variant:"accent",size:s==="xs"?"sm":s,children:y.length})]}),u&&J.createPortal(e.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":t,tabIndex:-1,onKeyDown:P,style:{position:"fixed",top:(S==null?void 0:S.top)??-9999,left:(S==null?void 0:S.left)??-9999,zIndex:1e3,minWidth:180,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:D,maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:x==="exiting"?`lucent-filter-ms-out ${je}ms var(--lucent-easing-default) forwards`:`lucent-filter-ms-in ${je}ms var(--lucent-easing-decelerate)`,transformOrigin:(S==null?void 0:S.transformOrigin)??"top left",outline:"none",pointerEvents:x==="exiting"?"none":"auto",fontFamily:"var(--lucent-font-family-base)"},children:[r.map((q,N)=>{const H=y.includes(q.value),A=v===N;return e.jsxs("div",{role:"option","aria-selected":H,"aria-disabled":q.disabled,onClick:()=>!q.disabled&&R(q.value),onMouseEnter:()=>z(N),style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",padding:`var(--lucent-space-2) ${D}`,borderRadius:"var(--lucent-radius-md)",cursor:q.disabled?"not-allowed":"pointer",background:A?"var(--lucent-surface-secondary)":"transparent",opacity:q.disabled?.5:1,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:[e.jsx(be,{checked:H,onChange:()=>{},disabled:q.disabled,style:{pointerEvents:"none"}}),q.swatch?e.jsx(se,{size:s==="xs"?"sm":s,swatch:q.swatch,children:q.label}):e.jsx(I.Text,{size:W,children:q.label})]},q.value)}),e.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)"}}),e.jsx("div",{onClick:y.length>0?j:void 0,style:{display:"flex",alignItems:"center",padding:`var(--lucent-space-2) ${D}`,borderRadius:"var(--lucent-radius-md)",cursor:y.length>0?"pointer":"default",opacity:y.length>0?1:.5},children:e.jsx(I.Text,{size:W,color:y.length>0?"secondary":"disabled",children:"Clear all"})})]}),document.body)]})}function So({label:t,options:r,value:n,defaultValue:o,onChange:a,variant:i="secondary",size:s="sm",disabled:l=!1,icon:d,style:p}){var x;const m=n!==void 0,[f,w]=c.useState(o),y=m?n:f,g=(x=r.find(k=>k.value===y))==null?void 0:x.label,h=y!==void 0,u=k=>{m||w(k),a==null||a(k)},b=()=>{m||w(void 0),a==null||a(void 0)};return e.jsxs(Le,{trigger:e.jsx(I.Button,{variant:i==="outline"&&h?"secondary":i,size:s,chevron:!0,disabled:l,...d!==void 0&&{leftIcon:d},children:g??t}),size:s,...p!==void 0&&{style:p},children:[r.map(k=>e.jsx(me,{selected:y===k.value,...k.disabled!==void 0&&{disabled:k.disabled},onSelect:()=>u(k.value),children:k.label},k.value)),h&&e.jsxs(e.Fragment,{children:[e.jsx(it,{}),e.jsx(me,{onSelect:b,children:e.jsx(I.Text,{size:s==="lg"?"md":"sm",color:"secondary",children:"Clear"})})]})]})}const To=()=>e.jsxs("svg",{width:16,height:16,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"})]});function Co({value:t,defaultValue:r="",onChange:n,placeholder:o="Search…",variant:a="secondary",size:i="sm",width:s=260,disabled:l=!1,style:d}){const p=t!==void 0,[m,f]=c.useState(r),w=p?t:m,[y,g]=c.useState(!!w),h=c.useRef(null);c.useEffect(()=>{y&&requestAnimationFrame(()=>{var k;return(k=h.current)==null?void 0:k.focus()})},[y]);const u=k=>{const S=k.target.value;p||f(S),n==null||n(S)},b=()=>{w||g(!1)},x=()=>{l||g(!0)};return y?e.jsx(I.Input,{ref:h,placeholder:o,size:i,value:w,onChange:u,onBlur:b,disabled:l,style:{width:s,...d}}):e.jsx(I.Button,{variant:a,size:i,disabled:l,onClick:x,"aria-label":"Search",leftIcon:e.jsx(To,{}),style:d})}function Io(t,r){if(!t)return r;const n=o=>o.toLocaleDateString();return`${n(t.start)} → ${n(t.end)}`}function jo({label:t="Date range",value:r,defaultValue:n,onChange:o,variant:a="secondary",size:i="sm",min:s,max:l,disabled:d=!1,style:p}){const m=r!==void 0;return e.jsx(pt,{size:i,...r!==void 0&&{value:r},...n!==void 0&&{defaultValue:n},...o!==void 0&&{onChange:o},...s!==void 0&&{min:s},...l!==void 0&&{max:l},disabled:d,trigger:e.jsx(I.Button,{variant:a==="outline"&&m?"secondary":a,size:i,chevron:!0,disabled:d,children:Io(r,t)}),...p!==void 0&&{style:p}})}const Mo={sm:{circle:24,checkIcon:12,connector:2,labelSize:"var(--lucent-font-size-xs)",descSize:"var(--lucent-font-size-xs)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-2)"},md:{circle:32,checkIcon:14,connector:2,labelSize:"var(--lucent-font-size-sm)",descSize:"var(--lucent-font-size-xs)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-3)"},lg:{circle:40,checkIcon:18,connector:3,labelSize:"var(--lucent-font-size-md)",descSize:"var(--lucent-font-size-sm)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-3)"}};function zo(t){return typeof t=="string"?{label:t}:t}function Eo({size:t}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Re(t,r){return t<r?"completed":t===r?"current":"pending"}const Ao={completed:"Completed",current:"In Progress",pending:"Pending"},qo={completed:"success",current:"accent",pending:"neutral"},tt="lucent-stepper-keyframes";function Do(){if(typeof document>"u"||document.getElementById(tt))return;const t=document.createElement("style");t.id=tt,t.textContent="@keyframes lucent-stepper-check{0%{transform:scale(0)}60%{transform:scale(1.2)}100%{transform:scale(1)}}",document.head.appendChild(t)}function bt({index:t,state:r,step:n,cfg:o}){const a=r!=="pending";return e.jsx("div",{"aria-current":r==="current"?"step":void 0,style:{width:o.circle,height:o.circle,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:o.labelSize,fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)",background:a?"var(--lucent-accent-default)":"color-mix(in srgb, var(--lucent-text-secondary) 12%, var(--lucent-surface))",color:a?"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",transition:"background var(--lucent-duration-base) var(--lucent-easing-default), color var(--lucent-duration-base) var(--lucent-easing-default)",flexShrink:0},children:n.icon?n.icon:r==="completed"?e.jsx("span",{style:{display:"flex",animation:"lucent-stepper-check 300ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:e.jsx(Eo,{size:o.checkIcon})}):t+1})}function yt({state:t}){return e.jsx(se,{variant:qo[t],size:"sm",borderless:!0,children:Ao[t]})}function Ro({step:t,state:r,index:n,cfg:o,numbered:a,showStatus:i}){return e.jsxs(e.Fragment,{children:[a&&e.jsxs("span",{style:{fontSize:o.prefixSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",textTransform:"uppercase",letterSpacing:"var(--lucent-letter-spacing-wide)"},children:["Step ",n+1]}),e.jsx("span",{style:{fontSize:o.labelSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:r==="current"?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",color:r!=="pending"?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",transition:"color var(--lucent-duration-base) var(--lucent-easing-default)"},children:t.label}),t.description&&e.jsx("span",{style:{fontSize:o.descSize,fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)"},children:t.description}),i&&e.jsx(yt,{state:r})]})}function Bo({steps:t,current:r,cfg:n,numbered:o,showStatus:a}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.gap},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:[e.jsx("div",{style:{position:"absolute",left:n.circle/2,right:n.circle/2,top:n.circle/2-n.connector/2,height:n.connector,borderRadius:n.connector/2,background:"var(--lucent-border-default)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:n.connector/2,background:"var(--lucent-accent-default)",width:t.length>1?`${r/(t.length-1)*100}%`:"0%",transition:"width 300ms var(--lucent-easing-default)"}})}),t.map((i,s)=>e.jsx("div",{style:{flex:1,display:"flex",justifyContent:s===0?"flex-start":s===t.length-1?"flex-end":"center",position:"relative",zIndex:1},children:e.jsx(bt,{index:s,state:Re(s,r),step:i,cfg:n})},i.label))]}),e.jsx("div",{style:{display:"flex"},children:t.map((i,s)=>{const l=Re(s,r),d=s===t.length-1,p=s===0?"flex-start":d?"flex-end":"center",m=s===0?"left":d?"right":"center";return e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:p,gap:"2px",textAlign:m},children:e.jsx(Ro,{step:i,state:l,index:s,cfg:n,numbered:o,showStatus:a})},i.label)})})]})}function Po({steps:t,current:r,cfg:n,numbered:o,showStatus:a}){return e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.map((i,s)=>{const l=Re(s,r),d=s===t.length-1;return e.jsxs("div",{style:{display:"flex",gap:n.gap},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[e.jsx(bt,{index:s,state:l,step:i,cfg:n}),!d&&e.jsx("div",{style:{width:n.connector,flex:1,minHeight:24,borderRadius:n.connector/2,background:s<r?"var(--lucent-accent-default)":"var(--lucent-border-default)",transition:"background var(--lucent-duration-base) var(--lucent-easing-default)",margin:"4px 0"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"2px",paddingTop:(n.circle-18)/2,paddingBottom:d?0:"var(--lucent-space-4)"},children:[o&&e.jsxs("span",{style:{fontSize:n.prefixSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",textTransform:"uppercase",letterSpacing:"var(--lucent-letter-spacing-wide)"},children:["Step ",s+1]}),e.jsx("span",{style:{fontSize:n.labelSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:l==="current"?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",color:l!=="pending"?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",transition:"color var(--lucent-duration-base) var(--lucent-easing-default)"},children:i.label}),i.description&&e.jsx("span",{style:{fontSize:n.descSize,fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)"},children:i.description}),a&&e.jsx(yt,{state:l})]})]},i.label)})})}function Lo({steps:t,current:r,size:n="md",orientation:o="horizontal",numbered:a=!1,showStatus:i=!1,style:s}){c.useEffect(Do,[]);const l=Mo[n],d=t.map(zo),p=o==="vertical"?Po:Bo;return e.jsx("div",{role:"group","aria-label":"Progress steps",style:{fontFamily:"var(--lucent-font-family-base)",...s},children:e.jsx(p,{steps:d,current:r,cfg:l,numbered:a,showStatus:i})})}const Fo={id:"stepper",name:"Stepper",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A step indicator for multi-step flows — onboarding, wizards, checkout. Supports horizontal and vertical orientations with animated transitions.",designIntent:'Use Stepper to visualise progress through a sequence of discrete steps. Steps can be simple strings or objects with label, description, and custom icon. Completed steps show an animated checkmark (spring scale 0→1.2→1), the current step is highlighted with accent, and future steps are subdued. In horizontal mode the connector track runs behind all circles as a continuous bar; the filled portion animates smoothly between steps. First/last labels align left/right; middle labels center under their circles. Enable numbered to show "STEP N" prefixes and showStatus for Completed/In Progress/Pending Chip badges (success/accent/neutral variants). The vertical orientation suits sidebar layouts and forms with longer descriptive steps. Unlike Progress, Stepper is for discrete named stages, not continuous percentages.',props:[{name:"steps",type:"array",required:!0,description:"Step definitions. Each element is either a string (used as label) or an object { label: string, description?: string, icon?: ReactNode }. Custom icons override the default number/checkmark in the circle."},{name:"current",type:"number",required:!0,description:"Zero-based index of the active step. Steps before this index show as completed; steps after show as pending."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls circle diameter (sm=24, md=32, lg=40), checkmark size, connector thickness, and label font size.",enumValues:["sm","md","lg"]},{name:"orientation",type:"enum",required:!1,default:"horizontal",description:"Layout direction. Horizontal shows circles in a row with a connector track behind them; vertical stacks them with a connector column on the left.",enumValues:["horizontal","vertical"]},{name:"numbered",type:"boolean",required:!1,default:"false",description:'Show uppercase "STEP N" prefix above each step label.'},{name:"showStatus",type:"boolean",required:!1,default:"false",description:'Show a Chip badge below each label — "Completed" (success), "In Progress" (accent), or "Pending" (neutral).'},{name:"style",type:"object",required:!1,description:"Inline style overrides for the root container."}],usageExamples:[{title:"Basic horizontal",code:"<Stepper steps={['Profile', 'Preferences', 'Confirm']} current={1} />",description:"Minimal stepper — string labels, no extras."},{title:"Numbered with status badges",code:`<Stepper
|
|
532
|
+
`;let nt=!1;const xo={xs:"var(--lucent-space-1)",sm:"var(--lucent-space-2)",md:"var(--lucent-space-2)",lg:"var(--lucent-space-3)"},wo={xs:"sm",sm:"sm",md:"md",lg:"lg"},Me=4;function ko(t,r){const n=r.offsetHeight,o=r.offsetWidth,a=window.innerWidth,i=window.innerHeight;let l=t.bottom+Me,s=t.left,d="top left";return l+n>i&&t.top-n-Me>=0&&(l=t.top-n-Me,d="bottom left"),s+o>a&&(s=a-o-8),s<0&&(s=8),{top:l,left:s,transformOrigin:d}}function So({label:t,options:r,value:n,defaultValue:o=[],onChange:a,variant:i="secondary",size:l="sm",disabled:s=!1,icon:d,style:p}){const h=n!==void 0,[f,w]=c.useState(o),y=h?n:f,[g,m]=c.useState(!1),[u,b]=c.useState(!1),[x,k]=c.useState("idle"),[S,C]=c.useState(null),[v,z]=c.useState(-1),T=c.useRef(null),E=c.useRef(null);if(!nt&&typeof document<"u"){const q=document.createElement("style");q.textContent=yo,document.head.appendChild(q),nt=!0}c.useEffect(()=>{if(g)b(!0),k("entering"),z(-1);else if(u){k("exiting");const q=setTimeout(()=>{b(!1),k("idle")},je);return()=>clearTimeout(q)}},[g]),c.useLayoutEffect(()=>{if(!u||x!=="entering"||!T.current)return;const q=requestAnimationFrame(()=>{const N=E.current,H=T.current;!N||!H||C(ko(H.getBoundingClientRect(),N))});return()=>cancelAnimationFrame(q)},[u,x]);const F=c.useCallback(()=>m(!1),[]);c.useEffect(()=>{if(!g)return;const q=H=>{var B,M;const A=H.target;(B=T.current)!=null&&B.contains(A)||(M=E.current)!=null&&M.contains(A)||F()},N=requestAnimationFrame(()=>{document.addEventListener("mousedown",q)});return()=>{cancelAnimationFrame(N),document.removeEventListener("mousedown",q)}},[g,F]),c.useEffect(()=>{if(!g)return;const q=N=>{N.key==="Escape"&&F()};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[g,F]);const R=q=>{const N=y.includes(q)?y.filter(H=>H!==q):[...y,q];h||w(N),a==null||a(N)},j=()=>{h||w([]),a==null||a([]),F()},P=q=>{if(q.key==="ArrowDown")q.preventDefault(),z(N=>(N+1)%r.length);else if(q.key==="ArrowUp")q.preventDefault(),z(N=>(N-1+r.length)%r.length);else if((q.key==="Enter"||q.key===" ")&&v>=0){q.preventDefault();const N=r[v];N&&!N.disabled&&R(N.value)}},D=xo[l],W=wo[l];return e.jsxs("span",{ref:T,style:{display:"inline-flex",...p},children:[e.jsxs(I.Button,{variant:i==="outline"&&y.length>0?"secondary":i==="ghost"?"ghost":i,size:l,...t?{chevron:!0}:{},disabled:s,onClick:()=>!s&&m(q=>!q),...d!==void 0&&{leftIcon:d},children:[t||void 0,y.length>0&&e.jsx(se,{variant:"accent",size:l==="xs"?"sm":l,children:y.length})]}),u&&J.createPortal(e.jsxs("div",{ref:E,role:"listbox","aria-multiselectable":!0,"aria-label":t,tabIndex:-1,onKeyDown:P,style:{position:"fixed",top:(S==null?void 0:S.top)??-9999,left:(S==null?void 0:S.left)??-9999,zIndex:1e3,minWidth:180,background:"color-mix(in srgb, var(--lucent-surface-overlay) 85%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",border:"1px solid color-mix(in srgb, var(--lucent-accent-default) 15%, var(--lucent-border-default))",borderRadius:"var(--lucent-radius-lg)",boxShadow:"0 0 24px -4px color-mix(in srgb, var(--lucent-accent-default) 12%, transparent), var(--lucent-shadow-md)",padding:D,maxHeight:"min(320px, calc(100vh - 32px))",overflowY:"auto",animation:x==="exiting"?`lucent-filter-ms-out ${je}ms var(--lucent-easing-default) forwards`:`lucent-filter-ms-in ${je}ms var(--lucent-easing-decelerate)`,transformOrigin:(S==null?void 0:S.transformOrigin)??"top left",outline:"none",pointerEvents:x==="exiting"?"none":"auto",fontFamily:"var(--lucent-font-family-base)"},children:[r.map((q,N)=>{const H=y.includes(q.value),A=v===N;return e.jsxs("div",{role:"option","aria-selected":H,"aria-disabled":q.disabled,onClick:()=>!q.disabled&&R(q.value),onMouseEnter:()=>z(N),style:{display:"flex",alignItems:"center",gap:"var(--lucent-space-2)",padding:`var(--lucent-space-2) ${D}`,borderRadius:"var(--lucent-radius-md)",cursor:q.disabled?"not-allowed":"pointer",background:A?"var(--lucent-surface-secondary)":"transparent",opacity:q.disabled?.5:1,transition:"background var(--lucent-duration-fast) var(--lucent-easing-default)"},children:[e.jsx(be,{checked:H,onChange:()=>{},disabled:q.disabled,style:{pointerEvents:"none"}}),q.swatch?e.jsx(se,{size:l==="xs"?"sm":l,swatch:q.swatch,children:q.label}):e.jsx(I.Text,{size:W,children:q.label})]},q.value)}),e.jsx("div",{role:"separator",style:{height:1,margin:"var(--lucent-space-1) 0",background:"var(--lucent-border-subtle)"}}),e.jsx("div",{onClick:y.length>0?j:void 0,style:{display:"flex",alignItems:"center",padding:`var(--lucent-space-2) ${D}`,borderRadius:"var(--lucent-radius-md)",cursor:y.length>0?"pointer":"default",opacity:y.length>0?1:.5},children:e.jsx(I.Text,{size:W,color:y.length>0?"secondary":"disabled",children:"Clear all"})})]}),document.body)]})}function To({label:t,options:r,value:n,defaultValue:o,onChange:a,variant:i="secondary",size:l="sm",disabled:s=!1,icon:d,style:p}){var x;const h=n!==void 0,[f,w]=c.useState(o),y=h?n:f,g=(x=r.find(k=>k.value===y))==null?void 0:x.label,m=y!==void 0,u=k=>{h||w(k),a==null||a(k)},b=()=>{h||w(void 0),a==null||a(void 0)};return e.jsxs(Ne,{trigger:e.jsx(I.Button,{variant:i==="outline"&&m?"secondary":i,size:l,chevron:!0,disabled:s,...d!==void 0&&{leftIcon:d},children:g??t}),size:l,...p!==void 0&&{style:p},children:[r.map(k=>e.jsx(me,{selected:y===k.value,...k.disabled!==void 0&&{disabled:k.disabled},onSelect:()=>u(k.value),children:k.label},k.value)),m&&e.jsxs(e.Fragment,{children:[e.jsx(dt,{}),e.jsx(me,{onSelect:b,children:e.jsx(I.Text,{size:l==="lg"?"md":"sm",color:"secondary",children:"Clear"})})]})]})}const Co=()=>e.jsxs("svg",{width:16,height:16,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"})]});function Io({value:t,defaultValue:r="",onChange:n,placeholder:o="Search…",variant:a="secondary",size:i="sm",width:l=260,disabled:s=!1,style:d}){const p=t!==void 0,[h,f]=c.useState(r),w=p?t:h,[y,g]=c.useState(!!w),m=c.useRef(null);c.useEffect(()=>{y&&requestAnimationFrame(()=>{var k;return(k=m.current)==null?void 0:k.focus()})},[y]);const u=k=>{const S=k.target.value;p||f(S),n==null||n(S)},b=()=>{w||g(!1)},x=()=>{s||g(!0)};return y?e.jsx(I.Input,{ref:m,placeholder:o,size:i,value:w,onChange:u,onBlur:b,disabled:s,style:{width:l,...d}}):e.jsx(I.Button,{variant:a,size:i,disabled:s,onClick:x,"aria-label":"Search",leftIcon:e.jsx(Co,{}),style:d})}function jo(t,r){if(!t)return r;const n=o=>o.toLocaleDateString();return`${n(t.start)} → ${n(t.end)}`}function Mo({label:t="Date range",value:r,defaultValue:n,onChange:o,variant:a="secondary",size:i="sm",min:l,max:s,disabled:d=!1,style:p}){const h=r!==void 0;return e.jsx(vt,{size:i,...r!==void 0&&{value:r},...n!==void 0&&{defaultValue:n},...o!==void 0&&{onChange:o},...l!==void 0&&{min:l},...s!==void 0&&{max:s},disabled:d,trigger:e.jsx(I.Button,{variant:a==="outline"&&h?"secondary":a,size:i,chevron:!0,disabled:d,children:jo(r,t)}),...p!==void 0&&{style:p}})}const zo={sm:{circle:24,checkIcon:12,connector:2,labelSize:"var(--lucent-font-size-xs)",descSize:"var(--lucent-font-size-xs)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-2)"},md:{circle:32,checkIcon:14,connector:2,labelSize:"var(--lucent-font-size-sm)",descSize:"var(--lucent-font-size-xs)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-3)"},lg:{circle:40,checkIcon:18,connector:3,labelSize:"var(--lucent-font-size-md)",descSize:"var(--lucent-font-size-sm)",prefixSize:"var(--lucent-font-size-xs)",gap:"var(--lucent-space-3)"}};function Eo(t){return typeof t=="string"?{label:t}:t}function Ao({size:t}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Pe(t,r){return t<r?"completed":t===r?"current":"pending"}const qo={completed:"Completed",current:"In Progress",pending:"Pending"},Do={completed:"success",current:"accent",pending:"neutral"},rt="lucent-stepper-keyframes";function Ro(){if(typeof document>"u"||document.getElementById(rt))return;const t=document.createElement("style");t.id=rt,t.textContent="@keyframes lucent-stepper-check{0%{transform:scale(0)}60%{transform:scale(1.2)}100%{transform:scale(1)}}",document.head.appendChild(t)}function St({index:t,state:r,step:n,cfg:o}){const a=r!=="pending";return e.jsx("div",{"aria-current":r==="current"?"step":void 0,style:{width:o.circle,height:o.circle,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:o.labelSize,fontWeight:"var(--lucent-font-weight-semibold)",fontFamily:"var(--lucent-font-family-base)",background:a?"var(--lucent-accent-default)":"color-mix(in srgb, var(--lucent-text-secondary) 12%, var(--lucent-surface))",color:a?"var(--lucent-accent-fg)":"var(--lucent-text-secondary)",transition:"background var(--lucent-duration-base) var(--lucent-easing-default), color var(--lucent-duration-base) var(--lucent-easing-default)",flexShrink:0},children:n.icon?n.icon:r==="completed"?e.jsx("span",{style:{display:"flex",animation:"lucent-stepper-check 300ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:e.jsx(Ao,{size:o.checkIcon})}):t+1})}function Tt({state:t}){return e.jsx(se,{variant:Do[t],size:"sm",borderless:!0,children:qo[t]})}function Bo({step:t,state:r,index:n,cfg:o,numbered:a,showStatus:i}){return e.jsxs(e.Fragment,{children:[a&&e.jsxs("span",{style:{fontSize:o.prefixSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",textTransform:"uppercase",letterSpacing:"var(--lucent-letter-spacing-wide)"},children:["Step ",n+1]}),e.jsx("span",{style:{fontSize:o.labelSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:r==="current"?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",color:r!=="pending"?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",transition:"color var(--lucent-duration-base) var(--lucent-easing-default)"},children:t.label}),t.description&&e.jsx("span",{style:{fontSize:o.descSize,fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)"},children:t.description}),i&&e.jsx(Tt,{state:r})]})}function Po({steps:t,current:r,cfg:n,numbered:o,showStatus:a}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n.gap},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",position:"relative"},children:[e.jsx("div",{style:{position:"absolute",left:n.circle/2,right:n.circle/2,top:n.circle/2-n.connector/2,height:n.connector,borderRadius:n.connector/2,background:"var(--lucent-border-default)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:n.connector/2,background:"var(--lucent-accent-default)",width:t.length>1?`${r/(t.length-1)*100}%`:"0%",transition:"width 300ms var(--lucent-easing-default)"}})}),t.map((i,l)=>e.jsx("div",{style:{flex:1,display:"flex",justifyContent:l===0?"flex-start":l===t.length-1?"flex-end":"center",position:"relative",zIndex:1},children:e.jsx(St,{index:l,state:Pe(l,r),step:i,cfg:n})},i.label))]}),e.jsx("div",{style:{display:"flex"},children:t.map((i,l)=>{const s=Pe(l,r),d=l===t.length-1,p=l===0?"flex-start":d?"flex-end":"center",h=l===0?"left":d?"right":"center";return e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:p,gap:"2px",textAlign:h},children:e.jsx(Bo,{step:i,state:s,index:l,cfg:n,numbered:o,showStatus:a})},i.label)})})]})}function Lo({steps:t,current:r,cfg:n,numbered:o,showStatus:a}){return e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.map((i,l)=>{const s=Pe(l,r),d=l===t.length-1;return e.jsxs("div",{style:{display:"flex",gap:n.gap},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",flexShrink:0},children:[e.jsx(St,{index:l,state:s,step:i,cfg:n}),!d&&e.jsx("div",{style:{width:n.connector,flex:1,minHeight:24,borderRadius:n.connector/2,background:l<r?"var(--lucent-accent-default)":"var(--lucent-border-default)",transition:"background var(--lucent-duration-base) var(--lucent-easing-default)",margin:"4px 0"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"2px",paddingTop:(n.circle-18)/2,paddingBottom:d?0:"var(--lucent-space-4)"},children:[o&&e.jsxs("span",{style:{fontSize:n.prefixSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:"var(--lucent-font-weight-medium)",color:"var(--lucent-text-secondary)",textTransform:"uppercase",letterSpacing:"var(--lucent-letter-spacing-wide)"},children:["Step ",l+1]}),e.jsx("span",{style:{fontSize:n.labelSize,fontFamily:"var(--lucent-font-family-base)",fontWeight:s==="current"?"var(--lucent-font-weight-semibold)":"var(--lucent-font-weight-regular)",color:s!=="pending"?"var(--lucent-text-primary)":"var(--lucent-text-secondary)",transition:"color var(--lucent-duration-base) var(--lucent-easing-default)"},children:i.label}),i.description&&e.jsx("span",{style:{fontSize:n.descSize,fontFamily:"var(--lucent-font-family-base)",color:"var(--lucent-text-secondary)"},children:i.description}),a&&e.jsx(Tt,{state:s})]})]},i.label)})})}function Fo({steps:t,current:r,size:n="md",orientation:o="horizontal",numbered:a=!1,showStatus:i=!1,style:l}){c.useEffect(Ro,[]);const s=zo[n],d=t.map(Eo),p=o==="vertical"?Lo:Po;return e.jsx("div",{role:"group","aria-label":"Progress steps",style:{fontFamily:"var(--lucent-font-family-base)",...l},children:e.jsx(p,{steps:d,current:r,cfg:s,numbered:a,showStatus:i})})}const No={id:"stepper",name:"Stepper",tier:"molecule",domain:"neutral",specVersion:"1.0",description:"A step indicator for multi-step flows — onboarding, wizards, checkout. Supports horizontal and vertical orientations with animated transitions.",designIntent:'Use Stepper to visualise progress through a sequence of discrete steps. Steps can be simple strings or objects with label, description, and custom icon. Completed steps show an animated checkmark (spring scale 0→1.2→1), the current step is highlighted with accent, and future steps are subdued. In horizontal mode the connector track runs behind all circles as a continuous bar; the filled portion animates smoothly between steps. First/last labels align left/right; middle labels center under their circles. Enable numbered to show "STEP N" prefixes and showStatus for Completed/In Progress/Pending Chip badges (success/accent/neutral variants). The vertical orientation suits sidebar layouts and forms with longer descriptive steps. Unlike Progress, Stepper is for discrete named stages, not continuous percentages.',props:[{name:"steps",type:"array",required:!0,description:"Step definitions. Each element is either a string (used as label) or an object { label: string, description?: string, icon?: ReactNode }. Custom icons override the default number/checkmark in the circle."},{name:"current",type:"number",required:!0,description:"Zero-based index of the active step. Steps before this index show as completed; steps after show as pending."},{name:"size",type:"enum",required:!1,default:"md",description:"Controls circle diameter (sm=24, md=32, lg=40), checkmark size, connector thickness, and label font size.",enumValues:["sm","md","lg"]},{name:"orientation",type:"enum",required:!1,default:"horizontal",description:"Layout direction. Horizontal shows circles in a row with a connector track behind them; vertical stacks them with a connector column on the left.",enumValues:["horizontal","vertical"]},{name:"numbered",type:"boolean",required:!1,default:"false",description:'Show uppercase "STEP N" prefix above each step label.'},{name:"showStatus",type:"boolean",required:!1,default:"false",description:'Show a Chip badge below each label — "Completed" (success), "In Progress" (accent), or "Pending" (neutral).'},{name:"style",type:"object",required:!1,description:"Inline style overrides for the root container."}],usageExamples:[{title:"Basic horizontal",code:"<Stepper steps={['Profile', 'Preferences', 'Confirm']} current={1} />",description:"Minimal stepper — string labels, no extras."},{title:"Numbered with status badges",code:`<Stepper
|
|
519
533
|
steps={['Basic Details', 'Company Details', 'Subscription', 'Payment']}
|
|
520
534
|
current={2}
|
|
521
535
|
numbered
|
|
@@ -551,7 +565,39 @@ dismiss(id);`},{title:"Custom icon",description:"Override the built-in variant i
|
|
|
551
565
|
<Button variant="primary" size="sm" onClick={() => setStep(s => s + 1)}>Continue</Button>
|
|
552
566
|
</Row>
|
|
553
567
|
</Stack>
|
|
554
|
-
</Card>`,description:"Stepper paired with step content and navigation buttons inside a Card."}],compositionGraph:[{componentId:"chip",componentName:"Chip",role:"Status badge for each step (Completed/In Progress/Pending)",required:!1}],accessibility:{role:"group",ariaAttributes:["aria-label","aria-current"],keyboardInteractions:[],notes:'Root element has role="group" with aria-label="Progress steps". The current step circle receives aria-current="step" so screen readers can identify which step is active. Step labels are visible text, not aria-only. The checkmark animation uses prefers-reduced-motion: the spring scale is purely decorative and does not affect content comprehension.'}},No={navigation:{description:"Chrome/shell background for sidebars, headers, footers, and navigation rails. The outermost structural layer of the UI. Independent of bgBase — set it explicitly when the chrome needs a different tint than the content area.",lightGuidance:"A very faint cool or warm tint that distinguishes the chrome from the content area. Default #f4f6f8. Typically L 0.95–0.98.",darkGuidance:"The darkest layer — near-black with a subtle cool or warm tint. Typically L 0.06–0.09 (e.g. #0f0f11, #111318).",derives:[]},bgBase:{description:"Main content area background. The canvas on which surface elements (cards, tables, panels) sit. Slightly distinct from `navigation` to create a visual content/chrome boundary. When bgBase is customized, `surface` and `surfaceTint` are auto-derived so the entire card elevation hierarchy adapts automatically.",lightGuidance:"White or near-white. Default #ffffff. The content canvas that surface elements (cards) sit on.",darkGuidance:"Slightly lighter than navigation. Typically L 0.08–0.11 (e.g. #14161c, #15171e).",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:"White or near-white. Default #ffffff. Cards and panels sit on this surface above the content area background.",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 accentFg (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","accentSubtle","accentBorder","accentFg"]},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"]}},$o={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`, `accentSubtle`, `accentBorder`, and `accentFg`.\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\nAPCA auto-computation: `accentFg` is always computed from the resolved accent color via APCA contrast — it will be #000000 or #ffffff, whichever has higher perceived 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), navigation (chrome background — defaults to base theme value)."},{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';
|
|
568
|
+
</Card>`,description:"Stepper paired with step content and navigation buttons inside a Card."}],compositionGraph:[{componentId:"chip",componentName:"Chip",role:"Status badge for each step (Completed/In Progress/Pending)",required:!1}],accessibility:{role:"group",ariaAttributes:["aria-label","aria-current"],keyboardInteractions:[],notes:'Root element has role="group" with aria-label="Progress steps". The current step circle receives aria-current="step" so screen readers can identify which step is active. Step labels are visible text, not aria-only. The checkmark animation uses prefers-reduced-motion: the spring scale is purely decorative and does not affect content comprehension.'}};function at(t,r,n){return e.jsx(I.Button,{size:"sm",variant:t.variant??r,...t.onClick!==void 0&&{onClick:t.onClick},...t.leftIcon!==void 0&&{leftIcon:t.leftIcon},...t.rightIcon!==void 0&&{rightIcon:t.rightIcon},...t.disabled!==void 0&&{disabled:t.disabled},...t.loading!==void 0&&{loading:t.loading},...t["aria-label"]!==void 0&&{"aria-label":t["aria-label"]},children:t.label},n)}function $o({title:t,subtitle:r,breadcrumbs:n,action:o,secondaryActions:a,hideDivider:i=!1,style:l}){const s=a!=null&&a.length>0,d=o!=null,p=s||d;return e.jsxs(ze,{gap:"4",...l!==void 0&&{style:l},children:[n!=null&&n.length>0&&e.jsx(ft,{items:n}),e.jsxs(Ee,{justify:"between",align:"end",wrap:!0,gap:"3",children:[e.jsxs(ze,{gap:"1",style:{minWidth:0},children:[e.jsx(I.Text,{as:"h1",size:"3xl",weight:"bold",family:"display",children:t}),r!=null&&e.jsx(I.Text,{size:"sm",color:"secondary",children:r})]}),p&&e.jsxs(Ee,{gap:"2",wrap:!0,children:[s&&a.map((h,f)=>at(h,"outline",f)),d&&at(o,"primary")]})]}),!i&&e.jsx(st,{})]})}const Wo={id:"page-header",name:"PageHeader",tier:"molecule",domain:"neutral",specVersion:"0.1",description:"A page-level header pairing breadcrumbs, a large display title, optional subtitle, and up to one primary CTA with 0–3 secondary outline actions.",designIntent:'PageHeader is the canonical chrome for a page body. It encapsulates the action-bar pattern — breadcrumbs on top, a 3xl display title with optional subtitle below, action buttons anchored to the title baseline, and a divider separating the header from page content. The component owns three zones: breadcrumbs (nav context), title block, and action slot. \n\n## Multi-action support\nThe `action` prop holds the single primary CTA (rightmost position, `variant="primary"` by default). The `secondaryActions` prop accepts 0–3 additional actions that render to the left of the primary action with `variant="outline"` by default, keeping them visually subordinate. This covers the common detail-page need for Edit / Archive / primary-CTA triples without forcing consumers to rebuild the header from primitives. Beyond 3 secondary actions, reach for SplitButton or an overflow menu instead of widening the row.\n\n## Responsive behaviour\nBoth the outer title/action Row and the inner action Row set `wrap` so the button group flows below the title on narrow viewports instead of overflowing. `align="end"` anchors the buttons to the baseline of the subtitle line when the layout is horizontal.\n\n## Styling\nAll spacing, typography, and colors come from Lucent tokens — no custom values. The title uses the display font family and 3xl size; the subtitle uses the base font at sm/secondary. The bottom divider can be hidden via `hideDivider` when the header sits directly above another bordered surface.',props:[{name:"title",type:"string",required:!0,description:"Page title rendered as an h1 in the display font at 3xl size."},{name:"subtitle",type:"ReactNode",required:!1,description:"Optional subtitle or metadata line rendered below the title at sm/secondary."},{name:"breadcrumbs",type:"array",required:!1,description:"Breadcrumb items rendered above the title via the Breadcrumb molecule. Provides navigation context."},{name:"action",type:"object",required:!1,description:'Single primary CTA rendered rightmost. Shape: { label, onClick?, variant?, leftIcon?, rightIcon?, disabled?, loading? }. Defaults to variant="primary". Pass `null` to explicitly omit when spreading dynamic props.'},{name:"secondaryActions",type:"array",required:!1,description:'0–3 secondary actions rendered to the left of `action`. Each item uses the same PageHeaderAction shape as `action`. Defaults to variant="outline" so they stay visually subordinate. For more than 3 actions, use a SplitButton or overflow menu.'},{name:"hideDivider",type:"boolean",required:!1,default:"false",description:"Hide the bottom divider. Use when the header sits directly above another bordered surface."},{name:"style",type:"object",required:!1,description:"Inline style overrides for the outer Stack wrapper."}],usageExamples:[{title:"Minimal — title only",code:'<PageHeader title="Settings" />'},{title:"With subtitle and single primary action",code:`<PageHeader
|
|
569
|
+
title="Acme Corp"
|
|
570
|
+
subtitle="Last updated 5 minutes ago"
|
|
571
|
+
action={{ label: 'New report', onClick: () => createReport() }}
|
|
572
|
+
/>`},{title:"Detail view with secondary actions (Edit / Archive / Submit)",code:`<PageHeader
|
|
573
|
+
title="Sana Khan"
|
|
574
|
+
subtitle="Senior Product Designer · Added 3 days ago"
|
|
575
|
+
breadcrumbs={[
|
|
576
|
+
{ label: 'Home', href: '#' },
|
|
577
|
+
{ label: 'Candidates', href: '#' },
|
|
578
|
+
{ label: 'Sana Khan' },
|
|
579
|
+
]}
|
|
580
|
+
secondaryActions={[
|
|
581
|
+
{ label: 'Edit', onClick: () => openEdit() },
|
|
582
|
+
{ label: 'Archive', onClick: () => archive() },
|
|
583
|
+
]}
|
|
584
|
+
action={{ label: 'Submit to opportunity', onClick: () => submit() }}
|
|
585
|
+
/>`},{title:"Danger zone",code:`<PageHeader
|
|
586
|
+
title="Danger zone"
|
|
587
|
+
subtitle="These actions are irreversible."
|
|
588
|
+
breadcrumbs={[
|
|
589
|
+
{ label: 'Home', href: '#' },
|
|
590
|
+
{ label: 'Settings', href: '#' },
|
|
591
|
+
{ label: 'Danger zone' },
|
|
592
|
+
]}
|
|
593
|
+
action={{ label: 'Delete project', variant: 'danger', onClick: () => confirmDelete() }}
|
|
594
|
+
/>`},{title:"No primary CTA, secondary actions only",code:`<PageHeader
|
|
595
|
+
title="Reports"
|
|
596
|
+
secondaryActions={[
|
|
597
|
+
{ label: 'Export', onClick: () => exportAll() },
|
|
598
|
+
{ label: 'Filter', onClick: () => openFilter() },
|
|
599
|
+
]}
|
|
600
|
+
/>`}],compositionGraph:[{componentId:"breadcrumb",componentName:"Breadcrumb",role:"Navigation context above the title",required:!1},{componentId:"stack",componentName:"Stack",role:"Vertical layout for title and subtitle",required:!0},{componentId:"row",componentName:"Row",role:"Horizontal layout for title block and action slot",required:!0},{componentId:"text",componentName:"Text",role:"Title and subtitle rendering",required:!0},{componentId:"button",componentName:"Button",role:"Primary and secondary action buttons",required:!1},{componentId:"divider",componentName:"Divider",role:"Separator between header chrome and page content",required:!1}],accessibility:{notes:`The title renders as an <h1>, providing the page heading landmark for assistive tech. Breadcrumbs render inside <nav aria-label="Breadcrumb">. Action buttons inherit Button's focus ring, keyboard activation, and aria-label forwarding — pass aria-label on each action object when the label alone is insufficient (e.g. icon-only buttons).`}},Oo={navigation:{description:"Chrome/shell background for sidebars, headers, footers, and navigation rails. The outermost structural layer of the UI. Independent of bgBase — set it explicitly when the chrome needs a different tint than the content area.",lightGuidance:"A very faint cool or warm tint that distinguishes the chrome from the content area. Default #f4f6f8. Typically L 0.95–0.98.",darkGuidance:"The darkest layer — near-black with a subtle cool or warm tint. Typically L 0.06–0.09 (e.g. #0f0f11, #111318).",derives:[]},bgBase:{description:"Main content area background. The canvas on which surface elements (cards, tables, panels) sit. Slightly distinct from `navigation` to create a visual content/chrome boundary. When bgBase is customized, `surface` and `surfaceTint` are auto-derived so the entire card elevation hierarchy adapts automatically.",lightGuidance:"White or near-white. Default #ffffff. The content canvas that surface elements (cards) sit on.",darkGuidance:"Slightly lighter than navigation. Typically L 0.08–0.11 (e.g. #14161c, #15171e).",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:"White or near-white. Default #ffffff. Cards and panels sit on this surface above the content area background.",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 accentFg (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","accentSubtle","accentBorder","accentFg"]},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"]}},Vo={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`, `accentSubtle`, `accentBorder`, and `accentFg`.\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\nAPCA auto-computation: `accentFg` is always computed from the resolved accent color via APCA contrast — it will be #000000 or #ffffff, whichever has higher perceived 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), navigation (chrome background — defaults to base theme value)."},{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';
|
|
555
601
|
|
|
556
602
|
<LucentProvider preset="modern">
|
|
557
603
|
<App />
|
|
@@ -643,6 +689,6 @@ const myTheme = createTheme({
|
|
|
643
689
|
<App />
|
|
644
690
|
</main>
|
|
645
691
|
</div>
|
|
646
|
-
</LucentProvider>`}],compositionGraph:[]},
|
|
692
|
+
</LucentProvider>`}],compositionGraph:[]},Ho={accentDefault:"#e9c96b",accentHover:"#ddb84e",accentSubtle:"#fef9ec"};function Go(t,r="light"){const n=r==="light";return{accentDefault:t,accentHover:I.adjustLightness(t,n?.05:-.07),accentSubtle:I.adjustLightness(t,n?.85:-.6),accentBorder:I.adjustLightness(t,n?-.15:.15),accentFg:I.getAccentFg(t)}}function Y(t,r){return{field:t,message:r}}function Ct(t){const r=[];if(typeof t!="object"||t===null)return{valid:!1,errors:[Y("manifest","Must be a non-null object")]};const n=t,o=["id","name","description","designIntent","specVersion"];for(const i of o)(typeof n[i]!="string"||n[i].trim()==="")&&r.push(Y(i,"Must be a non-empty string"));typeof n.id=="string"&&!/^[a-z][a-z0-9-]*$/.test(n.id)&&r.push(Y("id",'Must be kebab-case (e.g. "button", "form-field")'));const a=["atom","molecule","block","flow","overlay","provider"];return a.includes(n.tier)||r.push(Y("tier",`Must be one of: ${a.join(", ")}`)),(typeof n.domain!="string"||n.domain.trim()==="")&&r.push(Y("domain","Must be a non-empty string")),Array.isArray(n.props)?n.props.forEach((i,l)=>{const s=i,d=`props[${l}]`;(typeof s.name!="string"||s.name==="")&&r.push(Y(`${d}.name`,"Must be a non-empty string")),(typeof s.type!="string"||s.type==="")&&r.push(Y(`${d}.type`,"Must be a non-empty string")),typeof s.required!="boolean"&&r.push(Y(`${d}.required`,"Must be a boolean")),(typeof s.description!="string"||s.description==="")&&r.push(Y(`${d}.description`,"Must be a non-empty string"))}):r.push(Y("props","Must be an array")),Array.isArray(n.usageExamples)?n.usageExamples.length===0?r.push(Y("usageExamples","Must have at least one example")):n.usageExamples.forEach((i,l)=>{const s=i,d=`usageExamples[${l}]`;(typeof s.title!="string"||s.title==="")&&r.push(Y(`${d}.title`,"Must be a non-empty string")),(typeof s.code!="string"||s.code==="")&&r.push(Y(`${d}.code`,"Must be a non-empty string"))}):r.push(Y("usageExamples","Must be an array")),Array.isArray(n.compositionGraph)||r.push(Y("compositionGraph","Must be an array (empty array is fine for atoms)")),typeof n.specVersion=="string"&&!/^\d+\.\d+$/.test(n.specVersion)&&r.push(Y("specVersion",'Must be "MAJOR.MINOR" format, e.g. "0.1"')),{valid:r.length===0,errors:r}}function Uo(t){const r=Ct(t);if(!r.valid){const n=r.errors.map(o=>` ${o.field}: ${o.message}`).join(`
|
|
647
693
|
`);throw new Error(`Invalid ComponentManifest:
|
|
648
|
-
${n}`)}}function
|
|
694
|
+
${n}`)}}function _o(t){if(typeof t!="object"||t===null)return!1;const r=t;return typeof r.name=="string"&&typeof r.type=="string"&&typeof r.required=="boolean"&&typeof r.description=="string"}const Yo="1.0",Ko="0.1.0";exports.Badge=I.Badge;exports.Button=I.Button;exports.ColorPicker=I.ColorPicker;exports.ColorSwatch=I.ColorSwatch;exports.Input=I.Input;exports.LucentProvider=I.LucentProvider;exports.SegmentedControl=I.SegmentedControl;exports.Select=I.Select;exports.Slider=I.Slider;exports.Tabs=I.Tabs;exports.Text=I.Text;exports.Toggle=I.Toggle;exports.bentoPreset=I.bentoPreset;exports.bloomPreset=I.bloomPreset;exports.brandPalette=I.brandPalette;exports.brutalistPreset=I.brutalistPreset;exports.brutalistShadow=I.brutalistShadow;exports.compactDensity=I.compactDensity;exports.createTheme=I.createTheme;exports.darkTokens=I.darkTokens;exports.defaultDensity=I.defaultDensity;exports.defaultPalette=I.defaultPalette;exports.deriveDarkFromLight=I.deriveDarkFromLight;exports.deriveTokens=I.deriveTokens;exports.elevatedShadow=I.elevatedShadow;exports.emeraldPalette=I.emeraldPalette;exports.enterprisePreset=I.enterprisePreset;exports.flatShadow=I.flatShadow;exports.getAccentFg=I.getAccentFg;exports.getContrastText=I.getContrastText;exports.glowShadow=I.glowShadow;exports.indigoPalette=I.indigoPalette;exports.lightTokens=I.lightTokens;exports.liquidGlassPreset=I.liquidGlassPreset;exports.liquidGlassShadow=I.liquidGlassShadow;exports.makeLibraryCSS=I.makeLibraryCSS;exports.minimalPreset=I.minimalPreset;exports.modernPreset=I.modernPreset;exports.naturalShadow=I.naturalShadow;exports.neumorphicShadow=I.neumorphicShadow;exports.oceanPalette=I.oceanPalette;exports.pillShape=I.pillShape;exports.playfulPreset=I.playfulPreset;exports.resolvePreset=I.resolvePreset;exports.rosePalette=I.rosePalette;exports.roundedShape=I.roundedShape;exports.sharpShape=I.sharpShape;exports.softUIPreset=I.softUIPreset;exports.spaciousDensity=I.spaciousDensity;exports.subtleShadow=I.subtleShadow;exports.terminalPreset=I.terminalPreset;exports.useLucent=I.useLucent;exports.Alert=Fr;exports.AlertManifest=Nr;exports.Avatar=$t;exports.AvatarManifest=Wt;exports.BadgeManifest=qt;exports.Breadcrumb=ft;exports.ButtonGroup=ht;exports.ButtonGroupManifest=sr;exports.ButtonManifest=It;exports.CHIP_MANIFEST=Pt;exports.COLOR_PICKER_MANIFEST=qn;exports.COLOR_SWATCH_MANIFEST=Dn;exports.COMMAND_PALETTE_MANIFEST=sa;exports.Card=Mr;exports.CardBleed=zr;exports.CardManifest=Er;exports.CardPaddingContext=ye;exports.Checkbox=be;exports.CheckboxManifest=Kt;exports.Chip=se;exports.CodeBlock=Sn;exports.CodeBlockManifest=Tn;exports.Collapsible=Yr;exports.CommandPalette=ia;exports.DATA_TABLE_MANIFEST=ra;exports.DATE_PICKER_MANIFEST=za;exports.DATE_RANGE_PICKER_MANIFEST=Ba;exports.DataTable=Qr;exports.DatePicker=Ma;exports.DateRangePicker=vt;exports.Divider=st;exports.DividerManifest=Gt;exports.EmptyState=$r;exports.EmptyStateManifest=Wr;exports.FILE_UPLOAD_MANIFEST=Na;exports.FileUpload=Fa;exports.FilterDateRange=Mo;exports.FilterMultiSelect=So;exports.FilterSearch=Io;exports.FilterSelect=To;exports.FormField=lr;exports.FormFieldManifest=cr;exports.Icon=mn;exports.IconManifest=gn;exports.InputManifest=jt;exports.LUCENT_UI_VERSION=Ko;exports.LucentProviderManifest=Vo;exports.MANIFEST_SPEC_VERSION=Yo;exports.MULTI_SELECT_MANIFEST=ha;exports.Menu=Ne;exports.MenuGroup=Jn;exports.MenuItem=me;exports.MenuManifest=Zn;exports.MenuSeparator=dt;exports.MultiSelect=pa;exports.NavLink=bn;exports.NavMenu=le;exports.NavMenuGroup=wt;exports.NavMenuItem=xt;exports.NavMenuSeparator=kt;exports.NavMenuSub=$e;exports.PageHeader=$o;exports.PageHeaderManifest=Wo;exports.PageLayout=Jr;exports.Progress=Hn;exports.ProgressManifest=Gn;exports.Radio=en;exports.RadioGroup=ct;exports.RadioGroupUncontrolled=tn;exports.RadioManifest=nn;exports.Row=Ee;exports.RowManifest=$n;exports.SEGMENTED_CONTROL_MANIFEST=Rn;exports.SearchInput=mr;exports.SearchInputManifest=gr;exports.SelectManifest=an;exports.Skeleton=Hr;exports.SkeletonManifest=Gr;exports.SliderManifest=yn;exports.Spinner=it;exports.SpinnerManifest=Ht;exports.SplitButton=pt;exports.SplitButtonManifest=ir;exports.Stack=ze;exports.StackManifest=Ln;exports.Stepper=Fo;exports.StepperManifest=No;exports.TIMELINE_MANIFEST=Va;exports.Table=ne;exports.TableManifest=An;exports.Tag=ln;exports.TagManifest=cn;exports.TextManifest=vn;exports.Textarea=ot;exports.TextareaManifest=At;exports.ThemeAnchorsSpec=Oo;exports.Timeline=Oa;exports.ToastManifest=fo;exports.ToastProvider=ho;exports.ToggleManifest=rn;exports.Tooltip=pn;exports.TooltipManifest=hn;exports.accentTokens=Go;exports.assertManifest=Uo;exports.brandTokens=Ho;exports.isValidPropDescriptor=_o;exports.useToast=Ha;exports.validateManifest=Ct;
|