@dxos/react-ui-mosaic 0.7.5-main.e9bb01b → 0.8.4-main.03d5cd7b56
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-RUQB4JIG.mjs +964 -0
- package/dist/lib/browser/chunk-RUQB4JIG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +654 -661
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/playwright/index.mjs +231 -0
- package/dist/lib/browser/playwright/index.mjs.map +7 -0
- package/dist/lib/browser/testing/index.mjs +138 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +18 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MYDCPSNY.mjs +966 -0
- package/dist/lib/node-esm/chunk-MYDCPSNY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +654 -662
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/playwright/index.mjs +233 -0
- package/dist/lib/node-esm/playwright/index.mjs.map +7 -0
- package/dist/lib/node-esm/testing/index.mjs +139 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +20 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/Board/Board.d.ts +88 -0
- package/dist/types/src/components/Board/Board.d.ts.map +1 -0
- package/dist/types/src/components/Board/Board.stories.d.ts +41 -0
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -0
- package/dist/types/src/components/Board/Column.d.ts +40 -0
- package/dist/types/src/components/Board/Column.d.ts.map +1 -0
- package/dist/types/src/components/Board/Item.d.ts +12 -0
- package/dist/types/src/components/Board/Item.d.ts.map +1 -0
- package/dist/types/src/components/Board/index.d.ts +2 -0
- package/dist/types/src/components/Board/index.d.ts.map +1 -0
- package/dist/types/src/components/Focus/Focus.d.ts +2 -0
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -0
- package/dist/types/src/components/Focus/index.d.ts +2 -0
- package/dist/types/src/components/Focus/index.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Container.d.ts +45 -0
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +50 -0
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +21 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Root.d.ts +35 -0
- package/dist/types/src/components/Mosaic/Root.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts +29 -0
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts +20 -0
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Tile.d.ts +53 -0
- package/dist/types/src/components/Mosaic/Tile.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 +86 -0
- package/dist/types/src/components/Mosaic/types.d.ts.map +1 -0
- package/dist/types/src/components/SearchStack/SearchStack.d.ts +20 -0
- package/dist/types/src/components/SearchStack/SearchStack.d.ts.map +1 -0
- package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts +10 -0
- package/dist/types/src/components/SearchStack/SearchStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/SearchStack/index.d.ts +2 -0
- package/dist/types/src/components/SearchStack/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -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/useDefaultColumnEventHandler.d.ts +15 -0
- package/dist/types/src/hooks/useDefaultColumnEventHandler.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/playwright/board-manager.d.ts +55 -0
- package/dist/types/src/playwright/board-manager.d.ts.map +1 -0
- package/dist/types/src/playwright/index.d.ts +9 -0
- package/dist/types/src/playwright/index.d.ts.map +1 -0
- package/dist/types/src/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/playwright/smoke.spec.d.ts +2 -0
- package/dist/types/src/playwright/smoke.spec.d.ts.map +1 -0
- package/dist/types/src/testing/CardContainer.d.ts +18 -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/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/testing/types.d.ts +21 -0
- package/dist/types/src/testing/types.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +11 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +84 -43
- package/src/AUDIT.md +106 -0
- package/src/components/Board/Board.stories.tsx +274 -0
- package/src/components/Board/Board.tsx +190 -0
- package/src/components/Board/Column.tsx +304 -0
- package/src/components/Board/Item.tsx +119 -0
- package/src/components/Board/index.ts +5 -0
- package/src/components/Focus/Focus.tsx +6 -0
- package/src/components/Focus/index.ts +5 -0
- package/src/components/Mosaic/Container.tsx +315 -0
- package/src/components/Mosaic/Mosaic.tsx +51 -0
- package/src/components/Mosaic/Placeholder.tsx +139 -0
- package/src/components/Mosaic/Root.tsx +286 -0
- package/src/components/Mosaic/Stack.stories.tsx +175 -0
- package/src/components/Mosaic/Stack.tsx +341 -0
- package/src/components/Mosaic/Tile.tsx +252 -0
- package/src/components/Mosaic/extension.ts +141 -0
- package/src/components/Mosaic/index.ts +10 -0
- package/src/components/Mosaic/styles.ts +32 -0
- package/src/components/Mosaic/types.ts +94 -0
- package/src/components/SearchStack/SearchStack.stories.tsx +47 -0
- package/src/components/SearchStack/SearchStack.tsx +135 -0
- package/src/components/SearchStack/index.ts +5 -0
- package/src/components/index.ts +8 -0
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useContainerDebug.tsx +48 -0
- package/src/hooks/useDefaultColumnEventHandler.ts +34 -0
- package/src/hooks/useEventHandlerAdapter.ts +108 -0
- package/src/hooks/useVisibleItems.ts +48 -0
- package/src/index.ts +3 -2
- package/src/playwright/board-manager.ts +287 -0
- package/src/playwright/index.ts +13 -0
- package/src/playwright/playwright.config.ts +17 -0
- package/src/playwright/smoke.spec.ts +143 -0
- package/src/testing/CardContainer.tsx +97 -0
- package/src/testing/DefaultStackTile.tsx +58 -0
- package/src/testing/decorator.tsx +16 -0
- package/src/testing/index.ts +5 -3
- package/src/testing/types.ts +38 -0
- package/src/translations.ts +19 -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 +0 -2
- 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/index.ts +0 -5
- 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
|
@@ -1,705 +1,697 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
Focus,
|
|
4
|
+
Mosaic,
|
|
5
|
+
getSourceData,
|
|
6
|
+
styles,
|
|
7
|
+
useFocus,
|
|
8
|
+
useMosaicContainerContext,
|
|
9
|
+
useMosaicRootContext,
|
|
10
|
+
useMosaicTileContext,
|
|
11
|
+
useVisibleItems
|
|
12
|
+
} from "./chunk-MYDCPSNY.mjs";
|
|
2
13
|
|
|
3
|
-
//
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var DEFAULT_COMPONENT = /* @__PURE__ */ forwardRef(() => /* @__PURE__ */ React.createElement(React.Fragment, null, "missing component"));
|
|
11
|
-
var MosaicOperations = [
|
|
12
|
-
"transfer",
|
|
13
|
-
"copy",
|
|
14
|
-
"rearrange",
|
|
15
|
-
"reject"
|
|
16
|
-
];
|
|
17
|
-
var MosaicContainerContext = /* @__PURE__ */ createContext({
|
|
18
|
-
id: "never",
|
|
19
|
-
type: DEFAULT_TYPE,
|
|
20
|
-
Component: DEFAULT_COMPONENT
|
|
21
|
-
});
|
|
22
|
-
var MosaicContainer = ({ children, id, debug, type = DEFAULT_TYPE, Component: Component2 = DEFAULT_COMPONENT, transitionDuration = DEFAULT_TRANSITION, modifier, getOverlayProps, getOverlayStyle, onOver, onDrop, onMove, onDragEnd }) => {
|
|
23
|
-
const mosaic = useMosaic();
|
|
24
|
-
const container = {
|
|
25
|
-
id,
|
|
26
|
-
debug,
|
|
27
|
-
type,
|
|
28
|
-
Component: Component2,
|
|
29
|
-
transitionDuration,
|
|
30
|
-
modifier,
|
|
31
|
-
getOverlayProps,
|
|
32
|
-
getOverlayStyle,
|
|
33
|
-
onOver,
|
|
34
|
-
onDrop,
|
|
35
|
-
onMove,
|
|
36
|
-
onDragEnd
|
|
37
|
-
};
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
mosaic.setContainer(container.id, container);
|
|
40
|
-
return () => {
|
|
41
|
-
};
|
|
42
|
-
}, Object.values(container));
|
|
43
|
-
return /* @__PURE__ */ React.createElement(MosaicContainerContext.Provider, {
|
|
44
|
-
value: container
|
|
45
|
-
}, children);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useContainer.ts
|
|
49
|
-
var useContainer = () => useContext(MosaicContainerContext);
|
|
50
|
-
|
|
51
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
|
|
52
|
-
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
53
|
-
|
|
54
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
|
|
55
|
-
import { useContext as useContext2 } from "react";
|
|
56
|
-
import { raise } from "@dxos/debug";
|
|
14
|
+
// src/components/Board/Board.tsx
|
|
15
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
16
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
17
|
+
import React4, { forwardRef as forwardRef4, useRef as useRef3, useState as useState3 } from "react";
|
|
18
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
19
|
+
import { JsonHighlighter as JsonHighlighter2 } from "@dxos/react-ui-syntax-highlighter";
|
|
20
|
+
import { composable as composable2, composableProps as composableProps2, mx as mx3 } from "@dxos/ui-theme";
|
|
57
21
|
|
|
58
|
-
//
|
|
59
|
-
import
|
|
60
|
-
import { sortableKeyboardCoordinates } from "@dnd-kit/sortable";
|
|
61
|
-
import React4, { createContext as createContext2, useState } from "react";
|
|
22
|
+
// src/hooks/useContainerDebug.tsx
|
|
23
|
+
import React, { forwardRef, useMemo, useRef } from "react";
|
|
62
24
|
import { createPortal } from "react-dom";
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var SEPARATOR = "~";
|
|
86
|
-
var Path = {
|
|
87
|
-
create: (...args) => args.join(SEPARATOR),
|
|
88
|
-
parts: (path) => path.split(SEPARATOR),
|
|
89
|
-
length: (path) => path.split(SEPARATOR).length,
|
|
90
|
-
first: (path) => path.split(SEPARATOR)[0] ?? path,
|
|
91
|
-
last: (path) => path.split(SEPARATOR).at(-1) ?? path,
|
|
92
|
-
parent: (path) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
|
|
93
|
-
hasRoot: (path, id) => Path.first(path) === id,
|
|
94
|
-
hasChild: (path, compare) => Path.parent(compare) === path,
|
|
95
|
-
hasDescendent: (path, compare) => compare !== path && compare.startsWith(path),
|
|
96
|
-
siblings: (path, compare) => Path.parent(path) === Path.parent(compare),
|
|
97
|
-
onPath: (path, id) => Path.parts(path).includes(id)
|
|
25
|
+
import { JsonHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
26
|
+
import { mx } from "@dxos/ui-theme";
|
|
27
|
+
var useContainerDebug = (debug) => {
|
|
28
|
+
const debugRef = useRef(null);
|
|
29
|
+
return useMemo(() => {
|
|
30
|
+
if (!debug) {
|
|
31
|
+
return [
|
|
32
|
+
() => null,
|
|
33
|
+
void 0
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
return [
|
|
37
|
+
({ classNames }) => /* @__PURE__ */ React.createElement("div", {
|
|
38
|
+
className: mx("overflow-hidden", classNames),
|
|
39
|
+
ref: debugRef
|
|
40
|
+
}),
|
|
41
|
+
() => debugRef.current && /* @__PURE__ */ createPortal(/* @__PURE__ */ React.createElement(ContainerInfo, null), debugRef.current)
|
|
42
|
+
];
|
|
43
|
+
}, [
|
|
44
|
+
debug,
|
|
45
|
+
debugRef
|
|
46
|
+
]);
|
|
98
47
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
ref: forwardRef4,
|
|
115
|
-
style: draggableStyle
|
|
116
|
-
}, /* @__PURE__ */ React3.createElement(Card.Header, null, /* @__PURE__ */ React3.createElement(Card.DragHandle, draggableProps), /* @__PURE__ */ React3.createElement(Card.Title, {
|
|
117
|
-
title: Path.create(path, id),
|
|
118
|
-
classNames: "truncate font-mono text-xs"
|
|
119
|
-
})));
|
|
48
|
+
var CONTAINER_INFO_NAME = "ContainerInfo";
|
|
49
|
+
var ContainerInfo = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
50
|
+
const { id, state, activeLocation, scrolling } = useMosaicContainerContext(CONTAINER_INFO_NAME);
|
|
51
|
+
const counter = useRef(0);
|
|
52
|
+
return /* @__PURE__ */ React.createElement(JsonHighlighter, {
|
|
53
|
+
data: {
|
|
54
|
+
id,
|
|
55
|
+
activeLocation,
|
|
56
|
+
scrolling,
|
|
57
|
+
state,
|
|
58
|
+
count: counter.current++
|
|
59
|
+
},
|
|
60
|
+
classNames: mx("text-xs", classNames),
|
|
61
|
+
ref: forwardedRef
|
|
62
|
+
});
|
|
120
63
|
});
|
|
121
|
-
|
|
64
|
+
ContainerInfo.displayName = CONTAINER_INFO_NAME;
|
|
122
65
|
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
66
|
+
// src/hooks/useEventHandlerAdapter.ts
|
|
67
|
+
import { useMemo as useMemo2 } from "react";
|
|
68
|
+
import { log } from "@dxos/log";
|
|
69
|
+
import { arrayMove } from "@dxos/util";
|
|
70
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-mosaic/src/hooks/useEventHandlerAdapter.ts";
|
|
71
|
+
var useEventHandlerAdapter = ({ items, getId, get, make, onChange, ...props }) => {
|
|
72
|
+
return useMemo2(() => ({
|
|
73
|
+
...props,
|
|
74
|
+
onTake: ({ source }, cb) => {
|
|
75
|
+
log.info("onTake", {
|
|
76
|
+
source
|
|
77
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 14, S: void 0 });
|
|
78
|
+
const mutate = (items2) => {
|
|
79
|
+
const from = items2.findIndex((item) => getId(item) === source.id);
|
|
80
|
+
if (from !== -1) {
|
|
81
|
+
items2.splice(from, 1);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (onChange) {
|
|
85
|
+
onChange(mutate);
|
|
143
86
|
} else {
|
|
144
|
-
|
|
145
|
-
return rest;
|
|
87
|
+
mutate(items);
|
|
146
88
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const container = containers[Path.first(activeItem.path)];
|
|
165
|
-
return container?.modifier?.(activeItem, props) ?? transform;
|
|
166
|
-
} else {
|
|
167
|
-
return transform;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const sensors = useSensors(useSensor(MouseSensor, {
|
|
171
|
-
activationConstraint: {
|
|
172
|
-
distance: 10
|
|
173
|
-
}
|
|
174
|
-
}), useSensor(TouchSensor, {
|
|
175
|
-
activationConstraint: {
|
|
176
|
-
delay: 200,
|
|
177
|
-
tolerance: 5
|
|
178
|
-
}
|
|
179
|
-
}), useSensor(KeyboardSensor, {
|
|
180
|
-
coordinateGetter: sortableKeyboardCoordinates
|
|
181
|
-
}));
|
|
182
|
-
const handleDragStart = (event) => {
|
|
183
|
-
setActiveItem(pick(event.active.data.current, [
|
|
184
|
-
"path",
|
|
185
|
-
"type",
|
|
186
|
-
"item",
|
|
187
|
-
"position"
|
|
188
|
-
]));
|
|
189
|
-
};
|
|
190
|
-
const handleDragMove = (event) => {
|
|
191
|
-
const nextOverItem = pick(event.over?.data.current, [
|
|
192
|
-
"path",
|
|
193
|
-
"type",
|
|
194
|
-
"item",
|
|
195
|
-
"position"
|
|
196
|
-
]);
|
|
197
|
-
const nextOverContainer = nextOverItem && nextOverItem?.path ? containers[Path.first(nextOverItem.path)] : void 0;
|
|
198
|
-
if (!event.over || !nextOverItem || !nextOverContainer) {
|
|
199
|
-
setOperation("reject");
|
|
200
|
-
setOverItem(void 0);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (overItem !== nextOverItem) {
|
|
204
|
-
setOverItem(nextOverItem);
|
|
205
|
-
}
|
|
206
|
-
if (activeItem && nextOverItem && nextOverContainer?.onMove) {
|
|
207
|
-
const { operation: nextOperation, details: nextDetails } = nextOverContainer.onMove({
|
|
208
|
-
active: activeItem,
|
|
209
|
-
over: nextOverItem,
|
|
210
|
-
details: {
|
|
211
|
-
delta: event.delta
|
|
89
|
+
void cb(source.data);
|
|
90
|
+
},
|
|
91
|
+
onDrop: ({ source, target }) => {
|
|
92
|
+
log.info("onDrop", {
|
|
93
|
+
source,
|
|
94
|
+
target
|
|
95
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 31, S: void 0 });
|
|
96
|
+
const mutate = (items2) => {
|
|
97
|
+
const to = target?.type === "tile" || target?.type === "placeholder" ? target.location : target?.type === "container" ? items2.length : -1;
|
|
98
|
+
const from = items2.findIndex((item) => getId(item) === source.id);
|
|
99
|
+
const insertIndex = typeof to === "number" && to >= 0 ? Math.floor(to) : -1;
|
|
100
|
+
if (insertIndex !== -1) {
|
|
101
|
+
if (from !== -1) {
|
|
102
|
+
arrayMove(items2, from, insertIndex);
|
|
103
|
+
} else {
|
|
104
|
+
items2.splice(insertIndex, 0, make(get(source.data)));
|
|
105
|
+
}
|
|
212
106
|
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
!moveDetails && nextDetails || // only update if details change
|
|
219
|
-
Object.entries(nextDetails).find(([key, value]) => !(key in moveDetails) || moveDetails[key] !== value)
|
|
220
|
-
) {
|
|
221
|
-
setMoveDetails(nextDetails);
|
|
107
|
+
};
|
|
108
|
+
if (onChange) {
|
|
109
|
+
onChange(mutate);
|
|
110
|
+
} else {
|
|
111
|
+
mutate(items);
|
|
222
112
|
}
|
|
223
113
|
}
|
|
114
|
+
}), [
|
|
115
|
+
items,
|
|
116
|
+
onChange
|
|
117
|
+
]);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/hooks/useDefaultColumnEventHandler.ts
|
|
121
|
+
var useDefaultColumnEventHandler = (id, model, items) => useEventHandlerAdapter({
|
|
122
|
+
id,
|
|
123
|
+
items,
|
|
124
|
+
getId: model.getColumnId,
|
|
125
|
+
get: (data) => data,
|
|
126
|
+
make: (object) => object,
|
|
127
|
+
canDrop: ({ source }) => model.isColumn(source.data)
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// src/components/Mosaic/extension.ts
|
|
131
|
+
import { StateEffect, StateField } from "@codemirror/state";
|
|
132
|
+
import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
133
|
+
var dropHandler = ({ onDrop = handleDrop } = {}) => {
|
|
134
|
+
const views = /* @__PURE__ */ new Set();
|
|
135
|
+
let state = null;
|
|
136
|
+
const reset = () => {
|
|
137
|
+
views.forEach((view) => view.dispatch({
|
|
138
|
+
effects: setDrop.of(null)
|
|
139
|
+
}));
|
|
140
|
+
state = null;
|
|
224
141
|
};
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
142
|
+
const extension = [
|
|
143
|
+
dropField,
|
|
144
|
+
ViewPlugin.fromClass(class {
|
|
145
|
+
_view;
|
|
146
|
+
constructor(_view) {
|
|
147
|
+
this._view = _view;
|
|
148
|
+
views.add(_view);
|
|
149
|
+
}
|
|
150
|
+
destroy() {
|
|
151
|
+
views.delete(this._view);
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
];
|
|
155
|
+
return {
|
|
156
|
+
extension,
|
|
157
|
+
update: (position) => {
|
|
158
|
+
if (!position) {
|
|
159
|
+
reset();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
views.forEach((view) => {
|
|
163
|
+
const rect = view.dom.getBoundingClientRect();
|
|
164
|
+
if (position.x >= rect.left && position.x <= rect.right && position.y >= rect.top && position.y <= rect.bottom) {
|
|
165
|
+
let pos = view.posAtCoords(position);
|
|
166
|
+
if (pos !== null) {
|
|
167
|
+
const word = view.state.wordAt(pos);
|
|
168
|
+
if (word) {
|
|
169
|
+
const startDist = Math.abs(pos - word.from);
|
|
170
|
+
const endDist = Math.abs(pos - word.to);
|
|
171
|
+
pos = startDist < endDist ? word.from : word.to;
|
|
172
|
+
}
|
|
173
|
+
view.dispatch({
|
|
174
|
+
effects: setDrop.of(pos)
|
|
175
|
+
});
|
|
176
|
+
state = {
|
|
177
|
+
view,
|
|
178
|
+
pos
|
|
179
|
+
};
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
view.dispatch({
|
|
184
|
+
effects: setDrop.of(null)
|
|
185
|
+
});
|
|
248
186
|
});
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const handleDragEnd = (event) => {
|
|
259
|
-
const overContainer = overItem && containers[Path.first(overItem.path)];
|
|
260
|
-
if (operation !== "reject" && activeItem && overItem) {
|
|
261
|
-
let nextDropAnimation = defaultDropAnimation;
|
|
262
|
-
const activeContainer = containers[Path.first(activeItem.path)];
|
|
263
|
-
if (activeContainer) {
|
|
264
|
-
nextDropAnimation = activeContainer.onDrop?.({
|
|
265
|
-
operation,
|
|
266
|
-
active: activeItem,
|
|
267
|
-
over: overItem,
|
|
268
|
-
details: moveDetails
|
|
187
|
+
},
|
|
188
|
+
cancel: () => {
|
|
189
|
+
reset();
|
|
190
|
+
},
|
|
191
|
+
drop: ({ text, url }) => {
|
|
192
|
+
if (state) {
|
|
193
|
+
onDrop(state.view, state.pos, {
|
|
194
|
+
text,
|
|
195
|
+
url
|
|
269
196
|
});
|
|
270
|
-
if (overContainer && overContainer !== activeContainer) {
|
|
271
|
-
nextDropAnimation = overContainer.onDrop?.({
|
|
272
|
-
operation,
|
|
273
|
-
active: activeItem,
|
|
274
|
-
over: overItem,
|
|
275
|
-
details: moveDetails
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
197
|
}
|
|
279
|
-
|
|
198
|
+
reset();
|
|
280
199
|
}
|
|
281
|
-
Object.values(containers).forEach((container) => container?.onDragEnd?.(event));
|
|
282
|
-
setTimeout(() => {
|
|
283
|
-
setOperation("reject");
|
|
284
|
-
setOverItem(void 0);
|
|
285
|
-
setActiveItem(void 0);
|
|
286
|
-
}, overContainer?.transitionDuration ?? DEFAULT_TRANSITION);
|
|
287
200
|
};
|
|
288
|
-
return /* @__PURE__ */ React4.createElement(MosaicContext.Provider, {
|
|
289
|
-
value: {
|
|
290
|
-
containers,
|
|
291
|
-
setContainer: handleSetContainer,
|
|
292
|
-
activeItem,
|
|
293
|
-
overItem,
|
|
294
|
-
operation,
|
|
295
|
-
moveDetails,
|
|
296
|
-
dropAnimation
|
|
297
|
-
}
|
|
298
|
-
}, /* @__PURE__ */ React4.createElement(DndContext, {
|
|
299
|
-
collisionDetection,
|
|
300
|
-
modifiers: [
|
|
301
|
-
modifiers
|
|
302
|
-
],
|
|
303
|
-
sensors,
|
|
304
|
-
// TODO(burdon): Allow container to veto drop.
|
|
305
|
-
cancelDrop: (event) => false,
|
|
306
|
-
onDragStart: handleDragStart,
|
|
307
|
-
onDragMove: handleDragMove,
|
|
308
|
-
onDragOver: handleDragOver,
|
|
309
|
-
onDragCancel: handleDragCancel,
|
|
310
|
-
onDragEnd: handleDragEnd
|
|
311
|
-
}, children, debug && /* @__PURE__ */ createPortal(/* @__PURE__ */ React4.createElement(MosaicDebug, {
|
|
312
|
-
containers,
|
|
313
|
-
operation,
|
|
314
|
-
activeItem,
|
|
315
|
-
overItem
|
|
316
|
-
}), document.body)));
|
|
317
201
|
};
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
type: activeItem?.type,
|
|
328
|
-
position: activeItem?.position
|
|
202
|
+
var handleDrop = (view, pos, event) => {
|
|
203
|
+
const line = view.state.doc.lineAt(pos);
|
|
204
|
+
if (line.text.trim() === "") {
|
|
205
|
+
view.dispatch({
|
|
206
|
+
changes: {
|
|
207
|
+
from: pos,
|
|
208
|
+
insert: `
|
|
209
|
+

|
|
210
|
+
`
|
|
329
211
|
},
|
|
330
|
-
|
|
331
|
-
id: overItem?.item?.id.slice(0, 16),
|
|
332
|
-
path: overItem?.path && Path.create(...Path.parts(overItem.path).map((part) => part.slice(0, 16))),
|
|
333
|
-
type: overItem?.type,
|
|
334
|
-
position: overItem?.position
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useMosaic.ts
|
|
341
|
-
var useMosaic = () => useContext2(MosaicContext) ?? raise(new Error("Missing MosaicContext"));
|
|
342
|
-
|
|
343
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithPreview.ts
|
|
344
|
-
var useItemsWithPreview = ({ path, items }) => {
|
|
345
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
346
|
-
const [itemsWithPreview, setItemsWithPreview] = useState2(items);
|
|
347
|
-
const overParent = (
|
|
348
|
-
// If over the sortable context itself & active item is foreign, then treat self as the parent.
|
|
349
|
-
// This allows items to be appended to the end of the sortable.
|
|
350
|
-
overItem?.path === path && activeItem && Path.parent(activeItem.path) !== overItem.path ? path : overItem && !!overItem.path && Path.parent(overItem.path)
|
|
351
|
-
);
|
|
352
|
-
const [lastOverParent, setLastOverParent] = useState2(overParent);
|
|
353
|
-
useEffect2(() => {
|
|
354
|
-
if (!activeItem || !overItem) {
|
|
355
|
-
setLastOverParent(void 0);
|
|
356
|
-
setItemsWithPreview(items);
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (lastOverParent === overParent) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
363
|
-
const overIsChild = Path.hasChild(path, overItem.path);
|
|
364
|
-
const overSelf = overItem.path === path;
|
|
365
|
-
if (operation === "reject" || operation === "rearrange") {
|
|
366
|
-
setLastOverParent(void 0);
|
|
367
|
-
setItemsWithPreview(items);
|
|
368
|
-
return;
|
|
369
|
-
} else {
|
|
370
|
-
setLastOverParent(overParent);
|
|
371
|
-
}
|
|
372
|
-
if (!activeIsChild && overIsChild) {
|
|
373
|
-
setItemsWithPreview((items2) => {
|
|
374
|
-
const position = overItem.position;
|
|
375
|
-
return [
|
|
376
|
-
...items2.slice(0, position),
|
|
377
|
-
activeItem.item,
|
|
378
|
-
...items2.slice(position)
|
|
379
|
-
];
|
|
380
|
-
});
|
|
381
|
-
} else if (!activeIsChild && overSelf) {
|
|
382
|
-
setItemsWithPreview((items2) => [
|
|
383
|
-
...items2,
|
|
384
|
-
activeItem.item
|
|
385
|
-
]);
|
|
386
|
-
} else if (activeIsChild && !overIsChild) {
|
|
387
|
-
setItemsWithPreview((items2) => items2.filter((item) => item.id !== activeItem.item.id));
|
|
388
|
-
} else {
|
|
389
|
-
setItemsWithPreview(items);
|
|
390
|
-
}
|
|
391
|
-
}, [
|
|
392
|
-
operation,
|
|
393
|
-
activeItem,
|
|
394
|
-
overItem,
|
|
395
|
-
overParent,
|
|
396
|
-
lastOverParent,
|
|
397
|
-
path,
|
|
398
|
-
items
|
|
399
|
-
]);
|
|
400
|
-
return items.length === itemsWithPreview.length ? items : itemsWithPreview;
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
// packages/ui/react-ui-mosaic/src/mosaic/hooks/useItemsWithOrigin.ts
|
|
404
|
-
var useItemsWithOrigin = (path, items) => {
|
|
405
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
406
|
-
if (!activeItem || !overItem) {
|
|
407
|
-
return items;
|
|
408
|
-
}
|
|
409
|
-
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
410
|
-
const overIsChild = Path.hasChild(path, overItem.path);
|
|
411
|
-
if (activeIsChild && !overIsChild && operation !== "rearrange") {
|
|
412
|
-
return items.map((item) => {
|
|
413
|
-
if (item.id === activeItem.item.id) {
|
|
414
|
-
return {
|
|
415
|
-
...item,
|
|
416
|
-
id: `${item.id}--origin`
|
|
417
|
-
};
|
|
418
|
-
} else {
|
|
419
|
-
return item;
|
|
420
|
-
}
|
|
212
|
+
effects: setDrop.of(null)
|
|
421
213
|
});
|
|
422
214
|
} else {
|
|
423
|
-
|
|
215
|
+
view.dispatch({
|
|
216
|
+
changes: {
|
|
217
|
+
from: pos,
|
|
218
|
+
insert: ` [${event.text}](${event.url})`
|
|
219
|
+
},
|
|
220
|
+
effects: setDrop.of(null)
|
|
221
|
+
});
|
|
424
222
|
}
|
|
425
223
|
};
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
224
|
+
var setDrop = StateEffect.define();
|
|
225
|
+
var dropField = StateField.define({
|
|
226
|
+
create: () => Decoration.none,
|
|
227
|
+
update: (decorations, tr) => {
|
|
228
|
+
for (const effect of tr.effects) {
|
|
229
|
+
if (effect.is(setDrop)) {
|
|
230
|
+
if (effect.value === null) {
|
|
231
|
+
return Decoration.none;
|
|
232
|
+
}
|
|
233
|
+
return Decoration.set([
|
|
234
|
+
Decoration.widget({
|
|
235
|
+
widget: new class extends WidgetType {
|
|
236
|
+
toDOM() {
|
|
237
|
+
const dom = document.createElement("span");
|
|
238
|
+
dom.className = "cm-drop-cursor";
|
|
239
|
+
dom.style.borderLeft = "2px solid var(--color-accent-surface)";
|
|
240
|
+
dom.style.display = "inline-block";
|
|
241
|
+
dom.style.height = "1em";
|
|
242
|
+
dom.style.verticalAlign = "middle";
|
|
243
|
+
return dom;
|
|
244
|
+
}
|
|
245
|
+
}(),
|
|
246
|
+
side: 0
|
|
247
|
+
}).range(effect.value)
|
|
248
|
+
]);
|
|
447
249
|
}
|
|
448
|
-
clearTimeout(timer.current);
|
|
449
|
-
timer.current = setTimeout(() => setState({
|
|
450
|
-
container: container2,
|
|
451
|
-
OverlayComponent: OverlayComponent2
|
|
452
|
-
}), timer.current ? delay : 0);
|
|
453
|
-
} else {
|
|
454
|
-
setState({});
|
|
455
250
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
251
|
+
return decorations.map(tr.changes);
|
|
252
|
+
},
|
|
253
|
+
provide: (field) => EditorView.decorations.from(field)
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// src/components/Board/Column.tsx
|
|
257
|
+
import { useAtomValue } from "@effect-atom/atom-react";
|
|
258
|
+
import { createContext } from "@radix-ui/react-context";
|
|
259
|
+
import React3, { forwardRef as forwardRef3, useMemo as useMemo4, useState as useState2 } from "react";
|
|
260
|
+
import { Obj as Obj2, Ref } from "@dxos/echo";
|
|
261
|
+
import { useObject } from "@dxos/react-client/echo";
|
|
262
|
+
import { IconButton, ScrollArea, Toolbar as Toolbar2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
263
|
+
import { Menu as Menu2, createMenuAction as createMenuAction2 } from "@dxos/react-ui-menu";
|
|
264
|
+
import { composable, composableProps, mx as mx2 } from "@dxos/ui-theme";
|
|
265
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
266
|
+
|
|
267
|
+
// src/components/Board/Item.tsx
|
|
268
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
269
|
+
import React2, { forwardRef as forwardRef2, useMemo as useMemo3, useRef as useRef2, useState } from "react";
|
|
270
|
+
import { Obj } from "@dxos/echo";
|
|
271
|
+
import { Card, Tag, Toolbar, useTranslation } from "@dxos/react-ui";
|
|
272
|
+
import { Menu, createMenuAction } from "@dxos/react-ui-menu";
|
|
273
|
+
import { getHashStyles } from "@dxos/ui-theme";
|
|
274
|
+
import { translationKey } from "#translations";
|
|
275
|
+
var BOARD_ITEM_NAME = "Board.Item";
|
|
276
|
+
var BoardItemInner = /* @__PURE__ */ forwardRef2(({ classNames, data, location, debug, draggable }, forwardedRef) => {
|
|
277
|
+
const { t } = useTranslation(translationKey);
|
|
278
|
+
const rootRef = useRef2(null);
|
|
279
|
+
const composedRef = useComposedRefs(rootRef, forwardedRef);
|
|
280
|
+
const [dragHandle, setDragHandle] = useState(null);
|
|
281
|
+
const { model } = useBoard(BOARD_ITEM_NAME);
|
|
282
|
+
const column = useBoardColumn();
|
|
283
|
+
const items = useMemo3(() => column != null && model.onItemDelete ? [
|
|
284
|
+
createMenuAction("delete-item", () => model.onItemDelete?.(column, data), {
|
|
285
|
+
label: t("delete-menu.label"),
|
|
286
|
+
icon: "ph--trash--regular"
|
|
287
|
+
})
|
|
288
|
+
] : [], [
|
|
289
|
+
column,
|
|
290
|
+
data,
|
|
291
|
+
model.onItemDelete,
|
|
292
|
+
t
|
|
459
293
|
]);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
const FallbackComponent = (activeItem && containers[Path.first(activeItem.path)])?.Component ?? DefaultComponent;
|
|
463
|
-
return (
|
|
464
|
-
// TODO(burdon): Set custom animations (e.g., in/out/around).
|
|
465
|
-
/* @__PURE__ */ React5.createElement(DragOverlay, {
|
|
466
|
-
adjustScale: false,
|
|
467
|
-
...overlayProps,
|
|
468
|
-
dropAnimation,
|
|
469
|
-
style: {
|
|
470
|
-
...container?.getOverlayStyle?.()
|
|
471
|
-
}
|
|
472
|
-
}, activeItem?.path && container && OverlayComponent && /* @__PURE__ */ React5.createElement(OverlayErrorBoundary, {
|
|
473
|
-
fallback: /* @__PURE__ */ React5.createElement(FallbackComponent, {
|
|
474
|
-
...container.getOverlayProps?.(),
|
|
475
|
-
item: activeItem.item,
|
|
476
|
-
path: activeItem.path,
|
|
477
|
-
operation,
|
|
478
|
-
active: "overlay"
|
|
479
|
-
})
|
|
480
|
-
}, /* @__PURE__ */ React5.createElement(OverlayComponent, {
|
|
481
|
-
...container.getOverlayProps?.(),
|
|
482
|
-
item: activeItem.item,
|
|
483
|
-
path: activeItem.path,
|
|
484
|
-
type: activeItem.type,
|
|
485
|
-
operation,
|
|
486
|
-
active: "overlay"
|
|
487
|
-
}), debug && /* @__PURE__ */ React5.createElement("div", {
|
|
488
|
-
className: "flex flex-wrap mt-1 p-1 bg-neutral-50 dark:bg-neutral-700 text-xs border rounded overflow-hidden gap-1"
|
|
489
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
490
|
-
className: "truncate"
|
|
491
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
492
|
-
className: "text-neutral-400"
|
|
493
|
-
}, "container "), container.id), /* @__PURE__ */ React5.createElement("span", {
|
|
494
|
-
className: "truncate"
|
|
495
|
-
}, /* @__PURE__ */ React5.createElement("span", {
|
|
496
|
-
className: "text-neutral-400"
|
|
497
|
-
}, "item "), activeItem.item.id.slice(0, 8)))))
|
|
498
|
-
);
|
|
499
|
-
};
|
|
500
|
-
var OverlayErrorBoundary = class extends Component {
|
|
501
|
-
constructor(props) {
|
|
502
|
-
super(props);
|
|
503
|
-
this.state = {
|
|
504
|
-
error: null
|
|
505
|
-
};
|
|
506
|
-
this.fallback = props.fallback ?? /* @__PURE__ */ React5.createElement("p", null, "ERROR: $", String(this.state.error));
|
|
507
|
-
}
|
|
508
|
-
static getDerivedStateFromError(error) {
|
|
509
|
-
return {
|
|
510
|
-
error
|
|
511
|
-
};
|
|
294
|
+
if (!data) {
|
|
295
|
+
return null;
|
|
512
296
|
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
297
|
+
const label = Obj.getLabel(data);
|
|
298
|
+
const description = Obj.getDescription(data);
|
|
299
|
+
return /* @__PURE__ */ React2.createElement(Menu.Root, null, /* @__PURE__ */ React2.createElement(Mosaic.Tile, {
|
|
300
|
+
ref: rootRef,
|
|
301
|
+
asChild: true,
|
|
302
|
+
draggable,
|
|
303
|
+
dragHandle,
|
|
304
|
+
id: data.id,
|
|
305
|
+
data,
|
|
306
|
+
location,
|
|
307
|
+
debug
|
|
308
|
+
}, /* @__PURE__ */ React2.createElement(Focus.Item, {
|
|
309
|
+
asChild: true
|
|
310
|
+
}, /* @__PURE__ */ React2.createElement(Card.Root, {
|
|
311
|
+
classNames,
|
|
312
|
+
"data-testid": "board-item",
|
|
313
|
+
ref: composedRef,
|
|
314
|
+
onClick: (event) => event.currentTarget.focus()
|
|
315
|
+
}, /* @__PURE__ */ React2.createElement(Card.Toolbar, null, /* @__PURE__ */ React2.createElement(Card.DragHandle, {
|
|
316
|
+
ref: setDragHandle,
|
|
317
|
+
testId: "mosaicBoard.cardDragHandle"
|
|
318
|
+
}), /* @__PURE__ */ React2.createElement(Card.Title, {
|
|
319
|
+
"data-testid": "mosaicBoard.cardTitle"
|
|
320
|
+
}, label), /* @__PURE__ */ React2.createElement(Menu.Trigger, {
|
|
321
|
+
asChild: true,
|
|
322
|
+
disabled: !items?.length
|
|
323
|
+
}, /* @__PURE__ */ React2.createElement(Toolbar.IconButton, {
|
|
324
|
+
iconOnly: true,
|
|
325
|
+
variant: "ghost",
|
|
326
|
+
icon: "ph--dots-three-vertical--regular",
|
|
327
|
+
label: t("action-menu.label")
|
|
328
|
+
})), /* @__PURE__ */ React2.createElement(Menu.Content, {
|
|
329
|
+
items
|
|
330
|
+
})), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
331
|
+
icon: "ph--note--regular",
|
|
332
|
+
classNames: "text-description"
|
|
333
|
+
}, /* @__PURE__ */ React2.createElement(Card.Text, null, description)), /* @__PURE__ */ React2.createElement(Card.Row, {
|
|
334
|
+
icon: "ph--tag--regular"
|
|
335
|
+
}, label && /* @__PURE__ */ React2.createElement("div", {
|
|
336
|
+
className: "shrink-0 flex gap-1 items-center text-xs"
|
|
337
|
+
}, /* @__PURE__ */ React2.createElement(Tag, {
|
|
338
|
+
palette: getHashStyles(label).hue
|
|
339
|
+
}, label)))))));
|
|
340
|
+
});
|
|
341
|
+
BoardItemInner.displayName = BOARD_ITEM_NAME;
|
|
342
|
+
var BoardItem = BoardItemInner;
|
|
530
343
|
|
|
531
|
-
//
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
344
|
+
// src/components/Board/Column.tsx
|
|
345
|
+
var BOARD_COLUMN_CONTEXT_NAME = "Board.Column";
|
|
346
|
+
var [BoardColumnProvider, useBoardColumnContext] = createContext(BOARD_COLUMN_CONTEXT_NAME, null);
|
|
347
|
+
function useBoardColumn() {
|
|
348
|
+
const value = useBoardColumnContext(BOARD_COLUMN_CONTEXT_NAME);
|
|
349
|
+
return value?.column;
|
|
350
|
+
}
|
|
351
|
+
var BOARD_COLUMN_ROOT_NAME = "Board.Column.Root";
|
|
352
|
+
var BoardColumnRootInner = composable(({ classNames, children, location, data, debug, draggable, dragHandle, ...rest }, forwardedRef) => {
|
|
353
|
+
const { model } = useBoard(BOARD_COLUMN_ROOT_NAME);
|
|
354
|
+
return /* @__PURE__ */ React3.createElement(Mosaic.Tile, {
|
|
355
|
+
asChild: true,
|
|
356
|
+
location,
|
|
357
|
+
id: model.getColumnId(data),
|
|
358
|
+
data,
|
|
359
|
+
debug,
|
|
360
|
+
draggable,
|
|
361
|
+
dragHandle
|
|
362
|
+
}, /* @__PURE__ */ React3.createElement(Focus.Group, {
|
|
363
|
+
...rest,
|
|
364
|
+
"data-testid": "board-column",
|
|
365
|
+
border: true,
|
|
366
|
+
classNames: mx2("group/column", "h-full w-full md:w-card-default-width snap-center bg-deck-surface", "overflow-hidden", classNames),
|
|
367
|
+
ref: forwardedRef
|
|
368
|
+
}, /* @__PURE__ */ React3.createElement(BoardColumnProvider, {
|
|
369
|
+
column: data
|
|
370
|
+
}, children)));
|
|
371
|
+
});
|
|
372
|
+
BoardColumnRootInner.displayName = BOARD_COLUMN_ROOT_NAME;
|
|
373
|
+
var BoardColumnRoot = BoardColumnRootInner;
|
|
374
|
+
var BOARD_COLUMN_HEADER_NAME = "Board.Column.Header";
|
|
375
|
+
var BoardColumnHeader = composable(({ label, dragHandleRef, ...props }, forwardedRef) => {
|
|
376
|
+
const { t } = useTranslation2(translationKey2);
|
|
377
|
+
const { model } = useBoard(BOARD_COLUMN_HEADER_NAME);
|
|
378
|
+
const column = useBoardColumn();
|
|
379
|
+
const columnMenuItems = useMemo4(() => column != null && model.onColumnDelete ? [
|
|
380
|
+
createMenuAction2("delete-column", () => model.onColumnDelete?.(column), {
|
|
381
|
+
label: t("delete-menu.label"),
|
|
382
|
+
icon: "ph--trash--regular"
|
|
383
|
+
})
|
|
384
|
+
] : [], [
|
|
385
|
+
column,
|
|
386
|
+
model.onColumnDelete,
|
|
387
|
+
t
|
|
388
|
+
]);
|
|
389
|
+
return /* @__PURE__ */ React3.createElement(Menu2.Root, null, /* @__PURE__ */ React3.createElement(Toolbar2.Root, {
|
|
390
|
+
...composableProps(props),
|
|
391
|
+
"data-testid": "board-column-header",
|
|
392
|
+
ref: forwardedRef
|
|
393
|
+
}, /* @__PURE__ */ React3.createElement(Toolbar2.DragHandle, {
|
|
394
|
+
ref: dragHandleRef,
|
|
395
|
+
testId: "mosaicBoard.columnDragHandle"
|
|
396
|
+
}), /* @__PURE__ */ React3.createElement(Toolbar2.Text, {
|
|
397
|
+
"data-testid": "mosaicBoard.columnTitle"
|
|
398
|
+
}, label), /* @__PURE__ */ React3.createElement(Menu2.Trigger, {
|
|
399
|
+
asChild: true,
|
|
400
|
+
disabled: !columnMenuItems?.length
|
|
401
|
+
}, /* @__PURE__ */ React3.createElement(Toolbar2.IconButton, {
|
|
402
|
+
iconOnly: true,
|
|
403
|
+
variant: "ghost",
|
|
404
|
+
icon: "ph--dots-three-vertical--regular",
|
|
405
|
+
label: t("action-menu.label")
|
|
406
|
+
})), /* @__PURE__ */ React3.createElement(Menu2.Content, {
|
|
407
|
+
items: columnMenuItems
|
|
408
|
+
})));
|
|
409
|
+
});
|
|
410
|
+
BoardColumnHeader.displayName = BOARD_COLUMN_HEADER_NAME;
|
|
411
|
+
var BOARD_COLUMN_BODY_NAME = "Board.Column.Body";
|
|
412
|
+
var BoardColumnBody = composable(({ data, eventHandler, Tile = BoardItem, debug, ...props }, forwardedRef) => {
|
|
413
|
+
const { model } = useBoard(BOARD_COLUMN_BODY_NAME);
|
|
414
|
+
const [viewport, setViewport] = useState2(null);
|
|
415
|
+
const items = useAtomValue(model.items(data));
|
|
416
|
+
return /* @__PURE__ */ React3.createElement(Mosaic.Container, {
|
|
417
|
+
...composableProps(props),
|
|
418
|
+
asChild: true,
|
|
419
|
+
withFocus: true,
|
|
420
|
+
orientation: "vertical",
|
|
421
|
+
autoScroll: viewport,
|
|
422
|
+
eventHandler,
|
|
423
|
+
debug,
|
|
424
|
+
ref: forwardedRef
|
|
425
|
+
}, /* @__PURE__ */ React3.createElement(ScrollArea.Root, {
|
|
426
|
+
orientation: "vertical",
|
|
427
|
+
thin: true,
|
|
428
|
+
centered: true,
|
|
429
|
+
padding: true
|
|
430
|
+
}, /* @__PURE__ */ React3.createElement(ScrollArea.Viewport, {
|
|
431
|
+
classNames: "snap-y md:snap-none",
|
|
432
|
+
ref: setViewport
|
|
433
|
+
}, /* @__PURE__ */ React3.createElement(Mosaic.Stack, {
|
|
434
|
+
items,
|
|
435
|
+
getId: model.getItemId,
|
|
436
|
+
Tile
|
|
437
|
+
}))));
|
|
438
|
+
});
|
|
439
|
+
BoardColumnBody.displayName = BOARD_COLUMN_BODY_NAME;
|
|
440
|
+
var BOARD_COLUMN_FOOTER_NAME = "Board.Column.Footer";
|
|
441
|
+
var BoardColumnFooter = /* @__PURE__ */ forwardRef3(({ classNames, data, onAdd }, forwardedRef) => {
|
|
442
|
+
const { t } = useTranslation2(translationKey2);
|
|
443
|
+
const { model } = useBoard(BOARD_COLUMN_FOOTER_NAME);
|
|
444
|
+
const handleAdd = onAdd ?? (model.onItemCreate && data ? () => void model.onItemCreate?.(data) : void 0);
|
|
445
|
+
return /* @__PURE__ */ React3.createElement(Toolbar2.Root, {
|
|
446
|
+
classNames: mx2("rounded-b-sm border-t border-separator", classNames),
|
|
447
|
+
ref: forwardedRef
|
|
448
|
+
}, handleAdd && /* @__PURE__ */ React3.createElement(IconButton, {
|
|
449
|
+
"data-testid": "board-column-add-item",
|
|
450
|
+
classNames: "group-hover/column:opacity-100 md:opacity-0 transition transition-opacity duration-500",
|
|
451
|
+
variant: "ghost",
|
|
452
|
+
icon: "ph--plus--regular",
|
|
453
|
+
iconOnly: true,
|
|
454
|
+
label: t("add-item.label"),
|
|
455
|
+
onClick: handleAdd
|
|
456
|
+
}));
|
|
457
|
+
});
|
|
458
|
+
BoardColumnFooter.displayName = BOARD_COLUMN_FOOTER_NAME;
|
|
459
|
+
var BOARD_DEFAULT_COLUMN_NAME = "Board.DefaultColumn";
|
|
460
|
+
var DefaultBoardColumn = /* @__PURE__ */ forwardRef3(({ classNames, location, data, debug, draggable, Tile = BoardItem }, forwardedRef) => {
|
|
461
|
+
const { model } = useBoard(BOARD_DEFAULT_COLUMN_NAME);
|
|
462
|
+
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
463
|
+
const [dragHandle, setDragHandle] = useState2(null);
|
|
464
|
+
const [column, updateColumn] = useObject(data);
|
|
465
|
+
const eventHandler = useEventHandlerAdapter({
|
|
466
|
+
id: model.getColumnId(data),
|
|
467
|
+
items: column?.items ?? [],
|
|
468
|
+
getId: (ref) => ref.target?.id ?? ref.dxn.toString(),
|
|
469
|
+
get: (refOrObj) => Ref.isRef(refOrObj) ? refOrObj.target : refOrObj,
|
|
470
|
+
make: (object) => Ref.make(object),
|
|
471
|
+
canDrop: ({ source }) => {
|
|
472
|
+
const item = Ref.isRef(source.data) ? source.data.target : source.data;
|
|
473
|
+
return item != null && Obj2.isObject(item) && model.isItem(item);
|
|
474
|
+
},
|
|
475
|
+
onChange: (mutator) => updateColumn((col) => mutator(col.items))
|
|
543
476
|
});
|
|
544
|
-
return /* @__PURE__ */
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
477
|
+
return /* @__PURE__ */ React3.createElement(BoardColumnRootInner, {
|
|
478
|
+
classNames: mx2("group/column grid", debug ? "grid-rows-[var(--dx-rail-action)_1fr_20rem]" : "grid-rows-[var(--dx-rail-action)_1fr_var(--dx-rail-action)]", classNames),
|
|
479
|
+
location,
|
|
480
|
+
data,
|
|
481
|
+
draggable,
|
|
482
|
+
dragHandle,
|
|
483
|
+
ref: forwardedRef
|
|
484
|
+
}, /* @__PURE__ */ React3.createElement(BoardColumnHeader, {
|
|
485
|
+
label: Obj2.getLabel(data) ?? data.id,
|
|
486
|
+
dragHandleRef: setDragHandle
|
|
487
|
+
}), /* @__PURE__ */ React3.createElement(BoardColumnBody, {
|
|
488
|
+
data,
|
|
489
|
+
eventHandler,
|
|
490
|
+
debug: debugHandler,
|
|
491
|
+
Tile
|
|
492
|
+
}), /* @__PURE__ */ React3.createElement("div", {
|
|
493
|
+
className: "flex flex-col col-span-full"
|
|
494
|
+
}, /* @__PURE__ */ React3.createElement(BoardColumnFooter, {
|
|
495
|
+
data
|
|
496
|
+
}), /* @__PURE__ */ React3.createElement(DebugInfo, null)));
|
|
497
|
+
});
|
|
498
|
+
DefaultBoardColumn.displayName = BOARD_DEFAULT_COLUMN_NAME;
|
|
499
|
+
var BoardColumn = {
|
|
500
|
+
Root: BoardColumnRoot,
|
|
501
|
+
Header: BoardColumnHeader,
|
|
502
|
+
Body: BoardColumnBody,
|
|
503
|
+
Footer: BoardColumnFooter
|
|
548
504
|
};
|
|
549
|
-
var Column = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
|
|
550
|
-
id,
|
|
551
|
-
items,
|
|
552
|
-
strategy: verticalListSortingStrategy
|
|
553
|
-
}, children);
|
|
554
|
-
var Row = ({ children, id, items }) => /* @__PURE__ */ React6.createElement(SortableContext, {
|
|
555
|
-
id,
|
|
556
|
-
items,
|
|
557
|
-
strategy: horizontalListSortingStrategy
|
|
558
|
-
}, children);
|
|
559
505
|
|
|
560
|
-
//
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
listeners,
|
|
572
|
-
/* transform, */
|
|
573
|
-
isDragging
|
|
574
|
-
} = useDraggable({
|
|
575
|
-
id: path,
|
|
576
|
-
data: {
|
|
577
|
-
path,
|
|
578
|
-
type,
|
|
579
|
-
item,
|
|
580
|
-
position
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
return /* @__PURE__ */ React7.createElement(Component2, {
|
|
584
|
-
ref: setNodeRef,
|
|
585
|
-
item,
|
|
586
|
-
path,
|
|
587
|
-
type,
|
|
588
|
-
position,
|
|
589
|
-
operation,
|
|
590
|
-
isDragging,
|
|
591
|
-
draggableStyle: {
|
|
592
|
-
// TODO(burdon): Override by container?
|
|
593
|
-
// transform: getTransformCSS(transform),
|
|
594
|
-
...draggableStyle
|
|
595
|
-
},
|
|
596
|
-
draggableProps: {
|
|
597
|
-
...attributes,
|
|
598
|
-
...listeners
|
|
599
|
-
},
|
|
600
|
-
...props
|
|
601
|
-
});
|
|
506
|
+
// src/components/Board/Board.tsx
|
|
507
|
+
var BOARD_NAME = "Board";
|
|
508
|
+
var [BoardContextProvider, useBoardContext] = createContext2(BOARD_NAME);
|
|
509
|
+
function useBoard(displayName) {
|
|
510
|
+
return useBoardContext(displayName ?? BOARD_NAME);
|
|
511
|
+
}
|
|
512
|
+
var BOARD_ROOT_NAME = "Board.Root";
|
|
513
|
+
var BoardRootInner = ({ model, children }) => {
|
|
514
|
+
return /* @__PURE__ */ React4.createElement(BoardContextProvider, {
|
|
515
|
+
model
|
|
516
|
+
}, children);
|
|
602
517
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
518
|
+
BoardRootInner.displayName = BOARD_ROOT_NAME;
|
|
519
|
+
var BoardRoot = BoardRootInner;
|
|
520
|
+
var BOARD_CONTENT_NAME = "Board.Content";
|
|
521
|
+
var BoardContentInner = composable2(({ id: _id, debug, eventHandler, Tile = DefaultBoardColumn, ...props }, forwardedRef) => {
|
|
522
|
+
const { model } = useBoardContext(BOARD_CONTENT_NAME);
|
|
523
|
+
const [DebugInfo, debugHandler] = useContainerDebug(debug);
|
|
524
|
+
const [viewport, setViewport] = useState3(null);
|
|
525
|
+
const items = useAtomValue2(model.columns);
|
|
526
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
527
|
+
...composableProps2(props, {
|
|
528
|
+
classNames: "dx-container"
|
|
529
|
+
}),
|
|
530
|
+
ref: forwardedRef
|
|
531
|
+
}, /* @__PURE__ */ React4.createElement(Focus.Group, {
|
|
532
|
+
asChild: true,
|
|
533
|
+
orientation: "horizontal"
|
|
534
|
+
}, /* @__PURE__ */ React4.createElement(Mosaic.Container, {
|
|
535
|
+
asChild: true,
|
|
536
|
+
withFocus: true,
|
|
537
|
+
orientation: "horizontal",
|
|
538
|
+
autoScroll: viewport,
|
|
539
|
+
eventHandler,
|
|
540
|
+
debug: debugHandler
|
|
541
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea2.Root, {
|
|
542
|
+
orientation: "horizontal",
|
|
543
|
+
centered: true,
|
|
544
|
+
padding: true
|
|
545
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea2.Viewport, {
|
|
546
|
+
classNames: "snap-mandatory snap-x md:snap-none",
|
|
547
|
+
ref: setViewport
|
|
548
|
+
}, /* @__PURE__ */ React4.createElement(Mosaic.Stack, {
|
|
549
|
+
items,
|
|
550
|
+
getId: model.getColumnId,
|
|
551
|
+
Tile,
|
|
552
|
+
debug
|
|
553
|
+
}))))), /* @__PURE__ */ React4.createElement(DebugInfo, null));
|
|
626
554
|
});
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
555
|
+
BoardContentInner.displayName = BOARD_CONTENT_NAME;
|
|
556
|
+
var BoardContent = BoardContentInner;
|
|
557
|
+
var BOARD_PLACEHOLDER_NAME = "Board.Placeholder";
|
|
558
|
+
var BoardPlaceholder = (props) => {
|
|
559
|
+
return /* @__PURE__ */ React4.createElement(Mosaic.Placeholder, {
|
|
560
|
+
...props,
|
|
561
|
+
classNames: styles.placeholder.root
|
|
562
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
563
|
+
className: mx3("flex h-full border border-dashed border-separator rounded-xs", styles.placeholder.content)
|
|
564
|
+
}));
|
|
565
|
+
};
|
|
566
|
+
BoardPlaceholder.displayName = BOARD_PLACEHOLDER_NAME;
|
|
567
|
+
var BOARD_DEBUG_NAME = "Board.Debug";
|
|
568
|
+
var BoardDebug = /* @__PURE__ */ forwardRef4(({ classNames }, forwardedRef) => {
|
|
569
|
+
const { containers, dragging } = useMosaicRootContext(BOARD_DEBUG_NAME);
|
|
570
|
+
const counter = useRef3(0);
|
|
571
|
+
return /* @__PURE__ */ React4.createElement(JsonHighlighter2, {
|
|
634
572
|
data: {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
position
|
|
639
|
-
},
|
|
640
|
-
animateLayoutChanges: (args) => defaultAnimateLayoutChanges({
|
|
641
|
-
...args,
|
|
642
|
-
wasDragging: item.id !== activeItem?.item.id
|
|
643
|
-
})
|
|
644
|
-
});
|
|
645
|
-
let active;
|
|
646
|
-
if (isDragging) {
|
|
647
|
-
if (operation === "rearrange" || operation === "reject") {
|
|
648
|
-
active = "rearrange";
|
|
649
|
-
} else if (activeItem && activeItem.path && Path.parent(activeItem.path) !== parentPath) {
|
|
650
|
-
active = "destination";
|
|
651
|
-
} else {
|
|
652
|
-
active = "origin";
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
const Component2 = OverrideComponent ?? ContainerComponent ?? DefaultComponent;
|
|
656
|
-
return /* @__PURE__ */ React7.createElement(Component2, {
|
|
657
|
-
ref: setNodeRef,
|
|
658
|
-
item,
|
|
659
|
-
path,
|
|
660
|
-
type,
|
|
661
|
-
position,
|
|
662
|
-
operation,
|
|
663
|
-
active,
|
|
664
|
-
isDragging,
|
|
665
|
-
isOver,
|
|
666
|
-
draggableStyle: {
|
|
667
|
-
transform: getTransformCSS(transform),
|
|
668
|
-
transition: transform ? `transform ${transitionDuration}ms ease` : "none",
|
|
669
|
-
...draggableStyle
|
|
670
|
-
},
|
|
671
|
-
draggableProps: {
|
|
672
|
-
...attributes,
|
|
673
|
-
...listeners
|
|
573
|
+
containers,
|
|
574
|
+
dragging,
|
|
575
|
+
count: counter.current++
|
|
674
576
|
},
|
|
675
|
-
|
|
577
|
+
classNames: mx3("text-xs", classNames),
|
|
578
|
+
ref: forwardedRef
|
|
676
579
|
});
|
|
580
|
+
});
|
|
581
|
+
BoardDebug.displayName = BOARD_DEBUG_NAME;
|
|
582
|
+
var Board = {
|
|
583
|
+
Root: BoardRoot,
|
|
584
|
+
Content: BoardContent,
|
|
585
|
+
Column: BoardColumn,
|
|
586
|
+
Item: BoardItem,
|
|
587
|
+
Placeholder: BoardPlaceholder,
|
|
588
|
+
Debug: BoardDebug
|
|
677
589
|
};
|
|
678
590
|
|
|
679
|
-
//
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
591
|
+
// src/components/SearchStack/SearchStack.tsx
|
|
592
|
+
import React5, { forwardRef as forwardRef5, useCallback, useMemo as useMemo5, useState as useState4 } from "react";
|
|
593
|
+
import { Card as Card2, ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
594
|
+
import { composable as composable3, composableProps as composableProps3 } from "@dxos/ui-theme";
|
|
595
|
+
var SearchStack = composable3(({ results = [], currentId, onAction, ...props }, forwardedRef) => {
|
|
596
|
+
const [viewport, setViewport] = useState4(null);
|
|
597
|
+
const items = useMemo5(() => results.map((result) => ({
|
|
598
|
+
result,
|
|
599
|
+
onAction
|
|
600
|
+
})), [
|
|
601
|
+
results,
|
|
602
|
+
onAction
|
|
603
|
+
]);
|
|
604
|
+
const handleCurrentChange = useCallback((id) => {
|
|
605
|
+
if (id) {
|
|
606
|
+
onAction?.({
|
|
607
|
+
type: "select",
|
|
608
|
+
resultId: id
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}, [
|
|
612
|
+
onAction
|
|
613
|
+
]);
|
|
614
|
+
const handleKeyDown = useCallback((event) => {
|
|
615
|
+
if (event.key === "Enter") {
|
|
616
|
+
event.preventDefault();
|
|
617
|
+
document.activeElement?.click();
|
|
618
|
+
}
|
|
619
|
+
}, []);
|
|
620
|
+
return /* @__PURE__ */ React5.createElement(Focus.Group, {
|
|
621
|
+
asChild: true,
|
|
622
|
+
...composableProps3(props),
|
|
623
|
+
onKeyDown: handleKeyDown,
|
|
624
|
+
ref: forwardedRef
|
|
625
|
+
}, /* @__PURE__ */ React5.createElement(Mosaic.Container, {
|
|
626
|
+
asChild: true,
|
|
627
|
+
withFocus: true,
|
|
628
|
+
currentId,
|
|
629
|
+
onCurrentChange: handleCurrentChange
|
|
630
|
+
}, /* @__PURE__ */ React5.createElement(ScrollArea3.Root, {
|
|
631
|
+
orientation: "vertical",
|
|
632
|
+
padding: true,
|
|
633
|
+
centered: true,
|
|
634
|
+
thin: true
|
|
635
|
+
}, /* @__PURE__ */ React5.createElement(ScrollArea3.Viewport, {
|
|
636
|
+
ref: setViewport
|
|
637
|
+
}, /* @__PURE__ */ React5.createElement(Mosaic.VirtualStack, {
|
|
638
|
+
Tile: SearchTile,
|
|
639
|
+
classNames: "my-2",
|
|
640
|
+
gap: 8,
|
|
641
|
+
items,
|
|
642
|
+
draggable: false,
|
|
643
|
+
getId: (item) => item.result.id,
|
|
644
|
+
getScrollElement: () => viewport,
|
|
645
|
+
estimateSize: () => 100
|
|
646
|
+
})))));
|
|
647
|
+
});
|
|
648
|
+
SearchStack.displayName = "SearchStack";
|
|
649
|
+
var SearchTile = /* @__PURE__ */ forwardRef5(({ data, location, current }, forwardedRef) => {
|
|
650
|
+
const { result } = data;
|
|
651
|
+
const { setCurrentId } = useMosaicContainerContext("SearchTile");
|
|
652
|
+
const handleCurrentChange = useCallback(() => {
|
|
653
|
+
setCurrentId(result.id);
|
|
654
|
+
}, [
|
|
655
|
+
result.id,
|
|
656
|
+
setCurrentId
|
|
657
|
+
]);
|
|
658
|
+
return /* @__PURE__ */ React5.createElement(Mosaic.Tile, {
|
|
659
|
+
asChild: true,
|
|
660
|
+
classNames: "dx-hover dx-current",
|
|
661
|
+
id: result.id,
|
|
662
|
+
data,
|
|
663
|
+
location,
|
|
664
|
+
current
|
|
665
|
+
}, /* @__PURE__ */ React5.createElement(Focus.Item, {
|
|
666
|
+
asChild: true,
|
|
667
|
+
current,
|
|
668
|
+
onCurrentChange: handleCurrentChange
|
|
669
|
+
}, /* @__PURE__ */ React5.createElement(Card2.Root, {
|
|
670
|
+
fullWidth: true,
|
|
671
|
+
ref: forwardedRef
|
|
672
|
+
}, /* @__PURE__ */ React5.createElement(Card2.Toolbar, null, /* @__PURE__ */ React5.createElement(Card2.IconBlock, null), /* @__PURE__ */ React5.createElement(Card2.Title, null, result.label)), result.snippet && /* @__PURE__ */ React5.createElement(Card2.Content, null, /* @__PURE__ */ React5.createElement(Card2.Row, null, /* @__PURE__ */ React5.createElement(Card2.Text, {
|
|
673
|
+
variant: "description"
|
|
674
|
+
}, result.snippet))))));
|
|
675
|
+
});
|
|
676
|
+
SearchTile.displayName = "SearchTile";
|
|
693
677
|
export {
|
|
678
|
+
Board,
|
|
679
|
+
BoardDebug,
|
|
680
|
+
Focus,
|
|
694
681
|
Mosaic,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
682
|
+
SearchStack,
|
|
683
|
+
dropHandler,
|
|
684
|
+
getSourceData,
|
|
685
|
+
styles as mosaicStyles,
|
|
686
|
+
useBoard,
|
|
687
|
+
useBoardColumn,
|
|
688
|
+
useContainerDebug,
|
|
689
|
+
useDefaultColumnEventHandler,
|
|
690
|
+
useEventHandlerAdapter,
|
|
691
|
+
useFocus,
|
|
692
|
+
useMosaicRootContext as useMosaic,
|
|
693
|
+
useMosaicContainerContext as useMosaicContainer,
|
|
694
|
+
useMosaicTileContext as useMosaicTile,
|
|
695
|
+
useVisibleItems
|
|
704
696
|
};
|
|
705
697
|
//# sourceMappingURL=index.mjs.map
|