{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-select",
  "type": "registry:ui",
  "title": "react-tw/select.tsx",
  "description": "Carbon `Select` as a React + Tailwind component: a native `<select>` (your `<option>` / 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": [
    "@purpurabog/ui@^2.3.0"
  ],
  "registryDependencies": [
    "@kanok-ui/core-field",
    "@kanok-ui/tw-field",
    "@kanok-ui/tw-skeleton",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/select.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/select.tsx",
      "content": "import { useId, type ComponentProps, type ReactNode } from 'react';\nimport { Select as SelectPrimitive } from '@purpurabog/ui/headless';\nimport { FieldLabel, FieldMessageLine, StatusIcon, fluidBoxClasses, fluidControlClasses, useFluid, useFieldDisabled, fieldMessage, fieldBoxClasses, fieldDisabledState, fieldReadOnlyEdge, fieldInlineEdge, fieldLabelFont, fieldLabelInk, fieldInvalidRing, fieldTextSize } from './field.tsx';\nimport type { FieldMessage } from '../core/field.ts';\nimport { cn } from './lib/utils.ts';\nimport { FieldSkeleton, type FieldSkeletonProps } from './skeleton.tsx';\n\n/**\n * Carbon `Select` as a React + Tailwind component: a native `<select>` (your `<option>` /\n * `<optgroup>` children) drawn as `<ui-select>` — the chevron and status icon 16px from the end,\n * a muted placeholder, `inline` for a label beside a borderless select. `readOnly` keeps the value\n * (mouse and keyboard can't change it). Validation is the app's: `invalid` + `invalidText`.\n * `fluid` (or a `FluidForm` around it) is Carbon `FluidSelect`: the label inside a 64px box.\n */\nexport interface SelectProps extends Omit<ComponentProps<'select'>, 'size'> {\n    label: ReactNode;\n    hideLabel?: boolean;\n    size?: 'sm' | 'md' | 'lg';\n    /** First, empty option shown in a muted colour until a value is chosen. */\n    placeholder?: string;\n    helperText?: ReactNode;\n    invalid?: boolean;\n    invalidText?: ReactNode;\n    warn?: boolean;\n    warnText?: ReactNode;\n    readOnly?: boolean;\n    /** Label beside the select, no field background or border (Carbon inline select). */\n    inline?: boolean;\n    /** Carbon `FluidSelect` (also set by `FluidForm`). */\n    fluid?: boolean;\n}\n\ninterface SelectLook {\n    size: NonNullable<SelectProps['size']>;\n    showError: boolean;\n    /** A warning or error icon sits beside the arrow. */\n    hasStatus: boolean;\n    readOnly: boolean;\n    inline: boolean;\n    fluid: boolean;\n    status: FieldMessage['kind'] | undefined;\n}\n\nconst FIELD_HEIGHT = { sm: 'min-h-field-sm', md: 'min-h-field-md', lg: 'min-h-field-lg' } as const;\n\nfunction selectClasses({ size, showError, hasStatus, readOnly, inline, fluid, status }: SelectLook) {\n    return cn(\n        // ui-select-picker (theme.css): appearance none (Carbon), or a customizable select in a design's menu look (Kanok)\n        'm-0 box-border w-full cursor-pointer ui-select-picker py-0 ps-4 pe-12',\n        fieldBoxClasses,\n        'text-ink type-body-sm',\n        fieldTextSize,\n        // Carbon select-input: the outline at fast-01, not the background\n        'outline-[length:var(--ui-field-focus-width,2px)] [outline-offset:calc(-1*var(--ui-field-focus-width,2px))] outline-transparent transition-[outline-color] duration-(--ui-duration-fast) ease-carbon focus:outline-focus focus:[box-shadow:var(--ui-field-focus-halo,none)]',\n        'disabled:cursor-not-allowed disabled:text-ink-disabled',\n        fieldDisabledState,\n        FIELD_HEIGHT[size],\n        // the placeholder is the choice shown (disabled keeps the disabled colour)\n        'enabled:data-placeholder:text-ink-muted',\n        showError && fieldInvalidRing,\n        hasStatus && 'pe-18',\n        readOnly && cn('cursor-default bg-[var(--ui-field-readonly-background,transparent)]', fieldReadOnlyEdge),\n        inline && cn('w-auto bg-transparent hover:bg-ghost-hover', fieldInlineEdge),\n        'forced-colors:border forced-colors:border-[FieldText] forced-colors:focus:outline-[Highlight]',\n        '[&_option]:text-ink',\n        fluid && cn('h-16 min-h-16 pt-8 pb-[13px] pe-8', fluidControlClasses(status, readOnly)),\n    );\n}\n\n/** The inline select's label sits beside it; otherwise the field label above (or inside, fluid). */\nfunction SelectLabel({ htmlFor, inline, hidden, disabled, fluid, children }: Readonly<{ htmlFor: string; inline: boolean; hidden?: boolean; disabled: boolean; fluid: boolean; children: ReactNode }>) {\n    if (inline && !hidden) {\n        return (\n            <label htmlFor={htmlFor} className={cn('inline-block', fieldLabelFont, fieldLabelInk, disabled && 'text-ink-disabled')}>\n                {children}\n            </label>\n        );\n    }\n    return (\n        <FieldLabel htmlFor={htmlFor} hidden={hidden} disabled={disabled} fluid={fluid}>\n            {children}\n        </FieldLabel>\n    );\n}\n\n/** The arrow (and the status icon before it); fluid: the arrow 34px down, 12px from the end, the status icon in the message row. */\nfunction SelectArrow({ status, fluid, disabled, readOnly }: Readonly<{ status: FieldMessage['kind'] | undefined; fluid: boolean; disabled: boolean; readOnly: boolean }>) {\n    return (\n        <span className={cn('pointer-events-none absolute inset-y-0 end-4 flex items-center gap-2', fluid && 'end-3 items-start pt-[34px]')} aria-hidden=\"true\">\n            <StatusIcon kind={status} className={fluid ? 'absolute end-1 top-[calc(100%+8px)]' : undefined} />\n            <svg className={cn('size-4 fill-ink forced-colors:fill-[FieldText]', disabled && 'fill-ink-disabled', readOnly && 'fill-ink-subtle')} viewBox=\"0 0 16 16\">\n                <path d=\"M8 11 3 6l.7-.7L8 9.6l4.3-4.3.7.7z\" />\n            </svg>\n        </span>\n    );\n}\n\nexport function Select({ label, hideLabel, size = 'md', placeholder, helperText, invalid, invalidText, warn, warnText, readOnly, inline, fluid: fluidProp, className, id, disabled: ownDisabled, ...rest }: Readonly<SelectProps>) {\n    const disabled = useFieldDisabled(ownDisabled);\n    const autoId = useId();\n    const selectId = id ?? autoId;\n    const interactive = !disabled && !readOnly;\n    const { message, content } = fieldMessage({ interactive, invalid, invalidText, warn, warnText, helperText });\n    const showError = message?.kind === 'error';\n    const hasStatus = !!message && message.kind !== 'helper';\n    const fluid = useFluid(fluidProp) && !inline;\n    const status = hasStatus ? message.kind : undefined;\n    return (\n        <div className={cn('block font-sans', inline && 'grid grid-cols-[auto_auto] items-center justify-start gap-x-2', fluid && fluidBoxClasses(status, readOnly), className)}>\n            <SelectLabel htmlFor={selectId} inline={!!inline} hidden={hideLabel} disabled={disabled} fluid={fluid}>\n                {label}\n            </SelectLabel>\n            <div className=\"relative\">\n                <SelectPrimitive.Root\n                    {...rest}\n                    id={selectId}\n                    placeholder={placeholder}\n                    disabled={disabled}\n                    readOnly={!!readOnly}\n                    invalid={showError}\n                    aria-describedby={message ? `${selectId}-message` : undefined}\n                    className={selectClasses({ size, showError, hasStatus, readOnly: !!readOnly, inline: !!inline, fluid, status })}\n                />\n                <SelectArrow status={message?.kind} fluid={fluid} disabled={disabled} readOnly={!!readOnly} />\n            </div>\n            <FieldMessageLine id={`${selectId}-message`} message={message} content={content} disabled={disabled} fluid={fluid} className={inline ? 'col-span-full' : undefined} />\n        </div>\n    );\n}\n\n/** Carbon `SelectSkeleton`: the shape of the field while its data loads (label bar, 8px, the field's bar). Hidden from assistive tech. */\nexport function SelectSkeleton(props: Readonly<FieldSkeletonProps>) {\n    return <FieldSkeleton {...props} />;\n}\n"
    }
  ]
}
