@dxos/react-list 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,134 @@
1
- # DXOS `react-list` primitive
1
+ # `@dxos/react-list` — elemental list primitive
2
+
3
+ ARIA-only foundation for DXOS list components. Renders semantically-correct
4
+ `<ol>` / `<ul>` markup; when `selectable` is set, becomes a
5
+ `role="listbox"` with `role="option"` children that carry `aria-selected`.
6
+
7
+ This package applies **no** styling, **no** keyboard navigation, and **no**
8
+ `dx-*` utility classes. Those live above:
9
+
10
+ ```text
11
+ ┌────────────────────────────────────────────────────────────┐
12
+ │ @dxos/react-ui-mosaic virtualization, DnD, cards/board │
13
+ ├────────────────────────────────────────────────────────────┤
14
+ │ @dxos/react-ui-list dx-* styling, keyboard nav, │
15
+ │ RowList / CardList containers │
16
+ ├────────────────────────────────────────────────────────────┤
17
+ │ @dxos/react-list ARIA + structure only ← this pkg │
18
+ └────────────────────────────────────────────────────────────┘
19
+ ```
20
+
21
+ Most app code should reach for `@dxos/react-ui-list`. Use this primitive
22
+ directly only when building a new selectable surface that needs full
23
+ control over styling and keyboard handling — e.g. a custom Combobox.
24
+
25
+ ## Components
26
+
27
+ | Component | Renders |
28
+ | ------------------------------ | ---------------------------------------------------- |
29
+ | `List` | `<ol>` / `<ul>`; optionally `role="listbox"` |
30
+ | `ListItem` | `<li>`; optionally `role="option"` + `aria-selected` |
31
+ | `ListItemHeading` | `<div>` with `id` linked via `aria-labelledby` |
32
+ | `ListItemOpenTrigger` | Radix `Collapsible.Trigger` |
33
+ | `ListItemCollapsibleContent` | Radix `Collapsible.Content` |
34
+
35
+ `ListItem` accepts `selected`, `defaultSelected`, `open`, `defaultOpen`,
36
+ and `collapsible` props; selection / open state can be controlled or
37
+ uncontrolled (uses `useControllableState`).
38
+
39
+ ## Quick start
40
+
41
+ ### Static unordered list (no selection)
42
+
43
+ ```tsx
44
+ import { List, ListItem, ListItemHeading } from '@dxos/react-list';
45
+
46
+ <List variant='unordered'>
47
+ <ListItem>
48
+ <ListItemHeading>Coffee</ListItemHeading>
49
+ </ListItem>
50
+ <ListItem>
51
+ <ListItemHeading>Tea</ListItemHeading>
52
+ </ListItem>
53
+ </List>;
54
+ ```
55
+
56
+ ### Single-select listbox
57
+
58
+ ```tsx
59
+ import { useState } from 'react';
60
+ import { List, ListItem, ListItemHeading } from '@dxos/react-list';
61
+
62
+ const Picker = ({ items }: { items: { id: string; label: string }[] }) => {
63
+ const [selected, setSelected] = useState<string | undefined>(items[0]?.id);
64
+ return (
65
+ <List variant='unordered' selectable aria-label='Items'>
66
+ {items.map((item) => (
67
+ <ListItem
68
+ key={item.id}
69
+ selected={item.id === selected}
70
+ onClick={() => setSelected(item.id)}
71
+ // Pair `aria-selected` (set by the primitive when `selectable`)
72
+ // with `dx-selected` from `@dxos/ui-theme` to get the canonical
73
+ // selected-row visual treatment. See
74
+ // ui-theme/src/css/components/selected.md.
75
+ className='dx-hover dx-selected'
76
+ >
77
+ <ListItemHeading>{item.label}</ListItemHeading>
78
+ </ListItem>
79
+ ))}
80
+ </List>
81
+ );
82
+ };
83
+ ```
84
+
85
+ ### Multi-select listbox
86
+
87
+ ```tsx
88
+ <List variant='unordered' selectable multiSelectable aria-label='Tags'>
89
+
90
+ </List>;
91
+ ```
92
+
93
+ `multiSelectable` adds `aria-multiselectable="true"`; without it the
94
+ listbox is single-select (the default; `aria-multiselectable` is
95
+ intentionally omitted to keep assistive-tech announcements concise).
96
+
97
+ ### Collapsible item
98
+
99
+ ```tsx
100
+ import {
101
+ List,
102
+ ListItem,
103
+ ListItemHeading,
104
+ ListItemOpenTrigger,
105
+ ListItemCollapsibleContent,
106
+ } from '@dxos/react-list';
107
+
108
+ <List variant='unordered'>
109
+ <ListItem collapsible defaultOpen>
110
+ <ListItemOpenTrigger asChild>
111
+ <ListItemHeading>Section A</ListItemHeading>
112
+ </ListItemOpenTrigger>
113
+ <ListItemCollapsibleContent>
114
+ …content…
115
+ </ListItemCollapsibleContent>
116
+ </ListItem>
117
+ </List>;
118
+ ```
119
+
120
+ ## What this primitive does NOT provide
121
+
122
+ - **Keyboard navigation** — wire your own (or use `@dxos/react-ui-list`'s
123
+ `RowList`, which integrates `@fluentui/react-tabster`).
124
+ - **Styling** — pair with `dx-hover` / `dx-selected` / `dx-current` from
125
+ `@dxos/ui-theme` per the grammar in
126
+ `ui-theme/src/css/components/selected.md`.
127
+ - **Virtualization or drag-and-drop** — see `@dxos/react-ui-mosaic`.
128
+
129
+ ## Related
130
+
131
+ - [`@dxos/react-ui-list`](../../react-ui-list) — the styled / opinionated layer.
132
+ - [`@dxos/react-ui-mosaic`](../../react-ui-mosaic) — virtualized / draggable.
133
+ - [`packages/ui/react-ui-list/AUDIT.md`](../../react-ui-list/AUDIT.md) —
134
+ rationale for the layering.
@@ -6,12 +6,14 @@ var LIST_NAME = "List";
6
6
  var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
7
7
  var [ListProvider, useListContext] = createListContext(LIST_NAME);
8
8
  var List = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
9
- const { __listScope, variant = "ordered", selectable = false, itemSizes, children, ...rootProps } = props;
9
+ const { __listScope, variant = "ordered", selectable = false, multiSelectable = false, itemSizes, children, ...rootProps } = props;
10
10
  const ListRoot = variant === "ordered" ? Primitive.ol : Primitive.ul;
11
11
  return /* @__PURE__ */ React.createElement(ListRoot, {
12
12
  ...selectable && {
13
13
  role: "listbox",
14
- "aria-multiselectable": true
14
+ ...multiSelectable && {
15
+ "aria-multiselectable": true
16
+ }
15
17
  },
16
18
  ...rootProps,
17
19
  ref: forwardedRef
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/List.tsx", "../../../src/ListItem.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\n// TODO(thure): A lot of the accessible affordances for this kind of thing need to be implemented per https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\nconst LIST_NAME = 'List';\n\ntype ListScopedProps<P> = P & { __listScope?: Scope };\n\ntype ListVariant = 'ordered' | 'unordered';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype ListProps = ComponentPropsWithRef<typeof Primitive.ol> & {\n selectable?: boolean;\n variant?: ListVariant;\n itemSizes?: ListItemSizes;\n};\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = {\n selectable: Exclude<ListProps['selectable'], undefined>;\n variant: Exclude<ListProps['variant'], undefined>;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const { __listScope, variant = 'ordered', selectable = false, itemSizes, children, ...rootProps } = props;\n const ListRoot = variant === 'ordered' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot {...(selectable && { role: 'listbox', 'aria-multiselectable': true })} {...rootProps} ref={forwardedRef}>\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n itemSizes,\n }}\n >\n {children}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME };\n\nexport type { ListProps, ListVariant, ListScopedProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type Dispatch,\n type ElementRef,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type SetStateAction,\n forwardRef,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, type ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n labelId?: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & RefAttributes<HTMLLIElement> &\n ComponentPropsWithoutRef<'li'> & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = ElementRef<'li'>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n};\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> &\n RefAttributes<HTMLParagraphElement> & {\n asChild?: boolean;\n };\n\nconst ListItemHeading = forwardRef<HTMLDivElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Comp = asChild ? Slot : Primitive.div;\n return (\n <Comp {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;\n\nconst ListItemOpenTrigger = Collapsible.Trigger;\n\ntype ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;\n\nconst ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps> = Collapsible.Content;\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps>>, forwardedRef) => {\n const id = useId('listItem', props.id);\n\n const {\n __listScope,\n __listItemScope,\n children,\n selected: propsSelected,\n defaultSelected,\n onSelectedChange,\n open: propsOpen,\n defaultOpen,\n onOpenChange,\n collapsible,\n labelId,\n ...listItemProps\n } = props;\n const { selectable } = useListContext(LIST_NAME, __listScope);\n\n const [selected = false, setSelected] = useControllableState({\n prop: propsSelected,\n defaultProp: defaultSelected,\n onChange: onSelectedChange,\n });\n\n const [open = false, setOpen] = useControllableState({\n prop: propsOpen,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const headingId = useId('listItem__heading', labelId);\n\n const listItem = (\n <Primitive.li\n {...listItemProps}\n id={id}\n ref={forwardedRef}\n aria-labelledby={headingId}\n {...(selectable && { role: 'option', 'aria-selected': !!selected })}\n {...(open && { 'aria-expanded': true })}\n >\n {children}\n </Primitive.li>\n );\n\n return (\n <ListItemProvider\n scope={__listItemScope}\n headingId={headingId}\n open={open}\n selected={selected}\n setSelected={setSelected}\n >\n {collapsible ? (\n <Collapsible.Root asChild open={open} onOpenChange={setOpen}>\n {listItem}\n </Collapsible.Root>\n ) : (\n listItem\n )}\n </ListItemProvider>\n );\n },\n);\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
5
- "mappings": ";AAIA,SAAqBA,0BAA0B;AAC/C,SAASC,iBAAiB;AAC1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,KAAKR;KAClCJ,QAAAA;AAGP,CAAA;AAKF,IAAMa,sBAAkCC;AAIxC,IAAMC,6BAA6FC;AAEnG,IAAMC,WAAWlB,gBAAAA,YACf,CAACI,OAA4DC,iBAAAA;AAC3D,QAAMO,KAAKO,MAAM,YAAYf,MAAMQ,EAAE;AAErC,QAAM,EACJQ,aACAjB,iBACAF,UACAoB,UAAUC,eACVC,iBACAC,kBACAC,MAAMC,WACNC,aACAC,cACAC,aACAC,SACA,GAAGC,cAAAA,IACD3B;AACJ,QAAM,EAAE4B,WAAU,IAAKC,eAAeC,WAAWd,WAAAA;AAEjD,QAAM,CAACC,WAAW,OAAOc,WAAAA,IAAeC,qBAAqB;IAC3DC,MAAMf;IACNgB,aAAaf;IACbgB,UAAUf;EACZ,CAAA;AAEA,QAAM,CAACC,OAAO,OAAOe,OAAAA,IAAWJ,qBAAqB;IACnDC,MAAMX;IACNY,aAAaX;IACbY,UAAUX;EACZ,CAAA;AAEA,QAAMtB,YAAYa,MAAM,qBAAqBW,OAAAA;AAE7C,QAAMW,WACJ,gBAAA9B,OAAA,cAACF,WAAUiC,IAAE;IACV,GAAGX;IACJnB;IACAC,KAAKR;IACLsC,mBAAiBrC;IAChB,GAAI0B,cAAc;MAAEY,MAAM;MAAU,iBAAiB,CAAC,CAACvB;IAAS;IAChE,GAAII,QAAQ;MAAE,iBAAiB;IAAK;KAEpCxB,QAAAA;AAIL,SACE,gBAAAU,OAAA,cAACd,kBAAAA;IACCgD,OAAO1C;IACPG;IACAmB;IACAJ;IACAc;KAECN,cACC,gBAAAlB,OAAA,cAAamC,kBAAI;IAAC5C,SAAAA;IAAQuB;IAAYG,cAAcY;KACjDC,QAAAA,IAGHA,QAAAA;AAIR,CAAA;AAGFvB,SAAS6B,cAActD;",
6
- "names": ["createContextScope", "Primitive", "React", "forwardRef", "LIST_NAME", "createListContext", "createListScope", "createContextScope", "ListProvider", "useListContext", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "role", "ref", "scope", "displayName", "Collapsible", "createContextScope", "Primitive", "Slot", "useControllableState", "React", "forwardRef", "useId", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Comp", "Slot", "Primitive", "div", "React", "id", "ref", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "ListItem", "useId", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "labelId", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "listItem", "li", "aria-labelledby", "role", "scope", "Root", "displayName"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// Elemental list / listbox primitive.\n//\n// This is the ARIA-only foundation of the DXOS list stack. It renders a\n// semantically-correct `<ol>` / `<ul>` (or, when `selectable={true}`, a\n// `role=\"listbox\"` element with `role=\"option\"` children carrying\n// `aria-selected`). It applies no styling, no keyboard navigation, and\n// no `dx-*` utility classes — those are layered above in\n// `@dxos/react-ui-list`.\n//\n// Layering:\n// - `@dxos/react-list` — this package; ARIA + structure only.\n// - `@dxos/react-ui-list` — adds `dx-*` styling, keyboard nav, and\n// opinionated `RowList`/`CardList` containers.\n// - `@dxos/react-ui-mosaic` — virtualized / draggable / card-board\n// layouts; composes the above where useful.\n//\n// Most app code should reach for `@dxos/react-ui-list`. Use this primitive\n// directly only when building a *new* selectable surface that needs full\n// control over styling and keyboard handling (e.g. a custom Combobox).\n//\n// See:\n// - `packages/ui/ui-theme/src/css/components/selected.md` for the\n// `aria-selected` `dx-selected` pairing rules.\n// - `packages/ui/react-ui-list/AUDIT.md` for why this layering exists.\n// - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nconst LIST_NAME = 'List';\n\ntype ListScopedProps<P> = P & { __listScope?: Scope };\n\ntype ListVariant = 'ordered' | 'unordered';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype ListProps = ComponentPropsWithRef<typeof Primitive.ol> & {\n /**\n * If true, render as `role=\"listbox\"` and let `ListItem` children become\n * `role=\"option\"` + `aria-selected`. If false (default) the list is a\n * plain `<ol>` / `<ul>` with no selection semantics — pick this for\n * static lists.\n */\n selectable?: boolean;\n /**\n * If true, the listbox advertises multi-select via\n * `aria-multiselectable=\"true\"`. Defaults to false (single-select).\n * Has no effect unless `selectable` is also true.\n */\n multiSelectable?: boolean;\n variant?: ListVariant;\n itemSizes?: ListItemSizes;\n};\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = {\n selectable: Exclude<ListProps['selectable'], undefined>;\n variant: Exclude<ListProps['variant'], undefined>;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const {\n __listScope,\n variant = 'ordered',\n selectable = false,\n multiSelectable = false,\n itemSizes,\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot\n // `aria-multiselectable` is only meaningful on `role=\"listbox\"`,\n // and even there is omitted in the single-select default to keep\n // assistive tech announcements concise.\n {...(selectable && {\n role: 'listbox',\n ...(multiSelectable && { 'aria-multiselectable': true as const }),\n })}\n {...rootProps}\n ref={forwardedRef}\n >\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n itemSizes,\n }}\n >\n {children}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME };\n\nexport type { ListProps, ListVariant, ListScopedProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type Dispatch,\n type ComponentRef,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type SetStateAction,\n forwardRef,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, type ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n labelId?: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & RefAttributes<HTMLLIElement> &\n ComponentPropsWithoutRef<'li'> & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = ComponentRef<'li'>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n};\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> &\n RefAttributes<HTMLParagraphElement> & {\n asChild?: boolean;\n };\n\nconst ListItemHeading = forwardRef<HTMLDivElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Comp = asChild ? Slot : Primitive.div;\n return (\n <Comp {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;\n\nconst ListItemOpenTrigger = Collapsible.Trigger;\n\ntype ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;\n\nconst ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps> = Collapsible.Content;\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps>>, forwardedRef) => {\n const id = useId('listItem', props.id);\n\n const {\n __listScope,\n __listItemScope,\n children,\n selected: propsSelected,\n defaultSelected,\n onSelectedChange,\n open: propsOpen,\n defaultOpen,\n onOpenChange,\n collapsible,\n labelId,\n ...listItemProps\n } = props;\n const { selectable } = useListContext(LIST_NAME, __listScope);\n\n const [selected = false, setSelected] = useControllableState({\n prop: propsSelected,\n defaultProp: defaultSelected,\n onChange: onSelectedChange,\n });\n\n const [open = false, setOpen] = useControllableState({\n prop: propsOpen,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const headingId = useId('listItem__heading', labelId);\n\n const listItem = (\n <Primitive.li\n {...listItemProps}\n id={id}\n ref={forwardedRef}\n aria-labelledby={headingId}\n {...(selectable && { role: 'option', 'aria-selected': !!selected })}\n {...(open && { 'aria-expanded': true })}\n >\n {children}\n </Primitive.li>\n );\n\n return (\n <ListItemProvider\n scope={__listItemScope}\n headingId={headingId}\n open={open}\n selected={selected}\n setSelected={setSelected}\n >\n {collapsible ? (\n <Collapsible.Root asChild open={open} onOpenChange={setOpen}>\n {listItem}\n </Collapsible.Root>\n ) : (\n listItem\n )}\n </ListItemProvider>\n );\n },\n);\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
5
+ "mappings": ";AA8BA,SAAqBA,0BAA0B;AAC/C,SAASC,iBAAiB;AAC1B,OAAOC,SAAqCC,kBAAkB;AAE9D,IAAMC,YAAY;AA0BlB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBN,mBAAmBI,WAAW,CAAA,CAAE;AAQ7E,IAAM,CAACG,cAAcC,cAAAA,IAAkBH,kBAAoCD,SAAAA;AAE3E,IAAMK,OAAON,2BAAwC,CAACO,OAAmCC,iBAAAA;AACvF,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,kBAAkB,OAClBC,WACAC,UACA,GAAGC,UAAAA,IACDR;AACJ,QAAMS,WAAWN,YAAY,YAAYZ,UAAUmB,KAAKnB,UAAUoB;AAClE,SACE,sBAAA,cAACF,UAAAA;IAIE,GAAIL,cAAc;MACjBQ,MAAM;MACN,GAAIP,mBAAmB;QAAE,wBAAwB;MAAc;IACjE;IACC,GAAGG;IACJK,KAAKZ;KAEL,sBAAA,cAACJ,cACK;IACFiB,OAAOZ;IACPC;IACAC;IACAE;EACF,GAECC,QAAAA,CAAAA;AAIT,CAAA;AAEAR,KAAKgB,cAAcrB;;;ACrGnB,YAAYsB,iBAAiB;AAC7B,SAAqBC,sBAAAA,2BAA0B;AAC/C,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,4BAA4B;AACrC,OAAOC,UAQLC,cAAAA,mBACK;AAEP,SAASC,aAAa;AAItB,IAAMC,iBAAiB;AAsBvB,IAAM,CAACC,uBAAuBC,mBAAAA,IAAuBC,oBAAmBH,g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IL,SACE,gBAAAU,OAAA,cAACd,kBAAAA;IACCgD,OAAO1C;IACPG;IACAmB;IACAJ;IACAc;KAECN,cACC,gBAAAlB,OAAA,cAAamC,kBAAI;IAAC5C,SAAAA;IAAQuB;IAAYG,cAAcY;KACjDC,QAAAA,IAGHA,QAAAA;AAIR,CAAA;AAGFvB,SAAS6B,cAActD;",
6
+ "names": ["createContextScope", "Primitive", "React", "forwardRef", "LIST_NAME", "createListContext", "createListScope", "ListProvider", "useListContext", "List", "props", "forwardedRef", "__listScope", "variant", "selectable", "multiSelectable", "itemSizes", "children", "rootProps", "ListRoot", "ol", "ul", "role", "ref", "scope", "displayName", "Collapsible", "createContextScope", "Primitive", "Slot", "useControllableState", "React", "forwardRef", "useId", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Comp", "Slot", "Primitive", "div", "React", "id", "ref", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "ListItem", "useId", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "labelId", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "listItem", "li", "aria-labelledby", "role", "scope", "Root", "displayName"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/List.tsx":{"bytes":5385,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/ListItem.tsx":{"bytes":13012,"imports":[{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"src/List.tsx","kind":"import-statement","original":"./List"}],"format":"esm"},"src/index.ts":{"bytes":546,"imports":[{"path":"src/List.tsx","kind":"import-statement","original":"./List"},{"path":"src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10282},"dist/lib/browser/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true}],"exports":["LIST_ITEM_NAME","LIST_NAME","List","ListItem","ListItemCollapsibleContent","ListItemHeading","ListItemOpenTrigger","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"src/index.ts","inputs":{"src/List.tsx":{"bytesInOutput":935},"src/index.ts":{"bytesInOutput":0},"src/ListItem.tsx":{"bytesInOutput":2528}},"bytes":3751}}}
1
+ {"inputs":{"src/List.tsx":{"bytes":9674,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/ListItem.tsx":{"bytes":12922,"imports":[{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"src/List.tsx","kind":"import-statement","original":"./List"}],"format":"esm"},"src/index.ts":{"bytes":456,"imports":[{"path":"src/List.tsx","kind":"import-statement","original":"./List"},{"path":"src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}],"format":"esm"}},"outputs":{"dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12305},"dist/lib/browser/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true}],"exports":["LIST_ITEM_NAME","LIST_NAME","List","ListItem","ListItemCollapsibleContent","ListItemHeading","ListItemOpenTrigger","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"src/index.ts","inputs":{"src/List.tsx":{"bytesInOutput":1000},"src/index.ts":{"bytesInOutput":0},"src/ListItem.tsx":{"bytesInOutput":2528}},"bytes":3816}}}
@@ -8,12 +8,14 @@ var LIST_NAME = "List";
8
8
  var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
9
9
  var [ListProvider, useListContext] = createListContext(LIST_NAME);
10
10
  var List = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
11
- const { __listScope, variant = "ordered", selectable = false, itemSizes, children, ...rootProps } = props;
11
+ const { __listScope, variant = "ordered", selectable = false, multiSelectable = false, itemSizes, children, ...rootProps } = props;
12
12
  const ListRoot = variant === "ordered" ? Primitive.ol : Primitive.ul;
13
13
  return /* @__PURE__ */ React.createElement(ListRoot, {
14
14
  ...selectable && {
15
15
  role: "listbox",
16
- "aria-multiselectable": true
16
+ ...multiSelectable && {
17
+ "aria-multiselectable": true
18
+ }
17
19
  },
18
20
  ...rootProps,
19
21
  ref: forwardedRef
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/List.tsx", "../../../src/ListItem.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\n// TODO(thure): A lot of the accessible affordances for this kind of thing need to be implemented per https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\nconst LIST_NAME = 'List';\n\ntype ListScopedProps<P> = P & { __listScope?: Scope };\n\ntype ListVariant = 'ordered' | 'unordered';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype ListProps = ComponentPropsWithRef<typeof Primitive.ol> & {\n selectable?: boolean;\n variant?: ListVariant;\n itemSizes?: ListItemSizes;\n};\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = {\n selectable: Exclude<ListProps['selectable'], undefined>;\n variant: Exclude<ListProps['variant'], undefined>;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const { __listScope, variant = 'ordered', selectable = false, itemSizes, children, ...rootProps } = props;\n const ListRoot = variant === 'ordered' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot {...(selectable && { role: 'listbox', 'aria-multiselectable': true })} {...rootProps} ref={forwardedRef}>\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n itemSizes,\n }}\n >\n {children}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME };\n\nexport type { ListProps, ListVariant, ListScopedProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type Dispatch,\n type ElementRef,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type SetStateAction,\n forwardRef,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, type ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n labelId?: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & RefAttributes<HTMLLIElement> &\n ComponentPropsWithoutRef<'li'> & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = ElementRef<'li'>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n};\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> &\n RefAttributes<HTMLParagraphElement> & {\n asChild?: boolean;\n };\n\nconst ListItemHeading = forwardRef<HTMLDivElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Comp = asChild ? Slot : Primitive.div;\n return (\n <Comp {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;\n\nconst ListItemOpenTrigger = Collapsible.Trigger;\n\ntype ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;\n\nconst ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps> = Collapsible.Content;\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps>>, forwardedRef) => {\n const id = useId('listItem', props.id);\n\n const {\n __listScope,\n __listItemScope,\n children,\n selected: propsSelected,\n defaultSelected,\n onSelectedChange,\n open: propsOpen,\n defaultOpen,\n onOpenChange,\n collapsible,\n labelId,\n ...listItemProps\n } = props;\n const { selectable } = useListContext(LIST_NAME, __listScope);\n\n const [selected = false, setSelected] = useControllableState({\n prop: propsSelected,\n defaultProp: defaultSelected,\n onChange: onSelectedChange,\n });\n\n const [open = false, setOpen] = useControllableState({\n prop: propsOpen,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const headingId = useId('listItem__heading', labelId);\n\n const listItem = (\n <Primitive.li\n {...listItemProps}\n id={id}\n ref={forwardedRef}\n aria-labelledby={headingId}\n {...(selectable && { role: 'option', 'aria-selected': !!selected })}\n {...(open && { 'aria-expanded': true })}\n >\n {children}\n </Primitive.li>\n );\n\n return (\n <ListItemProvider\n scope={__listItemScope}\n headingId={headingId}\n open={open}\n selected={selected}\n setSelected={setSelected}\n >\n {collapsible ? (\n <Collapsible.Root asChild open={open} onOpenChange={setOpen}>\n {listItem}\n </Collapsible.Root>\n ) : (\n listItem\n )}\n </ListItemProvider>\n );\n },\n);\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
5
- "mappings": ";;;AAIA,SAAqBA,0BAA0B;AAC/C,SAASC,iBAAiB;AAC1B,OAAOC,SAAqCC,kBAAkB;AAI9D,IAAMC,YAAY;AAclB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBC,mBAAmBH,WAAW,CAAA,CAAE;AAQ7E,IAAM,CAACI,cAAcC,cAAAA,IAAkBJ,kBAAoCD,SAAAA;AAE3E,IAAMM,OAAOC,2BAAwC,CAACC,OAAmCC,iBAAAA;AACvF,QAAM,EAAEC,aAAaC,UAAU,WAAWC,aAAa,OAAOC,WAAWC,UAAU,GAAGC,UAAAA,IAAcP;AACpG,QAAMQ,WAAWL,YAAY,YAAYM,UAAUC,KAAKD,UAAUE;AAClE,SACE,sBAAA,cAACH,UAAAA;IAAU,GAAIJ,cAAc;MAAEQ,MAAM;MAAW,wBAAwB;IAAK;IAAK,GAAGL;IAAWM,KAAKZ;KACnG,sBAAA,cAACL,cACK;IACFkB,OAAOZ;IACPC;IACAC;IACAC;EACF,GAECC,QAAAA,CAAAA;AAIT,CAAA;AAEAR,KAAKiB,cAAcvB;;;AC/CnB,YAAYwB,iBAAiB;AAC7B,SAAqBC,sBAAAA,2BAA0B;AAC/C,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,YAAY;AACrB,SAASC,4BAA4B;AACrC,OAAOC,UAQLC,cAAAA,mBACK;AAEP,SAASC,aAAa;AAItB,IAAMC,iBAAiB;AAsBvB,IAAM,CAACC,uBAAuBC,mBAAAA,IAAu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CxB,QAAAA;AAIL,SACE,gBAAAU,OAAA,cAACd,kBAAAA;IACCgD,OAAO1C;IACPG;IACAmB;IACAJ;IACAc;KAECN,cACC,gBAAAlB,OAAA,cAAamC,kBAAI;IAAC5C,SAAAA;IAAQuB;IAAYG,cAAcY;KACjDC,QAAAA,IAGHA,QAAAA;AAIR,CAAA;AAGFvB,SAAS6B,cAActD;",
6
- "names": ["createContextScope", "Primitive", "React", "forwardRef", "LIST_NAME", "createListContext", "createListScope", "createContextScope", "ListProvider", "useListContext", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "role", "ref", "scope", "displayName", "Collapsible", "createContextScope", "Primitive", "Slot", "useControllableState", "React", "forwardRef", "useId", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Comp", "Slot", "Primitive", "div", "React", "id", "ref", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "ListItem", "useId", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "labelId", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "listItem", "li", "aria-labelledby", "role", "scope", "Root", "displayName"]
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\n// Elemental list / listbox primitive.\n//\n// This is the ARIA-only foundation of the DXOS list stack. It renders a\n// semantically-correct `<ol>` / `<ul>` (or, when `selectable={true}`, a\n// `role=\"listbox\"` element with `role=\"option\"` children carrying\n// `aria-selected`). It applies no styling, no keyboard navigation, and\n// no `dx-*` utility classes — those are layered above in\n// `@dxos/react-ui-list`.\n//\n// Layering:\n// - `@dxos/react-list` — this package; ARIA + structure only.\n// - `@dxos/react-ui-list` — adds `dx-*` styling, keyboard nav, and\n// opinionated `RowList`/`CardList` containers.\n// - `@dxos/react-ui-mosaic` — virtualized / draggable / card-board\n// layouts; composes the above where useful.\n//\n// Most app code should reach for `@dxos/react-ui-list`. Use this primitive\n// directly only when building a *new* selectable surface that needs full\n// control over styling and keyboard handling (e.g. a custom Combobox).\n//\n// See:\n// - `packages/ui/ui-theme/src/css/components/selected.md` for the\n// `aria-selected` `dx-selected` pairing rules.\n// - `packages/ui/react-ui-list/AUDIT.md` for why this layering exists.\n// - https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { type ComponentPropsWithRef, forwardRef } from 'react';\n\nconst LIST_NAME = 'List';\n\ntype ListScopedProps<P> = P & { __listScope?: Scope };\n\ntype ListVariant = 'ordered' | 'unordered';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype ListProps = ComponentPropsWithRef<typeof Primitive.ol> & {\n /**\n * If true, render as `role=\"listbox\"` and let `ListItem` children become\n * `role=\"option\"` + `aria-selected`. If false (default) the list is a\n * plain `<ol>` / `<ul>` with no selection semantics — pick this for\n * static lists.\n */\n selectable?: boolean;\n /**\n * If true, the listbox advertises multi-select via\n * `aria-multiselectable=\"true\"`. Defaults to false (single-select).\n * Has no effect unless `selectable` is also true.\n */\n multiSelectable?: boolean;\n variant?: ListVariant;\n itemSizes?: ListItemSizes;\n};\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = {\n selectable: Exclude<ListProps['selectable'], undefined>;\n variant: Exclude<ListProps['variant'], undefined>;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const {\n __listScope,\n variant = 'ordered',\n selectable = false,\n multiSelectable = false,\n itemSizes,\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot\n // `aria-multiselectable` is only meaningful on `role=\"listbox\"`,\n // and even there is omitted in the single-select default to keep\n // assistive tech announcements concise.\n {...(selectable && {\n role: 'listbox',\n ...(multiSelectable && { 'aria-multiselectable': true as const }),\n })}\n {...rootProps}\n ref={forwardedRef}\n >\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n itemSizes,\n }}\n >\n {children}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME };\n\nexport type { ListProps, ListVariant, ListScopedProps };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport { Slot } from '@radix-ui/react-slot';\nimport { useControllableState } from '@radix-ui/react-use-controllable-state';\nimport React, {\n type ComponentProps,\n type ComponentPropsWithoutRef,\n type Dispatch,\n type ComponentRef,\n type ForwardRefExoticComponent,\n type RefAttributes,\n type SetStateAction,\n forwardRef,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, type ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n labelId?: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & RefAttributes<HTMLLIElement> &\n ComponentPropsWithoutRef<'li'> & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = ComponentRef<'li'>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n};\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> &\n RefAttributes<HTMLParagraphElement> & {\n asChild?: boolean;\n };\n\nconst ListItemHeading = forwardRef<HTMLDivElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Comp = asChild ? Slot : Primitive.div;\n return (\n <Comp {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Comp>\n );\n },\n);\n\ntype ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;\n\nconst ListItemOpenTrigger = Collapsible.Trigger;\n\ntype ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;\n\nconst ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps> = Collapsible.Content;\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps>>, forwardedRef) => {\n const id = useId('listItem', props.id);\n\n const {\n __listScope,\n __listItemScope,\n children,\n selected: propsSelected,\n defaultSelected,\n onSelectedChange,\n open: propsOpen,\n defaultOpen,\n onOpenChange,\n collapsible,\n labelId,\n ...listItemProps\n } = props;\n const { selectable } = useListContext(LIST_NAME, __listScope);\n\n const [selected = false, setSelected] = useControllableState({\n prop: propsSelected,\n defaultProp: defaultSelected,\n onChange: onSelectedChange,\n });\n\n const [open = false, setOpen] = useControllableState({\n prop: propsOpen,\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n });\n\n const headingId = useId('listItem__heading', labelId);\n\n const listItem = (\n <Primitive.li\n {...listItemProps}\n id={id}\n ref={forwardedRef}\n aria-labelledby={headingId}\n {...(selectable && { role: 'option', 'aria-selected': !!selected })}\n {...(open && { 'aria-expanded': true })}\n >\n {children}\n </Primitive.li>\n );\n\n return (\n <ListItemProvider\n scope={__listItemScope}\n headingId={headingId}\n open={open}\n selected={selected}\n setSelected={setSelected}\n >\n {collapsible ? (\n <Collapsible.Root asChild open={open} onOpenChange={setOpen}>\n {listItem}\n </Collapsible.Root>\n ) : (\n listItem\n )}\n </ListItemProvider>\n );\n },\n);\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
5
+ "mappings": ";;;AA8BA,SAAqBA,0BAA0B;AAC/C,SAASC,iBAAiB;AAC1B,OAAOC,SAAqCC,kBAAkB;AAE9D,IAAMC,YAAY;AA0BlB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBN,mBAAmBI,WAAW,CAAA,CAAE;AAQ7E,IAAM,CAACG,cAAcC,cAAAA,IAAkBH,kBAAoCD,SAAAA;AAE3E,IAAMK,OAAON,2BAAwC,CAACO,OAAmCC,iBAAAA;AACvF,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,kBAAkB,OAClBC,WACAC,UACA,GAAGC,UAAAA,IACDR;AACJ,QAAMS,WAAWN,YAAY,YAAYZ,UAAUmB,KAAKnB,UAAUoB;AAClE,SACE,sBAAA,cAACF,UAAAA;IAIE,GAAIL,cAAc;MACjBQ,MAAM;MACN,GAAIP,mBAAmB;QAAE,wBAAwB;MAAc;IACjE;IACC,GAAGG;IACJK,KAAKZ;KA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AM,CAACC,OAAO,OAAOe,OAAAA,IAAWJ,qBAAqB;IACnDC,MAAMX;IACNY,aAAaX;IACbY,UAAUX;EACZ,CAAA;AAEA,QAAMtB,YAAYa,MAAM,qBAAqBW,OAAAA;AAE7C,QAAMW,WACJ,gBAAA9B,OAAA,cAACF,WAAUiC,IAAE;IACV,GAAGX;IACJnB;IACAC,KAAKR;IACLsC,mBAAiBrC;IAChB,GAAI0B,cAAc;MAAEY,MAAM;MAAU,iBAAiB,CAAC,CAACvB;IAAS;IAChE,GAAII,QAAQ;MAAE,iBAAiB;IAAK;KAEpCxB,QAAAA;AAIL,SACE,gBAAAU,OAAA,cAACd,kBAAAA;IACCgD,OAAO1C;IACPG;IACAmB;IACAJ;IACAc;KAECN,cACC,gBAAAlB,OAAA,cAAamC,kBAAI;IAAC5C,SAAAA;IAAQuB;IAAYG,cAAcY;KACjDC,QAAAA,IAGHA,QAAAA;AAIR,CAAA;AAGFvB,SAAS6B,cAActD;",
6
+ "names": ["createContextScope", "Primitive", "React", "forwardRef", "LIST_NAME", "createListContext", "createListScope", "ListProvider", "useListContext", "List", "props", "forwardedRef", "__listScope", "variant", "selectable", "multiSelectable", "itemSizes", "children", "rootProps", "ListRoot", "ol", "ul", "role", "ref", "scope", "displayName", "Collapsible", "createContextScope", "Primitive", "Slot", "useControllableState", "React", "forwardRef", "useId", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Comp", "Slot", "Primitive", "div", "React", "id", "ref", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "ListItem", "useId", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "labelId", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "listItem", "li", "aria-labelledby", "role", "scope", "Root", "displayName"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"src/List.tsx":{"bytes":5385,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/ListItem.tsx":{"bytes":13012,"imports":[{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"src/List.tsx","kind":"import-statement","original":"./List"}],"format":"esm"},"src/index.ts":{"bytes":546,"imports":[{"path":"src/List.tsx","kind":"import-statement","original":"./List"},{"path":"src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":10284},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true}],"exports":["LIST_ITEM_NAME","LIST_NAME","List","ListItem","ListItemCollapsibleContent","ListItemHeading","ListItemOpenTrigger","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"src/index.ts","inputs":{"src/List.tsx":{"bytesInOutput":935},"src/index.ts":{"bytesInOutput":0},"src/ListItem.tsx":{"bytesInOutput":2528}},"bytes":3844}}}
1
+ {"inputs":{"src/List.tsx":{"bytes":9674,"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}],"format":"esm"},"src/ListItem.tsx":{"bytes":12922,"imports":[{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true},{"path":"src/List.tsx","kind":"import-statement","original":"./List"}],"format":"esm"},"src/index.ts":{"bytes":456,"imports":[{"path":"src/List.tsx","kind":"import-statement","original":"./List"},{"path":"src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}],"format":"esm"}},"outputs":{"dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12307},"dist/lib/node-esm/index.mjs":{"imports":[{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"@radix-ui/react-primitive","kind":"import-statement","external":true},{"path":"@radix-ui/react-slot","kind":"import-statement","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-hooks","kind":"import-statement","external":true}],"exports":["LIST_ITEM_NAME","LIST_NAME","List","ListItem","ListItemCollapsibleContent","ListItemHeading","ListItemOpenTrigger","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"src/index.ts","inputs":{"src/List.tsx":{"bytesInOutput":1000},"src/index.ts":{"bytesInOutput":0},"src/ListItem.tsx":{"bytesInOutput":2528}},"bytes":3909}}}
@@ -8,7 +8,19 @@ type ListScopedProps<P> = P & {
8
8
  type ListVariant = 'ordered' | 'unordered';
9
9
  type ListItemSizes = 'one' | 'many';
10
10
  type ListProps = ComponentPropsWithRef<typeof Primitive.ol> & {
11
+ /**
12
+ * If true, render as `role="listbox"` and let `ListItem` children become
13
+ * `role="option"` + `aria-selected`. If false (default) the list is a
14
+ * plain `<ol>` / `<ul>` with no selection semantics — pick this for
15
+ * static lists.
16
+ */
11
17
  selectable?: boolean;
18
+ /**
19
+ * If true, the listbox advertises multi-select via
20
+ * `aria-multiselectable="true"`. Defaults to false (single-select).
21
+ * Has no effect unless `selectable` is also true.
22
+ */
23
+ multiSelectable?: boolean;
12
24
  variant?: ListVariant;
13
25
  itemSizes?: ListItemSizes;
14
26
  };
@@ -1 +1 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,KAAK,qBAAqB,EAAc,MAAM,OAAO,CAAC;AAItE,QAAA,MAAM,SAAS,SAAS,CAAC;AAEzB,KAAK,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAEtD,KAAK,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAE3C,KAAK,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpC,KAAK,SAAS,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,EAAE,CAAC,GAAG;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,SAAS,CAAC,EAAE,aA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aAAa,CAAC;CAC3B,CAAC;AAEF,QAAA,MAA0B,eAAe,+CAAqC,CAAC;AAE/E,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC;IACxD,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,CAAC;IAClD,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAqB,cAAc,wFAAkD,CAAC;AAEtF,QAAA,MAAM,IAAI,iGAmCR,CAAC;AAIH,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAE5D,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Decorator, type StoryObj } from '@storybook/react-vite';
2
+ declare const meta: {
3
+ title: string;
4
+ decorators: Decorator[];
5
+ };
6
+ export default meta;
7
+ type Story = StoryObj<typeof meta>;
8
+ export declare const Static: Story;
9
+ export declare const SingleSelect: Story;
10
+ export declare const MultiSelect: Story;
11
+ export declare const Collapsible: Story;
12
+ //# sourceMappingURL=List.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.stories.d.ts","sourceRoot":"","sources":["../../../src/List.stories.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,SAAS,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AA+HjF,QAAA,MAAM,IAAI;;;CAGM,CAAC;eAEF,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,MAAM,EAAE,KAA+B,CAAC;AACrD,eAAO,MAAM,YAAY,EAAE,KAAqC,CAAC;AACjE,eAAO,MAAM,WAAW,EAAE,KAAoC,CAAC;AAC/D,eAAO,MAAM,WAAW,EAAE,KAAoC,CAAC"}
@@ -2,7 +2,7 @@ import type { CheckboxProps } from '@radix-ui/react-checkbox';
2
2
  import { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
3
3
  import * as Collapsible from '@radix-ui/react-collapsible';
4
4
  import { type Scope } from '@radix-ui/react-context';
5
- import React, { type ComponentProps, type ComponentPropsWithoutRef, type Dispatch, type ForwardRefExoticComponent, type RefAttributes, type SetStateAction } from 'react';
5
+ import { type ComponentProps, type ComponentPropsWithoutRef, type Dispatch, type ForwardRefExoticComponent, type RefAttributes, type SetStateAction } from 'react';
6
6
  declare const LIST_ITEM_NAME = "ListItem";
7
7
  type ListItemScopedProps<P> = P & {
8
8
  __listItemScope?: Scope;
@@ -33,12 +33,12 @@ declare const useListItemContext: (consumerName: string, scope: Scope<ListItemCo
33
33
  type ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> & RefAttributes<HTMLParagraphElement> & {
34
34
  asChild?: boolean;
35
35
  };
36
- declare const ListItemHeading: React.ForwardRefExoticComponent<Omit<ListItemHeadingProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
36
+ declare const ListItemHeading: ForwardRefExoticComponent<Omit<ListItemHeadingProps, "ref"> & RefAttributes<HTMLDivElement>>;
37
37
  type ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;
38
- declare const ListItemOpenTrigger: React.ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
38
+ declare const ListItemOpenTrigger: ForwardRefExoticComponent<CollapsibleTriggerProps & RefAttributes<HTMLButtonElement>>;
39
39
  type ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;
40
40
  declare const ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps>;
41
- declare const ListItem: React.ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
41
+ declare const ListItem: ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & RefAttributes<HTMLLIElement>>;
42
42
  export { ListItem, ListItemHeading, ListItemCollapsibleContent, ListItemOpenTrigger, createListItemScope, useListItemContext, LIST_ITEM_NAME, };
43
43
  export type { ListItemProps, ListItemHeadingProps, ListItemCollapsibleContentProps, ListItemOpenTriggerProps, ListItemScopedProps, };
44
44
  //# sourceMappingURL=ListItem.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACzG,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AAIzE,OAAO,KAAK,EAAE,EACZ,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EAEb,KAAK,yBAAyB,EAC9B,KAAK,aAAa,EAClB,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AAMf,QAAA,MAAM,cAAc,aAAa,CAAC;AAElC,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,eAAe,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9D,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,KAAK,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAAC,aAAa,CAAC,GACtG,wBAAwB,CAAC,IAAI,CAAC,GAAG;IAC/B,WA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