{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress",
  "title": "Progress",
  "description": "How far a task has got. The fill draws along a thin track, a sheen runs over it while it works, a piece slides across while the length is unknown, and the value turns into a tick when it is done. A ring shows it where a line is too short for a track.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/spinner.json",
    "https://kinoui.com/r/track.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/progress.tsx",
      "content": "'use client'\n\nimport { Spinner } from '@/registry/components/kino/spinner'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport {\n  gaugeText,\n  slidingFillClassName,\n  slidingFillStyle,\n  trackClassName,\n  trackFillClassName,\n  trackHeaderClassName,\n  trackLabelClassName,\n  trackRootClassName,\n  valuePercent,\n} from '@/registry/lib/track'\nimport {\n  ProgressIndicator as ProgressIndicatorPrimitive,\n  ProgressLabel as ProgressLabelPrimitive,\n  Progress as ProgressPrimitive,\n  ProgressTrack as ProgressTrackPrimitive,\n  ProgressValue as ProgressValuePrimitive,\n  type ProgressValueState,\n} from '@ui-sdk/react/progress'\nimport type { ComponentProps, ReactNode } from 'react'\n\nimport { cn } from '@/lib/utils'\n\ntype ProgressRootProps = Omit<\n  ComponentProps<typeof ProgressPrimitive>,\n  'className' | 'format' | 'locale' | 'children'\n> & {\n  className?: string\n  /** How `ProgressValue` and the value read out are written: a percentage by default. */\n  format?: Intl.NumberFormatOptions\n  locale?: Intl.LocalesArgument\n}\n\ntype ProgressProps = ProgressRootProps & {\n  /** `destructive` for a task that failed: the fill turns red and stops looking live. */\n  variant?: 'default' | 'destructive'\n  /** Names a progress that has no `ProgressLabel`. */\n  'aria-label'?: string\n  /** The label and value, in a row above the track. */\n  children?: ReactNode\n  /**\n   * Draws the track as one segment for each entry, for work done in any\n   * order, such as a setup's tasks: `filled` for one done, `dimmed` for one\n   * set aside and `empty` for one to do. `value` is still what is read out.\n   */\n  segments?: readonly ProgressSegment[]\n}\n\ntype ProgressSegment = 'filled' | 'dimmed' | 'empty'\n\nfunction Progress({\n  className,\n  children,\n  value,\n  min = 0,\n  max = 100,\n  variant = 'default',\n  format,\n  locale,\n  segments,\n  ...props\n}: ProgressProps) {\n  const percent = valuePercent(value ?? null, min, max)\n  // Live once it has started, until it ends or fails; segments are steps, never live.\n  const running =\n    percent > 0 && percent < 100 && variant === 'default' && segments === undefined\n  return (\n    <ProgressPrimitive\n      data-variant={variant}\n      data-live={running || undefined}\n      value={value}\n      min={min}\n      max={max}\n      format={(reading: number) => gaugeText(reading, { min, max, locale, format })}\n      className={cn(trackRootClassName, 'group/progress', className)}\n      {...props}\n    >\n      {children ? (\n        <div data-slot='progress-header' className={trackHeaderClassName}>\n          {children}\n        </div>\n      ) : null}\n      {segments ? (\n        <ProgressTrackPrimitive data-segmented='' className='flex w-full gap-1'>\n          {segments.map((segment, index) => (\n            <span\n              // A segment is its place on the track.\n              // oxlint-disable-next-line react/no-array-index-key\n              key={index}\n              className={cn(trackClassName, 'min-w-0 flex-1 overflow-hidden')}\n            >\n              <span\n                data-segment={segment}\n                style={slidingFillStyle(segment === 'empty' ? 0 : 100)}\n                className={cn(\n                  slidingFillClassName,\n                  'data-[segment=dimmed]:bg-muted-foreground/35 forced-colors:data-[segment=dimmed]:bg-[GrayText]!',\n                )}\n              />\n            </span>\n          ))}\n        </ProgressTrackPrimitive>\n      ) : (\n        <ProgressTrackPrimitive className={cn(trackClassName, 'overflow-hidden')}>\n          <ProgressIndicatorPrimitive\n            style={slidingFillStyle(percent)}\n            className={cn(\n              slidingFillClassName,\n              'data-[variant=destructive]:bg-destructive',\n            )}\n            data-variant={variant}\n          >\n            {/* Live while it runs: a sheen sweeps the fill. It pauses where it is and fades once the task ends. */}\n            <span\n              aria-hidden\n              className='via-primary-foreground/35 pointer-events-none absolute inset-y-0 start-0 w-[30%] animate-[kino-progress-sheen_calc(var(--motion-layout-duration)*5)_linear_infinite] bg-linear-to-r from-transparent to-transparent opacity-0 transition-opacity duration-(--motion-exit-duration) ease-(--motion-exit-easing) [animation-play-state:paused] group-data-live/progress:opacity-100 group-data-live/progress:[animation-play-state:running] motion-reduce:hidden forced-colors:hidden rtl:bg-linear-to-l'\n            />\n          </ProgressIndicatorPrimitive>\n          {/* Unknown length: a piece of the fill slides across. It pauses where it is and fades as the real fill draws in. */}\n          <span\n            aria-hidden\n            data-slot='progress-indeterminate'\n            className={cn(\n              trackFillClassName,\n              'start-0 w-2/5 animate-[kino-progress-slide_calc(var(--motion-layout-duration)*4)_ease-in-out_infinite] rounded-full opacity-0 transition-opacity duration-(--motion-exit-duration) ease-(--motion-exit-easing) [animation-play-state:paused] group-data-indeterminate/progress:opacity-100 group-data-indeterminate/progress:duration-(--motion-enter-duration) group-data-indeterminate/progress:[animation-play-state:running] motion-reduce:w-full motion-reduce:animate-none motion-reduce:group-data-indeterminate/progress:animate-pulse',\n            )}\n          />\n        </ProgressTrackPrimitive>\n      )}\n    </ProgressPrimitive>\n  )\n}\n\nfunction ProgressLabel({\n  className,\n  ...props\n}: Omit<ComponentProps<typeof ProgressLabelPrimitive>, 'className'> & {\n  className?: string\n}) {\n  return (\n    <ProgressLabelPrimitive className={cn(trackLabelClassName, className)} {...props} />\n  )\n}\n\ntype ProgressValueProps = Omit<\n  ComponentProps<typeof ProgressValuePrimitive>,\n  'children' | 'className'\n> & {\n  className?: string\n  /** Writes the value yourself from its state, such as `512 of 1,284`. Not called while the value is unknown. */\n  children?: (state: ProgressValueState & { value: number }) => ReactNode\n  /** What it says beside a tick once the task is complete. */\n  completeLabel?: ReactNode\n}\n\n/**\n * The value, at the end of the row. Once the task completes, it leaves and a\n * tick with `completeLabel` takes its place. Both sit in one grid cell, so\n * the change moves nothing beside it.\n */\nfunction ProgressValue({\n  className,\n  children,\n  completeLabel = 'Done',\n  ...props\n}: ProgressValueProps) {\n  return (\n    <ProgressValuePrimitive\n      className={cn(\n        'text-muted-foreground ms-auto grid shrink-0 justify-items-end',\n        className,\n      )}\n      {...props}\n    >\n      {(state) => {\n        // While the value is unknown, the row shows nothing.\n        const text =\n          state.value === null\n            ? null\n            : children\n              ? children({ ...state, value: state.value })\n              : state.text\n        return (\n          <>\n            <span className='col-start-1 row-start-1 tabular-nums transition-[opacity,translate] duration-(--motion-exit-duration) ease-(--motion-exit-easing) group-data-complete/progress:-translate-y-(--progress-value-roll,0.375rem) group-data-complete/progress:opacity-0 group-data-[variant=destructive]/progress:translate-y-0 group-data-[variant=destructive]/progress:opacity-100 motion-reduce:translate-y-0'>\n              {text || ' '}\n            </span>\n            <span className=\"text-foreground col-start-1 row-start-1 inline-flex translate-y-(--progress-value-roll,0.375rem) items-center gap-1 font-medium opacity-0 transition-[opacity,translate] duration-(--motion-exit-duration) ease-(--motion-exit-easing) group-data-complete/progress:translate-y-0 group-data-complete/progress:opacity-100 group-data-complete/progress:delay-[calc(var(--motion-draw-duration)*0.7)] group-data-complete/progress:duration-(--motion-enter-duration) group-data-complete/progress:ease-(--motion-enter-easing) group-data-[variant=destructive]/progress:hidden motion-reduce:translate-y-0 [&_svg:not([class*='size-'])]:size-4\">\n              <IconPlaceholder\n                lucide='CheckIcon'\n                tabler='IconCheck'\n                hugeicons='Tick02Icon'\n                phosphor='CheckIcon'\n                remixicon='RiCheckLine'\n                aria-hidden\n              />\n              {completeLabel}\n            </span>\n          </>\n        )\n      }}\n    </ProgressValuePrimitive>\n  )\n}\n\n/**\n * The progress as a ring, for a line too short for a track, such as an\n * island's pill: it fills clockwise from the top on `draw`. While the value\n * is unknown, the Spinner's arc turns in its place, and it fades to the ring\n * once a value comes. It is 16px, as an icon beside text.\n */\nfunction ProgressRing({\n  className,\n  value,\n  min = 0,\n  max = 100,\n  format,\n  locale,\n  ...props\n}: ProgressRootProps & {\n  /** Names a ring that has no label beside it. */\n  'aria-label'?: string\n}) {\n  const percent = valuePercent(value ?? null, min, max)\n  return (\n    <ProgressPrimitive\n      data-progress-ring=''\n      value={value}\n      min={min}\n      max={max}\n      format={(reading: number) => gaugeText(reading, { min, max, locale, format })}\n      className={cn(\n        'group/progress-ring text-primary relative inline-grid size-4 shrink-0 forced-colors:text-[Highlight] *:col-start-1 *:row-start-1 *:size-full',\n        className,\n      )}\n      {...props}\n    >\n      <svg\n        aria-hidden\n        viewBox='0 0 16 16'\n        fill='none'\n        className='opacity-100 transition-opacity duration-(--motion-enter-duration) ease-(--motion-enter-easing) group-data-indeterminate/progress-ring:opacity-0'\n      >\n        <circle\n          cx='8'\n          cy='8'\n          r='6'\n          stroke='currentColor'\n          strokeOpacity='0.25'\n          strokeWidth='2'\n        />\n        <circle\n          cx='8'\n          cy='8'\n          r='6'\n          pathLength={100}\n          strokeDasharray='100'\n          strokeDashoffset={100 - percent}\n          strokeWidth='2'\n          strokeLinecap='round'\n          transform='rotate(-90 8 8)'\n          className='stroke-current transition-[stroke-dashoffset] duration-(--motion-draw-duration) ease-(--motion-draw-easing) motion-reduce:transition-none'\n        />\n      </svg>\n      <Spinner\n        aria-hidden\n        className='size-full opacity-0 transition-opacity duration-(--motion-exit-duration) ease-(--motion-exit-easing) [animation-play-state:paused] group-data-indeterminate/progress-ring:opacity-100 group-data-indeterminate/progress-ring:[animation-play-state:running]'\n      />\n    </ProgressPrimitive>\n  )\n}\n\nexport { Progress, ProgressLabel, ProgressRing, ProgressValue }\nexport type { ProgressSegment }\n",
      "type": "registry:component",
      "target": "@components/kino/progress.tsx"
    }
  ],
  "css": {
    "@keyframes kino-progress-sheen": {
      "from": {
        "translate": "calc(var(--track-dir, 1) * -100%) 0"
      },
      "to": {
        "translate": "calc(var(--track-dir, 1) * 340%) 0"
      }
    },
    "@keyframes kino-progress-slide": {
      "from": {
        "translate": "calc(var(--track-dir, 1) * -100%) 0"
      },
      "to": {
        "translate": "calc(var(--track-dir, 1) * 250%) 0"
      }
    }
  },
  "type": "registry:component"
}