{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shared-skeleton",
  "type": "registry:lib",
  "title": "shared/skeleton",
  "description": "Internal module shared by the ui-* components (skeleton). 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-field",
    "@kanok-ui/tokens"
  ],
  "files": [
    {
      "path": "src/primitives/shared/skeleton.ts",
      "type": "registry:lib",
      "target": "components/ui/primitives/shared/skeleton.ts",
      "content": "import { css, html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { UiElement } from './element.ts';\nimport { hasData, syncFluid } from './field.ts';\n\n/**\n * Carbon `skeleton` mixin (@carbon/styles utilities/_skeleton.scss) for any `.bone` element: the\n * skeleton-background bar with a skeleton-element layer that grows and shrinks across it every 3s.\n */\nexport const skeletonStyles = css`\n    .bone {\n        position: relative;\n        overflow: hidden;\n        /* square in Carbon; a design rounds the bars (--ui-skeleton-radius, Kanok: 4px) */\n        border-radius: var(--ui-skeleton-radius);\n        background-color: var(--ui-skeleton-background);\n        pointer-events: none;\n    }\n\n    .bone::before {\n        position: absolute;\n        inset-block-start: 0;\n        inset-inline-start: 0;\n        inline-size: 100%;\n        block-size: 100%;\n        background-color: var(--ui-skeleton-element);\n        animation: 3000ms ease-in-out ui-skeleton infinite;\n        content: '';\n        will-change: transform-origin, transform, opacity;\n    }\n\n    @media (prefers-reduced-motion: reduce) {\n        .bone::before {\n            animation: none;\n        }\n    }\n\n    @keyframes ui-skeleton {\n        0% {\n            opacity: 0.3;\n            transform: scaleX(0);\n            transform-origin: left;\n        }\n\n        20% {\n            opacity: 1;\n            transform: scaleX(1);\n            transform-origin: left;\n        }\n\n        28% {\n            transform: scaleX(1);\n            transform-origin: right;\n        }\n\n        51% {\n            transform: scaleX(0);\n            transform-origin: right;\n        }\n\n        58% {\n            transform: scaleX(0);\n            transform-origin: right;\n        }\n\n        82% {\n            transform: scaleX(1);\n            transform-origin: right;\n        }\n\n        83% {\n            transform: scaleX(1);\n            transform-origin: left;\n        }\n\n        96% {\n            transform: scaleX(0);\n            transform-origin: left;\n        }\n\n        100% {\n            opacity: 0.3;\n            transform: scaleX(0);\n            transform-origin: left;\n        }\n    }\n\n    @media (forced-colors: active) {\n        .bone {\n            background-color: CanvasText;\n        }\n\n        .bone::before {\n            background-color: Canvas;\n            forced-color-adjust: none;\n        }\n    }\n`;\n\n/**\n * Carbon's field skeleton (TextInput, NumberInput, Dropdown, Select, DatePicker, TextArea): a 75×14 label bar,\n * 8px, then the field's bar at the field's height (`--_field-h`, from `size`: sm 32 / md 40 / lg 48).\n */\nexport const fieldSkeletonStyles = css`\n    :host {\n        display: block;\n        --_field-h: var(--ui-field-height-md, 40px);\n    }\n\n    :host([size='sm']) {\n        --_field-h: var(--ui-field-height-sm, 32px);\n    }\n\n    :host([size='lg']) {\n        --_field-h: var(--ui-field-height-lg, 48px);\n    }\n\n    .label {\n        display: block;\n        inline-size: 75px;\n        block-size: 14px;\n        margin-block-end: var(--ui-space-xs);\n    }\n\n    :host([hide-label]) .label {\n        display: none;\n    }\n\n    .field {\n        inline-size: 100%;\n        block-size: var(--_field-h);\n        border-radius: var(--ui-field-radius, var(--ui-skeleton-radius)); /* the field's corners */\n    }\n\n    /*\n     * Carbon's fluid field skeletons (FluidTextInput / FluidDropdown / FluidSelect … Skeleton): a 64px box in\n     * skeleton-background with a 1px skeleton-element line below, a 25% bar 16px in and a 50% bar at 36px.\n     */\n    .fluid-box {\n        position: relative;\n        box-sizing: border-box;\n        block-size: 64px;\n        border-block-end: 1px solid var(--ui-skeleton-element);\n        background-color: var(--ui-skeleton-background);\n    }\n\n    .fluid-box .bone {\n        position: absolute;\n        inset-inline-start: var(--ui-space-md);\n        block-size: 8px;\n    }\n\n    .fluid-box .top {\n        inset-block-start: var(--ui-space-md);\n        inline-size: 25%;\n    }\n\n    .fluid-box .bottom {\n        inset-block-start: 36px;\n        inline-size: 50%;\n    }\n`;\n\n/** A fluid field skeleton's box with its two bars. */\nexport const fluidSkeletonBox = html`<div class=\"fluid-box\" part=\"field\"><span class=\"bone top\" part=\"label\"></span><span class=\"bone bottom\" part=\"value\"></span></div>`;\n\n/**\n * A component skeleton (Carbon `*Skeleton`): the shape of a component while its data loads. Purely visual —\n * hidden from assistive tech and never focusable; say \"loading\" on the container (`aria-busy`, a status message).\n */\nexport class UiSkeletonElement extends UiElement {\n    override connectedCallback() {\n        super.connectedCallback();\n        this.setAttribute('aria-hidden', 'true');\n    }\n}\n\n/** A field's skeleton: the label bar and the field bar (Carbon `TextInputSkeleton`, `DropdownSkeleton` …). */\nexport class UiFieldSkeleton extends UiSkeletonElement {\n    static override readonly styles = [skeletonStyles, fieldSkeletonStyles];\n\n    /** The field's height: sm 32px, md 40px, lg 48px. */\n    @property({ reflect: true }) size: 'sm' | 'md' | 'lg' = 'md';\n\n    /** No label bar (the field had `hide-label`). */\n    @property({ type: Boolean, reflect: true, attribute: 'hide-label' }) hideLabel = false;\n\n    /** The fluid field's skeleton (Carbon `Fluid*Skeleton`): a 64px box with two bars; `<ui-fluid-form>` sets it. */\n    @property({ type: Boolean, reflect: true }) fluid = false;\n\n    /** Fluid itself or inside a `<ui-fluid-form>`. */\n    protected get isFluid() {\n        return hasData(this, 'fluid');\n    }\n\n    override connectedCallback() {\n        super.connectedCallback();\n        syncFluid(this, this.fluid);\n    }\n\n    protected override willUpdate() {\n        syncFluid(this, this.fluid);\n    }\n\n    override render() {\n        if (this.isFluid) return fluidSkeletonBox;\n        return html`<span class=\"bone label\" part=\"label\"></span><div class=\"bone field\" part=\"field\"></div>`;\n    }\n}\n"
    }
  ]
}
