@dxos/react-list 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/dist/lib/browser/index.mjs +60 -77
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +60 -77
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/src/ListItem.tsx +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/List.tsx
|
|
2
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
3
2
|
import { createContextScope } from "@radix-ui/react-context";
|
|
4
3
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
5
4
|
import React, { forwardRef } from "react";
|
|
@@ -7,31 +6,25 @@ var LIST_NAME = "List";
|
|
|
7
6
|
var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
|
|
8
7
|
var [ListProvider, useListContext] = createListContext(LIST_NAME);
|
|
9
8
|
var List = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
itemSizes
|
|
26
|
-
}, children));
|
|
27
|
-
} finally {
|
|
28
|
-
_effect.f();
|
|
29
|
-
}
|
|
9
|
+
const { __listScope, variant = "ordered", selectable = false, itemSizes, children, ...rootProps } = props;
|
|
10
|
+
const ListRoot = variant === "ordered" ? Primitive.ol : Primitive.ul;
|
|
11
|
+
return /* @__PURE__ */ React.createElement(ListRoot, {
|
|
12
|
+
...selectable && {
|
|
13
|
+
role: "listbox",
|
|
14
|
+
"aria-multiselectable": true
|
|
15
|
+
},
|
|
16
|
+
...rootProps,
|
|
17
|
+
ref: forwardedRef
|
|
18
|
+
}, /* @__PURE__ */ React.createElement(ListProvider, {
|
|
19
|
+
scope: __listScope,
|
|
20
|
+
variant,
|
|
21
|
+
selectable,
|
|
22
|
+
itemSizes
|
|
23
|
+
}, children));
|
|
30
24
|
});
|
|
31
25
|
List.displayName = LIST_NAME;
|
|
32
26
|
|
|
33
27
|
// src/ListItem.tsx
|
|
34
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
35
28
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
36
29
|
import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
|
|
37
30
|
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
@@ -43,65 +36,55 @@ var LIST_ITEM_NAME = "ListItem";
|
|
|
43
36
|
var [createListItemContext, createListItemScope] = createContextScope2(LIST_ITEM_NAME, []);
|
|
44
37
|
var [ListItemProvider, useListItemContext] = createListItemContext(LIST_ITEM_NAME);
|
|
45
38
|
var ListItemHeading = /* @__PURE__ */ forwardRef2(({ children, asChild, __listItemScope, ...props }, forwardedRef) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ref: forwardedRef
|
|
54
|
-
}, children);
|
|
55
|
-
} finally {
|
|
56
|
-
_effect.f();
|
|
57
|
-
}
|
|
39
|
+
const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
|
|
40
|
+
const Comp = asChild ? Slot : Primitive2.div;
|
|
41
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
42
|
+
...props,
|
|
43
|
+
id: headingId,
|
|
44
|
+
ref: forwardedRef
|
|
45
|
+
}, children);
|
|
58
46
|
});
|
|
59
47
|
var ListItemOpenTrigger = Collapsible.Trigger;
|
|
60
48
|
var ListItemCollapsibleContent = Collapsible.Content;
|
|
61
49
|
var ListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
onOpenChange: setOpen
|
|
101
|
-
}, listItem) : listItem);
|
|
102
|
-
} finally {
|
|
103
|
-
_effect.f();
|
|
104
|
-
}
|
|
50
|
+
const id = useId("listItem", props.id);
|
|
51
|
+
const { __listScope, __listItemScope, children, selected: propsSelected, defaultSelected, onSelectedChange, open: propsOpen, defaultOpen, onOpenChange, collapsible, labelId, ...listItemProps } = props;
|
|
52
|
+
const { selectable } = useListContext(LIST_NAME, __listScope);
|
|
53
|
+
const [selected = false, setSelected] = useControllableState({
|
|
54
|
+
prop: propsSelected,
|
|
55
|
+
defaultProp: defaultSelected,
|
|
56
|
+
onChange: onSelectedChange
|
|
57
|
+
});
|
|
58
|
+
const [open = false, setOpen] = useControllableState({
|
|
59
|
+
prop: propsOpen,
|
|
60
|
+
defaultProp: defaultOpen,
|
|
61
|
+
onChange: onOpenChange
|
|
62
|
+
});
|
|
63
|
+
const headingId = useId("listItem__heading", labelId);
|
|
64
|
+
const listItem = /* @__PURE__ */ React2.createElement(Primitive2.li, {
|
|
65
|
+
...listItemProps,
|
|
66
|
+
id,
|
|
67
|
+
ref: forwardedRef,
|
|
68
|
+
"aria-labelledby": headingId,
|
|
69
|
+
...selectable && {
|
|
70
|
+
role: "option",
|
|
71
|
+
"aria-selected": !!selected
|
|
72
|
+
},
|
|
73
|
+
...open && {
|
|
74
|
+
"aria-expanded": true
|
|
75
|
+
}
|
|
76
|
+
}, children);
|
|
77
|
+
return /* @__PURE__ */ React2.createElement(ListItemProvider, {
|
|
78
|
+
scope: __listItemScope,
|
|
79
|
+
headingId,
|
|
80
|
+
open,
|
|
81
|
+
selected,
|
|
82
|
+
setSelected
|
|
83
|
+
}, collapsible ? /* @__PURE__ */ React2.createElement(Collapsible.Root, {
|
|
84
|
+
asChild: true,
|
|
85
|
+
open,
|
|
86
|
+
onOpenChange: setOpen
|
|
87
|
+
}, listItem) : listItem);
|
|
105
88
|
});
|
|
106
89
|
ListItem.displayName = LIST_ITEM_NAME;
|
|
107
90
|
export {
|
|
@@ -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
|
|
5
|
-
"mappings": "
|
|
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", "
|
|
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": "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",
|
|
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"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/List.tsx":{"bytes":
|
|
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,7 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/List.tsx
|
|
4
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
5
4
|
import { createContextScope } from "@radix-ui/react-context";
|
|
6
5
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
7
6
|
import React, { forwardRef } from "react";
|
|
@@ -9,31 +8,25 @@ var LIST_NAME = "List";
|
|
|
9
8
|
var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
|
|
10
9
|
var [ListProvider, useListContext] = createListContext(LIST_NAME);
|
|
11
10
|
var List = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
itemSizes
|
|
28
|
-
}, children));
|
|
29
|
-
} finally {
|
|
30
|
-
_effect.f();
|
|
31
|
-
}
|
|
11
|
+
const { __listScope, variant = "ordered", selectable = false, itemSizes, children, ...rootProps } = props;
|
|
12
|
+
const ListRoot = variant === "ordered" ? Primitive.ol : Primitive.ul;
|
|
13
|
+
return /* @__PURE__ */ React.createElement(ListRoot, {
|
|
14
|
+
...selectable && {
|
|
15
|
+
role: "listbox",
|
|
16
|
+
"aria-multiselectable": true
|
|
17
|
+
},
|
|
18
|
+
...rootProps,
|
|
19
|
+
ref: forwardedRef
|
|
20
|
+
}, /* @__PURE__ */ React.createElement(ListProvider, {
|
|
21
|
+
scope: __listScope,
|
|
22
|
+
variant,
|
|
23
|
+
selectable,
|
|
24
|
+
itemSizes
|
|
25
|
+
}, children));
|
|
32
26
|
});
|
|
33
27
|
List.displayName = LIST_NAME;
|
|
34
28
|
|
|
35
29
|
// src/ListItem.tsx
|
|
36
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
37
30
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
38
31
|
import { createContextScope as createContextScope2 } from "@radix-ui/react-context";
|
|
39
32
|
import { Primitive as Primitive2 } from "@radix-ui/react-primitive";
|
|
@@ -45,65 +38,55 @@ var LIST_ITEM_NAME = "ListItem";
|
|
|
45
38
|
var [createListItemContext, createListItemScope] = createContextScope2(LIST_ITEM_NAME, []);
|
|
46
39
|
var [ListItemProvider, useListItemContext] = createListItemContext(LIST_ITEM_NAME);
|
|
47
40
|
var ListItemHeading = /* @__PURE__ */ forwardRef2(({ children, asChild, __listItemScope, ...props }, forwardedRef) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
ref: forwardedRef
|
|
56
|
-
}, children);
|
|
57
|
-
} finally {
|
|
58
|
-
_effect.f();
|
|
59
|
-
}
|
|
41
|
+
const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
|
|
42
|
+
const Comp = asChild ? Slot : Primitive2.div;
|
|
43
|
+
return /* @__PURE__ */ React2.createElement(Comp, {
|
|
44
|
+
...props,
|
|
45
|
+
id: headingId,
|
|
46
|
+
ref: forwardedRef
|
|
47
|
+
}, children);
|
|
60
48
|
});
|
|
61
49
|
var ListItemOpenTrigger = Collapsible.Trigger;
|
|
62
50
|
var ListItemCollapsibleContent = Collapsible.Content;
|
|
63
51
|
var ListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
onOpenChange: setOpen
|
|
103
|
-
}, listItem) : listItem);
|
|
104
|
-
} finally {
|
|
105
|
-
_effect.f();
|
|
106
|
-
}
|
|
52
|
+
const id = useId("listItem", props.id);
|
|
53
|
+
const { __listScope, __listItemScope, children, selected: propsSelected, defaultSelected, onSelectedChange, open: propsOpen, defaultOpen, onOpenChange, collapsible, labelId, ...listItemProps } = props;
|
|
54
|
+
const { selectable } = useListContext(LIST_NAME, __listScope);
|
|
55
|
+
const [selected = false, setSelected] = useControllableState({
|
|
56
|
+
prop: propsSelected,
|
|
57
|
+
defaultProp: defaultSelected,
|
|
58
|
+
onChange: onSelectedChange
|
|
59
|
+
});
|
|
60
|
+
const [open = false, setOpen] = useControllableState({
|
|
61
|
+
prop: propsOpen,
|
|
62
|
+
defaultProp: defaultOpen,
|
|
63
|
+
onChange: onOpenChange
|
|
64
|
+
});
|
|
65
|
+
const headingId = useId("listItem__heading", labelId);
|
|
66
|
+
const listItem = /* @__PURE__ */ React2.createElement(Primitive2.li, {
|
|
67
|
+
...listItemProps,
|
|
68
|
+
id,
|
|
69
|
+
ref: forwardedRef,
|
|
70
|
+
"aria-labelledby": headingId,
|
|
71
|
+
...selectable && {
|
|
72
|
+
role: "option",
|
|
73
|
+
"aria-selected": !!selected
|
|
74
|
+
},
|
|
75
|
+
...open && {
|
|
76
|
+
"aria-expanded": true
|
|
77
|
+
}
|
|
78
|
+
}, children);
|
|
79
|
+
return /* @__PURE__ */ React2.createElement(ListItemProvider, {
|
|
80
|
+
scope: __listItemScope,
|
|
81
|
+
headingId,
|
|
82
|
+
open,
|
|
83
|
+
selected,
|
|
84
|
+
setSelected
|
|
85
|
+
}, collapsible ? /* @__PURE__ */ React2.createElement(Collapsible.Root, {
|
|
86
|
+
asChild: true,
|
|
87
|
+
open,
|
|
88
|
+
onOpenChange: setOpen
|
|
89
|
+
}, listItem) : listItem);
|
|
107
90
|
});
|
|
108
91
|
ListItem.displayName = LIST_ITEM_NAME;
|
|
109
92
|
export {
|
|
@@ -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
|
|
5
|
-
"mappings": "
|
|
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", "
|
|
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": "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",
|
|
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"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"src/List.tsx":{"bytes":
|
|
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}}}
|