@dxos/react-list 0.10.0 → 0.11.1
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/index.mjs +97 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/types/src/List.d.ts +3 -35
- package/dist/types/src/List.d.ts.map +1 -1
- package/dist/types/src/ListContext.d.ts +40 -0
- package/dist/types/src/ListContext.d.ts.map +1 -0
- package/dist/types/src/ListItem.d.ts +7 -38
- package/dist/types/src/ListItem.d.ts.map +1 -1
- package/dist/types/src/ListItemContext.d.ts +41 -0
- package/dist/types/src/ListItemContext.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/List.stories.tsx +1 -1
- package/src/List.tsx +3 -40
- package/src/ListContext.ts +46 -0
- package/src/ListItem.tsx +14 -68
- package/src/ListItemContext.ts +54 -0
- package/src/index.ts +16 -0
- package/dist/lib/browser/index.mjs +0 -105
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -107
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
2
|
+
import { Primitive } from "@radix-ui/react-primitive";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
6
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
7
|
+
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
8
|
+
import { useId } from "@dxos/react-hooks";
|
|
9
|
+
//#region src/ListContext.ts
|
|
10
|
+
var LIST_NAME = "List";
|
|
11
|
+
var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
|
|
12
|
+
var [ListProvider, useListContext] = createListContext(LIST_NAME);
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/List.tsx
|
|
15
|
+
var List = forwardRef((props, forwardedRef) => {
|
|
16
|
+
const { __listScope, variant = "ordered", selectable = false, multiSelectable = false, itemSizes, children, ...rootProps } = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(variant === "ordered" ? Primitive.ol : Primitive.ul, {
|
|
18
|
+
...selectable && {
|
|
19
|
+
role: "listbox",
|
|
20
|
+
...multiSelectable && { "aria-multiselectable": true }
|
|
21
|
+
},
|
|
22
|
+
...rootProps,
|
|
23
|
+
ref: forwardedRef,
|
|
24
|
+
children: /* @__PURE__ */ jsx(ListProvider, {
|
|
25
|
+
scope: __listScope,
|
|
26
|
+
variant,
|
|
27
|
+
selectable,
|
|
28
|
+
itemSizes,
|
|
29
|
+
children
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
List.displayName = LIST_NAME;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/ListItemContext.ts
|
|
36
|
+
var LIST_ITEM_NAME = "ListItem";
|
|
37
|
+
var [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);
|
|
38
|
+
var [ListItemProvider, useListItemContext] = createListItemContext(LIST_ITEM_NAME);
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/ListItem.tsx
|
|
41
|
+
var ListItemHeading = forwardRef(({ children, asChild, __listItemScope, ...props }, forwardedRef) => {
|
|
42
|
+
const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);
|
|
43
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : Primitive.div, {
|
|
44
|
+
...props,
|
|
45
|
+
id: headingId,
|
|
46
|
+
ref: forwardedRef,
|
|
47
|
+
children
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var ListItemOpenTrigger = Collapsible.Trigger;
|
|
51
|
+
var ListItemCollapsibleContent = Collapsible.Content;
|
|
52
|
+
var ListItem = forwardRef((props, forwardedRef) => {
|
|
53
|
+
const id = useId("listItem", props.id);
|
|
54
|
+
const { __listScope, __listItemScope, children, selected: propsSelected, defaultSelected, onSelectedChange, open: propsOpen, defaultOpen, onOpenChange, collapsible, labelId, ...listItemProps } = props;
|
|
55
|
+
const { selectable } = useListContext(LIST_NAME, __listScope);
|
|
56
|
+
const [selected = false, setSelected] = useControllableState({
|
|
57
|
+
prop: propsSelected,
|
|
58
|
+
defaultProp: defaultSelected,
|
|
59
|
+
onChange: onSelectedChange
|
|
60
|
+
});
|
|
61
|
+
const [open = false, setOpen] = useControllableState({
|
|
62
|
+
prop: propsOpen,
|
|
63
|
+
defaultProp: defaultOpen,
|
|
64
|
+
onChange: onOpenChange
|
|
65
|
+
});
|
|
66
|
+
const headingId = useId("listItem__heading", labelId);
|
|
67
|
+
const listItem = /* @__PURE__ */ jsx(Primitive.li, {
|
|
68
|
+
...listItemProps,
|
|
69
|
+
id,
|
|
70
|
+
ref: forwardedRef,
|
|
71
|
+
"aria-labelledby": headingId,
|
|
72
|
+
...selectable && {
|
|
73
|
+
"role": "option",
|
|
74
|
+
"aria-selected": !!selected
|
|
75
|
+
},
|
|
76
|
+
...open && { "aria-expanded": true },
|
|
77
|
+
children
|
|
78
|
+
});
|
|
79
|
+
return /* @__PURE__ */ jsx(ListItemProvider, {
|
|
80
|
+
scope: __listItemScope,
|
|
81
|
+
headingId,
|
|
82
|
+
open,
|
|
83
|
+
selected,
|
|
84
|
+
setSelected,
|
|
85
|
+
children: collapsible ? /* @__PURE__ */ jsx(Collapsible.Root, {
|
|
86
|
+
asChild: true,
|
|
87
|
+
open,
|
|
88
|
+
onOpenChange: setOpen,
|
|
89
|
+
children: listItem
|
|
90
|
+
}) : listItem
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
ListItem.displayName = LIST_ITEM_NAME;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { LIST_ITEM_NAME, LIST_NAME, List, ListItem, ListItemCollapsibleContent, ListItemHeading, ListItemOpenTrigger, createListItemScope, createListScope, useListContext, useListItemContext };
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/ListContext.ts","../../src/List.tsx","../../src/ListItemContext.ts","../../src/ListItem.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport { type Primitive } from '@radix-ui/react-primitive';\nimport { type ComponentPropsWithRef } from 'react';\n\n// Kept out of `List.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const LIST_NAME = 'List';\n\nexport type ListScopedProps<P> = P & { __listScope?: Scope };\n\nexport type ListVariant = 'ordered' | 'unordered';\n\nexport type ListItemSizes = 'one' | 'many';\n\nexport type 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\nexport const [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\nexport type ListContextValue = {\n selectable: Exclude<ListProps['selectable'], undefined>;\n variant: Exclude<ListProps['variant'], undefined>;\n itemSizes?: ListItemSizes;\n};\n\nexport const [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n","//\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 containers (Listbox, OrderedList,\n// Tree, Accordion, Combobox, Picker) plus the\n// reusable navigation/selection/disclosure aspects.\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/state.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 { Primitive } from '@radix-ui/react-primitive';\nimport React, { forwardRef } from 'react';\n\nimport { LIST_NAME, type ListProps, ListProvider, type ListScopedProps } from './ListContext';\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 };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { type CheckboxProps } from '@radix-ui/react-checkbox';\nimport { type Scope, createContextScope } from '@radix-ui/react-context';\nimport {\n type ComponentPropsWithoutRef,\n type ComponentRef,\n type Dispatch,\n type RefAttributes,\n type SetStateAction,\n} from 'react';\n\n// Kept out of `ListItem.tsx`: react-refresh only fast-refreshes a module whose exports are all\n// components, so a context and its hook exported beside them force a full page reload on every edit.\n\nexport const LIST_ITEM_NAME = 'ListItem';\n\nexport type ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\nexport interface ListItemData {\n id: string;\n labelId?: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\nexport type 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\nexport type ListItemElement = ComponentRef<'li'>;\n\nexport const [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\nexport type ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n};\n\nexport const [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\nexport type ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> &\n RefAttributes<HTMLParagraphElement> & {\n asChild?: boolean;\n };\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\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, { type ComponentProps, type ForwardRefExoticComponent, forwardRef } from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, type ListScopedProps, useListContext } from './ListContext';\nimport {\n LIST_ITEM_NAME,\n type ListItemElement,\n type ListItemHeadingProps,\n type ListItemProps,\n ListItemProvider,\n type ListItemScopedProps,\n useListItemContext,\n} from './ListItemContext';\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 { ListItem, ListItemCollapsibleContent, ListItemHeading, ListItemOpenTrigger };\n\nexport type { ListItemCollapsibleContentProps, ListItemOpenTriggerProps };\n"],"mappings":";;;;;;;;;AAWA,IAAa,YAAY;AA0BzB,IAAa,CAAC,mBAAmB,mBAAmB,mBAAmB,WAAW,CAAC,CAAC;AAQpF,IAAa,CAAC,cAAc,kBAAkB,kBAAoC,SAAS;;;ACR3F,IAAM,OAAO,YAAyC,OAAmC,iBAAiB;CACxG,MAAM,EACJ,aACA,UAAU,WACV,aAAa,OACb,kBAAkB,OAClB,WACA,UACA,GAAG,cACD;CAEJ,OACE,oBAFe,YAAY,YAAY,UAAU,KAAK,UAAU,IAEhE;EAIE,GAAK,cAAc;GACjB,MAAM;GACN,GAAI,mBAAmB,EAAE,wBAAwB,KAAc;EACjE;EACA,GAAI;EACJ,KAAK;YAEL,oBAAC,cAAD;GAEI,OAAO;GACP;GACA;GACA;GAGD;EACW,CAAA;CACN,CAAA;AAEd,CAAC;AAED,KAAK,cAAc;;;ACzDnB,IAAa,iBAAiB;AAsB9B,IAAa,CAAC,uBAAuB,uBAAuB,mBAAmB,gBAAgB,CAAC,CAAC;AASjG,IAAa,CAAC,kBAAkB,sBAAsB,sBAA4C,cAAc;;;ACxBhH,IAAM,kBAAkB,YACrB,EAAE,UAAU,SAAS,iBAAiB,GAAG,SAAS,iBAAiB;CAClE,MAAM,EAAE,cAAc,mBAAmB,gBAAgB,eAAe;CAExE,OACE,oBAFW,UAAU,OAAO,UAAU,KAEtC;EAAM,GAAI;EAAO,IAAI;EAAW,KAAK;EAClC;CACG,CAAA;AAEV,CACF;AAIA,IAAM,sBAAsB,YAAY;AAIxC,IAAM,6BAAiF,YAAY;AAEnG,IAAM,WAAW,YACd,OAA4D,iBAAiB;CAC5E,MAAM,KAAK,MAAM,YAAY,MAAM,EAAE;CAErC,MAAM,EACJ,aACA,iBACA,UACA,UAAU,eACV,iBACA,kBACA,MAAM,WACN,aACA,cACA,aACA,SACA,GAAG,kBACD;CACJ,MAAM,EAAE,eAAe,eAAe,WAAW,WAAW;CAE5D,MAAM,CAAC,WAAW,OAAO,eAAe,qBAAqB;EAC3D,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CAED,MAAM,CAAC,OAAO,OAAO,WAAW,qBAAqB;EACnD,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;CAED,MAAM,YAAY,MAAM,qBAAqB,OAAO;CAEpD,MAAM,WACJ,oBAAC,UAAU,IAAX;EACE,GAAI;EACA;EACJ,KAAK;EACL,mBAAiB;EACjB,GAAK,cAAc;GAAE,QAAQ;GAAU,iBAAiB,CAAC,CAAC;EAAS;EACnE,GAAK,QAAQ,EAAE,iBAAiB,KAAK;EAEpC;CACW,CAAA;CAGhB,OACE,oBAAC,kBAAD;EACE,OAAO;EACI;EACL;EACI;EACG;YAEZ,cACC,oBAAC,YAAY,MAAb;GAAkB,SAAA;GAAc;GAAM,cAAc;aACjD;EACe,CAAA,IAElB;CAEc,CAAA;AAEtB,CACF;AAEA,SAAS,cAAc"}
|
package/dist/types/src/List.d.ts
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import React, { type ComponentPropsWithRef } from 'react';
|
|
4
|
-
declare const LIST_NAME = "List";
|
|
5
|
-
type ListScopedProps<P> = P & {
|
|
6
|
-
__listScope?: Scope;
|
|
7
|
-
};
|
|
8
|
-
type ListVariant = 'ordered' | 'unordered';
|
|
9
|
-
type ListItemSizes = 'one' | 'many';
|
|
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
|
-
*/
|
|
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;
|
|
24
|
-
variant?: ListVariant;
|
|
25
|
-
itemSizes?: ListItemSizes;
|
|
26
|
-
};
|
|
27
|
-
declare const createListScope: import("@radix-ui/react-context").CreateScope;
|
|
28
|
-
type ListContextValue = {
|
|
29
|
-
selectable: Exclude<ListProps['selectable'], undefined>;
|
|
30
|
-
variant: Exclude<ListProps['variant'], undefined>;
|
|
31
|
-
itemSizes?: ListItemSizes;
|
|
32
|
-
};
|
|
33
|
-
declare const useListContext: (consumerName: string, scope: Scope<ListContextValue | undefined>) => ListContextValue;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ListProps } from './ListContext';
|
|
34
3
|
declare const List: React.ForwardRefExoticComponent<Omit<ListProps, "ref"> & React.RefAttributes<HTMLOListElement>>;
|
|
35
|
-
export { List
|
|
36
|
-
export type { ListProps, ListScopedProps, ListVariant };
|
|
4
|
+
export { List };
|
|
37
5
|
//# sourceMappingURL=List.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.tsx"],"names":[],"mappings":"AAiCA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAa,KAAK,SAAS,EAAsC,MAAM,eAAe,CAAC;AAE9F,QAAA,MAAM,IAAI,iGAmCR,CAAC;AAIH,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Scope } from '@radix-ui/react-context';
|
|
2
|
+
import { type Primitive } from '@radix-ui/react-primitive';
|
|
3
|
+
import { type ComponentPropsWithRef } from 'react';
|
|
4
|
+
export declare const LIST_NAME = "List";
|
|
5
|
+
export type ListScopedProps<P> = P & {
|
|
6
|
+
__listScope?: Scope;
|
|
7
|
+
};
|
|
8
|
+
export type ListVariant = 'ordered' | 'unordered';
|
|
9
|
+
export type ListItemSizes = 'one' | 'many';
|
|
10
|
+
export 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
|
+
*/
|
|
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;
|
|
24
|
+
variant?: ListVariant;
|
|
25
|
+
itemSizes?: ListItemSizes;
|
|
26
|
+
};
|
|
27
|
+
export declare const createListContext: <ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [React.FC<ContextValueType & {
|
|
28
|
+
scope: Scope<ContextValueType>;
|
|
29
|
+
children: import("react").ReactNode;
|
|
30
|
+
}>, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], createListScope: import("@radix-ui/react-context").CreateScope;
|
|
31
|
+
export type ListContextValue = {
|
|
32
|
+
selectable: Exclude<ListProps['selectable'], undefined>;
|
|
33
|
+
variant: Exclude<ListProps['variant'], undefined>;
|
|
34
|
+
itemSizes?: ListItemSizes;
|
|
35
|
+
};
|
|
36
|
+
export declare const ListProvider: import("react").FC<ListContextValue & {
|
|
37
|
+
scope: Scope<ListContextValue>;
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
}>, useListContext: (consumerName: string, scope: Scope<ListContextValue | undefined>) => ListContextValue;
|
|
40
|
+
//# sourceMappingURL=ListContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListContext.d.ts","sourceRoot":"","sources":["../../../src/ListContext.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,OAAO,CAAC;AAKnD,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,EAAE,CAAC,GAAG;IACnE;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAO,iBAAiB;;;6FAAE,eAAe,+CAAqC,CAAC;AAEtF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,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,eAAO,MAAO,YAAY;;;IAAE,cAAc,wFAAkD,CAAC"}
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
import type { CheckboxProps } from '@radix-ui/react-checkbox';
|
|
2
1
|
import { type CollapsibleContentProps, type CollapsibleTriggerProps } from '@radix-ui/react-collapsible';
|
|
3
2
|
import * as Collapsible from '@radix-ui/react-collapsible';
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
6
|
-
declare const
|
|
7
|
-
type ListItemScopedProps<P> = P & {
|
|
8
|
-
__listItemScope?: Scope;
|
|
9
|
-
};
|
|
10
|
-
interface ListItemData {
|
|
11
|
-
id: string;
|
|
12
|
-
labelId?: string;
|
|
13
|
-
selected?: CheckboxProps['checked'];
|
|
14
|
-
open?: boolean;
|
|
15
|
-
}
|
|
16
|
-
type ListItemProps = Omit<ListItemData, 'id'> & {
|
|
17
|
-
collapsible?: boolean;
|
|
18
|
-
} & RefAttributes<HTMLLIElement> & ComponentPropsWithoutRef<'li'> & {
|
|
19
|
-
defaultOpen?: boolean;
|
|
20
|
-
onOpenChange?: (nextOpen: boolean) => void;
|
|
21
|
-
} & {
|
|
22
|
-
onSelectedChange?: CheckboxProps['onCheckedChange'];
|
|
23
|
-
defaultSelected?: CheckboxProps['defaultChecked'];
|
|
24
|
-
};
|
|
25
|
-
declare const createListItemScope: import("@radix-ui/react-context").CreateScope;
|
|
26
|
-
type ListItemContextValue = {
|
|
27
|
-
headingId: string;
|
|
28
|
-
open: boolean;
|
|
29
|
-
selected: CheckboxProps['checked'];
|
|
30
|
-
setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;
|
|
31
|
-
};
|
|
32
|
-
declare const useListItemContext: (consumerName: string, scope: Scope<ListItemContextValue | undefined>) => ListItemContextValue;
|
|
33
|
-
type ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> & RefAttributes<HTMLParagraphElement> & {
|
|
34
|
-
asChild?: boolean;
|
|
35
|
-
};
|
|
36
|
-
declare const ListItemHeading: ForwardRefExoticComponent<Omit<ListItemHeadingProps, "ref"> & RefAttributes<HTMLDivElement>>;
|
|
3
|
+
import React, { type ComponentProps, type ForwardRefExoticComponent } from 'react';
|
|
4
|
+
import { type ListItemHeadingProps, type ListItemProps, type ListItemScopedProps } from './ListItemContext';
|
|
5
|
+
declare const ListItemHeading: ForwardRefExoticComponent<Omit<ListItemHeadingProps, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
37
6
|
type ListItemOpenTriggerProps = ListItemScopedProps<CollapsibleTriggerProps>;
|
|
38
|
-
declare const ListItemOpenTrigger: ForwardRefExoticComponent<CollapsibleTriggerProps & RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
declare const ListItemOpenTrigger: ForwardRefExoticComponent<CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
39
8
|
type ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content>;
|
|
40
9
|
declare const ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps>;
|
|
41
|
-
declare const ListItem: ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & RefAttributes<HTMLLIElement>>;
|
|
42
|
-
export {
|
|
43
|
-
export type { ListItemCollapsibleContentProps,
|
|
10
|
+
declare const ListItem: ForwardRefExoticComponent<Omit<ListItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
11
|
+
export { ListItem, ListItemCollapsibleContent, ListItemHeading, ListItemOpenTrigger };
|
|
12
|
+
export type { ListItemCollapsibleContentProps, ListItemOpenTriggerProps };
|
|
44
13
|
//# sourceMappingURL=ListItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACzG,OAAO,KAAK,WAAW,MAAM,6BAA6B,CAAC;AAI3D,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAAE,KAAK,yBAAyB,EAAc,MAAM,OAAO,CAAC;AAK/F,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAElB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAE3B,QAAA,MAAM,eAAe,oGAUpB,CAAC;AAEF,KAAK,wBAAwB,GAAG,mBAAmB,CAAC,uBAAuB,CAAC,CAAC;AAE7E,QAAA,MAAM,mBAAmB,6FAAsB,CAAC;AAEhD,KAAK,+BAA+B,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAElF,QAAA,MAAM,0BAA0B,EAAE,yBAAyB,CAAC,uBAAuB,CAAuB,CAAC;AAE3G,QAAA,MAAM,QAAQ,4FAiEb,CAAC;AAIF,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AAEtF,YAAY,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type CheckboxProps } from '@radix-ui/react-checkbox';
|
|
2
|
+
import { type Scope } from '@radix-ui/react-context';
|
|
3
|
+
import { type ComponentPropsWithoutRef, type ComponentRef, type Dispatch, type RefAttributes, type SetStateAction } from 'react';
|
|
4
|
+
export declare const LIST_ITEM_NAME = "ListItem";
|
|
5
|
+
export type ListItemScopedProps<P> = P & {
|
|
6
|
+
__listItemScope?: Scope;
|
|
7
|
+
};
|
|
8
|
+
export interface ListItemData {
|
|
9
|
+
id: string;
|
|
10
|
+
labelId?: string;
|
|
11
|
+
selected?: CheckboxProps['checked'];
|
|
12
|
+
open?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type ListItemProps = Omit<ListItemData, 'id'> & {
|
|
15
|
+
collapsible?: boolean;
|
|
16
|
+
} & RefAttributes<HTMLLIElement> & ComponentPropsWithoutRef<'li'> & {
|
|
17
|
+
defaultOpen?: boolean;
|
|
18
|
+
onOpenChange?: (nextOpen: boolean) => void;
|
|
19
|
+
} & {
|
|
20
|
+
onSelectedChange?: CheckboxProps['onCheckedChange'];
|
|
21
|
+
defaultSelected?: CheckboxProps['defaultChecked'];
|
|
22
|
+
};
|
|
23
|
+
export type ListItemElement = ComponentRef<'li'>;
|
|
24
|
+
export declare const createListItemContext: <ContextValueType extends object | null>(rootComponentName: string, defaultContext?: ContextValueType | undefined) => readonly [React.FC<ContextValueType & {
|
|
25
|
+
scope: Scope<ContextValueType>;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
}>, (consumerName: string, scope: Scope<ContextValueType | undefined>) => ContextValueType], createListItemScope: import("@radix-ui/react-context").CreateScope;
|
|
28
|
+
export type ListItemContextValue = {
|
|
29
|
+
headingId: string;
|
|
30
|
+
open: boolean;
|
|
31
|
+
selected: CheckboxProps['checked'];
|
|
32
|
+
setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;
|
|
33
|
+
};
|
|
34
|
+
export declare const ListItemProvider: import("react").FC<ListItemContextValue & {
|
|
35
|
+
scope: Scope<ListItemContextValue>;
|
|
36
|
+
children: React.ReactNode;
|
|
37
|
+
}>, useListItemContext: (consumerName: string, scope: Scope<ListItemContextValue | undefined>) => ListItemContextValue;
|
|
38
|
+
export type ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithoutRef<'p'>, 'id'>> & RefAttributes<HTMLParagraphElement> & {
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=ListItemContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListItemContext.d.ts","sourceRoot":"","sources":["../../../src/ListItemContext.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,yBAAyB,CAAC;AACzE,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAKf,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,eAAe,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B,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,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CAAC,aAAa,CAAC,GAC7G,wBAAwB,CAAC,IAAI,CAAC,GAAG;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C,GAAG;IACF,gBAAgB,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IACpD,eAAe,CAAC,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CACnD,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AAEjD,eAAO,MAAO,qBAAqB;;;6FAAE,mBAAmB,+CAA0C,CAAC;AAEnG,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACnC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CACjE,CAAC;AAEF,eAAO,MAAO,gBAAgB;;;IAAE,kBAAkB,gGAA+D,CAAC;AAElH,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAC,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,GAC/F,aAAa,CAAC,oBAAoB,CAAC,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { LIST_NAME, type ListProps, type ListScopedProps, type ListVariant, createListScope, useListContext, } from './ListContext';
|
|
1
2
|
export * from './List';
|
|
3
|
+
export { LIST_ITEM_NAME, type ListItemHeadingProps, type ListItemProps, type ListItemScopedProps, createListItemScope, useListItemContext, } from './ListItemContext';
|
|
2
4
|
export * from './ListItem';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACT,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,OAAO,EACL,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|