{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "show-more",
  "title": "ShowMore",
  "description": "Long content cut to a few lines, with a button to show the rest.",
  "registryDependencies": [
    "https://creance.pages.dev/r/creance-base.json"
  ],
  "files": [
    {
      "path": "show-more/ShowMore.css",
      "content": ".cr-show-more {\n  display: grid;\n  justify-items: center;\n  gap: var(--cr-space-2);\n}\n\n.cr-show-more__content {\n  justify-self: stretch;\n  overflow: hidden;\n}\n\n.cr-show-more__content[data-collapsed] {\n  -webkit-mask-image: linear-gradient(to bottom, black 45%, transparent);\n  mask-image: linear-gradient(to bottom, black 45%, transparent);\n}\n\n.cr-show-more__toggle {\n  padding: var(--cr-space-1) var(--cr-space-2);\n  border: 0;\n  border-radius: var(--cr-radius-full);\n  background: none;\n  color: var(--cr-color-text-link);\n  font: inherit;\n  font-family: var(--cr-font-family-sans);\n  font-size: var(--cr-font-size-md);\n  font-weight: var(--cr-font-weight-semibold);\n  cursor: pointer;\n}\n\n.cr-show-more__toggle:hover {\n  text-decoration: underline;\n}\n\n.cr-show-more__toggle:focus-visible {\n  outline: var(--cr-focus-width) solid var(--cr-color-focus);\n  outline-offset: var(--cr-focus-offset);\n}\n",
      "type": "registry:file",
      "target": "@components/creance/show-more/ShowMore.css"
    },
    {
      "path": "show-more/ShowMore.tsx",
      "content": "'use client';\n\nimport { useId, useLayoutEffect, useRef, useState, type ReactNode } from 'react';\nimport { cx } from '@/lib/creance/cx';\nimport './ShowMore.css';\n\nexport interface ShowMoreProps {\n  children: ReactNode;\n  /** Height shown while collapsed, in pixels. Default 96. */\n  collapsedHeight?: number;\n  /** Button text while collapsed: \"Show 209 more lines\". Default \"Show more\". */\n  moreLabel?: ReactNode;\n  lessLabel?: ReactNode;\n  defaultExpanded?: boolean;\n  className?: string;\n}\n\n/** Long content cut to a few lines with a fade. The button only appears when the content overflows. */\nexport function ShowMore({\n  children,\n  collapsedHeight = 96,\n  moreLabel = 'Show more',\n  lessLabel = 'Show less',\n  defaultExpanded = false,\n  className,\n}: ShowMoreProps) {\n  const id = useId();\n  const ref = useRef<HTMLDivElement>(null);\n  const [expanded, setExpanded] = useState(defaultExpanded);\n  const [overflows, setOverflows] = useState(true);\n\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (el) setOverflows(el.scrollHeight > collapsedHeight + 1);\n  }, [children, collapsedHeight]);\n\n  const collapsed = overflows && !expanded;\n  return (\n    <div className={cx('cr-show-more', className)}>\n      <div\n        ref={ref}\n        id={id}\n        className=\"cr-show-more__content\"\n        data-collapsed={collapsed || undefined}\n        style={collapsed ? { maxHeight: collapsedHeight } : undefined}\n      >\n        {children}\n      </div>\n      {overflows && (\n        <button\n          type=\"button\"\n          className=\"cr-show-more__toggle\"\n          aria-expanded={expanded}\n          aria-controls={id}\n          onClick={() => setExpanded(!expanded)}\n        >\n          {expanded ? lessLabel : moreLabel}\n        </button>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/creance/show-more/ShowMore.tsx"
    }
  ],
  "categories": [
    "molecule",
    "actions"
  ],
  "type": "registry:ui"
}