@wordpress/grid 0.1.1-next.v.202606191442.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 (158) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE.md +788 -0
  3. package/README.md +534 -0
  4. package/build/dashboard-grid/grid-item.cjs +308 -0
  5. package/build/dashboard-grid/grid-item.cjs.map +7 -0
  6. package/build/dashboard-grid/index.cjs +591 -0
  7. package/build/dashboard-grid/index.cjs.map +7 -0
  8. package/build/dashboard-grid/resolve-fill-widths.cjs +189 -0
  9. package/build/dashboard-grid/resolve-fill-widths.cjs.map +7 -0
  10. package/build/dashboard-grid/types.cjs +19 -0
  11. package/build/dashboard-grid/types.cjs.map +7 -0
  12. package/build/dashboard-lanes/index.cjs +558 -0
  13. package/build/dashboard-lanes/index.cjs.map +7 -0
  14. package/build/dashboard-lanes/lane-placement.cjs +110 -0
  15. package/build/dashboard-lanes/lane-placement.cjs.map +7 -0
  16. package/build/dashboard-lanes/lanes-item.cjs +295 -0
  17. package/build/dashboard-lanes/lanes-item.cjs.map +7 -0
  18. package/build/dashboard-lanes/types.cjs +19 -0
  19. package/build/dashboard-lanes/types.cjs.map +7 -0
  20. package/build/dashboard-lanes/use-lane-placement.cjs +206 -0
  21. package/build/dashboard-lanes/use-lane-placement.cjs.map +7 -0
  22. package/build/index.cjs +34 -0
  23. package/build/index.cjs.map +7 -0
  24. package/build/shared/drag-overlay-drop-animation.cjs +70 -0
  25. package/build/shared/drag-overlay-drop-animation.cjs.map +7 -0
  26. package/build/shared/grid-item-key.cjs +31 -0
  27. package/build/shared/grid-item-key.cjs.map +7 -0
  28. package/build/shared/grid-overlay.cjs +187 -0
  29. package/build/shared/grid-overlay.cjs.map +7 -0
  30. package/build/shared/item-exit-overlay.cjs +150 -0
  31. package/build/shared/item-exit-overlay.cjs.map +7 -0
  32. package/build/shared/resize-handle.cjs +224 -0
  33. package/build/shared/resize-handle.cjs.map +7 -0
  34. package/build/shared/resize-snap.cjs +47 -0
  35. package/build/shared/resize-snap.cjs.map +7 -0
  36. package/build/shared/types.cjs +19 -0
  37. package/build/shared/types.cjs.map +7 -0
  38. package/build/shared/use-item-exit-animation.cjs +148 -0
  39. package/build/shared/use-item-exit-animation.cjs.map +7 -0
  40. package/build/shared/use-layout-shift-animation.cjs +167 -0
  41. package/build/shared/use-layout-shift-animation.cjs.map +7 -0
  42. package/build-module/dashboard-grid/grid-item.mjs +273 -0
  43. package/build-module/dashboard-grid/grid-item.mjs.map +7 -0
  44. package/build-module/dashboard-grid/index.mjs +579 -0
  45. package/build-module/dashboard-grid/index.mjs.map +7 -0
  46. package/build-module/dashboard-grid/resolve-fill-widths.mjs +164 -0
  47. package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +7 -0
  48. package/build-module/dashboard-grid/types.mjs +1 -0
  49. package/build-module/dashboard-grid/types.mjs.map +7 -0
  50. package/build-module/dashboard-lanes/index.mjs +547 -0
  51. package/build-module/dashboard-lanes/index.mjs.map +7 -0
  52. package/build-module/dashboard-lanes/lane-placement.mjs +85 -0
  53. package/build-module/dashboard-lanes/lane-placement.mjs.map +7 -0
  54. package/build-module/dashboard-lanes/lanes-item.mjs +260 -0
  55. package/build-module/dashboard-lanes/lanes-item.mjs.map +7 -0
  56. package/build-module/dashboard-lanes/types.mjs +1 -0
  57. package/build-module/dashboard-lanes/types.mjs.map +7 -0
  58. package/build-module/dashboard-lanes/use-lane-placement.mjs +181 -0
  59. package/build-module/dashboard-lanes/use-lane-placement.mjs.map +7 -0
  60. package/build-module/index.mjs +8 -0
  61. package/build-module/index.mjs.map +7 -0
  62. package/build-module/shared/drag-overlay-drop-animation.mjs +47 -0
  63. package/build-module/shared/drag-overlay-drop-animation.mjs.map +7 -0
  64. package/build-module/shared/grid-item-key.mjs +6 -0
  65. package/build-module/shared/grid-item-key.mjs.map +7 -0
  66. package/build-module/shared/grid-overlay.mjs +152 -0
  67. package/build-module/shared/grid-overlay.mjs.map +7 -0
  68. package/build-module/shared/item-exit-overlay.mjs +125 -0
  69. package/build-module/shared/item-exit-overlay.mjs.map +7 -0
  70. package/build-module/shared/resize-handle.mjs +193 -0
  71. package/build-module/shared/resize-handle.mjs.map +7 -0
  72. package/build-module/shared/resize-snap.mjs +21 -0
  73. package/build-module/shared/resize-snap.mjs.map +7 -0
  74. package/build-module/shared/types.mjs +1 -0
  75. package/build-module/shared/types.mjs.map +7 -0
  76. package/build-module/shared/use-item-exit-animation.mjs +128 -0
  77. package/build-module/shared/use-item-exit-animation.mjs.map +7 -0
  78. package/build-module/shared/use-layout-shift-animation.mjs +140 -0
  79. package/build-module/shared/use-layout-shift-animation.mjs.map +7 -0
  80. package/build-types/dashboard-grid/grid-item.d.ts +3 -0
  81. package/build-types/dashboard-grid/grid-item.d.ts.map +1 -0
  82. package/build-types/dashboard-grid/index.d.ts +35 -0
  83. package/build-types/dashboard-grid/index.d.ts.map +1 -0
  84. package/build-types/dashboard-grid/resolve-fill-widths.d.ts +26 -0
  85. package/build-types/dashboard-grid/resolve-fill-widths.d.ts.map +1 -0
  86. package/build-types/dashboard-grid/stories/index.story.d.ts +98 -0
  87. package/build-types/dashboard-grid/stories/index.story.d.ts.map +1 -0
  88. package/build-types/dashboard-grid/types.d.ts +232 -0
  89. package/build-types/dashboard-grid/types.d.ts.map +1 -0
  90. package/build-types/dashboard-lanes/index.d.ts +40 -0
  91. package/build-types/dashboard-lanes/index.d.ts.map +1 -0
  92. package/build-types/dashboard-lanes/lane-placement.d.ts +126 -0
  93. package/build-types/dashboard-lanes/lane-placement.d.ts.map +1 -0
  94. package/build-types/dashboard-lanes/lanes-item.d.ts +52 -0
  95. package/build-types/dashboard-lanes/lanes-item.d.ts.map +1 -0
  96. package/build-types/dashboard-lanes/stories/index.story.d.ts +64 -0
  97. package/build-types/dashboard-lanes/stories/index.story.d.ts.map +1 -0
  98. package/build-types/dashboard-lanes/types.d.ts +151 -0
  99. package/build-types/dashboard-lanes/types.d.ts.map +1 -0
  100. package/build-types/dashboard-lanes/use-lane-placement.d.ts +74 -0
  101. package/build-types/dashboard-lanes/use-lane-placement.d.ts.map +1 -0
  102. package/build-types/index.d.ts +6 -0
  103. package/build-types/index.d.ts.map +1 -0
  104. package/build-types/shared/drag-overlay-drop-animation.d.ts +13 -0
  105. package/build-types/shared/drag-overlay-drop-animation.d.ts.map +1 -0
  106. package/build-types/shared/grid-item-key.d.ts +6 -0
  107. package/build-types/shared/grid-item-key.d.ts.map +1 -0
  108. package/build-types/shared/grid-overlay.d.ts +19 -0
  109. package/build-types/shared/grid-overlay.d.ts.map +1 -0
  110. package/build-types/shared/item-exit-overlay.d.ts +20 -0
  111. package/build-types/shared/item-exit-overlay.d.ts.map +1 -0
  112. package/build-types/shared/resize-handle.d.ts +23 -0
  113. package/build-types/shared/resize-handle.d.ts.map +1 -0
  114. package/build-types/shared/resize-snap.d.ts +41 -0
  115. package/build-types/shared/resize-snap.d.ts.map +1 -0
  116. package/build-types/shared/types.d.ts +144 -0
  117. package/build-types/shared/types.d.ts.map +1 -0
  118. package/build-types/shared/use-item-exit-animation.d.ts +37 -0
  119. package/build-types/shared/use-item-exit-animation.d.ts.map +1 -0
  120. package/build-types/shared/use-layout-shift-animation.d.ts +77 -0
  121. package/build-types/shared/use-layout-shift-animation.d.ts.map +1 -0
  122. package/package.json +80 -0
  123. package/src/dashboard-grid/grid-item.module.css +94 -0
  124. package/src/dashboard-grid/grid-item.tsx +205 -0
  125. package/src/dashboard-grid/grid.module.css +134 -0
  126. package/src/dashboard-grid/index.tsx +713 -0
  127. package/src/dashboard-grid/resolve-fill-widths.ts +224 -0
  128. package/src/dashboard-grid/stories/index.story.tsx +930 -0
  129. package/src/dashboard-grid/test/keyboard-activation.test.tsx +76 -0
  130. package/src/dashboard-grid/test/resolve-fill-widths.test.ts +250 -0
  131. package/src/dashboard-grid/types.ts +271 -0
  132. package/src/dashboard-lanes/index.tsx +629 -0
  133. package/src/dashboard-lanes/lane-placement.ts +245 -0
  134. package/src/dashboard-lanes/lanes-item.module.css +93 -0
  135. package/src/dashboard-lanes/lanes-item.tsx +236 -0
  136. package/src/dashboard-lanes/lanes.module.css +152 -0
  137. package/src/dashboard-lanes/stories/index.story.tsx +518 -0
  138. package/src/dashboard-lanes/test/keyboard-activation.test.tsx +71 -0
  139. package/src/dashboard-lanes/test/lane-placement.test.ts +442 -0
  140. package/src/dashboard-lanes/test/use-lane-placement.test.tsx +358 -0
  141. package/src/dashboard-lanes/types.ts +176 -0
  142. package/src/dashboard-lanes/use-lane-placement.ts +313 -0
  143. package/src/index.ts +17 -0
  144. package/src/shared/actionable-area-slot.module.css +16 -0
  145. package/src/shared/drag-overlay-drop-animation.ts +66 -0
  146. package/src/shared/grid-item-key.ts +5 -0
  147. package/src/shared/grid-overlay.module.css +82 -0
  148. package/src/shared/grid-overlay.tsx +93 -0
  149. package/src/shared/item-exit-animation.module.css +49 -0
  150. package/src/shared/item-exit-overlay.tsx +57 -0
  151. package/src/shared/layout-shift-animation.module.css +16 -0
  152. package/src/shared/resize-handle.module.css +88 -0
  153. package/src/shared/resize-handle.tsx +163 -0
  154. package/src/shared/resize-snap.ts +63 -0
  155. package/src/shared/test/resize-snap.test.ts +35 -0
  156. package/src/shared/types.ts +164 -0
  157. package/src/shared/use-item-exit-animation.ts +199 -0
  158. package/src/shared/use-layout-shift-animation.ts +284 -0
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { DragPreviewRenderProps, GridOverlayRenderProps, ResizeDelta, ResizeHandleRenderProps } from '../shared/types';
5
+ import type { ResizeSnapSize } from '../shared/resize-snap';
6
+ /**
7
+ * Dashboard grid layout item definition.
8
+ *
9
+ * `width` accepts either a numeric column span or a discriminated string:
10
+ * - `number` spans that many columns (clamped to the grid's column count).
11
+ * - `'fill'` spans the remaining columns in the current row.
12
+ * - `'full'` spans all columns (`grid-column: 1 / -1`).
13
+ */
14
+ export type DashboardGridLayoutItem = {
15
+ /**
16
+ * Unique key that matches a child component key.
17
+ */
18
+ key: string;
19
+ /**
20
+ * Number of columns this item spans, or a string discriminator
21
+ * (`'fill'` or `'full'`).
22
+ */
23
+ width?: number | 'fill' | 'full';
24
+ /**
25
+ * Number of rows this item spans.
26
+ *
27
+ * @default 1
28
+ */
29
+ height?: number;
30
+ /**
31
+ * Display order for the item. Lower values render first. When
32
+ * omitted, the item falls back to its index in the `layout` array.
33
+ */
34
+ order?: number;
35
+ };
36
+ /**
37
+ * Props for the internal `<GridItem />` wrapper.
38
+ */
39
+ export type GridItemProps = {
40
+ /**
41
+ * The layout item containing grid positioning information.
42
+ */
43
+ item: DashboardGridLayoutItem;
44
+ /**
45
+ * The maximum number of columns in the grid.
46
+ */
47
+ maxColumns: number;
48
+ /**
49
+ * Whether drag and resize interactions are disabled.
50
+ *
51
+ * @default false
52
+ */
53
+ disabled?: boolean;
54
+ /**
55
+ * Whether the item can be resized vertically. Disabled when the
56
+ * grid uses `rowHeight: 'auto'`, where row height is driven by
57
+ * content rather than by the user.
58
+ *
59
+ * @default true
60
+ */
61
+ verticalResizable?: boolean;
62
+ /**
63
+ * Whether any tile in the grid is currently being dragged or
64
+ * resized. Drives the drag activator cursor.
65
+ *
66
+ * @default false
67
+ */
68
+ interacting?: boolean;
69
+ /**
70
+ * Whether a tile drag is in progress. Mutes each tile's
71
+ * `actionableArea` with `inert` so hovers on other tiles' controls
72
+ * do not steal the gesture.
73
+ *
74
+ * @default false
75
+ */
76
+ dragging?: boolean;
77
+ /**
78
+ * The content to be displayed within the grid item.
79
+ */
80
+ children: React.ReactNode;
81
+ /**
82
+ * Content rendered above the draggable area that stays interactive
83
+ * in edit mode, typically action buttons, menus, or links. While
84
+ * a tile drag is in progress, this content is set `inert` so hovers
85
+ * on other tiles can't steal the gesture. During resize, visibility
86
+ * is controlled by grid-level CSS hooks.
87
+ */
88
+ actionableArea?: React.ReactNode;
89
+ /**
90
+ * Callback fired while the item is being resized. Receives the
91
+ * item's `key` plus the cursor offset from the gesture start in
92
+ * pixels. The grid derives snapped spans from the delta and passes
93
+ * them back through `resizeSnapPreview`.
94
+ */
95
+ onResize: (id: string, delta: ResizeDelta) => void;
96
+ /**
97
+ * Snapped grid size in pixels for the resize-preview outline. The
98
+ * tile content resizes continuously with the cursor; this outline
99
+ * shows the span the layout will commit to on release.
100
+ */
101
+ resizeSnapPreview?: ResizeSnapSize | null;
102
+ /**
103
+ * Minimum tile width while resizing, in pixels (one column track).
104
+ */
105
+ minResizeWidthPx: number;
106
+ /**
107
+ * Minimum tile height while resizing, in pixels (one row track).
108
+ * Omitted when vertical resize is disabled.
109
+ */
110
+ minResizeHeightPx?: number;
111
+ /**
112
+ * Callback fired when the resize gesture ends.
113
+ */
114
+ onResizeEnd: () => void;
115
+ /**
116
+ * Component forwarded to `<ResizeHandle />` to override the default
117
+ * corner triangle. See `DashboardGridProps.renderResizeHandle`.
118
+ */
119
+ renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
120
+ };
121
+ /**
122
+ * Props for `DashboardGrid`. Extends the standard div props so consumers
123
+ * can pass `id`, `aria-*`, `data-*`, event handlers, etc., directly on
124
+ * the grid root.
125
+ *
126
+ * `columns` and `minColumnWidth` compose as a layered model:
127
+ * - `columns` alone: fixed N columns; each tile scales with the container.
128
+ * - `minColumnWidth` alone: column count derives from container width,
129
+ * floored by the per-tile minimum, down to 1 column.
130
+ * - Both together: `columns` caps the count, `minColumnWidth` enforces a
131
+ * per-tile width floor that can reduce the count below the cap on
132
+ * narrow containers ("up to N columns, but never narrower than W px").
133
+ */
134
+ export interface DashboardGridProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'className' | 'style'> {
135
+ /**
136
+ * Array of layout items.
137
+ */
138
+ layout: DashboardGridLayoutItem[];
139
+ /**
140
+ * Grid children. Each child must carry a `key` that matches an
141
+ * entry in `layout`; children without a match render at the end
142
+ * of the grid without explicit placement and fall through CSS
143
+ * Grid's auto-flow.
144
+ */
145
+ children: React.ReactNode;
146
+ /**
147
+ * Additional CSS class on the grid root.
148
+ */
149
+ className?: string;
150
+ /**
151
+ * Inline styles applied to the grid root. Merged underneath the
152
+ * grid's own layout styles, so the layout (`gridTemplateColumns`,
153
+ * `gridAutoRows`) always wins. The gap between tiles is owned by
154
+ * the design-system gap token and is not configurable per
155
+ * instance; override it via a theme or density change.
156
+ */
157
+ style?: React.CSSProperties;
158
+ /**
159
+ * Height of each row in pixels, or `'auto'` to let the tallest
160
+ * tile in the row size it.
161
+ *
162
+ * @default 'auto'
163
+ */
164
+ rowHeight?: number | 'auto';
165
+ /**
166
+ * Whether the grid is in edit mode (allows dragging and
167
+ * repositioning items).
168
+ *
169
+ * @default false
170
+ */
171
+ editMode?: boolean;
172
+ /**
173
+ * Callback fired when the user commits a drag or resize. Receives
174
+ * the resulting layout.
175
+ */
176
+ onChangeLayout?: (newLayout: DashboardGridLayoutItem[]) => void;
177
+ /**
178
+ * Callback fired continuously during a drag or resize interaction
179
+ * with the in-progress layout. Useful for live feedback in the
180
+ * surface (e.g., displaying the current width/position). The final
181
+ * committed layout is still emitted via `onChangeLayout`.
182
+ */
183
+ onPreviewLayout?: (previewLayout: DashboardGridLayoutItem[]) => void;
184
+ /**
185
+ * Override the default corner-triangle resize handle with a custom
186
+ * component. The grid still owns the gesture (dnd-kit `<DndContext>`,
187
+ * throttled delta loop) and passes the wiring to the consumer:
188
+ * spread `listeners` and `attributes` and assign `ref` on the
189
+ * element that should receive the gesture. Use `disabled` and
190
+ * `verticalResizable` to adapt the visual to context.
191
+ */
192
+ renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
193
+ /**
194
+ * Custom wrapper for the dragged-clone visual mounted inside
195
+ * `<DragOverlay>`. The surface always wraps the clone with a thin
196
+ * functional frame (lift scale, grabbing cursor, pointer pass-
197
+ * through) and mounts this component inside it; the consumer
198
+ * owns the visual chrome (shadow, radius, padding).
199
+ *
200
+ * When omitted, the cloned children render directly inside the
201
+ * functional frame so any chrome the consumer applied to the
202
+ * persistent tile carries through unchanged.
203
+ *
204
+ * Token-only adjustments (lift scale, placeholder opacity,
205
+ * outline color, placeholder radius) flow through CSS custom
206
+ * properties documented in the README.
207
+ */
208
+ renderDragPreview?: React.ComponentType<DragPreviewRenderProps>;
209
+ /**
210
+ * Override the default edit-mode overlay (row-marker tiles per
211
+ * column) with a custom component. The grid supplies the resolved
212
+ * column count, row height, and row count; the consumer is
213
+ * responsible for the visual.
214
+ *
215
+ * The overlay only renders when `editMode` is true. When omitted,
216
+ * the package's default visual is used.
217
+ */
218
+ renderGridOverlay?: React.ComponentType<GridOverlayRenderProps>;
219
+ /**
220
+ * Target column count, used as a cap. Defaults to six when neither
221
+ * `columns` nor `minColumnWidth` is set; with `minColumnWidth` set
222
+ * it can resolve lower on narrow containers.
223
+ */
224
+ columns?: number;
225
+ /**
226
+ * Per-tile minimum width in pixels. Enables responsive mode: the
227
+ * column count derives from container width, floored by this value,
228
+ * down to 1.
229
+ */
230
+ minColumnWidth?: number;
231
+ }
232
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dashboard-grid/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,40 @@
1
+ import type { DashboardLanesProps } from './types';
2
+ /**
3
+ * Masonry-style surface aligned with `display: grid-lanes`. Items
4
+ * declare a column span; heights are driven by content; placement
5
+ * follows the source-ordered, shortest-lane algorithm with
6
+ * `flow-tolerance` tiebreaking.
7
+ *
8
+ * On browsers that support `display: grid-lanes` natively, the
9
+ * component emits the spec's CSS and lets the engine handle layout.
10
+ * Otherwise, `useLanePlacement` measures item heights and assigns
11
+ * explicit `grid-column-start` / `grid-row-start` values that
12
+ * approximate the same result inside CSS Grid.
13
+ *
14
+ * Each child's `key` must match an entry in the `layout` array;
15
+ * children without a match render at the end of the surface without
16
+ * explicit placement and fall through the lanes auto-flow.
17
+ *
18
+ * @example
19
+ * ```jsx
20
+ * <DashboardLanes
21
+ * layout={ [
22
+ * { key: 'a' },
23
+ * { key: 'b', width: 2 },
24
+ * { key: 'c' },
25
+ * ] }
26
+ * columns={ 3 }
27
+ * editMode
28
+ * onChangeLayout={ setLayout }
29
+ * >
30
+ * <Tile key="a">A</Tile>
31
+ * <Tile key="b">B</Tile>
32
+ * <Tile key="c">C</Tile>
33
+ * </DashboardLanes>
34
+ * ```
35
+ *
36
+ * @param props Component props.
37
+ * @param ref Forwarded to the surface's root `<div>`.
38
+ */
39
+ export declare const DashboardLanes: import("react").ForwardRefExoticComponent<DashboardLanesProps & import("react").RefAttributes<HTMLDivElement>>;
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/index.tsx"],"names":[],"mappings":"AAiDA,OAAO,KAAK,EAA4B,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAyB7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,cAAc,gHAqgB1B,CAAC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Lane placement algorithm for `display: grid-lanes` polyfill.
3
+ *
4
+ * Implements the source-ordered, shortest-lane placement described in
5
+ * https://webkit.org/blog/17660/introducing-css-grid-lanes/.
6
+ *
7
+ * The skyline + tolerance core is adapted from the CSS Grid Lanes
8
+ * Polyfill by Simon Willison (MIT,
9
+ * https://tools.simonwillison.net/grid-lanes-polyfill.js). The rest
10
+ * of this module is a pure function suitable for unit testing in
11
+ * isolation from any DOM.
12
+ *
13
+ * Concepts:
14
+ * - "Lane" is the cross-axis track: a column in waterfall mode, a row
15
+ * in brick mode. The algorithm is axis-agnostic; the renderer maps
16
+ * the chosen lane index plus offset to `grid-column-start` /
17
+ * `grid-row-start` (or vice versa).
18
+ * - Items are placed in source order. Explicit-lane items are placed
19
+ * first so auto-placed items can flow around them.
20
+ * - `flowTolerance` is a length: when two candidate lanes differ in
21
+ * baseline by no more than this, the earlier lane wins (preserves
22
+ * reading order).
23
+ */
24
+ /**
25
+ * A single item to place. Heights are pre-measured by the caller.
26
+ */
27
+ export type LanePlacementItem = {
28
+ /**
29
+ * Stable identity. Returned in the result map.
30
+ */
31
+ key: string;
32
+ /**
33
+ * Number of contiguous lanes this item occupies. Clamped to
34
+ * `[ 1, lanes ]` by the algorithm.
35
+ */
36
+ span: number;
37
+ /**
38
+ * Measured cross-axis size (typically pixels). The algorithm only
39
+ * adds and compares heights; the unit is whatever the caller uses,
40
+ * as long as `gap` and `flowTolerance` use the same one.
41
+ */
42
+ height: number;
43
+ /**
44
+ * Explicit 0-indexed starting lane. When set, the item bypasses
45
+ * the skyline lookup and is placed at this lane regardless of
46
+ * source order. Out-of-range values are clamped.
47
+ */
48
+ lane?: number;
49
+ };
50
+ /**
51
+ * Algorithm input.
52
+ */
53
+ export type LanePlacementInput = {
54
+ /**
55
+ * Items in source order.
56
+ */
57
+ items: ReadonlyArray<LanePlacementItem>;
58
+ /**
59
+ * Total number of lanes. Clamped to `>= 1`.
60
+ */
61
+ lanes: number;
62
+ /**
63
+ * Gap between items in the same lane. Same unit as `height`.
64
+ */
65
+ gap: number;
66
+ /**
67
+ * Tolerance for source-order tiebreaking. When two candidate
68
+ * lanes have baselines within this amount, the earlier lane wins.
69
+ * Defaults to `0` if a negative value is passed.
70
+ */
71
+ flowTolerance: number;
72
+ };
73
+ /**
74
+ * Resolved position for a single item.
75
+ */
76
+ export type LanePlacement = {
77
+ /**
78
+ * Mirrors the input key.
79
+ */
80
+ key: string;
81
+ /**
82
+ * 0-indexed starting lane. The renderer adds 1 for
83
+ * `grid-column-start`.
84
+ */
85
+ lane: number;
86
+ /**
87
+ * Cross-axis offset from the container's start edge, in the same
88
+ * unit as the input heights. Use as the item's start position
89
+ * (e.g. `top`, or `grid-row-start` after dividing by a row unit).
90
+ */
91
+ top: number;
92
+ /**
93
+ * Effective span after clamping. Useful for the renderer when the
94
+ * input span exceeded the lane count.
95
+ */
96
+ span: number;
97
+ };
98
+ /**
99
+ * Algorithm output.
100
+ */
101
+ export type LanePlacementResult = {
102
+ /**
103
+ * Per-key placement. Insertion-ordered: the first iteration yields
104
+ * the explicit items in source order, then the auto items in
105
+ * source order.
106
+ */
107
+ placements: Map<string, LanePlacement>;
108
+ /**
109
+ * Sum of the tallest lane after all items are placed. The renderer
110
+ * applies this as the container's intrinsic height.
111
+ */
112
+ totalHeight: number;
113
+ };
114
+ /**
115
+ * Places all items into a fixed lane count using the grid-lanes
116
+ * algorithm: explicit items first, then auto items chosen by the
117
+ * shortest-lane skyline with a tolerance for source order.
118
+ *
119
+ * Pure: no DOM access, no mutation of inputs. Safe to call from a
120
+ * worker or during SSR.
121
+ *
122
+ * @param input Items, lane count, gap, and tolerance.
123
+ * @return Per-key placements plus the resulting total height.
124
+ */
125
+ export declare function computeLanePlacements(input: LanePlacementInput): LanePlacementResult;
126
+ //# sourceMappingURL=lane-placement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lane-placement.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/lane-placement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC;;OAEG;IACH,KAAK,EAAE,aAAa,CAAE,iBAAiB,CAAE,CAAC;IAE1C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,aAAa,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC;;;;OAIG;IACH,UAAU,EAAE,GAAG,CAAE,MAAM,EAAE,aAAa,CAAE,CAAC;IAEzC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACpB,CAAC;AA8BF;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,kBAAkB,GACvB,mBAAmB,CA2ErB"}
@@ -0,0 +1,52 @@
1
+ import { type ResizeSnapSize } from '../shared/resize-snap';
2
+ import type { ResizeDelta, ResizeHandleRenderProps } from '../shared/types';
3
+ /**
4
+ * Props for the internal `<LanesItem />` wrapper.
5
+ */
6
+ export type LanesItemProps = {
7
+ /**
8
+ * Item key. Forwarded to dnd-kit and emitted as the
9
+ * `data-wp-grid-item-key` attribute the hook reads to map measured DOM
10
+ * nodes back to logical items.
11
+ */
12
+ itemKey: string;
13
+ /**
14
+ * Inline placement style produced by `useLanePlacement`. On native
15
+ * (`display: grid-lanes`), only `gridColumn: span N`. While
16
+ * polyfilling, also `gridColumnStart` / `gridRowStart` /
17
+ * `gridRowEnd: span N`.
18
+ */
19
+ placementStyle: React.CSSProperties;
20
+ /**
21
+ * Whether drag and resize interactions are disabled.
22
+ */
23
+ disabled?: boolean;
24
+ /**
25
+ * Whether any tile in the surface is currently being dragged or
26
+ * resized. Drives the drag activator cursor.
27
+ */
28
+ interacting?: boolean;
29
+ /**
30
+ * Whether a tile drag is in progress. Mutes each tile's
31
+ * `actionableArea` with `inert` so hovers on other tiles' controls
32
+ * do not steal the gesture.
33
+ *
34
+ * @default false
35
+ */
36
+ dragging?: boolean;
37
+ children: React.ReactNode;
38
+ actionableArea?: React.ReactNode;
39
+ onResize: (id: string, delta: ResizeDelta) => void;
40
+ /**
41
+ * Snapped column span in pixels for the resize-preview outline.
42
+ */
43
+ resizeSnapPreview?: ResizeSnapSize | null;
44
+ /**
45
+ * Minimum tile width while resizing, in pixels (one column track).
46
+ */
47
+ minResizeWidthPx: number;
48
+ onResizeEnd: () => void;
49
+ renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
50
+ };
51
+ export declare function LanesItem({ itemKey, placementStyle, disabled, interacting, children, actionableArea, onResize, onResizeEnd, resizeSnapPreview, minResizeWidthPx, renderResizeHandle, dragging }: LanesItemProps): import("react").JSX.Element;
52
+ //# sourceMappingURL=lanes-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lanes-item.d.ts","sourceRoot":"","sources":["../../src/dashboard-lanes/lanes-item.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAoB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAgB5E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC5B;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAE1B,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAEjC,QAAQ,EAAE,CAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,KAAM,IAAI,CAAC;IAErD;;OAEG;IACH,iBAAiB,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB,kBAAkB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,uBAAuB,CAAE,CAAC;CACpE,CAAC;AAEF,wBAAgB,SAAS,CAAE,EAC1B,OAAO,EACP,cAAc,EACd,QAAgB,EAChB,WAAmB,EACnB,QAAQ,EACR,cAAqB,EACrB,QAAQ,EACR,WAAW,EACX,iBAAwB,EACxB,gBAAgB,EAChB,kBAAkB,EAClB,QAAgB,EAChB,EAAE,cAAc,+BA+HhB"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import type { Meta, StoryObj } from '@storybook/react-vite';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { DashboardLanes } from '..';
9
+ declare const meta: Meta<typeof DashboardLanes>;
10
+ export default meta;
11
+ type Story = StoryObj<typeof DashboardLanes>;
12
+ /**
13
+ * Mixed-height tiles in a fixed lane count. Items pack from
14
+ * left-to-right by source order, falling into whichever lane has
15
+ * the lowest baseline at the moment of placement.
16
+ */
17
+ export declare const Default: Story;
18
+ /**
19
+ * Responsive lane count: derived from container width using
20
+ * `minColumnWidth` as the per-lane lower bound. Resize the preview
21
+ * frame to see the lane count adapt.
22
+ */
23
+ export declare const Responsive: Story;
24
+ /**
25
+ * Layered configuration: `columns` caps the lane count and
26
+ * `minColumnWidth` enforces a per-tile width floor. The surface
27
+ * renders up to `columns` lanes on wide containers and reduces the
28
+ * count on narrow ones whenever fitting all of them would push
29
+ * tiles below `minColumnWidth`.
30
+ */
31
+ export declare const Layered: Story;
32
+ /**
33
+ * Items with `width: 2` span two lanes. The skyline picks a span
34
+ * position that minimizes the resulting baseline across spanned
35
+ * lanes.
36
+ */
37
+ export declare const Spanning: Story;
38
+ /**
39
+ * Edit mode: drag to reorder, resize from the bottom-right corner
40
+ * (horizontal only — heights are content-driven). Drop commits the
41
+ * new layout via `onChangeLayout`.
42
+ *
43
+ * While `editMode` is on, `<DashboardLanes />` paints its default
44
+ * overlay behind the tiles to mark the lane tracks. Lanes paint
45
+ * columns only — there are no row markers because heights are
46
+ * content-driven.
47
+ *
48
+ * Theme the default look in place via `--wp-grid-overlay-tile-bg`,
49
+ * or replace the visual wholesale
50
+ * by passing `renderGridOverlay`. See the `Custom Grid Overlay`
51
+ * story below for a full override example.
52
+ */
53
+ export declare const EditMode: Story;
54
+ /**
55
+ * Replaces the surface's default edit-mode overlay with a custom
56
+ * visual through the `renderGridOverlay` prop. The same contract as
57
+ * `<DashboardGrid />`'s override path, with `rowHeight` omitted from
58
+ * the render props because lanes are content-driven vertically.
59
+ *
60
+ * Pass `renderGridOverlay={ () => null }` to suppress the overlay
61
+ * entirely while keeping `editMode` interactions on.
62
+ */
63
+ export declare const CustomGridOverlayStory: Story;
64
+ //# sourceMappingURL=index.story.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/dashboard-lanes/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAO5D;;GAEG;AACH,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"}