@wordpress/grid 0.1.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/CHANGELOG.md +33 -0
- package/LICENSE.md +788 -0
- package/README.md +534 -0
- package/build/dashboard-grid/grid-item.cjs +308 -0
- package/build/dashboard-grid/grid-item.cjs.map +7 -0
- package/build/dashboard-grid/index.cjs +591 -0
- package/build/dashboard-grid/index.cjs.map +7 -0
- package/build/dashboard-grid/resolve-fill-widths.cjs +189 -0
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +7 -0
- package/build/dashboard-grid/types.cjs +19 -0
- package/build/dashboard-grid/types.cjs.map +7 -0
- package/build/dashboard-lanes/index.cjs +558 -0
- package/build/dashboard-lanes/index.cjs.map +7 -0
- package/build/dashboard-lanes/lane-placement.cjs +110 -0
- package/build/dashboard-lanes/lane-placement.cjs.map +7 -0
- package/build/dashboard-lanes/lanes-item.cjs +295 -0
- package/build/dashboard-lanes/lanes-item.cjs.map +7 -0
- package/build/dashboard-lanes/types.cjs +19 -0
- package/build/dashboard-lanes/types.cjs.map +7 -0
- package/build/dashboard-lanes/use-lane-placement.cjs +206 -0
- package/build/dashboard-lanes/use-lane-placement.cjs.map +7 -0
- package/build/index.cjs +34 -0
- package/build/index.cjs.map +7 -0
- package/build/shared/drag-overlay-drop-animation.cjs +70 -0
- package/build/shared/drag-overlay-drop-animation.cjs.map +7 -0
- package/build/shared/grid-item-key.cjs +31 -0
- package/build/shared/grid-item-key.cjs.map +7 -0
- package/build/shared/grid-overlay.cjs +187 -0
- package/build/shared/grid-overlay.cjs.map +7 -0
- package/build/shared/item-exit-overlay.cjs +150 -0
- package/build/shared/item-exit-overlay.cjs.map +7 -0
- package/build/shared/resize-handle.cjs +224 -0
- package/build/shared/resize-handle.cjs.map +7 -0
- package/build/shared/resize-snap.cjs +47 -0
- package/build/shared/resize-snap.cjs.map +7 -0
- package/build/shared/types.cjs +19 -0
- package/build/shared/types.cjs.map +7 -0
- package/build/shared/use-item-exit-animation.cjs +148 -0
- package/build/shared/use-item-exit-animation.cjs.map +7 -0
- package/build/shared/use-layout-shift-animation.cjs +167 -0
- package/build/shared/use-layout-shift-animation.cjs.map +7 -0
- package/build-module/dashboard-grid/grid-item.mjs +273 -0
- package/build-module/dashboard-grid/grid-item.mjs.map +7 -0
- package/build-module/dashboard-grid/index.mjs +579 -0
- package/build-module/dashboard-grid/index.mjs.map +7 -0
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +164 -0
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +7 -0
- package/build-module/dashboard-grid/types.mjs +1 -0
- package/build-module/dashboard-grid/types.mjs.map +7 -0
- package/build-module/dashboard-lanes/index.mjs +547 -0
- package/build-module/dashboard-lanes/index.mjs.map +7 -0
- package/build-module/dashboard-lanes/lane-placement.mjs +85 -0
- package/build-module/dashboard-lanes/lane-placement.mjs.map +7 -0
- package/build-module/dashboard-lanes/lanes-item.mjs +260 -0
- package/build-module/dashboard-lanes/lanes-item.mjs.map +7 -0
- package/build-module/dashboard-lanes/types.mjs +1 -0
- package/build-module/dashboard-lanes/types.mjs.map +7 -0
- package/build-module/dashboard-lanes/use-lane-placement.mjs +181 -0
- package/build-module/dashboard-lanes/use-lane-placement.mjs.map +7 -0
- package/build-module/index.mjs +8 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs +47 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs.map +7 -0
- package/build-module/shared/grid-item-key.mjs +6 -0
- package/build-module/shared/grid-item-key.mjs.map +7 -0
- package/build-module/shared/grid-overlay.mjs +152 -0
- package/build-module/shared/grid-overlay.mjs.map +7 -0
- package/build-module/shared/item-exit-overlay.mjs +125 -0
- package/build-module/shared/item-exit-overlay.mjs.map +7 -0
- package/build-module/shared/resize-handle.mjs +193 -0
- package/build-module/shared/resize-handle.mjs.map +7 -0
- package/build-module/shared/resize-snap.mjs +21 -0
- package/build-module/shared/resize-snap.mjs.map +7 -0
- package/build-module/shared/types.mjs +1 -0
- package/build-module/shared/types.mjs.map +7 -0
- package/build-module/shared/use-item-exit-animation.mjs +128 -0
- package/build-module/shared/use-item-exit-animation.mjs.map +7 -0
- package/build-module/shared/use-layout-shift-animation.mjs +140 -0
- package/build-module/shared/use-layout-shift-animation.mjs.map +7 -0
- package/build-types/dashboard-grid/grid-item.d.ts +3 -0
- package/build-types/dashboard-grid/grid-item.d.ts.map +1 -0
- package/build-types/dashboard-grid/index.d.ts +35 -0
- package/build-types/dashboard-grid/index.d.ts.map +1 -0
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts +26 -0
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts.map +1 -0
- package/build-types/dashboard-grid/stories/index.story.d.ts +98 -0
- package/build-types/dashboard-grid/stories/index.story.d.ts.map +1 -0
- package/build-types/dashboard-grid/types.d.ts +232 -0
- package/build-types/dashboard-grid/types.d.ts.map +1 -0
- package/build-types/dashboard-lanes/index.d.ts +40 -0
- package/build-types/dashboard-lanes/index.d.ts.map +1 -0
- package/build-types/dashboard-lanes/lane-placement.d.ts +126 -0
- package/build-types/dashboard-lanes/lane-placement.d.ts.map +1 -0
- package/build-types/dashboard-lanes/lanes-item.d.ts +52 -0
- package/build-types/dashboard-lanes/lanes-item.d.ts.map +1 -0
- package/build-types/dashboard-lanes/stories/index.story.d.ts +64 -0
- package/build-types/dashboard-lanes/stories/index.story.d.ts.map +1 -0
- package/build-types/dashboard-lanes/types.d.ts +151 -0
- package/build-types/dashboard-lanes/types.d.ts.map +1 -0
- package/build-types/dashboard-lanes/use-lane-placement.d.ts +74 -0
- package/build-types/dashboard-lanes/use-lane-placement.d.ts.map +1 -0
- package/build-types/index.d.ts +6 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/shared/drag-overlay-drop-animation.d.ts +13 -0
- package/build-types/shared/drag-overlay-drop-animation.d.ts.map +1 -0
- package/build-types/shared/grid-item-key.d.ts +6 -0
- package/build-types/shared/grid-item-key.d.ts.map +1 -0
- package/build-types/shared/grid-overlay.d.ts +19 -0
- package/build-types/shared/grid-overlay.d.ts.map +1 -0
- package/build-types/shared/item-exit-overlay.d.ts +20 -0
- package/build-types/shared/item-exit-overlay.d.ts.map +1 -0
- package/build-types/shared/resize-handle.d.ts +23 -0
- package/build-types/shared/resize-handle.d.ts.map +1 -0
- package/build-types/shared/resize-snap.d.ts +41 -0
- package/build-types/shared/resize-snap.d.ts.map +1 -0
- package/build-types/shared/types.d.ts +144 -0
- package/build-types/shared/types.d.ts.map +1 -0
- package/build-types/shared/use-item-exit-animation.d.ts +37 -0
- package/build-types/shared/use-item-exit-animation.d.ts.map +1 -0
- package/build-types/shared/use-layout-shift-animation.d.ts +77 -0
- package/build-types/shared/use-layout-shift-animation.d.ts.map +1 -0
- package/package.json +80 -0
- package/src/dashboard-grid/grid-item.module.css +94 -0
- package/src/dashboard-grid/grid-item.tsx +205 -0
- package/src/dashboard-grid/grid.module.css +134 -0
- package/src/dashboard-grid/index.tsx +713 -0
- package/src/dashboard-grid/resolve-fill-widths.ts +224 -0
- package/src/dashboard-grid/stories/index.story.tsx +930 -0
- package/src/dashboard-grid/test/keyboard-activation.test.tsx +76 -0
- package/src/dashboard-grid/test/resolve-fill-widths.test.ts +250 -0
- package/src/dashboard-grid/types.ts +271 -0
- package/src/dashboard-lanes/index.tsx +629 -0
- package/src/dashboard-lanes/lane-placement.ts +245 -0
- package/src/dashboard-lanes/lanes-item.module.css +93 -0
- package/src/dashboard-lanes/lanes-item.tsx +236 -0
- package/src/dashboard-lanes/lanes.module.css +152 -0
- package/src/dashboard-lanes/stories/index.story.tsx +518 -0
- package/src/dashboard-lanes/test/keyboard-activation.test.tsx +71 -0
- package/src/dashboard-lanes/test/lane-placement.test.ts +442 -0
- package/src/dashboard-lanes/test/use-lane-placement.test.tsx +358 -0
- package/src/dashboard-lanes/types.ts +176 -0
- package/src/dashboard-lanes/use-lane-placement.ts +313 -0
- package/src/index.ts +17 -0
- package/src/shared/actionable-area-slot.module.css +16 -0
- package/src/shared/drag-overlay-drop-animation.ts +66 -0
- package/src/shared/grid-item-key.ts +5 -0
- package/src/shared/grid-overlay.module.css +82 -0
- package/src/shared/grid-overlay.tsx +93 -0
- package/src/shared/item-exit-animation.module.css +49 -0
- package/src/shared/item-exit-overlay.tsx +57 -0
- package/src/shared/layout-shift-animation.module.css +16 -0
- package/src/shared/resize-handle.module.css +88 -0
- package/src/shared/resize-handle.tsx +163 -0
- package/src/shared/resize-snap.ts +63 -0
- package/src/shared/test/resize-snap.test.ts +35 -0
- package/src/shared/types.ts +164 -0
- package/src/shared/use-item-exit-animation.ts +199 -0
- package/src/shared/use-layout-shift-animation.ts +284 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { DragPreviewRenderProps, GridOverlayRenderProps, ResizeHandleRenderProps } from '../shared/types';
|
|
5
|
+
/**
|
|
6
|
+
* Lanes layout item definition.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the public surface of `display: grid-lanes`: column span,
|
|
9
|
+
* an optional pinned lane, and an optional source order. Heights are
|
|
10
|
+
* content-driven; there is no `height` field. There is no `'fill'`
|
|
11
|
+
* (lanes pack their items by skyline; nothing is "left over").
|
|
12
|
+
* `'full'` is expressed by setting `width` to the lane count.
|
|
13
|
+
*/
|
|
14
|
+
export type DashboardLanesLayoutItem = {
|
|
15
|
+
/**
|
|
16
|
+
* Unique key that matches a child component key.
|
|
17
|
+
*/
|
|
18
|
+
key: string;
|
|
19
|
+
/**
|
|
20
|
+
* Number of lanes this item spans (`grid-column: span N`). Clamped
|
|
21
|
+
* to the surface's lane count.
|
|
22
|
+
*
|
|
23
|
+
* @default 1
|
|
24
|
+
*/
|
|
25
|
+
width?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Pin the item to a specific 0-indexed lane. Pinned items are
|
|
28
|
+
* placed before auto items, so the auto flow runs around them.
|
|
29
|
+
* Out-of-range values (negative, or beyond `columns - width`) are
|
|
30
|
+
* clamped to the available range.
|
|
31
|
+
*/
|
|
32
|
+
lane?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Display order. Lower values render first. When omitted, the
|
|
35
|
+
* item falls back to its index in the `layout` array.
|
|
36
|
+
*/
|
|
37
|
+
order?: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Props for `DashboardLanes`.
|
|
41
|
+
*
|
|
42
|
+
* `columns` and `minColumnWidth` compose as a layered model:
|
|
43
|
+
* - `columns` alone: fixed N lanes; tiles scale with the container.
|
|
44
|
+
* - `minColumnWidth` alone: lane count derives from container width,
|
|
45
|
+
* floored by the per-tile minimum, down to 1.
|
|
46
|
+
* - Both together: `columns` caps the count, `minColumnWidth` enforces
|
|
47
|
+
* a per-tile width floor that can reduce the count below the cap.
|
|
48
|
+
*/
|
|
49
|
+
export interface DashboardLanesProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'className' | 'style'> {
|
|
50
|
+
/**
|
|
51
|
+
* Array of layout items.
|
|
52
|
+
*/
|
|
53
|
+
layout: DashboardLanesLayoutItem[];
|
|
54
|
+
/**
|
|
55
|
+
* Surface children. Each child must carry a `key` matching an
|
|
56
|
+
* entry in `layout`; children without a match render at the end
|
|
57
|
+
* of the surface without explicit placement and fall through the
|
|
58
|
+
* lanes auto-flow.
|
|
59
|
+
*/
|
|
60
|
+
children: React.ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* Additional CSS class on the surface root.
|
|
63
|
+
*/
|
|
64
|
+
className?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Inline styles on the surface root. Merged underneath the
|
|
67
|
+
* surface's own layout styles, so `display` and
|
|
68
|
+
* `gridTemplateColumns` always win. The gap between tiles is
|
|
69
|
+
* owned by the design-system gap token and is not configurable
|
|
70
|
+
* per instance; override it via a theme or density change.
|
|
71
|
+
*/
|
|
72
|
+
style?: React.CSSProperties;
|
|
73
|
+
/**
|
|
74
|
+
* `flow-tolerance` value in pixels. When two candidate lanes
|
|
75
|
+
* differ in baseline by no more than this, the earlier lane wins
|
|
76
|
+
* to preserve source order. Larger values keep tiles closer to
|
|
77
|
+
* reading order at the cost of bigger empty regions.
|
|
78
|
+
*
|
|
79
|
+
* @default 16
|
|
80
|
+
*/
|
|
81
|
+
flowTolerance?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Snap unit for the polyfill's `grid-row-start` / `grid-row-end:
|
|
84
|
+
* span N` math. Smaller values produce sharper placement at the
|
|
85
|
+
* cost of a larger implicit row count. Ignored on browsers with
|
|
86
|
+
* native `display: grid-lanes` support.
|
|
87
|
+
*
|
|
88
|
+
* @default 4
|
|
89
|
+
*/
|
|
90
|
+
rowUnit?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the surface is in edit mode (drag-to-reorder, resize).
|
|
93
|
+
*
|
|
94
|
+
* @default false
|
|
95
|
+
*/
|
|
96
|
+
editMode?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Fired when the user commits a drag or resize.
|
|
99
|
+
*/
|
|
100
|
+
onChangeLayout?: (newLayout: DashboardLanesLayoutItem[]) => void;
|
|
101
|
+
/**
|
|
102
|
+
* Fired continuously during a gesture with the in-progress
|
|
103
|
+
* layout. The committed result still emits via `onChangeLayout`.
|
|
104
|
+
*/
|
|
105
|
+
onPreviewLayout?: (previewLayout: DashboardLanesLayoutItem[]) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Override the default corner resize handle. See `DashboardGrid`
|
|
108
|
+
* for the full contract; on lanes the handle is horizontal-only
|
|
109
|
+
* because heights are content-driven.
|
|
110
|
+
*/
|
|
111
|
+
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
112
|
+
/**
|
|
113
|
+
* Custom wrapper for the dragged-clone visual mounted inside
|
|
114
|
+
* `<DragOverlay>`. The surface always wraps the clone with a thin
|
|
115
|
+
* functional frame (lift scale, grabbing cursor, pointer pass-
|
|
116
|
+
* through) and mounts this component inside it; the consumer
|
|
117
|
+
* owns the visual chrome (shadow, radius, padding).
|
|
118
|
+
*
|
|
119
|
+
* When omitted, the cloned children render directly inside the
|
|
120
|
+
* functional frame so any chrome the consumer applied to the
|
|
121
|
+
* persistent tile carries through unchanged.
|
|
122
|
+
*
|
|
123
|
+
* Token-only adjustments (lift scale, placeholder opacity,
|
|
124
|
+
* outline color, placeholder radius) flow through CSS custom
|
|
125
|
+
* properties documented in the README.
|
|
126
|
+
*/
|
|
127
|
+
renderDragPreview?: React.ComponentType<DragPreviewRenderProps>;
|
|
128
|
+
/**
|
|
129
|
+
* Override the default edit-mode overlay (empty column tracks) with
|
|
130
|
+
* a custom component. Lanes are content-driven vertically, so no
|
|
131
|
+
* `rowHeight` or `rows` is supplied and the default visual paints
|
|
132
|
+
* columns only.
|
|
133
|
+
*
|
|
134
|
+
* The overlay only renders when `editMode` is true. When omitted,
|
|
135
|
+
* the package's default visual is used.
|
|
136
|
+
*/
|
|
137
|
+
renderGridOverlay?: React.ComponentType<GridOverlayRenderProps>;
|
|
138
|
+
/**
|
|
139
|
+
* Target lane count, used as a cap. Defaults to six when neither
|
|
140
|
+
* `columns` nor `minColumnWidth` is set; with `minColumnWidth` set
|
|
141
|
+
* it can resolve lower on narrow containers.
|
|
142
|
+
*/
|
|
143
|
+
columns?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Per-tile minimum width in pixels. Enables responsive mode: the
|
|
146
|
+
* lane count derives from container width, floored by this value,
|
|
147
|
+
* down to 1.
|
|
148
|
+
*/
|
|
149
|
+
minColumnWidth?: number;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACtC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,mBAChB,SAAQ,IAAI,CACX,KAAK,CAAC,wBAAwB,CAAE,KAAK,CAAE,EACvC,UAAU,GAAG,WAAW,GAAG,OAAO,CAClC;IACD;;OAEG;IACH,MAAM,EAAE,wBAAwB,EAAE,CAAC;IAEnC;;;;;OAKG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,CAAE,SAAS,EAAE,wBAAwB,EAAE,KAAM,IAAI,CAAC;IAEnE;;;OAGG;IACH,eAAe,CAAC,EAAE,CAAE,aAAa,EAAE,wBAAwB,EAAE,KAAM,IAAI,CAAC;IAExE;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,uBAAuB,CAAE,CAAC;IAEpE;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,sBAAsB,CAAE,CAAC;IAElE;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,sBAAsB,CAAE,CAAC;IAElE;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logical item passed to the hook. The renderer is responsible for
|
|
3
|
+
* mounting a DOM node with `data-wp-grid-item-key={ item.key }` for each
|
|
4
|
+
* entry; the hook will measure that node and produce inline styles.
|
|
5
|
+
*/
|
|
6
|
+
export type LaneItemInput = {
|
|
7
|
+
key: string;
|
|
8
|
+
span?: number;
|
|
9
|
+
lane?: number;
|
|
10
|
+
};
|
|
11
|
+
export type UseLanePlacementInput = {
|
|
12
|
+
items: ReadonlyArray<LaneItemInput>;
|
|
13
|
+
lanes: number;
|
|
14
|
+
gap: number;
|
|
15
|
+
flowTolerance: number;
|
|
16
|
+
/**
|
|
17
|
+
* Snap unit for `grid-row-start` / `grid-row-end: span N` math.
|
|
18
|
+
* Smaller values produce sharper placement at the cost of more
|
|
19
|
+
* implicit rows. Defaults to 4 (px).
|
|
20
|
+
*/
|
|
21
|
+
rowUnit?: number;
|
|
22
|
+
};
|
|
23
|
+
export type UseLanePlacementResult = {
|
|
24
|
+
/**
|
|
25
|
+
* Inline styles to apply to each item, keyed by item key. On
|
|
26
|
+
* native (`display: grid-lanes`), entries carry only
|
|
27
|
+
* `gridColumn: span N`; the browser handles row placement. While
|
|
28
|
+
* polyfilling, entries also carry explicit `grid-column-start` /
|
|
29
|
+
* `grid-row-*` values.
|
|
30
|
+
*/
|
|
31
|
+
itemStyles: Map<string, React.CSSProperties>;
|
|
32
|
+
/**
|
|
33
|
+
* `false` when the host browser supports `display: grid-lanes`
|
|
34
|
+
* natively. The hook avoids mounting any observers in that case.
|
|
35
|
+
*/
|
|
36
|
+
isPolyfilled: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Hook that measures item heights and resolves their placement when
|
|
40
|
+
* `display: grid-lanes` is unavailable, falling through to a no-op
|
|
41
|
+
* pass when the host browser supports the feature natively.
|
|
42
|
+
*
|
|
43
|
+
* Usage from the renderer:
|
|
44
|
+
*
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const [ container, setContainer ] = useState< HTMLDivElement | null >( null );
|
|
47
|
+
* const { itemStyles } = useLanePlacement( container, {
|
|
48
|
+
* items: layout,
|
|
49
|
+
* lanes: columns,
|
|
50
|
+
* gap: gapPx,
|
|
51
|
+
* flowTolerance: 16,
|
|
52
|
+
* } );
|
|
53
|
+
*
|
|
54
|
+
* return (
|
|
55
|
+
* <div ref={ setContainer } style={ { display: 'grid-lanes', ... } }>
|
|
56
|
+
* { items.map( ( item ) => (
|
|
57
|
+
* <div
|
|
58
|
+
* key={ item.key }
|
|
59
|
+
* data-wp-grid-item-key={ item.key }
|
|
60
|
+
* style={ itemStyles.get( item.key ) }
|
|
61
|
+
* >
|
|
62
|
+
* { ... }
|
|
63
|
+
* </div>
|
|
64
|
+
* ) ) }
|
|
65
|
+
* </div>
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param container HTMLElement (or null pre-mount) hosting the items.
|
|
70
|
+
* @param input Logical items, lane count, gap, and tuning.
|
|
71
|
+
* @return Per-item styles plus the `isPolyfilled` flag.
|
|
72
|
+
*/
|
|
73
|
+
export declare function useLanePlacement(container: HTMLElement | null, input: UseLanePlacementInput): UseLanePlacementResult;
|
|
74
|
+
//# sourceMappingURL=use-lane-placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-lane-placement.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/use-lane-placement.ts"],"names":[],"mappings":"AA2BA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC,KAAK,EAAE,aAAa,CAAE,aAAa,CAAE,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC;;;;;;OAMG;IACH,UAAU,EAAE,GAAG,CAAE,MAAM,EAAE,KAAK,CAAC,aAAa,CAAE,CAAC;IAE/C;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,WAAW,GAAG,IAAI,EAC7B,KAAK,EAAE,qBAAqB,GAC1B,sBAAsB,CA8MxB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { DashboardGrid } from './dashboard-grid';
|
|
2
|
+
export { DashboardLanes } from './dashboard-lanes';
|
|
3
|
+
export type { DashboardGridLayoutItem, DashboardGridProps, } from './dashboard-grid/types';
|
|
4
|
+
export type { DashboardLanesLayoutItem, DashboardLanesProps, } from './dashboard-lanes/types';
|
|
5
|
+
export type { DragPreviewRenderProps, GridOverlayRenderProps, ResizeDelta, ResizeHandleRenderProps, } from './shared/types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,YAAY,EACX,uBAAuB,EACvB,kBAAkB,GAClB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACX,wBAAwB,EACxB,mBAAmB,GACnB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,uBAAuB,GACvB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DropAnimation } from '@dnd-kit/core';
|
|
2
|
+
/** Matches `--wpds-motion-duration-md` on the drag preview frame exit. */
|
|
3
|
+
export declare const DROP_ANIMATION_DURATION_MS = 200;
|
|
4
|
+
/**
|
|
5
|
+
* Composes @dnd-kit/core’s default overlay drop translation with preview
|
|
6
|
+
* exit keyframes (via side effects). When the pointer never moves, @dnd-kit
|
|
7
|
+
* skips the drop animation and these side effects do not run.
|
|
8
|
+
*
|
|
9
|
+
* @param dragPreviewFrameClassName Hashed class for `.drag-preview-frame`.
|
|
10
|
+
* @param exitingFrameClassName Hashed class for the exit state.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDashboardDragDropAnimation(dragPreviewFrameClassName: string, exitingFrameClassName: string): DropAnimation;
|
|
13
|
+
//# sourceMappingURL=drag-overlay-drop-animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag-overlay-drop-animation.d.ts","sourceRoot":"","sources":["../../src/shared/drag-overlay-drop-animation.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAK9C;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC/C,yBAAyB,EAAE,MAAM,EACjC,qBAAqB,EAAE,MAAM,GAC3B,aAAa,CAuCf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-item-key.d.ts","sourceRoot":"","sources":["../../src/shared/grid-item-key.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { GridOverlayRenderProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Default edit-mode overlay: one column per track, each holding `rows`
|
|
7
|
+
* row-marker tiles when `rowHeight` is uniform. Used by both surfaces
|
|
8
|
+
* and replaceable via `renderGridOverlay`. Reveals with a diagonal
|
|
9
|
+
* wave on activate and releases paint cost while inactive.
|
|
10
|
+
*
|
|
11
|
+
* @param props Render props supplied by the surface.
|
|
12
|
+
* @param props.columns Column tracks to mirror.
|
|
13
|
+
* @param props.rowHeight Uniform row height in pixels; omitted for
|
|
14
|
+
* content-sized rows, which skip row markers.
|
|
15
|
+
* @param props.rows Row tracks per column; omitted when unknown.
|
|
16
|
+
* @param props.isActive When `false`, the overlay fades out.
|
|
17
|
+
*/
|
|
18
|
+
export declare function GridOverlay({ columns, rowHeight, rows, isActive }: GridOverlayRenderProps): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=grid-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-overlay.d.ts","sourceRoot":"","sources":["../../src/shared/grid-overlay.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGtD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAE,EAC5B,OAAO,EACP,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,EAAE,sBAAsB,+BA0DxB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RectSnapshot } from './use-layout-shift-animation';
|
|
2
|
+
export type ItemExitOverlayRect = Pick<RectSnapshot, 'left' | 'top' | 'width' | 'height'>;
|
|
3
|
+
export type ItemExitOverlayProps = {
|
|
4
|
+
itemKey: string;
|
|
5
|
+
rect: ItemExitOverlayRect;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
onAnimationEnd: () => void;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Ghost tile shown at the removed item's last position while siblings
|
|
11
|
+
* reflow. Not a sortable grid cell — only visual exit feedback.
|
|
12
|
+
*
|
|
13
|
+
* @param root0 Component props.
|
|
14
|
+
* @param root0.itemKey Layout key of the removed tile.
|
|
15
|
+
* @param root0.rect Last bounds relative to the grid surface.
|
|
16
|
+
* @param root0.children Cached tile content to render in the ghost.
|
|
17
|
+
* @param root0.onAnimationEnd Called when the exit animation finishes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ItemExitOverlay({ itemKey, rect, children, onAnimationEnd }: ItemExitOverlayProps): import("react").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=item-exit-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-exit-overlay.d.ts","sourceRoot":"","sources":["../../src/shared/item-exit-overlay.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACrC,YAAY,EACZ,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CACnC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAE,EAChC,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,EAAE,oBAAoB,+BAsBtB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ResizeHandleProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Renders a corner resize handle inside an isolated `<DndContext>`.
|
|
7
|
+
* Reports the cursor offset since the gesture started (in pixels)
|
|
8
|
+
* via `onResize`, throttled to one animation frame so the grid
|
|
9
|
+
* commit loop runs at most once per paint.
|
|
10
|
+
*
|
|
11
|
+
* Auto-scroll is enabled with a tight trigger zone and a low
|
|
12
|
+
* acceleration so a resize gesture near the viewport edge scrolls
|
|
13
|
+
* the page only when the user deliberately pushes against the very
|
|
14
|
+
* edge, and even then at a pace the user can interrupt by releasing.
|
|
15
|
+
* Default tuning would otherwise produce a runaway loop where the
|
|
16
|
+
* page scrolls fast, dnd-kit's document-coordinate `delta` inflates
|
|
17
|
+
* with the scroll, and the tile keeps growing without further user
|
|
18
|
+
* input.
|
|
19
|
+
*
|
|
20
|
+
* @param props Component props.
|
|
21
|
+
*/
|
|
22
|
+
export default function ResizeHandleWrapper(props: ResizeHandleProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=resize-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-handle.d.ts","sourceRoot":"","sources":["../../src/shared/resize-handle.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAsF9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,KAAK,EAAE,iBAAiB,+BA2CpE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ResizeDelta } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Pixel dimensions for the snapped resize preview outline.
|
|
4
|
+
*/
|
|
5
|
+
export type ResizeSnapSize = {
|
|
6
|
+
widthPx: number;
|
|
7
|
+
/** When `null`, the preview spans the item's content height (lanes). */
|
|
8
|
+
heightPx: number | null;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Clamps a resize delta so the tile cannot shrink below the given
|
|
12
|
+
* minimum width (and height when provided).
|
|
13
|
+
*
|
|
14
|
+
* @param delta Cursor offset from the gesture start in pixels.
|
|
15
|
+
* @param initialSize Size captured at gesture start.
|
|
16
|
+
* @param initialSize.width Initial width in pixels.
|
|
17
|
+
* @param initialSize.height Initial height in pixels.
|
|
18
|
+
* @param minSize Minimum tile size in pixels.
|
|
19
|
+
* @param minSize.width Minimum width in pixels.
|
|
20
|
+
* @param minSize.height Minimum height in pixels, when vertical resize applies.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clampResizeDelta(delta: ResizeDelta, initialSize: {
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}, minSize: {
|
|
26
|
+
width: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
}): ResizeDelta;
|
|
29
|
+
/**
|
|
30
|
+
* Converts grid spans to pixel width/height for the resize-preview
|
|
31
|
+
* outline, using the same track math the surface uses for placement.
|
|
32
|
+
*
|
|
33
|
+
* @param columnSpan Number of columns the snap target spans.
|
|
34
|
+
* @param rowSpan Number of rows the snap target spans.
|
|
35
|
+
* @param columnWidth Width of one column track in pixels.
|
|
36
|
+
* @param gapPx Gap between tracks in pixels.
|
|
37
|
+
* @param rowHeightPx Row track height in pixels, or `null` when rows
|
|
38
|
+
* are content-sized.
|
|
39
|
+
*/
|
|
40
|
+
export declare function gridSpanToPixelSize(columnSpan: number, rowSpan: number, columnWidth: number, gapPx: number, rowHeightPx: number | null): ResizeSnapSize;
|
|
41
|
+
//# sourceMappingURL=resize-snap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-snap.d.ts","sourceRoot":"","sources":["../../src/shared/resize-snap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC9C,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACzC,WAAW,CASb;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,GACxB,cAAc,CAOhB"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { useDraggable } from '@dnd-kit/core';
|
|
5
|
+
type DraggableBindings = ReturnType<typeof useDraggable>;
|
|
6
|
+
/**
|
|
7
|
+
* Cursor offset reported by the resize handle, in pixels relative to
|
|
8
|
+
* the gesture start. Width and height are independent so the surface
|
|
9
|
+
* can step columns and rows separately.
|
|
10
|
+
*/
|
|
11
|
+
export type ResizeDelta = {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Props received by a custom resize handle component. Spread `listeners`
|
|
17
|
+
* and `attributes` onto the element that should respond to the gesture,
|
|
18
|
+
* and assign `ref` to the same element so dnd-kit can track it.
|
|
19
|
+
*/
|
|
20
|
+
export interface ResizeHandleRenderProps {
|
|
21
|
+
/**
|
|
22
|
+
* Ref callback to attach to the gesture-bearing element.
|
|
23
|
+
*/
|
|
24
|
+
ref: DraggableBindings['setNodeRef'];
|
|
25
|
+
/**
|
|
26
|
+
* Pointer/keyboard event listeners that initiate the drag.
|
|
27
|
+
*/
|
|
28
|
+
listeners: DraggableBindings['listeners'];
|
|
29
|
+
/**
|
|
30
|
+
* Accessibility and dnd-kit attributes (role, aria-*, tabIndex…).
|
|
31
|
+
*/
|
|
32
|
+
attributes: DraggableBindings['attributes'];
|
|
33
|
+
/**
|
|
34
|
+
* Whether vertical resizing is allowed for this tile. Useful for
|
|
35
|
+
* adapting the cursor or visual cue.
|
|
36
|
+
*/
|
|
37
|
+
verticalResizable: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* True while the user is actively dragging this handle. Use it to
|
|
40
|
+
* swap colors, icons, or transforms during the gesture.
|
|
41
|
+
*/
|
|
42
|
+
isResizing: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Owning item's `key`. Available so consumers can render per-tile
|
|
45
|
+
* content if needed.
|
|
46
|
+
*/
|
|
47
|
+
itemId?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Props received by a custom drag-preview component. The surface mounts
|
|
51
|
+
* the component inside `<DragOverlay>` and supplies the active tile's
|
|
52
|
+
* cloned children plus its `key`. The component is responsible for the
|
|
53
|
+
* visual chrome of the dragged clone (shadow, radius, padding); the
|
|
54
|
+
* surface keeps a thin functional wrapper around it that owns the lift
|
|
55
|
+
* cue, the cursor, and pointer pass-through during the gesture.
|
|
56
|
+
*/
|
|
57
|
+
export interface DragPreviewRenderProps {
|
|
58
|
+
/**
|
|
59
|
+
* The cloned tile content the surface mounts inside the
|
|
60
|
+
* `<DragOverlay>` portal. Render it where the visual wrapper
|
|
61
|
+
* expects the tile body.
|
|
62
|
+
*/
|
|
63
|
+
children: React.ReactNode;
|
|
64
|
+
/**
|
|
65
|
+
* Owning tile's `key`. Useful when the visual chrome needs to
|
|
66
|
+
* vary by which tile is being dragged.
|
|
67
|
+
*/
|
|
68
|
+
itemId: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Props received by a custom grid overlay component. The overlay
|
|
72
|
+
* paints behind the tiles in edit mode to visualize the column tracks
|
|
73
|
+
* and (when `rowHeight` is defined) the row tracks. Receives a
|
|
74
|
+
* snapshot of the surface's resolved layout parameters so the visual
|
|
75
|
+
* can reproduce the tracks pixel-accurately without re-deriving them.
|
|
76
|
+
*
|
|
77
|
+
* Reused by both `DashboardGrid` and `DashboardLanes`: lanes pass no
|
|
78
|
+
* `rowHeight` because heights are content-driven.
|
|
79
|
+
*/
|
|
80
|
+
export interface GridOverlayRenderProps {
|
|
81
|
+
/**
|
|
82
|
+
* Number of column tracks in the active surface. In responsive
|
|
83
|
+
* mode (`minColumnWidth`), this is the count derived from the
|
|
84
|
+
* container width, not the prop value.
|
|
85
|
+
*/
|
|
86
|
+
columns: number;
|
|
87
|
+
/**
|
|
88
|
+
* Row height in pixels for surfaces with uniform rows. Omitted on
|
|
89
|
+
* surfaces with content-driven heights (lanes) or when row height
|
|
90
|
+
* is `'auto'`; in those cases row markers are omitted.
|
|
91
|
+
*/
|
|
92
|
+
rowHeight?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Number of row tracks to mirror in each column. Derived from the
|
|
95
|
+
* grid container height when `rowHeight` is numeric; omitted when
|
|
96
|
+
* row height is unknown.
|
|
97
|
+
*/
|
|
98
|
+
rows?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the overlay should be visible. Surfaces render the
|
|
101
|
+
* overlay even when `false` so the implementation can transition
|
|
102
|
+
* opacity in and out; while `false`, the overlay must hide itself
|
|
103
|
+
* (and ideally release paint cost via `visibility: hidden` or an
|
|
104
|
+
* equivalent).
|
|
105
|
+
*/
|
|
106
|
+
isActive: boolean;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Props for the internal `<ResizeHandle />` wrapper.
|
|
110
|
+
*/
|
|
111
|
+
export interface ResizeHandleProps {
|
|
112
|
+
/**
|
|
113
|
+
* Owning item's `key`. Forwarded as `data.itemId` on the draggable
|
|
114
|
+
* so the parent can correlate the gesture with a tile if needed.
|
|
115
|
+
*/
|
|
116
|
+
itemId?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Whether the handle should track vertical movement. When false,
|
|
119
|
+
* the handle still appears but only emits horizontal deltas, and
|
|
120
|
+
* the cursor is constrained to the column resize axis.
|
|
121
|
+
*
|
|
122
|
+
* @default true
|
|
123
|
+
*/
|
|
124
|
+
verticalResizable?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Callback fired while the handle is being dragged. Receives the
|
|
127
|
+
* cursor offset from the gesture start in pixels.
|
|
128
|
+
*/
|
|
129
|
+
onResize?: (delta: ResizeDelta) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Callback fired when the gesture ends.
|
|
132
|
+
*/
|
|
133
|
+
onResizeEnd?: () => void;
|
|
134
|
+
/**
|
|
135
|
+
* Component that overrides the default corner triangle with a
|
|
136
|
+
* custom element. Receives gesture wiring (`ref`, `listeners`,
|
|
137
|
+
* `attributes`) plus context. The surface keeps ownership of the
|
|
138
|
+
* `<DndContext>` and the throttled delta loop; consumers are only
|
|
139
|
+
* responsible for the visual.
|
|
140
|
+
*/
|
|
141
|
+
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
142
|
+
}
|
|
143
|
+
export {};
|
|
144
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,KAAK,iBAAiB,GAAG,UAAU,CAAE,OAAO,YAAY,CAAE,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,GAAG,EAAE,iBAAiB,CAAE,YAAY,CAAE,CAAC;IAEvC;;OAEG;IACH,SAAS,EAAE,iBAAiB,CAAE,WAAW,CAAE,CAAC;IAE5C;;OAEG;IACH,UAAU,EAAE,iBAAiB,CAAE,YAAY,CAAE,CAAC;IAE9C;;;OAGG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAE,KAAK,EAAE,WAAW,KAAM,IAAI,CAAC;IAE1C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,uBAAuB,CAAE,CAAC;CACpE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ItemExitOverlayRect } from './item-exit-overlay';
|
|
5
|
+
import type { RectSnapshot } from './use-layout-shift-animation';
|
|
6
|
+
export type ExitingGridItem = {
|
|
7
|
+
key: string;
|
|
8
|
+
rect: ItemExitOverlayRect;
|
|
9
|
+
child: React.ReactElement;
|
|
10
|
+
};
|
|
11
|
+
type UseItemExitAnimationOptions = {
|
|
12
|
+
container: HTMLElement | null;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
layoutKeys: ReadonlySet<string>;
|
|
15
|
+
getPositionsBeforeLastChange: () => ReadonlyMap<string, RectSnapshot> | null;
|
|
16
|
+
childrenCacheRef: React.MutableRefObject<Map<string, React.ReactElement>>;
|
|
17
|
+
};
|
|
18
|
+
type UseItemExitAnimationResult = {
|
|
19
|
+
exitingItems: ExitingGridItem[];
|
|
20
|
+
hasExitingItems: boolean;
|
|
21
|
+
clearExitingItem: (key: string) => void;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* When `layout` loses keys in edit mode, keeps a short-lived overlay at
|
|
25
|
+
* the removed tile's last position (scale + fade) while siblings FLIP.
|
|
26
|
+
*
|
|
27
|
+
* @param root0 Hook options.
|
|
28
|
+
* @param root0.container Surface root that contains grid tiles.
|
|
29
|
+
* @param root0.enabled When false, exiting state is cleared.
|
|
30
|
+
* @param root0.layoutKeys Keys in the committed `layout` prop.
|
|
31
|
+
* @param root0.getPositionsBeforeLastChange Container-relative rects before the latest layout commit.
|
|
32
|
+
* @param root0.childrenCacheRef Last rendered children keyed by tile id.
|
|
33
|
+
* @return Exiting overlays and a callback to dismiss one by key.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useItemExitAnimation({ container, enabled, layoutKeys, getPositionsBeforeLastChange, childrenCacheRef }: UseItemExitAnimationOptions): UseItemExitAnimationResult;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=use-item-exit-animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-item-exit-animation.d.ts","sourceRoot":"","sources":["../../src/shared/use-item-exit-animation.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AASjE,MAAM,MAAM,eAAe,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC;CAC1B,CAAC;AAEF,KAAK,2BAA2B,GAAG;IAClC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAE,MAAM,CAAE,CAAC;IAClC,4BAA4B,EAAE,MAAM,WAAW,CAC9C,MAAM,EACN,YAAY,CACZ,GAAG,IAAI,CAAC;IACT,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,CACvC,GAAG,CAAE,MAAM,EAAE,KAAK,CAAC,YAAY,CAAE,CACjC,CAAC;CACF,CAAC;AAEF,KAAK,0BAA0B,GAAG;IACjC,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,CAAE,GAAG,EAAE,MAAM,KAAM,IAAI,CAAC;CAC1C,CAAC;AASF;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAE,EACrC,SAAS,EACT,OAAO,EACP,UAAU,EACV,4BAA4B,EAC5B,gBAAgB,EAChB,EAAE,2BAA2B,GAAI,0BAA0B,CA6H3D"}
|