@dxos/react-ui-mosaic 0.10.0 → 0.11.0
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/chunk-Mosaic.mjs +1024 -0
- package/dist/lib/chunk-Mosaic.mjs.map +1 -0
- package/dist/lib/index.mjs +653 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/playwright.mjs +200 -0
- package/dist/lib/playwright.mjs.map +1 -0
- package/dist/lib/testing.mjs +127 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +11 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/types/src/components/Board/Board.d.ts +7 -27
- package/dist/types/src/components/Board/Board.d.ts.map +1 -1
- package/dist/types/src/components/Board/Board.stories.d.ts.map +1 -1
- package/dist/types/src/components/Board/BoardColumnContext.d.ts +10 -0
- package/dist/types/src/components/Board/BoardColumnContext.d.ts.map +1 -0
- package/dist/types/src/components/Board/BoardContext.d.ts +26 -0
- package/dist/types/src/components/Board/BoardContext.d.ts.map +1 -0
- package/dist/types/src/components/Board/Column.d.ts +2 -7
- package/dist/types/src/components/Board/Column.d.ts.map +1 -1
- package/dist/types/src/components/Board/index.d.ts +2 -0
- package/dist/types/src/components/Board/index.d.ts.map +1 -1
- package/dist/types/src/components/Focus/Focus.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Container.d.ts +6 -34
- package/dist/types/src/components/Mosaic/Container.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Mosaic.d.ts +10 -15
- package/dist/types/src/components/Mosaic/Mosaic.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/MosaicContainerContext.d.ts +34 -0
- package/dist/types/src/components/Mosaic/MosaicContainerContext.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/MosaicTileContext.d.ts +31 -0
- package/dist/types/src/components/Mosaic/MosaicTileContext.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/Placeholder.d.ts +3 -3
- package/dist/types/src/components/Mosaic/Placeholder.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Stack.d.ts +8 -2
- package/dist/types/src/components/Mosaic/Stack.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Stack.stories.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/Tile.d.ts +6 -32
- package/dist/types/src/components/Mosaic/Tile.d.ts.map +1 -1
- package/dist/types/src/components/Mosaic/VirtualStackPagination.stories.d.ts +13 -0
- package/dist/types/src/components/Mosaic/VirtualStackPagination.stories.d.ts.map +1 -0
- package/dist/types/src/components/Mosaic/index.d.ts +0 -1
- package/dist/types/src/components/Mosaic/index.d.ts.map +1 -1
- package/dist/types/src/components/SearchStack/SearchStack.d.ts +1 -1
- package/dist/types/src/components/SearchStack/SearchStack.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts +2 -2
- package/dist/types/src/hooks/useDefaultColumnEventHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts +3 -3
- package/dist/types/src/hooks/useEventHandlerAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useVirtualizerPagination.d.ts +60 -0
- package/dist/types/src/hooks/useVirtualizerPagination.d.ts.map +1 -0
- package/dist/types/src/hooks/useVirtualizerPagination.test.d.ts +2 -0
- package/dist/types/src/hooks/useVirtualizerPagination.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useVisibleItems.d.ts +2 -2
- package/dist/types/src/hooks/useVisibleItems.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +35 -37
- package/src/components/Board/Board.stories.tsx +7 -6
- package/src/components/Board/Board.tsx +9 -54
- package/src/components/Board/BoardColumnContext.ts +25 -0
- package/src/components/Board/BoardContext.ts +43 -0
- package/src/components/Board/Column.tsx +13 -27
- package/src/components/Board/Item.tsx +2 -2
- package/src/components/Board/index.ts +3 -0
- package/src/components/Mosaic/Container.tsx +31 -53
- package/src/components/Mosaic/DragHandle.tsx +1 -1
- package/src/components/Mosaic/{Mosaic.tsx → Mosaic.ts} +5 -16
- package/src/components/Mosaic/MosaicContainerContext.ts +44 -0
- package/src/components/Mosaic/MosaicTileContext.ts +34 -0
- package/src/components/Mosaic/Placeholder.tsx +7 -8
- package/src/components/Mosaic/ResizeHandle.stories.tsx +4 -4
- package/src/components/Mosaic/ResizeHandle.tsx +2 -2
- package/src/components/Mosaic/Stack.stories.tsx +49 -13
- package/src/components/Mosaic/Stack.tsx +30 -9
- package/src/components/Mosaic/Tile.tsx +33 -33
- package/src/components/Mosaic/VirtualStackPagination.stories.tsx +423 -0
- package/src/components/Mosaic/index.ts +0 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useDefaultColumnEventHandler.ts +2 -2
- package/src/hooks/useEventHandlerAdapter.ts +4 -5
- package/src/hooks/useVirtualizerPagination.test.tsx +105 -0
- package/src/hooks/useVirtualizerPagination.ts +473 -0
- package/src/hooks/useVisibleItems.ts +2 -2
- package/src/playwright/smoke.spec.ts +4 -1
- package/src/testing/DefaultStackTile.tsx +1 -1
- package/src/testing/decorator.tsx +3 -3
- package/dist/lib/browser/chunk-OBVIYZLR.mjs +0 -1119
- package/dist/lib/browser/chunk-OBVIYZLR.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -701
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/playwright/index.mjs +0 -256
- package/dist/lib/browser/playwright/index.mjs.map +0 -7
- package/dist/lib/browser/testing/index.mjs +0 -136
- package/dist/lib/browser/testing/index.mjs.map +0 -7
- package/dist/lib/browser/translations.mjs +0 -18
- package/dist/lib/browser/translations.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4IEMCMIV.mjs +0 -1121
- package/dist/lib/node-esm/chunk-4IEMCMIV.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -702
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/playwright/index.mjs +0 -258
- package/dist/lib/node-esm/playwright/index.mjs.map +0 -7
- package/dist/lib/node-esm/testing/index.mjs +0 -137
- package/dist/lib/node-esm/testing/index.mjs.map +0 -7
- package/dist/lib/node-esm/translations.mjs +0 -20
- package/dist/lib/node-esm/translations.mjs.map +0 -7
- package/dist/types/src/components/Mosaic/Root.d.ts +0 -35
- package/dist/types/src/components/Mosaic/Root.d.ts.map +0 -1
- package/dist/types/src/components/Mosaic/types.d.ts +0 -86
- package/dist/types/src/components/Mosaic/types.d.ts.map +0 -1
- package/src/components/Mosaic/Root.tsx +0 -288
- package/src/components/Mosaic/types.ts +0 -94
- /package/src/components/Focus/{Focus.tsx → Focus.ts} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Virtualizer } from '@tanstack/react-virtual';
|
|
2
|
+
import { type GetId } from '@dxos/react-ui-dnd';
|
|
3
|
+
export type VirtualizerPaginationController = {
|
|
4
|
+
/** Requests the next (e.g. older) page. Omit to disable the bottom-edge trigger. */
|
|
5
|
+
getNext?: () => void;
|
|
6
|
+
/** Requests the previous (e.g. newer) page. Omit to disable the top-edge trigger. */
|
|
7
|
+
getPrevious?: () => void;
|
|
8
|
+
/** When true, suppresses the top-edge trigger (window is anchored at the live head). */
|
|
9
|
+
atHead?: boolean;
|
|
10
|
+
/** When true, suppresses both edge triggers while a page is in flight. */
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type UseVirtualizerPaginationProps<TItem = any> = {
|
|
14
|
+
/** Currently loaded window, in the order rendered by the virtualizer. */
|
|
15
|
+
items: readonly TItem[] | TItem[] | undefined;
|
|
16
|
+
/** ID getter, aligned with the virtualizer's own `getId`/`getItemKey`. */
|
|
17
|
+
getId: GetId<TItem>;
|
|
18
|
+
/** Load-next/load-previous callbacks. Both edges are inert while omitted. */
|
|
19
|
+
pagination?: VirtualizerPaginationController;
|
|
20
|
+
/** Rows from either loaded edge at which the adjacent page is requested. @default 12. */
|
|
21
|
+
threshold?: number;
|
|
22
|
+
};
|
|
23
|
+
export type UseVirtualizerPaginationResult = {
|
|
24
|
+
onChange: (virtualizer: Virtualizer<any, any>) => void;
|
|
25
|
+
/** Extra scrollable space (px) to feed into the virtualizer's `paddingStart`. */
|
|
26
|
+
leadingSpace: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Wires a paginated data source into a `Mosaic.VirtualStack`: requests the next/previous page near
|
|
30
|
+
* either loaded edge (`evaluateTriggers`), and keeps the scrollbar stable across the resulting
|
|
31
|
+
* `items` change by maintaining a leading spacer instead of rewriting the scroll offset.
|
|
32
|
+
*
|
|
33
|
+
* Called internally by `Mosaic.VirtualStack` when its `pagination` prop is set -- not normally
|
|
34
|
+
* called directly.
|
|
35
|
+
*
|
|
36
|
+
* `@tanstack/react-virtual` recomputes every item's pixel offset from the current array on each
|
|
37
|
+
* render, with no compensation for insertion/removal at the front -- rewriting the scroll offset
|
|
38
|
+
* to chase that shift visibly jumps the scrollbar thumb. Instead, `leadingSpace` (fed back into
|
|
39
|
+
* `paddingStart`) grows by exactly the evicted height and shrinks by exactly the prepended height,
|
|
40
|
+
* so retained items keep their absolute position and the thumb only scales as the total grows.
|
|
41
|
+
*
|
|
42
|
+
* Eviction (`classifyFrontEdgeChange`'s `'evicted'`) is corrected synchronously during the same
|
|
43
|
+
* render that observes the new `items`, since the evicted height is already known -- deferring it
|
|
44
|
+
* would let the browser observe (and clamp `scrollTop` against) a momentary, too-short frame.
|
|
45
|
+
* Prepending (`'prepended'`) is corrected one render later, from a layout effect
|
|
46
|
+
* (`computePrependCorrection`), since the prepended items' heights aren't known until the incoming
|
|
47
|
+
* render measures them; that lag is safe because prepending only ever grows content before the
|
|
48
|
+
* spacer shrinks to match.
|
|
49
|
+
*
|
|
50
|
+
* The layout effect also re-runs `evaluateTriggers` on every `items` change, evicted/appended or
|
|
51
|
+
* prepended alike -- `@tanstack/react-virtual` only calls `onChange` when the visible range (or
|
|
52
|
+
* `isScrolling`) changes, not merely when `items` does. Once the loaded window's tail is already
|
|
53
|
+
* fully rendered and the scrollbar sits at its physical max, further scrolling can't move that
|
|
54
|
+
* range at all, so `onChange` stops firing -- relying on it alone would permanently stall a
|
|
55
|
+
* `getNext` chain right after its own page lands, before the user scrolls again.
|
|
56
|
+
*
|
|
57
|
+
* Assumes the stack renders with `draggable={false}` (virtual indices map 1:1 onto `items`).
|
|
58
|
+
*/
|
|
59
|
+
export declare const useVirtualizerPagination: <TItem = any>({ items, getId, pagination, threshold, }: UseVirtualizerPaginationProps<TItem>) => UseVirtualizerPaginationResult;
|
|
60
|
+
//# sourceMappingURL=useVirtualizerPagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVirtualizerPagination.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVirtualizerPagination.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAehD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,oFAAoF;IACpF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qFAAqF;IACrF,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,wFAAwF;IACxF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,CAAC,KAAK,GAAG,GAAG,IAAI;IACvD,yEAAyE;IACzE,KAAK,EAAE,SAAS,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,SAAS,CAAC;IAE9C,0EAA0E;IAC1E,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAEpB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,+BAA+B,CAAC;IAE7C,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,CAAC;IACvD,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AA8QF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,wBAAwB,GAAI,KAAK,GAAG,GAAG,4CAKjD,6BAA6B,CAAC,KAAK,CAAC,KAAG,8BAmHzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVirtualizerPagination.test.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVirtualizerPagination.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type DndTileData, type GetId } from '@dxos/react-ui-dnd';
|
|
2
2
|
export type UseVisibleItemsProps<TItem = any> = {
|
|
3
3
|
/** Container id. */
|
|
4
4
|
id: string;
|
|
5
5
|
/** Current items. */
|
|
6
6
|
items?: readonly TItem[] | TItem[];
|
|
7
7
|
/** Currently dragging item. */
|
|
8
|
-
dragging:
|
|
8
|
+
dragging: DndTileData<TItem> | undefined;
|
|
9
9
|
/** ID getter */
|
|
10
10
|
getId: GetId<TItem>;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useVisibleItems.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVisibleItems.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"useVisibleItems.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useVisibleItems.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG,GAAG,IAAI;IAC9C,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;IAEX,qBAAqB;IACrB,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC;IAEnC,+BAA+B;IAC/B,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;IAEzC,gBAAgB;IAChB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,GAAG,GAAG,mCAKxC,oBAAoB,CAAC,KAAK,CAAC,KAAG,SAAS,KAAK,EAAE,GAAG,KAAK,EAiBxD,CAAC"}
|