@wordpress/grid 0.5.0 → 0.7.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 (94) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +44 -1
  3. package/build/dashboard-grid/grid-item.cjs +21 -7
  4. package/build/dashboard-grid/grid-item.cjs.map +2 -2
  5. package/build/dashboard-grid/index.cjs +110 -48
  6. package/build/dashboard-grid/index.cjs.map +2 -2
  7. package/build/dashboard-grid/resolve-fill-widths.cjs +68 -50
  8. package/build/dashboard-grid/resolve-fill-widths.cjs.map +2 -2
  9. package/build/dashboard-grid/types.cjs.map +1 -1
  10. package/build/dashboard-lanes/index.cjs +62 -20
  11. package/build/dashboard-lanes/index.cjs.map +2 -2
  12. package/build/dashboard-lanes/lanes-item.cjs +14 -6
  13. package/build/dashboard-lanes/lanes-item.cjs.map +2 -2
  14. package/build/dashboard-lanes/types.cjs.map +1 -1
  15. package/build/index.cjs.map +1 -1
  16. package/build/shared/array-move-with-pinned.cjs +49 -0
  17. package/build/shared/array-move-with-pinned.cjs.map +7 -0
  18. package/build/shared/resize-snap.cjs +91 -5
  19. package/build/shared/resize-snap.cjs.map +2 -2
  20. package/build/shared/types.cjs.map +1 -1
  21. package/build/shared/use-span-bounds.cjs +85 -0
  22. package/build/shared/use-span-bounds.cjs.map +7 -0
  23. package/build-module/dashboard-grid/grid-item.mjs +21 -7
  24. package/build-module/dashboard-grid/grid-item.mjs.map +2 -2
  25. package/build-module/dashboard-grid/index.mjs +111 -50
  26. package/build-module/dashboard-grid/index.mjs.map +2 -2
  27. package/build-module/dashboard-grid/resolve-fill-widths.mjs +68 -50
  28. package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +2 -2
  29. package/build-module/dashboard-lanes/index.mjs +63 -22
  30. package/build-module/dashboard-lanes/index.mjs.map +2 -2
  31. package/build-module/dashboard-lanes/lanes-item.mjs +14 -6
  32. package/build-module/dashboard-lanes/lanes-item.mjs.map +2 -2
  33. package/build-module/index.mjs.map +1 -1
  34. package/build-module/shared/array-move-with-pinned.mjs +24 -0
  35. package/build-module/shared/array-move-with-pinned.mjs.map +7 -0
  36. package/build-module/shared/resize-snap.mjs +87 -4
  37. package/build-module/shared/resize-snap.mjs.map +2 -2
  38. package/build-module/shared/use-span-bounds.mjs +62 -0
  39. package/build-module/shared/use-span-bounds.mjs.map +7 -0
  40. package/build-types/dashboard-grid/grid-item.d.ts +1 -1
  41. package/build-types/dashboard-grid/grid-item.d.ts.map +1 -1
  42. package/build-types/dashboard-grid/index.d.ts.map +1 -1
  43. package/build-types/dashboard-grid/resolve-fill-widths.d.ts +12 -1
  44. package/build-types/dashboard-grid/resolve-fill-widths.d.ts.map +1 -1
  45. package/build-types/dashboard-grid/types.d.ts +43 -1
  46. package/build-types/dashboard-grid/types.d.ts.map +1 -1
  47. package/build-types/dashboard-lanes/index.d.ts.map +1 -1
  48. package/build-types/dashboard-lanes/lanes-item.d.ts +18 -1
  49. package/build-types/dashboard-lanes/lanes-item.d.ts.map +1 -1
  50. package/build-types/dashboard-lanes/types.d.ts +20 -1
  51. package/build-types/dashboard-lanes/types.d.ts.map +1 -1
  52. package/build-types/index.d.ts +1 -1
  53. package/build-types/index.d.ts.map +1 -1
  54. package/build-types/shared/array-move-with-pinned.d.ts +13 -0
  55. package/build-types/shared/array-move-with-pinned.d.ts.map +1 -0
  56. package/build-types/shared/resize-snap.d.ts +65 -2
  57. package/build-types/shared/resize-snap.d.ts.map +1 -1
  58. package/build-types/shared/types.d.ts +31 -0
  59. package/build-types/shared/types.d.ts.map +1 -1
  60. package/build-types/shared/use-span-bounds.d.ts +29 -0
  61. package/build-types/shared/use-span-bounds.d.ts.map +1 -0
  62. package/package.json +12 -11
  63. package/src/dashboard-grid/grid-item.tsx +21 -7
  64. package/src/dashboard-grid/grid.module.css +6 -6
  65. package/src/dashboard-grid/index.tsx +155 -58
  66. package/src/dashboard-grid/resolve-fill-widths.ts +85 -62
  67. package/src/dashboard-grid/stories/index.story.tsx +169 -0
  68. package/src/dashboard-grid/test/item-interactions.jsdom.test.tsx +64 -0
  69. package/src/dashboard-grid/test/item-limits.jsdom.test.tsx +147 -0
  70. package/src/dashboard-grid/test/{keyboard-activation.test.tsx → keyboard-activation.jsdom.test.tsx} +4 -3
  71. package/src/dashboard-grid/test/resolve-fill-widths.test.ts +159 -0
  72. package/src/dashboard-grid/types.ts +50 -0
  73. package/src/dashboard-lanes/index.tsx +87 -25
  74. package/src/dashboard-lanes/lanes-item.tsx +34 -6
  75. package/src/dashboard-lanes/lanes.module.css +6 -6
  76. package/src/dashboard-lanes/stories/index.story.tsx +144 -0
  77. package/src/dashboard-lanes/test/item-interactions.jsdom.test.tsx +64 -0
  78. package/src/dashboard-lanes/test/item-limits.jsdom.test.tsx +140 -0
  79. package/src/dashboard-lanes/test/{keyboard-activation.test.tsx → keyboard-activation.jsdom.test.tsx} +4 -3
  80. package/src/dashboard-lanes/test/lane-placement.test.ts +1 -0
  81. package/src/dashboard-lanes/test/{use-lane-placement.test.tsx → use-lane-placement.jsdom.test.tsx} +21 -13
  82. package/src/dashboard-lanes/types.ts +23 -0
  83. package/src/index.ts +2 -0
  84. package/src/shared/array-move-with-pinned.ts +36 -0
  85. package/src/shared/resize-snap.ts +161 -5
  86. package/src/shared/test/array-move-with-pinned.test.ts +40 -0
  87. package/src/shared/test/resize-snap.test.ts +171 -2
  88. package/src/shared/test/use-span-bounds.jsdom.test.ts +105 -0
  89. package/src/shared/types.ts +35 -0
  90. package/src/shared/use-span-bounds.ts +99 -0
  91. package/build-types/dashboard-grid/stories/index.story.d.ts +0 -92
  92. package/build-types/dashboard-grid/stories/index.story.d.ts.map +0 -1
  93. package/build-types/dashboard-lanes/stories/index.story.d.ts +0 -58
  94. package/build-types/dashboard-lanes/stories/index.story.d.ts.map +0 -1
@@ -1,4 +1,10 @@
1
- import { clampResizeDelta, gridSpanToPixelSize } from '../resize-snap';
1
+ import { describe, expect, it } from 'vitest';
2
+ import {
3
+ clampResizeDelta,
4
+ clampSpan,
5
+ gridSpanToPixelSize,
6
+ pixelLimitsToSpanBounds,
7
+ } from '../resize-snap';
2
8
 
3
9
  describe( 'gridSpanToPixelSize', () => {
4
10
  it( 'returns one column track width for a single-column span', () => {
@@ -8,6 +14,139 @@ describe( 'gridSpanToPixelSize', () => {
8
14
  } );
9
15
  } );
10
16
 
17
+ describe( 'pixelLimitsToSpanBounds', () => {
18
+ it( 'rounds minimums up to whole tracks', () => {
19
+ expect(
20
+ pixelLimitsToSpanBounds( { minWidth: 480 }, 292, 24, 300, 4 )
21
+ ).toEqual( {
22
+ minWidth: 2,
23
+ minHeight: 1,
24
+ maxWidth: 4,
25
+ maxHeight: Infinity,
26
+ } );
27
+ } );
28
+
29
+ it( 'covers both minimum axes when a row height is known', () => {
30
+ expect(
31
+ pixelLimitsToSpanBounds(
32
+ { minWidth: 480, minHeight: 360 },
33
+ 292,
34
+ 24,
35
+ 300,
36
+ 4
37
+ )
38
+ ).toEqual( {
39
+ minWidth: 2,
40
+ minHeight: 2,
41
+ maxWidth: 4,
42
+ maxHeight: Infinity,
43
+ } );
44
+ } );
45
+
46
+ it( 'rounds maximums down to whole tracks', () => {
47
+ expect(
48
+ pixelLimitsToSpanBounds( { maxWidth: 700 }, 292, 24, null, 4 )
49
+ ).toEqual( {
50
+ minWidth: 1,
51
+ minHeight: 1,
52
+ maxWidth: 2,
53
+ maxHeight: Infinity,
54
+ } );
55
+ } );
56
+
57
+ it( 'keeps a maximum at one track or more', () => {
58
+ expect(
59
+ pixelLimitsToSpanBounds( { maxWidth: 100 }, 292, 24, null, 4 )
60
+ .maxWidth
61
+ ).toBe( 1 );
62
+ } );
63
+
64
+ it( 'lets the minimum win over a tighter maximum', () => {
65
+ expect(
66
+ pixelLimitsToSpanBounds(
67
+ { minWidth: 480, maxWidth: 300 },
68
+ 292,
69
+ 24,
70
+ null,
71
+ 4
72
+ )
73
+ ).toEqual( {
74
+ minWidth: 2,
75
+ minHeight: 1,
76
+ maxWidth: 2,
77
+ maxHeight: Infinity,
78
+ } );
79
+ } );
80
+
81
+ it( 'saturates width bounds at the column count', () => {
82
+ expect(
83
+ pixelLimitsToSpanBounds(
84
+ { minWidth: 4000, maxWidth: 9000 },
85
+ 292,
86
+ 24,
87
+ null,
88
+ 4
89
+ )
90
+ ).toEqual( {
91
+ minWidth: 4,
92
+ minHeight: 1,
93
+ maxWidth: 4,
94
+ maxHeight: Infinity,
95
+ } );
96
+ } );
97
+
98
+ it( 'bounds heights against the row track', () => {
99
+ expect(
100
+ pixelLimitsToSpanBounds(
101
+ { minHeight: 360, maxHeight: 800 },
102
+ 292,
103
+ 24,
104
+ 300,
105
+ 4
106
+ )
107
+ ).toEqual( {
108
+ minWidth: 1,
109
+ minHeight: 2,
110
+ maxWidth: 4,
111
+ maxHeight: 2,
112
+ } );
113
+ } );
114
+
115
+ it( 'leaves height bounds open when rows are content-sized', () => {
116
+ expect(
117
+ pixelLimitsToSpanBounds(
118
+ { minHeight: 360, maxHeight: 600 },
119
+ 292,
120
+ 24,
121
+ null,
122
+ 4
123
+ )
124
+ ).toEqual( {
125
+ minWidth: 1,
126
+ minHeight: 1,
127
+ maxWidth: 4,
128
+ maxHeight: Infinity,
129
+ } );
130
+ } );
131
+
132
+ it( 'falls back to the full range while the surface is unmeasured', () => {
133
+ expect(
134
+ pixelLimitsToSpanBounds(
135
+ { minWidth: 480, maxWidth: 600 },
136
+ 0,
137
+ 24,
138
+ null,
139
+ 4
140
+ )
141
+ ).toEqual( {
142
+ minWidth: 1,
143
+ minHeight: 1,
144
+ maxWidth: 4,
145
+ maxHeight: Infinity,
146
+ } );
147
+ } );
148
+ } );
149
+
11
150
  describe( 'clampResizeDelta', () => {
12
151
  it( 'does not shrink width below one column', () => {
13
152
  const initial = { width: 216, height: 120 };
@@ -25,11 +164,41 @@ describe( 'clampResizeDelta', () => {
25
164
  ).toEqual( { width: 0, height: -96 } );
26
165
  } );
27
166
 
28
- it( 'leaves growth deltas unchanged', () => {
167
+ it( 'leaves growth deltas unchanged without a maximum', () => {
29
168
  const initial = { width: 100, height: 48 };
30
169
  const min = { width: 100, height: 48 };
31
170
  expect(
32
171
  clampResizeDelta( { width: 80, height: 40 }, initial, min )
33
172
  ).toEqual( { width: 80, height: 40 } );
34
173
  } );
174
+
175
+ it( 'does not grow width past the maximum', () => {
176
+ const initial = { width: 216, height: 120 };
177
+ const min = { width: 100 };
178
+ const max = { width: 300 };
179
+ expect(
180
+ clampResizeDelta( { width: 200, height: 0 }, initial, min, max )
181
+ ).toEqual( { width: 84, height: 0 } );
182
+ } );
183
+
184
+ it( 'does not grow height past the maximum when one applies', () => {
185
+ const initial = { width: 200, height: 144 };
186
+ const min = { width: 100, height: 48 };
187
+ const max = { width: 400, height: 200 };
188
+ expect(
189
+ clampResizeDelta( { width: 0, height: 120 }, initial, min, max )
190
+ ).toEqual( { width: 0, height: 56 } );
191
+ } );
192
+ } );
193
+
194
+ describe( 'clampSpan', () => {
195
+ it( 'keeps a span inside the inclusive range', () => {
196
+ expect( clampSpan( 0, 1, 4 ) ).toBe( 1 );
197
+ expect( clampSpan( 3, 1, 4 ) ).toBe( 3 );
198
+ expect( clampSpan( 9, 1, 4 ) ).toBe( 4 );
199
+ } );
200
+
201
+ it( 'treats an infinite maximum as open', () => {
202
+ expect( clampSpan( 40, 1, Infinity ) ).toBe( 40 );
203
+ } );
35
204
  } );
@@ -0,0 +1,105 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { renderHook } from '@testing-library/react';
3
+ import { useResizePixelLimits, useSpanBounds } from '../use-span-bounds';
4
+ import type { GridItemLimits } from '../types';
5
+
6
+ type Props = {
7
+ itemLimits?: Record< string, GridItemLimits >;
8
+ columnWidth: number;
9
+ };
10
+
11
+ function renderSpanBounds( initialProps: Props ) {
12
+ return renderHook(
13
+ ( { itemLimits, columnWidth }: Props ) =>
14
+ useSpanBounds( itemLimits, columnWidth, 16, 80, 6 ),
15
+ { initialProps }
16
+ );
17
+ }
18
+
19
+ describe( 'useSpanBounds', () => {
20
+ const itemLimits = { a: { minWidth: 300, maxHeight: 250 } };
21
+
22
+ it( 'quantizes limits to whole tracks', () => {
23
+ const { result } = renderSpanBounds( { itemLimits, columnWidth: 100 } );
24
+ expect( result.current.get( 'a' ) ).toEqual( {
25
+ minWidth: 3,
26
+ minHeight: 1,
27
+ maxWidth: 6,
28
+ maxHeight: 2,
29
+ } );
30
+ } );
31
+
32
+ it( 'keeps the map identity across geometry ticks that leave the bounds unchanged', () => {
33
+ const { result, rerender } = renderSpanBounds( {
34
+ itemLimits,
35
+ columnWidth: 100,
36
+ } );
37
+ const first = result.current;
38
+ rerender( { itemLimits, columnWidth: 101 } );
39
+ expect( result.current ).toBe( first );
40
+ } );
41
+
42
+ it( 'keeps the map identity when an equal itemLimits object is passed', () => {
43
+ const { result, rerender } = renderSpanBounds( {
44
+ itemLimits,
45
+ columnWidth: 100,
46
+ } );
47
+ const first = result.current;
48
+ rerender( { itemLimits: { ...itemLimits }, columnWidth: 100 } );
49
+ expect( result.current ).toBe( first );
50
+ } );
51
+
52
+ it( 'returns a new map once a bound crosses a track threshold', () => {
53
+ const { result, rerender } = renderSpanBounds( {
54
+ itemLimits,
55
+ columnWidth: 100,
56
+ } );
57
+ const first = result.current;
58
+ rerender( { itemLimits, columnWidth: 150 } );
59
+ expect( result.current ).not.toBe( first );
60
+ expect( result.current.get( 'a' )?.minWidth ).toBe( 2 );
61
+ } );
62
+
63
+ it( 'returns a stable empty map without limits', () => {
64
+ const { result, rerender } = renderSpanBounds( { columnWidth: 100 } );
65
+ const first = result.current;
66
+ expect( first.size ).toBe( 0 );
67
+ rerender( { columnWidth: 120 } );
68
+ expect( result.current ).toBe( first );
69
+ } );
70
+ } );
71
+
72
+ describe( 'useResizePixelLimits', () => {
73
+ it( 'converts bounds to pixel limits for the resize gesture', () => {
74
+ const bounds = new Map( [
75
+ [ 'a', { minWidth: 2, minHeight: 1, maxWidth: 4, maxHeight: 3 } ],
76
+ ] );
77
+ const { result } = renderHook( () =>
78
+ useResizePixelLimits( bounds, 100, 16, 80 )
79
+ );
80
+ expect( result.current.get( 'a' ) ).toEqual( {
81
+ minWidthPx: 216,
82
+ minHeightPx: 80,
83
+ maxWidthPx: 448,
84
+ maxHeightPx: 272,
85
+ } );
86
+ } );
87
+
88
+ it( 'leaves the height open when the height bound is open', () => {
89
+ const bounds = new Map( [
90
+ [
91
+ 'a',
92
+ {
93
+ minWidth: 1,
94
+ minHeight: 1,
95
+ maxWidth: 2,
96
+ maxHeight: Infinity,
97
+ },
98
+ ],
99
+ ] );
100
+ const { result } = renderHook( () =>
101
+ useResizePixelLimits( bounds, 100, 16, 80 )
102
+ );
103
+ expect( result.current.get( 'a' )?.maxHeightPx ).toBeNull();
104
+ } );
105
+ } );
@@ -159,3 +159,38 @@ export interface ResizeHandleProps {
159
159
  */
160
160
  renderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;
161
161
  }
162
+
163
+ /**
164
+ * Per-item width limits, in pixels. Surfaces quantize each limit to
165
+ * whole tracks (minimums round up, maximums round down), bound rendered
166
+ * spans and resize gestures at the result, and never write it into the
167
+ * layout. A quantized minimum wins over a smaller quantized maximum.
168
+ */
169
+ export type GridItemWidthLimits = {
170
+ /**
171
+ * Minimum tile width in pixels.
172
+ */
173
+ minWidth?: number;
174
+
175
+ /**
176
+ * Maximum tile width in pixels.
177
+ */
178
+ maxWidth?: number;
179
+ };
180
+
181
+ /**
182
+ * Per-item size limits on both axes, in pixels, for surfaces with row
183
+ * tracks. Height limits quantize against the row track when `rowHeight`
184
+ * is numeric and stay open otherwise.
185
+ */
186
+ export type GridItemLimits = GridItemWidthLimits & {
187
+ /**
188
+ * Minimum tile height in pixels.
189
+ */
190
+ minHeight?: number;
191
+
192
+ /**
193
+ * Maximum tile height in pixels.
194
+ */
195
+ maxHeight?: number;
196
+ };
@@ -0,0 +1,99 @@
1
+ import { useMemo } from '@wordpress/element';
2
+ import {
3
+ pixelLimitsToSpanBounds,
4
+ spanBoundsToPixelLimits,
5
+ } from './resize-snap';
6
+ import type { ResizePixelLimits, SpanBounds } from './resize-snap';
7
+ import type { GridItemLimits } from './types';
8
+
9
+ const NO_BOUNDS: ReadonlyMap< string, SpanBounds > = new Map();
10
+ const NO_LIMITS: ReadonlyMap< string, ResizePixelLimits > = new Map();
11
+
12
+ /**
13
+ * Quantizes per-item pixel limits to span bounds for the current
14
+ * geometry. The map keeps its identity while every bound is unchanged,
15
+ * so container width ticks and fresh `itemLimits` objects do not
16
+ * invalidate the layout memos or the sortable context downstream.
17
+ *
18
+ * @param itemLimits Per-item pixel limits, keyed by layout item key.
19
+ * @param columnWidth Width of one column track in pixels.
20
+ * @param gapPx Gap between tracks in pixels.
21
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
22
+ * are content-sized.
23
+ * @param maxColumns Number of column tracks in the surface.
24
+ */
25
+ export function useSpanBounds(
26
+ itemLimits: Record< string, GridItemLimits > | undefined,
27
+ columnWidth: number,
28
+ gapPx: number,
29
+ rowHeightPx: number | null,
30
+ maxColumns: number
31
+ ): ReadonlyMap< string, SpanBounds > {
32
+ const computed = useMemo( () => {
33
+ if ( ! itemLimits ) {
34
+ return NO_BOUNDS;
35
+ }
36
+ const map = new Map< string, SpanBounds >();
37
+ for ( const [ key, limits ] of Object.entries( itemLimits ) ) {
38
+ map.set(
39
+ key,
40
+ pixelLimitsToSpanBounds(
41
+ limits,
42
+ columnWidth,
43
+ gapPx,
44
+ rowHeightPx,
45
+ maxColumns
46
+ )
47
+ );
48
+ }
49
+ return map;
50
+ }, [ itemLimits, columnWidth, gapPx, rowHeightPx, maxColumns ] );
51
+
52
+ const signature = useMemo( () => {
53
+ let value = '';
54
+ for ( const [ key, bounds ] of computed ) {
55
+ value += `${ key }:${ bounds.minWidth }:${ bounds.minHeight }:${ bounds.maxWidth }:${ bounds.maxHeight }|`;
56
+ }
57
+ return value;
58
+ }, [ computed ] );
59
+
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `signature` encodes every bound; `computed` changes identity on geometry ticks that leave the bounds unchanged.
61
+ return useMemo( () => computed, [ signature ] );
62
+ }
63
+
64
+ /**
65
+ * Pixel limits for the resize gesture of every bounded item. Tracks
66
+ * the continuous geometry, but only recomputes when it changes, not on
67
+ * every gesture frame.
68
+ *
69
+ * @param spanBounds Span bounds per item key.
70
+ * @param columnWidth Width of one column track in pixels.
71
+ * @param gapPx Gap between tracks in pixels.
72
+ * @param rowHeightPx Row track height in pixels, or `null` when rows
73
+ * are content-sized.
74
+ */
75
+ export function useResizePixelLimits(
76
+ spanBounds: ReadonlyMap< string, SpanBounds >,
77
+ columnWidth: number,
78
+ gapPx: number,
79
+ rowHeightPx: number | null
80
+ ): ReadonlyMap< string, ResizePixelLimits > {
81
+ return useMemo( () => {
82
+ if ( spanBounds.size === 0 ) {
83
+ return NO_LIMITS;
84
+ }
85
+ const map = new Map< string, ResizePixelLimits >();
86
+ for ( const [ key, bounds ] of spanBounds ) {
87
+ map.set(
88
+ key,
89
+ spanBoundsToPixelLimits(
90
+ bounds,
91
+ columnWidth,
92
+ gapPx,
93
+ rowHeightPx
94
+ )
95
+ );
96
+ }
97
+ return map;
98
+ }, [ spanBounds, columnWidth, gapPx, rowHeightPx ] );
99
+ }
@@ -1,92 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { DashboardGrid } from '..';
3
- declare const meta: Meta<typeof DashboardGrid>;
4
- export default meta;
5
- type Story = StoryObj<typeof DashboardGrid>;
6
- /**
7
- * Static grid with a fixed number of columns. Each item declares its
8
- * column span via `width`. Items flow left-to-right and wrap to new
9
- * rows as the total exceeds `columns`.
10
- */
11
- export declare const Default: Story;
12
- /**
13
- * Responsive grid: the column count is derived from the container
14
- * width using `minColumnWidth` as the lower bound per column. A
15
- * `ResizeObserver` recomputes the count on container resize.
16
- */
17
- export declare const Responsive: Story;
18
- /**
19
- * Layered configuration: `columns` caps the count and
20
- * `minColumnWidth` enforces a per-tile width floor. The grid renders
21
- * up to `columns` columns on wide containers and reduces the count
22
- * on narrow ones whenever fitting all of them would push tiles
23
- * below `minColumnWidth`. Resize the preview to see the cap apply
24
- * on wide widths and the floor reduce the count on narrow widths.
25
- */
26
- export declare const Layered: Story;
27
- /**
28
- * A `width: 'fill'` item expands to cover the remaining columns in
29
- * its row. Mix it with fixed-width items on either side to build
30
- * sidebar-like layouts that adapt to the column count.
31
- */
32
- export declare const FillWidth: Story;
33
- /**
34
- * A `width: 'full'` item spans every column (`grid-column: 1 / -1`),
35
- * forcing a row break around it. Useful for dividers, hero banners,
36
- * or embedded content that should always take the full width.
37
- */
38
- export declare const FullWidth: Story;
39
- /**
40
- * Numeric `rowHeight` lets items span multiple rows via `height`.
41
- * Combined with `width`, this produces tile-based dashboards where
42
- * each cell can be tuned independently.
43
- */
44
- export declare const RowHeight: Story;
45
- /**
46
- * Edit mode with drag, resize, and all width modes. While `editMode`
47
- * is on, `<DashboardGrid />` paints its default overlay behind the
48
- * tiles to visualize the underlying template: rounded row-marker
49
- * tiles in each column when `rowHeight` is numeric. The overlay
50
- * disappears when `editMode` flips back to `false`.
51
- *
52
- * Theme the default look in place via `--wp-grid-overlay-tile-bg`,
53
- * or replace the visual wholesale by passing `renderGridOverlay`.
54
- * See the `Custom Grid Overlay` story for a full override example.
55
- *
56
- * A state panel shows the raw layout JSON. Drag items to reorder;
57
- * resize from the bottom-right handle. Keyboard sensor is enabled:
58
- * use Tab to focus an item, Space to grab, arrow keys to move, Space
59
- * to drop.
60
- */
61
- export declare const EditMode: Story;
62
- /**
63
- * Exercises the three customization vectors on a single grid:
64
- *
65
- * 1. `renderResizeHandle` swaps the default corner triangle for a
66
- * custom diagonal-arrow icon.
67
- * 2. `renderDragPreview` wraps the dragged clone (here only for the
68
- * height chain; lift and shadow stay on the grid frame).
69
- * 3. CSS custom properties on an ancestor retheme the lift scale,
70
- * placeholder opacity, placeholder outline color, and placeholder
71
- * border-radius without touching the package.
72
- *
73
- * Toggle `editMode`, then drag and resize a tile to see all three
74
- * respond.
75
- */
76
- export declare const Customization: Story;
77
- /**
78
- * Replaces the package's default edit-mode overlay with a custom
79
- * visual through the `renderGridOverlay` prop. The grid mounts the
80
- * supplied component as a sibling behind the tiles whenever
81
- * `editMode` is on, passing the resolved `{ columns, rowHeight }`
82
- * so the override can reproduce the column and row tracks
83
- * pixel-accurately without re-deriving them.
84
- *
85
- * Here the override (see `NumberedOverlay` above) swaps the warning
86
- * tone for info, drops the row dividers, and labels each column
87
- * track with its index. Pass `renderGridOverlay={ () => null }` to
88
- * suppress the overlay entirely while keeping `editMode` interactions
89
- * on.
90
- */
91
- export declare const CustomGridOverlayStory: Story;
92
- //# sourceMappingURL=index.story.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/dashboard-grid/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAQnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CAuCrC,CAAC;eACa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,aAAa,CAAE,CAAC;AAgM9C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KA4BrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAiCxB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAAE,KAkCrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KAwBvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KA4BvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,KA6BvB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,EAAE,KA8JtB,CAAC;AAoEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa,EAAE,KA6D3B,CAAC;AAoEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAmDpC,CAAC"}
@@ -1,58 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react-vite';
2
- import { DashboardLanes } from '..';
3
- declare const meta: Meta<typeof DashboardLanes>;
4
- export default meta;
5
- type Story = StoryObj<typeof DashboardLanes>;
6
- /**
7
- * Mixed-height tiles in a fixed lane count. Items pack from
8
- * left-to-right by source order, falling into whichever lane has
9
- * the lowest baseline at the moment of placement.
10
- */
11
- export declare const Default: Story;
12
- /**
13
- * Responsive lane count: derived from container width using
14
- * `minColumnWidth` as the per-lane lower bound. Resize the preview
15
- * frame to see the lane count adapt.
16
- */
17
- export declare const Responsive: Story;
18
- /**
19
- * Layered configuration: `columns` caps the lane count and
20
- * `minColumnWidth` enforces a per-tile width floor. The surface
21
- * renders up to `columns` lanes on wide containers and reduces the
22
- * count on narrow ones whenever fitting all of them would push
23
- * tiles below `minColumnWidth`.
24
- */
25
- export declare const Layered: Story;
26
- /**
27
- * Items with `width: 2` span two lanes. The skyline picks a span
28
- * position that minimizes the resulting baseline across spanned
29
- * lanes.
30
- */
31
- export declare const Spanning: Story;
32
- /**
33
- * Edit mode: drag to reorder, resize from the bottom-right corner
34
- * (horizontal only — heights are content-driven). Drop commits the
35
- * new layout via `onChangeLayout`.
36
- *
37
- * While `editMode` is on, `<DashboardLanes />` paints its default
38
- * overlay behind the tiles to mark the lane tracks. Lanes paint
39
- * columns only — there are no row markers because heights are
40
- * content-driven.
41
- *
42
- * Theme the default look in place via `--wp-grid-overlay-tile-bg`,
43
- * or replace the visual wholesale
44
- * by passing `renderGridOverlay`. See the `Custom Grid Overlay`
45
- * story below for a full override example.
46
- */
47
- export declare const EditMode: Story;
48
- /**
49
- * Replaces the surface's default edit-mode overlay with a custom
50
- * visual through the `renderGridOverlay` prop. The same contract as
51
- * `<DashboardGrid />`'s override path, with `rowHeight` omitted from
52
- * the render props because lanes are content-driven vertically.
53
- *
54
- * Pass `renderGridOverlay={ () => null }` to suppress the overlay
55
- * entirely while keeping `editMode` interactions on.
56
- */
57
- export declare const CustomGridOverlayStory: Story;
58
- //# sourceMappingURL=index.story.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/dashboard-lanes/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AAIpC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,cAAc,CA6CtC,CAAC;eACa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,cAAc,CAAE,CAAC;AAkF/C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KAwCrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAoBxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,EAAE,KAqBrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,KA0BtB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,QAAQ,EAAE,KAuEtB,CAAC;AAkEF;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAwEpC,CAAC"}