@dxos/react-list 0.1.51-main.6a6c684 → 0.1.51-main.b72af36
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 +13 -32
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +11 -31
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/List.d.ts +19 -28
- package/dist/types/src/List.d.ts.map +1 -1
- package/dist/types/src/ListItem.d.ts +1 -1
- package/dist/types/src/ListItem.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/List.tsx +22 -60
- package/src/ListItem.tsx +5 -6
- package/src/index.ts +0 -1
- package/dist/types/src/arrayMoveInPlace.d.ts +0 -2
- package/dist/types/src/arrayMoveInPlace.d.ts.map +0 -1
- package/src/arrayMoveInPlace.ts +0 -7
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// packages/ui/primitives/react-list/src/List.tsx
|
|
2
2
|
import { DndContext } from "@dnd-kit/core";
|
|
3
3
|
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
4
|
-
import { SortableContext, arrayMove
|
|
4
|
+
import { SortableContext, arrayMove } from "@dnd-kit/sortable";
|
|
5
5
|
import { createContextScope } from "@radix-ui/react-context";
|
|
6
6
|
import { Primitive } from "@radix-ui/react-primitive";
|
|
7
|
-
import
|
|
7
|
+
import omit from "lodash.omit";
|
|
8
|
+
import React, { forwardRef } from "react";
|
|
8
9
|
function _extends() {
|
|
9
10
|
_extends = Object.assign || function(target) {
|
|
10
11
|
for (var i = 1; i < arguments.length; i++) {
|
|
@@ -22,39 +23,26 @@ function _extends() {
|
|
|
22
23
|
var LIST_NAME = "List";
|
|
23
24
|
var [createListContext, createListScope] = createContextScope(LIST_NAME, []);
|
|
24
25
|
var [ListProvider, useListContext] = createListContext(LIST_NAME);
|
|
25
|
-
var isOrderedDraggable = (props) => props.variant === "ordered-draggable";
|
|
26
26
|
var List = /* @__PURE__ */ forwardRef((props, forwardedRef) => {
|
|
27
|
-
const { __listScope, variant = "ordered", selectable = false,
|
|
27
|
+
const { __listScope, variant = "ordered", selectable = false, toggleOpenLabel = "Expand/collapse item", children, ...rootProps } = props;
|
|
28
28
|
const ListRoot = variant === "ordered" || variant === "ordered-draggable" ? Primitive.ol : Primitive.ul;
|
|
29
|
-
const [draggingId, setDraggingId] = useState(void 0);
|
|
30
|
-
const onDragStart = useCallback((event) => setDraggingId(event.active.id), []);
|
|
31
|
-
const composedOnDragEnd = useCallback((event) => {
|
|
32
|
-
setDraggingId(void 0);
|
|
33
|
-
onDragEnd == null ? void 0 : onDragEnd(event);
|
|
34
|
-
}, [
|
|
35
|
-
onDragEnd
|
|
36
|
-
]);
|
|
37
29
|
return /* @__PURE__ */ React.createElement(ListRoot, _extends({}, selectable && {
|
|
38
30
|
role: "listbox",
|
|
39
31
|
"aria-multiselectable": true
|
|
40
|
-
}, rootProps, {
|
|
32
|
+
}, omit(rootProps, "onDragEnd", "listItemIds"), {
|
|
41
33
|
ref: forwardedRef
|
|
42
34
|
}), /* @__PURE__ */ React.createElement(ListProvider, _extends({}, {
|
|
43
35
|
scope: __listScope,
|
|
44
36
|
variant,
|
|
45
37
|
selectable,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
onDragEnd: composedOnDragEnd,
|
|
50
|
-
onDragOver,
|
|
51
|
-
onDragStart,
|
|
38
|
+
toggleOpenLabel
|
|
39
|
+
}), variant === "ordered-draggable" ? /* @__PURE__ */ React.createElement(DndContext, {
|
|
40
|
+
onDragEnd: props.onDragEnd,
|
|
52
41
|
modifiers: [
|
|
53
42
|
restrictToVerticalAxis
|
|
54
43
|
]
|
|
55
44
|
}, /* @__PURE__ */ React.createElement(SortableContext, {
|
|
56
|
-
items: listItemIds
|
|
57
|
-
strategy: verticalListSortingStrategy
|
|
45
|
+
items: props.listItemIds
|
|
58
46
|
}, children)) : /* @__PURE__ */ React.createElement(React.Fragment, null, children)));
|
|
59
47
|
});
|
|
60
48
|
List.displayName = LIST_NAME;
|
|
@@ -104,7 +92,7 @@ var ListItemDragHandle = /* @__PURE__ */ forwardRef2(({ __listItemScope, childre
|
|
|
104
92
|
});
|
|
105
93
|
var ListItemOpenTrigger = Collapsible.Trigger;
|
|
106
94
|
var ListItemCollapsibleContent = Collapsible.Content;
|
|
107
|
-
var
|
|
95
|
+
var PureListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
|
|
108
96
|
const { __listScope, __listItemScope, children, selected: propsSelected, defaultSelected, onSelectedChange, open: propsOpen, defaultOpen, onOpenChange, collapsible, id, draggableAttributes, draggableListeners, ...listItemProps } = props;
|
|
109
97
|
const { selectable } = useListContext(LIST_NAME, __listScope);
|
|
110
98
|
const [selected = false, setSelected] = useControllableState({
|
|
@@ -145,12 +133,11 @@ var DraggableListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
|
|
|
145
133
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
146
134
|
id: props.id
|
|
147
135
|
});
|
|
148
|
-
const { itemSizes } = useListContext(LIST_NAME, props.__listScope);
|
|
149
136
|
const ref = useComposedRefs(forwardedRef, setNodeRef);
|
|
150
|
-
return /* @__PURE__ */ React2.createElement(
|
|
137
|
+
return /* @__PURE__ */ React2.createElement(PureListItem, _extends2({}, props, {
|
|
151
138
|
style: {
|
|
152
139
|
...props.style,
|
|
153
|
-
transform: CSS
|
|
140
|
+
transform: CSS.Transform.toString(transform),
|
|
154
141
|
transition
|
|
155
142
|
},
|
|
156
143
|
ref
|
|
@@ -168,18 +155,13 @@ var ListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
|
|
|
168
155
|
id: listItemId
|
|
169
156
|
}));
|
|
170
157
|
} else {
|
|
171
|
-
return /* @__PURE__ */ React2.createElement(
|
|
158
|
+
return /* @__PURE__ */ React2.createElement(PureListItem, _extends2({}, props, {
|
|
172
159
|
ref: forwardedRef,
|
|
173
160
|
id: listItemId
|
|
174
161
|
}));
|
|
175
162
|
}
|
|
176
163
|
});
|
|
177
164
|
ListItem.displayName = LIST_ITEM_NAME;
|
|
178
|
-
|
|
179
|
-
// packages/ui/primitives/react-list/src/arrayMoveInPlace.ts
|
|
180
|
-
var arrayMoveInPlace = (array, from, to) => {
|
|
181
|
-
return array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
182
|
-
};
|
|
183
165
|
export {
|
|
184
166
|
LIST_ITEM_NAME,
|
|
185
167
|
LIST_NAME,
|
|
@@ -190,7 +172,6 @@ export {
|
|
|
190
172
|
ListItemHeading,
|
|
191
173
|
ListItemOpenTrigger,
|
|
192
174
|
arrayMove,
|
|
193
|
-
arrayMoveInPlace,
|
|
194
175
|
createListItemScope,
|
|
195
176
|
createListScope,
|
|
196
177
|
useListContext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/List.tsx", "../../../src/ListItem.tsx"
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { DndContext, DragEndEvent, DragStartEvent, DragOverEvent } from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport { createContextScope, Scope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { ComponentPropsWithRef, forwardRef, useCallback, useState } 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' | 'ordered-draggable';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype SharedListProps = {\n selectable?: boolean;\n variant?: ListVariant;\n listItemIds?: string[];\n onDragEnd?: (event: DragEndEvent) => void;\n onDragOver?: (event: DragOverEvent) => void;\n itemSizes?: ListItemSizes;\n};\n\ntype SharedDraggableListProps = SharedListProps & {\n listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;\n variant: 'ordered-draggable';\n};\n\ntype HeterogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {\n itemSizes?: 'many';\n};\n\ntype HomogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {\n itemSizes: 'one';\n};\n\ntype BaseListProps = Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd' | 'onDragOver'>;\n\ntype ListProps =\n | (BaseListProps & SharedListProps)\n | (BaseListProps & HomogeneousDraggableListProps)\n | (BaseListProps & HeterogeneousDraggableListProps);\n\n// LIST\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = Pick<ListProps, 'selectable' | 'variant'> & {\n draggingId?: string;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst isOrderedDraggable = (props: ListProps): props is SharedDraggableListProps =>\n props.variant === 'ordered-draggable';\nconst _isOrderedDraggableHomogeneous = (props: ListProps): props is HomogeneousDraggableListProps =>\n isOrderedDraggable(props) && props.itemSizes === 'one';\nconst _isOrderedDraggableHeterogeneous = (props: ListProps): props is HeterogeneousDraggableListProps =>\n isOrderedDraggable(props) && props.itemSizes !== 'one';\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const {\n __listScope,\n variant = 'ordered',\n selectable = false,\n onDragEnd,\n onDragOver,\n listItemIds,\n itemSizes,\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' || variant === 'ordered-draggable' ? Primitive.ol : Primitive.ul;\n const [draggingId, setDraggingId] = useState<string | undefined>(undefined);\n const onDragStart = useCallback((event: DragStartEvent) => setDraggingId(event.active.id as string), []);\n const composedOnDragEnd = useCallback(\n (event: DragEndEvent) => {\n setDraggingId(undefined);\n onDragEnd?.(event);\n },\n [onDragEnd],\n );\n return (\n <ListRoot {...(selectable && { role: 'listbox', 'aria-multiselectable': true })} {...rootProps} ref={forwardedRef}>\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n draggingId,\n itemSizes,\n }}\n >\n {isOrderedDraggable(props) ? (\n <DndContext\n onDragEnd={composedOnDragEnd}\n onDragOver={onDragOver}\n onDragStart={onDragStart}\n modifiers={[restrictToVerticalAxis]}\n >\n <SortableContext items={listItemIds!} strategy={verticalListSortingStrategy}>\n {children}\n </SortableContext>\n </DndContext>\n ) : (\n <>{children}</>\n )}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME, arrayMove };\n\nexport type { ListProps, ListVariant, ListScopedProps, DragEndEvent, DragOverEvent };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DraggableAttributes } from '@dnd-kit/core';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { CollapsibleContentProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope, Scope } 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 ComponentProps,\n ComponentPropsWithRef,\n Dispatch,\n forwardRef,\n ForwardRefExoticComponent,\n SetStateAction,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & ComponentPropsWithRef<\n typeof Primitive.li\n > & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = React.ElementRef<typeof Primitive.li>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype DraggableListItemContextValue = {\n draggableAttributes: DraggableAttributes;\n draggableListeners: ReturnType<typeof useSortable>['listeners'];\n};\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n} & Partial<DraggableListItemContextValue>;\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithRef<typeof Primitive.p>, 'id'>> & {\n asChild?: boolean;\n};\n\nconst ListItemHeading = forwardRef<HTMLParagraphElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Root = asChild ? Slot : Primitive.p;\n return (\n <Root {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Root>\n );\n },\n);\n\ntype ListItemDragHandleProps = ComponentPropsWithRef<typeof Primitive.div>;\n\nconst ListItemDragHandle = forwardRef<HTMLDivElement, ListItemScopedProps<ListItemDragHandleProps>>(\n ({ __listItemScope, children, ...props }, forwardedRef) => {\n const { draggableAttributes, draggableListeners } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n return (\n <div role='button' ref={forwardedRef} {...props} {...draggableAttributes} {...draggableListeners}>\n {children}\n </div>\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 ListItemImpl = forwardRef<\n ListItemElement,\n ListItemProps & { id: string } & Partial<DraggableListItemContextValue>\n>(\n (\n props: ListItemScopedProps<\n ListScopedProps<ListItemProps & { id: string } & Partial<DraggableListItemContextValue>>\n >,\n forwardedRef,\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 id,\n draggableAttributes,\n draggableListeners,\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');\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 >\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 {...{ draggableAttributes, draggableListeners }}\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\nconst DraggableListItem = forwardRef<ListItemElement, ListItemProps & { id: string }>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps & { id: string }>>, forwardedRef) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({\n id: props.id,\n });\n const { itemSizes } = useListContext(LIST_NAME, props.__listScope);\n const ref = useComposedRefs(forwardedRef, setNodeRef) as ComponentPropsWithRef<typeof Primitive.li>['ref'];\n\n return (\n <ListItemImpl\n {...props}\n style={{\n ...props.style,\n transform: CSS[itemSizes === 'one' ? 'Transform' : 'Translate'].toString(transform),\n transition,\n }}\n ref={ref}\n {...{\n draggableAttributes: attributes,\n draggableListeners: listeners,\n }}\n />\n );\n },\n);\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>((props: ListScopedProps<ListItemProps>, forwardedRef) => {\n const { variant } = useListContext(LIST_NAME, props.__listScope);\n const listItemId = useId('listItem', props.id);\n\n if (variant === 'ordered-draggable') {\n return <DraggableListItem {...props} ref={forwardedRef} id={listItemId} />;\n } else {\n return <ListItemImpl {...props} ref={forwardedRef} id={listItemId} />;\n }\n});\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemDragHandle,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemDragHandleProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const arrayMoveInPlace = <T>(array: Array<T>, from: number, to: number) => {\n return array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);\n};\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,
|
|
6
|
-
"names": ["DndContext", "restrictToVerticalAxis", "SortableContext", "arrayMove", "
|
|
3
|
+
"sources": ["../../../src/List.tsx", "../../../src/ListItem.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { DndContext, DragEndEvent } from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove } from '@dnd-kit/sortable';\nimport { createContextScope, Scope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport omit from 'lodash.omit';\nimport React, { ComponentPropsWithRef, forwardRef, ReactHTMLElement } 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' | 'ordered-draggable';\n\ntype SharedListProps = {\n selectable?: boolean;\n variant?: ListVariant;\n onDragEnd?: (event: DragEndEvent) => void;\n listItemIds?: string[];\n toggleOpenLabel?: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;\n};\n\ntype DraggableListProps = Omit<SharedListProps, 'slots'> & {\n onDragEnd: Exclude<SharedListProps['onDragEnd'], undefined>;\n listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;\n variant: 'ordered-draggable';\n};\n\ntype ListProps =\n | (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & SharedListProps)\n | (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & DraggableListProps);\n\n// LIST\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = Pick<ListProps, 'selectable' | 'variant' | 'toggleOpenLabel'>;\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 toggleOpenLabel = 'Expand/collapse item',\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' || variant === 'ordered-draggable' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot\n {...(selectable && { role: 'listbox', 'aria-multiselectable': true })}\n {...omit(rootProps, 'onDragEnd', 'listItemIds')}\n ref={forwardedRef}\n >\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n toggleOpenLabel,\n }}\n >\n {variant === 'ordered-draggable' ? (\n <DndContext onDragEnd={(props as DraggableListProps).onDragEnd} modifiers={[restrictToVerticalAxis]}>\n <SortableContext items={(props as DraggableListProps).listItemIds}>{children}</SortableContext>\n </DndContext>\n ) : (\n <>{children}</>\n )}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME, arrayMove };\n\nexport type { ListProps, ListVariant, ListScopedProps, DragEndEvent };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DraggableAttributes } from '@dnd-kit/core';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { CollapsibleContentProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope, Scope } 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 ComponentProps,\n ComponentPropsWithRef,\n Dispatch,\n forwardRef,\n ForwardRefExoticComponent,\n SetStateAction,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & ComponentPropsWithRef<\n typeof Primitive.li\n > & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = React.ElementRef<typeof Primitive.li>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype DraggableListItemContextValue = {\n draggableAttributes: DraggableAttributes;\n draggableListeners: ReturnType<typeof useSortable>['listeners'];\n};\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n} & Partial<DraggableListItemContextValue>;\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithRef<typeof Primitive.p>, 'id'>> & {\n asChild?: boolean;\n};\n\nconst ListItemHeading = forwardRef<HTMLParagraphElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Root = asChild ? Slot : Primitive.p;\n return (\n <Root {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Root>\n );\n },\n);\n\ntype ListItemDragHandleProps = ComponentPropsWithRef<typeof Primitive.div>;\n\nconst ListItemDragHandle = forwardRef<HTMLDivElement, ListItemScopedProps<ListItemDragHandleProps>>(\n ({ __listItemScope, children, ...props }, forwardedRef) => {\n const { draggableAttributes, draggableListeners } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n return (\n <div role='button' ref={forwardedRef} {...props} {...draggableAttributes} {...draggableListeners}>\n {children}\n </div>\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 PureListItem = forwardRef<\n ListItemElement,\n ListItemProps & { id: string } & Partial<DraggableListItemContextValue>\n>(\n (\n props: ListItemScopedProps<\n ListScopedProps<ListItemProps & { id: string } & Partial<DraggableListItemContextValue>>\n >,\n forwardedRef,\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 id,\n draggableAttributes,\n draggableListeners,\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');\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 >\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 {...{ draggableAttributes, draggableListeners }}\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\nconst DraggableListItem = forwardRef<ListItemElement, ListItemProps & { id: string }>(\n (props: ListItemScopedProps<ListItemProps & { id: string }>, forwardedRef) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({\n id: props.id,\n });\n const ref = useComposedRefs(forwardedRef, setNodeRef) as ComponentPropsWithRef<typeof Primitive.li>['ref'];\n\n return (\n <PureListItem\n {...props}\n style={{\n ...props.style,\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n ref={ref}\n {...{\n draggableAttributes: attributes,\n draggableListeners: listeners,\n }}\n />\n );\n },\n);\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>((props: ListScopedProps<ListItemProps>, forwardedRef) => {\n const { variant } = useListContext(LIST_NAME, props.__listScope);\n const listItemId = useId('listItem', props.id);\n\n if (variant === 'ordered-draggable') {\n return <DraggableListItem {...props} ref={forwardedRef} id={listItemId} />;\n } else {\n return <PureListItem {...props} ref={forwardedRef} id={listItemId} />;\n }\n});\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemDragHandle,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemDragHandleProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAASA,kBAAgC;AACzC,SAASC,8BAA8B;AACvC,SAASC,iBAAiBC,iBAAiB;AAC3C,SAASC,0BAAiC;AAC1C,SAASC,iBAAiB;AAC1B,OAAOC,UAAU;AACjB,OAAOC,SAAgCC,kBAAoC;AAN3E,SAAA,WAAA;;;;;;;;;;;;;;AAUA,IAAMC,YAAY;AA0BlB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBP,mBAAmBK,WAAW,CAAA,CAAE;AAI7E,IAAM,CAACG,cAAcC,cAAAA,IAAkBH,kBAAoCD,SAAAA;AAE3E,IAAMK,OAAON,2BAAwC,CAACO,OAAmCC,iBAAiB;AACxG,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,kBAAkB,wBAClBC,UACA,GAAGC,UAAAA,IACDP;AACJ,QAAMQ,WAAWL,YAAY,aAAaA,YAAY,sBAAsBb,UAAUmB,KAAKnB,UAAUoB;AACrG,SACE,sBAAA,cAACF,UAAAA,SAAAA,CAAAA,GACMJ,cAAc;IAAEO,MAAM;IAAW,wBAAwB;EAAK,GAC/DpB,KAAKg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;AAGF,IAAMI,oBAAoBjD,gBAAAA,YACxB,CAACI,OAA4DC,iBAAiB;AAC5E,QAAM,EAAE6C,YAAYC,WAAWC,YAAYC,WAAWC,WAAU,IAAKC,YAAY;IAC/E3C,IAAIR,MAAMQ;EACZ,CAAA;AACA,QAAMC,MAAM2C,gBAAgBnD,cAAc+C,UAAAA;AAE1C,SACE,gBAAAzC,OAAA,cAACY,cAAAA,UAAAA,CAAAA,GACKnB,OAAAA;IACJqD,OAAO;MACL,GAAGrD,MAAMqD;MACTJ,WAAWK,IAAIC,UAAUC,SAASP,SAAAA;MAClCC;IACF;IACAzC;KACI;IACFE,qBAAqBmC;IACrBlC,oBAAoBmC;EACtB,CAAA,CAAA;AAGN,CAAA;AAGF,IAAMU,WAAW7D,gBAAAA,YAA2C,CAACI,OAAuCC,iBAAiB;AACnH,QAAM,EAAEyD,QAAO,IAAK1B,eAAeC,WAAWjC,MAAMoB,WAAW;AAC/D,QAAMuC,aAAanB,MAAM,YAAYxC,MAAMQ,EAAE;AAE7C,MAAIkD,YAAY,qBAAqB;AACnC,WAAO,gBAAAnD,OAAA,cAACsC,mBAAAA,UAAAA,CAAAA,GAAsB7C,OAAAA;MAAOS,KAAKR;MAAcO,IAAImD;;EAC9D,OAAO;AACL,WAAO,gBAAApD,OAAA,cAACY,cAAAA,UAAAA,CAAAA,GAAiBnB,OAAAA;MAAOS,KAAKR;MAAcO,IAAImD;;EACzD;AACF,CAAA;AAEAF,SAASG,cAAcvE;",
|
|
6
|
+
"names": ["DndContext", "restrictToVerticalAxis", "SortableContext", "arrayMove", "createContextScope", "Primitive", "omit", "React", "forwardRef", "LIST_NAME", "createListContext", "createListScope", "ListProvider", "useListContext", "List", "props", "forwardedRef", "__listScope", "variant", "selectable", "toggleOpenLabel", "children", "rootProps", "ListRoot", "ol", "ul", "role", "ref", "scope", "onDragEnd", "modifiers", "items", "listItemIds", "displayName", "useSortable", "CSS", "Collapsible", "useComposedRefs", "createContextScope", "Primitive", "Slot", "useControllableState", "React", "forwardRef", "useId", "_extends", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Root", "Slot", "Primitive", "p", "React", "id", "ref", "ListItemDragHandle", "draggableAttributes", "draggableListeners", "div", "role", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "PureListItem", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "useId", "listItem", "li", "aria-labelledby", "scope", "DraggableListItem", "attributes", "listeners", "setNodeRef", "transform", "transition", "useSortable", "useComposedRefs", "style", "CSS", "Transform", "toString", "ListItem", "variant", "listItemId", "displayName"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":8588,"imports":[{"path":"@dnd-kit/core","kind":"import-statement","external":true},{"path":"@dnd-kit/modifiers","kind":"import-statement","external":true},{"path":"@dnd-kit/sortable","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":"lodash.omit","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":19718,"imports":[{"path":"@dnd-kit/sortable","kind":"import-statement","external":true},{"path":"@dnd-kit/utilities","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","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":"packages/ui/primitives/react-list/src/List.tsx","kind":"import-statement","original":"./List"}]},"packages/ui/primitives/react-list/src/index.ts":{"bytes":456,"imports":[{"path":"packages/ui/primitives/react-list/src/List.tsx","kind":"import-statement","original":"./List"},{"path":"packages/ui/primitives/react-list/src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}]}},"outputs":{"packages/ui/primitives/react-list/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15547},"packages/ui/primitives/react-list/dist/lib/browser/index.mjs":{"imports":[{"path":"@dnd-kit/core","kind":"import-statement","external":true},{"path":"@dnd-kit/modifiers","kind":"import-statement","external":true},{"path":"@dnd-kit/sortable","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":"lodash.omit","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dnd-kit/sortable","kind":"import-statement","external":true},{"path":"@dnd-kit/utilities","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","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","ListItemDragHandle","ListItemHeading","ListItemOpenTrigger","arrayMove","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"packages/ui/primitives/react-list/src/index.ts","inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytesInOutput":1963},"packages/ui/primitives/react-list/src/index.ts":{"bytesInOutput":0},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":4536}},"bytes":6890}}}
|
package/dist/lib/node/index.cjs
CHANGED
|
@@ -39,7 +39,6 @@ __export(src_exports, {
|
|
|
39
39
|
ListItemHeading: () => ListItemHeading,
|
|
40
40
|
ListItemOpenTrigger: () => ListItemOpenTrigger,
|
|
41
41
|
arrayMove: () => import_sortable.arrayMove,
|
|
42
|
-
arrayMoveInPlace: () => arrayMoveInPlace,
|
|
43
42
|
createListItemScope: () => createListItemScope,
|
|
44
43
|
createListScope: () => createListScope,
|
|
45
44
|
useListContext: () => useListContext,
|
|
@@ -53,6 +52,7 @@ var import_modifiers = require("@dnd-kit/modifiers");
|
|
|
53
52
|
var import_sortable = require("@dnd-kit/sortable");
|
|
54
53
|
var import_react_context = require("@radix-ui/react-context");
|
|
55
54
|
var import_react_primitive = require("@radix-ui/react-primitive");
|
|
55
|
+
var import_lodash = __toESM(require("lodash.omit"));
|
|
56
56
|
var import_react = __toESM(require("react"));
|
|
57
57
|
function _extends() {
|
|
58
58
|
_extends = Object.assign || function(target) {
|
|
@@ -71,39 +71,26 @@ function _extends() {
|
|
|
71
71
|
var LIST_NAME = "List";
|
|
72
72
|
var [createListContext, createListScope] = (0, import_react_context.createContextScope)(LIST_NAME, []);
|
|
73
73
|
var [ListProvider, useListContext] = createListContext(LIST_NAME);
|
|
74
|
-
var isOrderedDraggable = (props) => props.variant === "ordered-draggable";
|
|
75
74
|
var List = /* @__PURE__ */ (0, import_react.forwardRef)((props, forwardedRef) => {
|
|
76
|
-
const { __listScope, variant = "ordered", selectable = false,
|
|
75
|
+
const { __listScope, variant = "ordered", selectable = false, toggleOpenLabel = "Expand/collapse item", children, ...rootProps } = props;
|
|
77
76
|
const ListRoot = variant === "ordered" || variant === "ordered-draggable" ? import_react_primitive.Primitive.ol : import_react_primitive.Primitive.ul;
|
|
78
|
-
const [draggingId, setDraggingId] = (0, import_react.useState)(void 0);
|
|
79
|
-
const onDragStart = (0, import_react.useCallback)((event) => setDraggingId(event.active.id), []);
|
|
80
|
-
const composedOnDragEnd = (0, import_react.useCallback)((event) => {
|
|
81
|
-
setDraggingId(void 0);
|
|
82
|
-
onDragEnd == null ? void 0 : onDragEnd(event);
|
|
83
|
-
}, [
|
|
84
|
-
onDragEnd
|
|
85
|
-
]);
|
|
86
77
|
return /* @__PURE__ */ import_react.default.createElement(ListRoot, _extends({}, selectable && {
|
|
87
78
|
role: "listbox",
|
|
88
79
|
"aria-multiselectable": true
|
|
89
|
-
}, rootProps, {
|
|
80
|
+
}, (0, import_lodash.default)(rootProps, "onDragEnd", "listItemIds"), {
|
|
90
81
|
ref: forwardedRef
|
|
91
82
|
}), /* @__PURE__ */ import_react.default.createElement(ListProvider, _extends({}, {
|
|
92
83
|
scope: __listScope,
|
|
93
84
|
variant,
|
|
94
85
|
selectable,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
onDragEnd: composedOnDragEnd,
|
|
99
|
-
onDragOver,
|
|
100
|
-
onDragStart,
|
|
86
|
+
toggleOpenLabel
|
|
87
|
+
}), variant === "ordered-draggable" ? /* @__PURE__ */ import_react.default.createElement(import_core.DndContext, {
|
|
88
|
+
onDragEnd: props.onDragEnd,
|
|
101
89
|
modifiers: [
|
|
102
90
|
import_modifiers.restrictToVerticalAxis
|
|
103
91
|
]
|
|
104
92
|
}, /* @__PURE__ */ import_react.default.createElement(import_sortable.SortableContext, {
|
|
105
|
-
items: listItemIds
|
|
106
|
-
strategy: import_sortable.verticalListSortingStrategy
|
|
93
|
+
items: props.listItemIds
|
|
107
94
|
}, children)) : /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, children)));
|
|
108
95
|
});
|
|
109
96
|
List.displayName = LIST_NAME;
|
|
@@ -153,7 +140,7 @@ var ListItemDragHandle = /* @__PURE__ */ (0, import_react2.forwardRef)(({ __list
|
|
|
153
140
|
});
|
|
154
141
|
var ListItemOpenTrigger = Collapsible.Trigger;
|
|
155
142
|
var ListItemCollapsibleContent = Collapsible.Content;
|
|
156
|
-
var
|
|
143
|
+
var PureListItem = /* @__PURE__ */ (0, import_react2.forwardRef)((props, forwardedRef) => {
|
|
157
144
|
const { __listScope, __listItemScope, children, selected: propsSelected, defaultSelected, onSelectedChange, open: propsOpen, defaultOpen, onOpenChange, collapsible, id, draggableAttributes, draggableListeners, ...listItemProps } = props;
|
|
158
145
|
const { selectable } = useListContext(LIST_NAME, __listScope);
|
|
159
146
|
const [selected = false, setSelected] = (0, import_react_use_controllable_state.useControllableState)({
|
|
@@ -194,12 +181,11 @@ var DraggableListItem = /* @__PURE__ */ (0, import_react2.forwardRef)((props, fo
|
|
|
194
181
|
const { attributes, listeners, setNodeRef, transform, transition } = (0, import_sortable2.useSortable)({
|
|
195
182
|
id: props.id
|
|
196
183
|
});
|
|
197
|
-
const { itemSizes } = useListContext(LIST_NAME, props.__listScope);
|
|
198
184
|
const ref = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, setNodeRef);
|
|
199
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
185
|
+
return /* @__PURE__ */ import_react2.default.createElement(PureListItem, _extends2({}, props, {
|
|
200
186
|
style: {
|
|
201
187
|
...props.style,
|
|
202
|
-
transform: import_utilities.CSS
|
|
188
|
+
transform: import_utilities.CSS.Transform.toString(transform),
|
|
203
189
|
transition
|
|
204
190
|
},
|
|
205
191
|
ref
|
|
@@ -217,18 +203,13 @@ var ListItem = /* @__PURE__ */ (0, import_react2.forwardRef)((props, forwardedRe
|
|
|
217
203
|
id: listItemId
|
|
218
204
|
}));
|
|
219
205
|
} else {
|
|
220
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
206
|
+
return /* @__PURE__ */ import_react2.default.createElement(PureListItem, _extends2({}, props, {
|
|
221
207
|
ref: forwardedRef,
|
|
222
208
|
id: listItemId
|
|
223
209
|
}));
|
|
224
210
|
}
|
|
225
211
|
});
|
|
226
212
|
ListItem.displayName = LIST_ITEM_NAME;
|
|
227
|
-
|
|
228
|
-
// packages/ui/primitives/react-list/src/arrayMoveInPlace.ts
|
|
229
|
-
var arrayMoveInPlace = (array, from, to) => {
|
|
230
|
-
return array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
|
|
231
|
-
};
|
|
232
213
|
// Annotate the CommonJS export names for ESM import in node:
|
|
233
214
|
0 && (module.exports = {
|
|
234
215
|
LIST_ITEM_NAME,
|
|
@@ -240,7 +221,6 @@ var arrayMoveInPlace = (array, from, to) => {
|
|
|
240
221
|
ListItemHeading,
|
|
241
222
|
ListItemOpenTrigger,
|
|
242
223
|
arrayMove,
|
|
243
|
-
arrayMoveInPlace,
|
|
244
224
|
createListItemScope,
|
|
245
225
|
createListScope,
|
|
246
226
|
useListContext,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/index.ts", "../../../src/List.tsx", "../../../src/ListItem.tsx"
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './List';\nexport * from './ListItem';\nexport * from './arrayMoveInPlace';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DndContext, DragEndEvent, DragStartEvent, DragOverEvent } from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove, verticalListSortingStrategy } from '@dnd-kit/sortable';\nimport { createContextScope, Scope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport React, { ComponentPropsWithRef, forwardRef, useCallback, useState } 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' | 'ordered-draggable';\n\ntype ListItemSizes = 'one' | 'many';\n\ntype SharedListProps = {\n selectable?: boolean;\n variant?: ListVariant;\n listItemIds?: string[];\n onDragEnd?: (event: DragEndEvent) => void;\n onDragOver?: (event: DragOverEvent) => void;\n itemSizes?: ListItemSizes;\n};\n\ntype SharedDraggableListProps = SharedListProps & {\n listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;\n variant: 'ordered-draggable';\n};\n\ntype HeterogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {\n itemSizes?: 'many';\n};\n\ntype HomogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {\n itemSizes: 'one';\n};\n\ntype BaseListProps = Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd' | 'onDragOver'>;\n\ntype ListProps =\n | (BaseListProps & SharedListProps)\n | (BaseListProps & HomogeneousDraggableListProps)\n | (BaseListProps & HeterogeneousDraggableListProps);\n\n// LIST\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = Pick<ListProps, 'selectable' | 'variant'> & {\n draggingId?: string;\n itemSizes?: ListItemSizes;\n};\n\nconst [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);\n\nconst isOrderedDraggable = (props: ListProps): props is SharedDraggableListProps =>\n props.variant === 'ordered-draggable';\nconst _isOrderedDraggableHomogeneous = (props: ListProps): props is HomogeneousDraggableListProps =>\n isOrderedDraggable(props) && props.itemSizes === 'one';\nconst _isOrderedDraggableHeterogeneous = (props: ListProps): props is HeterogeneousDraggableListProps =>\n isOrderedDraggable(props) && props.itemSizes !== 'one';\n\nconst List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {\n const {\n __listScope,\n variant = 'ordered',\n selectable = false,\n onDragEnd,\n onDragOver,\n listItemIds,\n itemSizes,\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' || variant === 'ordered-draggable' ? Primitive.ol : Primitive.ul;\n const [draggingId, setDraggingId] = useState<string | undefined>(undefined);\n const onDragStart = useCallback((event: DragStartEvent) => setDraggingId(event.active.id as string), []);\n const composedOnDragEnd = useCallback(\n (event: DragEndEvent) => {\n setDraggingId(undefined);\n onDragEnd?.(event);\n },\n [onDragEnd],\n );\n return (\n <ListRoot {...(selectable && { role: 'listbox', 'aria-multiselectable': true })} {...rootProps} ref={forwardedRef}>\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n draggingId,\n itemSizes,\n }}\n >\n {isOrderedDraggable(props) ? (\n <DndContext\n onDragEnd={composedOnDragEnd}\n onDragOver={onDragOver}\n onDragStart={onDragStart}\n modifiers={[restrictToVerticalAxis]}\n >\n <SortableContext items={listItemIds!} strategy={verticalListSortingStrategy}>\n {children}\n </SortableContext>\n </DndContext>\n ) : (\n <>{children}</>\n )}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME, arrayMove };\n\nexport type { ListProps, ListVariant, ListScopedProps, DragEndEvent, DragOverEvent };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DraggableAttributes } from '@dnd-kit/core';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { CollapsibleContentProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope, Scope } 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 ComponentProps,\n ComponentPropsWithRef,\n Dispatch,\n forwardRef,\n ForwardRefExoticComponent,\n SetStateAction,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & ComponentPropsWithRef<\n typeof Primitive.li\n > & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = React.ElementRef<typeof Primitive.li>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype DraggableListItemContextValue = {\n draggableAttributes: DraggableAttributes;\n draggableListeners: ReturnType<typeof useSortable>['listeners'];\n};\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n} & Partial<DraggableListItemContextValue>;\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithRef<typeof Primitive.p>, 'id'>> & {\n asChild?: boolean;\n};\n\nconst ListItemHeading = forwardRef<HTMLParagraphElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Root = asChild ? Slot : Primitive.p;\n return (\n <Root {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Root>\n );\n },\n);\n\ntype ListItemDragHandleProps = ComponentPropsWithRef<typeof Primitive.div>;\n\nconst ListItemDragHandle = forwardRef<HTMLDivElement, ListItemScopedProps<ListItemDragHandleProps>>(\n ({ __listItemScope, children, ...props }, forwardedRef) => {\n const { draggableAttributes, draggableListeners } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n return (\n <div role='button' ref={forwardedRef} {...props} {...draggableAttributes} {...draggableListeners}>\n {children}\n </div>\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 ListItemImpl = forwardRef<\n ListItemElement,\n ListItemProps & { id: string } & Partial<DraggableListItemContextValue>\n>(\n (\n props: ListItemScopedProps<\n ListScopedProps<ListItemProps & { id: string } & Partial<DraggableListItemContextValue>>\n >,\n forwardedRef,\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 id,\n draggableAttributes,\n draggableListeners,\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');\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 >\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 {...{ draggableAttributes, draggableListeners }}\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\nconst DraggableListItem = forwardRef<ListItemElement, ListItemProps & { id: string }>(\n (props: ListItemScopedProps<ListScopedProps<ListItemProps & { id: string }>>, forwardedRef) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({\n id: props.id,\n });\n const { itemSizes } = useListContext(LIST_NAME, props.__listScope);\n const ref = useComposedRefs(forwardedRef, setNodeRef) as ComponentPropsWithRef<typeof Primitive.li>['ref'];\n\n return (\n <ListItemImpl\n {...props}\n style={{\n ...props.style,\n transform: CSS[itemSizes === 'one' ? 'Transform' : 'Translate'].toString(transform),\n transition,\n }}\n ref={ref}\n {...{\n draggableAttributes: attributes,\n draggableListeners: listeners,\n }}\n />\n );\n },\n);\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>((props: ListScopedProps<ListItemProps>, forwardedRef) => {\n const { variant } = useListContext(LIST_NAME, props.__listScope);\n const listItemId = useId('listItem', props.id);\n\n if (variant === 'ordered-draggable') {\n return <DraggableListItem {...props} ref={forwardedRef} id={listItemId} />;\n } else {\n return <ListItemImpl {...props} ref={forwardedRef} id={listItemId} />;\n }\n});\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemDragHandle,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemDragHandleProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const arrayMoveInPlace = <T>(array: Array<T>, from: number, to: number) => {\n return array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
6
|
-
"names": ["LIST_NAME", "createListContext", "createListScope", "createContextScope", "ListProvider", "useListContext", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/List.tsx", "../../../src/ListItem.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nexport * from './List';\nexport * from './ListItem';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DndContext, DragEndEvent } from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove } from '@dnd-kit/sortable';\nimport { createContextScope, Scope } from '@radix-ui/react-context';\nimport { Primitive } from '@radix-ui/react-primitive';\nimport omit from 'lodash.omit';\nimport React, { ComponentPropsWithRef, forwardRef, ReactHTMLElement } 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' | 'ordered-draggable';\n\ntype SharedListProps = {\n selectable?: boolean;\n variant?: ListVariant;\n onDragEnd?: (event: DragEndEvent) => void;\n listItemIds?: string[];\n toggleOpenLabel?: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;\n};\n\ntype DraggableListProps = Omit<SharedListProps, 'slots'> & {\n onDragEnd: Exclude<SharedListProps['onDragEnd'], undefined>;\n listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;\n variant: 'ordered-draggable';\n};\n\ntype ListProps =\n | (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & SharedListProps)\n | (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & DraggableListProps);\n\n// LIST\n\nconst [createListContext, createListScope] = createContextScope(LIST_NAME, []);\n\ntype ListContextValue = Pick<ListProps, 'selectable' | 'variant' | 'toggleOpenLabel'>;\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 toggleOpenLabel = 'Expand/collapse item',\n children,\n ...rootProps\n } = props;\n const ListRoot = variant === 'ordered' || variant === 'ordered-draggable' ? Primitive.ol : Primitive.ul;\n return (\n <ListRoot\n {...(selectable && { role: 'listbox', 'aria-multiselectable': true })}\n {...omit(rootProps, 'onDragEnd', 'listItemIds')}\n ref={forwardedRef}\n >\n <ListProvider\n {...{\n scope: __listScope,\n variant,\n selectable,\n toggleOpenLabel,\n }}\n >\n {variant === 'ordered-draggable' ? (\n <DndContext onDragEnd={(props as DraggableListProps).onDragEnd} modifiers={[restrictToVerticalAxis]}>\n <SortableContext items={(props as DraggableListProps).listItemIds}>{children}</SortableContext>\n </DndContext>\n ) : (\n <>{children}</>\n )}\n </ListProvider>\n </ListRoot>\n );\n});\n\nList.displayName = LIST_NAME;\n\nexport { List, createListScope, useListContext, LIST_NAME, arrayMove };\n\nexport type { ListProps, ListVariant, ListScopedProps, DragEndEvent };\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { DraggableAttributes } from '@dnd-kit/core';\nimport { useSortable } from '@dnd-kit/sortable';\nimport { CSS } from '@dnd-kit/utilities';\nimport type { CheckboxProps } from '@radix-ui/react-checkbox';\nimport { CollapsibleContentProps, CollapsibleTriggerProps } from '@radix-ui/react-collapsible';\nimport * as Collapsible from '@radix-ui/react-collapsible';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { createContextScope, Scope } 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 ComponentProps,\n ComponentPropsWithRef,\n Dispatch,\n forwardRef,\n ForwardRefExoticComponent,\n SetStateAction,\n} from 'react';\n\nimport { useId } from '@dxos/react-hooks';\n\nimport { LIST_NAME, ListScopedProps, useListContext } from './List';\n\nconst LIST_ITEM_NAME = 'ListItem';\n\ntype ListItemScopedProps<P> = P & { __listItemScope?: Scope };\n\ninterface ListItemData {\n id: string;\n selected?: CheckboxProps['checked'];\n open?: boolean;\n}\n\ntype ListItemProps = Omit<ListItemData, 'id'> & { collapsible?: boolean } & ComponentPropsWithRef<\n typeof Primitive.li\n > & {\n defaultOpen?: boolean;\n onOpenChange?: (nextOpen: boolean) => void;\n } & {\n onSelectedChange?: CheckboxProps['onCheckedChange'];\n defaultSelected?: CheckboxProps['defaultChecked'];\n };\n\ntype ListItemElement = React.ElementRef<typeof Primitive.li>;\n\nconst [createListItemContext, createListItemScope] = createContextScope(LIST_ITEM_NAME, []);\n\ntype DraggableListItemContextValue = {\n draggableAttributes: DraggableAttributes;\n draggableListeners: ReturnType<typeof useSortable>['listeners'];\n};\n\ntype ListItemContextValue = {\n headingId: string;\n open: boolean;\n selected: CheckboxProps['checked'];\n setSelected: Dispatch<SetStateAction<CheckboxProps['checked']>>;\n} & Partial<DraggableListItemContextValue>;\n\nconst [ListItemProvider, useListItemContext] = createListItemContext<ListItemContextValue>(LIST_ITEM_NAME);\n\ntype ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithRef<typeof Primitive.p>, 'id'>> & {\n asChild?: boolean;\n};\n\nconst ListItemHeading = forwardRef<HTMLParagraphElement, ListItemHeadingProps>(\n ({ children, asChild, __listItemScope, ...props }, forwardedRef) => {\n const { headingId } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n const Root = asChild ? Slot : Primitive.p;\n return (\n <Root {...props} id={headingId} ref={forwardedRef}>\n {children}\n </Root>\n );\n },\n);\n\ntype ListItemDragHandleProps = ComponentPropsWithRef<typeof Primitive.div>;\n\nconst ListItemDragHandle = forwardRef<HTMLDivElement, ListItemScopedProps<ListItemDragHandleProps>>(\n ({ __listItemScope, children, ...props }, forwardedRef) => {\n const { draggableAttributes, draggableListeners } = useListItemContext(LIST_ITEM_NAME, __listItemScope);\n return (\n <div role='button' ref={forwardedRef} {...props} {...draggableAttributes} {...draggableListeners}>\n {children}\n </div>\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 PureListItem = forwardRef<\n ListItemElement,\n ListItemProps & { id: string } & Partial<DraggableListItemContextValue>\n>(\n (\n props: ListItemScopedProps<\n ListScopedProps<ListItemProps & { id: string } & Partial<DraggableListItemContextValue>>\n >,\n forwardedRef,\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 id,\n draggableAttributes,\n draggableListeners,\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');\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 >\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 {...{ draggableAttributes, draggableListeners }}\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\nconst DraggableListItem = forwardRef<ListItemElement, ListItemProps & { id: string }>(\n (props: ListItemScopedProps<ListItemProps & { id: string }>, forwardedRef) => {\n const { attributes, listeners, setNodeRef, transform, transition } = useSortable({\n id: props.id,\n });\n const ref = useComposedRefs(forwardedRef, setNodeRef) as ComponentPropsWithRef<typeof Primitive.li>['ref'];\n\n return (\n <PureListItem\n {...props}\n style={{\n ...props.style,\n transform: CSS.Transform.toString(transform),\n transition,\n }}\n ref={ref}\n {...{\n draggableAttributes: attributes,\n draggableListeners: listeners,\n }}\n />\n );\n },\n);\n\nconst ListItem = forwardRef<ListItemElement, ListItemProps>((props: ListScopedProps<ListItemProps>, forwardedRef) => {\n const { variant } = useListContext(LIST_NAME, props.__listScope);\n const listItemId = useId('listItem', props.id);\n\n if (variant === 'ordered-draggable') {\n return <DraggableListItem {...props} ref={forwardedRef} id={listItemId} />;\n } else {\n return <PureListItem {...props} ref={forwardedRef} id={listItemId} />;\n }\n});\n\nListItem.displayName = LIST_ITEM_NAME;\n\nexport {\n ListItem,\n ListItemHeading,\n ListItemCollapsibleContent,\n ListItemDragHandle,\n ListItemOpenTrigger,\n createListItemScope,\n useListItemContext,\n LIST_ITEM_NAME,\n};\n\nexport type {\n ListItemProps,\n ListItemHeadingProps,\n ListItemCollapsibleContentProps,\n ListItemDragHandleProps,\n ListItemOpenTriggerProps,\n ListItemScopedProps,\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;ACIA,kBAAyC;AACzC,uBAAuC;AACvC,sBAA2C;AAC3C,2BAA0C;AAC1C,6BAA0B;AAC1B,oBAAiB;AACjB,mBAA2E;AAN3E,SAAA,WAAA;;;;;;;;;;;;;;AAUA,IAAMA,YAAY;AA0BlB,IAAM,CAACC,mBAAmBC,eAAAA,QAAmBC,yCAAmBH,WAAW,CAAA,CAAE;AAI7E,IAAM,CAACI,cAAcC,cAAAA,IAAkBJ,kBAAoCD,SAAAA;AAE3E,IAAMM,OAAOC,6CAAwC,CAACC,OAAmCC,iBAAiB;AACxG,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,kBAAkB,wBAClBC,UACA,GAAGC,UAAAA,IACDP;AACJ,QAAMQ,WAAWL,YAAY,aAAaA,YAAY,sBA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B,cACC,8BAAAtB,QAAA,cAAaJ,kBAAI;IAACL,SAAAA;IAAQ2B;IAAYG,cAAcW;KACjDE,QAAAA,IAGHA,QACD;AAGP,CAAA;AAGF,IAAMI,oBAAoBjD,8CACxB,CAACI,OAA4DC,iBAAiB;AAC5E,QAAM,EAAE6C,YAAYC,WAAWC,YAAYC,WAAWC,WAAU,QAAKC,8BAAY;IAC/E3C,IAAIR,MAAMQ;EACZ,CAAA;AACA,QAAMC,UAAM2C,2CAAgBnD,cAAc+C,UAAAA;AAE1C,SACE,8BAAAzC,QAAA,cAACY,cAAAA,UAAAA,CAAAA,GACKnB,OAAAA;IACJqD,OAAO;MACL,GAAGrD,MAAMqD;MACTJ,WAAWK,qBAAIC,UAAUC,SAASP,SAAAA;MAClCC;IACF;IACAzC;KACI;IACFE,qBAAqBmC;IACrBlC,oBAAoBmC;EACtB,CAAA,CAAA;AAGN,CAAA;AAGF,IAAMU,WAAW7D,8CAA2C,CAACI,OAAuCC,iBAAiB;AACnH,QAAM,EAAEyD,QAAO,IAAK1B,eAAeC,WAAWjC,MAAMoB,WAAW;AAC/D,QAAMuC,iBAAanB,0BAAM,YAAYxC,MAAMQ,EAAE;AAE7C,MAAIkD,YAAY,qBAAqB;AACnC,WAAO,8BAAAnD,QAAA,cAACsC,mBAAAA,UAAAA,CAAAA,GAAsB7C,OAAAA;MAAOS,KAAKR;MAAcO,IAAImD;;EAC9D,OAAO;AACL,WAAO,8BAAApD,QAAA,cAACY,cAAAA,UAAAA,CAAAA,GAAiBnB,OAAAA;MAAOS,KAAKR;MAAcO,IAAImD;;EACzD;AACF,CAAA;AAEAF,SAASG,cAAcvE;",
|
|
6
|
+
"names": ["LIST_NAME", "createListContext", "createListScope", "createContextScope", "ListProvider", "useListContext", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "toggleOpenLabel", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "React", "role", "omit", "ref", "scope", "DndContext", "onDragEnd", "modifiers", "restrictToVerticalAxis", "SortableContext", "items", "listItemIds", "displayName", "import_sortable", "import_react_context", "import_react_primitive", "import_react", "_extends", "LIST_ITEM_NAME", "createListItemContext", "createListItemScope", "createContextScope", "ListItemProvider", "useListItemContext", "ListItemHeading", "forwardRef", "children", "asChild", "__listItemScope", "props", "forwardedRef", "headingId", "Root", "Slot", "Primitive", "p", "React", "id", "ref", "ListItemDragHandle", "draggableAttributes", "draggableListeners", "div", "role", "ListItemOpenTrigger", "Trigger", "ListItemCollapsibleContent", "Content", "PureListItem", "__listScope", "selected", "propsSelected", "defaultSelected", "onSelectedChange", "open", "propsOpen", "defaultOpen", "onOpenChange", "collapsible", "listItemProps", "selectable", "useListContext", "LIST_NAME", "setSelected", "useControllableState", "prop", "defaultProp", "onChange", "setOpen", "useId", "listItem", "li", "aria-labelledby", "scope", "DraggableListItem", "attributes", "listeners", "setNodeRef", "transform", "transition", "useSortable", "useComposedRefs", "style", "CSS", "Transform", "toString", "ListItem", "variant", "listItemId", "displayName"]
|
|
7
7
|
}
|
package/dist/lib/node/meta.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":
|
|
1
|
+
{"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":8588,"imports":[{"path":"@dnd-kit/core","kind":"import-statement","external":true},{"path":"@dnd-kit/modifiers","kind":"import-statement","external":true},{"path":"@dnd-kit/sortable","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":"lodash.omit","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":19718,"imports":[{"path":"@dnd-kit/sortable","kind":"import-statement","external":true},{"path":"@dnd-kit/utilities","kind":"import-statement","external":true},{"path":"@radix-ui/react-collapsible","kind":"import-statement","external":true},{"path":"@radix-ui/react-compose-refs","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":"packages/ui/primitives/react-list/src/List.tsx","kind":"import-statement","original":"./List"}]},"packages/ui/primitives/react-list/src/index.ts":{"bytes":456,"imports":[{"path":"packages/ui/primitives/react-list/src/List.tsx","kind":"import-statement","original":"./List"},{"path":"packages/ui/primitives/react-list/src/ListItem.tsx","kind":"import-statement","original":"./ListItem"}]}},"outputs":{"packages/ui/primitives/react-list/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":15546},"packages/ui/primitives/react-list/dist/lib/node/index.cjs":{"imports":[{"path":"@dnd-kit/core","kind":"require-call","external":true},{"path":"@dnd-kit/modifiers","kind":"require-call","external":true},{"path":"@dnd-kit/sortable","kind":"require-call","external":true},{"path":"@radix-ui/react-context","kind":"require-call","external":true},{"path":"@radix-ui/react-primitive","kind":"require-call","external":true},{"path":"lodash.omit","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"@dnd-kit/sortable","kind":"require-call","external":true},{"path":"@dnd-kit/utilities","kind":"require-call","external":true},{"path":"@radix-ui/react-collapsible","kind":"require-call","external":true},{"path":"@radix-ui/react-compose-refs","kind":"require-call","external":true},{"path":"@radix-ui/react-context","kind":"require-call","external":true},{"path":"@radix-ui/react-primitive","kind":"require-call","external":true},{"path":"@radix-ui/react-slot","kind":"require-call","external":true},{"path":"@radix-ui/react-use-controllable-state","kind":"require-call","external":true},{"path":"react","kind":"require-call","external":true},{"path":"@dxos/react-hooks","kind":"require-call","external":true}],"exports":[],"entryPoint":"packages/ui/primitives/react-list/src/index.ts","inputs":{"packages/ui/primitives/react-list/src/index.ts":{"bytesInOutput":641},"packages/ui/primitives/react-list/src/List.tsx":{"bytesInOutput":2228},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":5072}},"bytes":9859}}}
|
package/dist/types/src/List.d.ts
CHANGED
|
@@ -1,51 +1,42 @@
|
|
|
1
|
-
import { DragEndEvent
|
|
1
|
+
import { DragEndEvent } from '@dnd-kit/core';
|
|
2
2
|
import { arrayMove } from '@dnd-kit/sortable';
|
|
3
3
|
import { Scope } from '@radix-ui/react-context';
|
|
4
4
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
5
|
-
import React, { ComponentPropsWithRef } from 'react';
|
|
5
|
+
import React, { ComponentPropsWithRef, ReactHTMLElement } from 'react';
|
|
6
6
|
declare const LIST_NAME = "List";
|
|
7
7
|
type ListScopedProps<P> = P & {
|
|
8
8
|
__listScope?: Scope;
|
|
9
9
|
};
|
|
10
10
|
type ListVariant = 'ordered' | 'unordered' | 'ordered-draggable';
|
|
11
|
-
type ListItemSizes = 'one' | 'many';
|
|
12
11
|
type SharedListProps = {
|
|
13
12
|
selectable?: boolean;
|
|
14
13
|
variant?: ListVariant;
|
|
15
|
-
listItemIds?: string[];
|
|
16
14
|
onDragEnd?: (event: DragEndEvent) => void;
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
listItemIds?: string[];
|
|
16
|
+
toggleOpenLabel?: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
|
|
19
17
|
};
|
|
20
|
-
type
|
|
18
|
+
type DraggableListProps = Omit<SharedListProps, 'slots'> & {
|
|
19
|
+
onDragEnd: Exclude<SharedListProps['onDragEnd'], undefined>;
|
|
21
20
|
listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;
|
|
22
21
|
variant: 'ordered-draggable';
|
|
23
22
|
};
|
|
24
|
-
type
|
|
25
|
-
itemSizes?: 'many';
|
|
26
|
-
};
|
|
27
|
-
type HomogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {
|
|
28
|
-
itemSizes: 'one';
|
|
29
|
-
};
|
|
30
|
-
type BaseListProps = Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd' | 'onDragOver'>;
|
|
31
|
-
type ListProps = (BaseListProps & SharedListProps) | (BaseListProps & HomogeneousDraggableListProps) | (BaseListProps & HeterogeneousDraggableListProps);
|
|
23
|
+
type ListProps = (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & SharedListProps) | (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & DraggableListProps);
|
|
32
24
|
declare const createListScope: import("@radix-ui/react-context").CreateScope;
|
|
33
|
-
type ListContextValue = Pick<ListProps, 'selectable' | 'variant'
|
|
34
|
-
draggingId?: string;
|
|
35
|
-
itemSizes?: ListItemSizes;
|
|
36
|
-
};
|
|
25
|
+
type ListContextValue = Pick<ListProps, 'selectable' | 'variant' | 'toggleOpenLabel'>;
|
|
37
26
|
declare const useListContext: (consumerName: string, scope: Scope<ListContextValue | undefined>) => ListContextValue;
|
|
38
|
-
declare const List: React.ForwardRefExoticComponent<(Pick<
|
|
39
|
-
|
|
40
|
-
variant: 'ordered-draggable';
|
|
27
|
+
declare const List: React.ForwardRefExoticComponent<(Pick<Omit<Pick<React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "key" | keyof React.OlHTMLAttributes<HTMLOListElement>> & {
|
|
28
|
+
ref?: ((instance: HTMLOListElement | null) => void) | React.RefObject<HTMLOListElement> | null | undefined;
|
|
41
29
|
} & {
|
|
42
|
-
|
|
43
|
-
}, "
|
|
30
|
+
asChild?: boolean | undefined;
|
|
31
|
+
}, "onDragEnd"> & SharedListProps, "type" | "key" | keyof SharedListProps | "slot" | "style" | "title" | "reversed" | "start" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "asChild"> | Pick<Omit<Pick<React.DetailedHTMLProps<React.OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "key" | keyof React.OlHTMLAttributes<HTMLOListElement>> & {
|
|
32
|
+
ref?: ((instance: HTMLOListElement | null) => void) | React.RefObject<HTMLOListElement> | null | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
asChild?: boolean | undefined;
|
|
35
|
+
}, "onDragEnd"> & Omit<SharedListProps, "slots"> & {
|
|
36
|
+
onDragEnd: Exclude<SharedListProps['onDragEnd'], undefined>;
|
|
44
37
|
listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;
|
|
45
38
|
variant: 'ordered-draggable';
|
|
46
|
-
} &
|
|
47
|
-
itemSizes?: "many" | undefined;
|
|
48
|
-
}, "slot" | "style" | "title" | "key" | "reversed" | "start" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "asChild" | keyof SharedListProps>) & React.RefAttributes<HTMLOListElement>>;
|
|
39
|
+
}, "type" | "key" | keyof SharedListProps | "slot" | "style" | "title" | "reversed" | "start" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "asChild">) & React.RefAttributes<HTMLOListElement>>;
|
|
49
40
|
export { List, createListScope, useListContext, LIST_NAME, arrayMove };
|
|
50
|
-
export type { ListProps, ListVariant, ListScopedProps, DragEndEvent
|
|
41
|
+
export type { ListProps, ListVariant, ListScopedProps, DragEndEvent };
|
|
51
42
|
//# sourceMappingURL=List.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,YAAY,
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../src/List.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,YAAY,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAmB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAsB,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,qBAAqB,EAAc,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAInF,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,GAAG,mBAAmB,CAAC;AAEjE,KAAK,eAAe,GAAG;IACrB,UAAU,CAAC,EAAE,OAAO,C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AS,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -39,7 +39,7 @@ declare const useListItemContext: (consumerName: string, scope: Scope<ListItemCo
|
|
|
39
39
|
type ListItemHeadingProps = ListItemScopedProps<Omit<ComponentPropsWithRef<typeof Primitive.p>, 'id'>> & {
|
|
40
40
|
asChild?: boolean;
|
|
41
41
|
};
|
|
42
|
-
declare const ListItemHeading: React.ForwardRefExoticComponent<Pick<ListItemHeadingProps, "
|
|
42
|
+
declare const ListItemHeading: React.ForwardRefExoticComponent<Pick<ListItemHeadingProps, "key" | "onDragEnd" | "slot" | "style" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "asChild" | "__listItemScope"> & React.RefAttributes<HTMLParagraphElement>>;
|
|
43
43
|
type ListItemDragHandleProps = ComponentPropsWithRef<typeof Primitive.div>;
|
|
44
44
|
declare const ListItemDragHandle: React.ForwardRefExoticComponent<Pick<ListItemScopedProps<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
45
45
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../src/ListItem.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,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],"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,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-list",
|
|
3
|
-
"version": "0.1.51-main.
|
|
3
|
+
"version": "0.1.51-main.b72af36",
|
|
4
4
|
"description": "List primitive components for React.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@radix-ui/react-slot": "^1.0.1",
|
|
28
28
|
"@radix-ui/react-use-controllable-state": "^1.0.0",
|
|
29
29
|
"lodash.omit": "^4.5.0",
|
|
30
|
-
"@dxos/react-hooks": "0.1.51-main.
|
|
30
|
+
"@dxos/react-hooks": "0.1.51-main.b72af36"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@radix-ui/react-checkbox": "^1.0.3",
|
package/src/List.tsx
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { DndContext, DragEndEvent
|
|
5
|
+
import { DndContext, DragEndEvent } from '@dnd-kit/core';
|
|
6
6
|
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
|
|
7
|
-
import { SortableContext, arrayMove
|
|
7
|
+
import { SortableContext, arrayMove } from '@dnd-kit/sortable';
|
|
8
8
|
import { createContextScope, Scope } from '@radix-ui/react-context';
|
|
9
9
|
import { Primitive } from '@radix-ui/react-primitive';
|
|
10
|
-
import
|
|
10
|
+
import omit from 'lodash.omit';
|
|
11
|
+
import React, { ComponentPropsWithRef, forwardRef, ReactHTMLElement } from 'react';
|
|
11
12
|
|
|
12
13
|
// 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
|
|
13
14
|
|
|
@@ -17,98 +18,59 @@ type ListScopedProps<P> = P & { __listScope?: Scope };
|
|
|
17
18
|
|
|
18
19
|
type ListVariant = 'ordered' | 'unordered' | 'ordered-draggable';
|
|
19
20
|
|
|
20
|
-
type ListItemSizes = 'one' | 'many';
|
|
21
|
-
|
|
22
21
|
type SharedListProps = {
|
|
23
22
|
selectable?: boolean;
|
|
24
23
|
variant?: ListVariant;
|
|
25
|
-
listItemIds?: string[];
|
|
26
24
|
onDragEnd?: (event: DragEndEvent) => void;
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
listItemIds?: string[];
|
|
26
|
+
toggleOpenLabel?: string | Omit<ReactHTMLElement<HTMLElement>, 'ref'>;
|
|
29
27
|
};
|
|
30
28
|
|
|
31
|
-
type
|
|
29
|
+
type DraggableListProps = Omit<SharedListProps, 'slots'> & {
|
|
30
|
+
onDragEnd: Exclude<SharedListProps['onDragEnd'], undefined>;
|
|
32
31
|
listItemIds: Exclude<SharedListProps['listItemIds'], undefined>;
|
|
33
32
|
variant: 'ordered-draggable';
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
type HeterogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {
|
|
37
|
-
itemSizes?: 'many';
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
type HomogeneousDraggableListProps = Exclude<SharedDraggableListProps, 'itemSizes'> & {
|
|
41
|
-
itemSizes: 'one';
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type BaseListProps = Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd' | 'onDragOver'>;
|
|
45
|
-
|
|
46
35
|
type ListProps =
|
|
47
|
-
| (
|
|
48
|
-
| (
|
|
49
|
-
| (BaseListProps & HeterogeneousDraggableListProps);
|
|
36
|
+
| (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & SharedListProps)
|
|
37
|
+
| (Omit<ComponentPropsWithRef<typeof Primitive.ol>, 'onDragEnd'> & DraggableListProps);
|
|
50
38
|
|
|
51
39
|
// LIST
|
|
52
40
|
|
|
53
41
|
const [createListContext, createListScope] = createContextScope(LIST_NAME, []);
|
|
54
42
|
|
|
55
|
-
type ListContextValue = Pick<ListProps, 'selectable' | 'variant'
|
|
56
|
-
draggingId?: string;
|
|
57
|
-
itemSizes?: ListItemSizes;
|
|
58
|
-
};
|
|
43
|
+
type ListContextValue = Pick<ListProps, 'selectable' | 'variant' | 'toggleOpenLabel'>;
|
|
59
44
|
|
|
60
45
|
const [ListProvider, useListContext] = createListContext<ListContextValue>(LIST_NAME);
|
|
61
46
|
|
|
62
|
-
const isOrderedDraggable = (props: ListProps): props is SharedDraggableListProps =>
|
|
63
|
-
props.variant === 'ordered-draggable';
|
|
64
|
-
const _isOrderedDraggableHomogeneous = (props: ListProps): props is HomogeneousDraggableListProps =>
|
|
65
|
-
isOrderedDraggable(props) && props.itemSizes === 'one';
|
|
66
|
-
const _isOrderedDraggableHeterogeneous = (props: ListProps): props is HeterogeneousDraggableListProps =>
|
|
67
|
-
isOrderedDraggable(props) && props.itemSizes !== 'one';
|
|
68
|
-
|
|
69
47
|
const List = forwardRef<HTMLOListElement, ListProps>((props: ListScopedProps<ListProps>, forwardedRef) => {
|
|
70
48
|
const {
|
|
71
49
|
__listScope,
|
|
72
50
|
variant = 'ordered',
|
|
73
51
|
selectable = false,
|
|
74
|
-
|
|
75
|
-
onDragOver,
|
|
76
|
-
listItemIds,
|
|
77
|
-
itemSizes,
|
|
52
|
+
toggleOpenLabel = 'Expand/collapse item',
|
|
78
53
|
children,
|
|
79
54
|
...rootProps
|
|
80
55
|
} = props;
|
|
81
56
|
const ListRoot = variant === 'ordered' || variant === 'ordered-draggable' ? Primitive.ol : Primitive.ul;
|
|
82
|
-
const [draggingId, setDraggingId] = useState<string | undefined>(undefined);
|
|
83
|
-
const onDragStart = useCallback((event: DragStartEvent) => setDraggingId(event.active.id as string), []);
|
|
84
|
-
const composedOnDragEnd = useCallback(
|
|
85
|
-
(event: DragEndEvent) => {
|
|
86
|
-
setDraggingId(undefined);
|
|
87
|
-
onDragEnd?.(event);
|
|
88
|
-
},
|
|
89
|
-
[onDragEnd],
|
|
90
|
-
);
|
|
91
57
|
return (
|
|
92
|
-
<ListRoot
|
|
58
|
+
<ListRoot
|
|
59
|
+
{...(selectable && { role: 'listbox', 'aria-multiselectable': true })}
|
|
60
|
+
{...omit(rootProps, 'onDragEnd', 'listItemIds')}
|
|
61
|
+
ref={forwardedRef}
|
|
62
|
+
>
|
|
93
63
|
<ListProvider
|
|
94
64
|
{...{
|
|
95
65
|
scope: __listScope,
|
|
96
66
|
variant,
|
|
97
67
|
selectable,
|
|
98
|
-
|
|
99
|
-
itemSizes,
|
|
68
|
+
toggleOpenLabel,
|
|
100
69
|
}}
|
|
101
70
|
>
|
|
102
|
-
{
|
|
103
|
-
<DndContext
|
|
104
|
-
|
|
105
|
-
onDragOver={onDragOver}
|
|
106
|
-
onDragStart={onDragStart}
|
|
107
|
-
modifiers={[restrictToVerticalAxis]}
|
|
108
|
-
>
|
|
109
|
-
<SortableContext items={listItemIds!} strategy={verticalListSortingStrategy}>
|
|
110
|
-
{children}
|
|
111
|
-
</SortableContext>
|
|
71
|
+
{variant === 'ordered-draggable' ? (
|
|
72
|
+
<DndContext onDragEnd={(props as DraggableListProps).onDragEnd} modifiers={[restrictToVerticalAxis]}>
|
|
73
|
+
<SortableContext items={(props as DraggableListProps).listItemIds}>{children}</SortableContext>
|
|
112
74
|
</DndContext>
|
|
113
75
|
) : (
|
|
114
76
|
<>{children}</>
|
|
@@ -122,4 +84,4 @@ List.displayName = LIST_NAME;
|
|
|
122
84
|
|
|
123
85
|
export { List, createListScope, useListContext, LIST_NAME, arrayMove };
|
|
124
86
|
|
|
125
|
-
export type { ListProps, ListVariant, ListScopedProps, DragEndEvent
|
|
87
|
+
export type { ListProps, ListVariant, ListScopedProps, DragEndEvent };
|
package/src/ListItem.tsx
CHANGED
|
@@ -101,7 +101,7 @@ type ListItemCollapsibleContentProps = ComponentProps<typeof Collapsible.Content
|
|
|
101
101
|
|
|
102
102
|
const ListItemCollapsibleContent: ForwardRefExoticComponent<CollapsibleContentProps> = Collapsible.Content;
|
|
103
103
|
|
|
104
|
-
const
|
|
104
|
+
const PureListItem = forwardRef<
|
|
105
105
|
ListItemElement,
|
|
106
106
|
ListItemProps & { id: string } & Partial<DraggableListItemContextValue>
|
|
107
107
|
>(
|
|
@@ -177,19 +177,18 @@ const ListItemImpl = forwardRef<
|
|
|
177
177
|
);
|
|
178
178
|
|
|
179
179
|
const DraggableListItem = forwardRef<ListItemElement, ListItemProps & { id: string }>(
|
|
180
|
-
(props: ListItemScopedProps<
|
|
180
|
+
(props: ListItemScopedProps<ListItemProps & { id: string }>, forwardedRef) => {
|
|
181
181
|
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
182
182
|
id: props.id,
|
|
183
183
|
});
|
|
184
|
-
const { itemSizes } = useListContext(LIST_NAME, props.__listScope);
|
|
185
184
|
const ref = useComposedRefs(forwardedRef, setNodeRef) as ComponentPropsWithRef<typeof Primitive.li>['ref'];
|
|
186
185
|
|
|
187
186
|
return (
|
|
188
|
-
<
|
|
187
|
+
<PureListItem
|
|
189
188
|
{...props}
|
|
190
189
|
style={{
|
|
191
190
|
...props.style,
|
|
192
|
-
transform: CSS
|
|
191
|
+
transform: CSS.Transform.toString(transform),
|
|
193
192
|
transition,
|
|
194
193
|
}}
|
|
195
194
|
ref={ref}
|
|
@@ -209,7 +208,7 @@ const ListItem = forwardRef<ListItemElement, ListItemProps>((props: ListScopedPr
|
|
|
209
208
|
if (variant === 'ordered-draggable') {
|
|
210
209
|
return <DraggableListItem {...props} ref={forwardedRef} id={listItemId} />;
|
|
211
210
|
} else {
|
|
212
|
-
return <
|
|
211
|
+
return <PureListItem {...props} ref={forwardedRef} id={listItemId} />;
|
|
213
212
|
}
|
|
214
213
|
});
|
|
215
214
|
|
package/src/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayMoveInPlace.d.ts","sourceRoot":"","sources":["../../../src/arrayMoveInPlace.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,wBAA8B,MAAM,MAAM,MAAM,QAE5E,CAAC"}
|