@wordpress/grid 0.6.0 → 0.7.1-next.v.202608281122.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 +14 -0
- package/README.md +44 -1
- package/build/dashboard-grid/grid-item.cjs +21 -7
- package/build/dashboard-grid/grid-item.cjs.map +2 -2
- package/build/dashboard-grid/index.cjs +107 -45
- package/build/dashboard-grid/index.cjs.map +2 -2
- package/build/dashboard-grid/resolve-fill-widths.cjs +68 -50
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +2 -2
- package/build/dashboard-grid/types.cjs.map +1 -1
- package/build/dashboard-lanes/index.cjs +59 -17
- package/build/dashboard-lanes/index.cjs.map +2 -2
- package/build/dashboard-lanes/lanes-item.cjs +14 -6
- package/build/dashboard-lanes/lanes-item.cjs.map +2 -2
- package/build/dashboard-lanes/types.cjs.map +1 -1
- package/build/index.cjs.map +1 -1
- package/build/shared/array-move-with-pinned.cjs +49 -0
- package/build/shared/array-move-with-pinned.cjs.map +7 -0
- package/build/shared/resize-snap.cjs +91 -5
- package/build/shared/resize-snap.cjs.map +2 -2
- package/build/shared/types.cjs.map +1 -1
- package/build/shared/use-span-bounds.cjs +85 -0
- package/build/shared/use-span-bounds.cjs.map +7 -0
- package/build-module/dashboard-grid/grid-item.mjs +21 -7
- package/build-module/dashboard-grid/grid-item.mjs.map +2 -2
- package/build-module/dashboard-grid/index.mjs +108 -47
- package/build-module/dashboard-grid/index.mjs.map +2 -2
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +68 -50
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +2 -2
- package/build-module/dashboard-lanes/index.mjs +60 -19
- package/build-module/dashboard-lanes/index.mjs.map +2 -2
- package/build-module/dashboard-lanes/lanes-item.mjs +14 -6
- package/build-module/dashboard-lanes/lanes-item.mjs.map +2 -2
- package/build-module/index.mjs.map +1 -1
- package/build-module/shared/array-move-with-pinned.mjs +24 -0
- package/build-module/shared/array-move-with-pinned.mjs.map +7 -0
- package/build-module/shared/resize-snap.mjs +87 -4
- package/build-module/shared/resize-snap.mjs.map +2 -2
- package/build-module/shared/use-span-bounds.mjs +62 -0
- package/build-module/shared/use-span-bounds.mjs.map +7 -0
- package/build-types/dashboard-grid/grid-item.d.ts +1 -1
- package/build-types/dashboard-grid/grid-item.d.ts.map +1 -1
- package/build-types/dashboard-grid/index.d.ts.map +1 -1
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts +12 -1
- package/build-types/dashboard-grid/resolve-fill-widths.d.ts.map +1 -1
- package/build-types/dashboard-grid/types.d.ts +43 -1
- package/build-types/dashboard-grid/types.d.ts.map +1 -1
- package/build-types/dashboard-lanes/index.d.ts.map +1 -1
- package/build-types/dashboard-lanes/lanes-item.d.ts +18 -1
- package/build-types/dashboard-lanes/lanes-item.d.ts.map +1 -1
- package/build-types/dashboard-lanes/types.d.ts +20 -1
- package/build-types/dashboard-lanes/types.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/shared/array-move-with-pinned.d.ts +13 -0
- package/build-types/shared/array-move-with-pinned.d.ts.map +1 -0
- package/build-types/shared/resize-snap.d.ts +65 -2
- package/build-types/shared/resize-snap.d.ts.map +1 -1
- package/build-types/shared/types.d.ts +31 -0
- package/build-types/shared/types.d.ts.map +1 -1
- package/build-types/shared/use-span-bounds.d.ts +29 -0
- package/build-types/shared/use-span-bounds.d.ts.map +1 -0
- package/package.json +7 -8
- package/src/dashboard-grid/grid-item.tsx +21 -7
- package/src/dashboard-grid/index.tsx +154 -57
- package/src/dashboard-grid/resolve-fill-widths.ts +85 -62
- package/src/dashboard-grid/stories/index.story.tsx +154 -0
- package/src/dashboard-grid/test/item-interactions.test.tsx +63 -0
- package/src/dashboard-grid/test/item-limits.test.tsx +147 -0
- package/src/dashboard-grid/test/resolve-fill-widths.test.ts +158 -0
- package/src/dashboard-grid/types.ts +50 -0
- package/src/dashboard-lanes/index.tsx +86 -24
- package/src/dashboard-lanes/lanes-item.tsx +34 -6
- package/src/dashboard-lanes/stories/index.story.tsx +119 -0
- package/src/dashboard-lanes/test/item-interactions.test.tsx +63 -0
- package/src/dashboard-lanes/test/item-limits.test.tsx +140 -0
- package/src/dashboard-lanes/types.ts +23 -0
- package/src/index.ts +2 -0
- package/src/shared/array-move-with-pinned.ts +36 -0
- package/src/shared/resize-snap.ts +161 -5
- package/src/shared/test/array-move-with-pinned.test.ts +39 -0
- package/src/shared/test/resize-snap.test.ts +170 -2
- package/src/shared/test/use-span-bounds.test.ts +104 -0
- package/src/shared/types.ts +35 -0
- package/src/shared/use-span-bounds.ts +99 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DragPreviewRenderProps, GridOverlayRenderProps, ResizeHandleRenderProps } from '../shared/types';
|
|
1
|
+
import type { DragPreviewRenderProps, GridItemWidthLimits, GridOverlayRenderProps, ResizeHandleRenderProps } from '../shared/types';
|
|
2
2
|
/**
|
|
3
3
|
* Lanes layout item definition.
|
|
4
4
|
*
|
|
@@ -27,6 +27,20 @@ export type DashboardLanesLayoutItem = {
|
|
|
27
27
|
* clamped to the available range.
|
|
28
28
|
*/
|
|
29
29
|
lane?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the item can be dragged while the surface is in edit mode.
|
|
32
|
+
* When `false`, the item is pinned: it also holds its index while the
|
|
33
|
+
* other items reorder around it.
|
|
34
|
+
*
|
|
35
|
+
* @default true
|
|
36
|
+
*/
|
|
37
|
+
draggable?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the item can be resized while the surface is in edit mode.
|
|
40
|
+
*
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
resizable?: boolean;
|
|
30
44
|
/**
|
|
31
45
|
* Display order. Lower values render first. When omitted, the
|
|
32
46
|
* item falls back to its index in the `layout` array.
|
|
@@ -144,5 +158,10 @@ export interface DashboardLanesProps extends Omit<React.ComponentPropsWithoutRef
|
|
|
144
158
|
* down to 1.
|
|
145
159
|
*/
|
|
146
160
|
minColumnWidth?: number;
|
|
161
|
+
/**
|
|
162
|
+
* Per-item width limits in pixels, keyed by layout item key. Lane
|
|
163
|
+
* heights are content-driven, so there is no height axis.
|
|
164
|
+
*/
|
|
165
|
+
itemLimits?: Record<string, GridItemWidthLimits>;
|
|
147
166
|
}
|
|
148
167
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/types.ts"],"names":[],"mappings":"AAAA,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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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;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAE,MAAM,EAAE,mBAAmB,CAAE,CAAC;CACnD"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { DashboardGrid } from './dashboard-grid';
|
|
|
2
2
|
export { DashboardLanes } from './dashboard-lanes';
|
|
3
3
|
export type { DashboardGridLayoutItem, DashboardGridProps, } from './dashboard-grid/types';
|
|
4
4
|
export type { DashboardLanesLayoutItem, DashboardLanesProps, } from './dashboard-lanes/types';
|
|
5
|
-
export type { DragPreviewRenderProps, GridOverlayRenderProps, ResizeDelta, ResizeHandleRenderProps, } from './shared/types';
|
|
5
|
+
export type { DragPreviewRenderProps, GridItemLimits, GridItemWidthLimits, GridOverlayRenderProps, ResizeDelta, ResizeHandleRenderProps, } from './shared/types';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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"}
|
|
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,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,EACX,uBAAuB,GACvB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves the item at `from` to `to` while pinned items hold their index:
|
|
3
|
+
* the free items reorder among the remaining slots. Moving a pinned item
|
|
4
|
+
* is a no-op.
|
|
5
|
+
*
|
|
6
|
+
* @param items Items in display order.
|
|
7
|
+
* @param from Index of the moved item.
|
|
8
|
+
* @param to Target index.
|
|
9
|
+
* @param isPinned Whether an item holds its index.
|
|
10
|
+
* @return The reordered items.
|
|
11
|
+
*/
|
|
12
|
+
export declare function arrayMoveWithPinned<T>(items: T[], from: number, to: number, isPinned: (item: T) => boolean): T[];
|
|
13
|
+
//# sourceMappingURL=array-move-with-pinned.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-move-with-pinned.d.ts","sourceRoot":"","sources":["../../src/shared/array-move-with-pinned.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAE,CAAC,EACrC,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAE,IAAI,EAAE,CAAC,KAAM,OAAO,GAC9B,CAAC,EAAE,CAiBL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResizeDelta } from './types';
|
|
1
|
+
import type { GridItemLimits, ResizeDelta } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Pixel dimensions for the snapped resize preview outline.
|
|
4
4
|
*/
|
|
@@ -9,7 +9,7 @@ export type ResizeSnapSize = {
|
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
11
|
* Clamps a resize delta so the tile cannot shrink below the given
|
|
12
|
-
* minimum
|
|
12
|
+
* minimum size, nor grow past the given maximum when one applies.
|
|
13
13
|
*
|
|
14
14
|
* @param delta Cursor offset from the gesture start in pixels.
|
|
15
15
|
* @param initialSize Size captured at gesture start.
|
|
@@ -18,6 +18,9 @@ export type ResizeSnapSize = {
|
|
|
18
18
|
* @param minSize Minimum tile size in pixels.
|
|
19
19
|
* @param minSize.width Minimum width in pixels.
|
|
20
20
|
* @param minSize.height Minimum height in pixels, when vertical resize applies.
|
|
21
|
+
* @param maxSize Maximum tile size in pixels, when one applies.
|
|
22
|
+
* @param maxSize.width Maximum width in pixels.
|
|
23
|
+
* @param maxSize.height Maximum height in pixels, when vertical resize applies.
|
|
21
24
|
*/
|
|
22
25
|
export declare function clampResizeDelta(delta: ResizeDelta, initialSize: {
|
|
23
26
|
width: number;
|
|
@@ -25,6 +28,9 @@ export declare function clampResizeDelta(delta: ResizeDelta, initialSize: {
|
|
|
25
28
|
}, minSize: {
|
|
26
29
|
width: number;
|
|
27
30
|
height?: number;
|
|
31
|
+
}, maxSize?: {
|
|
32
|
+
width?: number;
|
|
33
|
+
height?: number;
|
|
28
34
|
}): ResizeDelta;
|
|
29
35
|
/**
|
|
30
36
|
* Converts grid spans to pixel width/height for the resize-preview
|
|
@@ -38,4 +44,61 @@ export declare function clampResizeDelta(delta: ResizeDelta, initialSize: {
|
|
|
38
44
|
* are content-sized.
|
|
39
45
|
*/
|
|
40
46
|
export declare function gridSpanToPixelSize(columnSpan: number, rowSpan: number, columnWidth: number, gapPx: number, rowHeightPx: number | null): ResizeSnapSize;
|
|
47
|
+
/**
|
|
48
|
+
* Span bounds derived from per-item pixel limits, in whole tracks.
|
|
49
|
+
* Maximums are concrete: an undeclared width maximum resolves to the
|
|
50
|
+
* column count, an undeclared or inapplicable height maximum to
|
|
51
|
+
* `Infinity`.
|
|
52
|
+
*/
|
|
53
|
+
export type SpanBounds = {
|
|
54
|
+
minWidth: number;
|
|
55
|
+
minHeight: number;
|
|
56
|
+
maxWidth: number;
|
|
57
|
+
maxHeight: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Converts per-item pixel limits to span bounds with the track math of
|
|
61
|
+
* `gridSpanToPixelSize`. Minimums round up, maximums round down, every
|
|
62
|
+
* bound stays at one track or more, and a minimum wins over a smaller
|
|
63
|
+
* maximum. Width bounds saturate at the column count; height bounds
|
|
64
|
+
* resolve to `1`/`Infinity` when rows are content-sized.
|
|
65
|
+
*
|
|
66
|
+
* @param limits Size limits in pixels.
|
|
67
|
+
* @param columnWidth Width of one column track in pixels.
|
|
68
|
+
* @param gapPx Gap between tracks in pixels.
|
|
69
|
+
* @param rowHeightPx Row track height in pixels, or `null` when rows
|
|
70
|
+
* are content-sized.
|
|
71
|
+
* @param maxColumns Number of column tracks in the surface.
|
|
72
|
+
*/
|
|
73
|
+
export declare function pixelLimitsToSpanBounds(limits: GridItemLimits, columnWidth: number, gapPx: number, rowHeightPx: number | null, maxColumns: number): SpanBounds;
|
|
74
|
+
/**
|
|
75
|
+
* Clamps a span to the inclusive `[ min, max ]` range.
|
|
76
|
+
*
|
|
77
|
+
* @param span Span in tracks.
|
|
78
|
+
* @param min Lowest allowed span.
|
|
79
|
+
* @param max Highest allowed span.
|
|
80
|
+
*/
|
|
81
|
+
export declare function clampSpan(span: number, min: number, max: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Pixel limits for the resize gesture, derived from span bounds.
|
|
84
|
+
* Heights are `null` when rows are content-sized or the height
|
|
85
|
+
* bound is open.
|
|
86
|
+
*/
|
|
87
|
+
export type ResizePixelLimits = {
|
|
88
|
+
minWidthPx: number;
|
|
89
|
+
minHeightPx: number | null;
|
|
90
|
+
maxWidthPx: number;
|
|
91
|
+
maxHeightPx: number | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Converts span bounds back to pixel limits for the resize gesture,
|
|
95
|
+
* using the same track math as `gridSpanToPixelSize`.
|
|
96
|
+
*
|
|
97
|
+
* @param bounds Span bounds in whole tracks.
|
|
98
|
+
* @param columnWidth Width of one column track in pixels.
|
|
99
|
+
* @param gapPx Gap between tracks in pixels.
|
|
100
|
+
* @param rowHeightPx Row track height in pixels, or `null` when rows
|
|
101
|
+
* are content-sized.
|
|
102
|
+
*/
|
|
103
|
+
export declare function spanBoundsToPixelLimits(bounds: SpanBounds, columnWidth: number, gapPx: number, rowHeightPx: number | null): ResizePixelLimits;
|
|
41
104
|
//# sourceMappingURL=resize-snap.d.ts.map
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"resize-snap.d.ts","sourceRoot":"","sources":["../../src/shared/resize-snap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;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,EAC3C,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,WAAW,CAeb;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;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,cAAc,EACtB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,UAAU,EAAE,MAAM,GAChB,UAAU,CAiDZ;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAI,MAAM,CAE1E;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,GACxB,iBAAiB,CAsBnB"}
|
|
@@ -137,5 +137,36 @@ export interface ResizeHandleProps {
|
|
|
137
137
|
*/
|
|
138
138
|
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
139
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Per-item width limits, in pixels. Surfaces quantize each limit to
|
|
142
|
+
* whole tracks (minimums round up, maximums round down), bound rendered
|
|
143
|
+
* spans and resize gestures at the result, and never write it into the
|
|
144
|
+
* layout. A quantized minimum wins over a smaller quantized maximum.
|
|
145
|
+
*/
|
|
146
|
+
export type GridItemWidthLimits = {
|
|
147
|
+
/**
|
|
148
|
+
* Minimum tile width in pixels.
|
|
149
|
+
*/
|
|
150
|
+
minWidth?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Maximum tile width in pixels.
|
|
153
|
+
*/
|
|
154
|
+
maxWidth?: number;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Per-item size limits on both axes, in pixels, for surfaces with row
|
|
158
|
+
* tracks. Height limits quantize against the row track when `rowHeight`
|
|
159
|
+
* is numeric and stay open otherwise.
|
|
160
|
+
*/
|
|
161
|
+
export type GridItemLimits = GridItemWidthLimits & {
|
|
162
|
+
/**
|
|
163
|
+
* Minimum tile height in pixels.
|
|
164
|
+
*/
|
|
165
|
+
minHeight?: number;
|
|
166
|
+
/**
|
|
167
|
+
* Maximum tile height in pixels.
|
|
168
|
+
*/
|
|
169
|
+
maxHeight?: number;
|
|
170
|
+
};
|
|
140
171
|
export {};
|
|
141
172
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":"AAAA,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,CAA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}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ResizePixelLimits, SpanBounds } from './resize-snap';
|
|
2
|
+
import type { GridItemLimits } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Quantizes per-item pixel limits to span bounds for the current
|
|
5
|
+
* geometry. The map keeps its identity while every bound is unchanged,
|
|
6
|
+
* so container width ticks and fresh `itemLimits` objects do not
|
|
7
|
+
* invalidate the layout memos or the sortable context downstream.
|
|
8
|
+
*
|
|
9
|
+
* @param itemLimits Per-item pixel limits, keyed by layout item key.
|
|
10
|
+
* @param columnWidth Width of one column track in pixels.
|
|
11
|
+
* @param gapPx Gap between tracks in pixels.
|
|
12
|
+
* @param rowHeightPx Row track height in pixels, or `null` when rows
|
|
13
|
+
* are content-sized.
|
|
14
|
+
* @param maxColumns Number of column tracks in the surface.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useSpanBounds(itemLimits: Record<string, GridItemLimits> | undefined, columnWidth: number, gapPx: number, rowHeightPx: number | null, maxColumns: number): ReadonlyMap<string, SpanBounds>;
|
|
17
|
+
/**
|
|
18
|
+
* Pixel limits for the resize gesture of every bounded item. Tracks
|
|
19
|
+
* the continuous geometry, but only recomputes when it changes, not on
|
|
20
|
+
* every gesture frame.
|
|
21
|
+
*
|
|
22
|
+
* @param spanBounds Span bounds per item key.
|
|
23
|
+
* @param columnWidth Width of one column track in pixels.
|
|
24
|
+
* @param gapPx Gap between tracks in pixels.
|
|
25
|
+
* @param rowHeightPx Row track height in pixels, or `null` when rows
|
|
26
|
+
* are content-sized.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useResizePixelLimits(spanBounds: ReadonlyMap<string, SpanBounds>, columnWidth: number, gapPx: number, rowHeightPx: number | null): ReadonlyMap<string, ResizePixelLimits>;
|
|
29
|
+
//# sourceMappingURL=use-span-bounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-span-bounds.d.ts","sourceRoot":"","sources":["../../src/shared/use-span-bounds.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAK9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC5B,UAAU,EAAE,MAAM,CAAE,MAAM,EAAE,cAAc,CAAE,GAAG,SAAS,EACxD,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,UAAU,EAAE,MAAM,GAChB,WAAW,CAAE,MAAM,EAAE,UAAU,CAAE,CA+BnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CACnC,UAAU,EAAE,WAAW,CAAE,MAAM,EAAE,UAAU,CAAE,EAC7C,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,IAAI,GACxB,WAAW,CAAE,MAAM,EAAE,iBAAiB,CAAE,CAmB1C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1-next.v.202608281122.0",
|
|
4
4
|
"description": "Grid layout components for arranging tiles in dashboard-style surfaces, with drag-to-reorder and tile resizing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -48,10 +48,9 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@dnd-kit/core": "^6.3.1",
|
|
50
50
|
"@dnd-kit/sortable": "^10.0.0",
|
|
51
|
-
"@
|
|
52
|
-
"@wordpress/
|
|
53
|
-
"@wordpress/
|
|
54
|
-
"@wordpress/style-runtime": "^0.10.0",
|
|
51
|
+
"@wordpress/compose": "^8.7.2-next.v.202608281122.0",
|
|
52
|
+
"@wordpress/element": "^8.6.2-next.v.202608281122.0",
|
|
53
|
+
"@wordpress/style-runtime": "^0.10.1-next.v.202608281122.0",
|
|
55
54
|
"clsx": "^2.1.1"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
@@ -60,8 +59,8 @@
|
|
|
60
59
|
"@testing-library/jest-dom": "^6.9.1",
|
|
61
60
|
"@testing-library/react": "^16.3.2",
|
|
62
61
|
"@types/jest": "^30.0.0",
|
|
63
|
-
"@wordpress/icons": "^15.5.0",
|
|
64
|
-
"@wordpress/ui": "^0.
|
|
62
|
+
"@wordpress/icons": "^15.5.1-next.v.202608281122.0",
|
|
63
|
+
"@wordpress/ui": "^0.22.1-next.v.202608281122.0",
|
|
65
64
|
"storybook": "^10.5.3"
|
|
66
65
|
},
|
|
67
66
|
"peerDependencies": {
|
|
@@ -77,5 +76,5 @@
|
|
|
77
76
|
"publishConfig": {
|
|
78
77
|
"access": "public"
|
|
79
78
|
},
|
|
80
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "de479d415171765f7b573c81aeec5334ff506a12"
|
|
81
80
|
}
|
|
@@ -29,6 +29,8 @@ export function GridItem( {
|
|
|
29
29
|
item,
|
|
30
30
|
maxColumns,
|
|
31
31
|
disabled = false,
|
|
32
|
+
draggable = true,
|
|
33
|
+
resizable = true,
|
|
32
34
|
verticalResizable = true,
|
|
33
35
|
interacting = false,
|
|
34
36
|
dragging = false,
|
|
@@ -39,6 +41,8 @@ export function GridItem( {
|
|
|
39
41
|
resizeSnapPreview = null,
|
|
40
42
|
minResizeWidthPx,
|
|
41
43
|
minResizeHeightPx,
|
|
44
|
+
maxResizeWidthPx,
|
|
45
|
+
maxResizeHeightPx,
|
|
42
46
|
renderResizeHandle,
|
|
43
47
|
}: GridItemProps ) {
|
|
44
48
|
const [ resizeDelta, setResizeDelta ] = useState< ResizeDelta | null >(
|
|
@@ -50,6 +54,8 @@ export function GridItem( {
|
|
|
50
54
|
} | null >( null );
|
|
51
55
|
const itemRef = useRef< HTMLDivElement >( null );
|
|
52
56
|
const contentRef = useRef< HTMLDivElement >( null );
|
|
57
|
+
const dragDisabled = disabled || ! draggable;
|
|
58
|
+
const resizeDisabled = disabled || ! resizable;
|
|
53
59
|
const {
|
|
54
60
|
attributes,
|
|
55
61
|
listeners,
|
|
@@ -58,7 +64,7 @@ export function GridItem( {
|
|
|
58
64
|
isDragging,
|
|
59
65
|
} = useSortable( {
|
|
60
66
|
id: item.key,
|
|
61
|
-
disabled,
|
|
67
|
+
disabled: dragDisabled,
|
|
62
68
|
} );
|
|
63
69
|
const mergedRef = useMergeRefs( [ itemRef, setNodeRef ] );
|
|
64
70
|
const contentMergedRef = useMergeRefs( [ contentRef ] );
|
|
@@ -100,10 +106,18 @@ export function GridItem( {
|
|
|
100
106
|
height: verticalResizable ? delta.height : 0,
|
|
101
107
|
};
|
|
102
108
|
if ( baselineSize ) {
|
|
103
|
-
clamped = clampResizeDelta(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
clamped = clampResizeDelta(
|
|
110
|
+
clamped,
|
|
111
|
+
baselineSize,
|
|
112
|
+
{
|
|
113
|
+
width: minResizeWidthPx,
|
|
114
|
+
height: verticalResizable ? minResizeHeightPx : undefined,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
width: maxResizeWidthPx,
|
|
118
|
+
height: verticalResizable ? maxResizeHeightPx : undefined,
|
|
119
|
+
}
|
|
120
|
+
);
|
|
107
121
|
}
|
|
108
122
|
setResizeDelta( clamped );
|
|
109
123
|
onResize( item.key, clamped );
|
|
@@ -156,7 +170,7 @@ export function GridItem( {
|
|
|
156
170
|
{ ...listeners }
|
|
157
171
|
style={ {
|
|
158
172
|
height: '100%',
|
|
159
|
-
cursor: getItemCursor(
|
|
173
|
+
cursor: getItemCursor( dragDisabled, interacting ),
|
|
160
174
|
} }
|
|
161
175
|
>
|
|
162
176
|
<div
|
|
@@ -165,7 +179,7 @@ export function GridItem( {
|
|
|
165
179
|
style={ continuousContentStyle }
|
|
166
180
|
>
|
|
167
181
|
{ children }
|
|
168
|
-
{ !
|
|
182
|
+
{ ! resizeDisabled && (
|
|
169
183
|
<ResizeHandle
|
|
170
184
|
itemId={ item.key }
|
|
171
185
|
verticalResizable={ verticalResizable }
|