{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "contained-list",
  "type": "registry:ui",
  "title": "<ui-contained-list>",
  "description": "Carbon `ContainedList`: a titled list of rows separated by 1px rules, for settings panels, side panels and tiles. `kind=\"on-page\"` (default) has a 48px heading-compact header on the page background; `kind=\"disclosed\"` a 32px label-01 header on the layer. `size` sets the row height (sm 32 / md 40 / lg 48 / xl 64), `inset` shortens the rules to the padding. Put a `<ui-search>` or `<ui-icon-button>` in slot `action` for a header control. Beyond Carbon: `current` marks the whole list (the selected board among several): the side nav's start bar on the header and `aria-current=\"true\"` on the `role=list` the label names. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [
    "lit@^3.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-field",
    "@kanok-ui/shared-slots",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/contained-list/contained-list-item.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/contained-list/contained-list-item.ts",
      "content": "import { LitElement, css, html, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { SlotController } from '../shared/slots.ts';\nimport { UiElement } from '../shared/element.ts';\n\n/**\n * One row of a `<ui-contained-list>` (Carbon `ContainedListItem`). Set `clickable` to make the\n * row a button (fires `ui-click`; `disabled` greys it out); slot `icon` adds a 16px leading icon and\n * slot `action` a trailing control (e.g. `<ui-icon-button>`) that stays interactive on its own.\n * Beyond Carbon (which has no selected row): `current` marks the row the user is on, with the side\n * nav's current-page look and `aria-current=\"true\"` (on the button when `clickable`, else on the row).\n *\n * @slot - Row content\n * @slot icon - 16px icon\n * @slot action - Trailing action\n * @fires ui-click - Clickable rows, when activated\n * @csspart content - The row body (a button when `clickable`)\n * @csspart action - The action wrapper\n * @cssprop --ui-nav-current-background / --ui-nav-current-mark - The `current` row's fill and start bar, the side nav's settings (default canvas-selected, primary; Kanok: the highlight tint, no bar)\n * @cssprop --ui-nav-current-mark-width / --ui-nav-current-mark-inset / --ui-nav-current-mark-radius - The bar's width (3px), top and bottom inset (0) and corners (0)\n */\n@customElement('ui-contained-list-item')\nexport class UiContainedListItem extends UiElement {\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            position: relative;\n            display: list-item;\n            list-style: none;\n            --_h: var(--ui-field-height-lg, 48px);\n            --_pad: var(--ui-space-md);\n        }\n\n        /*\n         * Carbon: rows after the first overlap the one above by 1px. The margin sits on the first part and\n         * collapses through the host (a block box without padding or border) — on :host a page-wide\n         * CSS reset would remove it.\n         */\n        :host(:not(:first-of-type)) .content {\n            margin-block-start: -1px;\n        }\n\n        :host([data-size='sm']) {\n            --_h: 32px;\n        }\n\n        :host([data-size='md']) {\n            --_h: 40px;\n        }\n\n        :host([data-size='xl']) {\n            --_h: 64px;\n        }\n\n        :host(:not(:last-of-type))::before {\n            content: '';\n            position: absolute;\n            inset-block-end: 0;\n            inset-inline: 0;\n            block-size: 1px;\n            background-color: var(--ui-hairline);\n        }\n\n        :host([data-inset]:not(:last-of-type))::before {\n            inset-inline: var(--_pad);\n        }\n\n        .content {\n            box-sizing: border-box;\n            display: block;\n            inline-size: 100%;\n            min-block-size: var(--_h);\n            margin: 0;\n            padding: calc((var(--_h) - 20px) / 2) var(--_pad);\n            border: none;\n            background: transparent;\n            color: var(--ui-ink);\n            font: var(--ui-font-body-sm);\n            line-height: 20px; /* body-01 */\n            letter-spacing: var(--ui-tracking-body);\n            text-align: start;\n            transition: background-color var(--ui-duration-moderate-01) var(--ui-easing); /* Carbon moderate-01 */\n        }\n\n        :host([data-with-action]) .content {\n            padding-inline-end: var(--ui-space-xxl);\n        }\n\n        .inner {\n            display: grid;\n            grid-template-columns: 1fr;\n            column-gap: var(--ui-space-sm);\n        }\n\n        :host([data-with-icon]) .inner {\n            grid-template-columns: 1rem 1fr;\n        }\n\n        .icon {\n            display: none;\n            padding-block-start: 2px;\n        }\n\n        :host([data-with-icon]) .icon {\n            display: inline-flex;\n        }\n\n        ::slotted([slot='icon']) {\n            width: 16px;\n            height: 16px;\n            fill: var(--ui-icon-primary);\n        }\n\n        button.content {\n            cursor: pointer;\n            outline: none;\n        }\n\n        button.content:not(:disabled):hover {\n            background-color: var(--ui-ghost-hover);\n        }\n\n        button.content:not(:disabled):active {\n            background-color: var(--ui-ghost-active);\n        }\n\n        button.content:disabled {\n            color: var(--ui-ink-disabled);\n            cursor: not-allowed;\n        }\n\n        button.content:focus-visible::after {\n            content: '';\n            position: absolute;\n            inset: 0;\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: -2px;\n            border-radius: var(--ui-focus-radius, 0); /* Kanok: 6px */\n        }\n\n        /* beyond Carbon: the row the user is on, the side nav's current page (--ui-nav-current-*; Kanok: a tint) — it keeps the fill under the pointer, as there */\n        :host([current]) .content,\n        :host([current]) button.content:not(:disabled):is(:hover, :active) {\n            background-color: var(--ui-nav-current-background, var(--ui-canvas-selected));\n        }\n\n        :host([current]) .content::before {\n            content: '';\n            position: absolute;\n            inset-block: var(--ui-nav-current-mark-inset, 0);\n            inset-inline-start: 0;\n            inline-size: var(--ui-nav-current-mark-width, 3px);\n            border-radius: var(--ui-nav-current-mark-radius, 0);\n            background-color: var(--ui-nav-current-mark, var(--ui-primary)); /* border-interactive */\n        }\n\n        .action {\n            position: absolute;\n            inset-block-start: 0;\n            inset-inline: 0;\n            display: none;\n            align-items: center; /* a smaller control still sits on the row's centre line */\n            justify-content: flex-end;\n            block-size: var(--_h);\n            pointer-events: none;\n        }\n\n        :host([data-with-action]) .action {\n            display: flex;\n        }\n\n        ::slotted([slot='action']) {\n            pointer-events: all;\n        }\n\n        @media (forced-colors: active) {\n            :host(:not(:last-of-type))::before {\n                background-color: CanvasText;\n            }\n\n            :host([current]) .content::before {\n                inline-size: 3px; /* shown here even where a design hides it */\n                background-color: Highlight;\n            }\n        }\n    `;\n\n    /** Render the row as a button. */\n    @property({ type: Boolean, reflect: true }) clickable = false;\n\n    @property({ type: Boolean, reflect: true }) disabled = false;\n\n    /** Beyond Carbon: the row the user is on (`aria-current=\"true\"`, the side nav's current-page look). */\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    private readonly slots = new SlotController(this);\n    /** The row itself carries aria-current (a `current` row that isn't `clickable`). */\n    private currentOnHost = false;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem');\n    }\n\n    protected override updated() {\n        this.toggleAttribute('data-with-icon', this.slots.has('icon'));\n        this.toggleAttribute('data-with-action', this.slots.has('action'));\n        this.syncCurrent();\n    }\n\n    /** aria-current on the row when it has no button to carry it; an author's own value is left alone. */\n    private syncCurrent() {\n        const onHost = this.current && !this.clickable;\n        if (onHost) this.setAttribute('aria-current', 'true');\n        else if (this.currentOnHost) this.removeAttribute('aria-current');\n        this.currentOnHost = onHost;\n    }\n\n    private onClick() {\n        if (this.disabled) return;\n        this.dispatchEvent(new CustomEvent('ui-click', { bubbles: true, composed: true }));\n    }\n\n    override render() {\n        const ariaCurrent = this.current ? 'true' : nothing;\n        const inner = html`<span class=\"inner\"><span class=\"icon\"><slot name=\"icon\"></slot></span><span><slot></slot></span></span>`;\n        return html`\n            ${this.clickable\n                ? html`<button class=\"content\" part=\"content\" type=\"button\" ?disabled=${this.disabled} aria-current=${ariaCurrent} @click=${this.onClick}>${inner}</button>`\n                : html`<div class=\"content\" part=\"content\">${inner}</div>`}\n            <div class=\"action\" part=\"action\"><slot name=\"action\"></slot></div>\n        `;\n    }\n}\n\nexport interface UiContainedListItemEventMap extends HTMLElementEventMap {\n    'ui-click': CustomEvent<null>;\n}\n\n/** Typed listeners for UiContainedListItem's events (declaration merging with the class). */\nexport interface UiContainedListItem {\n    addEventListener<K extends keyof UiContainedListItemEventMap>(type: K, listener: (this: UiContainedListItem, event: UiContainedListItemEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiContainedListItemEventMap>(type: K, listener: (this: UiContainedListItem, event: UiContainedListItemEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;\n    removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-contained-list-item': UiContainedListItem;\n    }\n}\n"
    },
    {
      "path": "src/primitives/contained-list/contained-list.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/contained-list/contained-list.ts",
      "content": "// Its child elements are one per file beside it; this module re-exports them (one entry point).\nimport { css, html, nothing } from 'lit';\nimport { customElement, property, queryAssignedElements } from 'lit/decorators.js';\nimport { uid } from '../shared/field.ts';\nimport { SlotController } from '../shared/slots.ts';\nimport { UiElement } from '../shared/element.ts';\nimport type { UiContainedListItem } from './contained-list-item.ts';\nexport * from './contained-list-item.ts';\n\nexport type ContainedListKind = 'on-page' | 'disclosed';\n\nexport type ContainedListSize = 'sm' | 'md' | 'lg' | 'xl';\n\n/**\n * Carbon `ContainedList`: a titled list of rows separated by 1px rules, for settings panels, side\n * panels and tiles. `kind=\"on-page\"` (default) has a 48px heading-compact header on the page\n * background; `kind=\"disclosed\"` a 32px label-01 header on the layer. `size` sets the row height\n * (sm 32 / md 40 / lg 48 / xl 64), `inset` shortens the rules to the padding. Put a\n * `<ui-search>` or `<ui-icon-button>` in slot `action` for a header control. Beyond Carbon: `current`\n * marks the whole list (the selected board among several): the side nav's start bar on the header and\n * `aria-current=\"true\"` on the `role=list` the label names.\n *\n * @slot - `<ui-contained-list-item>` elements\n * @slot label - Rich label\n * @slot action - Header action (search, icon button)\n * @csspart header - The sticky header row\n * @csspart label - The label\n * @csspart action - The header action wrapper\n * @csspart list - The `role=list` container\n * @cssprop --ui-nav-current-mark / --ui-nav-current-mark-width / --ui-nav-current-mark-inset / --ui-nav-current-mark-radius - The `current` list's header bar, the side nav's settings (default primary, 3px, 0, 0); `--ui-nav-current-background` its fill (default `--ui-canvas-selected`)\n */\n@customElement('ui-contained-list')\nexport class UiContainedList extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: block;\n            font-family: var(--ui-font-family);\n            --_h: var(--ui-field-height-lg, 48px);\n        }\n\n        :host([size='sm']) {\n            --_h: 32px;\n        }\n\n        :host([size='md']) {\n            --_h: 40px;\n        }\n\n        :host([size='xl']) {\n            --_h: 64px;\n        }\n\n        /*\n         * Carbon: an on-page list right after another sits 16px below it (Carbon .--on-page + .--on-page). :host()\n         * can't see siblings, so the list marks itself (data-after-list); the margin is on its first part\n         * and collapses through the host — a page-wide CSS reset would remove a :host margin.\n         */\n        :host([data-after-list]) > :first-child {\n            margin-block-start: var(--ui-space-md);\n        }\n\n        .header {\n            position: sticky;\n            inset-block-start: 0;\n            z-index: 1;\n            display: flex;\n            align-items: center;\n            box-sizing: border-box;\n            block-size: var(--_h);\n            padding-inline: var(--ui-space-md);\n            border-block-end: 1px solid var(--ui-hairline);\n            background-color: var(--ui-layer-background);\n            color: var(--ui-ink);\n            font: var(--ui-font-body-emphasis);\n            line-height: 18px; /* heading-compact-01 */\n            letter-spacing: var(--ui-tracking-body);\n        }\n\n        :host([kind='disclosed']) .header {\n            block-size: 32px;\n            border-block-end: none;\n            background-color: var(--ui-surface-1);\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-caption);\n            line-height: 16px; /* label-01 */\n            letter-spacing: var(--ui-tracking-caption);\n        }\n\n        /* beyond Carbon: a current list, the side nav's current-page fill and bar on its header (--ui-nav-current-*; Kanok: the tint, no bar) */\n        :host([current]) .header {\n            background-color: var(--ui-nav-current-background, var(--ui-canvas-selected));\n        }\n\n        :host([current]) .header::before {\n            content: '';\n            position: absolute;\n            inset-block: var(--ui-nav-current-mark-inset, 0);\n            inset-inline-start: 0;\n            inline-size: var(--ui-nav-current-mark-width, 3px);\n            border-radius: var(--ui-nav-current-mark-radius, 0);\n            background-color: var(--ui-nav-current-mark, var(--ui-primary)); /* border-interactive */\n        }\n\n        @media (forced-colors: active) {\n            :host([current]) .header::before {\n                inline-size: 3px; /* shown here even where a design hides it */\n                background-color: Highlight;\n            }\n        }\n\n        .label {\n            inline-size: 100%;\n        }\n\n        .action {\n            display: flex;\n            align-items: center;\n            margin-inline-end: calc(-1 * var(--ui-space-md));\n        }\n\n        .list {\n            margin: 0;\n            padding: 0;\n        }\n    `;\n\n    @property() label = '';\n\n    @property({ reflect: true }) kind: ContainedListKind = 'on-page';\n\n    @property({ reflect: true }) size: ContainedListSize = 'lg';\n\n    /** Rules stop at the row padding instead of running edge to edge (Carbon `isInset`). */\n    @property({ type: Boolean, reflect: true }) inset = false;\n\n    /** Beyond Carbon: the list the user is on, among several (`aria-current=\"true\"` on the list, the side nav's fill and bar on the header). */\n    @property({ type: Boolean, reflect: true }) current = false;\n\n    @queryAssignedElements({ selector: 'ui-contained-list-item' }) private readonly items!: UiContainedListItem[];\n\n    private readonly ids = uid('ui-contained-list');\n    private readonly slots = new SlotController(this);\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.syncSpacing();\n    }\n\n    /** Whether this list follows an on-page list as an on-page list itself; and the same for the list after it. */\n    private syncSpacing() {\n        const follows = (list: Element | null) => list instanceof UiContainedList && list.kind === 'on-page' && list.previousElementSibling instanceof UiContainedList && list.previousElementSibling.kind === 'on-page';\n        this.toggleAttribute('data-after-list', follows(this));\n        const next = this.nextElementSibling;\n        if (next instanceof UiContainedList) next.toggleAttribute('data-after-list', follows(next));\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (changed.has('kind')) this.syncSpacing();\n        for (const item of this.items) {\n            item.dataset.size = this.size;\n            item.toggleAttribute('data-inset', this.inset);\n        }\n    }\n\n    override render() {\n        const hasLabel = this.label || this.slots.has('label');\n        const hasAction = this.slots.has('action');\n        return html`\n            ${hasLabel || hasAction\n                ? html`<div class=\"header\" part=\"header\">\n                      <div class=\"label\" part=\"label\" id=${`${this.ids}-label`}><slot name=\"label\">${this.label}</slot></div>\n                      <div class=\"action\" part=\"action\"><slot name=\"action\"></slot></div>\n                  </div>`\n                : nothing}\n            <div class=\"list\" part=\"list\" role=\"list\" aria-labelledby=${hasLabel ? `${this.ids}-label` : nothing} aria-current=${this.current ? 'true' : nothing}><slot @slotchange=${() => this.requestUpdate()}></slot></div>\n        `;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-contained-list': UiContainedList;\n    }\n}\n"
    }
  ]
}
