@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,69 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { useMosaic } from './useMosaic';
|
|
8
|
-
import { type MosaicDataItem } from '../types';
|
|
9
|
-
import { Path } from '../util';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Returns a spliced collection of items including a placeholder if items that could drop,
|
|
13
|
-
* and removing any item that is currently being dragged out.
|
|
14
|
-
*/
|
|
15
|
-
export const useItemsWithPreview = <T extends MosaicDataItem>({ path, items }: { path: string; items: T[] }): T[] => {
|
|
16
|
-
const { operation, activeItem, overItem } = useMosaic();
|
|
17
|
-
const [itemsWithPreview, setItemsWithPreview] = useState(items);
|
|
18
|
-
const overParent =
|
|
19
|
-
// If over the sortable context itself & active item is foreign, then treat self as the parent.
|
|
20
|
-
// This allows items to be appended to the end of the sortable.
|
|
21
|
-
overItem?.path === path && activeItem && Path.parent(activeItem.path) !== overItem.path
|
|
22
|
-
? path
|
|
23
|
-
: overItem && !!overItem.path && Path.parent(overItem.path);
|
|
24
|
-
const [lastOverParent, setLastOverParent] = useState(overParent);
|
|
25
|
-
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
if (!activeItem || !overItem) {
|
|
28
|
-
setLastOverParent(undefined);
|
|
29
|
-
setItemsWithPreview(items);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (lastOverParent === overParent) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
38
|
-
const overIsChild = Path.hasChild(path, overItem.path);
|
|
39
|
-
const overSelf = overItem.path === path;
|
|
40
|
-
|
|
41
|
-
if (operation === 'reject' || operation === 'rearrange') {
|
|
42
|
-
setLastOverParent(undefined);
|
|
43
|
-
setItemsWithPreview(items);
|
|
44
|
-
return;
|
|
45
|
-
} else {
|
|
46
|
-
setLastOverParent(overParent);
|
|
47
|
-
}
|
|
48
|
-
if (!activeIsChild && overIsChild) {
|
|
49
|
-
// Insert item into sortable.
|
|
50
|
-
setItemsWithPreview((items) => {
|
|
51
|
-
const position = overItem.position as number;
|
|
52
|
-
return [...items.slice(0, position), activeItem.item as T, ...items.slice(position)];
|
|
53
|
-
});
|
|
54
|
-
} else if (!activeIsChild && overSelf) {
|
|
55
|
-
// Append item to end of sortable.
|
|
56
|
-
setItemsWithPreview((items) => [...items, activeItem.item as T]);
|
|
57
|
-
} else if (activeIsChild && !overIsChild) {
|
|
58
|
-
// Remove item being dragged out.
|
|
59
|
-
setItemsWithPreview((items) => items.filter((item) => item.id !== activeItem.item.id));
|
|
60
|
-
} else {
|
|
61
|
-
// Reset items.
|
|
62
|
-
setItemsWithPreview(items);
|
|
63
|
-
}
|
|
64
|
-
}, [operation, activeItem, overItem, overParent, lastOverParent, path, items]);
|
|
65
|
-
|
|
66
|
-
// In order to avoid render glitching, rather than waiting for the effect to run,
|
|
67
|
-
// immediately return the new items after dropping an item into a new path.
|
|
68
|
-
return items.length === itemsWithPreview.length ? items : itemsWithPreview;
|
|
69
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useContext } from 'react';
|
|
6
|
-
|
|
7
|
-
import { raise } from '@dxos/debug';
|
|
8
|
-
|
|
9
|
-
import { MosaicContext } from '../Root';
|
|
10
|
-
|
|
11
|
-
export const useMosaic = () => useContext(MosaicContext) ?? raise(new Error('Missing MosaicContext'));
|
package/src/mosaic/index.ts
DELETED
package/src/mosaic/types.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(wittjosiah): Rename MosiacDataItem to MosaicItemData?
|
|
6
|
-
export type MosaicDataItem = { id: string };
|
|
7
|
-
|
|
8
|
-
export type MosaicDraggedItem<TPosition = unknown> = {
|
|
9
|
-
path: string;
|
|
10
|
-
type: string;
|
|
11
|
-
// TODO(wittjosiah): Rename data? Otherwise item within item.
|
|
12
|
-
item: MosaicDataItem;
|
|
13
|
-
// Index or layout-specific positional information (stored separately from the item).
|
|
14
|
-
position?: TPosition;
|
|
15
|
-
};
|
package/src/mosaic/util/data.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { arrayMove } from '@dxos/util';
|
|
6
|
-
|
|
7
|
-
import { type MosaicDataItem } from '../types';
|
|
8
|
-
|
|
9
|
-
// TODO(wittjosiah): Generalize and expand rearrange utilities.
|
|
10
|
-
|
|
11
|
-
export const swapItems = <TItem extends MosaicDataItem, TValue extends MosaicDataItem>(
|
|
12
|
-
items: TItem[],
|
|
13
|
-
from: TValue,
|
|
14
|
-
to: TValue,
|
|
15
|
-
): TItem[] => {
|
|
16
|
-
const fromIndex = items.findIndex((item) => item.id === from.id);
|
|
17
|
-
const toIndex = items.findIndex((item) => item.id === to.id);
|
|
18
|
-
return fromIndex !== -1 && toIndex !== -1 ? arrayMove(items, fromIndex, toIndex) : items;
|
|
19
|
-
};
|
package/src/mosaic/util/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, expect, test } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { Path } from './path';
|
|
8
|
-
|
|
9
|
-
describe('paths', () => {
|
|
10
|
-
test('create', () => {
|
|
11
|
-
const path = Path.create('a', 'b', 'c');
|
|
12
|
-
expect(Path.first(path)).to.eq('a');
|
|
13
|
-
expect(Path.last(path)).to.eq('c');
|
|
14
|
-
|
|
15
|
-
expect(Path.hasRoot(path, 'a')).to.be.true;
|
|
16
|
-
expect(Path.hasRoot(path, 'x')).to.be.false;
|
|
17
|
-
|
|
18
|
-
expect(Path.hasChild(Path.create('a', 'b'), path)).to.be.true;
|
|
19
|
-
expect(Path.hasChild(Path.create('a'), path)).to.be.false;
|
|
20
|
-
|
|
21
|
-
expect(Path.hasDescendent(Path.create('a', 'b'), path)).to.be.true;
|
|
22
|
-
expect(Path.hasDescendent(Path.create('a'), path)).to.be.true;
|
|
23
|
-
});
|
|
24
|
-
});
|
package/src/mosaic/util/path.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
const SEPARATOR = '~';
|
|
6
|
-
|
|
7
|
-
export const Path = {
|
|
8
|
-
create: (...args: string[]) => args.join(SEPARATOR),
|
|
9
|
-
|
|
10
|
-
parts: (path: string) => path.split(SEPARATOR),
|
|
11
|
-
length: (path: string) => path.split(SEPARATOR).length,
|
|
12
|
-
first: (path: string) => path.split(SEPARATOR)[0] ?? path,
|
|
13
|
-
last: (path: string) => path.split(SEPARATOR).at(-1) ?? path,
|
|
14
|
-
parent: (path: string) => path.split(SEPARATOR).slice(0, -1).join(SEPARATOR),
|
|
15
|
-
|
|
16
|
-
hasRoot: (path: string, id: string) => Path.first(path) === id,
|
|
17
|
-
hasChild: (path: string, compare: string) => Path.parent(compare) === path,
|
|
18
|
-
hasDescendent: (path: string, compare: string) => compare !== path && compare.startsWith(path),
|
|
19
|
-
siblings: (path: string, compare: string) => Path.parent(path) === Path.parent(compare),
|
|
20
|
-
onPath: (path: string, id: string) => Path.parts(path).includes(id),
|
|
21
|
-
};
|
package/src/mosaic/util/props.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { MosaicOperations } from '../Container';
|
|
6
|
-
import { type MosaicTileComponentProps, type MosaicTileProps } from '../Tile';
|
|
7
|
-
|
|
8
|
-
export const isTileProps = (props: Record<string, unknown>): props is MosaicTileProps =>
|
|
9
|
-
typeof props.path === 'string' && typeof props.item === 'object' && props.item
|
|
10
|
-
? 'id' in props.item && typeof props.item.id === 'string'
|
|
11
|
-
: false;
|
|
12
|
-
|
|
13
|
-
export const isTileComponentProps = (props: Record<string, unknown>): props is MosaicTileComponentProps =>
|
|
14
|
-
isTileProps(props) && typeof props.operation === 'string' && MosaicOperations.includes(props.operation);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// https://docs.dndkit.com/api-documentation/draggable/usedraggable#transform
|
|
6
|
-
|
|
7
|
-
import { CSS, type Transform } from '@dnd-kit/utilities';
|
|
8
|
-
|
|
9
|
-
export const getTransformCSS = (transform: Transform | null) =>
|
|
10
|
-
transform ? CSS.Transform.toString(Object.assign(transform, { scaleX: 1, scaleY: 1 })) : undefined;
|
package/src/testing/Cards.tsx
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { forwardRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Card } from '@dxos/react-ui-card';
|
|
8
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
-
|
|
10
|
-
import { Mosaic, type MosaicTileComponent } from '../mosaic';
|
|
11
|
-
|
|
12
|
-
// TODO(burdon): Menu options.
|
|
13
|
-
// TODO(burdon): Margin while dragging.
|
|
14
|
-
|
|
15
|
-
export type SimpleCardProps = { id: string; title?: string; body?: string; image?: string };
|
|
16
|
-
|
|
17
|
-
export const SimpleCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
|
|
18
|
-
(
|
|
19
|
-
{ classNames, active, draggableStyle, draggableProps, item: { id, title }, path, position, grow, debug, onSelect },
|
|
20
|
-
forwardRef,
|
|
21
|
-
) => {
|
|
22
|
-
const full = !title;
|
|
23
|
-
return (
|
|
24
|
-
<div role='none' ref={forwardRef} className='flex w-full' style={draggableStyle}>
|
|
25
|
-
<Card.Root
|
|
26
|
-
noPadding={full}
|
|
27
|
-
classNames={mx(
|
|
28
|
-
'w-full snap-center',
|
|
29
|
-
(active === 'origin' || active === 'rearrange') && 'opacity-0',
|
|
30
|
-
active === 'destination' && 'opacity-20',
|
|
31
|
-
classNames,
|
|
32
|
-
)}
|
|
33
|
-
grow={grow}
|
|
34
|
-
>
|
|
35
|
-
<Card.Header floating={full} onDoubleClick={() => onSelect?.()}>
|
|
36
|
-
<Card.DragHandle position={full ? 'left' : undefined} {...draggableProps} />
|
|
37
|
-
{title && <Card.Title title={title} />}
|
|
38
|
-
<Card.Menu position={full ? 'right' : undefined} />
|
|
39
|
-
</Card.Header>
|
|
40
|
-
{debug && (
|
|
41
|
-
<Card.Body>
|
|
42
|
-
<Mosaic.Debug data={{ path, id, position }} />
|
|
43
|
-
</Card.Body>
|
|
44
|
-
)}
|
|
45
|
-
</Card.Root>
|
|
46
|
-
</div>
|
|
47
|
-
);
|
|
48
|
-
},
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
SimpleCard.displayName = 'SimpleCard';
|
|
52
|
-
|
|
53
|
-
export const ComplexCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
|
|
54
|
-
(
|
|
55
|
-
{ classNames, isDragging, draggableStyle, draggableProps, item: { id, title, body, image }, grow, debug, onSelect },
|
|
56
|
-
forwardRef,
|
|
57
|
-
) => {
|
|
58
|
-
const full = !title;
|
|
59
|
-
return (
|
|
60
|
-
<div role='none' ref={forwardRef} className='flex w-full' style={draggableStyle}>
|
|
61
|
-
<Card.Root
|
|
62
|
-
noPadding={full}
|
|
63
|
-
classNames={mx('w-full snap-center', isDragging && 'opacity-20', classNames)}
|
|
64
|
-
grow={grow}
|
|
65
|
-
>
|
|
66
|
-
<Card.Header floating={full} onDoubleClick={() => onSelect?.()}>
|
|
67
|
-
<Card.DragHandle position={full ? 'left' : undefined} {...draggableProps} />
|
|
68
|
-
{title && <Card.Title title={title} />}
|
|
69
|
-
<Card.Menu position={full ? 'right' : undefined} />
|
|
70
|
-
</Card.Header>
|
|
71
|
-
{image && <Card.Media src={image} />}
|
|
72
|
-
{title && body && (
|
|
73
|
-
<Card.Body gutter classNames='line-clamp-3 text-sm'>
|
|
74
|
-
{body}
|
|
75
|
-
</Card.Body>
|
|
76
|
-
)}
|
|
77
|
-
{debug && (
|
|
78
|
-
<Card.Body>
|
|
79
|
-
<Mosaic.Debug data={{ id }} />
|
|
80
|
-
</Card.Body>
|
|
81
|
-
)}
|
|
82
|
-
</Card.Root>
|
|
83
|
-
</div>
|
|
84
|
-
);
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
ComplexCard.displayName = 'ComplexCard';
|
package/src/testing/generator.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type S } from '@dxos/echo-schema';
|
|
6
|
-
import { create, type ReactiveObject } from '@dxos/live-object';
|
|
7
|
-
import { faker } from '@dxos/random';
|
|
8
|
-
import { range } from '@dxos/util';
|
|
9
|
-
|
|
10
|
-
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
11
|
-
|
|
12
|
-
type ObjectDataGenerator = {
|
|
13
|
-
createSchema?: () => S.Schema<any>;
|
|
14
|
-
createData: () => any;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type ObjectFactory<T extends ReactiveObject<any>> = {
|
|
18
|
-
schema?: S.Schema<any>; // TODO(burdon): Support both typed and expando schema.
|
|
19
|
-
createObject: () => T;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type ObjectFactoryMap = { [type: string]: ObjectFactory<any> };
|
|
23
|
-
|
|
24
|
-
const createFactory = ({ createSchema, createData }: ObjectDataGenerator) => {
|
|
25
|
-
const schema = createSchema?.();
|
|
26
|
-
return {
|
|
27
|
-
schema,
|
|
28
|
-
createObject: () => (schema ? create(schema, createData()) : create(createData())),
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// TODO(burdon): Handle restricted values.
|
|
33
|
-
export const Status = ['pending', 'active', 'done'];
|
|
34
|
-
export const Priority = [1, 2, 3, 4, 5];
|
|
35
|
-
|
|
36
|
-
const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
37
|
-
document: {
|
|
38
|
-
createData: () => ({
|
|
39
|
-
title: faker.lorem.sentence(3),
|
|
40
|
-
body: faker.lorem.sentences({ min: 1, max: faker.number.int({ min: 1, max: 3 }) }),
|
|
41
|
-
}),
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
image: {
|
|
45
|
-
createData: () => ({
|
|
46
|
-
title: faker.lorem.sentence(3),
|
|
47
|
-
image: faker.helpers.arrayElement(data.images),
|
|
48
|
-
body: faker.datatype.boolean() ? faker.lorem.sentences() : undefined,
|
|
49
|
-
}),
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
project: {
|
|
53
|
-
// createSchema: () =>
|
|
54
|
-
// return object(StoredEchoSchema, {
|
|
55
|
-
// typename: 'Project',
|
|
56
|
-
// version: '0.1.0',
|
|
57
|
-
// jsonSchema: toJsonSchema(
|
|
58
|
-
//
|
|
59
|
-
// ),
|
|
60
|
-
// })
|
|
61
|
-
// new Schema({
|
|
62
|
-
// props: [
|
|
63
|
-
// {
|
|
64
|
-
// id: 'title',
|
|
65
|
-
// type: Schema.PropType.STRING,
|
|
66
|
-
// },
|
|
67
|
-
// {
|
|
68
|
-
// id: 'repo',
|
|
69
|
-
// type: Schema.PropType.STRING,
|
|
70
|
-
// },
|
|
71
|
-
// {
|
|
72
|
-
// id: 'status',
|
|
73
|
-
// type: Schema.PropType.STRING,
|
|
74
|
-
// },
|
|
75
|
-
// {
|
|
76
|
-
// id: 'priority',
|
|
77
|
-
// type: Schema.PropType.NUMBER,
|
|
78
|
-
// },
|
|
79
|
-
// ],
|
|
80
|
-
// }),
|
|
81
|
-
createData: () => ({
|
|
82
|
-
title: faker.commerce.productName(),
|
|
83
|
-
repo: faker.datatype.boolean({ probability: 0.3 }) ? faker.internet.url() : undefined,
|
|
84
|
-
status: faker.helpers.arrayElement(Status),
|
|
85
|
-
priority: faker.helpers.arrayElement(Priority),
|
|
86
|
-
}),
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Typed object generator.
|
|
92
|
-
*/
|
|
93
|
-
export class TestObjectGenerator {
|
|
94
|
-
public readonly factories: ObjectFactoryMap;
|
|
95
|
-
|
|
96
|
-
constructor({ types, factories }: { types?: string[]; factories?: ObjectFactoryMap } = {}) {
|
|
97
|
-
this.factories =
|
|
98
|
-
factories ??
|
|
99
|
-
(types ?? Object.keys(defaultGenerators)).reduce<ObjectFactoryMap>((acc, type) => {
|
|
100
|
-
acc[type] = createFactory(defaultGenerators[type]);
|
|
101
|
-
return acc;
|
|
102
|
-
}, {});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
get schema(): S.Schema<any>[] {
|
|
106
|
-
return Object.values(this.factories).map((f) => f.schema!);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
createObject({ types }: { types?: string[] } = {}) {
|
|
110
|
-
const type = faker.helpers.arrayElement(types ?? Object.keys(this.factories));
|
|
111
|
-
const factory = this.factories[type];
|
|
112
|
-
return factory?.createObject();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
createObjects({ types, length }: { types?: string[]; length: number }) {
|
|
116
|
-
return range(length, () => this.createObject({ types }));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// https://unsplash.com
|
|
121
|
-
// TODO(burdon): Use https://picsum.photos?
|
|
122
|
-
const data = {
|
|
123
|
-
images: [
|
|
124
|
-
'/images/image-1.png',
|
|
125
|
-
'/images/image-2.png',
|
|
126
|
-
'/images/image-3.png',
|
|
127
|
-
'/images/image-4.png',
|
|
128
|
-
'/images/image-5.png',
|
|
129
|
-
'/images/image-6.png',
|
|
130
|
-
],
|
|
131
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
import { faker } from '@dxos/random';
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
|
-
|
|
12
|
-
import { Mosaic } from '../../mosaic';
|
|
13
|
-
import { ComplexCard, SimpleCard } from '../../testing';
|
|
14
|
-
import { DemoGrid } from '../Grid/testing';
|
|
15
|
-
import { DemoKanban } from '../Kanban/testing';
|
|
16
|
-
import { DemoStack } from '../Stack/testing';
|
|
17
|
-
import { DemoTree } from '../Tree/testing';
|
|
18
|
-
|
|
19
|
-
faker.seed(5);
|
|
20
|
-
|
|
21
|
-
export default {
|
|
22
|
-
title: 'ui/react-ui-mosaic/Demo',
|
|
23
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
24
|
-
parameters: {
|
|
25
|
-
layout: 'fullscreen',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const debug = false;
|
|
30
|
-
const types = ['document', 'image'];
|
|
31
|
-
|
|
32
|
-
export const Default = () => (
|
|
33
|
-
<Mosaic.Root debug={debug}>
|
|
34
|
-
<Mosaic.DragOverlay />
|
|
35
|
-
<div className='flex grow overflow-hidden'>
|
|
36
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden'>
|
|
37
|
-
<DemoStack id='stack-1' Component={SimpleCard} types={types} debug={debug} classNames='p-2' />
|
|
38
|
-
</div>
|
|
39
|
-
<div className='flex grow overflow-hidden bg-neutral-900'>
|
|
40
|
-
<DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} classNames='p-4' />
|
|
41
|
-
</div>
|
|
42
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900'>
|
|
43
|
-
<DemoStack id='stack-2' Component={ComplexCard} types={types} debug={debug} />
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</Mosaic.Root>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
export const Tree = () => (
|
|
50
|
-
<Mosaic.Root debug={debug}>
|
|
51
|
-
<Mosaic.DragOverlay />
|
|
52
|
-
<div className='flex grow overflow-hidden'>
|
|
53
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden'>
|
|
54
|
-
<DemoTree id='tree-1' types={types} debug={debug} />
|
|
55
|
-
</div>
|
|
56
|
-
<div className='flex grow overflow-hidden'>
|
|
57
|
-
<DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} classNames='p-4 bg-neutral-900' />
|
|
58
|
-
</div>
|
|
59
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900'>
|
|
60
|
-
<DemoStack id='stack-2' Component={ComplexCard} types={types} debug={debug} />
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</Mosaic.Root>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
export const Kanban = () => (
|
|
67
|
-
<Mosaic.Root debug={debug}>
|
|
68
|
-
<Mosaic.DragOverlay />
|
|
69
|
-
<div className='flex grow overflow-hidden'>
|
|
70
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden'>
|
|
71
|
-
<DemoTree id='tree-1' types={types} debug={debug} />
|
|
72
|
-
</div>
|
|
73
|
-
<div className='flex grow overflow-hidden'>
|
|
74
|
-
<DemoKanban id='kanban-1' Component={SimpleCard} debug={debug} classNames='p-4' />
|
|
75
|
-
</div>
|
|
76
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900 pl-2'>
|
|
77
|
-
<DemoStack id='stack-1' Component={ComplexCard} types={types} debug={debug} />
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</Mosaic.Root>
|
|
81
|
-
);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { faker } from '@dxos/random';
|
|
8
|
-
import { create } from '@dxos/react-client/echo';
|
|
9
|
-
import { type ClientRepeatedComponentProps, ClientRepeater } from '@dxos/react-client/testing';
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
|
-
import { range } from '@dxos/util';
|
|
12
|
-
|
|
13
|
-
import { Mosaic } from '../../mosaic';
|
|
14
|
-
import { TestObjectGenerator, Status, Priority } from '../../testing';
|
|
15
|
-
|
|
16
|
-
// import { EchoKanban } from '../Kanban/testing';
|
|
17
|
-
// import { GraphTree } from '../Tree/testing';
|
|
18
|
-
|
|
19
|
-
faker.seed(3);
|
|
20
|
-
const debug = true;
|
|
21
|
-
const generator = new TestObjectGenerator();
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Compute this?
|
|
24
|
-
const columnValues: { [property: string]: any[] } = {
|
|
25
|
-
status: ['unknown', ...Status],
|
|
26
|
-
priority: ['unknown', ...Priority],
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const Story = ({ spaceKey }: ClientRepeatedComponentProps) => {
|
|
30
|
-
return (
|
|
31
|
-
<Mosaic.Root debug={debug}>
|
|
32
|
-
<Mosaic.DragOverlay />
|
|
33
|
-
<div className='flex grow overflow-hidden'>
|
|
34
|
-
<div className='flex shrink-0 w-[280px] overflow-hidden'>{/* <GraphTree id='graph' debug={debug} /> */}</div>
|
|
35
|
-
<div className='flex grow overflow-hidden'>
|
|
36
|
-
{/* <EchoKanban id='projects' spaceKey={spaceKey} generator={generator} debug={debug} /> */}
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</Mosaic.Root>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default {
|
|
44
|
-
title: 'ui/react-ui-mosaic/Demo',
|
|
45
|
-
render: () => (
|
|
46
|
-
<ClientRepeater
|
|
47
|
-
component={Story}
|
|
48
|
-
onSpaceCreated={async ({ space }) => {
|
|
49
|
-
const factory = generator.factories.project;
|
|
50
|
-
const objects = [
|
|
51
|
-
factory.schema,
|
|
52
|
-
...range(10, factory.createObject),
|
|
53
|
-
create({
|
|
54
|
-
type: 'kanban',
|
|
55
|
-
title: 'Projects',
|
|
56
|
-
schema: factory.schema,
|
|
57
|
-
// TODO(burdon): Standardize with other story.
|
|
58
|
-
columnProp: 'status',
|
|
59
|
-
columnValues: columnValues.status,
|
|
60
|
-
objectPosition: {}, // TODO(burdon): Make this a CRDT.
|
|
61
|
-
}),
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
// TODO(burdon): Batch API.
|
|
65
|
-
objects.forEach((object) => space.db.add(object));
|
|
66
|
-
}}
|
|
67
|
-
createSpace
|
|
68
|
-
/>
|
|
69
|
-
),
|
|
70
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// TODO(wittjosiah): This currently has a bug where empty over events are fired when dragging from tree onto kanban.
|
|
74
|
-
// The bug didn't exist before the cleanup refactor so seems likely it's a side effect of that.
|
|
75
|
-
// export const ECHO = {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import React from 'react';
|
|
8
|
-
|
|
9
|
-
import { faker } from '@dxos/random';
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
|
-
|
|
12
|
-
import { Grid, type GridLayout } from './Grid';
|
|
13
|
-
import { DemoGrid } from './testing';
|
|
14
|
-
import { Mosaic } from '../../mosaic';
|
|
15
|
-
import { TestObjectGenerator } from '../../testing';
|
|
16
|
-
|
|
17
|
-
faker.seed(99);
|
|
18
|
-
|
|
19
|
-
const debug = true;
|
|
20
|
-
|
|
21
|
-
// TODO(burdon): Create object.
|
|
22
|
-
// TODO(burdon): Delete object (delete/remove from grid).
|
|
23
|
-
// TODO(burdon): Editable cards (and other card stories).
|
|
24
|
-
// TODO(burdon): Search story (drag from search stack).
|
|
25
|
-
|
|
26
|
-
const size = { x: 4, y: 4 };
|
|
27
|
-
const generator = new TestObjectGenerator({ types: ['document', 'image'] });
|
|
28
|
-
const testItems = generator.createObjects({ length: 20 });
|
|
29
|
-
const testLayout = testItems.reduce<GridLayout>((map, item) => {
|
|
30
|
-
map[item.id] = { x: faker.number.int({ min: 0, max: size.x - 1 }), y: faker.number.int({ min: 0, max: size.y - 1 }) };
|
|
31
|
-
return map;
|
|
32
|
-
}, {});
|
|
33
|
-
|
|
34
|
-
export default {
|
|
35
|
-
title: 'ui/react-ui-mosaic/Grid',
|
|
36
|
-
component: Grid,
|
|
37
|
-
render: () => {
|
|
38
|
-
return (
|
|
39
|
-
<Mosaic.Root debug={debug}>
|
|
40
|
-
<Mosaic.DragOverlay />
|
|
41
|
-
<DemoGrid id='grid' options={{ size }} initialItems={testItems} initialLayout={testLayout} />
|
|
42
|
-
</Mosaic.Root>
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
46
|
-
parameters: {
|
|
47
|
-
layout: 'fullscreen',
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const Default = {};
|