@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.
Files changed (114) hide show
  1. package/README.md +35 -14
  2. package/build/dashboard-grid/grid-item.cjs +232 -295
  3. package/build/dashboard-grid/grid-item.cjs.map +1 -7
  4. package/build/dashboard-grid/index.cjs +525 -632
  5. package/build/dashboard-grid/index.cjs.map +1 -7
  6. package/build/dashboard-grid/resolve-fill-widths.cjs +159 -203
  7. package/build/dashboard-grid/resolve-fill-widths.cjs.map +1 -7
  8. package/build/dashboard-grid/types.cjs +4 -18
  9. package/build/dashboard-lanes/index.cjs +494 -576
  10. package/build/dashboard-lanes/index.cjs.map +1 -7
  11. package/build/dashboard-lanes/lane-placement.cjs +77 -100
  12. package/build/dashboard-lanes/lane-placement.cjs.map +1 -7
  13. package/build/dashboard-lanes/lanes-item.cjs +222 -278
  14. package/build/dashboard-lanes/lanes-item.cjs.map +1 -7
  15. package/build/dashboard-lanes/types.cjs +4 -18
  16. package/build/dashboard-lanes/use-lane-placement.cjs +172 -198
  17. package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -7
  18. package/build/index.cjs +16 -31
  19. package/build/shared/array-move-with-pinned.cjs +29 -45
  20. package/build/shared/array-move-with-pinned.cjs.map +1 -7
  21. package/build/shared/column-policy.cjs +58 -0
  22. package/build/shared/column-policy.cjs.map +1 -0
  23. package/build/shared/drag-overlay-drop-animation.cjs +40 -66
  24. package/build/shared/drag-overlay-drop-animation.cjs.map +1 -7
  25. package/build/shared/grid-item-key.cjs +12 -29
  26. package/build/shared/grid-item-key.cjs.map +1 -7
  27. package/build/shared/grid-overlay.cjs +163 -164
  28. package/build/shared/grid-overlay.cjs.map +1 -7
  29. package/build/shared/item-exit-overlay.cjs +132 -134
  30. package/build/shared/item-exit-overlay.cjs.map +1 -7
  31. package/build/shared/resize-handle.cjs +213 -197
  32. package/build/shared/resize-handle.cjs.map +1 -7
  33. package/build/shared/resize-snap.cjs +116 -121
  34. package/build/shared/resize-snap.cjs.map +1 -7
  35. package/build/shared/types.cjs +4 -18
  36. package/build/shared/use-item-exit-animation.cjs +96 -143
  37. package/build/shared/use-item-exit-animation.cjs.map +1 -7
  38. package/build/shared/use-layout-shift-animation.cjs +121 -150
  39. package/build/shared/use-layout-shift-animation.cjs.map +1 -7
  40. package/build/shared/use-span-bounds.cjs +65 -79
  41. package/build/shared/use-span-bounds.cjs.map +1 -7
  42. package/build-module/dashboard-grid/grid-item.mjs +209 -265
  43. package/build-module/dashboard-grid/grid-item.mjs.map +1 -7
  44. package/build-module/dashboard-grid/index.mjs +502 -623
  45. package/build-module/dashboard-grid/index.mjs.map +1 -7
  46. package/build-module/dashboard-grid/resolve-fill-widths.mjs +155 -179
  47. package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +1 -7
  48. package/build-module/dashboard-grid/types.mjs +0 -1
  49. package/build-module/dashboard-lanes/index.mjs +470 -567
  50. package/build-module/dashboard-lanes/index.mjs.map +1 -7
  51. package/build-module/dashboard-lanes/lane-placement.mjs +73 -76
  52. package/build-module/dashboard-lanes/lane-placement.mjs.map +1 -7
  53. package/build-module/dashboard-lanes/lanes-item.mjs +199 -248
  54. package/build-module/dashboard-lanes/lanes-item.mjs.map +1 -7
  55. package/build-module/dashboard-lanes/types.mjs +0 -1
  56. package/build-module/dashboard-lanes/use-lane-placement.mjs +167 -173
  57. package/build-module/dashboard-lanes/use-lane-placement.mjs.map +1 -7
  58. package/build-module/index.mjs +1 -6
  59. package/build-module/shared/array-move-with-pinned.mjs +25 -21
  60. package/build-module/shared/array-move-with-pinned.mjs.map +1 -7
  61. package/build-module/shared/column-policy.mjs +52 -0
  62. package/build-module/shared/column-policy.mjs.map +1 -0
  63. package/build-module/shared/drag-overlay-drop-animation.mjs +35 -44
  64. package/build-module/shared/drag-overlay-drop-animation.mjs.map +1 -7
  65. package/build-module/shared/grid-item-key.mjs +8 -5
  66. package/build-module/shared/grid-item-key.mjs.map +1 -7
  67. package/build-module/shared/grid-overlay.mjs +143 -136
  68. package/build-module/shared/grid-overlay.mjs.map +1 -7
  69. package/build-module/shared/item-exit-overlay.mjs +128 -110
  70. package/build-module/shared/item-exit-overlay.mjs.map +1 -7
  71. package/build-module/shared/resize-handle.mjs +191 -171
  72. package/build-module/shared/resize-handle.mjs.map +1 -7
  73. package/build-module/shared/resize-snap.mjs +108 -93
  74. package/build-module/shared/resize-snap.mjs.map +1 -7
  75. package/build-module/shared/types.mjs +0 -1
  76. package/build-module/shared/use-item-exit-animation.mjs +92 -124
  77. package/build-module/shared/use-item-exit-animation.mjs.map +1 -7
  78. package/build-module/shared/use-layout-shift-animation.mjs +114 -123
  79. package/build-module/shared/use-layout-shift-animation.mjs.map +1 -7
  80. package/build-module/shared/use-span-bounds.mjs +60 -57
  81. package/build-module/shared/use-span-bounds.mjs.map +1 -7
  82. package/build-types/dashboard-grid/index.d.ts.map +1 -1
  83. package/build-types/dashboard-grid/types.d.ts +9 -5
  84. package/build-types/dashboard-grid/types.d.ts.map +1 -1
  85. package/build-types/dashboard-lanes/index.d.ts.map +1 -1
  86. package/build-types/dashboard-lanes/types.d.ts +9 -5
  87. package/build-types/dashboard-lanes/types.d.ts.map +1 -1
  88. package/build-types/index.d.ts +1 -0
  89. package/build-types/index.d.ts.map +1 -1
  90. package/build-types/shared/column-policy.d.ts +43 -0
  91. package/build-types/shared/column-policy.d.ts.map +1 -0
  92. package/package.json +11 -11
  93. package/src/dashboard-grid/grid-item.tsx +1 -1
  94. package/src/dashboard-grid/index.tsx +11 -12
  95. package/src/dashboard-grid/stories/index.story.tsx +129 -50
  96. package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
  97. package/src/dashboard-grid/types.ts +9 -5
  98. package/src/dashboard-lanes/index.tsx +11 -11
  99. package/src/dashboard-lanes/lanes-item.tsx +1 -1
  100. package/src/dashboard-lanes/stories/index.story.tsx +124 -28
  101. package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
  102. package/src/dashboard-lanes/types.ts +9 -5
  103. package/src/index.ts +1 -0
  104. package/src/shared/column-policy.ts +100 -0
  105. package/src/shared/test/column-policy.test.ts +215 -0
  106. package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
  107. package/build/dashboard-grid/types.cjs.map +0 -7
  108. package/build/dashboard-lanes/types.cjs.map +0 -7
  109. package/build/index.cjs.map +0 -7
  110. package/build/shared/types.cjs.map +0 -7
  111. package/build-module/dashboard-grid/types.mjs.map +0 -7
  112. package/build-module/dashboard-lanes/types.mjs.map +0 -7
  113. package/build-module/index.mjs.map +0 -7
  114. package/build-module/shared/types.mjs.map +0 -7
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Column count per container width. Each key is the inline size in pixels
3
+ * from which its count applies: `{ 0: 1, 600: 2, 960: 4 }` is one column
4
+ * from 0px, two from 600px, four from 960px, and below the smallest key
5
+ * that step's count applies. An `'auto'` step lifts the cap from its
6
+ * width up and leaves the count to `minColumnWidth`; with no floor set,
7
+ * the step is skipped and the count below it holds.
8
+ */
9
+ export type ColumnSteps = Record<number, number | 'auto'>;
10
+ /**
11
+ * Column policy shared by the surfaces: a count at every width, or a count
12
+ * per container width, with an optional per-column floor in pixels.
13
+ */
14
+ export interface ColumnPolicy {
15
+ columns?: number | ColumnSteps;
16
+ minColumnWidth?: number;
17
+ }
18
+ /**
19
+ * The count the policy asks for at a container width, before the floor.
20
+ * Counts are rounded down and never below one; a count that is not a
21
+ * finite number, or a step that is neither a count nor `'auto'`, is
22
+ * ignored.
23
+ *
24
+ * @param policy Column policy.
25
+ * @param containerWidth Measured inline size of the surface in pixels.
26
+ * @return The count, or `undefined` when none applies: no count was set, or
27
+ * an `'auto'` step lifts the cap over a floor.
28
+ */
29
+ export declare function resolveColumnCap(policy: ColumnPolicy, containerWidth: number): number | undefined;
30
+ /**
31
+ * Resolves the count a surface renders: the policy's count at the container
32
+ * width, lowered by the floor so no column is narrower than
33
+ * `minColumnWidth`. A floor with no count fits as many columns as the
34
+ * container allows.
35
+ *
36
+ * @param policy Column policy.
37
+ * @param containerWidth Measured inline size of the surface in pixels.
38
+ * @param gapPx Column gap in pixels.
39
+ * @param defaultColumns Count used when the policy sets neither field.
40
+ * @return Column count, at least one.
41
+ */
42
+ export declare function resolveColumnCount(policy: ColumnPolicy, containerWidth: number, gapPx: number, defaultColumns: number): number;
43
+ //# sourceMappingURL=column-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"column-policy.d.ts","sourceRoot":"","sources":["../../src/shared/column-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAE,CAAC;AAE5D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAgBD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAsBpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,YAAY,EACpB,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,MAAM,GACpB,MAAM,CAWR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/grid",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",
@@ -46,22 +46,22 @@
46
46
  "dependencies": {
47
47
  "@dnd-kit/core": "^6.3.1",
48
48
  "@dnd-kit/sortable": "^10.0.0",
49
- "@wordpress/compose": "^9.0.0",
50
- "@wordpress/element": "^10.0.0",
51
- "@wordpress/react-inert-value": "^2.0.0",
52
- "@wordpress/style-runtime": "^0.14.0",
53
- "@wordpress/ui": "^0.25.0",
49
+ "@wordpress/compose": "^9.1.0",
50
+ "@wordpress/element": "^10.1.0",
51
+ "@wordpress/react-inert-value": "^2.1.0",
52
+ "@wordpress/style-runtime": "^0.15.0",
53
+ "@wordpress/ui": "^0.26.0",
54
54
  "clsx": "^2.1.1"
55
55
  },
56
56
  "devDependencies": {
57
- "@storybook/react-vite": "^10.6.1",
57
+ "@storybook/react-vite": "^10.6.5",
58
58
  "@testing-library/dom": "^10.4.2",
59
59
  "@testing-library/jest-dom": "^7.0.1",
60
60
  "@testing-library/react": "^16.3.3",
61
- "@wordpress/icons": "^19.0.0",
61
+ "@wordpress/icons": "^20.0.0",
62
62
  "@wordpress/ui": "file:../ui",
63
- "storybook": "^10.6.1",
64
- "vitest": "^5.0.3",
63
+ "storybook": "^10.6.5",
64
+ "vitest": "^5.0.5",
65
65
  "vitest-browser-react": "^2.3.0"
66
66
  },
67
67
  "peerDependencies": {
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
80
+ "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
81
81
  }
@@ -167,7 +167,7 @@ export function GridItem( {
167
167
 
168
168
  <div
169
169
  ref={ setActivatorNodeRef }
170
- { ...attributes }
170
+ { ...( dragDisabled ? {} : attributes ) }
171
171
  { ...listeners }
172
172
  style={ {
173
173
  height: '100%',
@@ -25,6 +25,7 @@ import {
25
25
  } from '@wordpress/element';
26
26
  import { GridItem } from './grid-item';
27
27
  import { arrayMoveWithPinned } from '../shared/array-move-with-pinned';
28
+ import { resolveColumnCount } from '../shared/column-policy';
28
29
  import { GridOverlay } from '../shared/grid-overlay';
29
30
  import { clampSpan, gridSpanToPixelSize } from '../shared/resize-snap';
30
31
  import { useResizePixelLimits, useSpanBounds } from '../shared/use-span-bounds';
@@ -199,18 +200,16 @@ export const DashboardGrid = forwardRef< HTMLDivElement, DashboardGridProps >(
199
200
  setGapPx( parsed );
200
201
  }
201
202
  }, [ gridRoot ] );
202
- const effectiveColumns = useMemo( () => {
203
- if ( ! minColumnWidth ) {
204
- return columns ?? DEFAULT_COLUMNS;
205
- }
206
-
207
- const totalWidthPerColumn = minColumnWidth + gapPx;
208
- const maxFit = Math.max(
209
- 1,
210
- Math.floor( ( containerWidth + gapPx ) / totalWidthPerColumn )
211
- );
212
- return columns !== undefined ? Math.min( columns, maxFit ) : maxFit;
213
- }, [ minColumnWidth, gapPx, containerWidth, columns ] );
203
+ const effectiveColumns = useMemo(
204
+ () =>
205
+ resolveColumnCount(
206
+ { columns, minColumnWidth },
207
+ containerWidth,
208
+ gapPx,
209
+ DEFAULT_COLUMNS
210
+ ),
211
+ [ minColumnWidth, gapPx, containerWidth, columns ]
212
+ );
214
213
  const columnWidth =
215
214
  ( containerWidth - ( effectiveColumns - 1 ) * gapPx ) /
216
215
  effectiveColumns;
@@ -1,8 +1,12 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { useState, useMemo } from '@wordpress/element';
2
+ import { useId, useState, useMemo } from '@wordpress/element';
3
3
  import { close, justifyStretch, stretchFullWidth } from '@wordpress/icons';
4
- // eslint-disable-next-line @wordpress/use-recommended-components -- @wordpress/grid consumes @wordpress/ui in story examples only.
5
- import { Icon, IconButton, Stack } from '@wordpress/ui';
4
+ import {
5
+ Icon,
6
+ // eslint-disable-next-line @wordpress/use-recommended-components -- @wordpress/grid consumes @wordpress/ui in story examples only.
7
+ IconButton,
8
+ Stack,
9
+ } from '@wordpress/ui';
6
10
  import { DashboardGrid } from '..';
7
11
  import type { DashboardGridLayoutItem } from '../types';
8
12
  import type {
@@ -25,12 +29,13 @@ const meta: Meta< typeof DashboardGrid > = {
25
29
  children: { control: false },
26
30
  columns: {
27
31
  control: { type: 'number', min: 1, max: 24, step: 1 },
28
- description: 'Total columns in fixed mode.',
32
+ description:
33
+ 'Column count, or the cap when `minColumnWidth` is set.',
29
34
  },
30
35
  minColumnWidth: {
31
36
  control: { type: 'number', min: 80, max: 600, step: 8 },
32
37
  description:
33
- 'Enables responsive mode. Per-column lower bound in pixels.',
38
+ 'Per-column floor in pixels. Lowers the count on narrow containers, down to one.',
34
39
  },
35
40
  rowHeight: {
36
41
  control: { type: 'number', min: 24, max: 400, step: 4 },
@@ -281,90 +286,163 @@ export const Default: Story = {
281
286
  },
282
287
  };
283
288
 
289
+ function TileControls( { title }: { title: string } ) {
290
+ const metricId = useId();
291
+ return (
292
+ <Stack direction="column" gap="sm" align="flex-start">
293
+ <strong>{ title }</strong>
294
+ <a href="#details">Details</a>
295
+ <button type="button">Refresh</button>
296
+ <label htmlFor={ metricId }>
297
+ Metric{ ' ' }
298
+ <select id={ metricId }>
299
+ <option>Views</option>
300
+ <option>Clicks</option>
301
+ </select>
302
+ </label>
303
+ </Stack>
304
+ );
305
+ }
306
+
284
307
  /**
285
- * Responsive grid: the column count is derived from the container
286
- * width using `minColumnWidth` as the lower bound per column. A
287
- * `ResizeObserver` recomputes the count on container resize.
308
+ * Tiles with their own links, buttons and form controls. The a11y addon checks that the grid does not wrap them in drag semantics. In edit mode, the first tile is pinned (`draggable: false`) and its controls keep their semantics.
288
309
  */
289
- export const Responsive: Story = {
310
+ export const InteractiveContent: Story = {
290
311
  args: {
291
312
  layout: [
292
- { key: 'a', width: 1, order: 1 },
293
- { key: 'b', width: 2, order: 2 },
294
- { key: 'c', width: 2, order: 3 },
295
- { key: 'd', width: 1, order: 4 },
296
- { key: 'e', width: 2, order: 5 },
297
- { key: 'f', width: 2, order: 6 },
313
+ { key: 'pinned', width: 2, draggable: false },
314
+ { key: 'a', width: 2 },
315
+ { key: 'b', width: 2 },
298
316
  ],
317
+ columns: 6,
318
+ rowHeight: 160,
319
+ children: [
320
+ <Tile key="pinned" tone="neutral">
321
+ <TileControls title="Pinned" />
322
+ </Tile>,
323
+ <Tile key="a" tone="info">
324
+ <TileControls title="Tile" />
325
+ </Tile>,
326
+ <Tile key="b" tone="success">
327
+ <TileControls title="Tile" />
328
+ </Tile>,
329
+ ],
330
+ },
331
+ };
332
+
333
+ /**
334
+ * `columns` and `minColumnWidth` compose. `columns` alone fixes the count.
335
+ * `minColumnWidth` alone fits as many columns of at least that width as
336
+ * the container allows. Together, `columns` caps what the floor fits:
337
+ * up to four columns here, none narrower than 240px, down to one. The
338
+ * layout mixes fixed, `fill`, `full` and two-row tiles so the repacking
339
+ * is visible at every count: a `fill` takes the free run of the row it
340
+ * lands in, and the tall tile's shadow shortens the runs below it. Open
341
+ * the story full screen and resize the browser to walk the counts.
342
+ */
343
+ export const Columns: Story = {
344
+ args: {
345
+ columns: 4,
346
+ minColumnWidth: 240,
299
347
  rowHeight: 96,
300
- minColumnWidth: 192,
348
+ layout: [
349
+ { key: 'a', width: 1 },
350
+ { key: 'b', width: 'fill' },
351
+ { key: 'c', width: 1, height: 2 },
352
+ { key: 'd', width: 1 },
353
+ { key: 'e', width: 'fill' },
354
+ { key: 'f', width: 'full' },
355
+ ],
301
356
  children: [
302
357
  <Tile key="a" tone="brand">
303
- width: 1
358
+ 1
304
359
  </Tile>,
305
360
  <Tile key="b" tone="info">
306
- width: 2
361
+ fill
307
362
  </Tile>,
308
363
  <Tile key="c" tone="success">
309
- width: 2
364
+ 1 · 2 rows
310
365
  </Tile>,
311
366
  <Tile key="d" tone="warning">
312
- width: 1
367
+ 1
313
368
  </Tile>,
314
369
  <Tile key="e" tone="error">
315
- width: 2
370
+ fill
316
371
  </Tile>,
317
372
  <Tile key="f" tone="neutral">
318
- width: 2
373
+ full
319
374
  </Tile>,
320
375
  ],
321
376
  },
322
377
  };
323
378
 
324
379
  /**
325
- * Layered configuration: `columns` caps the count and
326
- * `minColumnWidth` enforces a per-tile width floor. The grid renders
327
- * up to `columns` columns on wide containers and reduces the count
328
- * on narrow ones whenever fitting all of them would push tiles
329
- * below `minColumnWidth`. Resize the preview to see the cap apply
330
- * on wide widths and the floor reduce the count on narrow widths.
380
+ * `columns` as a map: one column from 0px, two from 600px, four from
381
+ * 960px. The count steps at those container widths regardless of how
382
+ * wide each column ends up; add `minColumnWidth` to lower it further.
331
383
  */
332
- export const Layered: Story = {
384
+ export const ColumnSteps: Story = {
385
+ argTypes: {
386
+ columns: { control: 'object' },
387
+ },
333
388
  args: {
389
+ columns: { 0: 1, 600: 2, 960: 4 },
390
+ rowHeight: 96,
334
391
  layout: [
335
- { key: 'a', width: 1, order: 1 },
336
- { key: 'b', width: 2, order: 2 },
337
- { key: 'c', width: 2, order: 3 },
338
- { key: 'd', width: 1, order: 4 },
339
- { key: 'e', width: 2, order: 5 },
340
- { key: 'f', width: 2, order: 6 },
392
+ { key: 'fixed-1', width: 1, height: 1 },
393
+ { key: 'fixed-2', width: 2, height: 2 },
394
+ { key: 'fill-1', width: 'fill' },
395
+ { key: 'fixed-3', width: 1, height: 1 },
396
+ { key: 'fixed-4', width: 1, height: 2 },
397
+ { key: 'fixed-5', width: 2, height: 1 },
398
+ { key: 'fill-2', width: 'fill' },
399
+ { key: 'full-1', width: 'full' },
341
400
  ],
342
- rowHeight: 96,
343
- columns: 6,
344
- minColumnWidth: 240,
345
401
  children: [
346
- <Tile key="a" tone="brand">
347
- width: 1
402
+ <Tile key="fixed-1" tone="brand">
403
+ width: <strong>1</strong> · height: <strong>1</strong>
348
404
  </Tile>,
349
- <Tile key="b" tone="info">
350
- width: 2
405
+ <Tile key="fixed-2" tone="info">
406
+ width: <strong>2</strong> · height: <strong>2</strong>
351
407
  </Tile>,
352
- <Tile key="c" tone="success">
353
- width: 2
408
+ <Tile key="fill-1" tone="info">
409
+ width: <strong>fill</strong>
354
410
  </Tile>,
355
- <Tile key="d" tone="warning">
356
- width: 1
411
+ <Tile key="fixed-3" tone="success">
412
+ width: <strong>1</strong> · height: <strong>1</strong>
357
413
  </Tile>,
358
- <Tile key="e" tone="error">
359
- width: 2
414
+ <Tile key="fixed-4" tone="warning">
415
+ width: <strong>1</strong> · height: <strong>2</strong>
360
416
  </Tile>,
361
- <Tile key="f" tone="neutral">
362
- width: 2
417
+ <Tile key="fixed-5" tone="error">
418
+ width: <strong>2</strong> · height: <strong>1</strong>
419
+ </Tile>,
420
+ <Tile key="fill-2" tone="error">
421
+ width: <strong>fill</strong>
422
+ </Tile>,
423
+ <Tile key="full-1" tone="neutral">
424
+ width: <strong>full</strong>
363
425
  </Tile>,
364
426
  ],
365
427
  },
366
428
  };
367
429
 
430
+ /**
431
+ * A step can be `'auto'`: from that width up there is no cap and the
432
+ * floor alone decides the count. Here the steps fix one and two columns
433
+ * below 960px, and 240px columns fill the container above it.
434
+ */
435
+ export const ColumnStepsWithFloor: Story = {
436
+ argTypes: {
437
+ columns: { control: 'object' },
438
+ },
439
+ args: {
440
+ ...ColumnSteps.args,
441
+ columns: { 0: 1, 600: 2, 960: 'auto' },
442
+ minColumnWidth: 240,
443
+ },
444
+ };
445
+
368
446
  /**
369
447
  * A `width: 'fill'` item expands to cover the remaining columns in
370
448
  * its row. Mix it with fixed-width items on either side to build
@@ -504,6 +582,7 @@ export const EditMode: Story = {
504
582
  width: 1,
505
583
  height: 1,
506
584
  order: 1,
585
+ draggable: false,
507
586
  tone: 'success',
508
587
  },
509
588
  {
@@ -36,7 +36,7 @@ describe( 'DashboardGrid item interactions', () => {
36
36
  const { activator, resizeHandle } = await renderItem( {
37
37
  draggable: false,
38
38
  } );
39
- expect( activator ).toHaveAttribute( 'aria-disabled', 'true' );
39
+ expect( activator ).toBeNull();
40
40
  expect( resizeHandle ).not.toBeNull();
41
41
  } );
42
42
 
@@ -5,6 +5,7 @@ import type {
5
5
  ResizeDelta,
6
6
  ResizeHandleRenderProps,
7
7
  } from '../shared/types';
8
+ import type { ColumnSteps } from '../shared/column-policy';
8
9
  import type { ResizeSnapSize } from '../shared/resize-snap';
9
10
 
10
11
  /**
@@ -188,7 +189,8 @@ export type GridItemProps = {
188
189
  * the grid root.
189
190
  *
190
191
  * `columns` and `minColumnWidth` compose as a layered model:
191
- * - `columns` alone: fixed N columns; each tile scales with the container.
192
+ * - `columns` alone: the count at every width, or a count per container
193
+ * width when given as `ColumnSteps`; each tile scales with the container.
192
194
  * - `minColumnWidth` alone: column count derives from container width,
193
195
  * floored by the per-tile minimum, down to 1 column.
194
196
  * - Both together: `columns` caps the count, `minColumnWidth` enforces a
@@ -295,11 +297,13 @@ export interface DashboardGridProps extends Omit<
295
297
  renderGridOverlay?: React.ComponentType< GridOverlayRenderProps >;
296
298
 
297
299
  /**
298
- * Target column count, used as a cap. Defaults to six when neither
299
- * `columns` nor `minColumnWidth` is set; with `minColumnWidth` set
300
- * it can resolve lower on narrow containers.
300
+ * Column count, used as a cap. A number applies at every width; a
301
+ * `ColumnSteps` map applies a count from each container width up, and
302
+ * an `'auto'` step lifts the cap from its width up.
303
+ * Defaults to six when neither `columns` nor `minColumnWidth` is set;
304
+ * with `minColumnWidth` set it can resolve lower on narrow containers.
301
305
  */
302
- columns?: number;
306
+ columns?: number | ColumnSteps;
303
307
 
304
308
  /**
305
309
  * Per-tile minimum width in pixels. Enables responsive mode: the
@@ -26,6 +26,7 @@ import {
26
26
  import { LanesItem } from './lanes-item';
27
27
  import { useLanePlacement } from './use-lane-placement';
28
28
  import { arrayMoveWithPinned } from '../shared/array-move-with-pinned';
29
+ import { resolveColumnCount } from '../shared/column-policy';
29
30
  import { GridOverlay } from '../shared/grid-overlay';
30
31
  import { clampSpan, gridSpanToPixelSize } from '../shared/resize-snap';
31
32
  import { useResizePixelLimits, useSpanBounds } from '../shared/use-span-bounds';
@@ -177,17 +178,16 @@ export const DashboardLanes = forwardRef< HTMLDivElement, DashboardLanesProps >(
177
178
  setGapPx( parsed );
178
179
  }
179
180
  }, [ container ] );
180
- const effectiveColumns = useMemo( () => {
181
- if ( ! minColumnWidth ) {
182
- return columns ?? DEFAULT_COLUMNS;
183
- }
184
- const totalWidthPerColumn = minColumnWidth + gapPx;
185
- const maxFit = Math.max(
186
- 1,
187
- Math.floor( ( containerWidth + gapPx ) / totalWidthPerColumn )
188
- );
189
- return columns !== undefined ? Math.min( columns, maxFit ) : maxFit;
190
- }, [ minColumnWidth, gapPx, containerWidth, columns ] );
181
+ const effectiveColumns = useMemo(
182
+ () =>
183
+ resolveColumnCount(
184
+ { columns, minColumnWidth },
185
+ containerWidth,
186
+ gapPx,
187
+ DEFAULT_COLUMNS
188
+ ),
189
+ [ minColumnWidth, gapPx, containerWidth, columns ]
190
+ );
191
191
  const columnWidth =
192
192
  ( containerWidth - ( effectiveColumns - 1 ) * gapPx ) /
193
193
  effectiveColumns;
@@ -224,7 +224,7 @@ export function LanesItem( {
224
224
 
225
225
  <div
226
226
  ref={ setActivatorNodeRef }
227
- { ...attributes }
227
+ { ...( dragDisabled ? {} : attributes ) }
228
228
  { ...listeners }
229
229
  style={ {
230
230
  height: '100%',