@dxos/react-ui-mosaic 0.7.5-main.ff8607b → 0.8.4-main.69d29f4
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/README.md +2 -44
- package/dist/lib/browser/chunk-4VDZJ3HV.mjs +1639 -0
- package/dist/lib/browser/chunk-4VDZJ3HV.mjs.map +7 -0
- package/dist/lib/browser/index.css +13 -0
- package/dist/lib/browser/index.css.map +7 -0
- package/dist/lib/browser/index.mjs +85 -689
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.css +13 -0
- package/dist/lib/browser/testing/index.css.map +7 -0
- package/dist/lib/browser/testing/index.mjs +306 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KONKDEUD.mjs +1641 -0
- package/dist/lib/node-esm/chunk-KONKDEUD.mjs.map +7 -0
- package/dist/lib/node-esm/index.css +13 -0
- package/dist/lib/node-esm/index.css.map +7 -0
- package/dist/lib/node-esm/index.mjs +85 -690
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.css +13 -0
- package/dist/lib/node-esm/testing/index.css.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +307 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/components/Card/Card.d.ts +120 -0
- package/dist/types/src/components/Card/Card.d.ts.map +1 -0
- package/dist/types/src/components/Card/Card.stories.d.ts +21 -0
- package/dist/types/src/components/Card/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Card/CardDragPreview.d.ts +6 -0
- package/dist/types/src/components/Card/CardDragPreview.d.ts.map +1 -0
- package/dist/types/src/components/Card/index.d.ts +4 -0
- package/dist/types/src/components/Card/index.d.ts.map +1 -0
- package/dist/types/src/components/Card/styles.d.ts +13 -0
- package/dist/types/src/components/Card/styles.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +25 -0
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -0
- package/dist/types/src/components/Focus/index.d.ts +3 -0
- package/dist/types/src/components/Focus/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/styles.d.ts +6 -0
- package/dist/types/src/components/Focus/styles.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.d.ts +14 -0
- package/dist/types/src/components/Image/Image.d.ts.map +1 -0
- package/dist/types/src/components/Image/Image.stories.d.ts +33 -0
- package/dist/types/src/components/Image/Image.stories.d.ts.map +1 -0
- package/dist/types/src/components/Image/index.d.ts +2 -0
- package/dist/types/src/components/Image/index.d.ts.map +1 -0
- package/dist/types/src/components/Layout/Layout.d.ts +33 -0
- package/dist/types/src/components/Layout/Layout.d.ts.map +1 -0
- package/dist/types/src/components/Layout/Layout.stories.d.ts +10 -0
- package/dist/types/src/components/Layout/Layout.stories.d.ts.map +1 -0
- package/dist/types/src/components/Layout/index.d.ts +2 -0
- package/dist/types/src/components/Layout/index.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +141 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts +27 -0
- package/dist/types/src/components/Mosaic/Mosaic.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/extension.d.ts +20 -0
- package/dist/types/src/components/Mosaic/extension.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/index.d.ts +5 -0
- package/dist/types/src/components/Mosaic/index.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/styles.d.ts +7 -0
- package/dist/types/src/components/Mosaic/styles.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/types.d.ts +79 -0
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -0
- package/dist/types/src/components/Scrollable/Scrollable.d.ts +17 -0
- package/dist/types/src/components/Scrollable/Scrollable.d.ts.map +1 -0
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts +8 -0
- package/dist/types/src/components/Scrollable/Scrollable.stories.d.ts.map +1 -0
- package/dist/types/src/components/Scrollable/index.d.ts +2 -0
- package/dist/types/src/components/Scrollable/index.d.ts.map +1 -0
- package/dist/types/src/components/Stack/Stack.d.ts +24 -0
- package/dist/types/src/components/Stack/Stack.d.ts.map +1 -0
- package/dist/types/src/components/Stack/Stack.stories.d.ts +9 -0
- package/dist/types/src/components/Stack/Stack.stories.d.ts.map +1 -0
- package/dist/types/src/components/Stack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +7 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useContainerDebug.d.ts +9 -0
- package/dist/types/src/hooks/useContainerDebug.d.ts.map +1 -0
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +32 -0
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -0
- package/dist/types/src/hooks/useVisibleItems.d.ts +16 -0
- package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/Board.d.ts +45 -0
- package/dist/types/src/testing/Board.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +17 -0
- package/dist/types/src/testing/CardContainer.d.ts.map +1 -0
- package/dist/types/src/testing/DefaultStackTile.d.ts +4 -0
- package/dist/types/src/testing/DefaultStackTile.d.ts.map +1 -0
- package/dist/types/src/testing/Slot.stories.d.ts +14 -0
- package/dist/types/src/testing/Slot.stories.d.ts.map +1 -0
- package/dist/types/src/testing/Virtualizer.stories.d.ts +12 -0
- package/dist/types/src/testing/Virtualizer.stories.d.ts.map +1 -0
- package/dist/types/src/testing/decorator.d.ts +3 -0
- package/dist/types/src/testing/decorator.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +7 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +63 -40
- package/src/components/Card/Card.stories.tsx +148 -0
- package/src/components/Card/Card.tsx +435 -0
- package/src/components/Card/CardDragPreview.tsx +23 -0
- package/src/components/Card/index.ts +8 -0
- package/src/components/Card/styles.ts +23 -0
- package/src/components/Focus/Focus.tsx +95 -0
- package/src/components/Focus/index.ts +7 -0
- package/src/components/Focus/styles.ts +24 -0
- package/src/components/Image/Image.stories.tsx +86 -0
- package/src/components/Image/Image.tsx +223 -0
- package/src/components/Image/index.ts +5 -0
- package/src/components/Layout/Layout.stories.tsx +59 -0
- package/src/components/Layout/Layout.tsx +108 -0
- package/src/components/Layout/index.ts +5 -0
- package/src/components/Mosaic/Mosaic.stories.tsx +113 -0
- package/src/components/Mosaic/Mosaic.tsx +930 -0
- package/src/components/Mosaic/extension.ts +141 -0
- package/src/components/Mosaic/index.ts +10 -0
- package/src/components/Mosaic/styles.ts +31 -0
- package/src/components/Mosaic/types.ts +82 -0
- package/src/components/Scrollable/Scrollable.stories.tsx +33 -0
- package/src/components/Scrollable/Scrollable.tsx +99 -0
- package/src/components/Scrollable/index.ts +5 -0
- package/src/components/Scrollable/scrollable.css +20 -0
- package/src/components/Stack/Stack.stories.tsx +115 -0
- package/src/components/Stack/Stack.tsx +210 -0
- package/src/{views → components}/Stack/index.ts +1 -1
- package/src/components/index.ts +10 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useContainerDebug.tsx +46 -0
- package/src/hooks/useEventHandlerAdapter.ts +99 -0
- package/src/hooks/useVisibleItems.ts +43 -0
- package/src/index.ts +3 -2
- package/src/testing/Board.tsx +278 -0
- package/src/testing/CardContainer.tsx +88 -0
- package/src/testing/DefaultStackTile.tsx +38 -0
- package/src/testing/Slot.stories.tsx +101 -0
- package/src/testing/Virtualizer.stories.tsx +133 -0
- package/src/testing/decorator.tsx +16 -0
- package/src/testing/index.ts +5 -3
- package/src/translations.ts +15 -0
- package/dist/lib/node/index.cjs +0 -705
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/mosaic/Container.d.ts +0 -94
- package/dist/types/src/mosaic/Container.d.ts.map +0 -1
- package/dist/types/src/mosaic/Debug.d.ts +0 -9
- package/dist/types/src/mosaic/Debug.d.ts.map +0 -1
- package/dist/types/src/mosaic/DefaultComponent.d.ts +0 -4
- package/dist/types/src/mosaic/DefaultComponent.d.ts.map +0 -1
- package/dist/types/src/mosaic/DragOverlay.d.ts +0 -11
- package/dist/types/src/mosaic/DragOverlay.d.ts.map +0 -1
- package/dist/types/src/mosaic/Mosaic.d.ts +0 -34
- package/dist/types/src/mosaic/Mosaic.d.ts.map +0 -1
- package/dist/types/src/mosaic/Root.d.ts +0 -28
- package/dist/types/src/mosaic/Root.d.ts.map +0 -1
- package/dist/types/src/mosaic/SortableContext.d.ts +0 -14
- package/dist/types/src/mosaic/SortableContext.d.ts.map +0 -1
- package/dist/types/src/mosaic/Tile.d.ts +0 -74
- package/dist/types/src/mosaic/Tile.d.ts.map +0 -1
- package/dist/types/src/mosaic/hooks/index.d.ts +0 -5
- package/dist/types/src/mosaic/hooks/index.d.ts.map +0 -1
- package/dist/types/src/mosaic/hooks/useContainer.d.ts +0 -4
- package/dist/types/src/mosaic/hooks/useContainer.d.ts.map +0 -1
- package/dist/types/src/mosaic/hooks/useItemsWithOrigin.d.ts +0 -3
- package/dist/types/src/mosaic/hooks/useItemsWithOrigin.d.ts.map +0 -1
- package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts +0 -10
- package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts.map +0 -1
- package/dist/types/src/mosaic/hooks/useMosaic.d.ts +0 -2
- package/dist/types/src/mosaic/hooks/useMosaic.d.ts.map +0 -1
- package/dist/types/src/mosaic/index.d.ts +0 -5
- package/dist/types/src/mosaic/index.d.ts.map +0 -1
- package/dist/types/src/mosaic/types.d.ts +0 -10
- package/dist/types/src/mosaic/types.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/data.d.ts +0 -3
- package/dist/types/src/mosaic/util/data.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/index.d.ts +0 -5
- package/dist/types/src/mosaic/util/index.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/path.d.ts +0 -14
- package/dist/types/src/mosaic/util/path.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/path.test.d.ts +0 -2
- package/dist/types/src/mosaic/util/path.test.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/props.d.ts +0 -4
- package/dist/types/src/mosaic/util/props.d.ts.map +0 -1
- package/dist/types/src/mosaic/util/styles.d.ts +0 -3
- package/dist/types/src/mosaic/util/styles.d.ts.map +0 -1
- package/dist/types/src/testing/Cards.d.ts +0 -10
- package/dist/types/src/testing/Cards.d.ts.map +0 -1
- package/dist/types/src/testing/generator.d.ts +0 -35
- package/dist/types/src/testing/generator.d.ts.map +0 -1
- package/dist/types/src/views/Demo/Demo.stories.d.ts +0 -14
- package/dist/types/src/views/Demo/Demo.stories.d.ts.map +0 -1
- package/dist/types/src/views/Demo/Echo.stories.d.ts +0 -8
- package/dist/types/src/views/Demo/Echo.stories.d.ts.map +0 -1
- package/dist/types/src/views/Grid/Grid.d.ts +0 -31
- package/dist/types/src/views/Grid/Grid.d.ts.map +0 -1
- package/dist/types/src/views/Grid/Grid.stories.d.ts +0 -14
- package/dist/types/src/views/Grid/Grid.stories.d.ts.map +0 -1
- package/dist/types/src/views/Grid/index.d.ts +0 -3
- package/dist/types/src/views/Grid/index.d.ts.map +0 -1
- package/dist/types/src/views/Grid/layout.d.ts +0 -27
- package/dist/types/src/views/Grid/layout.d.ts.map +0 -1
- package/dist/types/src/views/Grid/testing.d.ts +0 -11
- package/dist/types/src/views/Grid/testing.d.ts.map +0 -1
- package/dist/types/src/views/Kanban/Kanban.d.ts +0 -12
- package/dist/types/src/views/Kanban/Kanban.d.ts.map +0 -1
- package/dist/types/src/views/Kanban/Kanban.stories.d.ts +0 -29
- package/dist/types/src/views/Kanban/Kanban.stories.d.ts.map +0 -1
- package/dist/types/src/views/Kanban/index.d.ts +0 -2
- package/dist/types/src/views/Kanban/index.d.ts.map +0 -1
- package/dist/types/src/views/Kanban/testing.d.ts +0 -12
- package/dist/types/src/views/Kanban/testing.d.ts.map +0 -1
- package/dist/types/src/views/Stack/Columns.stories.d.ts +0 -34
- package/dist/types/src/views/Stack/Columns.stories.d.ts.map +0 -1
- package/dist/types/src/views/Stack/Stack.d.ts +0 -10
- package/dist/types/src/views/Stack/Stack.d.ts.map +0 -1
- package/dist/types/src/views/Stack/Stack.stories.d.ts +0 -40
- package/dist/types/src/views/Stack/Stack.stories.d.ts.map +0 -1
- package/dist/types/src/views/Stack/index.d.ts.map +0 -1
- package/dist/types/src/views/Stack/testing.d.ts +0 -10
- package/dist/types/src/views/Stack/testing.d.ts.map +0 -1
- package/dist/types/src/views/Tree/Graph.stories.d.ts +0 -11
- package/dist/types/src/views/Tree/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/views/Tree/Tree.d.ts +0 -13
- package/dist/types/src/views/Tree/Tree.d.ts.map +0 -1
- package/dist/types/src/views/Tree/Tree.stories.d.ts +0 -42
- package/dist/types/src/views/Tree/Tree.stories.d.ts.map +0 -1
- package/dist/types/src/views/Tree/index.d.ts +0 -2
- package/dist/types/src/views/Tree/index.d.ts.map +0 -1
- package/dist/types/src/views/Tree/testing.d.ts +0 -11
- package/dist/types/src/views/Tree/testing.d.ts.map +0 -1
- package/dist/types/src/views/index.d.ts +0 -5
- package/dist/types/src/views/index.d.ts.map +0 -1
- package/src/mosaic/Container.tsx +0 -190
- package/src/mosaic/Debug.tsx +0 -24
- package/src/mosaic/DefaultComponent.tsx +0 -26
- package/src/mosaic/DragOverlay.tsx +0 -150
- package/src/mosaic/Mosaic.ts +0 -100
- package/src/mosaic/Root.tsx +0 -320
- package/src/mosaic/SortableContext.tsx +0 -61
- package/src/mosaic/Tile.tsx +0 -207
- package/src/mosaic/hooks/index.ts +0 -8
- package/src/mosaic/hooks/useContainer.ts +0 -13
- package/src/mosaic/hooks/useItemsWithOrigin.ts +0 -33
- package/src/mosaic/hooks/useItemsWithPreview.ts +0 -69
- package/src/mosaic/hooks/useMosaic.ts +0 -11
- package/src/mosaic/index.ts +0 -9
- package/src/mosaic/types.ts +0 -15
- package/src/mosaic/util/data.ts +0 -19
- package/src/mosaic/util/index.ts +0 -8
- package/src/mosaic/util/path.test.ts +0 -24
- package/src/mosaic/util/path.ts +0 -21
- package/src/mosaic/util/props.ts +0 -14
- package/src/mosaic/util/styles.ts +0 -10
- package/src/testing/Cards.tsx +0 -88
- package/src/testing/generator.ts +0 -131
- package/src/views/Demo/Demo.stories.tsx +0 -81
- package/src/views/Demo/Echo.stories.tsx +0 -75
- package/src/views/Grid/Grid.stories.tsx +0 -51
- package/src/views/Grid/Grid.tsx +0 -265
- package/src/views/Grid/index.ts +0 -7
- package/src/views/Grid/layout.ts +0 -42
- package/src/views/Grid/testing.tsx +0 -92
- package/src/views/Kanban/Kanban.stories.tsx +0 -51
- package/src/views/Kanban/Kanban.tsx +0 -139
- package/src/views/Kanban/index.ts +0 -5
- package/src/views/Kanban/testing.tsx +0 -234
- package/src/views/Stack/Columns.stories.tsx +0 -63
- package/src/views/Stack/Stack.stories.tsx +0 -65
- package/src/views/Stack/Stack.tsx +0 -58
- package/src/views/Stack/testing.tsx +0 -77
- package/src/views/Tree/Graph.stories.tsx +0 -37
- package/src/views/Tree/Tree.stories.tsx +0 -95
- package/src/views/Tree/Tree.tsx +0 -126
- package/src/views/Tree/index.ts +0 -5
- package/src/views/Tree/testing.tsx +0 -142
- package/src/views/index.ts +0 -8
- /package/dist/types/src/{views → components}/Stack/index.d.ts +0 -0
|
@@ -1,703 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
transitionDuration,
|
|
28
|
-
modifier,
|
|
29
|
-
getOverlayProps,
|
|
30
|
-
getOverlayStyle,
|
|
31
|
-
onOver,
|
|
32
|
-
onDrop,
|
|
33
|
-
onMove,
|
|
34
|
-
onDragEnd
|
|
35
|
-
};
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
mosaic.setContainer(container.id, container);
|
|
38
|
-
return () => {
|
|
39
|
-
};
|
|
40
|
-
}, Object.values(container));
|
|
41
|
-
return /* @__PURE__ */ React.createElement(MosaicContainerContext.Provider, {
|
|
42
|
-
value: container
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
Focus,
|
|
4
|
+
Image,
|
|
5
|
+
Mosaic,
|
|
6
|
+
Stack,
|
|
7
|
+
VirtualStack,
|
|
8
|
+
dropHandler,
|
|
9
|
+
styles,
|
|
10
|
+
styles2,
|
|
11
|
+
styles3,
|
|
12
|
+
useContainerContext,
|
|
13
|
+
useContainerDebug,
|
|
14
|
+
useEventHandlerAdapter,
|
|
15
|
+
useFocus,
|
|
16
|
+
useRootContext,
|
|
17
|
+
useTileContext,
|
|
18
|
+
useVisibleItems
|
|
19
|
+
} from "./chunk-4VDZJ3HV.mjs";
|
|
20
|
+
|
|
21
|
+
// src/components/Card/CardDragPreview.tsx
|
|
22
|
+
import React from "react";
|
|
23
|
+
import { mx } from "@dxos/ui-theme";
|
|
24
|
+
var CardDragPreviewRoot = ({ children }) => {
|
|
25
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
26
|
+
className: "p-2"
|
|
43
27
|
}, children);
|
|
44
28
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
|
|
50
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
51
|
-
|
|
52
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
|
|
53
|
-
import { useContext as useContext2 } from "react";
|
|
54
|
-
import { raise } from "@dxos/debug";
|
|
55
|
-
|
|
56
|
-
// packages/ui/react-ui-mosaic/src/mosaic/Root.tsx
|
|
57
|
-
import { DndContext, KeyboardSensor, MouseSensor, pointerWithin, rectIntersection, TouchSensor, useSensor, useSensors } from "@dnd-kit/core";
|
|
58
|
-
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
|
59
|
-
import React4, { createContext as createContext2, useState } from "react";
|
|
60
|
-
import { createPortal } from "react-dom";
|
|
61
|
-
import { pick } from "@dxos/util";
|
|
62
|
-
|
|
63
|
-
// packages/ui/react-ui-mosaic/src/mosaic/Debug.tsx
|
|
64
|
-
import React2 from "react";
|
|
65
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
66
|
-
var Debug = ({ data, position }) => /* @__PURE__ */ React2.createElement("pre", {
|
|
67
|
-
className: mx("font-mono text-xs overflow-hidden m-2 p-1 z-[100]", "bg-neutral-50 dark:bg-neutral-700 border border-neutral-300 rounded", position === "bottom-left" && "fixed left-0 bottom-0", position === "bottom-right" && "fixed right-0 bottom-0")
|
|
68
|
-
}, JSON.stringify(data, void 0, 1));
|
|
69
|
-
|
|
70
|
-
// packages/ui/react-ui-mosaic/src/mosaic/DefaultComponent.tsx
|
|
71
|
-
import React3, { forwardRef as forwardRef2 } from "react";
|
|
72
|
-
import { Card } from "@dxos/react-ui-card";
|
|
73
|
-
|
|
74
|
-
// packages/ui/react-ui-mosaic/src/mosaic/util/data.ts
|
|
75
|
-
import { arrayMove } from "@dxos/util";
|
|
76
|
-
var swapItems = (items, from, to) => {
|
|
77
|
-
const fromIndex = items.findIndex((item) => item.id === from.id);
|
|
78
|
-
const toIndex = items.findIndex((item) => item.id === to.id);
|
|
79
|
-
return fromIndex !== -1 && toIndex !== -1 ? arrayMove(items, fromIndex, toIndex) : items;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// packages/ui/react-ui-mosaic/src/mosaic/util/path.ts
|
|
83
|
-
var SEPARATOR = "~";
|
|
84
|
-
var Path = {
|
|
85
|
-
create: (...args) => args.join(SEPARATOR),
|
|
86
|
-
parts: (path) => path.split(SEPARATOR),
|
|
87
|
-
length: (path) => path.split(SEPARATOR).length,
|
|
88
|
-
first: (path) => path.split(SEPARATOR)[0] ?? path,
|
|
89
|
-
last: (path) => path.split(SEPARATOR).at(-1) ?? path,
|
|
90
|
-
parent: (path) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
|
|
91
|
-
hasRoot: (path, id) => Path.first(path) === id,
|
|
92
|
-
hasChild: (path, compare) => Path.parent(compare) === path,
|
|
93
|
-
hasDescendent: (path, compare) => compare !== path && compare.startsWith(path),
|
|
94
|
-
siblings: (path, compare) => Path.parent(path) === Path.parent(compare),
|
|
95
|
-
onPath: (path, id) => Path.parts(path).includes(id)
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// packages/ui/react-ui-mosaic/src/mosaic/util/props.ts
|
|
99
|
-
var isTileProps = (props) => typeof props.path === "string" && typeof props.item === "object" && props.item ? "id" in props.item && typeof props.item.id === "string" : false;
|
|
100
|
-
var isTileComponentProps = (props) => isTileProps(props) && typeof props.operation === "string" && MosaicOperations.includes(props.operation);
|
|
101
|
-
|
|
102
|
-
// packages/ui/react-ui-mosaic/src/mosaic/util/styles.ts
|
|
103
|
-
import { CSS } from "@dnd-kit/utilities";
|
|
104
|
-
var getTransformCSS = (transform) => transform ? CSS.Transform.toString(Object.assign(transform, {
|
|
105
|
-
scaleX: 1,
|
|
106
|
-
scaleY: 1
|
|
107
|
-
})) : void 0;
|
|
108
|
-
|
|
109
|
-
// packages/ui/react-ui-mosaic/src/mosaic/DefaultComponent.tsx
|
|
110
|
-
var DefaultComponent = /* @__PURE__ */ forwardRef2(({ draggableStyle, draggableProps, item: { id }, path }, forwardRef4) => {
|
|
111
|
-
return /* @__PURE__ */ React3.createElement(Card.Root, {
|
|
112
|
-
ref: forwardRef4,
|
|
113
|
-
style: draggableStyle
|
|
114
|
-
}, /* @__PURE__ */ React3.createElement(Card.Header, null, /* @__PURE__ */ React3.createElement(Card.DragHandle, draggableProps), /* @__PURE__ */ React3.createElement(Card.Title, {
|
|
115
|
-
title: Path.create(path, id),
|
|
116
|
-
classNames: "truncate font-mono text-xs"
|
|
117
|
-
})));
|
|
118
|
-
});
|
|
119
|
-
DefaultComponent.displayName = "DefaultComponent";
|
|
120
|
-
|
|
121
|
-
// packages/ui/react-ui-mosaic/src/mosaic/Root.tsx
|
|
122
|
-
var DEFAULT_COMPONENT_ID = "__default";
|
|
123
|
-
var MosaicContext = /* @__PURE__ */ createContext2(void 0);
|
|
124
|
-
var defaultDropAnimation = {
|
|
125
|
-
duration: 0
|
|
126
|
-
};
|
|
127
|
-
var MosaicRoot = ({ Component: Component2 = DefaultComponent, debug, children }) => {
|
|
128
|
-
const [containers, setContainers] = useState({
|
|
129
|
-
[DEFAULT_COMPONENT_ID]: {
|
|
130
|
-
id: DEFAULT_COMPONENT_ID,
|
|
131
|
-
Component: Component2
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
const handleSetContainer = (id, container) => {
|
|
135
|
-
setContainers((containers2) => {
|
|
136
|
-
if (container) {
|
|
137
|
-
return {
|
|
138
|
-
...containers2,
|
|
139
|
-
[id]: container
|
|
140
|
-
};
|
|
141
|
-
} else {
|
|
142
|
-
const { [id]: _, ...rest } = containers2;
|
|
143
|
-
return rest;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
const [activeItem, setActiveItem] = useState();
|
|
148
|
-
const [overItem, setOverItem] = useState();
|
|
149
|
-
const [operation, setOperation] = useState("reject");
|
|
150
|
-
const [moveDetails, setMoveDetails] = useState();
|
|
151
|
-
const [dropAnimation, setDropAnimation] = useState(defaultDropAnimation);
|
|
152
|
-
const collisionDetection = (args) => {
|
|
153
|
-
const pointerCollisions = pointerWithin(args);
|
|
154
|
-
if (pointerCollisions.length > 0) {
|
|
155
|
-
return pointerCollisions;
|
|
156
|
-
}
|
|
157
|
-
return rectIntersection(args);
|
|
158
|
-
};
|
|
159
|
-
const modifiers = (props) => {
|
|
160
|
-
const { transform } = props;
|
|
161
|
-
if (activeItem) {
|
|
162
|
-
const container = containers[Path.first(activeItem.path)];
|
|
163
|
-
return container?.modifier?.(activeItem, props) ?? transform;
|
|
164
|
-
} else {
|
|
165
|
-
return transform;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const sensors = useSensors(useSensor(MouseSensor, {
|
|
169
|
-
activationConstraint: {
|
|
170
|
-
distance: 10
|
|
171
|
-
}
|
|
172
|
-
}), useSensor(TouchSensor, {
|
|
173
|
-
activationConstraint: {
|
|
174
|
-
delay: 200,
|
|
175
|
-
tolerance: 5
|
|
176
|
-
}
|
|
177
|
-
}), useSensor(KeyboardSensor, {
|
|
178
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
179
|
-
}));
|
|
180
|
-
const handleDragStart = (event) => {
|
|
181
|
-
setActiveItem(pick(event.active.data.current, [
|
|
182
|
-
"path",
|
|
183
|
-
"type",
|
|
184
|
-
"item",
|
|
185
|
-
"position"
|
|
186
|
-
]));
|
|
187
|
-
};
|
|
188
|
-
const handleDragMove = (event) => {
|
|
189
|
-
const nextOverItem = pick(event.over?.data.current, [
|
|
190
|
-
"path",
|
|
191
|
-
"type",
|
|
192
|
-
"item",
|
|
193
|
-
"position"
|
|
194
|
-
]);
|
|
195
|
-
const nextOverContainer = nextOverItem && nextOverItem?.path ? containers[Path.first(nextOverItem.path)] : void 0;
|
|
196
|
-
if (!event.over || !nextOverItem || !nextOverContainer) {
|
|
197
|
-
setOperation("reject");
|
|
198
|
-
setOverItem(void 0);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (overItem !== nextOverItem) {
|
|
202
|
-
setOverItem(nextOverItem);
|
|
203
|
-
}
|
|
204
|
-
if (activeItem && nextOverItem && nextOverContainer?.onMove) {
|
|
205
|
-
const { operation: nextOperation, details: nextDetails } = nextOverContainer.onMove({
|
|
206
|
-
active: activeItem,
|
|
207
|
-
over: nextOverItem,
|
|
208
|
-
details: {
|
|
209
|
-
delta: event.delta
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
setOperation(nextOperation);
|
|
213
|
-
if (
|
|
214
|
-
// always set falsy symbols
|
|
215
|
-
!nextDetails || // always set if details become truthy
|
|
216
|
-
!moveDetails && nextDetails || // only update if details change
|
|
217
|
-
Object.entries(nextDetails).find(([key, value]) => !(key in moveDetails) || moveDetails[key] !== value)
|
|
218
|
-
) {
|
|
219
|
-
setMoveDetails(nextDetails);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
const handleDragOver = (event) => {
|
|
224
|
-
const overItem2 = pick(event.over?.data.current, [
|
|
225
|
-
"path",
|
|
226
|
-
"type",
|
|
227
|
-
"item",
|
|
228
|
-
"position"
|
|
229
|
-
]);
|
|
230
|
-
const overContainer = overItem2 && overItem2?.path ? containers[Path.first(overItem2.path)] : void 0;
|
|
231
|
-
if (overContainer?.onMove) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const activeContainer = activeItem && containers[Path.first(activeItem.path)];
|
|
235
|
-
if (!event.over || !overItem2 || !overContainer || !activeItem || !activeContainer) {
|
|
236
|
-
setOperation("reject");
|
|
237
|
-
setOverItem(void 0);
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
let operation2 = "reject";
|
|
241
|
-
if (overContainer.onOver) {
|
|
242
|
-
operation2 = overContainer.onOver({
|
|
243
|
-
active: activeItem,
|
|
244
|
-
over: overItem2,
|
|
245
|
-
details: moveDetails
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
setOperation(operation2);
|
|
249
|
-
setOverItem(overItem2);
|
|
250
|
-
};
|
|
251
|
-
const handleDragCancel = (event) => {
|
|
252
|
-
setOperation("reject");
|
|
253
|
-
setActiveItem(void 0);
|
|
254
|
-
setOverItem(void 0);
|
|
255
|
-
};
|
|
256
|
-
const handleDragEnd = (event) => {
|
|
257
|
-
const overContainer = overItem && containers[Path.first(overItem.path)];
|
|
258
|
-
if (operation !== "reject" && activeItem && overItem) {
|
|
259
|
-
let nextDropAnimation = defaultDropAnimation;
|
|
260
|
-
const activeContainer = containers[Path.first(activeItem.path)];
|
|
261
|
-
if (activeContainer) {
|
|
262
|
-
nextDropAnimation = activeContainer.onDrop?.({
|
|
263
|
-
operation,
|
|
264
|
-
active: activeItem,
|
|
265
|
-
over: overItem,
|
|
266
|
-
details: moveDetails
|
|
267
|
-
});
|
|
268
|
-
if (overContainer && overContainer !== activeContainer) {
|
|
269
|
-
nextDropAnimation = overContainer.onDrop?.({
|
|
270
|
-
operation,
|
|
271
|
-
active: activeItem,
|
|
272
|
-
over: overItem,
|
|
273
|
-
details: moveDetails
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
setDropAnimation(nextDropAnimation);
|
|
278
|
-
}
|
|
279
|
-
Object.values(containers).forEach((container) => container?.onDragEnd?.(event));
|
|
280
|
-
setTimeout(() => {
|
|
281
|
-
setOperation("reject");
|
|
282
|
-
setOverItem(void 0);
|
|
283
|
-
setActiveItem(void 0);
|
|
284
|
-
}, overContainer?.transitionDuration ?? DEFAULT_TRANSITION);
|
|
285
|
-
};
|
|
286
|
-
return /* @__PURE__ */ React4.createElement(MosaicContext.Provider, {
|
|
287
|
-
value: {
|
|
288
|
-
containers,
|
|
289
|
-
setContainer: handleSetContainer,
|
|
290
|
-
activeItem,
|
|
291
|
-
overItem,
|
|
292
|
-
operation,
|
|
293
|
-
moveDetails,
|
|
294
|
-
dropAnimation
|
|
295
|
-
}
|
|
296
|
-
}, /* @__PURE__ */ React4.createElement(DndContext, {
|
|
297
|
-
collisionDetection,
|
|
298
|
-
modifiers: [
|
|
299
|
-
modifiers
|
|
300
|
-
],
|
|
301
|
-
sensors,
|
|
302
|
-
// TODO(burdon): Allow container to veto drop.
|
|
303
|
-
cancelDrop: (event) => false,
|
|
304
|
-
onDragStart: handleDragStart,
|
|
305
|
-
onDragMove: handleDragMove,
|
|
306
|
-
onDragOver: handleDragOver,
|
|
307
|
-
onDragCancel: handleDragCancel,
|
|
308
|
-
onDragEnd: handleDragEnd
|
|
309
|
-
}, children, debug && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(MosaicDebug, {
|
|
310
|
-
containers,
|
|
311
|
-
operation,
|
|
312
|
-
activeItem,
|
|
313
|
-
overItem
|
|
314
|
-
}), document.body)));
|
|
315
|
-
};
|
|
316
|
-
var MosaicDebug = ({ containers, operation, activeItem, overItem }) => {
|
|
317
|
-
return /* @__PURE__ */ React4.createElement(Debug, {
|
|
318
|
-
position: "bottom-right",
|
|
319
|
-
data: {
|
|
320
|
-
containers: Object.keys(containers).map((id) => id),
|
|
321
|
-
operation,
|
|
322
|
-
active: {
|
|
323
|
-
id: activeItem?.item?.id.slice(0, 16),
|
|
324
|
-
path: activeItem?.path && Path.create(...Path.parts(activeItem.path).map((part) => part.slice(0, 16))),
|
|
325
|
-
type: activeItem?.type,
|
|
326
|
-
position: activeItem?.position
|
|
327
|
-
},
|
|
328
|
-
over: {
|
|
329
|
-
id: overItem?.item?.id.slice(0, 16),
|
|
330
|
-
path: overItem?.path && Path.create(...Path.parts(overItem.path).map((part) => part.slice(0, 16))),
|
|
331
|
-
type: overItem?.type,
|
|
332
|
-
position: overItem?.position
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
|
|
339
|
-
var useMosaic = () => useContext2(MosaicContext) ?? raise(new Error("Missing MosaicContext"));
|
|
340
|
-
|
|
341
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
|
|
342
|
-
var useItemsWithPreview = ({ path, items }) => {
|
|
343
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
344
|
-
const [itemsWithPreview, setItemsWithPreview] = useState2(items);
|
|
345
|
-
const overParent = (
|
|
346
|
-
// If over the sortable context itself & active item is foreign, then treat self as the parent.
|
|
347
|
-
// This allows items to be appended to the end of the sortable.
|
|
348
|
-
overItem?.path === path && activeItem && Path.parent(activeItem.path) !== overItem.path ? path : overItem && !!overItem.path && Path.parent(overItem.path)
|
|
349
|
-
);
|
|
350
|
-
const [lastOverParent, setLastOverParent] = useState2(overParent);
|
|
351
|
-
useEffect2(() => {
|
|
352
|
-
if (!activeItem || !overItem) {
|
|
353
|
-
setLastOverParent(void 0);
|
|
354
|
-
setItemsWithPreview(items);
|
|
355
|
-
return;
|
|
356
|
-
}
|
|
357
|
-
if (lastOverParent === overParent) {
|
|
358
|
-
return;
|
|
359
|
-
}
|
|
360
|
-
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
361
|
-
const overIsChild = Path.hasChild(path, overItem.path);
|
|
362
|
-
const overSelf = overItem.path === path;
|
|
363
|
-
if (operation === "reject" || operation === "rearrange") {
|
|
364
|
-
setLastOverParent(void 0);
|
|
365
|
-
setItemsWithPreview(items);
|
|
366
|
-
return;
|
|
367
|
-
} else {
|
|
368
|
-
setLastOverParent(overParent);
|
|
369
|
-
}
|
|
370
|
-
if (!activeIsChild && overIsChild) {
|
|
371
|
-
setItemsWithPreview((items2) => {
|
|
372
|
-
const position = overItem.position;
|
|
373
|
-
return [
|
|
374
|
-
...items2.slice(0, position),
|
|
375
|
-
activeItem.item,
|
|
376
|
-
...items2.slice(position)
|
|
377
|
-
];
|
|
378
|
-
});
|
|
379
|
-
} else if (!activeIsChild && overSelf) {
|
|
380
|
-
setItemsWithPreview((items2) => [
|
|
381
|
-
...items2,
|
|
382
|
-
activeItem.item
|
|
383
|
-
]);
|
|
384
|
-
} else if (activeIsChild && !overIsChild) {
|
|
385
|
-
setItemsWithPreview((items2) => items2.filter((item) => item.id !== activeItem.item.id));
|
|
386
|
-
} else {
|
|
387
|
-
setItemsWithPreview(items);
|
|
388
|
-
}
|
|
389
|
-
}, [
|
|
390
|
-
operation,
|
|
391
|
-
activeItem,
|
|
392
|
-
overItem,
|
|
393
|
-
overParent,
|
|
394
|
-
lastOverParent,
|
|
395
|
-
path,
|
|
396
|
-
items
|
|
397
|
-
]);
|
|
398
|
-
return items.length === itemsWithPreview.length ? items : itemsWithPreview;
|
|
29
|
+
var CardDragPreviewContent = ({ children }) => {
|
|
30
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
31
|
+
className: mx(styles.root, "ring-focusLine ring-neutralFocusIndicator")
|
|
32
|
+
}, children);
|
|
399
33
|
};
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
404
|
-
if (!activeItem || !overItem) {
|
|
405
|
-
return items;
|
|
406
|
-
}
|
|
407
|
-
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
408
|
-
const overIsChild = Path.hasChild(path, overItem.path);
|
|
409
|
-
if (activeIsChild && !overIsChild && operation !== "rearrange") {
|
|
410
|
-
return items.map((item) => {
|
|
411
|
-
if (item.id === activeItem.item.id) {
|
|
412
|
-
return {
|
|
413
|
-
...item,
|
|
414
|
-
id: `${item.id}--origin`
|
|
415
|
-
};
|
|
416
|
-
} else {
|
|
417
|
-
return item;
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
} else {
|
|
421
|
-
return items;
|
|
422
|
-
}
|
|
34
|
+
var CardDragPreview = {
|
|
35
|
+
Root: CardDragPreviewRoot,
|
|
36
|
+
Content: CardDragPreviewContent
|
|
423
37
|
};
|
|
424
38
|
|
|
425
|
-
//
|
|
426
|
-
import {
|
|
427
|
-
import
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
if (overItem?.path) {
|
|
439
|
-
container2 = containers[Path.first(overItem.path)];
|
|
440
|
-
OverlayComponent2 = container2?.Component;
|
|
441
|
-
}
|
|
442
|
-
if (!OverlayComponent2) {
|
|
443
|
-
container2 = containers[Path.first(activeItem.path)];
|
|
444
|
-
OverlayComponent2 = container2?.Component ?? DefaultComponent;
|
|
445
|
-
}
|
|
446
|
-
clearTimeout(timer.current);
|
|
447
|
-
timer.current = setTimeout(() => setState({
|
|
448
|
-
container: container2,
|
|
449
|
-
OverlayComponent: OverlayComponent2
|
|
450
|
-
}), timer.current ? delay : 0);
|
|
451
|
-
} else {
|
|
452
|
-
setState({});
|
|
453
|
-
}
|
|
454
|
-
}, [
|
|
455
|
-
activeItem,
|
|
456
|
-
overItem
|
|
39
|
+
// src/components/Layout/Layout.tsx
|
|
40
|
+
import React2, { forwardRef, useMemo } from "react";
|
|
41
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
42
|
+
var Main = /* @__PURE__ */ forwardRef(({ classNames, children, role, toolbar, statusbar }, forwardedRef) => {
|
|
43
|
+
const style = useMemo(() => ({
|
|
44
|
+
gridTemplateRows: [
|
|
45
|
+
toolbar && "var(--toolbar-size)",
|
|
46
|
+
"1fr",
|
|
47
|
+
statusbar && "var(--statusbar-size)"
|
|
48
|
+
].filter(Boolean).join(" ")
|
|
49
|
+
}), [
|
|
50
|
+
toolbar,
|
|
51
|
+
statusbar
|
|
457
52
|
]);
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
/* @__PURE__ */ React5.createElement(DragOverlay, {
|
|
464
|
-
adjustScale: false,
|
|
465
|
-
...overlayProps,
|
|
466
|
-
dropAnimation,
|
|
467
|
-
style: {
|
|
468
|
-
...container?.getOverlayStyle?.()
|
|
469
|
-
}
|
|
470
|
-
}, activeItem?.path && container && OverlayComponent && /* @__PURE__ */ React5.createElement(OverlayErrorBoundary, {
|
|
471
|
-
fallback: /* @__PURE__ */ React5.createElement(FallbackComponent, {
|
|
472
|
-
...container.getOverlayProps?.(),
|
|
473
|
-
item: activeItem.item,
|
|
474
|
-
path: activeItem.path,
|
|
475
|
-
operation,
|
|
476
|
-
active: "overlay"
|
|
477
|
-
})
|
|
478
|
-
}, /* @__PURE__ */ React5.createElement(OverlayComponent, {
|
|
479
|
-
...container.getOverlayProps?.(),
|
|
480
|
-
item: activeItem.item,
|
|
481
|
-
path: activeItem.path,
|
|
482
|
-
type: activeItem.type,
|
|
483
|
-
operation,
|
|
484
|
-
active: "overlay"
|
|
485
|
-
}), debug && /* @__PURE__ */ React5.createElement("div", {
|
|
486
|
-
className: "flex flex-wrap mt-1 p-1 bg-neutral-50 dark:bg-neutral-700 text-xs border rounded overflow-hidden gap-1"
|
|
487
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
488
|
-
className: "truncate"
|
|
489
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
490
|
-
className: "text-neutral-400"
|
|
491
|
-
}, "container "), container.id), /* @__PURE__ */ React5.createElement("span", {
|
|
492
|
-
className: "truncate"
|
|
493
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
494
|
-
className: "text-neutral-400"
|
|
495
|
-
}, "item "), activeItem.item.id.slice(0, 8)))))
|
|
496
|
-
);
|
|
497
|
-
};
|
|
498
|
-
var OverlayErrorBoundary = class extends Component {
|
|
499
|
-
constructor(props) {
|
|
500
|
-
super(props);
|
|
501
|
-
this.state = {
|
|
502
|
-
error: null
|
|
503
|
-
};
|
|
504
|
-
this.fallback = props.fallback ?? /* @__PURE__ */ React5.createElement("p", null, "ERROR: $", String(this.state.error));
|
|
505
|
-
}
|
|
506
|
-
static getDerivedStateFromError(error) {
|
|
507
|
-
return {
|
|
508
|
-
error
|
|
509
|
-
};
|
|
510
|
-
}
|
|
511
|
-
componentDidCatch(error, info) {
|
|
512
|
-
log.catch(error, {
|
|
513
|
-
info
|
|
514
|
-
}, {
|
|
515
|
-
F: __dxlog_file,
|
|
516
|
-
L: 140,
|
|
517
|
-
S: this,
|
|
518
|
-
C: (f, a) => f(...a)
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
render() {
|
|
522
|
-
if (this.state.error) {
|
|
523
|
-
return this.fallback;
|
|
524
|
-
}
|
|
525
|
-
return this.props.children;
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
// packages/ui/react-ui-mosaic/src/mosaic/SortableContext.tsx
|
|
530
|
-
import { SortableContext, horizontalListSortingStrategy, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
531
|
-
import React6 from "react";
|
|
532
|
-
var MosaicSortableContext = ({ id, items = [], direction = "vertical", children }) => {
|
|
533
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
534
|
-
const container = useContainer();
|
|
535
|
-
const contextId = id ?? container.id;
|
|
536
|
-
const Sortable = direction === "vertical" ? Column : Row;
|
|
537
|
-
const ids = items.map((item) => {
|
|
538
|
-
const path = Path.create(contextId, item.id);
|
|
539
|
-
const isPreview = activeItem && activeItem.item.id === item.id && overItem && overItem.path && (Path.siblings(overItem.path, path) || Path.hasChild(overItem.path, path)) && operation !== "reject";
|
|
540
|
-
return isPreview ? activeItem.path : path;
|
|
541
|
-
});
|
|
542
|
-
return /* @__PURE__ */ React6.createElement(Sortable, {
|
|
543
|
-
id: contextId,
|
|
544
|
-
items: ids
|
|
53
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
54
|
+
ref: forwardedRef,
|
|
55
|
+
role: role ?? "none",
|
|
56
|
+
style,
|
|
57
|
+
className: mx2("bs-full is-full grid grid-cols-[100%] overflow-hidden", toolbar && "[&>.dx-toolbar]:relative [&>.dx-toolbar]:border-be [&>.dx-toolbar]:border-subduedSeparator", classNames)
|
|
545
58
|
}, children);
|
|
546
|
-
};
|
|
547
|
-
var Column = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
|
|
548
|
-
id,
|
|
549
|
-
items,
|
|
550
|
-
strategy: verticalListSortingStrategy
|
|
551
|
-
}, children);
|
|
552
|
-
var Row = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
|
|
553
|
-
id,
|
|
554
|
-
items,
|
|
555
|
-
strategy: horizontalListSortingStrategy
|
|
556
|
-
}, children);
|
|
557
|
-
|
|
558
|
-
// packages/ui/react-ui-mosaic/src/mosaic/Tile.tsx
|
|
559
|
-
import { useDraggable, useDroppable } from "@dnd-kit/core";
|
|
560
|
-
import { defaultAnimateLayoutChanges, useSortable } from "@dnd-kit/sortable";
|
|
561
|
-
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
562
|
-
import React7, { forwardRef as forwardRef3 } from "react";
|
|
563
|
-
var DraggableTile = ({ path: parentPath, type = DEFAULT_TYPE, item, Component: Component2 = DefaultComponent, position, draggableStyle, ...props }) => {
|
|
564
|
-
const { operation } = useMosaic();
|
|
565
|
-
const path = Path.create(parentPath, item.id);
|
|
566
|
-
const {
|
|
567
|
-
setNodeRef,
|
|
568
|
-
attributes,
|
|
569
|
-
listeners,
|
|
570
|
-
/* transform, */
|
|
571
|
-
isDragging
|
|
572
|
-
} = useDraggable({
|
|
573
|
-
id: path,
|
|
574
|
-
data: {
|
|
575
|
-
path,
|
|
576
|
-
type,
|
|
577
|
-
item,
|
|
578
|
-
position
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
return /* @__PURE__ */ React7.createElement(Component2, {
|
|
582
|
-
ref: setNodeRef,
|
|
583
|
-
item,
|
|
584
|
-
path,
|
|
585
|
-
type,
|
|
586
|
-
position,
|
|
587
|
-
operation,
|
|
588
|
-
isDragging,
|
|
589
|
-
draggableStyle: {
|
|
590
|
-
// TODO(burdon): Override by container?
|
|
591
|
-
// transform: getTransformCSS(transform),
|
|
592
|
-
...draggableStyle
|
|
593
|
-
},
|
|
594
|
-
draggableProps: {
|
|
595
|
-
...attributes,
|
|
596
|
-
...listeners
|
|
597
|
-
},
|
|
598
|
-
...props
|
|
599
|
-
});
|
|
600
|
-
};
|
|
601
|
-
var DroppableTile = /* @__PURE__ */ forwardRef3(({ path: parentPath, type = DEFAULT_TYPE, item, Component: Component2 = DefaultComponent, position, ...props }, forwardedRef) => {
|
|
602
|
-
const { operation } = useMosaic();
|
|
603
|
-
const path = parentPath === item.id ? parentPath : Path.create(parentPath, item.id);
|
|
604
|
-
const { setNodeRef, isOver } = useDroppable({
|
|
605
|
-
id: path,
|
|
606
|
-
data: {
|
|
607
|
-
path,
|
|
608
|
-
type,
|
|
609
|
-
item,
|
|
610
|
-
position
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
const ref = useComposedRefs(setNodeRef, forwardedRef);
|
|
614
|
-
return /* @__PURE__ */ React7.createElement(Component2, {
|
|
615
|
-
item,
|
|
616
|
-
path,
|
|
617
|
-
type,
|
|
618
|
-
position,
|
|
619
|
-
operation,
|
|
620
|
-
isOver,
|
|
621
|
-
...props,
|
|
622
|
-
ref
|
|
623
|
-
});
|
|
624
59
|
});
|
|
625
|
-
var
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
},
|
|
638
|
-
animateLayoutChanges: (args) => defaultAnimateLayoutChanges({
|
|
639
|
-
...args,
|
|
640
|
-
wasDragging: item.id !== activeItem?.item.id
|
|
641
|
-
})
|
|
642
|
-
});
|
|
643
|
-
let active;
|
|
644
|
-
if (isDragging) {
|
|
645
|
-
if (operation === "rearrange" || operation === "reject") {
|
|
646
|
-
active = "rearrange";
|
|
647
|
-
} else if (activeItem && activeItem.path && Path.parent(activeItem.path) !== parentPath) {
|
|
648
|
-
active = "destination";
|
|
649
|
-
} else {
|
|
650
|
-
active = "origin";
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
const Component2 = OverrideComponent ?? ContainerComponent ?? DefaultComponent;
|
|
654
|
-
return /* @__PURE__ */ React7.createElement(Component2, {
|
|
655
|
-
ref: setNodeRef,
|
|
656
|
-
item,
|
|
657
|
-
path,
|
|
658
|
-
type,
|
|
659
|
-
position,
|
|
660
|
-
operation,
|
|
661
|
-
active,
|
|
662
|
-
isDragging,
|
|
663
|
-
isOver,
|
|
664
|
-
draggableStyle: {
|
|
665
|
-
transform: getTransformCSS(transform),
|
|
666
|
-
transition: transform ? `transform ${transitionDuration}ms ease` : "none",
|
|
667
|
-
...draggableStyle
|
|
668
|
-
},
|
|
669
|
-
draggableProps: {
|
|
670
|
-
...attributes,
|
|
671
|
-
...listeners
|
|
672
|
-
},
|
|
673
|
-
...props
|
|
674
|
-
});
|
|
60
|
+
var Container = /* @__PURE__ */ forwardRef(({ classNames, children, role, scrollable }, forwardedRef) => {
|
|
61
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
62
|
+
ref: forwardedRef,
|
|
63
|
+
role: role ?? "none",
|
|
64
|
+
className: mx2("grid bs-full", scrollable ? "overflow-y-auto" : "overflow-hidden", classNames)
|
|
65
|
+
}, children);
|
|
66
|
+
});
|
|
67
|
+
var Flex = ({ children, classNames, role, column, grow }) => {
|
|
68
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
69
|
+
role: role ?? "none",
|
|
70
|
+
className: mx2("flex", column && "flex-col", grow && "flex-1 overflow-hidden", classNames)
|
|
71
|
+
}, children);
|
|
675
72
|
};
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
Container: MosaicContainer,
|
|
681
|
-
DragOverlay: MosaicDragOverlay,
|
|
682
|
-
SortableContext: MosaicSortableContext,
|
|
683
|
-
DraggableTile,
|
|
684
|
-
DroppableTile,
|
|
685
|
-
SortableTile,
|
|
686
|
-
// TODO(wittjosiah): Consider factoring out or using inline styles instead depending on DXOS UI theme/tailwind.
|
|
687
|
-
DefaultComponent,
|
|
688
|
-
// TODO(burdon): Don't export; move to util.
|
|
689
|
-
Debug
|
|
73
|
+
var Layout = {
|
|
74
|
+
Main,
|
|
75
|
+
Container,
|
|
76
|
+
Flex
|
|
690
77
|
};
|
|
691
78
|
export {
|
|
79
|
+
Card,
|
|
80
|
+
CardDragPreview,
|
|
81
|
+
Focus,
|
|
82
|
+
Image,
|
|
83
|
+
Layout,
|
|
692
84
|
Mosaic,
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
85
|
+
Stack,
|
|
86
|
+
VirtualStack,
|
|
87
|
+
styles as cardStyles,
|
|
88
|
+
dropHandler,
|
|
89
|
+
styles2 as focusStyles,
|
|
90
|
+
styles3 as mosaicStyles,
|
|
91
|
+
useContainerDebug,
|
|
92
|
+
useEventHandlerAdapter,
|
|
93
|
+
useFocus,
|
|
94
|
+
useRootContext as useMosaic,
|
|
95
|
+
useContainerContext as useMosaicContainer,
|
|
96
|
+
useTileContext as useMosaicTile,
|
|
97
|
+
useVisibleItems
|
|
702
98
|
};
|
|
703
99
|
//# sourceMappingURL=index.mjs.map
|