@dxos/react-ui-mosaic 0.3.3-main.006ca4d → 0.3.3-main.082f8b3
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/dist/lib/browser/index.mjs +513 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/mosaic/Container.d.ts +9 -1
- package/dist/types/src/mosaic/Container.d.ts.map +1 -1
- package/dist/types/src/mosaic/Mosaic.d.ts +3 -2
- package/dist/types/src/mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/mosaic/Root.d.ts.map +1 -1
- package/dist/types/src/mosaic/Tile.d.ts +6 -0
- package/dist/types/src/mosaic/Tile.d.ts.map +1 -1
- package/dist/types/src/mosaic/hooks/index.d.ts +0 -1
- package/dist/types/src/mosaic/hooks/index.d.ts.map +1 -1
- package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts +2 -1
- package/dist/types/src/mosaic/hooks/useItemsWithPreview.d.ts.map +1 -1
- package/dist/types/src/stories/Home.stories.d.ts +11 -0
- package/dist/types/src/stories/Home.stories.d.ts.map +1 -0
- package/dist/types/src/testing/decorators.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +4 -4
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/views/Grid/Grid.d.ts +3 -3
- package/dist/types/src/views/Grid/Grid.d.ts.map +1 -1
- package/dist/types/src/views/Grid/Grid.stories.d.ts +1 -1
- package/dist/types/src/views/Stack/Columns.stories.d.ts +1 -1
- package/dist/types/src/views/Stack/Columns.stories.d.ts.map +1 -1
- package/dist/types/src/views/Tree/testing.d.ts +1 -1
- package/dist/types/src/views/Tree/testing.d.ts.map +1 -1
- package/package.json +13 -14
- package/src/index.ts +3 -0
- package/src/mosaic/Container.tsx +10 -2
- package/src/mosaic/Mosaic.ts +6 -2
- package/src/mosaic/Root.tsx +1 -2
- package/src/mosaic/Tile.tsx +4 -0
- package/src/mosaic/hooks/index.ts +0 -1
- package/src/mosaic/hooks/useItemsWithPreview.ts +56 -20
- package/src/stories/Home.stories.tsx +87 -0
- package/src/testing/decorators.tsx +1 -0
- package/src/testing/generator.ts +9 -9
- package/src/testing/index.ts +0 -1
- package/src/views/Grid/Grid.tsx +27 -14
- package/src/views/Grid/testing.tsx +2 -2
- package/src/views/Kanban/Kanban.tsx +1 -1
- package/src/views/Stack/Columns.stories.tsx +1 -1
- package/src/views/Stack/testing.tsx +1 -1
- package/src/views/Tree/Tree.tsx +17 -11
- package/src/views/Tree/testing.tsx +13 -12
- package/dist/types/src/mosaic/hooks/useSortedItems.d.ts +0 -6
- package/dist/types/src/mosaic/hooks/useSortedItems.d.ts.map +0 -1
- package/dist/types/src/testing/next-fractional-index.d.ts +0 -5
- package/dist/types/src/testing/next-fractional-index.d.ts.map +0 -1
- package/src/mosaic/hooks/useSortedItems.ts +0 -14
- package/src/testing/next-fractional-index.ts +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Root.d.ts","sourceRoot":"","sources":["../../../../src/mosaic/Root.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,EAAiB,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAGxF,OAAO,EAAsB,KAAK,oBAAoB,EAAwB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAGxH,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAKjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;I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AAe,CAAC;CAC5B,CAAC;AAEF,eAAO,MAAM,aAAa,8CAA0D,CAAC;AAErF,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC;IAC9C;;OAEG;IACH,SAAS,CAAC,EAAE,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CA0K1C,CAAC"}
|
|
@@ -3,6 +3,11 @@ import type { CSSProperties, ForwardRefExoticComponent, HTMLAttributes, RefAttri
|
|
|
3
3
|
import type { MosaicOperation, MosaicTileOverlayProps } from './Container';
|
|
4
4
|
import type { MosaicDataItem } from './types';
|
|
5
5
|
export type MosaicActiveType = 'overlay' | 'rearrange' | 'origin' | 'destination';
|
|
6
|
+
export type MosaicTileAction = {
|
|
7
|
+
id: string;
|
|
8
|
+
action: string;
|
|
9
|
+
data?: any;
|
|
10
|
+
};
|
|
6
11
|
/**
|
|
7
12
|
* Props passed to mosaic tile.
|
|
8
13
|
*/
|
|
@@ -19,6 +24,7 @@ export type MosaicTileProps<TData extends MosaicDataItem = MosaicDataItem, TPosi
|
|
|
19
24
|
draggableProps?: DraggableAttributes & HTMLAttributes<HTMLElement>;
|
|
20
25
|
onSelect?: () => void;
|
|
21
26
|
onRemove?: () => void;
|
|
27
|
+
onAction?: (action: MosaicTileAction) => void;
|
|
22
28
|
};
|
|
23
29
|
/**
|
|
24
30
|
* Mosaic Tile component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.d.ts","sourceRoot":"","sources":["../../../../src/mosaic/Tile.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,eAAe,CAAC;AAGrF,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAErG,OAAO,KAAK,EAAE,e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a,8EAOvB,gBAAgB,GAAG,CAAC,gBAyBtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,8DAMvB,gBAAgB,GAAG,CAAC,gBAsBtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,iGAOtB,gBAAgB,GAAG,EAAE,MAAM,CAAC,gBAsD9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/mosaic/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/mosaic/hooks/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
|
@@ -3,8 +3,9 @@ import { type MosaicDataItem } from '../types';
|
|
|
3
3
|
* Returns a spliced collection of items including a placeholder if items that could drop,
|
|
4
4
|
* and removing any item that is currently being dragged out.
|
|
5
5
|
*/
|
|
6
|
-
export declare const useItemsWithPreview: <T extends MosaicDataItem>({ path, items }: {
|
|
6
|
+
export declare const useItemsWithPreview: <T extends MosaicDataItem>({ path, items, strategy, }: {
|
|
7
7
|
path: string;
|
|
8
8
|
items: T[];
|
|
9
|
+
strategy?: "default" | "layout-stable" | undefined;
|
|
9
10
|
}) => T[];
|
|
10
11
|
//# sourceMappingURL=useItemsWithPreview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useItemsWithPreview.d.ts","sourceRoot":"","sources":["../../../../../src/mosaic/hooks/useItemsWithPreview.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB;
|
|
1
|
+
{"version":3,"file":"useItemsWithPreview.d.ts","sourceRoot":"","sources":["../../../../../src/mosaic/hooks/useItemsWithPreview.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB;UAKxB,MAAM;;;SAgFb,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@dxosTheme';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
component: () => JSX.Element;
|
|
4
|
+
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0a347bb9").R>[];
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
10
|
+
export declare const Default: {};
|
|
11
|
+
//# sourceMappingURL=Home.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Home.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Home.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;;;;;;;;AA0EpB,wBAME;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../../src/testing/decorators.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD,eAAO,MAAM,mBAAmB,eAAgB,MAAM,KAAG,kBAAkB,aAAa,
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../../../src/testing/decorators.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD,eAAO,MAAM,mBAAmB,eAAgB,MAAM,KAAG,kBAAkB,aAAa,CASvF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema
|
|
1
|
+
import { Schema } from '@dxos/client/echo';
|
|
2
2
|
import { type TypedObject } from '@dxos/echo-schema';
|
|
3
3
|
export declare const range: <T>(fn: (i: number) => T | undefined, length: number) => T[];
|
|
4
4
|
export type TestItem = {
|
|
@@ -6,11 +6,11 @@ export type TestItem = {
|
|
|
6
6
|
type: string;
|
|
7
7
|
} & Record<string, any>;
|
|
8
8
|
type ObjectDataGenerator = {
|
|
9
|
-
createSchema?: () =>
|
|
9
|
+
createSchema?: () => Schema;
|
|
10
10
|
createData: () => any;
|
|
11
11
|
};
|
|
12
12
|
type ObjectFactory<T extends TypedObject> = {
|
|
13
|
-
schema?:
|
|
13
|
+
schema?: Schema;
|
|
14
14
|
createObject: () => T;
|
|
15
15
|
};
|
|
16
16
|
type ObjectFactoryMap = {
|
|
@@ -30,7 +30,7 @@ export declare class TestObjectGenerator {
|
|
|
30
30
|
types?: string[];
|
|
31
31
|
factories?: ObjectFactoryMap;
|
|
32
32
|
});
|
|
33
|
-
get schema():
|
|
33
|
+
get schema(): Schema[];
|
|
34
34
|
createObject({ types }?: {
|
|
35
35
|
types?: string[];
|
|
36
36
|
}): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/testing/generator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../src/testing/generator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG9D,eAAO,MAAM,KAAK,cAAe,MAAM,4BAA4B,MAAM,QAG9C,CAAC;AAG5B,MAAM,MAAM,QAAQ,GAAG;IAAE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c,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,cAAc,SAAS,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import '@dxosTheme';
|
|
2
1
|
import { type Dimension, type Position, type Size } from './layout';
|
|
3
|
-
import { type MosaicContainerProps, type MosaicDataItem } from '../../mosaic';
|
|
2
|
+
import { type MosaicContainerProps, type MosaicDataItem, type MosaicTileAction } from '../../mosaic';
|
|
4
3
|
type ControlledSelection = {
|
|
5
4
|
selected?: string;
|
|
6
5
|
onSelect?: (id: string) => void;
|
|
@@ -21,10 +20,11 @@ export type GridProps<TData extends MosaicDataItem = MosaicDataItem> = MosaicCon
|
|
|
21
20
|
square?: boolean;
|
|
22
21
|
debug?: boolean;
|
|
23
22
|
onCreate?: (position: Position) => void;
|
|
23
|
+
onAction?: (action: MosaicTileAction) => void;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Grid content.
|
|
27
27
|
*/
|
|
28
|
-
export declare const Grid: ({ id, items, layout, options: opts, margin, square, debug, selected: controlledSelected, Component, className, onDrop, onSelect, onCreate, }: GridProps) => JSX.Element;
|
|
28
|
+
export declare const Grid: ({ id, items, layout, options: opts, margin, square, debug, selected: controlledSelected, Component, className, onDrop, onOver, onSelect, onCreate, onAction, }: GridProps) => JSX.Element;
|
|
29
29
|
export {};
|
|
30
30
|
//# sourceMappingURL=Grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.tsx"],"names":[],"mappings":"AAaA,OAAO,EAML,KAAK,SA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id, items, layout, options: opts, margin, square, debug, selected: controlledSelected, Component, className, onDrop, onSelect, onCreate, }: import("./Grid").GridProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
|
|
4
|
+
component: ({ id, items, layout, options: opts, margin, square, debug, selected: controlledSelected, Component, className, onDrop, onOver, onSelect, onCreate, onAction, }: import("./Grid").GridProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
|
|
5
5
|
render: () => JSX.Element;
|
|
6
6
|
decorators: import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0a347bb9").R>[];
|
|
7
7
|
parameters: {
|
|
@@ -11,7 +11,7 @@ declare const _default: {
|
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
export default _default;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const Transfer: {
|
|
15
15
|
args: {
|
|
16
16
|
Component: import("../../mosaic").MosaicTileComponent<import("../../testing").SimpleCardProps>;
|
|
17
17
|
debug: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Columns.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Stack/Columns.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAMpB,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;;;;mBAS1C,cAAc;;;;;;AAH/B,wBAoBE;AAEF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"Columns.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Stack/Columns.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAMpB,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;;;;mBAS1C,cAAc;;;;;;AAH/B,wBAoBE;AAEF,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC;AAGF,eAAO,MAAM,IAAI;;;;;;CAMhB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;CAMlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAA2B,MAAM,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAA2B,MAAM,iBAAiB,CAAC;AAItE,OAAO,EAAQ,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAM7D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,QAAQ,uCAAiD,aAAa,gBA0DlF,CAAC;AAEF,eAAO,MAAM,WAAW,aAqBvB,CAAC;AAcF,eAAO,MAAM,SAAS;QAAgD,MAAM;;WAAwB,OAAO;iBAsC1G,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-mosaic",
|
|
3
|
-
"version": "0.3.3-main.
|
|
3
|
+
"version": "0.3.3-main.082f8b3",
|
|
4
4
|
"description": "An intermediate interface for drag-and-drop interactions.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -21,18 +21,17 @@
|
|
|
21
21
|
"@dnd-kit/utilities": "^3.2.0",
|
|
22
22
|
"@preact/signals-core": "^1.5.0",
|
|
23
23
|
"@radix-ui/react-compose-refs": "^1.0.0",
|
|
24
|
-
"
|
|
25
|
-
"deepsignal": "^1.3.6",
|
|
24
|
+
"deepsignal": "1.4.0-shallow.0",
|
|
26
25
|
"lodash.defaultsdeep": "^4.6.1",
|
|
27
26
|
"lodash.pick": "^4.4.0",
|
|
28
27
|
"react-resize-detector": "^7.1.2",
|
|
29
|
-
"@dxos/debug": "0.3.3-main.
|
|
30
|
-
"@dxos/invariant": "0.3.3-main.
|
|
31
|
-
"@dxos/keys": "0.3.3-main.
|
|
32
|
-
"@dxos/react-ui": "0.3.3-main.
|
|
33
|
-
"@dxos/react-ui-theme": "0.3.3-main.
|
|
34
|
-
"@dxos/react-ui-types": "0.3.3-main.
|
|
35
|
-
"@dxos/util": "0.3.3-main.
|
|
28
|
+
"@dxos/debug": "0.3.3-main.082f8b3",
|
|
29
|
+
"@dxos/invariant": "0.3.3-main.082f8b3",
|
|
30
|
+
"@dxos/keys": "0.3.3-main.082f8b3",
|
|
31
|
+
"@dxos/react-ui": "0.3.3-main.082f8b3",
|
|
32
|
+
"@dxos/react-ui-theme": "0.3.3-main.082f8b3",
|
|
33
|
+
"@dxos/react-ui-types": "0.3.3-main.082f8b3",
|
|
34
|
+
"@dxos/util": "0.3.3-main.082f8b3"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@faker-js/faker": "^8.0.2",
|
|
@@ -48,10 +47,10 @@
|
|
|
48
47
|
"react-dom": "^18.2.0",
|
|
49
48
|
"vite": "^4.3.9",
|
|
50
49
|
"vite-plugin-turbosnap": "^1.0.2",
|
|
51
|
-
"@
|
|
52
|
-
"@dxos/echo-schema": "0.3.3-main.
|
|
53
|
-
"@dxos/gem-core": "0.3.3-main.
|
|
54
|
-
"@dxos/react-client": "0.3.3-main.
|
|
50
|
+
"@dxos/app-graph": "0.3.3-main.082f8b3",
|
|
51
|
+
"@dxos/echo-schema": "0.3.3-main.082f8b3",
|
|
52
|
+
"@dxos/gem-core": "0.3.3-main.082f8b3",
|
|
53
|
+
"@dxos/react-client": "0.3.3-main.082f8b3"
|
|
55
54
|
},
|
|
56
55
|
"peerDependencies": {
|
|
57
56
|
"@phosphor-icons/react": "^2.0.5",
|
package/src/index.ts
CHANGED
package/src/mosaic/Container.tsx
CHANGED
|
@@ -22,8 +22,16 @@ export type MosaicTileOverlayProps = {
|
|
|
22
22
|
debug?: boolean;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Possible operations when dropping a tile.
|
|
27
|
+
*
|
|
28
|
+
* * `transfer` - Remove the tile from it's current path and move to a new path.
|
|
29
|
+
* * `copy` - Add a clone of the tile at a new path.
|
|
30
|
+
* * `rearrange` - Change the order of the tile within it's current path.
|
|
31
|
+
* * `reject` - The tile is not allowed where it was dropped.
|
|
32
|
+
*/
|
|
33
|
+
// TODO(wittjosiah): Add 'delete'. Consider adding 'swap'.
|
|
34
|
+
export type MosaicOperation = 'transfer' | 'copy' | 'rearrange' | 'reject';
|
|
27
35
|
|
|
28
36
|
export type MosaicMoveEvent<TPosition = unknown> = {
|
|
29
37
|
active: MosaicDraggedItem<TPosition>;
|
package/src/mosaic/Mosaic.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
DraggableTile,
|
|
22
22
|
DroppableTile,
|
|
23
23
|
SortableTile,
|
|
24
|
+
type MosaicTileAction as NaturalMosaicTileAction,
|
|
24
25
|
type MosaicTileProps as NaturalMosaicTileProps,
|
|
25
26
|
type MosaicTileComponent as NaturalMosaicTileComponent,
|
|
26
27
|
type MosaicActiveType as NaturalMosaicActiveType,
|
|
@@ -64,6 +65,8 @@ export type MosaicOverlayProps = MosaicDragOverlayProps;
|
|
|
64
65
|
|
|
65
66
|
export type MosaicSortableProps = NaturalMosaicSortableProps;
|
|
66
67
|
|
|
68
|
+
export type MosaicTileAction = NaturalMosaicTileAction;
|
|
69
|
+
|
|
67
70
|
export type MosaicTileProps<
|
|
68
71
|
TData extends MosaicDataItem = MosaicDataItem,
|
|
69
72
|
TPosition = unknown,
|
|
@@ -74,11 +77,12 @@ export type MosaicTileComponent<
|
|
|
74
77
|
TElement extends HTMLElement = HTMLDivElement,
|
|
75
78
|
> = NaturalMosaicTileComponent<TData, TElement>;
|
|
76
79
|
|
|
77
|
-
export type MosaicDebugProps = DebugProps;
|
|
78
|
-
|
|
79
80
|
export type MosaicMoveEvent<TPosition = unknown> = NaturalMosaicMoveEvent<TPosition>;
|
|
80
81
|
export type MosaicDropEvent<TPosition = unknown> = NaturalMosaicDropEvent<TPosition>;
|
|
81
82
|
export type MosaicOperation = NaturalMosaicOperation;
|
|
82
83
|
export type MosaicActiveType = NaturalMosaicActiveType;
|
|
83
84
|
|
|
84
85
|
export type MosaicCompareDataItem = NaturalMosaicCompareDataItem;
|
|
86
|
+
|
|
87
|
+
// TODO(burdon): Remove.
|
|
88
|
+
export type MosaicDebugProps = DebugProps;
|
package/src/mosaic/Root.tsx
CHANGED
|
@@ -161,8 +161,7 @@ export const MosaicRoot: FC<MosaicRootProps> = ({ Component = DefaultComponent,
|
|
|
161
161
|
} else if (overContainer.onOver) {
|
|
162
162
|
return overContainer.onOver({ active, over });
|
|
163
163
|
} else {
|
|
164
|
-
|
|
165
|
-
return 'adopt';
|
|
164
|
+
return 'reject';
|
|
166
165
|
}
|
|
167
166
|
};
|
|
168
167
|
|
package/src/mosaic/Tile.tsx
CHANGED
|
@@ -15,6 +15,8 @@ import { getTransformCSS, Path } from './util';
|
|
|
15
15
|
|
|
16
16
|
export type MosaicActiveType = 'overlay' | 'rearrange' | 'origin' | 'destination';
|
|
17
17
|
|
|
18
|
+
export type MosaicTileAction = { id: string; action: string; data?: any };
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* Props passed to mosaic tile.
|
|
20
22
|
*/
|
|
@@ -38,8 +40,10 @@ export type MosaicTileProps<TData extends MosaicDataItem = MosaicDataItem, TPosi
|
|
|
38
40
|
// TODO(wittjosiah): SyntheticListenerMap.
|
|
39
41
|
HTMLAttributes<HTMLElement>;
|
|
40
42
|
|
|
43
|
+
// TODO(burdon): Generalize events via onAction?
|
|
41
44
|
onSelect?: () => void;
|
|
42
45
|
onRemove?: () => void;
|
|
46
|
+
onAction?: (action: MosaicTileAction) => void;
|
|
43
47
|
};
|
|
44
48
|
|
|
45
49
|
/**
|
|
@@ -12,7 +12,15 @@ import { Path } from '../util';
|
|
|
12
12
|
* Returns a spliced collection of items including a placeholder if items that could drop,
|
|
13
13
|
* and removing any item that is currently being dragged out.
|
|
14
14
|
*/
|
|
15
|
-
export const useItemsWithPreview = <T extends MosaicDataItem>({
|
|
15
|
+
export const useItemsWithPreview = <T extends MosaicDataItem>({
|
|
16
|
+
path,
|
|
17
|
+
items,
|
|
18
|
+
strategy = 'default',
|
|
19
|
+
}: {
|
|
20
|
+
path: string;
|
|
21
|
+
items: T[];
|
|
22
|
+
strategy?: 'default' | 'layout-stable';
|
|
23
|
+
}): T[] => {
|
|
16
24
|
const { operation, activeItem, overItem } = useMosaic();
|
|
17
25
|
const [itemsWithPreview, setItemsWithPreview] = useState(items);
|
|
18
26
|
const overParent =
|
|
@@ -24,7 +32,7 @@ export const useItemsWithPreview = <T extends MosaicDataItem>({ path, items }: {
|
|
|
24
32
|
const [lastOverParent, setLastOverParent] = useState(overParent);
|
|
25
33
|
|
|
26
34
|
useEffect(() => {
|
|
27
|
-
if (
|
|
35
|
+
if (!activeItem || !overItem) {
|
|
28
36
|
setLastOverParent(undefined);
|
|
29
37
|
setItemsWithPreview(items);
|
|
30
38
|
return;
|
|
@@ -34,31 +42,59 @@ export const useItemsWithPreview = <T extends MosaicDataItem>({ path, items }: {
|
|
|
34
42
|
return;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
setLastOverParent(overParent);
|
|
38
|
-
|
|
39
45
|
const activeIsChild = Path.hasChild(path, activeItem.path);
|
|
40
46
|
const overIsChild = Path.hasChild(path, overItem.path);
|
|
41
47
|
const overSelf = overItem.path === path;
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
switch (strategy) {
|
|
50
|
+
case 'layout-stable':
|
|
51
|
+
setLastOverParent(overParent);
|
|
52
|
+
if (activeIsChild && !overIsChild && operation !== 'rearrange') {
|
|
53
|
+
// Change the dnd-id of the origin item that may move to a foreign destination
|
|
54
|
+
setItemsWithPreview((sortedItems) =>
|
|
55
|
+
sortedItems.map((item) => {
|
|
56
|
+
if (item.id === activeItem.item.id) {
|
|
57
|
+
return { ...item, id: `${item.id}--origin` };
|
|
58
|
+
} else {
|
|
59
|
+
return item;
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
// Reset items.
|
|
65
|
+
setItemsWithPreview(items);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case 'default':
|
|
69
|
+
default:
|
|
70
|
+
if (operation === 'reject' || operation === 'rearrange') {
|
|
71
|
+
setLastOverParent(undefined);
|
|
72
|
+
setItemsWithPreview(items);
|
|
73
|
+
return;
|
|
74
|
+
} else {
|
|
75
|
+
setLastOverParent(overParent);
|
|
76
|
+
}
|
|
77
|
+
if (!activeIsChild && overIsChild) {
|
|
78
|
+
// Insert item into sortable.
|
|
79
|
+
setItemsWithPreview((items) => {
|
|
80
|
+
const position = overItem.position as number;
|
|
81
|
+
return [...items.slice(0, position), activeItem.item as T, ...items.slice(position)];
|
|
82
|
+
});
|
|
83
|
+
} else if (!activeIsChild && overSelf) {
|
|
84
|
+
// Append item to end of sortable.
|
|
85
|
+
setItemsWithPreview((items) => [...items, activeItem.item as T]);
|
|
86
|
+
} else if (activeIsChild && !overIsChild) {
|
|
87
|
+
// Remove item being dragged out.
|
|
88
|
+
setItemsWithPreview((items) => items.filter((item) => item.id !== activeItem.item.id));
|
|
89
|
+
} else {
|
|
90
|
+
// Reset items.
|
|
91
|
+
setItemsWithPreview(items);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
58
94
|
}
|
|
59
95
|
}, [operation, activeItem, overItem, overParent, lastOverParent, path, items]);
|
|
60
96
|
|
|
61
97
|
// In order to avoid render glitching, rather than waiting for the effect to run,
|
|
62
98
|
// immediately return the new items after dropping an item into a new path.
|
|
63
|
-
return items.length === itemsWithPreview.length ? items : itemsWithPreview;
|
|
99
|
+
return strategy !== 'layout-stable' && items.length === itemsWithPreview.length ? items : itemsWithPreview;
|
|
64
100
|
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxosTheme';
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { FullscreenDecorator } from '../testing';
|
|
10
|
+
|
|
11
|
+
const org = '@dxos-mosaic';
|
|
12
|
+
|
|
13
|
+
const data = {
|
|
14
|
+
quote: `"I've written a few thousand words on why traditional “semantic class names” are the reason CSS is hard to ' +
|
|
15
|
+
'maintain, but the truth is you’re never going to believe me until you actually try it. If you can suppress the ' +
|
|
16
|
+
'urge to retch long enough to give it a chance, I really think you’ll wonder how you ever worked with CSS any other ' +
|
|
17
|
+
'way." [User]`,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const packages = [
|
|
21
|
+
{
|
|
22
|
+
name: `${org}/ui`,
|
|
23
|
+
description: 'Component primitives.',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: `${org}/dnd`,
|
|
27
|
+
description: 'Drag-and-drop containers and tiles.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: `${org}/echo`,
|
|
31
|
+
description: 'DXOS ECHO bindings.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: `${org}/editor`,
|
|
35
|
+
description: 'Rich text editor.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: `${org}/table`,
|
|
39
|
+
description: 'Blazingly fast virtualized tables.',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: `${org}/stack`,
|
|
43
|
+
description: 'Flexible block editor.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: `${org}/grid`,
|
|
47
|
+
description: 'Hierarchical and zoomable grid.',
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const Home = () => {
|
|
52
|
+
return (
|
|
53
|
+
<div className='flex flex-col w-[800px] bg-white px-16 py-20 gap-4 text-lg font-light'>
|
|
54
|
+
<b className='text-4xl font-medium text-black'>Mosaic</b>
|
|
55
|
+
<p>
|
|
56
|
+
Mosaic is an extensible user interface framework and component library built using{' '}
|
|
57
|
+
<span className='font-mono text-purple-700'>radix</span> and{' '}
|
|
58
|
+
<span className='font-mono text-purple-700'>tailwindcss</span>. It enables the rapid development of beautiful
|
|
59
|
+
data-driven applications.
|
|
60
|
+
</p>
|
|
61
|
+
<p>Mosaic is an extensible family of packages, which include:</p>
|
|
62
|
+
<table>
|
|
63
|
+
<tbody>
|
|
64
|
+
{packages.map(({ name, description }) => (
|
|
65
|
+
<tr key={name}>
|
|
66
|
+
<td className='font-mono text-purple-700 w-[260px]'>{name}</td>
|
|
67
|
+
<td>{description}</td>
|
|
68
|
+
</tr>
|
|
69
|
+
))}
|
|
70
|
+
</tbody>
|
|
71
|
+
</table>
|
|
72
|
+
<br />
|
|
73
|
+
<h1 className='text-lg flex justify-center font-medium text-blue-700'>Data-drive components, done right.</h1>
|
|
74
|
+
<p className='px-8'>{data.quote}</p>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default {
|
|
80
|
+
component: Home,
|
|
81
|
+
decorators: [FullscreenDecorator('flex justify-center bg-[url(/images/bg-mosaic.png)]')],
|
|
82
|
+
parameters: {
|
|
83
|
+
layout: 'fullscreen',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const Default = {};
|
|
@@ -12,6 +12,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
12
12
|
export const FullscreenDecorator = (className?: string): DecoratorFunction<ReactRenderer> => {
|
|
13
13
|
return (Story) => (
|
|
14
14
|
<div className={mx('flex fixed inset-0 overflow-hidden', className)}>
|
|
15
|
+
{/* TODO(burdon): Remove DensityProvider from generic decorator. */}
|
|
15
16
|
<DensityProvider density='fine'>
|
|
16
17
|
<Story />
|
|
17
18
|
</DensityProvider>
|
package/src/testing/generator.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import { faker } from '@faker-js/faker';
|
|
10
10
|
|
|
11
|
-
import { Schema
|
|
11
|
+
import { Schema } from '@dxos/client/echo';
|
|
12
12
|
import { Expando, type TypedObject } from '@dxos/echo-schema';
|
|
13
13
|
|
|
14
14
|
// TODO(burdon): Util.
|
|
@@ -21,12 +21,12 @@ export const range = <T>(fn: (i: number) => T | undefined, length: number): T[]
|
|
|
21
21
|
export type TestItem = { id: string; type: string } & Record<string, any>;
|
|
22
22
|
|
|
23
23
|
type ObjectDataGenerator = {
|
|
24
|
-
createSchema?: () =>
|
|
24
|
+
createSchema?: () => Schema;
|
|
25
25
|
createData: () => any;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
type ObjectFactory<T extends TypedObject> = {
|
|
29
|
-
schema?:
|
|
29
|
+
schema?: Schema; // TODO(burdon): Support both typed and expando schema.
|
|
30
30
|
createObject: () => T;
|
|
31
31
|
};
|
|
32
32
|
|
|
@@ -62,23 +62,23 @@ export const defaultGenerators: { [type: string]: ObjectDataGenerator } = {
|
|
|
62
62
|
|
|
63
63
|
project: {
|
|
64
64
|
createSchema: () =>
|
|
65
|
-
new
|
|
65
|
+
new Schema({
|
|
66
66
|
props: [
|
|
67
67
|
{
|
|
68
68
|
id: 'title',
|
|
69
|
-
type:
|
|
69
|
+
type: Schema.PropType.STRING,
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
id: 'repo',
|
|
73
|
-
type:
|
|
73
|
+
type: Schema.PropType.STRING,
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
id: 'status',
|
|
77
|
-
type:
|
|
77
|
+
type: Schema.PropType.STRING,
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
id: 'priority',
|
|
81
|
-
type:
|
|
81
|
+
type: Schema.PropType.NUMBER,
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
84
|
}),
|
|
@@ -106,7 +106,7 @@ export class TestObjectGenerator {
|
|
|
106
106
|
}, {});
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
get schema():
|
|
109
|
+
get schema(): Schema[] {
|
|
110
110
|
return Object.values(this.factories).map((f) => f.schema!);
|
|
111
111
|
}
|
|
112
112
|
|