@wordpress/grid 0.5.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 +22 -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 +110 -48
- 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 +62 -20
- 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 +111 -50
- 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 +63 -22
- 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 +10 -10
- package/src/dashboard-grid/grid-item.tsx +21 -7
- package/src/dashboard-grid/grid.module.css +6 -6
- package/src/dashboard-grid/index.tsx +155 -58
- package/src/dashboard-grid/resolve-fill-widths.ts +85 -62
- package/src/dashboard-grid/stories/index.story.tsx +169 -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 +87 -25
- package/src/dashboard-lanes/lanes-item.tsx +34 -6
- package/src/dashboard-lanes/lanes.module.css +6 -6
- package/src/dashboard-lanes/stories/index.story.tsx +144 -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/test/use-lane-placement.test.tsx +10 -3
- 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
- package/build-types/dashboard-grid/stories/index.story.d.ts +0 -92
- package/build-types/dashboard-grid/stories/index.story.d.ts.map +0 -1
- package/build-types/dashboard-lanes/stories/index.story.d.ts +0 -58
- package/build-types/dashboard-lanes/stories/index.story.d.ts.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// packages/grid/src/dashboard-grid/resolve-fill-widths.ts
|
|
2
|
-
function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
2
|
+
function resolveFillWidths(sortedKeys, layoutMap, maxColumns, itemBounds) {
|
|
3
3
|
const resolved = /* @__PURE__ */ new Map();
|
|
4
4
|
const n = sortedKeys.length;
|
|
5
5
|
const items = new Array(n);
|
|
6
|
+
const kinds = new Array(n);
|
|
6
7
|
const widths = new Array(n);
|
|
7
8
|
const heights = new Array(n);
|
|
8
9
|
let hasFill = false;
|
|
@@ -11,12 +12,26 @@ function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
|
11
12
|
for (let i = 0; i < n; i++) {
|
|
12
13
|
const item = layoutMap.get(sortedKeys[i]);
|
|
13
14
|
items[i] = item;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (item
|
|
15
|
+
if (!item) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (item.width === "fill") {
|
|
19
|
+
kinds[i] = "fill";
|
|
20
|
+
widths[i] = 1;
|
|
18
21
|
hasFill = true;
|
|
22
|
+
} else if (item.width === "full") {
|
|
23
|
+
const cap = Math.min(
|
|
24
|
+
itemBounds?.get(item.key)?.maxWidth ?? maxColumns,
|
|
25
|
+
maxColumns
|
|
26
|
+
);
|
|
27
|
+
kinds[i] = cap < maxColumns ? "fixed" : "full";
|
|
28
|
+
widths[i] = cap;
|
|
29
|
+
} else {
|
|
30
|
+
kinds[i] = "fixed";
|
|
31
|
+
widths[i] = typeof item.width === "number" ? Math.min(item.width, maxColumns) : 1;
|
|
19
32
|
}
|
|
33
|
+
const h = Math.max(1, Math.floor(item.height ?? 1));
|
|
34
|
+
heights[i] = h;
|
|
20
35
|
if (h > 1) {
|
|
21
36
|
hasMultiRow = true;
|
|
22
37
|
}
|
|
@@ -32,27 +47,32 @@ function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
|
32
47
|
if (!item) {
|
|
33
48
|
continue;
|
|
34
49
|
}
|
|
35
|
-
if (
|
|
50
|
+
if (kinds[i] === "full") {
|
|
36
51
|
currentCol = 0;
|
|
37
52
|
continue;
|
|
38
53
|
}
|
|
39
|
-
if (
|
|
54
|
+
if (kinds[i] === "fill") {
|
|
55
|
+
const bounds = itemBounds?.get(item.key);
|
|
56
|
+
const minW = Math.min(bounds?.minWidth ?? 1, maxColumns);
|
|
57
|
+
const maxW = bounds?.maxWidth ?? maxColumns;
|
|
58
|
+
if (currentCol + minW > maxColumns) {
|
|
59
|
+
currentCol = 0;
|
|
60
|
+
}
|
|
40
61
|
let reserved = 0;
|
|
41
62
|
for (let j = i + 1; j < n; j++) {
|
|
42
|
-
|
|
43
|
-
if (!next || next.width === "full" || next.width === "fill") {
|
|
63
|
+
if (kinds[j] !== "fixed") {
|
|
44
64
|
break;
|
|
45
65
|
}
|
|
46
66
|
const nextW = widths[j];
|
|
47
|
-
if (currentCol +
|
|
67
|
+
if (currentCol + minW + reserved + nextW <= maxColumns) {
|
|
48
68
|
reserved += nextW;
|
|
49
69
|
} else {
|
|
50
70
|
break;
|
|
51
71
|
}
|
|
52
72
|
}
|
|
53
|
-
const fillCols = Math.
|
|
54
|
-
|
|
55
|
-
|
|
73
|
+
const fillCols = Math.min(
|
|
74
|
+
Math.max(minW, maxColumns - currentCol - reserved),
|
|
75
|
+
maxW
|
|
56
76
|
);
|
|
57
77
|
resolved.set(item.key, fillCols);
|
|
58
78
|
currentCol += fillCols;
|
|
@@ -72,13 +92,34 @@ function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
|
72
92
|
const rowOccupancy = new Array(maxColumns).fill(0);
|
|
73
93
|
let cursorRow = 0;
|
|
74
94
|
let cursorCol = 0;
|
|
95
|
+
const findFreeRun = (w) => {
|
|
96
|
+
let r = cursorRow;
|
|
97
|
+
let c = cursorCol;
|
|
98
|
+
place: for (; r <= totalRows; r++) {
|
|
99
|
+
c = r === cursorRow ? cursorCol : 0;
|
|
100
|
+
while (c + w <= maxColumns) {
|
|
101
|
+
let blocked = -1;
|
|
102
|
+
for (let k = 0; k < w; k++) {
|
|
103
|
+
if (rowOccupancy[c + k] > r) {
|
|
104
|
+
blocked = c + k;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (blocked === -1) {
|
|
109
|
+
break place;
|
|
110
|
+
}
|
|
111
|
+
c = blocked + 1;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return [r, c];
|
|
115
|
+
};
|
|
75
116
|
for (let i = 0; i < n; i++) {
|
|
76
117
|
const item = items[i];
|
|
77
118
|
if (!item) {
|
|
78
119
|
continue;
|
|
79
120
|
}
|
|
80
121
|
const h = heights[i];
|
|
81
|
-
if (
|
|
122
|
+
if (kinds[i] === "full") {
|
|
82
123
|
let r2 = cursorRow;
|
|
83
124
|
for (let c2 = 0; c2 < maxColumns; c2++) {
|
|
84
125
|
if (rowOccupancy[c2] > r2) {
|
|
@@ -92,37 +133,31 @@ function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
|
92
133
|
cursorCol = 0;
|
|
93
134
|
continue;
|
|
94
135
|
}
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (rowOccupancy[c2] <= r2) {
|
|
102
|
-
break scan;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const fillStartRow = r2;
|
|
107
|
-
const fillStartCol = c2;
|
|
108
|
-
let runLength = 0;
|
|
136
|
+
if (kinds[i] === "fill") {
|
|
137
|
+
const bounds = itemBounds?.get(item.key);
|
|
138
|
+
const minW = Math.min(bounds?.minWidth ?? 1, maxColumns);
|
|
139
|
+
const maxW = bounds?.maxWidth ?? maxColumns;
|
|
140
|
+
const [fillStartRow, fillStartCol] = findFreeRun(minW);
|
|
141
|
+
let runLength = minW;
|
|
109
142
|
while (fillStartCol + runLength < maxColumns && rowOccupancy[fillStartCol + runLength] <= fillStartRow) {
|
|
110
143
|
runLength++;
|
|
111
144
|
}
|
|
112
145
|
let reserved = 0;
|
|
113
146
|
for (let j = i + 1; j < n; j++) {
|
|
114
|
-
|
|
115
|
-
if (!next || next.width === "full" || next.width === "fill") {
|
|
147
|
+
if (kinds[j] !== "fixed") {
|
|
116
148
|
break;
|
|
117
149
|
}
|
|
118
150
|
const nextW = widths[j];
|
|
119
|
-
if (
|
|
151
|
+
if (minW + reserved + nextW <= runLength) {
|
|
120
152
|
reserved += nextW;
|
|
121
153
|
} else {
|
|
122
154
|
break;
|
|
123
155
|
}
|
|
124
156
|
}
|
|
125
|
-
const fillCols = Math.
|
|
157
|
+
const fillCols = Math.min(
|
|
158
|
+
Math.max(minW, runLength - reserved),
|
|
159
|
+
maxW
|
|
160
|
+
);
|
|
126
161
|
resolved.set(item.key, fillCols);
|
|
127
162
|
for (let k = 0; k < fillCols; k++) {
|
|
128
163
|
rowOccupancy[fillStartCol + k] = fillStartRow + h;
|
|
@@ -132,24 +167,7 @@ function resolveFillWidths(sortedKeys, layoutMap, maxColumns) {
|
|
|
132
167
|
continue;
|
|
133
168
|
}
|
|
134
169
|
const w = widths[i];
|
|
135
|
-
|
|
136
|
-
let c = cursorCol;
|
|
137
|
-
place: for (; r <= totalRows; r++) {
|
|
138
|
-
c = r === cursorRow ? cursorCol : 0;
|
|
139
|
-
while (c + w <= maxColumns) {
|
|
140
|
-
let blocked = -1;
|
|
141
|
-
for (let k = 0; k < w; k++) {
|
|
142
|
-
if (rowOccupancy[c + k] > r) {
|
|
143
|
-
blocked = c + k;
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
if (blocked === -1) {
|
|
148
|
-
break place;
|
|
149
|
-
}
|
|
150
|
-
c = blocked + 1;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
170
|
+
const [r, c] = findFreeRun(w);
|
|
153
171
|
for (let k = 0; k < w; k++) {
|
|
154
172
|
rowOccupancy[c + k] = r + h;
|
|
155
173
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/dashboard-grid/resolve-fill-widths.ts"],
|
|
4
|
-
"sourcesContent": ["import type { DashboardGridLayoutItem } from './types';\n\n/**\n * Resolves items with `width: 'fill'` by computing how many columns they\n * should span. Simulates CSS Grid's row-sparse auto-flow placement so the\n * resolved span matches the free run that CSS Grid will actually use.\n *\n * Two paths:\n * - Fast path (no `height > 1` items): single-row column tracker, O(n).\n * Each fixed item between two fills is visited at most once by a fill's\n * look-ahead.\n * - Multi-row path (any item with `height > 1`): per-column skyline that\n * tracks shadow occupation of tall tiles. Placement scans rows in\n * row-major order, so worst-case cost depends on both columns and rows\n * scanned (rows bounded by the sum of item heights), not only on\n * `maxColumns`.\n *\n * @param sortedKeys - Item keys in display order.\n * @param layoutMap - Map of key to DashboardGridLayoutItem.\n * @param maxColumns - Total columns in the grid.\n * @return Map of fill item keys to their resolved column spans.\n */\nexport function resolveFillWidths(\n\tsortedKeys: string[],\n\tlayoutMap: Map< string, DashboardGridLayoutItem >,\n\tmaxColumns: number\n): Map< string, number > {\n\tconst resolved = new Map< string, number >();\n\tconst n = sortedKeys.length;\n\n\t// Pre-extract items, clamp widths and heights, detect which path to take.\n\tconst items = new Array< DashboardGridLayoutItem | undefined >( n );\n\tconst widths = new Array< number >( n );\n\tconst heights = new Array< number >( n );\n\tlet hasFill = false;\n\tlet hasMultiRow = false;\n\tlet totalRows = 0;\n\n\tfor ( let i = 0; i < n; i++ ) {\n\t\tconst item = layoutMap.get( sortedKeys[ i ] );\n\t\titems[ i ] = item;\n\t\twidths[ i ]
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import type { DashboardGridLayoutItem } from './types';\n\n/**\n * Resolves items with `width: 'fill'` by computing how many columns they\n * should span. Simulates CSS Grid's row-sparse auto-flow placement so the\n * resolved span matches the free run that CSS Grid will actually use.\n *\n * Two paths:\n * - Fast path (no `height > 1` items): single-row column tracker, O(n).\n * Each fixed item between two fills is visited at most once by a fill's\n * look-ahead.\n * - Multi-row path (any item with `height > 1`): per-column skyline that\n * tracks shadow occupation of tall tiles. Placement scans rows in\n * row-major order, so worst-case cost depends on both columns and rows\n * scanned (rows bounded by the sum of item heights), not only on\n * `maxColumns`.\n *\n * Fill items honor per-item span bounds: the row plan reserves at least\n * the fill's minimum span (wrapping it to the next free run when the\n * current one is too narrow), and the resolved span never exceeds its\n * maximum. A `'full'` item capped below the column count places like a\n * fixed item of its capped width. Fixed-width items arrive already\n * bounded by the caller.\n *\n * @param sortedKeys - Item keys in display order.\n * @param layoutMap - Map of key to DashboardGridLayoutItem.\n * @param maxColumns - Total columns in the grid.\n * @param itemBounds - Optional per-key span bounds for fill and full items.\n * @return Map of fill item keys to their resolved column spans.\n */\nexport function resolveFillWidths(\n\tsortedKeys: string[],\n\tlayoutMap: Map< string, DashboardGridLayoutItem >,\n\tmaxColumns: number,\n\titemBounds?: ReadonlyMap< string, { minWidth: number; maxWidth: number } >\n): Map< string, number > {\n\tconst resolved = new Map< string, number >();\n\tconst n = sortedKeys.length;\n\n\t// Pre-extract items, clamp widths and heights, detect which path to take.\n\tconst items = new Array< DashboardGridLayoutItem | undefined >( n );\n\tconst kinds = new Array< 'fixed' | 'fill' | 'full' | undefined >( n );\n\tconst widths = new Array< number >( n );\n\tconst heights = new Array< number >( n );\n\tlet hasFill = false;\n\tlet hasMultiRow = false;\n\tlet totalRows = 0;\n\n\tfor ( let i = 0; i < n; i++ ) {\n\t\tconst item = layoutMap.get( sortedKeys[ i ] );\n\t\titems[ i ] = item;\n\t\tif ( ! item ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( item.width === 'fill' ) {\n\t\t\tkinds[ i ] = 'fill';\n\t\t\twidths[ i ] = 1;\n\t\t\thasFill = true;\n\t\t} else if ( item.width === 'full' ) {\n\t\t\tconst cap = Math.min(\n\t\t\t\titemBounds?.get( item.key )?.maxWidth ?? maxColumns,\n\t\t\t\tmaxColumns\n\t\t\t);\n\t\t\tkinds[ i ] = cap < maxColumns ? 'fixed' : 'full';\n\t\t\twidths[ i ] = cap;\n\t\t} else {\n\t\t\tkinds[ i ] = 'fixed';\n\t\t\twidths[ i ] =\n\t\t\t\ttypeof item.width === 'number'\n\t\t\t\t\t? Math.min( item.width, maxColumns )\n\t\t\t\t\t: 1;\n\t\t}\n\t\t// Clamp to a positive integer so `0`, fractional, or negative\n\t\t// values match the `|| 1` defaulting used in GridItem styles.\n\t\tconst h = Math.max( 1, Math.floor( item.height ?? 1 ) );\n\t\theights[ i ] = h;\n\t\tif ( h > 1 ) {\n\t\t\thasMultiRow = true;\n\t\t}\n\t\ttotalRows += h;\n\t}\n\n\tif ( ! hasFill ) {\n\t\treturn resolved;\n\t}\n\n\tif ( ! hasMultiRow ) {\n\t\tlet currentCol = 0;\n\n\t\tfor ( let i = 0; i < n; i++ ) {\n\t\t\tconst item = items[ i ];\n\t\t\tif ( ! item ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( kinds[ i ] === 'full' ) {\n\t\t\t\tcurrentCol = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( kinds[ i ] === 'fill' ) {\n\t\t\t\tconst bounds = itemBounds?.get( item.key );\n\t\t\t\tconst minW = Math.min( bounds?.minWidth ?? 1, maxColumns );\n\t\t\t\tconst maxW = bounds?.maxWidth ?? maxColumns;\n\t\t\t\t// Wrap first when the row cannot host the fill's floor.\n\t\t\t\tif ( currentCol + minW > maxColumns ) {\n\t\t\t\t\tcurrentCol = 0;\n\t\t\t\t}\n\t\t\t\tlet reserved = 0;\n\t\t\t\tfor ( let j = i + 1; j < n; j++ ) {\n\t\t\t\t\tif ( kinds[ j ] !== 'fixed' ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tconst nextW = widths[ j ];\n\t\t\t\t\tif ( currentCol + minW + reserved + nextW <= maxColumns ) {\n\t\t\t\t\t\treserved += nextW;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst fillCols = Math.min(\n\t\t\t\t\tMath.max( minW, maxColumns - currentCol - reserved ),\n\t\t\t\t\tmaxW\n\t\t\t\t);\n\t\t\t\tresolved.set( item.key, fillCols );\n\t\t\t\tcurrentCol += fillCols;\n\t\t\t} else {\n\t\t\t\tconst w = widths[ i ];\n\t\t\t\tif ( currentCol + w > maxColumns ) {\n\t\t\t\t\tcurrentCol = 0;\n\t\t\t\t}\n\t\t\t\tcurrentCol += w;\n\t\t\t}\n\n\t\t\tif ( currentCol >= maxColumns ) {\n\t\t\t\tcurrentCol = 0;\n\t\t\t}\n\t\t}\n\n\t\treturn resolved;\n\t}\n\n\t// `rowOccupancy[ col ]` is the index of the next free row at that\n\t// column; rows below it are taken by previously placed items. This\n\t// captures the \"shadow\" of tall tiles into the rows they span.\n\tconst rowOccupancy = new Array< number >( maxColumns ).fill( 0 );\n\tlet cursorRow = 0;\n\tlet cursorCol = 0;\n\n\t// First row and column, in row-major order from the cursor, where\n\t// `w` consecutive columns are free.\n\tconst findFreeRun = ( w: number ): [ number, number ] => {\n\t\tlet r = cursorRow;\n\t\tlet c = cursorCol;\n\t\tplace: for ( ; r <= totalRows; r++ ) {\n\t\t\tc = r === cursorRow ? cursorCol : 0;\n\t\t\twhile ( c + w <= maxColumns ) {\n\t\t\t\tlet blocked = -1;\n\t\t\t\tfor ( let k = 0; k < w; k++ ) {\n\t\t\t\t\tif ( rowOccupancy[ c + k ] > r ) {\n\t\t\t\t\t\tblocked = c + k;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( blocked === -1 ) {\n\t\t\t\t\tbreak place;\n\t\t\t\t}\n\t\t\t\tc = blocked + 1;\n\t\t\t}\n\t\t}\n\t\treturn [ r, c ];\n\t};\n\n\tfor ( let i = 0; i < n; i++ ) {\n\t\tconst item = items[ i ];\n\t\tif ( ! item ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst h = heights[ i ];\n\n\t\tif ( kinds[ i ] === 'full' ) {\n\t\t\tlet r = cursorRow;\n\t\t\tfor ( let c = 0; c < maxColumns; c++ ) {\n\t\t\t\tif ( rowOccupancy[ c ] > r ) {\n\t\t\t\t\tr = rowOccupancy[ c ];\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor ( let c = 0; c < maxColumns; c++ ) {\n\t\t\t\trowOccupancy[ c ] = r + h;\n\t\t\t}\n\t\t\tcursorRow = r + h;\n\t\t\tcursorCol = 0;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( kinds[ i ] === 'fill' ) {\n\t\t\tconst bounds = itemBounds?.get( item.key );\n\t\t\tconst minW = Math.min( bounds?.minWidth ?? 1, maxColumns );\n\t\t\tconst maxW = bounds?.maxWidth ?? maxColumns;\n\t\t\tconst [ fillStartRow, fillStartCol ] = findFreeRun( minW );\n\t\t\tlet runLength = minW;\n\t\t\twhile (\n\t\t\t\tfillStartCol + runLength < maxColumns &&\n\t\t\t\trowOccupancy[ fillStartCol + runLength ] <= fillStartRow\n\t\t\t) {\n\t\t\t\trunLength++;\n\t\t\t}\n\t\t\tlet reserved = 0;\n\t\t\tfor ( let j = i + 1; j < n; j++ ) {\n\t\t\t\tif ( kinds[ j ] !== 'fixed' ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst nextW = widths[ j ];\n\t\t\t\tif ( minW + reserved + nextW <= runLength ) {\n\t\t\t\t\treserved += nextW;\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst fillCols = Math.min(\n\t\t\t\tMath.max( minW, runLength - reserved ),\n\t\t\t\tmaxW\n\t\t\t);\n\t\t\tresolved.set( item.key, fillCols );\n\t\t\tfor ( let k = 0; k < fillCols; k++ ) {\n\t\t\t\trowOccupancy[ fillStartCol + k ] = fillStartRow + h;\n\t\t\t}\n\t\t\tcursorRow = fillStartRow;\n\t\t\tcursorCol = fillStartCol + fillCols;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst w = widths[ i ];\n\t\tconst [ r, c ] = findFreeRun( w );\n\t\tfor ( let k = 0; k < w; k++ ) {\n\t\t\trowOccupancy[ c + k ] = r + h;\n\t\t}\n\t\tcursorRow = r;\n\t\tcursorCol = c + w;\n\t}\n\n\treturn resolved;\n}\n"],
|
|
5
|
+
"mappings": ";AA8BO,SAAS,kBACf,YACA,WACA,YACA,YACwB;AACxB,QAAM,WAAW,oBAAI,IAAsB;AAC3C,QAAM,IAAI,WAAW;AAGrB,QAAM,QAAQ,IAAI,MAA8C,CAAE;AAClE,QAAM,QAAQ,IAAI,MAAgD,CAAE;AACpE,QAAM,SAAS,IAAI,MAAiB,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AAA,MACnD;AACA,kBAAY;AACZ,kBAAY,eAAe;AAC3B;AAAA,IACD;AAEA,UAAM,IAAI,OAAQ,CAAE;AACpB,UAAM,CAAE,GAAG,CAAE,IAAI,YAAa,CAAE;AAChC,aAAU,IAAI,GAAG,IAAI,GAAG,KAAM;AAC7B,mBAAc,IAAI,CAAE,IAAI,IAAI;AAAA,IAC7B;AACA,gBAAY;AACZ,gBAAY,IAAI;AAAA,EACjB;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": ["r", "c"]
|
|
7
7
|
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
useSensors
|
|
9
9
|
} from "@dnd-kit/core";
|
|
10
10
|
import {
|
|
11
|
-
arrayMove,
|
|
12
11
|
SortableContext,
|
|
13
12
|
sortableKeyboardCoordinates
|
|
14
13
|
} from "@dnd-kit/sortable";
|
|
@@ -26,8 +25,10 @@ import {
|
|
|
26
25
|
} from "@wordpress/element";
|
|
27
26
|
import { LanesItem } from "./lanes-item.mjs";
|
|
28
27
|
import { useLanePlacement } from "./use-lane-placement.mjs";
|
|
28
|
+
import { arrayMoveWithPinned } from "../shared/array-move-with-pinned.mjs";
|
|
29
29
|
import { GridOverlay } from "../shared/grid-overlay.mjs";
|
|
30
|
-
import { gridSpanToPixelSize } from "../shared/resize-snap.mjs";
|
|
30
|
+
import { clampSpan, gridSpanToPixelSize } from "../shared/resize-snap.mjs";
|
|
31
|
+
import { useResizePixelLimits, useSpanBounds } from "../shared/use-span-bounds.mjs";
|
|
31
32
|
|
|
32
33
|
// packages/style-runtime/src/index.ts
|
|
33
34
|
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
@@ -129,15 +130,15 @@ import { createDashboardDragDropAnimation } from "../shared/drag-overlay-drop-an
|
|
|
129
130
|
|
|
130
131
|
// packages/grid/src/dashboard-lanes/lanes.module.css
|
|
131
132
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
132
|
-
registerStyle("
|
|
133
|
+
registerStyle("7b851be8c0", "._8cc368bc6c2d79c6__lanes{column-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px));display:grid-lanes;position:relative;row-gap:var(--wp-grid-gap,var(--wpds-dimension-gap-xl,24px))}@supports not (display:grid-lanes){._8cc368bc6c2d79c6__lanes{display:grid;grid-auto-flow:dense;grid-auto-rows:var(--wp-grid-lane-row-unit,4px);row-gap:0}}._1bfa908a532e32a4__drag-preview-frame{--_wp-grid-elevation-xs:0 1px 1px rgba(0,0,0,.03),0 1px 2px rgba(0,0,0,.02),0 3px 3px rgba(0,0,0,.02),0 4px 4px rgba(0,0,0,.01);--_wp-grid-elevation-md:0 2px 3px rgba(0,0,0,.05),0 4px 5px rgba(0,0,0,.04),0 12px 12px rgba(0,0,0,.03),0 16px 16px rgba(0,0,0,.02);border-radius:var(--wp-grid-drag-preview-radius,0);box-shadow:var(--_wp-grid-elevation-md);cursor:grabbing;height:100%;pointer-events:none}.bd684ee9f92388ed__drag-preview-frame__lift{height:100%;transform:scale(var(--wp-grid-drag-preview-scale,1.05));transform-origin:center}@media not (prefers-reduced-motion:reduce){._1bfa908a532e32a4__drag-preview-frame{animation:_5f4a1718cb7927ee__wp-grid-drag-preview-shadow-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}.bd684ee9f92388ed__drag-preview-frame__lift{animation:_29f7f02d4f227b1e__wp-grid-drag-preview-scale-enter var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) both}}@media not (prefers-reduced-motion:reduce){@keyframes _5f4a1718cb7927ee__wp-grid-drag-preview-shadow-enter{0%{box-shadow:var(--_wp-grid-elevation-xs)}to{box-shadow:var(--_wp-grid-elevation-md)}}@keyframes _29f7f02d4f227b1e__wp-grid-drag-preview-scale-enter{0%{transform:scale(1)}to{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}}}@media not (prefers-reduced-motion:reduce){._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting{animation:_6883de14c5fb8559__wp-grid-drag-preview-shadow-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting .bd684ee9f92388ed__drag-preview-frame__lift{animation:_0de4da1cd817e536__wp-grid-drag-preview-scale-exit var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _6883de14c5fb8559__wp-grid-drag-preview-shadow-exit{0%{box-shadow:var(--_wp-grid-elevation-md)}to{box-shadow:var(--_wp-grid-elevation-xs)}}@keyframes _0de4da1cd817e536__wp-grid-drag-preview-scale-exit{0%{transform:scale(var(--wp-grid-drag-preview-scale,1.05))}to{transform:scale(1)}}}._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting{box-shadow:var(--_wp-grid-elevation-xs)}._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting .bd684ee9f92388ed__drag-preview-frame__lift{transform:scale(1)}@media (prefers-reduced-motion:reduce){._1bfa908a532e32a4__drag-preview-frame{box-shadow:var(--_wp-grid-elevation-md)}.bd684ee9f92388ed__drag-preview-frame__lift{transform:none}._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting{box-shadow:var(--_wp-grid-elevation-xs);transition:none}._1bfa908a532e32a4__drag-preview-frame._4e3613427755609c__is-exiting .bd684ee9f92388ed__drag-preview-frame__lift{transition:none}}");
|
|
133
134
|
}
|
|
134
|
-
var lanes_default = { "lanes": "_8cc368bc6c2d79c6__lanes", "drag-preview-frame": "_1bfa908a532e32a4__drag-preview-frame", "drag-preview-frame__lift": "bd684ee9f92388ed__drag-preview-frame__lift", "wp-grid-drag-preview-shadow-enter": "_5f4a1718cb7927ee__wp-grid-drag-preview-shadow-enter", "wp-grid-drag-preview-scale-enter": "_29f7f02d4f227b1e__wp-grid-drag-preview-scale-enter", "
|
|
135
|
+
var lanes_default = { "lanes": "_8cc368bc6c2d79c6__lanes", "drag-preview-frame": "_1bfa908a532e32a4__drag-preview-frame", "drag-preview-frame__lift": "bd684ee9f92388ed__drag-preview-frame__lift", "wp-grid-drag-preview-shadow-enter": "_5f4a1718cb7927ee__wp-grid-drag-preview-shadow-enter", "wp-grid-drag-preview-scale-enter": "_29f7f02d4f227b1e__wp-grid-drag-preview-scale-enter", "is-exiting": "_4e3613427755609c__is-exiting", "wp-grid-drag-preview-shadow-exit": "_6883de14c5fb8559__wp-grid-drag-preview-shadow-exit", "wp-grid-drag-preview-scale-exit": "_0de4da1cd817e536__wp-grid-drag-preview-scale-exit" };
|
|
135
136
|
|
|
136
137
|
// packages/grid/src/dashboard-lanes/index.tsx
|
|
137
138
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
138
139
|
var dashboardDragDropAnimation = createDashboardDragDropAnimation(
|
|
139
140
|
lanes_default["drag-preview-frame"],
|
|
140
|
-
lanes_default
|
|
141
|
+
lanes_default["is-exiting"]
|
|
141
142
|
);
|
|
142
143
|
var FALLBACK_GAP_PX = 24;
|
|
143
144
|
var DEFAULT_COLUMNS = 6;
|
|
@@ -153,6 +154,7 @@ var DashboardLanes = forwardRef(
|
|
|
153
154
|
flowTolerance = 16,
|
|
154
155
|
rowUnit = 4,
|
|
155
156
|
minColumnWidth,
|
|
157
|
+
itemLimits,
|
|
156
158
|
editMode = false,
|
|
157
159
|
onChangeLayout,
|
|
158
160
|
onPreviewLayout,
|
|
@@ -223,6 +225,19 @@ var DashboardLanes = forwardRef(
|
|
|
223
225
|
gapPx,
|
|
224
226
|
null
|
|
225
227
|
).widthPx;
|
|
228
|
+
const widthBoundsByKey = useSpanBounds(
|
|
229
|
+
itemLimits,
|
|
230
|
+
columnWidth,
|
|
231
|
+
gapPx,
|
|
232
|
+
null,
|
|
233
|
+
effectiveColumns
|
|
234
|
+
);
|
|
235
|
+
const resizeLimitsByKey = useResizePixelLimits(
|
|
236
|
+
widthBoundsByKey,
|
|
237
|
+
columnWidth,
|
|
238
|
+
gapPx,
|
|
239
|
+
null
|
|
240
|
+
);
|
|
226
241
|
const layoutMap = useMemo(() => {
|
|
227
242
|
const map = /* @__PURE__ */ new Map();
|
|
228
243
|
activeLayout.forEach((item) => map.set(item.key, item));
|
|
@@ -239,14 +254,28 @@ var DashboardLanes = forwardRef(
|
|
|
239
254
|
[activeLayout]
|
|
240
255
|
);
|
|
241
256
|
const items = sortedItems;
|
|
257
|
+
const renderedSpanByKey = useMemo(() => {
|
|
258
|
+
const map = /* @__PURE__ */ new Map();
|
|
259
|
+
for (const [key, item] of layoutMap) {
|
|
260
|
+
const span = typeof item.width === "number" ? Math.max(
|
|
261
|
+
1,
|
|
262
|
+
Math.min(item.width, effectiveColumns)
|
|
263
|
+
) : 1;
|
|
264
|
+
const bounds = widthBoundsByKey.get(key);
|
|
265
|
+
map.set(
|
|
266
|
+
key,
|
|
267
|
+
bounds ? clampSpan(span, bounds.minWidth, bounds.maxWidth) : span
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
return map;
|
|
271
|
+
}, [layoutMap, effectiveColumns, widthBoundsByKey]);
|
|
242
272
|
const placementItems = useMemo(() => {
|
|
243
|
-
return items.map((key) => {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}, [items, layoutMap, effectiveColumns]);
|
|
273
|
+
return items.map((key) => ({
|
|
274
|
+
key,
|
|
275
|
+
span: renderedSpanByKey.get(key) ?? 1,
|
|
276
|
+
lane: layoutMap.get(key)?.lane
|
|
277
|
+
}));
|
|
278
|
+
}, [items, layoutMap, renderedSpanByKey]);
|
|
250
279
|
const { itemStyles } = useLanePlacement(container, {
|
|
251
280
|
items: placementItems,
|
|
252
281
|
lanes: effectiveColumns,
|
|
@@ -343,7 +372,15 @@ var DashboardLanes = forwardRef(
|
|
|
343
372
|
if (newIndex === currentIndex) {
|
|
344
373
|
return;
|
|
345
374
|
}
|
|
346
|
-
const updatedItems =
|
|
375
|
+
const updatedItems = arrayMoveWithPinned(
|
|
376
|
+
items,
|
|
377
|
+
currentIndex,
|
|
378
|
+
newIndex,
|
|
379
|
+
(key) => layoutMap.get(key)?.draggable === false
|
|
380
|
+
);
|
|
381
|
+
if (updatedItems.every((key, index) => key === items[index])) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
347
384
|
const orderByKey = /* @__PURE__ */ new Map();
|
|
348
385
|
updatedItems.forEach((key, index) => {
|
|
349
386
|
orderByKey.set(key, index);
|
|
@@ -385,14 +422,14 @@ var DashboardLanes = forwardRef(
|
|
|
385
422
|
delta.width / (columnWidth + gapPx)
|
|
386
423
|
);
|
|
387
424
|
if (resizeBaselineRef.current === null) {
|
|
388
|
-
|
|
389
|
-
const baseWidth = typeof baseItem?.width === "number" ? baseItem.width : 1;
|
|
390
|
-
resizeBaselineRef.current = baseWidth;
|
|
425
|
+
resizeBaselineRef.current = renderedSpanByKey.get(id) ?? 1;
|
|
391
426
|
}
|
|
392
427
|
const baseline = resizeBaselineRef.current;
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
428
|
+
const bounds = widthBoundsByKey.get(id);
|
|
429
|
+
const newWidth = clampSpan(
|
|
430
|
+
baseline + relativeDelta,
|
|
431
|
+
bounds?.minWidth ?? 1,
|
|
432
|
+
bounds?.maxWidth ?? effectiveColumns
|
|
396
433
|
);
|
|
397
434
|
setResizeSnapPreview({
|
|
398
435
|
id,
|
|
@@ -407,8 +444,8 @@ var DashboardLanes = forwardRef(
|
|
|
407
444
|
const pendingItem = latestLayoutRef.current?.find(
|
|
408
445
|
(item) => item.key === id
|
|
409
446
|
);
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
447
|
+
const currentWidth = pendingItem?.width ?? renderedSpanByKey.get(id);
|
|
448
|
+
if (currentWidth === newWidth) {
|
|
412
449
|
return;
|
|
413
450
|
}
|
|
414
451
|
const updatedLayout = activeLayout.map(
|
|
@@ -500,18 +537,22 @@ var DashboardLanes = forwardRef(
|
|
|
500
537
|
if (!child) {
|
|
501
538
|
return null;
|
|
502
539
|
}
|
|
540
|
+
const limitsPx = resizeLimitsByKey.get(id);
|
|
503
541
|
return /* @__PURE__ */ jsx(
|
|
504
542
|
LanesItem,
|
|
505
543
|
{
|
|
506
544
|
itemKey: id,
|
|
507
545
|
placementStyle: itemStyles.get(id) ?? {},
|
|
508
546
|
disabled: !editMode,
|
|
547
|
+
draggable: layoutMap.get(id)?.draggable !== false,
|
|
548
|
+
resizable: layoutMap.get(id)?.resizable !== false,
|
|
509
549
|
interacting,
|
|
510
550
|
dragging: activeId !== null,
|
|
511
551
|
onResize: handleResize,
|
|
512
552
|
onResizeEnd: persistTemporaryLayout,
|
|
513
553
|
resizeSnapPreview: resizeSnapPreview?.id === id ? resizeSnapPreview.snap : null,
|
|
514
|
-
minResizeWidthPx,
|
|
554
|
+
minResizeWidthPx: limitsPx?.minWidthPx ?? minResizeWidthPx,
|
|
555
|
+
maxResizeWidthPx: limitsPx?.maxWidthPx,
|
|
515
556
|
actionableArea: actionableAreaMap.get(
|
|
516
557
|
id
|
|
517
558
|
),
|