@dxos/react-ui-list 0.6.12-main.2d19bf1

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.
Files changed (39) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +5 -0
  3. package/dist/lib/browser/index.mjs +303 -0
  4. package/dist/lib/browser/index.mjs.map +7 -0
  5. package/dist/lib/browser/meta.json +1 -0
  6. package/dist/lib/node/index.cjs +328 -0
  7. package/dist/lib/node/index.cjs.map +7 -0
  8. package/dist/lib/node/meta.json +1 -0
  9. package/dist/lib/node-esm/index.mjs +305 -0
  10. package/dist/lib/node-esm/index.mjs.map +7 -0
  11. package/dist/lib/node-esm/meta.json +1 -0
  12. package/dist/types/src/components/List/DropIndicator.d.ts +10 -0
  13. package/dist/types/src/components/List/DropIndicator.d.ts.map +1 -0
  14. package/dist/types/src/components/List/List.d.ts +26 -0
  15. package/dist/types/src/components/List/List.d.ts.map +1 -0
  16. package/dist/types/src/components/List/List.stories.d.ts +13 -0
  17. package/dist/types/src/components/List/List.stories.d.ts.map +1 -0
  18. package/dist/types/src/components/List/ListItem.d.ts +52 -0
  19. package/dist/types/src/components/List/ListItem.d.ts.map +1 -0
  20. package/dist/types/src/components/List/ListRoot.d.ts +30 -0
  21. package/dist/types/src/components/List/ListRoot.d.ts.map +1 -0
  22. package/dist/types/src/components/List/index.d.ts +2 -0
  23. package/dist/types/src/components/List/index.d.ts.map +1 -0
  24. package/dist/types/src/components/index.d.ts +2 -0
  25. package/dist/types/src/components/index.d.ts.map +1 -0
  26. package/dist/types/src/index.d.ts +2 -0
  27. package/dist/types/src/index.d.ts.map +1 -0
  28. package/dist/types/src/testing.d.ts +15 -0
  29. package/dist/types/src/testing.d.ts.map +1 -0
  30. package/package.json +63 -0
  31. package/src/components/List/DropIndicator.tsx +64 -0
  32. package/src/components/List/List.stories.tsx +108 -0
  33. package/src/components/List/List.tsx +44 -0
  34. package/src/components/List/ListItem.tsx +234 -0
  35. package/src/components/List/ListRoot.tsx +85 -0
  36. package/src/components/List/index.ts +5 -0
  37. package/src/components/index.ts +5 -0
  38. package/src/index.ts +5 -0
  39. package/src/testing.ts +29 -0
@@ -0,0 +1,305 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/ui/react-ui-list/src/components/List/ListItem.tsx
4
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
5
+ import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
6
+ import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
7
+ import { attachClosestEdge, extractClosestEdge as extractClosestEdge2 } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
8
+ import { createContext as createContext2 } from "@radix-ui/react-context";
9
+ import React3, { forwardRef, useEffect as useEffect2, useRef, useState as useState2 } from "react";
10
+ import { createPortal } from "react-dom";
11
+ import { invariant } from "@dxos/invariant";
12
+ import { Icon } from "@dxos/react-ui";
13
+ import { mx as mx2 } from "@dxos/react-ui-theme";
14
+
15
+ // packages/ui/react-ui-list/src/components/List/DropIndicator.tsx
16
+ import React from "react";
17
+ import { mx } from "@dxos/react-ui-theme";
18
+ var edgeToOrientationMap = {
19
+ top: "horizontal",
20
+ bottom: "horizontal",
21
+ left: "vertical",
22
+ right: "vertical"
23
+ };
24
+ var orientationStyles = {
25
+ horizontal: "h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]",
26
+ vertical: "w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]"
27
+ };
28
+ var edgeStyles = {
29
+ top: "top-[--line-offset] before:top-[--offset-terminal]",
30
+ right: "right-[--line-offset] before:right-[--offset-terminal]",
31
+ bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
32
+ left: "left-[--line-offset] before:left-[--offset-terminal]"
33
+ };
34
+ var strokeSize = 2;
35
+ var terminalSize = 8;
36
+ var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
37
+ var DropIndicator = ({ edge, gap = "0px" }) => {
38
+ const lineOffset = `calc(-0.5 * (${gap} + ${strokeSize}px))`;
39
+ const orientation = edgeToOrientationMap[edge];
40
+ return /* @__PURE__ */ React.createElement("div", {
41
+ style: {
42
+ "--line-thickness": `${strokeSize}px`,
43
+ "--line-offset": `${lineOffset}`,
44
+ "--terminal-size": `${terminalSize}px`,
45
+ "--terminal-radius": `${terminalSize / 2}px`,
46
+ "--negative-terminal-size": `-${terminalSize}px`,
47
+ "--offset-terminal": `${offsetToAlignTerminalWithLine}px`
48
+ },
49
+ className: mx("absolute z-10 pointer-events-none bg-blue-700", "before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute", "before:border-[length:--line-thickness] before:border-solid before:border-blue-700 before:rounded-full", orientationStyles[orientation], edgeStyles[edge])
50
+ });
51
+ };
52
+
53
+ // packages/ui/react-ui-list/src/components/List/ListRoot.tsx
54
+ import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
55
+ import { extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
56
+ import { reorderWithEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge";
57
+ import { createContext } from "@radix-ui/react-context";
58
+ import React2, { useEffect, useState } from "react";
59
+ import { flushSync } from "react-dom";
60
+ import { useControlledValue } from "@dxos/react-ui";
61
+ var LIST_NAME = "List";
62
+ var [ListProvider, useListContext] = createContext(LIST_NAME);
63
+ var ListRoot = ({ classNames, children, items: _items = [], isItem, ...props }) => {
64
+ const [items, setItems] = useControlledValue(_items);
65
+ const [state, setState] = useState(idle);
66
+ useEffect(() => {
67
+ return monitorForElements({
68
+ canMonitor: ({ source }) => isItem(source.data),
69
+ onDrop: ({ location, source }) => {
70
+ const target = location.current.dropTargets[0];
71
+ if (!target) {
72
+ return;
73
+ }
74
+ const sourceData = source.data;
75
+ const targetData = target.data;
76
+ if (!isItem(sourceData) || !isItem(targetData)) {
77
+ return;
78
+ }
79
+ const sourceIdx = items.findIndex((item) => item.id === sourceData.id);
80
+ const targetIdx = items.findIndex((item) => item.id === targetData.id);
81
+ if (targetIdx < 0 || sourceIdx < 0) {
82
+ return;
83
+ }
84
+ const closestEdgeOfTarget = extractClosestEdge(targetData);
85
+ flushSync(() => {
86
+ setItems(reorderWithEdge({
87
+ list: items,
88
+ startIndex: sourceIdx,
89
+ indexOfTarget: targetIdx,
90
+ axis: "vertical",
91
+ closestEdgeOfTarget
92
+ }));
93
+ });
94
+ }
95
+ });
96
+ }, [
97
+ items
98
+ ]);
99
+ return /* @__PURE__ */ React2.createElement(ListProvider, {
100
+ isItem,
101
+ state,
102
+ setState,
103
+ ...props
104
+ }, children?.({
105
+ state,
106
+ items
107
+ }));
108
+ };
109
+
110
+ // packages/ui/react-ui-list/src/components/List/ListItem.tsx
111
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/List/ListItem.tsx";
112
+ var idle = {
113
+ type: "idle"
114
+ };
115
+ var stateStyles = {
116
+ "is-dragging": "opacity-50"
117
+ };
118
+ var defaultContext = {};
119
+ var LIST_ITEM_NAME = "ListItem";
120
+ var [ListItemProvider, useListItemContext] = createContext2(LIST_ITEM_NAME, defaultContext);
121
+ var ListItem = ({ children, classNames, item }) => {
122
+ const { isItem, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
123
+ const ref = useRef(null);
124
+ const dragHandleRef = useRef(null);
125
+ const [state, setState] = useState2(idle);
126
+ useEffect2(() => {
127
+ const element = ref.current;
128
+ invariant(element, void 0, {
129
+ F: __dxlog_file,
130
+ L: 89,
131
+ S: void 0,
132
+ A: [
133
+ "element",
134
+ ""
135
+ ]
136
+ });
137
+ return combine(
138
+ //
139
+ // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable
140
+ //
141
+ draggable({
142
+ element,
143
+ dragHandle: dragHandleRef.current,
144
+ getInitialData: () => item,
145
+ onGenerateDragPreview: dragPreview ? ({ nativeSetDragImage, source }) => {
146
+ const rect = source.element.getBoundingClientRect();
147
+ setCustomNativeDragPreview({
148
+ nativeSetDragImage,
149
+ getOffset: ({ container }) => {
150
+ const { height } = container.getBoundingClientRect();
151
+ return {
152
+ x: 20,
153
+ y: height / 2
154
+ };
155
+ },
156
+ render: ({ container }) => {
157
+ container.style.width = rect.width + "px";
158
+ setState({
159
+ type: "preview",
160
+ container
161
+ });
162
+ setRootState({
163
+ type: "preview",
164
+ container,
165
+ item
166
+ });
167
+ }
168
+ });
169
+ } : void 0,
170
+ onDragStart: () => {
171
+ setState({
172
+ type: "is-dragging"
173
+ });
174
+ setRootState({
175
+ type: "is-dragging",
176
+ item
177
+ });
178
+ },
179
+ onDrop: () => {
180
+ setState(idle);
181
+ setRootState(idle);
182
+ }
183
+ }),
184
+ //
185
+ // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#drop-target-for-elements
186
+ //
187
+ dropTargetForElements({
188
+ element,
189
+ canDrop: ({ source }) => {
190
+ return source.element !== element && isItem(source.data);
191
+ },
192
+ getData: ({ input }) => {
193
+ return attachClosestEdge(item, {
194
+ element,
195
+ input,
196
+ allowedEdges: [
197
+ "top",
198
+ "bottom"
199
+ ]
200
+ });
201
+ },
202
+ getIsSticky: () => true,
203
+ onDragEnter: ({ self }) => {
204
+ const closestEdge = extractClosestEdge2(self.data);
205
+ setState({
206
+ type: "is-dragging-over",
207
+ closestEdge
208
+ });
209
+ },
210
+ onDrag: ({ self }) => {
211
+ const closestEdge = extractClosestEdge2(self.data);
212
+ setState((current) => {
213
+ if (current.type === "is-dragging-over" && current.closestEdge === closestEdge) {
214
+ return current;
215
+ }
216
+ return {
217
+ type: "is-dragging-over",
218
+ closestEdge
219
+ };
220
+ });
221
+ },
222
+ onDragLeave: () => {
223
+ setState(idle);
224
+ },
225
+ onDrop: () => {
226
+ setState(idle);
227
+ }
228
+ })
229
+ );
230
+ }, [
231
+ item
232
+ ]);
233
+ return /* @__PURE__ */ React3.createElement(ListItemProvider, {
234
+ item,
235
+ dragHandleRef
236
+ }, /* @__PURE__ */ React3.createElement("div", {
237
+ className: "relative"
238
+ }, /* @__PURE__ */ React3.createElement("div", {
239
+ ref,
240
+ role: "listitem",
241
+ className: mx2("flex", classNames, stateStyles[state.type])
242
+ }, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ React3.createElement(DropIndicator, {
243
+ edge: state.closestEdge
244
+ })));
245
+ };
246
+ var IconButton = /* @__PURE__ */ forwardRef(({ classNames, icon, ...props }, forwardedRef) => {
247
+ return /* @__PURE__ */ React3.createElement("button", {
248
+ ref: forwardedRef,
249
+ className: mx2("flex items-center justify-center", classNames),
250
+ ...props
251
+ }, /* @__PURE__ */ React3.createElement(Icon, {
252
+ icon,
253
+ classNames: "cursor-pointer",
254
+ size: 4
255
+ }));
256
+ });
257
+ var ListItemDeleteButton = ({ autoHide = true, classNames, ...props }) => {
258
+ const { state } = useListContext("DELETE_BUTTON");
259
+ const disabled = state.type !== "idle";
260
+ return /* @__PURE__ */ React3.createElement(IconButton, {
261
+ icon: "ph--x--regular",
262
+ disabled,
263
+ classNames: [
264
+ classNames,
265
+ autoHide && disabled && "hidden"
266
+ ],
267
+ ...props
268
+ });
269
+ };
270
+ var ListItemDragHandle = () => {
271
+ const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
272
+ return /* @__PURE__ */ React3.createElement(IconButton, {
273
+ ref: dragHandleRef,
274
+ icon: "ph--dots-six--regular"
275
+ });
276
+ };
277
+ var ListItemDragPreview = ({ children }) => {
278
+ const { state } = useListContext("DRAG_PREVIEW");
279
+ return state?.type === "preview" ? /* @__PURE__ */ createPortal(children({
280
+ item: state.item
281
+ }), state.container) : null;
282
+ };
283
+ var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ React3.createElement("div", {
284
+ className: mx2("flex w-full", classNames)
285
+ }, children);
286
+ var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ React3.createElement("div", {
287
+ className: mx2("flex w-full items-center", classNames),
288
+ ...props
289
+ }, children);
290
+
291
+ // packages/ui/react-ui-list/src/components/List/List.tsx
292
+ var List = {
293
+ Root: ListRoot,
294
+ Item: ListItem,
295
+ ItemDragPreview: ListItemDragPreview,
296
+ ItemWrapper: ListItemWrapper,
297
+ ItemDragHandle: ListItemDragHandle,
298
+ ItemDeleteButton: ListItemDeleteButton,
299
+ ItemTitle: ListItemTitle,
300
+ IconButton
301
+ };
302
+ export {
303
+ List
304
+ };
305
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/List/ListItem.tsx", "../../../src/components/List/DropIndicator.tsx", "../../../src/components/List/ListRoot.tsx", "../../../src/components/List/List.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';\nimport { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { setCustomNativeDragPreview } from '@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview';\nimport { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { attachClosestEdge, extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { createContext } from '@radix-ui/react-context';\nimport React, {\n type ComponentProps,\n type HTMLAttributes,\n type MutableRefObject,\n type PropsWithChildren,\n type ReactNode,\n forwardRef,\n useEffect,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { invariant } from '@dxos/invariant';\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { Icon } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { DropIndicator } from './DropIndicator';\nimport { useListContext } from './ListRoot';\n\nexport type ListItemRecord = { id: string };\n\nexport type ItemState =\n | {\n type: 'idle';\n }\n | {\n type: 'preview';\n container: HTMLElement;\n }\n | {\n type: 'is-dragging';\n }\n | {\n type: 'is-dragging-over';\n closestEdge: Edge | null;\n };\n\nexport const idle: ItemState = { type: 'idle' };\n\nconst stateStyles: { [Key in ItemState['type']]?: HTMLAttributes<HTMLDivElement>['className'] } = {\n 'is-dragging': 'opacity-50',\n};\n\ntype ListItemContext<T extends ListItemRecord> = {\n item: T;\n dragHandleRef: MutableRefObject<HTMLElement | null>;\n};\n\n/**\n * Default context defined for ListItemDragPreview, which is defined outside of ListItem.\n */\nconst defaultContext: ListItemContext<any> = {} as any;\n\nconst LIST_ITEM_NAME = 'ListItem';\n\nexport const [ListItemProvider, useListItemContext] = createContext<ListItemContext<any>>(\n LIST_ITEM_NAME,\n defaultContext,\n);\n\nexport type ListItemProps<T extends ListItemRecord> = ThemedClassName<\n PropsWithChildren<{\n item: T;\n }>\n>;\n\n/**\n * Draggable list item.\n */\nexport const ListItem = <T extends ListItemRecord>({ children, classNames, item }: ListItemProps<T>) => {\n const { isItem, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);\n const ref = useRef<HTMLDivElement | null>(null);\n const dragHandleRef = useRef<HTMLElement | null>(null);\n const [state, setState] = useState<ItemState>(idle);\n useEffect(() => {\n const element = ref.current;\n invariant(element);\n return combine(\n //\n // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable\n //\n draggable({\n element,\n dragHandle: dragHandleRef.current!,\n getInitialData: () => item,\n onGenerateDragPreview: dragPreview\n ? ({ nativeSetDragImage, source }) => {\n const rect = source.element.getBoundingClientRect();\n setCustomNativeDragPreview({\n nativeSetDragImage,\n getOffset: ({ container }) => {\n const { height } = container.getBoundingClientRect();\n return {\n x: 20,\n y: height / 2,\n };\n },\n render: ({ container }) => {\n container.style.width = rect.width + 'px';\n setState({ type: 'preview', container });\n setRootState({ type: 'preview', container, item });\n },\n });\n }\n : undefined,\n onDragStart: () => {\n setState({ type: 'is-dragging' });\n setRootState({ type: 'is-dragging', item });\n },\n onDrop: () => {\n setState(idle);\n setRootState(idle);\n },\n }),\n\n //\n // https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#drop-target-for-elements\n //\n dropTargetForElements({\n element,\n canDrop: ({ source }) => {\n return source.element !== element && isItem(source.data);\n },\n getData: ({ input }) => {\n return attachClosestEdge(item, { element, input, allowedEdges: ['top', 'bottom'] });\n },\n getIsSticky: () => true,\n onDragEnter: ({ self }) => {\n const closestEdge = extractClosestEdge(self.data);\n setState({ type: 'is-dragging-over', closestEdge });\n },\n onDrag: ({ self }) => {\n const closestEdge = extractClosestEdge(self.data);\n setState((current) => {\n if (current.type === 'is-dragging-over' && current.closestEdge === closestEdge) {\n return current;\n }\n return { type: 'is-dragging-over', closestEdge };\n });\n },\n onDragLeave: () => {\n setState(idle);\n },\n onDrop: () => {\n setState(idle);\n },\n }),\n );\n }, [item]);\n\n return (\n <ListItemProvider item={item} dragHandleRef={dragHandleRef}>\n <div className='relative'>\n <div ref={ref} role='listitem' className={mx('flex', classNames, stateStyles[state.type])}>\n {children}\n </div>\n {state.type === 'is-dragging-over' && state.closestEdge && <DropIndicator edge={state.closestEdge} />}\n </div>\n </ListItemProvider>\n );\n};\n\n//\n// List item components\n//\n\nexport type IconButtonProps = ThemedClassName<ComponentProps<'button'>> & { icon: string };\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(\n ({ classNames, icon, ...props }, forwardedRef) => {\n return (\n <button ref={forwardedRef} className={mx('flex items-center justify-center', classNames)} {...props}>\n <Icon icon={icon} classNames='cursor-pointer' size={4} />\n </button>\n );\n },\n);\n\nexport const ListItemDeleteButton = ({\n autoHide = true,\n classNames,\n ...props\n}: Omit<IconButtonProps, 'icon'> & { autoHide?: boolean }) => {\n const { state } = useListContext('DELETE_BUTTON');\n const disabled = state.type !== 'idle';\n return (\n <IconButton\n icon='ph--x--regular'\n disabled={disabled}\n classNames={[classNames, autoHide && disabled && 'hidden']}\n {...props}\n />\n );\n};\n\nexport const ListItemDragHandle = () => {\n const { dragHandleRef } = useListItemContext('DRAG_HANDLE');\n return <IconButton ref={dragHandleRef as any} icon='ph--dots-six--regular' />;\n};\n\nexport const ListItemDragPreview = <T extends ListItemRecord>({\n children,\n}: {\n children: ({ item }: { item: T }) => ReactNode;\n}) => {\n const { state } = useListContext('DRAG_PREVIEW');\n return state?.type === 'preview' ? createPortal(children({ item: state.item }), state.container) : null;\n};\n\nexport const ListItemWrapper = ({ classNames, children }: ThemedClassName<PropsWithChildren>) => (\n <div className={mx('flex w-full', classNames)}>{children}</div>\n);\n\nexport const ListItemTitle = ({\n classNames,\n children,\n ...props\n}: ThemedClassName<PropsWithChildren<ComponentProps<'div'>>>) => (\n <div className={mx('flex w-full items-center', classNames)} {...props}>\n {children}\n </div>\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';\nimport React, { type CSSProperties, type HTMLAttributes } from 'react';\n\nimport { mx } from '@dxos/react-ui-theme';\n\ntype Orientation = 'horizontal' | 'vertical';\n\nconst edgeToOrientationMap: Record<Edge, Orientation> = {\n top: 'horizontal',\n bottom: 'horizontal',\n left: 'vertical',\n right: 'vertical',\n};\n\nconst orientationStyles: Record<Orientation, HTMLAttributes<HTMLElement>['className']> = {\n horizontal: 'h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]',\n vertical: 'w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]',\n};\n\nconst edgeStyles: Record<Edge, HTMLAttributes<HTMLElement>['className']> = {\n top: 'top-[--line-offset] before:top-[--offset-terminal]',\n right: 'right-[--line-offset] before:right-[--offset-terminal]',\n bottom: 'bottom-[--line-offset] before:bottom-[--offset-terminal]',\n left: 'left-[--line-offset] before:left-[--offset-terminal]',\n};\n\nconst strokeSize = 2;\nconst terminalSize = 8;\nconst offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;\n\n/**\n * This is a tailwind port of `@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box`\n */\nexport const DropIndicator = ({ edge, gap = '0px' }: { edge: Edge; gap?: string }) => {\n const lineOffset = `calc(-0.5 * (${gap} + ${strokeSize}px))`;\n\n const orientation = edgeToOrientationMap[edge];\n\n return (\n <div\n style={\n {\n '--line-thickness': `${strokeSize}px`,\n '--line-offset': `${lineOffset}`,\n '--terminal-size': `${terminalSize}px`,\n '--terminal-radius': `${terminalSize / 2}px`,\n '--negative-terminal-size': `-${terminalSize}px`,\n '--offset-terminal': `${offsetToAlignTerminalWithLine}px`,\n } as CSSProperties\n }\n className={mx(\n 'absolute z-10 pointer-events-none bg-blue-700',\n \"before:content-[''] before:w-[--terminal-size] before:h-[--terminal-size] box-border before:absolute\",\n 'before:border-[length:--line-thickness] before:border-solid before:border-blue-700 before:rounded-full',\n orientationStyles[orientation],\n edgeStyles[edge],\n )}\n ></div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';\nimport { extractClosestEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';\nimport { reorderWithEdge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge';\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type ReactNode, useEffect, useState } from 'react';\nimport { flushSync } from 'react-dom';\n\nimport { type ThemedClassName, useControlledValue } from '@dxos/react-ui';\n\nimport { type ListItemRecord, idle, type ItemState } from './ListItem';\n\ntype ListContext<T extends ListItemRecord> = {\n isItem: (item: any) => boolean;\n dragPreview?: boolean;\n state: ItemState & { item?: T };\n setState: (state: ItemState & { item?: T }) => void;\n};\n\nconst LIST_NAME = 'List';\n\nexport const [ListProvider, useListContext] = createContext<ListContext<any>>(LIST_NAME);\n\nexport type ListRendererProps<T extends ListItemRecord> = {\n state: ListContext<T>['state'];\n items: T[];\n};\n\nexport type ListRootProps<T extends ListItemRecord> = ThemedClassName<{\n children?: (props: ListRendererProps<T>) => ReactNode;\n items?: T[];\n}> &\n Pick<ListContext<T>, 'isItem' | 'dragPreview'>;\n\nexport const ListRoot = <T extends ListItemRecord>({\n classNames,\n children,\n items: _items = [],\n isItem,\n ...props\n}: ListRootProps<T>) => {\n const [items, setItems] = useControlledValue<T[]>(_items);\n const [state, setState] = useState<ListContext<T>['state']>(idle);\n useEffect(() => {\n return monitorForElements({\n canMonitor: ({ source }) => isItem(source.data),\n onDrop: ({ location, source }) => {\n const target = location.current.dropTargets[0];\n if (!target) {\n return;\n }\n\n const sourceData = source.data;\n const targetData = target.data;\n if (!isItem(sourceData) || !isItem(targetData)) {\n return;\n }\n\n const sourceIdx = items.findIndex((item) => item.id === sourceData.id);\n const targetIdx = items.findIndex((item) => item.id === targetData.id);\n if (targetIdx < 0 || sourceIdx < 0) {\n return;\n }\n\n const closestEdgeOfTarget = extractClosestEdge(targetData);\n flushSync(() => {\n setItems(\n reorderWithEdge({\n list: items,\n startIndex: sourceIdx,\n indexOfTarget: targetIdx,\n axis: 'vertical',\n closestEdgeOfTarget,\n }),\n );\n });\n },\n });\n }, [items]);\n\n return <ListProvider {...{ isItem, state, setState, ...props }}>{children?.({ state, items })}</ListProvider>;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n IconButton,\n type IconButtonProps,\n ListItem,\n ListItemDeleteButton,\n ListItemDragHandle,\n ListItemDragPreview,\n type ListItemProps,\n type ListItemRecord,\n ListItemTitle,\n ListItemWrapper,\n} from './ListItem';\nimport { ListRoot, type ListRootProps } from './ListRoot';\n\n// TODO(burdon): Multi-select model.\n// TODO(burdon): Key nav.\n// TODO(burdon): Animation.\n// TODO(burdon): Constrain axis.\n// TODO(burdon): Tree view.\n// TODO(burdon): Fix autoscroll while dragging.\n\n/**\n * Draggable list.\n * Ref: https://github.com/atlassian/pragmatic-drag-and-drop\n * Ref: https://github.com/alexreardon/pdnd-react-tailwind/blob/main/src/task.tsx\n */\nexport const List = {\n Root: ListRoot,\n Item: ListItem,\n ItemDragPreview: ListItemDragPreview,\n ItemWrapper: ListItemWrapper,\n ItemDragHandle: ListItemDragHandle,\n ItemDeleteButton: ListItemDeleteButton,\n ItemTitle: ListItemTitle,\n IconButton,\n};\n\ntype ListItem = ListItemRecord;\n\nexport type { ListRootProps, ListItemProps, IconButtonProps, ListItem };\n"],
5
+ "mappings": ";;;AAIA,SAASA,eAAe;AACxB,SAASC,WAAWC,6BAA6B;AACjD,SAASC,kCAAkC;AAE3C,SAASC,mBAAmBC,sBAAAA,2BAA0B;AACtD,SAASC,iBAAAA,sBAAqB;AAC9B,OAAOC,UAMLC,YACAC,aAAAA,YACAC,QACAC,YAAAA,iBACK;AACP,SAASC,oBAAoB;AAE7B,SAASC,iBAAiB;AAE1B,SAASC,YAAY;AACrB,SAASC,MAAAA,WAAU;;;ACrBnB,OAAOC,WAAwD;AAE/D,SAASC,UAAU;AAInB,IAAMC,uBAAkD;EACtDC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,OAAO;AACT;AAEA,IAAMC,oBAAmF;EACvFC,YAAY;EACZC,UAAU;AACZ;AAEA,IAAMC,aAAqE;EACzEP,KAAK;EACLG,OAAO;EACPF,QAAQ;EACRC,MAAM;AACR;AAEA,IAAMM,aAAa;AACnB,IAAMC,eAAe;AACrB,IAAMC,iCAAiCF,aAAaC,gBAAgB;AAK7D,IAAME,gBAAgB,CAAC,EAAEC,MAAMC,MAAM,MAAK,MAAgC;AAC/E,QAAMC,aAAa,gBAAgBD,GAAAA,MAASL,UAAAA;AAE5C,QAAMO,cAAchB,qBAAqBa,IAAAA;AAEzC,SACE,sBAAA,cAACI,OAAAA;IACCC,OACE;MACE,oBAAoB,GAAGT,UAAAA;MACvB,iBAAiB,GAAGM,UAAAA;MACpB,mBAAmB,GAAGL,YAAAA;MACtB,qBAAqB,GAAGA,eAAe,CAAA;MACvC,4BAA4B,IAAIA,YAAAA;MAChC,qBAAqB,GAAGC,6BAAAA;IAC1B;IAEFQ,WAAWC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AYD,SAAQ,MACpD,gBAAAoD,OAAA,cAACC,OAAAA;EAAIC,WAAWE,IAAG,eAAevD,UAAAA;GAAcD,QAAAA;AAG3C,IAAM0E,gBAAgB,CAAC,EAC5BzE,YACAD,UACA,GAAG8D,MAAAA,MAEH,gBAAAV,OAAA,cAACC,OAAAA;EAAIC,WAAWE,IAAG,4BAA4BvD,UAAAA;EAAc,GAAG6D;GAC7D9D,QAAAA;;;AGzME,IAAM2E,OAAO;EAClBC,MAAMC;EACNC,MAAMC;EACNC,iBAAiBC;EACjBC,aAAaC;EACbC,gBAAgBC;EAChBC,kBAAkBC;EAClBC,WAAWC;EACXC;AACF;",
6
+ "names": ["combine", "draggable", "dropTargetForElements", "setCustomNativeDragPreview", "attachClosestEdge", "extractClosestEdge", "createContext", "React", "forwardRef", "useEffect", "useRef", "useState", "createPortal", "invariant", "Icon", "mx", "React", "mx", "edgeToOrientationMap", "top", "bottom", "left", "right", "orientationStyles", "horizontal", "vertical", "edgeStyles", "strokeSize", "terminalSize", "offsetToAlignTerminalWithLine", "DropIndicator", "edge", "gap", "lineOffset", "orientation", "div", "style", "className", "mx", "monitorForElements", "extractClosestEdge", "reorderWithEdge", "createContext", "React", "useEffect", "useState", "flushSync", "useControlledValue", "LIST_NAME", "ListProvider", "useListContext", "createContext", "ListRoot", "classNames", "children", "items", "_items", "isItem", "props", "setItems", "useControlledValue", "state", "setState", "useState", "idle", "useEffect", "monitorForElements", "canMonitor", "source", "data", "onDrop", "location", "target", "current", "dropTargets", "sourceData", "targetData", "sourceIdx", "findIndex", "item", "id", "targetIdx", "closestEdgeOfTarget", "extractClosestEdge", "flushSync", "reorderWithEdge", "list", "startIndex", "indexOfTarget", "axis", "React", "idle", "type", "stateStyles", "defaultContext", "LIST_ITEM_NAME", "ListItemProvider", "useListItemContext", "createContext", "ListItem", "children", "classNames", "item", "isItem", "dragPreview", "setState", "setRootState", "useListContext", "ref", "useRef", "dragHandleRef", "state", "useState", "useEffect", "element", "current", "invariant", "combine", "draggable", "dragHandle", "getInitialData", "onGenerateDragPreview", "nativeSetDragImage", "source", "rect", "getBoundingClientRect", "setCustomNativeDragPreview", "getOffset", "container", "height", "x", "y", "render", "style", "width", "undefined", "onDragStart", "onDrop", "dropTargetForElements", "canDrop", "data", "getData", "input", "attachClosestEdge", "allowedEdges", "getIsSticky", "onDragEnter", "self", "closestEdge", "extractClosestEdge", "onDrag", "onDragLeave", "React", "div", "className", "role", "mx", "DropIndicator", "edge", "IconButton", "forwardRef", "icon", "props", "forwardedRef", "button", "Icon", "size", "ListItemDeleteButton", "autoHide", "disabled", "ListItemDragHandle", "ListItemDragPreview", "createPortal", "ListItemWrapper", "ListItemTitle", "List", "Root", "ListRoot", "Item", "ListItem", "ItemDragPreview", "ListItemDragPreview", "ItemWrapper", "ListItemWrapper", "ItemDragHandle", "ListItemDragHandle", "ItemDeleteButton", "ListItemDeleteButton", "ItemTitle", "ListItemTitle", "IconButton"]
7
+ }
@@ -0,0 +1 @@
1
+ {"inputs":{"packages/ui/react-ui-list/src/components/List/DropIndicator.tsx":{"bytes":6988,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-list/src/components/List/ListRoot.tsx":{"bytes":8857,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-list/src/components/List/ListItem.tsx","kind":"import-statement","original":"./ListItem"}],"format":"esm"},"packages/ui/react-ui-list/src/components/List/ListItem.tsx":{"bytes":24071,"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/combine","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-list/src/components/List/DropIndicator.tsx","kind":"import-statement","original":"./DropIndicator"},{"path":"packages/ui/react-ui-list/src/components/List/ListRoot.tsx","kind":"import-statement","original":"./ListRoot"}],"format":"esm"},"packages/ui/react-ui-list/src/components/List/List.tsx":{"bytes":3478,"imports":[{"path":"packages/ui/react-ui-list/src/components/List/ListItem.tsx","kind":"import-statement","original":"./ListItem"},{"path":"packages/ui/react-ui-list/src/components/List/ListRoot.tsx","kind":"import-statement","original":"./ListRoot"}],"format":"esm"},"packages/ui/react-ui-list/src/components/List/index.ts":{"bytes":505,"imports":[{"path":"packages/ui/react-ui-list/src/components/List/List.tsx","kind":"import-statement","original":"./List"}],"format":"esm"},"packages/ui/react-ui-list/src/components/index.ts":{"bytes":500,"imports":[{"path":"packages/ui/react-ui-list/src/components/List/index.ts","kind":"import-statement","original":"./List"}],"format":"esm"},"packages/ui/react-ui-list/src/index.ts":{"bytes":503,"imports":[{"path":"packages/ui/react-ui-list/src/components/index.ts","kind":"import-statement","original":"./components"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-list/dist/lib/node-esm/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22108},"packages/ui/react-ui-list/dist/lib/node-esm/index.mjs":{"imports":[{"path":"@atlaskit/pragmatic-drag-and-drop/combine","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/invariant","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop/element/adapter","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge","kind":"import-statement","external":true},{"path":"@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge","kind":"import-statement","external":true},{"path":"@radix-ui/react-context","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react-dom","kind":"import-statement","external":true},{"path":"@dxos/react-ui","kind":"import-statement","external":true}],"exports":["List"],"entryPoint":"packages/ui/react-ui-list/src/index.ts","inputs":{"packages/ui/react-ui-list/src/components/List/ListItem.tsx":{"bytesInOutput":6314},"packages/ui/react-ui-list/src/components/List/DropIndicator.tsx":{"bytesInOutput":1702},"packages/ui/react-ui-list/src/components/List/ListRoot.tsx":{"bytesInOutput":1927},"packages/ui/react-ui-list/src/components/List/List.tsx":{"bytesInOutput":245},"packages/ui/react-ui-list/src/components/List/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-list/src/components/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-list/src/index.ts":{"bytesInOutput":0}},"bytes":10650}}}
@@ -0,0 +1,10 @@
1
+ import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/types';
2
+ import React from 'react';
3
+ /**
4
+ * This is a tailwind port of `@atlaskit/pragmatic-drag-and-drop-react-drop-indicator/box`
5
+ */
6
+ export declare const DropIndicator: ({ edge, gap }: {
7
+ edge: Edge;
8
+ gap?: string;
9
+ }) => React.JSX.Element;
10
+ //# sourceMappingURL=DropIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/DropIndicator.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,gDAAgD,CAAC;AAC3E,OAAO,KAAkD,MAAM,OAAO,CAAC;AA6BvE;;GAEG;AACH,eAAO,MAAM,aAAa,kBAA2B;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,sBA0BhF,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type IconButtonProps, ListItem, type ListItemProps, type ListItemRecord } from './ListItem';
2
+ import { type ListRootProps } from './ListRoot';
3
+ /**
4
+ * Draggable list.
5
+ * Ref: https://github.com/atlassian/pragmatic-drag-and-drop
6
+ * Ref: https://github.com/alexreardon/pdnd-react-tailwind/blob/main/src/task.tsx
7
+ */
8
+ export declare const List: {
9
+ Root: <T extends ListItemRecord>({ classNames, children, items: _items, isItem, ...props }: ListRootProps<T>) => import("react").JSX.Element;
10
+ Item: <T extends ListItemRecord>({ children, classNames, item }: ListItemProps<T>) => import("react").JSX.Element;
11
+ ItemDragPreview: <T extends ListItemRecord>({ children, }: {
12
+ children: ({ item }: {
13
+ item: T;
14
+ }) => import("react").ReactNode;
15
+ }) => import("react").ReactPortal | null;
16
+ ItemWrapper: ({ classNames, children }: import("packages/ui/react-ui/dist/types/src").ThemedClassName<import("react").PropsWithChildren>) => import("react").JSX.Element;
17
+ ItemDragHandle: () => import("react").JSX.Element;
18
+ ItemDeleteButton: ({ autoHide, classNames, ...props }: Omit<IconButtonProps, "icon"> & {
19
+ autoHide?: boolean;
20
+ }) => import("react").JSX.Element;
21
+ ItemTitle: ({ classNames, children, ...props }: import("packages/ui/react-ui/dist/types/src").ThemedClassName<import("react").PropsWithChildren<import("react").ComponentProps<"div">>>) => import("react").JSX.Element;
22
+ IconButton: import("react").ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
23
+ };
24
+ type ListItem = ListItemRecord;
25
+ export type { ListRootProps, ListItemProps, IconButtonProps, ListItem };
26
+ //# sourceMappingURL=List.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/List.tsx"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,eAAe,EACpB,QAAQ,EAIR,KAAK,aAAa,EAClB,KAAK,cAAc,EAGpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAS1D;;;;GAIG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;gBAc43J,CAAC;;;;CAL74J,CAAC;AAEF,KAAK,QAAQ,GAAG,cAAc,CAAC;AAE/B,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import '@dxos-theme';
2
+ import React from 'react';
3
+ import { type ListRootProps } from './List';
4
+ import { type TestItemType } from '../../testing';
5
+ declare const _default: {
6
+ title: string;
7
+ decorators: import("@storybook/react/*").Decorator[];
8
+ render: ({ items, ...props }: ListRootProps<TestItemType>) => React.JSX.Element;
9
+ };
10
+ export default _default;
11
+ export declare const Default: any;
12
+ export declare const Simple: any;
13
+ //# sourceMappingURL=List.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"List.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/List.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAQ,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;;;;kCAKrC,aAAa,CAAC,YAAY,CAAC;;AAmEpE,wBAKE;AAIF,eAAO,MAAM,OAAO,EAKf,GAAG,CAAC;AAET,eAAO,MAAM,MAAM,EAMd,GAAG,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { type Edge } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
2
+ import React, { type ComponentProps, type MutableRefObject, type PropsWithChildren, type ReactNode } from 'react';
3
+ import { type ThemedClassName } from '@dxos/react-ui';
4
+ export type ListItemRecord = {
5
+ id: string;
6
+ };
7
+ export type ItemState = {
8
+ type: 'idle';
9
+ } | {
10
+ type: 'preview';
11
+ container: HTMLElement;
12
+ } | {
13
+ type: 'is-dragging';
14
+ } | {
15
+ type: 'is-dragging-over';
16
+ closestEdge: Edge | null;
17
+ };
18
+ export declare const idle: ItemState;
19
+ type ListItemContext<T extends ListItemRecord> = {
20
+ item: T;
21
+ dragHandleRef: MutableRefObject<HTMLElement | null>;
22
+ };
23
+ export declare const ListItemProvider: {
24
+ (props: ListItemContext<any> & {
25
+ children: React.ReactNode;
26
+ }): import("react/jsx-runtime").JSX.Element;
27
+ displayName: string;
28
+ }, useListItemContext: (consumerName: string) => ListItemContext<any>;
29
+ export type ListItemProps<T extends ListItemRecord> = ThemedClassName<PropsWithChildren<{
30
+ item: T;
31
+ }>>;
32
+ /**
33
+ * Draggable list item.
34
+ */
35
+ export declare const ListItem: <T extends ListItemRecord>({ children, classNames, item }: ListItemProps<T>) => React.JSX.Element;
36
+ export type IconButtonProps = ThemedClassName<ComponentProps<'button'>> & {
37
+ icon: string;
38
+ };
39
+ export declare const IconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
40
+ export declare const ListItemDeleteButton: ({ autoHide, classNames, ...props }: Omit<IconButtonProps, "icon"> & {
41
+ autoHide?: boolean;
42
+ }) => React.JSX.Element;
43
+ export declare const ListItemDragHandle: () => React.JSX.Element;
44
+ export declare const ListItemDragPreview: <T extends ListItemRecord>({ children, }: {
45
+ children: ({ item }: {
46
+ item: T;
47
+ }) => ReactNode;
48
+ }) => React.ReactPortal | null;
49
+ export declare const ListItemWrapper: ({ classNames, children }: ThemedClassName<PropsWithChildren>) => React.JSX.Element;
50
+ export declare const ListItemTitle: ({ classNames, children, ...props }: ThemedClassName<PropsWithChildren<ComponentProps<"div">>>) => React.JSX.Element;
51
+ export {};
52
+ //# sourceMappingURL=ListItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/ListItem.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,uDAAuD,CAAC;AAGlF,OAAO,KAAK,EAAE,EACZ,KAAK,cAAc,EAEnB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAIf,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAOtD,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5C,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,WAAW,CAAC;CACxB,GACD;IACE,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEN,eAAO,MAAM,IAAI,EAAE,SAA4B,CAAC;AAMhD,KAAK,eAAe,CAAC,CAAC,SAAS,cAAc,IAAI;IAC/C,IAAI,EAAE,CAAC,CAAC;IACR,aAAa,EAAE,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CACrD,CAAC;AASF,eAAO,MAAO,gBAAgB;;wBA7DyD,SAAS;;;GA6DhE,kBAAkB,gDAGjD,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CACnE,iBAAiB,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC;CACT,CAAC,CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,kCAAkC,aAAa,CAAC,CAAC,CAAC,sBA2FlG,CAAC;AAMF,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3F,eAAO,MAAM,UAAU,wGAQtB,CAAC;AAEF,eAAO,MAAM,oBAAoB,uCAI9B,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,sBAWxD,CAAC;AAEF,eAAO,MAAM,kBAAkB,yBAG9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,cAAc,iBAEzD;IACD,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,KAAK,SAAS,CAAC;CAChD,6BAGA,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA8B,eAAe,CAAC,iBAAiB,CAAC,sBAE3F,CAAC;AAEF,eAAO,MAAM,aAAa,uCAIvB,eAAe,CAAC,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,sBAI3D,CAAC"}
@@ -0,0 +1,30 @@
1
+ import React, { type ReactNode } from 'react';
2
+ import { type ThemedClassName } from '@dxos/react-ui';
3
+ import { type ListItemRecord, type ItemState } from './ListItem';
4
+ type ListContext<T extends ListItemRecord> = {
5
+ isItem: (item: any) => boolean;
6
+ dragPreview?: boolean;
7
+ state: ItemState & {
8
+ item?: T;
9
+ };
10
+ setState: (state: ItemState & {
11
+ item?: T;
12
+ }) => void;
13
+ };
14
+ export declare const ListProvider: {
15
+ (props: ListContext<any> & {
16
+ children: React.ReactNode;
17
+ }): import("react/jsx-runtime").JSX.Element;
18
+ displayName: string;
19
+ }, useListContext: (consumerName: string) => ListContext<any>;
20
+ export type ListRendererProps<T extends ListItemRecord> = {
21
+ state: ListContext<T>['state'];
22
+ items: T[];
23
+ };
24
+ export type ListRootProps<T extends ListItemRecord> = ThemedClassName<{
25
+ children?: (props: ListRendererProps<T>) => ReactNode;
26
+ items?: T[];
27
+ }> & Pick<ListContext<T>, 'isItem' | 'dragPreview'>;
28
+ export declare const ListRoot: <T extends ListItemRecord>({ classNames, children, items: _items, isItem, ...props }: ListRootProps<T>) => React.JSX.Element;
29
+ export {};
30
+ //# sourceMappingURL=ListRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListRoot.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/ListRoot.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAC;AAGnE,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,KAAK,cAAc,EAAQ,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvE,KAAK,WAAW,CAAC,CAAC,SAAS,cAAc,IAAI;IAC3C,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG;QAAE,IAAI,CAAC,EAAE,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;CACrD,CAAC;AAIF,eAAO,MAAO,YAAY;;wBAlBoD,SAAS;;;GAkB3D,cAAc,4CAA8C,CAAC;AAEzF,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAAI;IACxD,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC/B,KAAK,EAAE,CAAC,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC;IACpE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IACtD,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;CACb,CAAC,GACA,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC,CAAC;AAEjD,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,cAAc,6DAM9C,aAAa,CAAC,CAAC,CAAC,sBAyClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './List';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/List/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './List';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './components';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { S } from '@dxos/echo-schema';
2
+ export declare const TestItemSchema: S.Struct<{
3
+ id: typeof S.String;
4
+ name: typeof S.String;
5
+ }>;
6
+ export type TestItemType = S.Schema.Type<typeof TestItemSchema>;
7
+ export declare const TestList: S.Struct<{
8
+ items: S.mutable<S.Array$<S.Struct<{
9
+ id: typeof S.String;
10
+ name: typeof S.String;
11
+ }>>>;
12
+ }>;
13
+ export type TestList = S.Schema.Type<typeof TestList>;
14
+ export declare const createList: (n?: number) => TestList;
15
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAGtC,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,cAAc,CAAC,CAAC;AAEhE,eAAO,MAAM,QAAQ;;;;;EAEnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEtD,eAAO,MAAM,UAAU,kBAAa,QAQlC,CAAC"}