@dxos/react-ui-mosaic 0.3.3-main.006ca4d → 0.3.3-main.1b7ca63

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.
@@ -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,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAMF,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B,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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-mosaic",
3
- "version": "0.3.3-main.006ca4d",
3
+ "version": "0.3.3-main.1b7ca63",
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.006ca4d",
30
- "@dxos/invariant": "0.3.3-main.006ca4d",
31
- "@dxos/keys": "0.3.3-main.006ca4d",
32
- "@dxos/react-ui": "0.3.3-main.006ca4d",
33
- "@dxos/react-ui-theme": "0.3.3-main.006ca4d",
34
- "@dxos/react-ui-types": "0.3.3-main.006ca4d",
35
- "@dxos/util": "0.3.3-main.006ca4d"
29
+ "@dxos/debug": "0.3.3-main.1b7ca63",
30
+ "@dxos/invariant": "0.3.3-main.1b7ca63",
31
+ "@dxos/keys": "0.3.3-main.1b7ca63",
32
+ "@dxos/react-ui": "0.3.3-main.1b7ca63",
33
+ "@dxos/react-ui-theme": "0.3.3-main.1b7ca63",
34
+ "@dxos/react-ui-types": "0.3.3-main.1b7ca63",
35
+ "@dxos/util": "0.3.3-main.1b7ca63"
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.006ca4d",
52
- "@dxos/echo-schema": "0.3.3-main.006ca4d",
53
- "@dxos/gem-core": "0.3.3-main.006ca4d",
54
- "@dxos/react-client": "0.3.3-main.006ca4d"
51
+ "@braneframe/plugin-graph": "0.3.3-main.1b7ca63",
52
+ "@dxos/echo-schema": "0.3.3-main.1b7ca63",
53
+ "@dxos/gem-core": "0.3.3-main.1b7ca63",
54
+ "@dxos/react-client": "0.3.3-main.1b7ca63"
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';
@@ -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;
@@ -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
  /**
@@ -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
@@ -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
  };