@wordpress/grid 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -14
- package/build/dashboard-grid/grid-item.cjs +232 -295
- package/build/dashboard-grid/grid-item.cjs.map +1 -7
- package/build/dashboard-grid/index.cjs +525 -632
- package/build/dashboard-grid/index.cjs.map +1 -7
- package/build/dashboard-grid/resolve-fill-widths.cjs +159 -203
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +1 -7
- package/build/dashboard-grid/types.cjs +4 -18
- package/build/dashboard-lanes/index.cjs +494 -576
- package/build/dashboard-lanes/index.cjs.map +1 -7
- package/build/dashboard-lanes/lane-placement.cjs +77 -100
- package/build/dashboard-lanes/lane-placement.cjs.map +1 -7
- package/build/dashboard-lanes/lanes-item.cjs +222 -278
- package/build/dashboard-lanes/lanes-item.cjs.map +1 -7
- package/build/dashboard-lanes/types.cjs +4 -18
- package/build/dashboard-lanes/use-lane-placement.cjs +172 -198
- package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -7
- package/build/index.cjs +16 -31
- package/build/shared/array-move-with-pinned.cjs +29 -45
- package/build/shared/array-move-with-pinned.cjs.map +1 -7
- package/build/shared/column-policy.cjs +58 -0
- package/build/shared/column-policy.cjs.map +1 -0
- package/build/shared/drag-overlay-drop-animation.cjs +40 -66
- package/build/shared/drag-overlay-drop-animation.cjs.map +1 -7
- package/build/shared/grid-item-key.cjs +12 -29
- package/build/shared/grid-item-key.cjs.map +1 -7
- package/build/shared/grid-overlay.cjs +163 -164
- package/build/shared/grid-overlay.cjs.map +1 -7
- package/build/shared/item-exit-overlay.cjs +132 -134
- package/build/shared/item-exit-overlay.cjs.map +1 -7
- package/build/shared/resize-handle.cjs +213 -197
- package/build/shared/resize-handle.cjs.map +1 -7
- package/build/shared/resize-snap.cjs +116 -121
- package/build/shared/resize-snap.cjs.map +1 -7
- package/build/shared/types.cjs +4 -18
- package/build/shared/use-item-exit-animation.cjs +96 -143
- package/build/shared/use-item-exit-animation.cjs.map +1 -7
- package/build/shared/use-layout-shift-animation.cjs +121 -150
- package/build/shared/use-layout-shift-animation.cjs.map +1 -7
- package/build/shared/use-span-bounds.cjs +65 -79
- package/build/shared/use-span-bounds.cjs.map +1 -7
- package/build-module/dashboard-grid/grid-item.mjs +209 -265
- package/build-module/dashboard-grid/grid-item.mjs.map +1 -7
- package/build-module/dashboard-grid/index.mjs +502 -623
- package/build-module/dashboard-grid/index.mjs.map +1 -7
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +155 -179
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +1 -7
- package/build-module/dashboard-grid/types.mjs +0 -1
- package/build-module/dashboard-lanes/index.mjs +470 -567
- package/build-module/dashboard-lanes/index.mjs.map +1 -7
- package/build-module/dashboard-lanes/lane-placement.mjs +73 -76
- package/build-module/dashboard-lanes/lane-placement.mjs.map +1 -7
- package/build-module/dashboard-lanes/lanes-item.mjs +199 -248
- package/build-module/dashboard-lanes/lanes-item.mjs.map +1 -7
- package/build-module/dashboard-lanes/types.mjs +0 -1
- package/build-module/dashboard-lanes/use-lane-placement.mjs +167 -173
- package/build-module/dashboard-lanes/use-lane-placement.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/shared/array-move-with-pinned.mjs +25 -21
- package/build-module/shared/array-move-with-pinned.mjs.map +1 -7
- package/build-module/shared/column-policy.mjs +52 -0
- package/build-module/shared/column-policy.mjs.map +1 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs +35 -44
- package/build-module/shared/drag-overlay-drop-animation.mjs.map +1 -7
- package/build-module/shared/grid-item-key.mjs +8 -5
- package/build-module/shared/grid-item-key.mjs.map +1 -7
- package/build-module/shared/grid-overlay.mjs +143 -136
- package/build-module/shared/grid-overlay.mjs.map +1 -7
- package/build-module/shared/item-exit-overlay.mjs +128 -110
- package/build-module/shared/item-exit-overlay.mjs.map +1 -7
- package/build-module/shared/resize-handle.mjs +191 -171
- package/build-module/shared/resize-handle.mjs.map +1 -7
- package/build-module/shared/resize-snap.mjs +108 -93
- package/build-module/shared/resize-snap.mjs.map +1 -7
- package/build-module/shared/types.mjs +0 -1
- package/build-module/shared/use-item-exit-animation.mjs +92 -124
- package/build-module/shared/use-item-exit-animation.mjs.map +1 -7
- package/build-module/shared/use-layout-shift-animation.mjs +114 -123
- package/build-module/shared/use-layout-shift-animation.mjs.map +1 -7
- package/build-module/shared/use-span-bounds.mjs +60 -57
- package/build-module/shared/use-span-bounds.mjs.map +1 -7
- package/build-types/dashboard-grid/index.d.ts.map +1 -1
- package/build-types/dashboard-grid/types.d.ts +9 -5
- 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/types.d.ts +9 -5
- package/build-types/dashboard-lanes/types.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/shared/column-policy.d.ts +43 -0
- package/build-types/shared/column-policy.d.ts.map +1 -0
- package/package.json +11 -11
- package/src/dashboard-grid/grid-item.tsx +1 -1
- package/src/dashboard-grid/index.tsx +11 -12
- package/src/dashboard-grid/stories/index.story.tsx +129 -50
- package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-grid/types.ts +9 -5
- package/src/dashboard-lanes/index.tsx +11 -11
- package/src/dashboard-lanes/lanes-item.tsx +1 -1
- package/src/dashboard-lanes/stories/index.story.tsx +124 -28
- package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-lanes/types.ts +9 -5
- package/src/index.ts +1 -0
- package/src/shared/column-policy.ts +100 -0
- package/src/shared/test/column-policy.test.ts +215 -0
- package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
- package/build/dashboard-grid/types.cjs.map +0 -7
- package/build/dashboard-lanes/types.cjs.map +0 -7
- package/build/index.cjs.map +0 -7
- package/build/shared/types.cjs.map +0 -7
- package/build-module/dashboard-grid/types.mjs.map +0 -7
- package/build-module/dashboard-lanes/types.mjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/shared/types.mjs.map +0 -7
package/README.md
CHANGED
|
@@ -148,8 +148,8 @@ interface DashboardGridLayoutItem {
|
|
|
148
148
|
| -------------------- | ------------------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
149
149
|
| `layout` | `DashboardGridLayoutItem[]` | — | Required. Positions and sizes keyed by child `key`. |
|
|
150
150
|
| `children` | `ReactNode` | — | Required. Each child needs a `key` matching a layout entry. |
|
|
151
|
-
| `columns` | `number`
|
|
152
|
-
| `minColumnWidth` | `number` | — |
|
|
151
|
+
| `columns` | `number \| ColumnSteps` | `6` | Column count, or a count per container width (`{ 0: 1, 600: 2, 960: 4 }`; a step can be `'auto'`). Caps the count when `minColumnWidth` is set. See [Columns](#columns). |
|
|
152
|
+
| `minColumnWidth` | `number` | — | Per-column floor in pixels: the count drops on narrow containers so no column is narrower, down to one. Alone, as many columns as fit. |
|
|
153
153
|
| `rowHeight` | `number \| 'auto'` | `'auto'` | Row height in pixels, or `'auto'` to let content size rows. |
|
|
154
154
|
| `itemLimits` | `Record< string, GridItemLimits >` | — | Per-item minimum and maximum tile sizes in pixels, keyed by layout item key. See [Size limits](#size-limits). |
|
|
155
155
|
| `editMode` | `boolean` | `false` | Enables drag-to-reorder and resize handles. |
|
|
@@ -179,9 +179,11 @@ while edit mode is on:
|
|
|
179
179
|
| ---------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
180
180
|
| `actionableArea` | `ReactNode` | Content rendered above the draggable surface of the grid item. Useful for close buttons, menus, or links that must stay clickable in edit mode. |
|
|
181
181
|
|
|
182
|
-
###
|
|
182
|
+
### Columns
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
`columns` and `minColumnWidth` compose. Both surfaces measure their own width with a `ResizeObserver` and resolve the count from it.
|
|
185
|
+
|
|
186
|
+
A number renders that many columns at every width:
|
|
185
187
|
|
|
186
188
|
```jsx
|
|
187
189
|
<DashboardGrid layout={ layout } columns={ 12 }>
|
|
@@ -189,20 +191,39 @@ while edit mode is on:
|
|
|
189
191
|
</DashboardGrid>
|
|
190
192
|
```
|
|
191
193
|
|
|
192
|
-
|
|
194
|
+
A `ColumnSteps` map renders a count from each container width up: one column from 0px, two from 600px, four from 960px.
|
|
193
195
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
```jsx
|
|
197
|
+
<DashboardGrid layout={ layout } columns={ { 0: 1, 600: 2, 960: 4 } }>
|
|
198
|
+
{ children }
|
|
199
|
+
</DashboardGrid>
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Below the smallest key, that step's count applies, so a map that starts at `0` states every width.
|
|
203
|
+
|
|
204
|
+
`minColumnWidth` is a per-column floor in pixels. Alone, the surface fits as many columns of at least that width as the container allows. With `columns`, the count is capped by the number or the step, and lowered whenever a column would end up narrower than the floor.
|
|
197
205
|
|
|
198
206
|
```jsx
|
|
199
|
-
<DashboardGrid layout={ layout } minColumnWidth={ 240 }>
|
|
207
|
+
<DashboardGrid layout={ layout } columns={ 4 } minColumnWidth={ 240 }>
|
|
200
208
|
{ children }
|
|
201
209
|
</DashboardGrid>
|
|
202
210
|
```
|
|
203
211
|
|
|
204
|
-
|
|
205
|
-
|
|
212
|
+
A step can be `'auto'`: from that width up there is no cap, and the floor alone decides the count. Below it the steps still fix the count. Without a floor, an `'auto'` step is skipped and the count below it holds.
|
|
213
|
+
|
|
214
|
+
```jsx
|
|
215
|
+
<DashboardGrid
|
|
216
|
+
layout={ layout }
|
|
217
|
+
columns={ { 0: 1, 600: 2, 960: 'auto' } }
|
|
218
|
+
minColumnWidth={ 240 }
|
|
219
|
+
>
|
|
220
|
+
{ children }
|
|
221
|
+
</DashboardGrid>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
A count is rounded down and never below one. A count that is not a finite number, or a step that is neither a count nor `'auto'`, is ignored.
|
|
225
|
+
|
|
226
|
+
Layout items can provide an `order` to control display order independently of array position.
|
|
206
227
|
|
|
207
228
|
#### Edit mode
|
|
208
229
|
|
|
@@ -311,8 +332,8 @@ items flow around them; out-of-range values (negative, or beyond
|
|
|
311
332
|
| -------------------- | ------------------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
312
333
|
| `layout` | `DashboardLanesLayoutItem[]` | — | Required. Span and order keyed by child `key`. |
|
|
313
334
|
| `children` | `ReactNode` | — | Required. Each child needs a `key` matching a layout entry. |
|
|
314
|
-
| `columns` | `number`
|
|
315
|
-
| `minColumnWidth` | `number` | — |
|
|
335
|
+
| `columns` | `number \| ColumnSteps` | `6` | Lane count, or a count per container width (`{ 0: 1, 600: 2, 960: 4 }`; a step can be `'auto'`). Caps the count when `minColumnWidth` is set. See [Columns](#columns). |
|
|
336
|
+
| `minColumnWidth` | `number` | — | Per-lane floor in pixels: the count drops on narrow containers so no lane is narrower, down to one. Alone, as many lanes as fit. |
|
|
316
337
|
| `flowTolerance` | `number` | `16` | Pixel tolerance for source-order tiebreaking when two candidate lanes have similar baselines. Larger values keep tiles closer to reading order at the cost of bigger empty regions. |
|
|
317
338
|
| `rowUnit` | `number` | `4` | Snap unit for the polyfill's `grid-row-start` math. Smaller values produce sharper placement at the cost of a larger implicit row count. Ignored on browsers with native `display: grid-lanes` support. |
|
|
318
339
|
| `itemLimits` | `Record< string, GridItemWidthLimits >` | — | Per-item minimum and maximum tile widths in pixels, keyed by layout item key. See [Size limits](#size-limits). |
|
|
@@ -423,7 +444,7 @@ heights are content-driven.
|
|
|
423
444
|
Drag-to-reorder is operable from the keyboard via `@dnd-kit`'s
|
|
424
445
|
keyboard sensor:
|
|
425
446
|
|
|
426
|
-
- `Tab` to focus a tile.
|
|
447
|
+
- In edit mode, `Tab` to focus a draggable tile.
|
|
427
448
|
- `Space` to pick it up.
|
|
428
449
|
- Arrow keys to move it between positions.
|
|
429
450
|
- `Space` to drop, or `Escape` to cancel.
|