{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inline-loading",
  "type": "registry:ui",
  "title": "<ui-inline-loading>",
  "description": "Carbon `InlineLoading`: a 16px spinner with a text beside it for in-place progress (saving, submitting). `status` moves through `active` → `finished` (check mark, then `ui-success` after `success-delay`) or `error` (error icon); `inactive` stops the spinner as Carbon web components do (it turns out and its rings run out over 1.4s; at once with reduced motion). The text is a polite live region so screen readers hear the change. 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-status-indicator",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-localize",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/inline-loading/inline-loading.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/inline-loading/inline-loading.ts",
      "content": "import { html, css } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { UiElement } from '../shared/element.ts';\nimport { CHECKMARK_FILLED, ERROR_FILLED } from '../../core/status-indicator.ts';\n\nexport type InlineLoadingStatus = 'inactive' | 'active' | 'finished' | 'error';\n\n/**\n * Carbon `InlineLoading`: a 16px spinner with a text beside it for in-place progress (saving,\n * submitting). `status` moves through `active` → `finished` (check mark, then `ui-success` after\n * `success-delay`) or `error` (error icon); `inactive` stops the spinner as Carbon web components do\n * (it turns out and its rings run out over 1.4s; at once with reduced motion). The text is a polite\n * live region so screen readers hear the change.\n *\n * Geometry per Carbon `_inline-loading.scss`: 32px minimum height, 16px icon with 8px after it,\n * label-02 text in text-secondary.\n *\n * @slot - The status text (Carbon `description`)\n * @fires ui-success - `success-delay` ms after `status` became `finished`\n * @csspart base - The row\n * @csspart icon - The spinner / check / error icon\n * @csspart text - The description\n */\n@customElement('ui-inline-loading')\nexport class UiInlineLoading extends UiElement {\n    static override readonly styles = css`\n        :host {\n            display: flex;\n            align-items: center;\n            width: 100%;\n            min-height: 32px;\n            font-family: var(--ui-font-family);\n            color: var(--ui-ink-muted);\n        }\n\n        .animation {\n            position: relative;\n            display: flex;\n            align-items: center;\n            justify-content: center;\n            width: 16px;\n            height: 16px;\n            margin-inline-end: var(--ui-space-xs);\n        }\n\n        svg {\n            width: 16px;\n            height: 16px;\n        }\n\n        .spinner {\n            animation: rotate 690ms linear infinite;\n        }\n\n        /* Carbon's small Loading (as <ui-loading small>): r 42 in a 100 box, a 276.46 dash (the r 44 circumference) */\n        .spinner circle {\n            fill: none;\n            stroke-dasharray: 276.46 276.46;\n            stroke-linecap: butt;\n            stroke-width: 16;\n        }\n\n        .track {\n            stroke: var(--ui-layer-accent);\n            stroke-dashoffset: -22;\n        }\n\n        .stroke {\n            stroke: var(--ui-interactive);\n            stroke-dashoffset: 143.76; /* 48 % */\n        }\n\n        /* inactive: Carbon WC .cds--loading--stop — one more turn, two turns back, then both rings run out (1.4s) */\n        .spinner.stop {\n            animation:\n                rotate-end-p1 700ms cubic-bezier(0, 0, 0.25, 1) forwards,\n                rotate-end-p2 700ms cubic-bezier(0, 0, 0.25, 1) 700ms forwards;\n        }\n\n        .spinner.stop circle {\n            animation: stroke-end 700ms cubic-bezier(0, 0, 0.25, 1) 700ms forwards;\n        }\n\n        /* Carbon CheckmarkFilled16 / ErrorFilled16: the mark is a hole in the circle, drawn at once */\n        .check {\n            fill: var(--ui-success);\n        }\n\n        .error {\n            fill: var(--ui-error);\n        }\n\n        .text {\n            font: var(--ui-font-body-sm);\n            letter-spacing: var(--ui-tracking-body);\n        }\n\n        @keyframes rotate {\n            to {\n                transform: rotate(360deg);\n            }\n        }\n\n        @keyframes rotate-end-p1 {\n            to {\n                transform: rotate(360deg);\n            }\n        }\n\n        @keyframes rotate-end-p2 {\n            to {\n                transform: rotate(-360deg);\n            }\n        }\n\n        @keyframes stroke-end {\n            from {\n                stroke-dashoffset: 52.53;\n            }\n\n            to {\n                stroke-dashoffset: 276.46;\n            }\n        }\n\n        /* reduced motion: a stopped spinner is gone at once (Carbon would leave both rings standing) */\n        @media (prefers-reduced-motion: reduce) {\n            .spinner,\n            .spinner.stop,\n            .spinner.stop circle {\n                animation-duration: 0s;\n                animation-delay: 0s;\n            }\n        }\n\n        @media (forced-colors: active) {\n            .track {\n                stroke: GrayText;\n            }\n\n            .stroke {\n                stroke: CanvasText;\n            }\n\n            .check {\n                fill: CanvasText;\n            }\n        }\n\n    `;\n\n    @property({ reflect: true }) status: InlineLoadingStatus = 'active';\n    /** Milliseconds after `finished` before `ui-success` fires (Carbon `successDelay`). */\n    @property({ type: Number, attribute: 'success-delay' }) successDelay = 1500;\n    /** Accessible name of the icon; defaults to the status. */\n    @property({ attribute: 'icon-label' }) iconLabel = '';\n\n    private timer?: ReturnType<typeof setTimeout>;\n    private readonly localize = new LocalizeController(this);\n\n    override connectedCallback() {\n        super.connectedCallback();\n        // Carbon puts aria-live on the whole component, so the status icon's name is announced with the text\n        this.internals.ariaLive = 'polite';\n    }\n\n    protected override updated(changed: Map<string, unknown>) {\n        if (!changed.has('status')) return;\n        clearTimeout(this.timer);\n        if (this.status === 'finished') {\n            this.timer = setTimeout(() => this.dispatchEvent(new CustomEvent('ui-success', { bubbles: true, composed: true })), this.successDelay);\n        }\n    }\n\n    override disconnectedCallback() {\n        super.disconnectedCallback();\n        clearTimeout(this.timer);\n    }\n\n    private renderIcon() {\n        const t = this.localize.t.common;\n        const fallback: Record<InlineLoadingStatus, string> = { active: t.loading, finished: t.loadingFinished, error: t.loadingError, inactive: '' };\n        const label = this.iconLabel || fallback[this.status];\n        switch (this.status) {\n            case 'active':\n                return html`<svg class=\"spinner\" viewBox=\"0 0 100 100\" role=\"img\" aria-label=${label}>\n                    <circle class=\"track\" cx=\"50%\" cy=\"50%\" r=\"42\" /><circle class=\"stroke\" cx=\"50%\" cy=\"50%\" r=\"42\" />\n                </svg>`;\n            case 'finished':\n                return html`<svg class=\"check\" viewBox=\"0 0 16 16\" role=\"img\" aria-label=${label}>\n                    <path d=${CHECKMARK_FILLED[16].paths[0].d} />\n                </svg>`;\n            case 'error':\n                return html`<svg class=\"error\" viewBox=\"0 0 16 16\" role=\"img\" aria-label=${label}>\n                    <path d=${ERROR_FILLED[16].paths[0].d} />\n                </svg>`;\n            case 'inactive':\n                return html`<svg class=\"spinner stop\" viewBox=\"0 0 100 100\" aria-hidden=\"true\">\n                    <circle class=\"track\" cx=\"50%\" cy=\"50%\" r=\"42\" /><circle class=\"stroke\" cx=\"50%\" cy=\"50%\" r=\"42\" />\n                </svg>`;\n        }\n    }\n\n    override render() {\n        return html`\n            <span class=\"animation\" part=\"icon\">${this.renderIcon()}</span>\n            <span class=\"text\" part=\"text\"><slot></slot></span>\n        `;\n    }\n}\n\nexport interface UiInlineLoadingEventMap extends HTMLElementEventMap {\n    'ui-success': CustomEvent<null>;\n}\n\n/** Typed listeners for UiInlineLoading's events (declaration merging with the class). */\nexport interface UiInlineLoading {\n    addEventListener<K extends keyof UiInlineLoadingEventMap>(type: K, listener: (this: UiInlineLoading, event: UiInlineLoadingEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;\n    addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;\n    removeEventListener<K extends keyof UiInlineLoadingEventMap>(type: K, listener: (this: UiInlineLoading, event: UiInlineLoadingEventMap[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-inline-loading': UiInlineLoading;\n    }\n}\n"
    }
  ]
}
