@dxos/react-ui-mosaic 0.3.3-main.3ce60d4 → 0.3.3-main.3dbd870

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.
Files changed (40) hide show
  1. package/dist/lib/browser/index.mjs +437 -9
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/index.d.ts +1 -0
  5. package/dist/types/src/index.d.ts.map +1 -1
  6. package/dist/types/src/mosaic/Container.d.ts +9 -1
  7. package/dist/types/src/mosaic/Container.d.ts.map +1 -1
  8. package/dist/types/src/mosaic/Mosaic.d.ts +3 -2
  9. package/dist/types/src/mosaic/Mosaic.d.ts.map +1 -1
  10. package/dist/types/src/mosaic/Root.d.ts.map +1 -1
  11. package/dist/types/src/mosaic/Tile.d.ts +6 -0
  12. package/dist/types/src/mosaic/Tile.d.ts.map +1 -1
  13. package/dist/types/src/stories/Home.stories.d.ts +11 -0
  14. package/dist/types/src/stories/Home.stories.d.ts.map +1 -0
  15. package/dist/types/src/testing/decorators.d.ts.map +1 -1
  16. package/dist/types/src/testing/next-fractional-index.d.ts +1 -1
  17. package/dist/types/src/testing/next-fractional-index.d.ts.map +1 -1
  18. package/dist/types/src/views/Grid/Grid.d.ts +3 -3
  19. package/dist/types/src/views/Grid/Grid.d.ts.map +1 -1
  20. package/dist/types/src/views/Grid/Grid.stories.d.ts +1 -1
  21. package/dist/types/src/views/Stack/Columns.stories.d.ts +1 -1
  22. package/dist/types/src/views/Stack/Columns.stories.d.ts.map +1 -1
  23. package/dist/types/src/views/Tree/testing.d.ts +1 -1
  24. package/dist/types/src/views/Tree/testing.d.ts.map +1 -1
  25. package/package.json +12 -12
  26. package/src/index.ts +3 -0
  27. package/src/mosaic/Container.tsx +10 -2
  28. package/src/mosaic/Mosaic.ts +6 -2
  29. package/src/mosaic/Root.tsx +1 -2
  30. package/src/mosaic/Tile.tsx +4 -0
  31. package/src/stories/Home.stories.tsx +87 -0
  32. package/src/testing/decorators.tsx +1 -0
  33. package/src/testing/next-fractional-index.ts +1 -1
  34. package/src/views/Grid/Grid.tsx +25 -14
  35. package/src/views/Grid/testing.tsx +2 -2
  36. package/src/views/Kanban/Kanban.tsx +1 -1
  37. package/src/views/Stack/Columns.stories.tsx +1 -1
  38. package/src/views/Stack/testing.tsx +1 -1
  39. package/src/views/Tree/Tree.tsx +1 -1
  40. package/src/views/Tree/testing.tsx +11 -9
@@ -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,eAAe,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG3E,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,SAAS,CAAC;AAGjE,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ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EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAC7B,KAAK,SAAS,cAAc,GAAG,cAAc,EAC7C,QAAQ,SAAS,WAAW,GAAG,cAAc,IAC3C,yBAAyB,CAC3B,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC,GAAG;IAAE,SAAS,EAAE,eAAe,CAAA;CAAE,CACnH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,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"}
@@ -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,CAQvF,CAAC"}
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,5 +1,5 @@
1
1
  import { type UniqueIdentifier } from '@dnd-kit/core';
2
- import { type Node } from '@braneframe/plugin-graph';
2
+ import { type Node } from '@dxos/app-graph';
3
3
  export declare const nextRearrangeIndex: (nodes: Node[], activeId: UniqueIdentifier, overId?: UniqueIdentifier) => string | null;
4
4
  export declare const nextCopyIndex: (nodes: Node[], overId?: UniqueIdentifier) => string;
5
5
  //# sourceMappingURL=next-fractional-index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"next-fractional-index.d.ts","sourceRoot":"","sources":["../../../../src/testing/next-fractional-index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAErD,eAAO,MAAM,kBAAkB,UAAW,IAAI,EAAE,YAAY,gBAAgB,WAAW,gBAAgB,kBAYtG,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,IAAI,EAAE,WAAW,gBAAgB,WAYrE,CAAC"}
1
+ {"version":3,"file":"next-fractional-index.d.ts","sourceRoot":"","sources":["../../../../src/testing/next-fractional-index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,kBAAkB,UAAW,IAAI,EAAE,YAAY,gBAAgB,WAAW,gBAAgB,kBAYtG,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,IAAI,EAAE,WAAW,gBAAgB,WAYrE,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, 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":"AAIA,OAAO,YAAY,CAAC;AAWpB,OAAO,EAML,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,cAAc,EAA2B,MAAM,cAAc,CAAC;AAOvG,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAA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;AAMF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,SAAS,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAEpD,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,GAAG,cAAc,IAAI,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1G,mBAAmB,GAAG;IACpB,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC/C,CAAC;AAEJ;;GAEG;AAEH,eAAO,MAAM,IAAI,2JAed,SAAS,gBAkHX,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import '@dxosTheme';
3
3
  declare const _default: {
4
- component: ({ 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, 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 Adopt: {
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,KAAK;;;;;CAKjB,CAAC;AAGF,eAAO,MAAM,IAAI;;;;;;CAMhB,CAAC;AAEF,eAAO,MAAM,MAAM;;;;;;CAMlB,CAAC"}
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,4 +1,4 @@
1
- import { type Graph } from '@braneframe/plugin-graph';
1
+ import { type Graph } from '@dxos/app-graph';
2
2
  import { type TreeData, type TreeProps } from './Tree';
3
3
  export type DemoTreeProps = TreeProps & {
4
4
  initialItems?: TreeData[];
@@ -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,0BAA0B,CAAC;AAI/E,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;iBAqC1G,CAAC"}
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;iBAuC1G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-mosaic",
3
- "version": "0.3.3-main.3ce60d4",
3
+ "version": "0.3.3-main.3dbd870",
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",
@@ -26,13 +26,13 @@
26
26
  "lodash.defaultsdeep": "^4.6.1",
27
27
  "lodash.pick": "^4.4.0",
28
28
  "react-resize-detector": "^7.1.2",
29
- "@dxos/debug": "0.3.3-main.3ce60d4",
30
- "@dxos/invariant": "0.3.3-main.3ce60d4",
31
- "@dxos/keys": "0.3.3-main.3ce60d4",
32
- "@dxos/react-ui": "0.3.3-main.3ce60d4",
33
- "@dxos/react-ui-theme": "0.3.3-main.3ce60d4",
34
- "@dxos/react-ui-types": "0.3.3-main.3ce60d4",
35
- "@dxos/util": "0.3.3-main.3ce60d4"
29
+ "@dxos/debug": "0.3.3-main.3dbd870",
30
+ "@dxos/invariant": "0.3.3-main.3dbd870",
31
+ "@dxos/keys": "0.3.3-main.3dbd870",
32
+ "@dxos/react-ui": "0.3.3-main.3dbd870",
33
+ "@dxos/react-ui-theme": "0.3.3-main.3dbd870",
34
+ "@dxos/react-ui-types": "0.3.3-main.3dbd870",
35
+ "@dxos/util": "0.3.3-main.3dbd870"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@faker-js/faker": "^8.0.2",
@@ -48,10 +48,10 @@
48
48
  "react-dom": "^18.2.0",
49
49
  "vite": "^4.3.9",
50
50
  "vite-plugin-turbosnap": "^1.0.2",
51
- "@braneframe/plugin-graph": "0.3.3-main.3ce60d4",
52
- "@dxos/echo-schema": "0.3.3-main.3ce60d4",
53
- "@dxos/gem-core": "0.3.3-main.3ce60d4",
54
- "@dxos/react-client": "0.3.3-main.3ce60d4"
51
+ "@dxos/app-graph": "0.3.3-main.3dbd870",
52
+ "@dxos/echo-schema": "0.3.3-main.3dbd870",
53
+ "@dxos/gem-core": "0.3.3-main.3dbd870",
54
+ "@dxos/react-client": "0.3.3-main.3dbd870"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@phosphor-icons/react": "^2.0.5",
package/src/index.ts CHANGED
@@ -3,3 +3,6 @@
3
3
  //
4
4
 
5
5
  export * from './mosaic';
6
+
7
+ // TODO(burdon): Remove (factor out components).
8
+ export * from './views';
@@ -22,8 +22,16 @@ export type MosaicTileOverlayProps = {
22
22
  debug?: boolean;
23
23
  };
24
24
 
25
- // TODO(wittjosiah): Add delete.
26
- export type MosaicOperation = 'adopt' | 'copy' | 'rearrange' | 'reject';
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>;
@@ -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;
@@ -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
- // TODO(wittjosiah): Default to reject.
165
- return 'adopt';
164
+ return 'reject';
166
165
  }
167
166
  };
168
167
 
@@ -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
  /**
@@ -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>
@@ -5,7 +5,7 @@
5
5
  import { type UniqueIdentifier } from '@dnd-kit/core';
6
6
  import { getIndexAbove, getIndexBelow, getIndexBetween } from '@tldraw/indices';
7
7
 
8
- import { type Node } from '@braneframe/plugin-graph';
8
+ import { type Node } from '@dxos/app-graph';
9
9
 
10
10
  export const nextRearrangeIndex = (nodes: Node[], activeId: UniqueIdentifier, overId?: UniqueIdentifier) => {
11
11
  const overOrderIndex = nodes.length > 0 ? nodes.findIndex(({ id }) => id === overId) : -1;
@@ -2,8 +2,6 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxosTheme';
6
-
7
5
  import { useDroppable } from '@dnd-kit/core';
8
6
  import { PlusCircle } from '@phosphor-icons/react';
9
7
  import defaultsDeep from 'lodash.defaultsdeep';
@@ -23,7 +21,14 @@ import {
23
21
  type Position,
24
22
  type Size,
25
23
  } from './layout';
26
- import { type MosaicContainerProps, type MosaicDataItem, Mosaic, Path, useMosaic } from '../../mosaic';
24
+ import {
25
+ type MosaicContainerProps,
26
+ type MosaicDataItem,
27
+ type MosaicTileAction,
28
+ Mosaic,
29
+ Path,
30
+ useMosaic,
31
+ } from '../../mosaic';
27
32
 
28
33
  //
29
34
  // Selection
@@ -47,8 +52,8 @@ type GridOptions = {
47
52
 
48
53
  const defaultGridOptions: GridOptions = {
49
54
  size: { x: 8, y: 8 },
50
- cellBounds: { width: 280, height: 280 },
51
- spacing: 8,
55
+ cellBounds: { width: 272, height: 272 },
56
+ spacing: 6,
52
57
  };
53
58
 
54
59
  //
@@ -66,6 +71,7 @@ export type GridProps<TData extends MosaicDataItem = MosaicDataItem> = MosaicCon
66
71
  square?: boolean;
67
72
  debug?: boolean;
68
73
  onCreate?: (position: Position) => void;
74
+ onAction?: (action: MosaicTileAction) => void; // TODO(burdon): Standardize across mosaics?
69
75
  };
70
76
 
71
77
  /**
@@ -86,6 +92,7 @@ export const Grid = ({
86
92
  onDrop,
87
93
  onSelect,
88
94
  onCreate,
95
+ onAction,
89
96
  }: GridProps) => {
90
97
  const { ref: containerRef, width, height } = useResizeDetector({ refreshRate: 200 });
91
98
  const options = defaultsDeep({}, opts, defaultGridOptions);
@@ -151,8 +158,8 @@ export const Grid = ({
151
158
  }}
152
159
  >
153
160
  <div className={mx('flex grow overflow-auto', className)}>
154
- <div ref={containerRef} className={mx('grow overflow-auto snap-x snap-mandatory md:snap-none bg-neutral-600')}>
155
- <div className='group block relative bg-neutral-500' style={{ ...bounds, margin: marginSize }}>
161
+ <div ref={containerRef} className={mx('grow overflow-auto snap-x snap-mandatory md:snap-none')}>
162
+ <div className='group block relative' style={{ ...bounds, margin: marginSize }}>
156
163
  {matrix && (
157
164
  <div style={{ padding: options.spacing }}>
158
165
  <div className='relative'>
@@ -172,7 +179,6 @@ export const Grid = ({
172
179
  </div>
173
180
  )}
174
181
 
175
- {/* TODO(burdon): Events: onDoubleClick={() => handleSelect(id)} */}
176
182
  <div>
177
183
  {items.map((item) => {
178
184
  const position = layout[item.id] ?? { x: 0, y: 0 };
@@ -188,6 +194,7 @@ export const Grid = ({
188
194
  ...getBounds(position, cellBounds, options.spacing),
189
195
  }}
190
196
  onSelect={() => handleSelect(item.id)}
197
+ onAction={onAction}
191
198
  // debug={debug}
192
199
  />
193
200
  );
@@ -227,14 +234,18 @@ const GridCell: FC<{
227
234
  >
228
235
  <div
229
236
  className={mx(
230
- 'group/cell hidden group-hover:flex w-full h-full items-center justify-center',
231
- isOverContainer && 'flex',
232
- 'box-border border-dashed border-4 border-neutral-600/50 rounded-lg',
233
- 'transition ease-in-out duration-200 bg-neutral-500',
234
- isOver && 'flex bg-neutral-600',
237
+ 'group/cell flex group-hover:flex w-full h-full items-center justify-center',
238
+ 'box-border border-dashed border-4 border-neutral-100 rounded-lg',
239
+ 'transition ease-in-out duration-300',
240
+ isOver && 'flex bg-neutral-200 border-neutral-400',
235
241
  )}
236
242
  >
237
- <div className={mx('hidden group-hover/cell:flex', isOverContainer && 'hidden')}>
243
+ <div
244
+ className={mx(
245
+ 'opacity-10 transition ease-in-out duration-300 group-hover/cell:opacity-100',
246
+ isOverContainer && 'hidden',
247
+ )}
248
+ >
238
249
  {onCreate && (
239
250
  // TODO(burdon): Style button.
240
251
  <Button variant='ghost' onClick={() => onCreate(position)}>
@@ -11,8 +11,8 @@ import { type MosaicDataItem, type MosaicDropEvent } from '../../mosaic';
11
11
  import { ComplexCard, TestObjectGenerator } from '../../testing';
12
12
 
13
13
  export type DemoGridProps = GridProps & {
14
- initialItems?: MosaicDataItem[];
15
- initialLayout?: GridLayout;
14
+ initialItems?: MosaicDataItem[]; // TODO(burdon): Remove or convert to controlled.
15
+ initialLayout?: GridLayout; // TODO(burdon): Remove or convert to controlled.
16
16
  types?: string[];
17
17
  debug?: boolean;
18
18
  };
@@ -51,7 +51,7 @@ export const Kanban = ({
51
51
  // Restrict to objects from other columns.
52
52
  // TODO(burdon): Consider objects from other containers.
53
53
  // TODO(wittjosiah): Allow override.
54
- onOver: ({ active, over }) => (Path.length(active.path) >= Path.length(over.path) ? 'adopt' : 'reject'),
54
+ onOver: ({ active, over }) => (Path.length(active.path) >= Path.length(over.path) ? 'transfer' : 'reject'),
55
55
  onDrop,
56
56
  }}
57
57
  >
@@ -36,7 +36,7 @@ export default {
36
36
  },
37
37
  };
38
38
 
39
- export const Adopt = {
39
+ export const Transfer = {
40
40
  args: {
41
41
  Component: SimpleCard,
42
42
  debug: true,
@@ -26,7 +26,7 @@ export const DemoStack = ({
26
26
  types,
27
27
  count = 8,
28
28
  direction = 'vertical',
29
- operation = 'adopt',
29
+ operation = 'transfer',
30
30
  debug,
31
31
  }: DemoStackProps) => {
32
32
  const [items, setItems] = useState<MosaicDataItem[]>(() => {
@@ -116,7 +116,7 @@ const TreeBranch = ({ path, items }: { path: string; items: TreeData[] }) => {
116
116
  position={index}
117
117
  Component={Component!}
118
118
  isOver={
119
- overItem?.path === Path.create(path, child.id) && (operation === 'adopt' || operation === 'copy')
119
+ overItem?.path === Path.create(path, child.id) && (operation === 'transfer' || operation === 'copy')
120
120
  }
121
121
  />
122
122
  </TreeItemComponent.Root>
@@ -5,12 +5,12 @@
5
5
  import { faker } from '@faker-js/faker';
6
6
  import React, { useCallback, useState } from 'react';
7
7
 
8
- import { type Graph, GraphBuilder, type Node } from '@braneframe/plugin-graph';
9
- import { buildGraph } from '@braneframe/plugin-graph/testing';
8
+ import { type Graph, GraphBuilder, type Node } from '@dxos/app-graph';
9
+ import { buildGraph } from '@dxos/app-graph/testing';
10
10
  import { arrayMove } from '@dxos/util';
11
11
 
12
12
  import { Tree, type TreeData, type TreeProps } from './Tree';
13
- import { type MosaicDropEvent, type MosaicMoveEvent, Path } from '../../mosaic';
13
+ import { type MosaicDropEvent, type MosaicMoveEvent, Path, type MosaicOperation } from '../../mosaic';
14
14
  import { TestObjectGenerator, nextRearrangeIndex } from '../../testing';
15
15
 
16
16
  const fake = faker.helpers.fake;
@@ -47,8 +47,8 @@ export const DemoTree = ({ id = 'tree', initialItems, types, debug }: DemoTreePr
47
47
  }),
48
48
  );
49
49
 
50
- const handleOver = useCallback(({ active, over }: MosaicMoveEvent<number>) => {
51
- return !(active.path === id && over.path !== id) ? 'adopt' : 'reject';
50
+ const handleOver = useCallback(({ over }: MosaicMoveEvent<number>) => {
51
+ return over && Path.hasChild(id, over.path) ? 'transfer' : 'reject';
52
52
  }, []);
53
53
 
54
54
  // NOTE: Does not handle deep operations.
@@ -67,8 +67,8 @@ export const DemoTree = ({ id = 'tree', initialItems, types, debug }: DemoTreePr
67
67
  if (Path.last(Path.parent(active.path)) === item.id) {
68
68
  children.splice(active.position!, 1);
69
69
  }
70
- if (Path.last(Path.parent(over.path)) === item.id) {
71
- children.splice(over.position!, 0, active.item as TreeData);
70
+ if (Path.last(over.path) === item.id) {
71
+ children.push(active.item as TreeData);
72
72
  }
73
73
  return { ...item, children };
74
74
  }),
@@ -117,7 +117,6 @@ const graphNodeCompare = (a: Node, b: Node) => {
117
117
  };
118
118
 
119
119
  export const GraphTree = ({ id, graph = createGraph(), debug }: { id: string; graph?: Graph; debug: boolean }) => {
120
- // TODO(wittjosiah): This graph does not handle order currently.
121
120
  const handleDrop = ({ operation, active, over }: MosaicDropEvent<number>) => {
122
121
  // Moving within the tree.
123
122
  if (Path.hasDescendent(id, active.path) && Path.hasDescendent(id, over.path)) {
@@ -137,18 +136,21 @@ export const GraphTree = ({ id, graph = createGraph(), debug }: { id: string; gr
137
136
  // This is a rearrange operation
138
137
  const nextIndex = nextRearrangeIndex(activeParent.children.sort(graphNodeCompare), activeNode.id, overNode.id);
139
138
  activeNode.properties.index = nextIndex ?? 'a0';
140
- } else if (activeNode && activeParent && overParent && operation === 'adopt') {
139
+ } else if (activeNode && activeParent && overParent && operation === 'transfer') {
141
140
  activeParent.removeNode(active.item.id);
142
141
  overNode.addNode('tree', { ...activeNode });
143
142
  }
144
143
  }
145
144
  };
146
145
 
146
+ const handleOver = (): MosaicOperation => 'transfer';
147
+
147
148
  return (
148
149
  <Tree
149
150
  id={id}
150
151
  items={graph.root.children as TreeData[]}
151
152
  onDrop={handleDrop}
153
+ onOver={handleOver}
152
154
  debug={debug}
153
155
  compare={graphNodeCompare}
154
156
  />