@dxos/react-ui-list 0.6.12-main.ac23639 → 0.6.13-main.548ca8d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -16
- package/src/components/List/List.stories.tsx +2 -2
- package/dist/lib/node/index.cjs +0 -328
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node-esm/index.mjs +0 -305
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-list",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13-main.548ca8d",
|
|
4
4
|
"description": "A list component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"browser": "./dist/lib/browser/index.mjs",
|
|
12
|
-
"node": {
|
|
13
|
-
"require": "./dist/lib/node/index.cjs",
|
|
14
|
-
"default": "./dist/lib/node-esm/index.mjs"
|
|
15
|
-
},
|
|
16
12
|
"types": "./dist/types/src/index.d.ts"
|
|
17
13
|
}
|
|
18
14
|
},
|
|
@@ -31,14 +27,14 @@
|
|
|
31
27
|
"@atlaskit/pragmatic-drag-and-drop-react-drop-indicator": "^1.1.3",
|
|
32
28
|
"@radix-ui/react-context": "^1.0.0",
|
|
33
29
|
"effect": "^3.9.1",
|
|
34
|
-
"@dxos/debug": "0.6.
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/react-ui": "0.6.
|
|
39
|
-
"@dxos/react-ui-theme": "0.6.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/util": "0.6.
|
|
30
|
+
"@dxos/debug": "0.6.13-main.548ca8d",
|
|
31
|
+
"@dxos/invariant": "0.6.13-main.548ca8d",
|
|
32
|
+
"@dxos/echo-schema": "0.6.13-main.548ca8d",
|
|
33
|
+
"@dxos/react-ui": "0.6.13-main.548ca8d",
|
|
34
|
+
"@dxos/react-ui-types": "0.6.13-main.548ca8d",
|
|
35
|
+
"@dxos/react-ui-theme": "0.6.13-main.548ca8d",
|
|
36
|
+
"@dxos/log": "0.6.13-main.548ca8d",
|
|
37
|
+
"@dxos/util": "0.6.13-main.548ca8d"
|
|
42
38
|
},
|
|
43
39
|
"devDependencies": {
|
|
44
40
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -47,9 +43,9 @@
|
|
|
47
43
|
"react": "~18.2.0",
|
|
48
44
|
"react-dom": "~18.2.0",
|
|
49
45
|
"vite": "5.4.7",
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/storybook-utils": "0.6.
|
|
46
|
+
"@dxos/react-ui-theme": "0.6.13-main.548ca8d",
|
|
47
|
+
"@dxos/random": "0.6.13-main.548ca8d",
|
|
48
|
+
"@dxos/storybook-utils": "0.6.13-main.548ca8d"
|
|
53
49
|
},
|
|
54
50
|
"peerDependencies": {
|
|
55
51
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { create, S } from '@dxos/echo-schema';
|
|
10
10
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
11
|
-
import { withTheme, withLayout
|
|
11
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
13
|
import { List, type ListRootProps } from './List';
|
|
14
14
|
import { createList, TestItemSchema, type TestItemType } from '../../testing';
|
|
@@ -86,7 +86,7 @@ const SimpleStory = ({ items = [], ...props }: ListRootProps<TestItemType>) => {
|
|
|
86
86
|
export default {
|
|
87
87
|
// TODO(burdon): Storybook collides with react-ui/List.
|
|
88
88
|
title: 'react-ui-list/List',
|
|
89
|
-
decorators: [withTheme,
|
|
89
|
+
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
90
90
|
render: Story,
|
|
91
91
|
};
|
|
92
92
|
|
package/dist/lib/node/index.cjs
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var node_exports = {};
|
|
30
|
-
__export(node_exports, {
|
|
31
|
-
List: () => List
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(node_exports);
|
|
34
|
-
var import_combine = require("@atlaskit/pragmatic-drag-and-drop/combine");
|
|
35
|
-
var import_adapter = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
36
|
-
var import_set_custom_native_drag_preview = require("@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview");
|
|
37
|
-
var import_closest_edge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
38
|
-
var import_react_context = require("@radix-ui/react-context");
|
|
39
|
-
var import_react = __toESM(require("react"));
|
|
40
|
-
var import_react_dom = require("react-dom");
|
|
41
|
-
var import_invariant = require("@dxos/invariant");
|
|
42
|
-
var import_react_ui = require("@dxos/react-ui");
|
|
43
|
-
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
44
|
-
var import_react2 = __toESM(require("react"));
|
|
45
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
46
|
-
var import_adapter2 = require("@atlaskit/pragmatic-drag-and-drop/element/adapter");
|
|
47
|
-
var import_closest_edge2 = require("@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge");
|
|
48
|
-
var import_reorder_with_edge = require("@atlaskit/pragmatic-drag-and-drop-hitbox/util/reorder-with-edge");
|
|
49
|
-
var import_react_context2 = require("@radix-ui/react-context");
|
|
50
|
-
var import_react3 = __toESM(require("react"));
|
|
51
|
-
var import_react_dom2 = require("react-dom");
|
|
52
|
-
var import_react_ui2 = require("@dxos/react-ui");
|
|
53
|
-
var edgeToOrientationMap = {
|
|
54
|
-
top: "horizontal",
|
|
55
|
-
bottom: "horizontal",
|
|
56
|
-
left: "vertical",
|
|
57
|
-
right: "vertical"
|
|
58
|
-
};
|
|
59
|
-
var orientationStyles = {
|
|
60
|
-
horizontal: "h-[--line-thickness] left-[--terminal-radius] right-0 before:left-[--negative-terminal-size]",
|
|
61
|
-
vertical: "w-[--line-thickness] top-[--terminal-radius] bottom-0 before:top-[--negative-terminal-size]"
|
|
62
|
-
};
|
|
63
|
-
var edgeStyles = {
|
|
64
|
-
top: "top-[--line-offset] before:top-[--offset-terminal]",
|
|
65
|
-
right: "right-[--line-offset] before:right-[--offset-terminal]",
|
|
66
|
-
bottom: "bottom-[--line-offset] before:bottom-[--offset-terminal]",
|
|
67
|
-
left: "left-[--line-offset] before:left-[--offset-terminal]"
|
|
68
|
-
};
|
|
69
|
-
var strokeSize = 2;
|
|
70
|
-
var terminalSize = 8;
|
|
71
|
-
var offsetToAlignTerminalWithLine = (strokeSize - terminalSize) / 2;
|
|
72
|
-
var DropIndicator = ({ edge, gap = "0px" }) => {
|
|
73
|
-
const lineOffset = `calc(-0.5 * (${gap} + ${strokeSize}px))`;
|
|
74
|
-
const orientation = edgeToOrientationMap[edge];
|
|
75
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
76
|
-
style: {
|
|
77
|
-
"--line-thickness": `${strokeSize}px`,
|
|
78
|
-
"--line-offset": `${lineOffset}`,
|
|
79
|
-
"--terminal-size": `${terminalSize}px`,
|
|
80
|
-
"--terminal-radius": `${terminalSize / 2}px`,
|
|
81
|
-
"--negative-terminal-size": `-${terminalSize}px`,
|
|
82
|
-
"--offset-terminal": `${offsetToAlignTerminalWithLine}px`
|
|
83
|
-
},
|
|
84
|
-
className: (0, import_react_ui_theme2.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])
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
var LIST_NAME = "List";
|
|
88
|
-
var [ListProvider, useListContext] = (0, import_react_context2.createContext)(LIST_NAME);
|
|
89
|
-
var ListRoot = ({ classNames, children, items: _items = [], isItem, ...props }) => {
|
|
90
|
-
const [items, setItems] = (0, import_react_ui2.useControlledValue)(_items);
|
|
91
|
-
const [state, setState] = (0, import_react3.useState)(idle);
|
|
92
|
-
(0, import_react3.useEffect)(() => {
|
|
93
|
-
return (0, import_adapter2.monitorForElements)({
|
|
94
|
-
canMonitor: ({ source }) => isItem(source.data),
|
|
95
|
-
onDrop: ({ location, source }) => {
|
|
96
|
-
const target = location.current.dropTargets[0];
|
|
97
|
-
if (!target) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const sourceData = source.data;
|
|
101
|
-
const targetData = target.data;
|
|
102
|
-
if (!isItem(sourceData) || !isItem(targetData)) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const sourceIdx = items.findIndex((item) => item.id === sourceData.id);
|
|
106
|
-
const targetIdx = items.findIndex((item) => item.id === targetData.id);
|
|
107
|
-
if (targetIdx < 0 || sourceIdx < 0) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const closestEdgeOfTarget = (0, import_closest_edge2.extractClosestEdge)(targetData);
|
|
111
|
-
(0, import_react_dom2.flushSync)(() => {
|
|
112
|
-
setItems((0, import_reorder_with_edge.reorderWithEdge)({
|
|
113
|
-
list: items,
|
|
114
|
-
startIndex: sourceIdx,
|
|
115
|
-
indexOfTarget: targetIdx,
|
|
116
|
-
axis: "vertical",
|
|
117
|
-
closestEdgeOfTarget
|
|
118
|
-
}));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}, [
|
|
123
|
-
items
|
|
124
|
-
]);
|
|
125
|
-
return /* @__PURE__ */ import_react3.default.createElement(ListProvider, {
|
|
126
|
-
isItem,
|
|
127
|
-
state,
|
|
128
|
-
setState,
|
|
129
|
-
...props
|
|
130
|
-
}, children?.({
|
|
131
|
-
state,
|
|
132
|
-
items
|
|
133
|
-
}));
|
|
134
|
-
};
|
|
135
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-list/src/components/List/ListItem.tsx";
|
|
136
|
-
var idle = {
|
|
137
|
-
type: "idle"
|
|
138
|
-
};
|
|
139
|
-
var stateStyles = {
|
|
140
|
-
"is-dragging": "opacity-50"
|
|
141
|
-
};
|
|
142
|
-
var defaultContext = {};
|
|
143
|
-
var LIST_ITEM_NAME = "ListItem";
|
|
144
|
-
var [ListItemProvider, useListItemContext] = (0, import_react_context.createContext)(LIST_ITEM_NAME, defaultContext);
|
|
145
|
-
var ListItem = ({ children, classNames, item }) => {
|
|
146
|
-
const { isItem, dragPreview, setState: setRootState } = useListContext(LIST_ITEM_NAME);
|
|
147
|
-
const ref = (0, import_react.useRef)(null);
|
|
148
|
-
const dragHandleRef = (0, import_react.useRef)(null);
|
|
149
|
-
const [state, setState] = (0, import_react.useState)(idle);
|
|
150
|
-
(0, import_react.useEffect)(() => {
|
|
151
|
-
const element = ref.current;
|
|
152
|
-
(0, import_invariant.invariant)(element, void 0, {
|
|
153
|
-
F: __dxlog_file,
|
|
154
|
-
L: 89,
|
|
155
|
-
S: void 0,
|
|
156
|
-
A: [
|
|
157
|
-
"element",
|
|
158
|
-
""
|
|
159
|
-
]
|
|
160
|
-
});
|
|
161
|
-
return (0, import_combine.combine)(
|
|
162
|
-
//
|
|
163
|
-
// https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#draggable
|
|
164
|
-
//
|
|
165
|
-
(0, import_adapter.draggable)({
|
|
166
|
-
element,
|
|
167
|
-
dragHandle: dragHandleRef.current,
|
|
168
|
-
getInitialData: () => item,
|
|
169
|
-
onGenerateDragPreview: dragPreview ? ({ nativeSetDragImage, source }) => {
|
|
170
|
-
const rect = source.element.getBoundingClientRect();
|
|
171
|
-
(0, import_set_custom_native_drag_preview.setCustomNativeDragPreview)({
|
|
172
|
-
nativeSetDragImage,
|
|
173
|
-
getOffset: ({ container }) => {
|
|
174
|
-
const { height } = container.getBoundingClientRect();
|
|
175
|
-
return {
|
|
176
|
-
x: 20,
|
|
177
|
-
y: height / 2
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
render: ({ container }) => {
|
|
181
|
-
container.style.width = rect.width + "px";
|
|
182
|
-
setState({
|
|
183
|
-
type: "preview",
|
|
184
|
-
container
|
|
185
|
-
});
|
|
186
|
-
setRootState({
|
|
187
|
-
type: "preview",
|
|
188
|
-
container,
|
|
189
|
-
item
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
} : void 0,
|
|
194
|
-
onDragStart: () => {
|
|
195
|
-
setState({
|
|
196
|
-
type: "is-dragging"
|
|
197
|
-
});
|
|
198
|
-
setRootState({
|
|
199
|
-
type: "is-dragging",
|
|
200
|
-
item
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
onDrop: () => {
|
|
204
|
-
setState(idle);
|
|
205
|
-
setRootState(idle);
|
|
206
|
-
}
|
|
207
|
-
}),
|
|
208
|
-
//
|
|
209
|
-
// https://atlassian.design/components/pragmatic-drag-and-drop/core-package/adapters/element/about#drop-target-for-elements
|
|
210
|
-
//
|
|
211
|
-
(0, import_adapter.dropTargetForElements)({
|
|
212
|
-
element,
|
|
213
|
-
canDrop: ({ source }) => {
|
|
214
|
-
return source.element !== element && isItem(source.data);
|
|
215
|
-
},
|
|
216
|
-
getData: ({ input }) => {
|
|
217
|
-
return (0, import_closest_edge.attachClosestEdge)(item, {
|
|
218
|
-
element,
|
|
219
|
-
input,
|
|
220
|
-
allowedEdges: [
|
|
221
|
-
"top",
|
|
222
|
-
"bottom"
|
|
223
|
-
]
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
getIsSticky: () => true,
|
|
227
|
-
onDragEnter: ({ self }) => {
|
|
228
|
-
const closestEdge = (0, import_closest_edge.extractClosestEdge)(self.data);
|
|
229
|
-
setState({
|
|
230
|
-
type: "is-dragging-over",
|
|
231
|
-
closestEdge
|
|
232
|
-
});
|
|
233
|
-
},
|
|
234
|
-
onDrag: ({ self }) => {
|
|
235
|
-
const closestEdge = (0, import_closest_edge.extractClosestEdge)(self.data);
|
|
236
|
-
setState((current) => {
|
|
237
|
-
if (current.type === "is-dragging-over" && current.closestEdge === closestEdge) {
|
|
238
|
-
return current;
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
type: "is-dragging-over",
|
|
242
|
-
closestEdge
|
|
243
|
-
};
|
|
244
|
-
});
|
|
245
|
-
},
|
|
246
|
-
onDragLeave: () => {
|
|
247
|
-
setState(idle);
|
|
248
|
-
},
|
|
249
|
-
onDrop: () => {
|
|
250
|
-
setState(idle);
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
);
|
|
254
|
-
}, [
|
|
255
|
-
item
|
|
256
|
-
]);
|
|
257
|
-
return /* @__PURE__ */ import_react.default.createElement(ListItemProvider, {
|
|
258
|
-
item,
|
|
259
|
-
dragHandleRef
|
|
260
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
261
|
-
className: "relative"
|
|
262
|
-
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
263
|
-
ref,
|
|
264
|
-
role: "listitem",
|
|
265
|
-
className: (0, import_react_ui_theme.mx)("flex", classNames, stateStyles[state.type])
|
|
266
|
-
}, children), state.type === "is-dragging-over" && state.closestEdge && /* @__PURE__ */ import_react.default.createElement(DropIndicator, {
|
|
267
|
-
edge: state.closestEdge
|
|
268
|
-
})));
|
|
269
|
-
};
|
|
270
|
-
var IconButton = /* @__PURE__ */ (0, import_react.forwardRef)(({ classNames, icon, ...props }, forwardedRef) => {
|
|
271
|
-
return /* @__PURE__ */ import_react.default.createElement("button", {
|
|
272
|
-
ref: forwardedRef,
|
|
273
|
-
className: (0, import_react_ui_theme.mx)("flex items-center justify-center", classNames),
|
|
274
|
-
...props
|
|
275
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Icon, {
|
|
276
|
-
icon,
|
|
277
|
-
classNames: "cursor-pointer",
|
|
278
|
-
size: 4
|
|
279
|
-
}));
|
|
280
|
-
});
|
|
281
|
-
var ListItemDeleteButton = ({ autoHide = true, classNames, ...props }) => {
|
|
282
|
-
const { state } = useListContext("DELETE_BUTTON");
|
|
283
|
-
const disabled = state.type !== "idle";
|
|
284
|
-
return /* @__PURE__ */ import_react.default.createElement(IconButton, {
|
|
285
|
-
icon: "ph--x--regular",
|
|
286
|
-
disabled,
|
|
287
|
-
classNames: [
|
|
288
|
-
classNames,
|
|
289
|
-
autoHide && disabled && "hidden"
|
|
290
|
-
],
|
|
291
|
-
...props
|
|
292
|
-
});
|
|
293
|
-
};
|
|
294
|
-
var ListItemDragHandle = () => {
|
|
295
|
-
const { dragHandleRef } = useListItemContext("DRAG_HANDLE");
|
|
296
|
-
return /* @__PURE__ */ import_react.default.createElement(IconButton, {
|
|
297
|
-
ref: dragHandleRef,
|
|
298
|
-
icon: "ph--dots-six--regular"
|
|
299
|
-
});
|
|
300
|
-
};
|
|
301
|
-
var ListItemDragPreview = ({ children }) => {
|
|
302
|
-
const { state } = useListContext("DRAG_PREVIEW");
|
|
303
|
-
return state?.type === "preview" ? /* @__PURE__ */ (0, import_react_dom.createPortal)(children({
|
|
304
|
-
item: state.item
|
|
305
|
-
}), state.container) : null;
|
|
306
|
-
};
|
|
307
|
-
var ListItemWrapper = ({ classNames, children }) => /* @__PURE__ */ import_react.default.createElement("div", {
|
|
308
|
-
className: (0, import_react_ui_theme.mx)("flex w-full", classNames)
|
|
309
|
-
}, children);
|
|
310
|
-
var ListItemTitle = ({ classNames, children, ...props }) => /* @__PURE__ */ import_react.default.createElement("div", {
|
|
311
|
-
className: (0, import_react_ui_theme.mx)("flex w-full items-center", classNames),
|
|
312
|
-
...props
|
|
313
|
-
}, children);
|
|
314
|
-
var List = {
|
|
315
|
-
Root: ListRoot,
|
|
316
|
-
Item: ListItem,
|
|
317
|
-
ItemDragPreview: ListItemDragPreview,
|
|
318
|
-
ItemWrapper: ListItemWrapper,
|
|
319
|
-
ItemDragHandle: ListItemDragHandle,
|
|
320
|
-
ItemDeleteButton: ListItemDeleteButton,
|
|
321
|
-
ItemTitle: ListItemTitle,
|
|
322
|
-
IconButton
|
|
323
|
-
};
|
|
324
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
325
|
-
0 && (module.exports = {
|
|
326
|
-
List
|
|
327
|
-
});
|
|
328
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
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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GAAGI,MAAAA,MAEHf,6BAAAA,QAAA,cAACC,OAAAA;EAAIE,eAAWC,sBAAAA,IAAG,4BAA4BM,UAAAA;EAAc,GAAGK;GAC7DJ,QAAAA;AGzME,IAAMgG,OAAO;EAClBC,MAAMnG;EACNoG,MAAMxD;EACNyD,iBAAiBP;EACjBQ,aAAaN;EACbO,gBAAgBV;EAChBW,kBAAkBd;EAClBe,WAAWR;EACXd;AACF;",
|
|
6
|
-
"names": ["import_react", "import_react_ui_theme", "import_adapter", "import_closest_edge", "import_react_context", "import_react_dom", "import_react_ui", "edgeToOrientationMap", "top", "bottom", "left", "right", "orientationStyles", "horizontal", "vertical", "edgeStyles", "strokeSize", "terminalSize", "offsetToAlignTerminalWithLine", "DropIndicator", "edge", "gap", "lineOffset", "orientation", "React", "div", "style", "className", "mx", "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", "type", "stateStyles", "defaultContext", "LIST_ITEM_NAME", "ListItemProvider", "useListItemContext", "ListItem", "dragPreview", "setRootState", "ref", "useRef", "dragHandleRef", "element", "invariant", "combine", "draggable", "dragHandle", "getInitialData", "onGenerateDragPreview", "nativeSetDragImage", "rect", "getBoundingClientRect", "setCustomNativeDragPreview", "getOffset", "container", "height", "x", "y", "render", "width", "undefined", "onDragStart", "dropTargetForElements", "canDrop", "getData", "input", "attachClosestEdge", "allowedEdges", "getIsSticky", "onDragEnter", "self", "closestEdge", "onDrag", "onDragLeave", "role", "IconButton", "forwardRef", "icon", "forwardedRef", "button", "Icon", "size", "ListItemDeleteButton", "autoHide", "disabled", "ListItemDragHandle", "ListItemDragPreview", "createPortal", "ListItemWrapper", "ListItemTitle", "List", "Root", "Item", "ItemDragPreview", "ItemWrapper", "ItemDragHandle", "ItemDeleteButton", "ItemTitle"]
|
|
7
|
-
}
|
package/dist/lib/node/meta.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":22106},"packages/ui/react-ui-list/dist/lib/node/index.cjs":{"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":10557}}}
|
|
@@ -1,305 +0,0 @@
|
|
|
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
|
|
@@ -1,7 +0,0 @@
|
|
|
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,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a,IAAKb,mBAAmB,aAAA;AAC7C,SAAO,gBAAAuD,OAAA,cAACO,YAAAA;IAAWnD,KAAKE;IAAsBmD,MAAK;;AACrD;AAEO,IAAMU,sBAAsB,CAA2B,EAC5DvE,SAAQ,MAGT;AACC,QAAM,EAAEW,MAAK,IAAKJ,eAAe,cAAA;AACjC,SAAOI,OAAOnB,SAAS,YAAYgF,6BAAaxE,SAAS;IAAEE,MAAMS,MAAMT;EAAK,CAAA,GAAIS,MAAMiB,SAAS,IAAI;AACrG;AAEO,IAAM6C,kBAAkB,CAAC,EAAExE,YAAYD,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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
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}}}
|