{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-bar",
  "type": "registry:ui",
  "title": "<ui-progress-bar>",
  "description": "Carbon `ProgressBar`: a labelled track that fills to `value / max`, or sweeps when `value` is unset (indeterminate). `status=\"finished\"` fills it green with a check mark, `status=\"error\"` empties it and turns label icon, bar and helper text red. `type=\"inline\"` puts label and track on one line (helper text is read by screen readers only); `type=\"indented\"` indents label and helper text by 16px to line up with indented content. 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-progress-bar",
    "@kanok-ui/shared-element",
    "@kanok-ui/shared-field",
    "@kanok-ui/shared-localize",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/progress-bar/progress-bar.ts",
      "type": "registry:ui",
      "target": "components/ui/primitives/progress-bar/progress-bar.ts",
      "content": "import { html, css, nothing, svg } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { srOnlyStyles, uid } from '../shared/field.ts';\nimport { UiElement } from '../shared/element.ts';\nimport { LocalizeController } from '../shared/localize.ts';\nimport { progressRatio, progressValue, type ProgressBarStatus } from '../../core/progress-bar.ts';\n\nexport type { ProgressBarStatus } from '../../core/progress-bar.ts';\nexport type ProgressBarType = 'default' | 'inline' | 'indented';\n/** `md` is Carbon's `big` (8px track), `sm` its `small` (4px). */\nexport type ProgressBarSize = 'sm' | 'md';\n\n// Carbon CheckmarkFilled / ErrorFilled (20px glyphs drawn at 16px)\nconst STATUS_ICON = {\n    finished: svg`<path d=\"M10 1a9 9 0 1 0 0 18 9 9 0 0 0 0-18ZM8.5 14 4.4 9.9l1.4-1.4 2.7 2.7 5.7-5.7 1.4 1.4z\" />`,\n    error: svg`<path d=\"M10 1a9 9 0 1 0 0 18 9 9 0 0 0 0-18Zm3.5 13.5L10 11l-3.5 3.5L5 13l3.5-3.5L5 6l1.5-1.5L10 8l3.5-3.5L15 6l-3.5 3.5L15 13z\" />`,\n};\n\n/**\n * Carbon `ProgressBar`: a labelled track that fills to `value / max`, or sweeps when `value`\n * is unset (indeterminate). `status=\"finished\"` fills it green with a check mark,\n * `status=\"error\"` empties it and turns label icon, bar and helper text red.\n * `type=\"inline\"` puts label and track on one line (helper text is read by screen readers\n * only); `type=\"indented\"` indents label and helper text by 16px to line up with\n * indented content.\n *\n * The track is the `progressbar`: `aria-valuemin/max/now` when determinate, `aria-busy`\n * until finished, named by the label (with \"Error\" for screen readers on error) and described by the helper text.\n *\n * @csspart base - The wrapper\n * @csspart label - Label row (text + status icon)\n * @csspart track - The `progressbar` element\n * @cssprop --ui-progress-track - The track's fill (default `--ui-surface-1`; Kanok: a hairline grey); `--ui-progress-radius` its corners (default square; Kanok: round)\n * @csspart bar - The filled portion\n * @csspart helper-text - Helper text below the track\n */\n@customElement('ui-progress-bar')\nexport class UiProgressBar extends UiElement {\n    static override readonly styles = [srOnlyStyles, css`\n        :host {\n            display: block;\n            font-family: var(--ui-font-family);\n            color: var(--ui-ink);\n        }\n\n        .label {\n            display: flex;\n            justify-content: space-between;\n            min-inline-size: 48px;\n            margin-block-end: var(--ui-space-xs);\n            font: var(--ui-font-body-sm);\n            line-height: 18px; /* body-compact-01 */\n            letter-spacing: var(--ui-tracking-body);\n        }\n\n        .label-text {\n            overflow: hidden;\n            text-overflow: ellipsis;\n            white-space: nowrap;\n        }\n\n        .status-icon {\n            flex-shrink: 0;\n            width: 16px;\n            height: 16px;\n            margin-inline-start: var(--ui-space-md);\n            fill: currentColor;\n        }\n\n        .track {\n            position: relative;\n            inline-size: 100%;\n            min-inline-size: 48px;\n            block-size: 8px;\n            /* Carbon: a square track in the layer colour; a design can tint and round it (the bar is clipped to it) */\n            border-radius: var(--ui-progress-radius);\n            background-color: var(--ui-progress-track, var(--ui-surface-1));\n            clip-path: inset(0 round var(--ui-progress-radius));\n        }\n\n        :host([size='sm']) .track {\n            block-size: 4px;\n        }\n\n        .bar {\n            display: block;\n            inline-size: 100%;\n            block-size: 100%;\n            background-color: currentColor;\n            color: var(--ui-interactive, var(--ui-primary));\n            transform: scaleX(0);\n            transform-origin: 0 center;\n            transition: transform var(--ui-duration-moderate) var(--ui-easing);\n        }\n\n        :host(:dir(rtl)) .bar {\n            transform-origin: 100% center;\n        }\n\n        .indeterminate .track::after {\n            content: '';\n            position: absolute;\n            inset: 0;\n            background-image: linear-gradient(90deg, var(--ui-interactive, var(--ui-primary)) 12.5%, transparent 12.5%);\n            background-position-x: 0%;\n            background-size: 200% 100%;\n            animation: indeterminate 1400ms linear infinite;\n        }\n\n        :host(:dir(rtl)) .indeterminate .track::after {\n            animation-name: indeterminate-rtl;\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n            .indeterminate .track::after {\n                animation-duration: 4s; /* keep the busy cue, drop the speed */\n            }\n        }\n\n        @keyframes indeterminate {\n            0% {\n                background-position-x: 25%;\n            }\n\n            80%,\n            100% {\n                background-position-x: -105%;\n            }\n        }\n\n        @keyframes indeterminate-rtl {\n            0% {\n                background-position-x: -105%;\n            }\n\n            80%,\n            100% {\n                background-position-x: 25%;\n            }\n        }\n\n        .helper {\n            margin-block-start: var(--ui-space-xs);\n            color: var(--ui-ink-muted);\n            font: var(--ui-font-caption);\n            line-height: 16px; /* helper-text-01 */\n            letter-spacing: var(--ui-tracking-caption);\n        }\n\n        .finished .bar,\n        .finished .status-icon {\n            color: var(--ui-success);\n        }\n\n        .error .bar,\n        .error .status-icon,\n        .error .helper {\n            color: var(--ui-error-text, var(--ui-error));\n        }\n\n        .finished .bar,\n        .error .bar {\n            transform: scaleX(1);\n        }\n\n        /* inline: label | track on one row; helper text for screen readers only */\n        :host([type='inline']) .base {\n            display: flex;\n            align-items: center;\n        }\n\n        :host([type='inline']) .label {\n            flex-shrink: 0;\n            margin-block-end: 0;\n            margin-inline-end: var(--ui-space-md);\n        }\n\n        :host([type='inline']) .track {\n            flex: 1 1 0;\n        }\n\n        :host([type='inline']) .finished .track,\n        :host([type='inline']) .error .track {\n            position: absolute;\n            min-inline-size: 0;\n            width: 1px;\n            height: 1px;\n            margin: -1px;\n            overflow: hidden;\n            clip-path: inset(50%);\n        }\n\n        :host([type='inline']) .finished .label,\n        :host([type='inline']) .error .label {\n            flex-shrink: 1;\n            justify-content: flex-start;\n            margin-inline-end: 0;\n        }\n\n        :host([type='indented']) .label,\n        :host([type='indented']) .helper {\n            padding-inline: var(--ui-space-md);\n        }\n\n        @media (forced-colors: active) {\n            .track {\n                border: 1px solid CanvasText;\n            }\n\n            .bar {\n                background-color: Highlight;\n            }\n        }\n    `];\n\n    /** Required. What is progressing; shown above (or beside) the track and read as the bar's name. */\n    @property() label = '';\n\n    /** Visually hides the label (it still names the bar). */\n    @property({ type: Boolean, attribute: 'hide-label' }) hideLabel = false;\n\n    @property({ attribute: 'helper-text' }) helperText = '';\n\n    /** Current progress; leave unset for an indeterminate bar. */\n    @property({ type: Number }) value?: number;\n\n    @property({ type: Number }) max = 100;\n\n    @property({ reflect: true }) size: ProgressBarSize = 'md';\n\n    @property({ reflect: true }) status: ProgressBarStatus = 'active';\n\n    @property({ reflect: true }) type: ProgressBarType = 'default';\n\n    private readonly ids = uid('ui-progress-bar');\n    private readonly localize = new LocalizeController(this);\n\n    override render() {\n        const finished = this.status === 'finished';\n        const error = this.status === 'error';\n        const capped = progressValue(this.value, this.max, this.status);\n        const indeterminate = capped === undefined;\n        const icon = finished || error ? STATUS_ICON[this.status as 'finished' | 'error'] : null;\n        const helperId = `${this.ids}-helper`;\n        const ratio = progressRatio(capped, this.max);\n        const scale = indeterminate || finished || error ? '' : `transform: scaleX(${ratio})`;\n        return html`\n            <div class=\"base ${classMap({ indeterminate, finished, error })}\" part=\"base\">\n                <div class=\"label ${classMap({ 'sr-only': this.hideLabel })}\" id=${`${this.ids}-label`} part=\"label\">\n                    <span class=\"label-text\">${this.label}</span>\n                    ${error ? html`<span class=\"sr-only\">, ${this.localize.t.common.loadingError}</span>` : nothing}\n                    ${icon ? html`<svg class=\"status-icon\" viewBox=\"0 0 20 20\" aria-hidden=\"true\">${icon}</svg>` : nothing}\n                </div>\n                <div\n                    class=\"track\"\n                    part=\"track\"\n                    role=\"progressbar\"\n                    aria-busy=${finished ? 'false' : 'true'}\n                    aria-labelledby=${`${this.ids}-label`}\n                    aria-describedby=${ifDefined(this.helperText ? helperId : undefined)}\n                    aria-valuemin=${ifDefined(indeterminate ? undefined : 0)}\n                    aria-valuemax=${ifDefined(indeterminate ? undefined : this.max)}\n                    aria-valuenow=${ifDefined(indeterminate ? undefined : capped)}\n                >\n                    <div class=\"bar\" part=\"bar\" style=${scale}></div>\n                </div>\n                ${this.helperText ? html`<div class=\"helper\" id=${helperId} part=\"helper-text\">${this.helperText}</div>` : nothing}\n            </div>\n        `;\n    }\n}\n\ndeclare global {\n    interface HTMLElementTagNameMap {\n        'ui-progress-bar': UiProgressBar;\n    }\n}\n"
    }
  ]
}
