@dxos/react-list 0.1.51-main.49677b6 → 0.1.51-main.57ad9f3

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.
@@ -175,11 +175,6 @@ var ListItem = /* @__PURE__ */ forwardRef2((props, forwardedRef) => {
175
175
  }
176
176
  });
177
177
  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
178
  export {
184
179
  LIST_ITEM_NAME,
185
180
  LIST_NAME,
@@ -190,7 +185,6 @@ export {
190
185
  ListItemHeading,
191
186
  ListItemOpenTrigger,
192
187
  arrayMove,
193
- arrayMoveInPlace,
194
188
  createListItemScope,
195
189
  createListScope,
196
190
  useListContext,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/List.tsx", "../../../src/ListItem.tsx", "../../../src/arrayMoveInPlace.ts"],
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,kBAA+D;AACxE,SAASC,8BAA8B;AACvC,SAASC,iBAAiBC,WAAWC,mCAAmC;AACxE,SAASC,0BAAiC;AAC1C,SAASC,iBAAiB;AAC1B,OAAOC,SAAgCC,YAAYC,aAAaC,gBAAgB;AALhF,SAAA,WAAA;;;;;;;;;;;;;;AASA,IAAMC,YAAY;AAuClB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBR,mBAAmBM,WAAW,CAAA,CAAE;AAO7E,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AMU,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;;;ACnNhB,IAAMwE,mBAAmB,CAAIC,OAAiBC,MAAcC,OAAe;AAChF,SAAOF,MAAMG,OAAOD,KAAK,IAAIF,MAAMI,SAASF,KAAKA,IAAI,GAAGF,MAAMG,OAAOF,MAAM,CAAA,EAAG,CAAA,CAAE;AAClF;",
6
- "names": ["DndContext", "restrictToVerticalAxis", "SortableContext", "arrayMove", "verticalListSortingStrategy", "createContextScope", "Primitive", "React", "forwardRef", "useCallback", "useState", "LIST_NAME", "createListContext", "createListScope", "ListProvider", "useListContext", "isOrderedDraggable", "props", "variant", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "onDragEnd", "onDragOver", "listItemIds", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "draggingId", "setDraggingId", "useState", "undefined", "onDragStart", "useCallback", "event", "active", "id", "composedOnDragEnd", "role", "ref", "ListProvider", "scope", "isOrderedDraggable", "DndContext", "modifiers", "restrictToVerticalAxis", "SortableContext", "items", "strategy", "verticalListSortingStrategy", "displayName", "LIST_NAME", "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", "ListItemImpl", "__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", "itemSizes", "useComposedRefs", "style", "CSS", "toString", "ListItem", "variant", "listItemId", "displayName", "arrayMoveInPlace", "array", "from", "to", "splice", "length"]
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"],
5
+ "mappings": ";AAIA,SAASA,kBAA+D;AACxE,SAASC,8BAA8B;AACvC,SAASC,iBAAiBC,WAAWC,mCAAmC;AACxE,SAASC,0BAAiC;AAC1C,SAASC,iBAAiB;AAC1B,OAAOC,SAAgCC,YAAYC,aAAaC,gBAAgB;AALhF,SAAA,WAAA;;;;;;;;;;;;;;AASA,IAAMC,YAAY;AAuClB,IAAM,CAACC,mBAAmBC,eAAAA,IAAmBR,mBAAmBM,WAAW,CAAA,CAAE;AAO7E,IAAM,CAACG,cAAcC,cAAAA,IAAkBH,kBAAoCD,SAAAA;AAE3E,IAAMK,qBAAqB,CAACC,UAC1BA,MAAMC,YAAY;AAMpB,IAAMC,OAAOC,2BAAwC,CAACC,OAAmCC,iBAAiB;AACxG,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,WACAC,YACAC,a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nD,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", "verticalListSortingStrategy", "createContextScope", "Primitive", "React", "forwardRef", "useCallback", "useState", "LIST_NAME", "createListContext", "createListScope", "ListProvider", "useListContext", "isOrderedDraggable", "props", "variant", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "onDragEnd", "onDragOver", "listItemIds", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "draggingId", "setDraggingId", "useState", "undefined", "onDragStart", "useCallback", "event", "active", "id", "composedOnDragEnd", "role", "ref", "ListProvider", "scope", "isOrderedDraggable", "DndContext", "modifiers", "restrictToVerticalAxis", "SortableContext", "items", "strategy", "verticalListSortingStrategy", "displayName", "LIST_NAME", "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", "ListItemImpl", "__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", "itemSizes", "useComposedRefs", "style", "CSS", "toString", "ListItem", "variant", "listItemId", "displayName"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":11866,"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":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":20114,"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/arrayMoveInPlace.ts":{"bytes":987,"imports":[]},"packages/ui/primitives/react-list/src/index.ts":{"bytes":564,"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"},{"path":"packages/ui/primitives/react-list/src/arrayMoveInPlace.ts","kind":"import-statement","original":"./arrayMoveInPlace"}]}},"outputs":{"packages/ui/primitives/react-list/dist/lib/browser/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18184},"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":"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","arrayMoveInPlace","createListItemScope","createListScope","useListContext","useListItemContext"],"entryPoint":"packages/ui/primitives/react-list/src/index.ts","inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytesInOutput":2401},"packages/ui/primitives/react-list/src/index.ts":{"bytesInOutput":0},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":4645},"packages/ui/primitives/react-list/src/arrayMoveInPlace.ts":{"bytesInOutput":134}},"bytes":7653}}}
1
+ {"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":11866,"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":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":20114,"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":17714},"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":"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":2401},"packages/ui/primitives/react-list/src/index.ts":{"bytesInOutput":0},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":4645}},"bytes":7437}}}
@@ -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,
@@ -224,11 +223,6 @@ var ListItem = /* @__PURE__ */ (0, import_react2.forwardRef)((props, forwardedRe
224
223
  }
225
224
  });
226
225
  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
226
  // Annotate the CommonJS export names for ESM import in node:
233
227
  0 && (module.exports = {
234
228
  LIST_ITEM_NAME,
@@ -240,7 +234,6 @@ var arrayMoveInPlace = (array, from, to) => {
240
234
  ListItemHeading,
241
235
  ListItemOpenTrigger,
242
236
  arrayMove,
243
- arrayMoveInPlace,
244
237
  createListItemScope,
245
238
  createListScope,
246
239
  useListContext,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/index.ts", "../../../src/List.tsx", "../../../src/ListItem.tsx", "../../../src/arrayMoveInPlace.ts"],
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;;;;;;;;;;;;;;;;;;;;ACIA,kBAAwE;AACxE,uBAAuC;AACvC,sBAAwE;AACxE,2BAA0C;AAC1C,6BAA0B;AAC1B,mBAAgF;AALhF,SAAA,WAAA;;;;;;;;;;;;;;AASA,IAAMA,YAAY;AAuClB,IAAM,CAACC,mBAAmBC,eAAAA,QAAmBC,yCAAmBH,WAAW,CAAA,CAAE;AAO7E,IAAM,CAACI,cAAcC,cAAAA,IAAkBJ,kBAAoCD,SAAAA;AAE3E,IAAMM,qBAAqB,CAACC,UAC1BA,MAAMC,YAAY;AAMpB,IAAMC,OAAOC,6CAAwC,CAACC,OAAmCC,iBAAiB;AACxG,QAAM,EACJC,aACAC,UAAU,WACVC,aAAa,OACbC,WACAC,YACAC,aACAC,WACAC,UACA,GAAGC,UAAAA,IACDV;AACJ,QAAMW,WAAWR,YAAY,aAAaA,YAAY,sBAAsBS,iCAAUC,KAAKD,iCAAUE;AACrG,QAAM,CAACC,YAAYC,aAAAA,QAAiBC,uBAA6BC,MAAAA;AACjE,QAAMC,kBAAcC,0BAAY,CAACC,UAA0BL,cAAcK,MAAMC,OAAOC,EAAE,GAAa,CAAA,CAAE;AACvG,QAAMC,wBAAoBJ,0BACxB,CAACC,UAAwB;AACvBL,kBAAcE,MAAAA;AACdb,2CAAYgB;EACd,GACA;IAAChB;GAAU;AAEb,SACE,6BAAAoB,QA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E;AAClF;",
6
- "names": ["LIST_NAME", "createListContext", "createListScope", "createContextScope", "ListProvider", "useListContext", "isOrderedDraggable", "props", "variant", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "onDragEnd", "onDragOver", "listItemIds", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "draggingId", "setDraggingId", "useState", "undefined", "onDragStart", "useCallback", "event", "active", "id", "composedOnDragEnd", "React", "role", "ref", "ListProvider", "scope", "isOrderedDraggable", "DndContext", "modifiers", "restrictToVerticalAxis", "SortableContext", "items", "strategy", "verticalListSortingStrategy", "displayName", "LIST_NAME", "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", "ListItemImpl", "__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", "itemSizes", "useComposedRefs", "style", "CSS", "toString", "ListItem", "variant", "listItemId", "displayName", "arrayMoveInPlace", "array", "from", "to", "splice", "length"]
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, 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 List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AAgBpD,cAAc+C,UAAAA;AAE1C,SACE,8BAAAzC,QAAA,cAACY,cAAAA,UAAAA,CAAAA,GACKnB,OAAAA;IACJsD,OAAO;MACL,GAAGtD,MAAMsD;MACTL,WAAWM,qBAAIH,cAAc,QAAQ,cAAc,WAAW,EAAEI,SAASP,SAAAA;MACzEC;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", "isOrderedDraggable", "props", "variant", "List", "forwardRef", "props", "forwardedRef", "__listScope", "variant", "selectable", "onDragEnd", "onDragOver", "listItemIds", "itemSizes", "children", "rootProps", "ListRoot", "Primitive", "ol", "ul", "draggingId", "setDraggingId", "useState", "undefined", "onDragStart", "useCallback", "event", "active", "id", "composedOnDragEnd", "React", "role", "ref", "ListProvider", "scope", "isOrderedDraggable", "DndContext", "modifiers", "restrictToVerticalAxis", "SortableContext", "items", "strategy", "verticalListSortingStrategy", "displayName", "LIST_NAME", "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", "ListItemImpl", "__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", "itemSizes", "useComposedRefs", "style", "CSS", "toString", "ListItem", "variant", "listItemId", "displayName"]
7
7
  }
@@ -1 +1 @@
1
- {"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":11866,"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":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":20114,"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/arrayMoveInPlace.ts":{"bytes":987,"imports":[]},"packages/ui/primitives/react-list/src/index.ts":{"bytes":564,"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"},{"path":"packages/ui/primitives/react-list/src/arrayMoveInPlace.ts","kind":"import-statement","original":"./arrayMoveInPlace"}]}},"outputs":{"packages/ui/primitives/react-list/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":18070},"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":"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":685},"packages/ui/primitives/react-list/src/List.tsx":{"bytesInOutput":2641},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":5181},"packages/ui/primitives/react-list/src/arrayMoveInPlace.ts":{"bytesInOutput":134}},"bytes":10641}}}
1
+ {"inputs":{"packages/ui/primitives/react-list/src/List.tsx":{"bytes":11866,"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":"react","kind":"import-statement","external":true}]},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytes":20114,"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":17562},"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":"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":2641},"packages/ui/primitives/react-list/src/ListItem.tsx":{"bytesInOutput":5181}},"bytes":10381}}}
@@ -1,4 +1,3 @@
1
1
  export * from './List';
2
2
  export * from './ListItem';
3
- export * from './arrayMoveInPlace';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,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.49677b6",
3
+ "version": "0.1.51-main.57ad9f3",
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.49677b6"
30
+ "@dxos/react-hooks": "0.1.51-main.57ad9f3"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@radix-ui/react-checkbox": "^1.0.3",
package/src/index.ts CHANGED
@@ -4,4 +4,3 @@
4
4
 
5
5
  export * from './List';
6
6
  export * from './ListItem';
7
- export * from './arrayMoveInPlace';
@@ -1,2 +0,0 @@
1
- export declare const arrayMoveInPlace: <T>(array: T[], from: number, to: number) => T[];
2
- //# sourceMappingURL=arrayMoveInPlace.d.ts.map
@@ -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"}
@@ -1,7 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export const arrayMoveInPlace = <T>(array: Array<T>, from: number, to: number) => {
6
- return array.splice(to < 0 ? array.length + to : to, 0, array.splice(from, 1)[0]);
7
- };