@dxos/react-ui-mosaic 0.3.10-next.ef70620 → 0.3.10

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 (49) hide show
  1. package/dist/lib/browser/index.mjs +11 -16
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/mosaic/Container.d.ts +3 -1
  5. package/dist/types/src/mosaic/Container.d.ts.map +1 -1
  6. package/dist/types/src/mosaic/Mosaic.d.ts +2 -2
  7. package/dist/types/src/mosaic/Mosaic.d.ts.map +1 -1
  8. package/dist/types/src/mosaic/Root.d.ts.map +1 -1
  9. package/dist/types/src/mosaic/Tile.d.ts +2 -1
  10. package/dist/types/src/mosaic/Tile.d.ts.map +1 -1
  11. package/dist/types/src/views/Demo/Echo.stories.d.ts +1 -5
  12. package/dist/types/src/views/Demo/Echo.stories.d.ts.map +1 -1
  13. package/dist/types/src/views/Grid/Grid.d.ts +2 -2
  14. package/dist/types/src/views/Grid/Grid.d.ts.map +1 -1
  15. package/dist/types/src/views/Grid/Grid.stories.d.ts +2 -1
  16. package/dist/types/src/views/Grid/Grid.stories.d.ts.map +1 -1
  17. package/dist/types/src/views/Grid/testing.d.ts +1 -1
  18. package/dist/types/src/views/Grid/testing.d.ts.map +1 -1
  19. package/dist/types/src/views/Kanban/Echo.stories.d.ts +1 -6
  20. package/dist/types/src/views/Kanban/Echo.stories.d.ts.map +1 -1
  21. package/dist/types/src/views/Kanban/Kanban.stories.d.ts +1 -0
  22. package/dist/types/src/views/Kanban/Kanban.stories.d.ts.map +1 -1
  23. package/dist/types/src/views/Stack/Stack.stories.d.ts +1 -0
  24. package/dist/types/src/views/Stack/Stack.stories.d.ts.map +1 -1
  25. package/dist/types/src/views/Tree/Tree.stories.d.ts +1 -0
  26. package/dist/types/src/views/Tree/Tree.stories.d.ts.map +1 -1
  27. package/package.json +14 -14
  28. package/src/mosaic/Container.tsx +5 -3
  29. package/src/mosaic/Mosaic.ts +2 -2
  30. package/src/mosaic/Root.tsx +9 -11
  31. package/src/mosaic/Tile.tsx +3 -4
  32. package/src/testing/Cards.tsx +4 -4
  33. package/src/views/Demo/Demo.stories.tsx +5 -5
  34. package/src/views/Demo/Echo.stories.tsx +11 -11
  35. package/src/views/Grid/Grid.stories.tsx +1 -0
  36. package/src/views/Grid/Grid.tsx +6 -3
  37. package/src/views/Grid/testing.tsx +2 -2
  38. package/src/views/Kanban/Echo.stories.tsx +29 -27
  39. package/src/views/Kanban/Kanban.stories.tsx +1 -0
  40. package/src/views/Kanban/Kanban.tsx +1 -1
  41. package/src/views/Stack/Columns.stories.tsx +1 -1
  42. package/src/views/Stack/Stack.stories.tsx +1 -0
  43. package/src/views/Stack/Stack.tsx +1 -1
  44. package/src/views/Tree/Graph.stories.tsx +1 -1
  45. package/src/views/Tree/Tree.stories.tsx +1 -0
  46. package/src/views/Tree/Tree.tsx +2 -2
  47. package/dist/types/src/stories/Home.stories.d.ts +0 -11
  48. package/dist/types/src/stories/Home.stories.d.ts.map +0 -1
  49. package/src/stories/Home.stories.tsx +0 -89
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.tsx"],"names":[],"mappings":"AAaA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAItB,MAAM,cAAc,CAAC;AAOtB,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;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,mKAgBd,SAAS,gBAoHX,CAAC"}
1
+ {"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.tsx"],"names":[],"mappings":"AAaA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,IAAI,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAItB,MAAM,cAAc,CAAC;AAOtB,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;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,IAAI,CACzE,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,EACrC,UAAU,CACX,GACC,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,oKAgBd,SAAS,gBAoHX,CAAC"}
@@ -1,7 +1,8 @@
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, onOver, onSelect, onCreate, onAction, }: import("./Grid").GridProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
4
+ title: string;
5
+ component: ({ id, items, layout, options: opts, margin, square, debug, selected: controlledSelected, Component, classNames, onDrop, onOver, onSelect, onCreate, onAction, }: import("./Grid").GridProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
5
6
  render: () => JSX.Element;
6
7
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R> | import("@storybook/react").Decorator)[];
7
8
  parameters: {
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;;;;;AA6BpB,wBAcE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
1
+ {"version":3,"file":"Grid.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/Grid.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;;;;;;;;;;AA6BpB,wBAeE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
@@ -6,5 +6,5 @@ export type DemoGridProps = GridProps & {
6
6
  types?: string[];
7
7
  debug?: boolean;
8
8
  };
9
- export declare const DemoGrid: ({ id, options, Component, initialItems, initialLayout, types, debug, className, }: DemoGridProps) => JSX.Element;
9
+ export declare const DemoGrid: ({ id, options, Component, initialItems, initialLayout, types, debug, classNames, }: DemoGridProps) => JSX.Element;
10
10
  //# sourceMappingURL=testing.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,cAAc,CAAC;AAGzE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,QAAQ,sFASlB,aAAa,gBA8Df,CAAC"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../../../src/views/Grid/testing.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAQ,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE/D,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,cAAc,CAAC;AAGzE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,YAAY,CAAC,EAAE,cAAc,EAAE,CAAC;IAChC,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,QAAQ,uFASlB,aAAa,gBA8Df,CAAC"}
@@ -1,13 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { type PublicKey } from '@dxos/react-client';
3
2
  declare const _default: {
4
3
  title: string;
5
4
  component: ({ id, columns, Component: TileComponent, debug, onDrop, }: import("./Kanban").KanbanProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
6
- render: ({ basePath, spaceKey, debug, }: {
7
- basePath: string;
8
- spaceKey: PublicKey;
9
- debug: boolean;
10
- }) => JSX.Element;
5
+ render: () => JSX.Element;
11
6
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R> | import("@storybook/react").Decorator)[];
12
7
  parameters: {
13
8
  layout: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Echo.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/Echo.stories.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;;;;;kBAqBtC,MAAM;kBACN,SAAS;eACZ,OAAO;;;;;;;AAXlB,wBAgDE;AAEF,eAAO,MAAM,IAAI,IAAK,CAAC"}
1
+ {"version":3,"file":"Echo.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/Echo.stories.tsx"],"names":[],"mappings":";;;;;;;;;;AAoCA,wBAgCE;AAEF,eAAO,MAAM,IAAI,IAAK,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import '@dxosTheme';
3
3
  import { type DemoKanbanProps } from './testing';
4
4
  declare const _default: {
5
+ title: string;
5
6
  component: ({ id, columns, Component: TileComponent, debug, onDrop, }: import("./Kanban").KanbanProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
6
7
  render: (args: DemoKanbanProps) => JSX.Element;
7
8
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R> | import("@storybook/react").Decorator)[];
@@ -1 +1 @@
1
- {"version":3,"file":"Kanban.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/Kanban.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAQpB,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;;;mBAQ5C,eAAe;;;;;;AAFhC,wBAcE;AAEF,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC"}
1
+ {"version":3,"file":"Kanban.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Kanban/Kanban.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAQpB,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;;;;mBAS5C,eAAe;;;;;;AAHhC,wBAeE;AAEF,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import '@dxosTheme';
3
3
  import { type StackProps } from './Stack';
4
4
  declare const _default: {
5
+ title: string;
5
6
  component: ({ id, Component, onOver, onDrop, items, direction, debug, }: StackProps<import("../../mosaic").MosaicDataItem>) => JSX.Element;
6
7
  render: (args: StackProps & {
7
8
  types: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"Stack.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Stack/Stack.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAOpB,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;;;mBAUvC,UAAU,GAAG;QACjB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf;;;;;;AANL,wBAmBE;AAEF,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;CAOtB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC"}
1
+ {"version":3,"file":"Stack.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Stack/Stack.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAOpB,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;;;;mBAWvC,UAAU,GAAG;QACjB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;KACf;;;;;;AAPL,wBAoBE;AAEF,eAAO,MAAM,OAAO;;;;;;CAMnB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;CAOtB,CAAC;AAEF,eAAO,MAAM,OAAO;;;;;;;CAOnB,CAAC"}
@@ -2,6 +2,7 @@
2
2
  import '@dxosTheme';
3
3
  import { type DemoTreeProps } from './testing';
4
4
  declare const _default: {
5
+ title: string;
5
6
  component: ({ id, Component, onOver, onDrop, items, debug }: import("./Tree").TreeProps<import("./Tree").TreeData>) => JSX.Element;
6
7
  render: (args: DemoTreeProps) => JSX.Element;
7
8
  decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R> | import("@storybook/react").Decorator)[];
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/Tree.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAQpB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;;;mBA6DxC,aAAa;;;;;;AAF9B,wBAcE;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAEnB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;;;;;;;;CAEhB,CAAC"}
1
+ {"version":3,"file":"Tree.stories.d.ts","sourceRoot":"","sources":["../../../../../src/views/Tree/Tree.stories.tsx"],"names":[],"mappings":";AAIA,OAAO,YAAY,CAAC;AAQpB,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;;;;mBA8DxC,aAAa;;;;;;AAH9B,wBAeE;AAEF,eAAO,MAAM,OAAO;;;;;;;;;;;;;CAEnB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;;;;;;;;;CAEhB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-mosaic",
3
- "version": "0.3.10-next.ef70620",
3
+ "version": "0.3.10",
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",
@@ -25,14 +25,14 @@
25
25
  "lodash.defaultsdeep": "^4.6.1",
26
26
  "lodash.pick": "^4.4.0",
27
27
  "react-resize-detector": "^7.1.2",
28
- "@dxos/debug": "0.3.10-next.ef70620",
29
- "@dxos/keys": "0.3.10-next.ef70620",
30
- "@dxos/react-ui": "0.3.10-next.ef70620",
31
- "@dxos/invariant": "0.3.10-next.ef70620",
32
- "@dxos/react-ui-card": "0.3.10-next.ef70620",
33
- "@dxos/react-ui-types": "0.3.10-next.ef70620",
34
- "@dxos/react-ui-theme": "0.3.10-next.ef70620",
35
- "@dxos/util": "0.3.10-next.ef70620"
28
+ "@dxos/debug": "0.3.10",
29
+ "@dxos/invariant": "0.3.10",
30
+ "@dxos/keys": "0.3.10",
31
+ "@dxos/react-ui": "0.3.10",
32
+ "@dxos/react-ui-card": "0.3.10",
33
+ "@dxos/react-ui-theme": "0.3.10",
34
+ "@dxos/react-ui-types": "0.3.10",
35
+ "@dxos/util": "0.3.10"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@faker-js/faker": "^8.0.2",
@@ -47,11 +47,11 @@
47
47
  "react-dom": "^18.2.0",
48
48
  "vite": "^4.3.9",
49
49
  "vite-plugin-turbosnap": "^1.0.2",
50
- "@dxos/app-graph": "0.3.10-next.ef70620",
51
- "@dxos/echo-schema": "0.3.10-next.ef70620",
52
- "@dxos/react-client": "0.3.10-next.ef70620",
53
- "@dxos/gem-core": "0.3.10-next.ef70620",
54
- "@dxos/storybook-utils": "0.3.10-next.ef70620"
50
+ "@dxos/app-graph": "0.3.10",
51
+ "@dxos/gem-core": "0.3.10",
52
+ "@dxos/echo-schema": "0.3.10",
53
+ "@dxos/react-client": "0.3.10",
54
+ "@dxos/storybook-utils": "0.3.10"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@phosphor-icons/react": "^2.0.5",
@@ -11,6 +11,8 @@ import React, {
11
11
  type PropsWithChildren,
12
12
  } from 'react';
13
13
 
14
+ import { type ThemedClassName } from '@dxos/react-ui';
15
+
14
16
  import { type MosaicTileComponent } from './Tile';
15
17
  import { useMosaic } from './hooks';
16
18
  import { type MosaicDataItem, type MosaicDraggedItem } from './types';
@@ -26,6 +28,7 @@ export const DEFAULT_TYPE = 'unknown';
26
28
  export type MosaicTileOverlayProps = {
27
29
  grow?: boolean;
28
30
  debug?: boolean;
31
+ itemContext?: Record<string, unknown>;
29
32
  };
30
33
 
31
34
  /**
@@ -49,9 +52,8 @@ export type MosaicDropEvent<TPosition = unknown> = MosaicMoveEvent<TPosition> &
49
52
  operation: MosaicOperation;
50
53
  };
51
54
 
52
- export type MosaicContainerProps<TData extends MosaicDataItem = MosaicDataItem, TPosition = unknown> = Pick<
53
- HTMLAttributes<HTMLDivElement>,
54
- 'className'
55
+ export type MosaicContainerProps<TData extends MosaicDataItem = MosaicDataItem, TPosition = unknown> = ThemedClassName<
56
+ Omit<HTMLAttributes<HTMLElement>, 'onDrop'>
55
57
  > &
56
58
  PropsWithChildren<{
57
59
  id: string;
@@ -2,7 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type FC } from 'react';
5
+ import { type FC, type RefAttributes } from 'react';
6
6
 
7
7
  import {
8
8
  MosaicContainer,
@@ -46,7 +46,7 @@ export const Mosaic = {
46
46
  DragOverlay: FC<MosaicOverlayProps>;
47
47
  SortableContext: FC<MosaicSortableProps>;
48
48
  DraggableTile: FC<MosaicTileProps<any, any>>;
49
- DroppableTile: FC<MosaicTileProps<any, any>>;
49
+ DroppableTile: FC<RefAttributes<HTMLDivElement> & MosaicTileProps<any, any>>;
50
50
  SortableTile: FC<MosaicTileProps<any, number>>;
51
51
 
52
52
  DefaultComponent: MosaicTileComponent;
@@ -24,7 +24,7 @@ import pick from 'lodash.pick';
24
24
  import React, { createContext, type FC, type PropsWithChildren, useState } from 'react';
25
25
  import { createPortal } from 'react-dom';
26
26
 
27
- import { DEFAULT_TRANSITION, type MosaicContainerProps, type MosaicMoveEvent, type MosaicOperation } from './Container';
27
+ import { DEFAULT_TRANSITION, type MosaicContainerProps, type MosaicOperation } from './Container';
28
28
  import { Debug } from './Debug';
29
29
  import { DefaultComponent } from './DefaultComponent';
30
30
  import { type MosaicTileComponent } from './Tile';
@@ -144,6 +144,7 @@ export const MosaicRoot: FC<MosaicRootProps> = ({ Component = DefaultComponent,
144
144
  // If the over item is the same as the active item, do nothing.
145
145
  // This happens when moving between containers where a placeholder of itself is rendered where it will be dropped.
146
146
  if (overItem?.item?.id === activeItem?.item.id) {
147
+ setOverItem(overItem);
147
148
  return;
148
149
  }
149
150
 
@@ -155,17 +156,14 @@ export const MosaicRoot: FC<MosaicRootProps> = ({ Component = DefaultComponent,
155
156
  return;
156
157
  }
157
158
 
158
- const onOver = ({ active, over }: MosaicMoveEvent) => {
159
- if (Path.parent(active.path) === Path.parent(over.path)) {
160
- return 'rearrange';
161
- } else if (overContainer.onOver) {
162
- return overContainer.onOver({ active, over });
163
- } else {
164
- return 'reject';
165
- }
166
- };
159
+ let operation: MosaicOperation = 'reject' as const;
160
+ if (Path.parent(activeItem.path) === Path.parent(overItem.path)) {
161
+ operation = 'rearrange' as const;
162
+ } else if (overContainer.onOver) {
163
+ operation = overContainer.onOver({ active: activeItem, over: overItem });
164
+ }
167
165
 
168
- setOperation(onOver({ active: activeItem, over: overItem }));
166
+ setOperation(operation);
169
167
  setOverItem(overItem);
170
168
  };
171
169
 
@@ -7,6 +7,8 @@ import { defaultAnimateLayoutChanges, useSortable } from '@dnd-kit/sortable';
7
7
  import React from 'react';
8
8
  import type { CSSProperties, ForwardRefExoticComponent, HTMLAttributes, RefAttributes } from 'react';
9
9
 
10
+ import { type ThemedClassName } from '@dxos/react-ui';
11
+
10
12
  import { DEFAULT_TYPE, type MosaicOperation, type MosaicTileOverlayProps } from './Container';
11
13
  import { DefaultComponent } from './DefaultComponent';
12
14
  import { useContainer, useMosaic } from './hooks';
@@ -21,10 +23,7 @@ export type MosaicTileAction = { id: string; action: string; data?: any };
21
23
  /**
22
24
  * Props passed to mosaic tile.
23
25
  */
24
- export type MosaicTileProps<TData extends MosaicDataItem = MosaicDataItem, TPosition = unknown> = Pick<
25
- HTMLAttributes<HTMLDivElement>,
26
- 'className'
27
- > &
26
+ export type MosaicTileProps<TData extends MosaicDataItem = MosaicDataItem, TPosition = unknown> = ThemedClassName<{}> &
28
27
  MosaicTileOverlayProps & {
29
28
  path: string;
30
29
  item: TData;
@@ -16,7 +16,7 @@ export type SimpleCardProps = { id: string; title?: string; body?: string; image
16
16
 
17
17
  export const SimpleCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
18
18
  (
19
- { className, active, draggableStyle, draggableProps, item: { id, title }, path, position, grow, debug, onSelect },
19
+ { classNames, active, draggableStyle, draggableProps, item: { id, title }, path, position, grow, debug, onSelect },
20
20
  forwardRef,
21
21
  ) => {
22
22
  const full = !title;
@@ -25,10 +25,10 @@ export const SimpleCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
25
25
  <Card.Root
26
26
  noPadding={full}
27
27
  classNames={mx(
28
- className,
29
28
  'w-full snap-center',
30
29
  (active === 'origin' || active === 'rearrange') && 'opacity-0',
31
30
  active === 'destination' && 'opacity-20',
31
+ classNames,
32
32
  )}
33
33
  grow={grow}
34
34
  >
@@ -52,7 +52,7 @@ SimpleCard.displayName = 'SimpleCard';
52
52
 
53
53
  export const ComplexCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
54
54
  (
55
- { className, isDragging, draggableStyle, draggableProps, item: { id, title, body, image }, grow, debug, onSelect },
55
+ { classNames, isDragging, draggableStyle, draggableProps, item: { id, title, body, image }, grow, debug, onSelect },
56
56
  forwardRef,
57
57
  ) => {
58
58
  const full = !title;
@@ -60,7 +60,7 @@ export const ComplexCard: MosaicTileComponent<SimpleCardProps> = forwardRef(
60
60
  <div role='none' ref={forwardRef} className='flex w-full' style={draggableStyle}>
61
61
  <Card.Root
62
62
  noPadding={full}
63
- classNames={mx(className, 'w-full snap-center', isDragging && 'opacity-20')}
63
+ classNames={mx('w-full snap-center', isDragging && 'opacity-20', classNames)}
64
64
  grow={grow}
65
65
  >
66
66
  <Card.Header floating={full} onDoubleClick={() => onSelect?.()}>
@@ -19,7 +19,7 @@ import { DemoTree } from '../Tree/testing';
19
19
  faker.seed(5);
20
20
 
21
21
  export default {
22
- title: 'Views/Demo',
22
+ title: 'react-ui-mosaic/Demo',
23
23
  decorators: [withTheme, FullscreenDecorator()],
24
24
  parameters: {
25
25
  layout: 'fullscreen',
@@ -34,10 +34,10 @@ export const Default = () => (
34
34
  <Mosaic.DragOverlay />
35
35
  <div className='flex grow overflow-hidden'>
36
36
  <div className='flex shrink-0 w-[280px] overflow-hidden'>
37
- <DemoStack id='stack-1' Component={SimpleCard} types={types} debug={debug} className='p-2' />
37
+ <DemoStack id='stack-1' Component={SimpleCard} types={types} debug={debug} classNames='p-2' />
38
38
  </div>
39
39
  <div className='flex grow overflow-hidden bg-neutral-900'>
40
- <DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} className='p-4' />
40
+ <DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} classNames='p-4' />
41
41
  </div>
42
42
  <div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900'>
43
43
  <DemoStack id='stack-2' Component={ComplexCard} types={types} debug={debug} />
@@ -54,7 +54,7 @@ export const Tree = () => (
54
54
  <DemoTree id='tree-1' types={types} debug={debug} />
55
55
  </div>
56
56
  <div className='flex grow overflow-hidden'>
57
- <DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} className='p-4 bg-neutral-900' />
57
+ <DemoGrid id='grid-1' Component={ComplexCard} types={types} debug={debug} classNames='p-4 bg-neutral-900' />
58
58
  </div>
59
59
  <div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900'>
60
60
  <DemoStack id='stack-2' Component={ComplexCard} types={types} debug={debug} />
@@ -71,7 +71,7 @@ export const Kanban = () => (
71
71
  <DemoTree id='tree-1' types={types} debug={debug} />
72
72
  </div>
73
73
  <div className='flex grow overflow-hidden'>
74
- <DemoKanban id='kanban-1' Component={SimpleCard} debug={debug} className='p-4' />
74
+ <DemoKanban id='kanban-1' Component={SimpleCard} debug={debug} classNames='p-4' />
75
75
  </div>
76
76
  <div className='flex shrink-0 w-[280px] overflow-hidden bg-neutral-900 pl-2'>
77
77
  <DemoStack id='stack-1' Component={ComplexCard} types={types} debug={debug} />
@@ -7,7 +7,7 @@ import React, { type FC } from 'react';
7
7
 
8
8
  import { type PublicKey } from '@dxos/react-client';
9
9
  import { Expando } from '@dxos/react-client/echo';
10
- import { ClientSpaceDecorator } from '@dxos/react-client/testing';
10
+ import { ClientRepeater } from '@dxos/react-client/testing';
11
11
  import { withTheme } from '@dxos/storybook-utils';
12
12
 
13
13
  import { Mosaic } from '../../mosaic';
@@ -42,13 +42,11 @@ const Story: FC<{ spaceKey: PublicKey }> = ({ spaceKey }) => {
42
42
  };
43
43
 
44
44
  export default {
45
- title: 'Views/Demo',
46
- render: Story,
47
- decorators: [
48
- withTheme,
49
- FullscreenDecorator(),
50
- ClientSpaceDecorator({
51
- onCreateSpace: async (space) => {
45
+ title: 'react-ui-mosaic/Demo',
46
+ render: () => (
47
+ <ClientRepeater
48
+ Component={Story}
49
+ onCreateSpace={async (space) => {
52
50
  const factory = generator.factories.project;
53
51
  const objects = [
54
52
  factory.schema,
@@ -66,9 +64,11 @@ export default {
66
64
 
67
65
  // TODO(burdon): Batch API.
68
66
  objects.forEach((object) => space.db.add(object));
69
- },
70
- }),
71
- ],
67
+ }}
68
+ createSpace
69
+ />
70
+ ),
71
+ decorators: [withTheme, FullscreenDecorator()],
72
72
  };
73
73
 
74
74
  // TODO(wittjosiah): This currently has a bug where empty over events are fired when dragging from tree onto kanban.
@@ -32,6 +32,7 @@ const testLayout = testItems.reduce<GridLayout>((map, item) => {
32
32
  }, {});
33
33
 
34
34
  export default {
35
+ title: 'react-ui-mosaic/Grid',
35
36
  component: Grid,
36
37
  render: () => {
37
38
  return (
@@ -62,7 +62,10 @@ const defaultGridOptions: GridOptions = {
62
62
 
63
63
  export type GridLayout = { [id: string]: Position };
64
64
 
65
- export type GridProps<TData extends MosaicDataItem = MosaicDataItem> = MosaicContainerProps<TData, Position> &
65
+ export type GridProps<TData extends MosaicDataItem = MosaicDataItem> = Omit<
66
+ MosaicContainerProps<TData, Position>,
67
+ 'onSelect'
68
+ > &
66
69
  ControlledSelection & {
67
70
  items?: TData[];
68
71
  layout?: GridLayout;
@@ -88,7 +91,7 @@ export const Grid = ({
88
91
  debug,
89
92
  selected: controlledSelected,
90
93
  Component = Mosaic.DefaultComponent,
91
- className,
94
+ classNames,
92
95
  onDrop,
93
96
  onOver,
94
97
  onSelect,
@@ -159,7 +162,7 @@ export const Grid = ({
159
162
  onOver,
160
163
  }}
161
164
  >
162
- <div className={mx('flex grow overflow-auto', className)}>
165
+ <div className={mx('flex grow overflow-auto', classNames)}>
163
166
  {/* TODO(burdon): Tailwind classes aren't currently processed by labs. */}
164
167
  <div ref={containerRef} className={mx('grow overflow-auto snap-x md:snap-none snap-mandatory')}>
165
168
  <div className='group block relative' style={{ ...bounds, margin: marginSize }}>
@@ -25,7 +25,7 @@ export const DemoGrid = ({
25
25
  initialLayout,
26
26
  types,
27
27
  debug,
28
- className,
28
+ classNames,
29
29
  }: DemoGridProps) => {
30
30
  const [selected, setSelected] = useState<string>();
31
31
  const [items, setItems] = useState<MosaicDataItem[]>(
@@ -80,7 +80,7 @@ export const DemoGrid = ({
80
80
  layout={layout}
81
81
  options={options}
82
82
  Component={Component}
83
- className={className}
83
+ classNames={classNames}
84
84
  debug={debug}
85
85
  selected={selected}
86
86
  onSelect={setSelected}
@@ -6,7 +6,7 @@ import React from 'react';
6
6
 
7
7
  import { type PublicKey } from '@dxos/react-client';
8
8
  import { Expando } from '@dxos/react-client/echo';
9
- import { ClientSpaceDecorator } from '@dxos/react-client/testing';
9
+ import { ClientRepeater } from '@dxos/react-client/testing';
10
10
  import { withTheme } from '@dxos/storybook-utils';
11
11
 
12
12
  import { Kanban } from './Kanban';
@@ -16,31 +16,30 @@ import { FullscreenDecorator, TestObjectGenerator, range } from '../../testing';
16
16
 
17
17
  const generator = new TestObjectGenerator();
18
18
 
19
+ const Story = ({
20
+ // TODO(wittjosiah): Can't use id because of ClientSpaceDecorator.
21
+ basePath = 'projects',
22
+ spaceKey,
23
+ debug,
24
+ }: {
25
+ basePath: string;
26
+ spaceKey: PublicKey;
27
+ debug: boolean;
28
+ }) => {
29
+ return (
30
+ <Mosaic.Root debug={debug}>
31
+ <Mosaic.DragOverlay />
32
+ <EchoKanban id={basePath} spaceKey={spaceKey} generator={generator} debug={debug} />
33
+ </Mosaic.Root>
34
+ );
35
+ };
36
+
19
37
  export default {
20
- title: 'Views/Kanban',
38
+ title: 'react-ui-mosaic/Kanban',
21
39
  component: Kanban,
22
- render: ({
23
- // TODO(wittjosiah): Can't use id because of ClientSpaceDecorator.
24
- basePath = 'projects',
25
- spaceKey,
26
- debug,
27
- }: {
28
- basePath: string;
29
- spaceKey: PublicKey;
30
- debug: boolean;
31
- }) => {
32
- return (
33
- <Mosaic.Root debug={debug}>
34
- <Mosaic.DragOverlay />
35
- <EchoKanban id={basePath} spaceKey={spaceKey} generator={generator} debug={debug} />
36
- </Mosaic.Root>
37
- );
38
- },
39
- decorators: [
40
- withTheme,
41
- FullscreenDecorator(),
42
- ClientSpaceDecorator({
43
- onCreateSpace: async (space) => {
40
+ render: () => (
41
+ <ClientRepeater
42
+ onCreateSpace={async (space) => {
44
43
  const factory = generator.factories.project;
45
44
  const objects = [
46
45
  factory.schema,
@@ -58,9 +57,12 @@ export default {
58
57
 
59
58
  // TODO(burdon): Batch API.
60
59
  objects.forEach((object) => space.db.add(object));
61
- },
62
- }),
63
- ],
60
+ }}
61
+ Component={Story}
62
+ createSpace
63
+ />
64
+ ),
65
+ decorators: [withTheme, FullscreenDecorator()],
64
66
  parameters: {
65
67
  layout: 'fullscreen',
66
68
  },
@@ -17,6 +17,7 @@ import { ComplexCard, FullscreenDecorator, SimpleCard } from '../../testing';
17
17
  faker.seed(3);
18
18
 
19
19
  export default {
20
+ title: 'react-ui-mosaic/Kanban',
20
21
  component: Kanban,
21
22
  render: (args: DemoKanbanProps) => {
22
23
  return (
@@ -124,7 +124,7 @@ const KanbanColumnComponent: MosaicTileComponent<KanbanColumn> = forwardRef(
124
124
  path={path}
125
125
  position={index}
126
126
  Component={Component!}
127
- className='m-1'
127
+ classNames='m-1'
128
128
  // debug={debug}
129
129
  />
130
130
  ))}
@@ -17,7 +17,7 @@ import { FullscreenDecorator, SimpleCard } from '../../testing';
17
17
  faker.seed(3);
18
18
 
19
19
  export default {
20
- title: 'Views/Stack/Columns',
20
+ title: 'react-ui-mosaic/Stack',
21
21
  component: Stack,
22
22
  render: (args: DemoStackProps) => {
23
23
  return (
@@ -17,6 +17,7 @@ import { ComplexCard, FullscreenDecorator, SimpleCard } from '../../testing';
17
17
  faker.seed(3);
18
18
 
19
19
  export default {
20
+ title: 'react-ui-mosaic/Stack',
20
21
  component: Stack,
21
22
  render: (
22
23
  args: StackProps & {
@@ -41,7 +41,7 @@ export const Stack = ({
41
41
  item={item}
42
42
  path={id}
43
43
  position={index}
44
- className='m-1'
44
+ classNames='m-1'
45
45
  // debug={debug}
46
46
  />
47
47
  ))}
@@ -17,7 +17,7 @@ import { FullscreenDecorator } from '../../testing';
17
17
  faker.seed(3);
18
18
 
19
19
  export default {
20
- title: 'Views/Tree',
20
+ title: 'react-ui-mosaic/Tree',
21
21
  component: Tree,
22
22
  render: ({ id = 'tree', debug }: { id: string; debug: boolean }) => {
23
23
  return (
@@ -70,6 +70,7 @@ const testItems2 = [
70
70
  ];
71
71
 
72
72
  export default {
73
+ title: 'react-ui-mosaic/Tree',
73
74
  component: Tree,
74
75
  render: (args: DemoTreeProps) => {
75
76
  return (
@@ -73,17 +73,17 @@ const TreeRoot = ({ items }: { items: TreeData[] }) => {
73
73
  * Pure component that is used by the mosaic overlay.
74
74
  */
75
75
  const TreeItem: MosaicTileComponent<TreeData> = forwardRef(
76
- ({ path, draggableStyle, draggableProps, item, operation, active, isOver, isDragging, className }, forwardedRef) => {
76
+ ({ path, draggableStyle, draggableProps, item, operation, active, isOver, isDragging, classNames }, forwardedRef) => {
77
77
  return (
78
78
  <div
79
79
  ref={forwardedRef}
80
80
  style={draggableStyle}
81
81
  className={mx(
82
82
  'flex flex-col rounded',
83
- className,
84
83
  (active === 'rearrange' || active === 'origin') && 'opacity-0',
85
84
  active === 'destination' && 'opacity-20',
86
85
  isOver && dropRing,
86
+ classNames,
87
87
  )}
88
88
  >
89
89
  <Card.Header>
@@ -1,11 +0,0 @@
1
- import '@dxosTheme';
2
- declare const _default: {
3
- component: () => JSX.Element;
4
- decorators: (import("@storybook/csf").DecoratorFunction<import("@storybook/react/dist/types-0fc72a6d").R> | import("@storybook/react").Decorator)[];
5
- parameters: {
6
- layout: string;
7
- };
8
- };
9
- export default _default;
10
- export declare const Default: {};
11
- //# sourceMappingURL=Home.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Home.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Home.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;;;;;;;;AA4EpB,wBAME;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}