{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-indicator",
  "type": "registry:ui",
  "title": "<ui-progress-indicator>",
  "description": "Carbon `ProgressIndicator`: an ordered list of `<ui-progress-step>`s. Steps before `current-index` are complete, the one at it is current, the rest incomplete (a step's own `complete` wins). `vertical` stacks the steps; `space-equally` stretches them across the width. `interactive` makes the steps clickable and Tab stops (Carbon makes them clickable when `onChange` is given; a listener can't be seen here): a click on a step that is neither current nor disabled makes it current and fires `ui-change` with its index. Without `interactive` no step is a Tab stop. 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-localize",
    "@kanok-ui/shared-skeleton",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/progress-indicator/progress-indicator-skeleton.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/progress-indicator/progress-indicator-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 `ProgressIndicatorSkeleton` (`cds-progress-indicator-skeleton`): `steps` incomplete steps (128px wide in a\n * row, or stacked with `vertical`): the subtle line, the empty-circle icon and a 40×14 label bar. Hidden from\n * assistive tech.\n *\n * @csspart step - Each step\n * @csspart label - Each label bar\n */\n@customElement('ui-progress-indicator-skeleton')\nexport class UiProgressIndicatorSkeleton extends UiSkeletonElement {\n    static override readonly styles = [\n        skeletonStyles,\n        css`\n            :host {\n                display: block;\n            }\n\n            .steps {\n                display: flex;\n                flex-wrap: wrap; /* as ui-progress-indicator: a second row instead of a wider page */\n            }\n\n            :host([vertical]) .steps {\n                flex-direction: column;\n            }\n\n            .step {\n                position: relative;\n                display: flex;\n                flex-shrink: 0;\n                inline-size: 128px;\n                min-inline-size: 112px;\n            }\n\n            :host([vertical]) .step {\n                inline-size: auto;\n                min-block-size: 58px;\n                padding-inline-start: var(--ui-space-md);\n            }\n\n            .line {\n                position: absolute;\n                inset-block-start: 0;\n                inset-inline-start: 0;\n                inline-size: 100%;\n                block-size: 2px;\n                background-color: var(--ui-hairline);\n            }\n\n            :host([vertical]) .line {\n                inline-size: 2px;\n                block-size: 100%;\n            }\n\n            .icon {\n                flex-shrink: 0;\n                inline-size: 16px;\n                block-size: 16px;\n                margin: 10px var(--ui-space-xs) 0 0;\n                fill: var(--ui-ink);\n            }\n\n            .label {\n                inline-size: 40px;\n                block-size: 14px;\n                margin-block-start: 10px;\n            }\n\n            :host([vertical]) .label {\n                margin-block-start: 11px;\n            }\n        `,\n    ];\n\n    @property({ type: Number }) steps = 4;\n\n    @property({ type: Boolean, reflect: true }) vertical = false;\n\n    override render() {\n        // the incomplete step's empty circle, as <ui-progress-step>\n        const step = html`<div class=\"step\" part=\"step\">\n            <span class=\"line\"></span>\n            <svg class=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"M8 2a6 6 0 1 1 0 12A6 6 0 0 1 8 2m0-1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Z\" /></svg>\n            <span class=\"bone label\" part=\"label\"></span>\n        </div>`;\n        return html`<div class=\"steps\">${Array.from({ length: Math.max(1, this.steps) }, () => step)}</div>`;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-progress-indicator-skeleton': UiProgressIndicatorSkeleton;\n    }\n}\n"
    },
    {
      "path": "src/primitives/progress-indicator/progress-indicator.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/progress-indicator/progress-indicator.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 { UiElement } from '../shared/element.ts';\nimport type { UiProgressStep } from './progress-step.ts';\nexport * from './progress-step.ts';\n\n/**\n * Carbon `ProgressIndicator`: an ordered list of `<ui-progress-step>`s. Steps before\n * `current-index` are complete, the one at it is current, the rest incomplete (a step's own\n * `complete` wins). `vertical` stacks the steps; `space-equally` stretches them across the width.\n * `interactive` makes the steps clickable and Tab stops (Carbon makes them clickable when `onChange` is\n * given; a listener can't be seen here): a click on a step that is neither current nor disabled makes it\n * current and fires `ui-change` with its index. Without `interactive` no step is a Tab stop.\n *\n * @slot - `<ui-progress-step>` elements\n * @fires ui-change - detail: { index } when the user picks another step\n * @csspart base - The list\n */\n@customElement('ui-progress-indicator')\nexport class UiProgressIndicator extends UiElement {\n    static override readonly styles = css`\n        /* steps that don't fit the width (a phone) go on to a second row instead of widening the page */\n        :host {\n            display: flex;\n            flex-direction: row;\n            flex-wrap: wrap;\n            list-style: none;\n            font-family: var(--ui-font-family);\n        }\n\n        :host([vertical]) {\n            flex-direction: column;\n        }\n\n        .list {\n            display: contents;\n        }\n    `;\n\n    /** Index of the current step (0-based). */\n    @property({ type: Number, attribute: 'current-index' }) currentIndex = 0;\n    @property({ type: Boolean, reflect: true }) vertical = false;\n    /** Stretch the steps to share the width (horizontal only). */\n    @property({ type: Boolean, reflect: true, attribute: 'space-equally' }) spaceEqually = false;\n    /** Let the user jump between steps (fires `ui-change`). */\n    @property({ type: Boolean, reflect: true }) interactive = false;\n\n    @queryAssignedElements({ selector: 'ui-progress-step' }) private readonly steps!: UiProgressStep[];\n\n    override connectedCallback() {\n        super.connectedCallback();\n        this.addEventListener('ui-step-click', this.onStepClick as EventListener);\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        this.removeEventListener('ui-step-click', this.onStepClick as EventListener);\n    }\n\n    private readonly onStepClick = (event: CustomEvent<{ index: number }>) => {\n        event.stopPropagation();\n        this.currentIndex = event.detail.index;\n        this.dispatchEvent(new CustomEvent('ui-change', { detail: { index: this.currentIndex }, bubbles: true, composed: true }));\n    };\n\n    protected override updated() {\n        this.sync();\n    }\n\n    private sync() {\n        this.steps.forEach((step, i) => {\n            step.index = i;\n            step.clickable = this.interactive;\n            step.toggleAttribute('data-vertical', this.vertical);\n            step.toggleAttribute('data-space-equally', this.spaceEqually && !this.vertical);\n            if (step.complete || i < this.currentIndex) step.state = 'complete';\n            else if (i === this.currentIndex) step.state = 'current';\n            else step.state = 'incomplete';\n        });\n    }\n\n    /** Interactive indicators: focus the current step. */\n    override focus(options?: FocusOptions) {\n        (this.steps.find((s) => s.state === 'current') ?? this.steps[0])?.focus(options);\n    }\n\n    override render() {\n        return html`<div class=\"list\" part=\"base\" role=\"list\"><slot @slotchange=${() => this.sync()}></slot></div>`;\n    }\n}\n\nexport interface ProgressIndicatorChangeDetail {\n    index: number;\n}\n\nexport interface UiProgressIndicatorEventMap extends HTMLElementEventMap {\n    'ui-change': CustomEvent<ProgressIndicatorChangeDetail>;\n}\n\n/** Typed listeners for UiProgressIndicator's events (declaration merging with the class). */\nexport interface UiProgressIndicator {\n    addEventListener<K extends keyof UiProgressIndicatorEventMap>(type: K, listener: (this: UiProgressIndicator, event: UiProgressIndicatorEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiProgressIndicatorEventMap>(type: K, listener: (this: UiProgressIndicator, event: UiProgressIndicatorEventMap[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-progress-indicator': UiProgressIndicator;\n    }\n}\n"
    },
    {
      "path": "src/primitives/progress-indicator/progress-step.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/progress-indicator/progress-step.ts",
      "content": "import { svg, LitElement, css, html, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { UiElement } from '../shared/element.ts';\n\nexport type ProgressStepState = 'complete' | 'current' | 'incomplete';\n\nconst ICONS = {\n    complete: svg`<path d=\"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm0 13a6 6 0 1 1 0-12 6 6 0 0 1 0 12Z\" /><path d=\"m7 11.4-2.7-2.7.7-.7L7 10l4-4 .7.7z\" />`,\n    current: svg`<path d=\"M8 1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Zm0 13a6 6 0 0 1 0-12z\" />`,\n    incomplete: svg`<path d=\"M8 2a6 6 0 1 1 0 12A6 6 0 0 1 8 2m0-1a7 7 0 1 0 0 14A7 7 0 0 0 8 1Z\" />`,\n    invalid: svg`<path d=\"M8 1 1 14h14L8 1Zm0 2.2L13.3 13H2.7L8 3.2ZM7.4 6h1.2v4H7.4zM8 12.4a.8.8 0 1 1 0-1.6.8.8 0 0 1 0 1.6Z\" />`,\n};\n\n/**\n * Carbon `ProgressStep`: one step of a `<ui-progress-indicator>`. Its state (complete / current /\n * incomplete) comes from the indicator's `current-index` unless `complete` is set; `invalid`\n * shows a warning icon, `disabled` greys it out and makes it unclickable.\n *\n * @slot - Nothing; use `label` and `secondary-label`\n * @csspart button - The clickable step\n * @csspart icon - The state icon\n * @csspart label - The label\n * @csspart secondary-label - The secondary label\n * @csspart line - The progress line\n * @cssprop --ui-progress-step-flex / --ui-progress-step-min-width - A horizontal step's `flex` and least width (default `0 1 auto`, 112px: Carbon's 128px steps; Kanok: `1 1 0`, 120px)\n * @cssprop --ui-progress-label-max-width / --ui-progress-label-gap - Its label's `max-width` and end margin (default 88px, 0)\n * @cssprop --ui-progress-label-white-space / --ui-progress-label-overflow / --ui-progress-label-text-overflow - Its label on one line (default normal, visible, clip: it wraps; Kanok: one line, an ellipsis)\n */\n@customElement('ui-progress-step')\nexport class UiProgressStep extends UiElement {\n    /** `el.focus()` lands on the control inside. */\n    static override readonly shadowRootOptions: ShadowRootInit = { ...LitElement.shadowRootOptions, delegatesFocus: true };\n\n    static override readonly styles = css`\n        :host {\n            position: relative;\n            display: inline-flex;\n            flex-direction: row;\n            box-sizing: border-box;\n            width: 128px;\n            min-width: 112px;\n            overflow: visible;\n            font-family: var(--ui-font-family);\n        }\n\n        /* Carbon: 128px steps (112px at the least); a design can share the row out (--ui-progress-step-*) */\n        :host(:not([data-vertical])) {\n            flex: var(--ui-progress-step-flex, 0 1 auto);\n            min-width: var(--ui-progress-step-min-width, 112px);\n        }\n\n        :host([data-space-equally]) {\n            flex: 1 1 0;\n            min-width: 128px;\n        }\n\n        .button {\n            display: flex;\n            flex-direction: row;\n            box-sizing: border-box;\n            width: 100%;\n            min-height: 32px;\n            margin: 0;\n            padding: 0;\n            border: 0;\n            background: none;\n            color: inherit;\n            font: inherit;\n            text-align: start;\n            cursor: default;\n        }\n\n        .button.clickable {\n            cursor: pointer;\n        }\n\n        .button:focus-visible {\n            outline: none;\n        }\n\n        .button:focus-visible .label {\n            color: var(--ui-focus);\n            outline: 1px solid var(--ui-focus);\n            border-radius: var(--ui-link-focus-radius, 0); /* as a link's ring (Kanok: 4px) */\n        }\n\n        .icon {\n            flex-shrink: 0;\n            width: 16px;\n            height: 16px;\n            margin: 10px var(--ui-space-xs) 0 0;\n            border-radius: 50%;\n            fill: var(--ui-primary);\n        }\n\n        :host([data-state='incomplete']) .icon {\n            fill: var(--ui-ink);\n        }\n\n        :host([invalid]) .icon {\n            fill: var(--ui-error);\n        }\n\n        :host([disabled]) .icon {\n            fill: var(--ui-ink-disabled);\n        }\n\n        .text {\n            display: flex;\n            flex-direction: column;\n            min-width: 0;\n        }\n\n        .label {\n            margin: var(--ui-space-xs) 0 0;\n            margin-inline-end: var(--ui-progress-label-gap, 0px);\n            max-width: var(--ui-progress-label-max-width, 88px);\n            color: var(--ui-ink);\n            font: var(--ui-font-body-sm);\n            letter-spacing: var(--ui-tracking-body);\n            /* Carbon truncates at 88px with an ellipsis; a long label wraps here instead, so no step name is hidden */\n            overflow-wrap: break-word;\n            transition: color var(--ui-duration-moderate) var(--ui-easing);\n        }\n\n        /* a design can keep each label on one line, ending in an ellipsis (--ui-progress-label-*) */\n        :host(:not([data-vertical])) .label {\n            overflow: var(--ui-progress-label-overflow, visible);\n            white-space: var(--ui-progress-label-white-space, normal);\n            text-overflow: var(--ui-progress-label-text-overflow, clip);\n        }\n\n        :host([data-space-equally]) .label {\n            max-width: 100%;\n            margin-inline-end: 12px;\n        }\n\n        .button.clickable:hover .label {\n            color: var(--ui-link-hover);\n        }\n\n        :host([disabled]) .label,\n        :host([disabled]) .secondary {\n            color: var(--ui-ink-disabled);\n        }\n\n        :host([disabled]) .button {\n            cursor: not-allowed;\n        }\n\n        .secondary {\n            margin-top: var(--ui-space-xxs);\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-caption);\n            letter-spacing: var(--ui-tracking-caption);\n        }\n\n        /* the 2px line along the top: interactive for complete / current, subtle for incomplete */\n        .line {\n            position: absolute;\n            top: 0;\n            inset-inline-start: 0;\n            width: 100%;\n            height: 2px;\n            background-color: var(--ui-primary);\n        }\n\n        :host([data-space-equally]) .line {\n            min-width: 128px;\n        }\n\n        :host([data-state='incomplete']) .line {\n            background-color: var(--ui-hairline);\n        }\n\n        /* vertical: steps stack, the line runs down the start edge */\n        :host([data-vertical]) {\n            display: flex;\n            width: auto;\n            min-width: 0;\n            min-height: 58px;\n        }\n\n        :host([data-vertical]) .button {\n            align-items: flex-start;\n            min-height: 58px;\n        }\n\n        :host([data-vertical]) .icon {\n            margin: 10px var(--ui-space-xs) 0 0;\n        }\n\n        :host([data-vertical]) .label {\n            margin-top: 8px;\n            white-space: normal;\n            max-width: 160px;\n        }\n\n        :host([data-vertical]) .line {\n            top: 0;\n            width: 2px;\n            height: 100%;\n        }\n\n        :host([data-vertical]) .button {\n            padding-inline-start: var(--ui-space-md);\n        }\n\n        .sr-only {\n            position: absolute;\n            width: 1px;\n            height: 1px;\n            overflow: hidden;\n            clip-path: inset(50%);\n            white-space: nowrap;\n        }\n\n        @media (forced-colors: active) {\n            .icon {\n                fill: CanvasText;\n            }\n\n            :host([data-state='current']) .icon {\n                fill: Highlight;\n            }\n\n            :host([disabled]) .icon {\n                fill: GrayText;\n            }\n\n            .button:focus-visible {\n                outline: 2px solid Highlight;\n            }\n        }\n\n    `;\n\n    @property() label = '';\n    /** Smaller text under the label (Carbon `secondaryLabel`). */\n    @property({ attribute: 'secondary-label' }) secondaryLabel = '';\n    /** Marks the step done regardless of `current-index`. */\n    @property({ type: Boolean, reflect: true }) complete = false;\n    @property({ type: Boolean, reflect: true }) invalid = false;\n    @property({ type: Boolean, reflect: true }) disabled = false;\n    /** Set by the indicator: the resolved state. */\n    @property({ attribute: 'data-state', reflect: true }) state: ProgressStepState = 'incomplete';\n    /** Set by the indicator: whether steps are clickable. */\n    @property({ type: Boolean, attribute: false }) clickable = false;\n    /** Set by the indicator: this step's position. */\n    @property({ type: Number, attribute: false }) index = 0;\n\n    override connectedCallback() {\n        super.connectedCallback();\n        if (!this.hasAttribute('role')) this.setAttribute('role', 'listitem'); // Carbon renders <li>\n    }\n\n    private readonly localize = new LocalizeController(this);\n\n    private get message() {\n        const t = this.localize.t.common;\n        if (this.invalid) return t.stepInvalid;\n        if (this.state === 'complete') return t.stepComplete;\n        if (this.state === 'current') return t.stepCurrent;\n        return t.stepIncomplete;\n    }\n\n    private onClick() {\n        if (!this.clickable || this.disabled || this.state === 'current') return;\n        // internal: for the indicator only, which stops it (not composed)\n        this.dispatchEvent(new CustomEvent('ui-step-click', { detail: { index: this.index }, bubbles: true }));\n    }\n\n    override render() {\n        const iconKey = this.invalid ? 'invalid' : this.state;\n        const interactive = this.clickable && !this.disabled && this.state !== 'current';\n        return html`\n            <button\n                class=\"button ${interactive ? 'clickable' : ''}\"\n                part=\"button\"\n                type=\"button\"\n                ?disabled=${this.disabled}\n                aria-disabled=${this.disabled ? 'true' : nothing}\n                aria-current=${this.state === 'current' ? 'step' : nothing}\n                tabindex=${this.disabled || !this.clickable ? -1 : 0}\n                @click=${this.onClick}\n            >\n                <svg class=\"icon\" part=\"icon\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">${ICONS[iconKey]}</svg>\n                <span class=\"text\">\n                    <span class=\"label\" part=\"label\">${this.label}</span>\n                    ${this.secondaryLabel ? html`<span class=\"secondary\" part=\"secondary-label\">${this.secondaryLabel}</span>` : nothing}\n                </span>\n                <span class=\"sr-only\">${this.message}</span>\n                <span class=\"line\" part=\"line\"></span>\n            </button>\n        `;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-progress-step': UiProgressStep;\n    }\n}\n"
    }
  ]
}
