{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-lists",
  "type": "registry:ui",
  "title": "react-tw/lists.tsx",
  "description": "Carbon `UnorderedList` as React + Tailwind, the look of `<ui-unordered-list>`: items marked with an en dash 16px 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": [],
  "registryDependencies": [
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/lists.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/lists.tsx",
      "content": "import { createContext, useContext, useMemo, type ComponentProps } from 'react';\nimport { cn } from './lib/utils.ts';\n\ntype Marker = 'dash' | 'square' | 'counter' | 'native';\n\n/** The list an item sits in (its marker); `inItem` tells a list it is nested. */\nconst ListContext = createContext<{ marker: Marker; nested: boolean; inItem: boolean }>({ marker: 'dash', nested: false, inItem: false });\n\n/** body-01 (14px / 20px) on a top list, body-02 with `isExpressive`; a nested list takes its parent's. */\nfunction listClasses(nested: boolean, expressive: boolean) {\n    return cn(\n        'm-0 p-0 list-none',\n        nested && !expressive && 'ms-8 [font:inherit] tracking-[inherit]',\n        nested && expressive && 'ms-8',\n        !nested && !expressive && 'type-body-sm leading-5!',\n        expressive && '[font:var(--ui-font-body)] tracking-normal',\n    );\n}\n\nconst MARKERS: Record<Marker, string> = {\n    // Carbon: an en dash 16px before the text; nested a ▪ 12px before\n    dash: \"before:absolute before:-start-4 before:content-['–']\",\n    square: \"before:absolute before:-start-3 before:content-['▪︎']\",\n    // \"1.\" 24px before the text, outside the list's box (as Carbon)\n    counter: \"before:absolute before:-start-6 before:content-[counter(item)_'.'] before:[counter-increment:item]\",\n    native: '',\n};\n\nexport interface UnorderedListProps extends Omit<ComponentProps<'ul'>, 'nested' | 'isExpressive'> {\n    /** Nested in another list's item (found for you inside a `ListItem`). */\n    nested?: boolean;\n    /** Body-02 type (16px) for expressive pages. */\n    isExpressive?: boolean;\n}\n\n/**\n * Carbon `UnorderedList` as React + Tailwind, the look of `<ui-unordered-list>`: items marked with an en dash 16px\n * before the text, the list 16px in; a list inside a `ListItem` is nested (32px in, a ▪ 12px before, items 4px in).\n */\nexport function UnorderedList({ nested: nestedProp, isExpressive = false, className, children, ...rest }: Readonly<UnorderedListProps>) {\n    const { inItem } = useContext(ListContext);\n    const nested = nestedProp ?? inItem;\n    const context = useMemo(() => ({ marker: nested ? 'square' : 'dash', nested, inItem: false }) as const, [nested]);\n    return (\n        <ul {...rest} className={cn(listClasses(nested, isExpressive), !nested && 'ms-4', className)}>\n            <ListContext.Provider value={context}>{children}</ListContext.Provider>\n        </ul>\n    );\n}\n\nexport interface OrderedListProps extends Omit<ComponentProps<'ol'>, 'nested' | 'isExpressive' | 'native'> {\n    /** Nested in another list's item (found for you inside a `ListItem`). */\n    nested?: boolean;\n    /** The browser's own markers (`decimal`) instead of Carbon's counter. */\n    native?: boolean;\n    /** Body-02 type (16px) for expressive pages. */\n    isExpressive?: boolean;\n}\n\n/**\n * Carbon `OrderedList` as React + Tailwind, the look of `<ui-ordered-list>`: items numbered \"1.\" 24px before the text\n * (outside the list's box, as Carbon); a nested list uses lower-latin markers (a. b. c.), 32px in; `native` the\n * browser's decimal markers at the top level too.\n */\nexport function OrderedList({ nested: nestedProp, native = false, isExpressive = false, className, children, ...rest }: Readonly<OrderedListProps>) {\n    const { inItem } = useContext(ListContext);\n    const nested = nestedProp ?? inItem;\n    const context = useMemo(() => ({ marker: !nested && !native ? 'counter' : 'native', nested, inItem: false }) as const, [nested, native]);\n    let markers = '';\n    if (nested) markers = 'list-[lower-latin]';\n    else if (native) markers = 'list-decimal';\n    return (\n        <ol {...rest} className={cn(listClasses(nested, isExpressive), markers, !nested && '[counter-reset:item]', className)}>\n            <ListContext.Provider value={context}>{children}</ListContext.Provider>\n        </ol>\n    );\n}\n\n/** Carbon `ListItem`: one item of an `UnorderedList` / `OrderedList` (text-primary); put a list inside it to nest. */\nexport function ListItem({ className, children, ...rest }: Readonly<ComponentProps<'li'>>) {\n    const { marker, nested } = useContext(ListContext);\n    const context = useMemo(() => ({ marker, nested, inItem: true }), [marker, nested]);\n    return (\n        <li {...rest} className={cn('relative text-ink', nested && 'ps-1', MARKERS[marker], className)}>\n            <ListContext.Provider value={context}>{children}</ListContext.Provider>\n        </li>\n    );\n}\n"
    }
  ]
}
