{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "structured-list",
  "type": "registry:ui",
  "title": "<ui-structured-list>",
  "description": "Carbon `StructuredList`: a read-only table of rows and cells (`role=table`) with Carbon's row rules, header typography and cell paddings. `selection` turns the body rows into a single-select list (hidden radios with the radio icon in a leading cell): click, Space, or Up / Down / Left / Right arrows select; `value` holds the selected row's `value`. `condensed` halves the paddings; `flush` removes the leading padding (ignored with `selection`). 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/core-roving",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-field",
    "@kanok-ui/shared-localize",
    "@kanok-ui/shared-skeleton",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/structured-list/structured-list-cell.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/structured-list/structured-list-cell.ts",
      "content": "import { css, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { setManagedAttribute } from '../shared/field.ts';\nimport { UiElement } from '../shared/element.ts';\n\n/**\n * One cell of a `<ui-structured-list-row>` (Carbon `StructuredListCell`): `role=cell`, or\n * `columnheader` in a `head` row. `nowrap` keeps the content on one line.\n *\n * @slot - Cell content\n */\n@customElement('ui-structured-list-cell')\nexport class UiStructuredListCell extends UiElement {\n    static override readonly styles = css`\n        :host {\n            position: relative;\n            display: table-cell;\n            box-sizing: border-box;\n            max-inline-size: 576px;\n            color: var(--ui-ink-muted);\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: color var(--ui-duration-moderate) var(--ui-easing);\n        }\n\n        :host([head]) {\n            block-size: 40px;\n            color: var(--ui-ink);\n            font-weight: 600;\n            line-height: 18px; /* heading-compact-01 */\n            vertical-align: top;\n        }\n\n        /*\n         * The cell's padding is this part's, not :host's (cell or row), so a page-wide CSS reset can't remove it;\n         * its transparent borders keep the room for the row's rules. The rules themselves are painted at the\n         * cell's own edges, which are the row's: a cell shorter than its row (one line beside a wrapped one, a\n         * status indicator) would otherwise draw them out of line. The row hands down their widths and colour (--_rule-*).\n         */\n        .base {\n            box-sizing: border-box;\n            padding: var(--ui-space-md) var(--ui-space-xs) var(--ui-space-lg);\n            border-block: var(--_rule-top, 0px) solid transparent;\n            border-block-end-width: var(--_rule-bottom, 0px);\n        }\n\n        :host::before,\n        :host::after {\n            position: absolute;\n            inset-inline: 0;\n            background-color: var(--_rule, transparent); /* recoloured at once: Carbon moves only the row's fill */\n            content: '';\n            pointer-events: none;\n        }\n\n        :host::before {\n            inset-block-start: 0;\n            block-size: var(--_rule-top, 0px);\n        }\n\n        :host::after {\n            inset-block-end: 0;\n            block-size: var(--_rule-bottom, 0px);\n        }\n\n        :host([head]) .base {\n            padding: var(--ui-space-md) var(--ui-space-xs) var(--ui-space-xs);\n        }\n\n        :host([data-condensed]) .base {\n            padding: var(--ui-space-xs);\n        }\n\n        /* after head / condensed: the first cell always starts at 16px (Carbon specificity order) */\n        :host(:first-of-type) .base {\n            padding-inline-start: var(--ui-space-md);\n        }\n\n        :host([data-selection]) .base,\n        :host([data-selection]:first-of-type) .base {\n            padding-inline: var(--ui-space-md);\n        }\n\n        :host([data-flush]) .base,\n        :host([data-flush]:first-of-type) .base {\n            padding-inline: 0 var(--ui-space-md);\n        }\n\n        :host([nowrap]) {\n            white-space: nowrap;\n        }\n    `;\n\n    /** Set by the row: this cell is a column header. */\n    @property({ type: Boolean, reflect: true }) head = false;\n\n    @property({ type: Boolean, reflect: true }) nowrap = false;\n\n    protected override updated() {\n        setManagedAttribute(this, 'role', this.head ? 'columnheader' : 'cell');\n    }\n\n    override render() {\n        return html`<div class=\"base\"><slot></slot></div>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-structured-list-cell': UiStructuredListCell;\n    }\n}\n"
    },
    {
      "path": "src/primitives/structured-list/structured-list-row.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/structured-list/structured-list-row.ts",
      "content": "import { html, nothing, css, svg } from 'lit';\nimport { customElement, property, query, queryAssignedElements } from 'lit/decorators.js';\nimport { srOnlyStyles, uid, stopEvent } from '../shared/field.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { UiElement } from '../shared/element.ts';\nimport type { UiStructuredListCell } from './structured-list-cell.ts';\n\nconst radioIcon = (checked: boolean) =>\n    html`<svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n        <circle cx=\"8\" cy=\"8\" r=\"6.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1\" />\n        ${checked ? svg`<circle cx=\"8\" cy=\"8\" r=\"3\" />` : nothing}\n    </svg>`;\n\n/**\n * A row of a `<ui-structured-list>` (Carbon `StructuredListRow`). `head` makes it the header\n * row (its cells become column headers). In a `selection` list every body row carries a hidden\n * radio in a leading cell with Carbon's radio icon; clicking the row or pressing Space / arrow\n * keys selects it.\n *\n * @slot - `<ui-structured-list-cell>` elements\n * @csspart radio-cell - The leading cell with the radio icon (selection lists)\n * @cssprop --ui-structured-list-selected - Fill of the chosen row of a selection list (default `--ui-surface-2`; Kanok: `--ui-highlight`)\n */\n@customElement('ui-structured-list-row')\nexport class UiStructuredListRow extends UiElement {\n    static override readonly styles = [srOnlyStyles, css`\n        /* the rules (Carbon row borders) are drawn by the cells' parts from these, see ui-structured-list-cell */\n        :host {\n            --_rule: var(--ui-hairline);\n            --_rule-top: 1px;\n            --_rule-bottom: 0px;\n\n            display: table-row;\n            transition: background-color var(--ui-duration-moderate) var(--ui-easing);\n        }\n\n        :host(:last-of-type:not([head])) {\n            --_rule-bottom: 1px;\n        }\n\n        :host([head]) {\n            --_rule-top: 0px;\n        }\n\n        :host([data-selection]:not([head]):hover:not([selected])) {\n            --_rule: var(--ui-ghost-hover);\n\n            background-color: var(--ui-ghost-hover);\n            cursor: pointer;\n        }\n\n        /* --ui-structured-list-selected: a design can tint the selected row like its other selections (Carbon: surface 2) */\n        :host([data-selection][selected]) {\n            --_rule: var(--ui-structured-list-selected, var(--ui-surface-2));\n\n            background-color: var(--ui-structured-list-selected, var(--ui-surface-2));\n        }\n\n        :host([data-selection]:not([head]):hover) ::slotted(ui-structured-list-cell),\n        :host([data-selection][selected]) ::slotted(ui-structured-list-cell) {\n            color: var(--ui-ink);\n        }\n\n        :host(:focus-within) {\n            outline: var(--ui-focus-width, 2px) solid var(--ui-focus);\n            outline-offset: -2px;\n        }\n\n        /* the rules at the cell's edges, as in ui-structured-list-cell (the radio cell can be shorter than its row) */\n        .radio-cell {\n            position: relative;\n            display: table-cell;\n            box-sizing: border-box;\n            inline-size: 32px;\n            vertical-align: top;\n        }\n\n        .radio-cell::before,\n        .radio-cell::after {\n            position: absolute;\n            inset-inline: 0;\n            background-color: var(--_rule);\n            content: '';\n            pointer-events: none;\n        }\n\n        .radio-cell::before {\n            inset-block-start: 0;\n            block-size: var(--_rule-top);\n        }\n\n        .radio-cell::after {\n            inset-block-end: 0;\n            block-size: var(--_rule-bottom);\n        }\n\n        .radio-base {\n            box-sizing: border-box;\n            padding: var(--ui-space-md) 0 var(--ui-space-lg) var(--ui-space-md);\n            border-block: var(--_rule-top) solid transparent;\n            border-block-end-width: var(--_rule-bottom);\n        }\n\n        :host([head]) .radio-base {\n            padding-block: var(--ui-space-md) var(--ui-space-xs);\n        }\n\n        :host([data-condensed]) .radio-base {\n            padding: var(--ui-space-xs) 0 var(--ui-space-xs) var(--ui-space-xs);\n        }\n\n        .icon {\n            display: inline-block;\n            width: 16px;\n            height: 16px;\n            margin-block-start: 2px;\n            vertical-align: top;\n            fill: var(--ui-icon-primary);\n            color: var(--ui-icon-primary);\n        }\n\n        @media (forced-colors: active) {\n            :host([selected]) {\n                outline: 1px solid Highlight;\n            }\n        }\n    `];\n\n    @property({ type: Boolean, reflect: true }) head = false;\n\n\n    private readonly localize = new LocalizeController(this);\n\n    /** Identifies the row in the list's `value` / `ui-change`. */\n    @property() value = '';\n\n    /** Set by the list. */\n    @property({ type: Boolean, reflect: true }) selected = false;\n\n    /** Set by the list: `selection` mode renders the radio cell. */\n    @property({ type: Boolean, attribute: 'data-selection', reflect: true }) selection = false;\n\n    /** Set by the list. */\n    @property({ type: Boolean, attribute: 'data-condensed', reflect: true }) condensed = false;\n\n    /** Set by the list. */\n    @property({ type: Boolean, attribute: 'data-flush', reflect: true }) flush = false;\n\n    /** Set by the list: the hidden radio is the row's tab stop. */\n    @property({ type: Boolean, attribute: false }) focusable = false;\n\n    /** Set by the list: screen-reader name of the radio column header. */\n    @property({ attribute: false }) selectionLabel = '';\n\n    /** Set by the list: position among the selectable rows and their count. Each radio sits in its own shadow root, so the browser would count \"1 of 1\". */\n    @property({ attribute: false }) position = 0;\n\n    @property({ attribute: false }) setSize = 0;\n\n    @query('input') private readonly input!: HTMLInputElement | null;\n\n    @queryAssignedElements({ selector: 'ui-structured-list-cell' }) private readonly cells!: UiStructuredListCell[];\n\n    private readonly radioId = uid('ui-structured-list-radio');\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'row');\n        this.addEventListener('click', this.onClick);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('click', this.onClick);\n    }\n\n    protected override updated() {\n        this.syncCells();\n        if (this.selected) this.setAttribute('aria-selected', 'true');\n        else if (this.selection && !this.head) this.setAttribute('aria-selected', 'false');\n        else this.removeAttribute('aria-selected');\n    }\n\n    private syncCells() {\n        for (const cell of this.cells) {\n            cell.head = this.head;\n            cell.toggleAttribute('data-selection', this.selection);\n            cell.toggleAttribute('data-condensed', this.condensed);\n            cell.toggleAttribute('data-flush', this.flush);\n        }\n    }\n\n    /** Focus the row's radio (selection lists). */\n    override focus(options?: FocusOptions) {\n        if (this.input) this.input.focus(options);\n        else super.focus(options);\n    }\n\n    private readonly onClick = () => {\n        if (this.head || !this.selection) return;\n        this.select();\n    };\n\n    private select() {\n        if (this.selected) return;\n        // internal: for the list only, which stops it (not composed)\n        this.dispatchEvent(new CustomEvent('ui-row-select', { detail: { value: this.value }, bubbles: true }));\n    }\n\n    /** Accessible name of the hidden radio: the row's text. */\n    private get rowLabel() {\n        return this.getAttribute('aria-label') ?? this.textContent?.replaceAll(/\\s+/g, ' ').trim() ?? '';\n    }\n\n    private renderRadioCell() {\n        if (!this.selection) return nothing;\n        // Carbon renders an empty header cell so the radio column lines up\n        if (this.head) return html`<div class=\"radio-cell\" part=\"radio-cell\" role=\"columnheader\"><div class=\"radio-base\"><span class=\"sr-only\">${this.selectionLabel || this.localize.t.common.select}</span></div></div>`;\n        return html`<div class=\"radio-cell\" part=\"radio-cell\" role=\"cell\"><div class=\"radio-base\">\n            <input\n                id=${this.radioId}\n                class=\"sr-only\"\n                type=\"radio\"\n                .checked=${this.selected}\n                tabindex=${this.focusable ? 0 : -1}\n                aria-label=${this.rowLabel}\n                aria-posinset=${this.position || nothing}\n                aria-setsize=${this.setSize || nothing}\n                @input=${stopEvent}\n                @change=${() => this.select()}\n            />\n            ${radioIcon(this.selected)}\n        </div></div>`;\n    }\n\n    override render() {\n        return html`${this.renderRadioCell()}<slot @slotchange=${() => this.syncCells()}></slot>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-structured-list-row': UiStructuredListRow;\n    }\n}\n"
    },
    {
      "path": "src/primitives/structured-list/structured-list-skeleton.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/structured-list/structured-list-skeleton.ts",
      "content": "import { html, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { skeletonStyles, UiSkeletonElement } from '../shared/skeleton.ts';\n\n/**\n * Carbon `StructuredListSkeleton`: a header row of three bars (16px, at 75% of their cells; columns 8 : 30 : 15) and\n * `rows` empty rows between subtle lines. Hidden from assistive tech.\n *\n * @csspart header - The header bars\n * @csspart row - Each empty row\n */\n@customElement('ui-structured-list-skeleton')\nexport class UiStructuredListSkeleton extends UiSkeletonElement {\n    static override readonly styles = [\n        skeletonStyles,\n        css`\n            :host {\n                display: block;\n            }\n\n            .row {\n                display: grid;\n                grid-template-columns: 8fr 30fr 15fr;\n            }\n\n            .th {\n                padding: var(--ui-space-md) var(--ui-space-xs) var(--ui-space-xs);\n            }\n\n            .th:first-child {\n                padding-inline-start: var(--ui-space-md);\n            }\n\n            .bone {\n                display: block;\n                inline-size: 75%;\n                block-size: 16px;\n            }\n\n            .body {\n                block-size: 40px;\n                border-block-start: 1px solid var(--ui-hairline);\n            }\n\n            .body:last-child {\n                border-block-end: 1px solid var(--ui-hairline);\n            }\n        `,\n    ];\n\n    @property({ type: Number }) rows = 5;\n\n    override render() {\n        const header = html`<div class=\"th\"><span class=\"bone\" part=\"header\"></span></div>`;\n        const row = html`<div class=\"body\" part=\"row\"></div>`;\n        return html`<div class=\"row\">${header}${header}${header}</div>${Array.from({ length: Math.max(0, this.rows) }, () => row)}`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-structured-list-skeleton': UiStructuredListSkeleton;\n    }\n}\n"
    },
    {
      "path": "src/primitives/structured-list/structured-list.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/structured-list/structured-list.ts",
      "content": "// Its child elements are one per file beside it; this module re-exports them (one entry point).\nimport { css, html } from 'lit';\nimport { customElement, property, queryAssignedElements } from 'lit/decorators.js';\nimport { setManagedAttribute } from '../shared/field.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { UiElement } from '../shared/element.ts';\nimport { rovingTarget } from '../../core/roving.ts';\nimport { UiStructuredListRow } from './structured-list-row.ts';\nexport * from './structured-list-cell.ts';\nexport * from './structured-list-row.ts';\n\n/**\n * Carbon `StructuredList`: a read-only table of rows and cells (`role=table`) with Carbon's\n * row rules, header typography and cell paddings. `selection` turns the body rows into a\n * single-select list (hidden radios with the radio icon in a leading cell): click, Space,\n * or Up / Down / Left / Right arrows select; `value` holds the selected row's `value`.\n * `condensed` halves the paddings; `flush` removes the leading padding (ignored with `selection`).\n *\n * @slot - `<ui-structured-list-row>` elements (first one usually `head`)\n * @fires ui-change - detail: { value } when the user selects another row\n */\n@customElement('ui-structured-list')\nexport class UiStructuredList extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: table;\n            inline-size: 100%;\n            border-collapse: collapse;\n            border-spacing: 0;\n            font-family: var(--ui-font-family);\n        }\n    `;\n\n    @property({ type: Boolean, reflect: true }) selection = false;\n\n\n    private readonly localize = new LocalizeController(this);\n\n    @property({ type: Boolean, reflect: true }) condensed = false;\n\n    @property({ type: Boolean, reflect: true }) flush = false;\n\n    /** Selected row's `value` (selection lists). */\n    @property({ reflect: true }) value = '';\n\n    @property() label = '';\n\n    /** Screen-reader name of the radio column (selection lists). */\n    @property({ attribute: 'selection-label' }) selectionLabel = '';\n\n    @queryAssignedElements({ selector: 'ui-structured-list-row' }) private readonly rows!: UiStructuredListRow[];\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'table');\n        this.addEventListener('ui-row-select', this.onRowSelect as EventListener);\n        this.addEventListener('keydown', this.onKeydown);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('ui-row-select', this.onRowSelect as EventListener);\n        this.removeEventListener('keydown', this.onKeydown);\n    }\n\n    protected override updated() {\n        setManagedAttribute(this, 'aria-label', this.label || this.localize.t.common.structuredList); // every update: the language may have changed\n        this.sync();\n    }\n\n    private bodyRows() {\n        return this.rows.filter((r) => !r.head);\n    }\n\n    private sync() {\n        const body = this.bodyRows();\n        const selected = body.find((r) => r.value === this.value && this.value !== '');\n        const focusable = selected ?? body[0];\n        for (const row of this.rows) {\n            row.selection = this.selection;\n            row.selectionLabel = (this.selectionLabel || this.localize.t.common.select);\n            row.condensed = this.condensed;\n            row.flush = this.flush && !this.selection;\n            row.selected = this.selection && row === selected;\n            row.focusable = row === focusable;\n            row.position = body.indexOf(row) + 1;\n            row.setSize = body.length;\n        }\n    }\n\n    private select(row: UiStructuredListRow) {\n        if (row.value === this.value) return;\n        this.value = row.value;\n        this.sync();\n        this.dispatchEvent(new CustomEvent('ui-change', { detail: { value: this.value }, bubbles: true, composed: true }));\n    }\n\n    private readonly onRowSelect = (event: CustomEvent<{ value: string }>) => {\n        event.stopPropagation();\n        if (event.target instanceof UiStructuredListRow) this.select(event.target);\n    };\n\n    /** Radio-group keyboard: arrows move focus and selection between body rows (wrapping). */\n    private readonly onKeydown = (event: KeyboardEvent) => {\n        if (!this.selection) return;\n        const body = this.bodyRows();\n        const current = body.findIndex((r) => r === event.target || r.contains(event.target as Node));\n        const target = current < 0 ? undefined : rovingTarget(body.length, current, event.key, { orientation: 'both', homeEnd: false, rtl: getComputedStyle(this).direction === 'rtl' });\n        if (target === undefined) return;\n        event.preventDefault();\n        const next = body[target];\n        this.select(next);\n        next.focus();\n    };\n\n    /** Selection lists: focus the selected (or first) row's radio. */\n    override focus(options?: FocusOptions) {\n        (this.rows.find((r) => r.focusable) ?? this.bodyRows()[0])?.focus(options);\n    }\n\n    override render() {\n        return html`<slot @slotchange=${() => this.sync()}></slot>`;\n    }\n}\n\nexport interface StructuredListChangeDetail {\n    value: string;\n}\n\nexport interface UiStructuredListEventMap extends HTMLElementEventMap {\n    'ui-change': CustomEvent<StructuredListChangeDetail>;\n}\n\n/** Typed listeners for UiStructuredList's events (declaration merging with the class). */\nexport interface UiStructuredList {\n    addEventListener<K extends keyof UiStructuredListEventMap>(type: K, listener: (this: UiStructuredList, event: UiStructuredListEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiStructuredListEventMap>(type: K, listener: (this: UiStructuredList, event: UiStructuredListEventMap[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-structured-list': UiStructuredList;\n    }\n}\n"
    }
  ]
}
