@wordpress/grid 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build-types/grid-item.d.ts +3 -0
- package/build-types/grid-item.d.ts.map +1 -0
- package/build-types/grid.d.ts +34 -0
- package/build-types/grid.d.ts.map +1 -0
- package/build-types/resize-handle.d.ts +23 -0
- package/build-types/resize-handle.d.ts.map +1 -0
- package/build-types/resolve-fill-widths.d.ts +26 -0
- package/build-types/resolve-fill-widths.d.ts.map +1 -0
- package/build-types/stories/index.story.d.ts +50 -0
- package/build-types/stories/index.story.d.ts.map +1 -0
- package/build-types/types.d.ts +266 -0
- package/build-types/types.d.ts.map +1 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { GridItemProps } from './types';
|
|
2
|
+
export declare function GridItem({ item, maxColumns, disabled, verticalResizable, interacting, children, actionableArea, onResize, onResizeEnd, renderResizeHandle }: GridItemProps): import("react").JSX.Element;
|
|
3
|
+
//# sourceMappingURL=grid-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid-item.d.ts","sourceRoot":"","sources":["../src/grid-item.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,SAAS,CAAC;AAkB1D,wBAAgB,QAAQ,CAAE,EACzB,IAAI,EACJ,UAAU,EACV,QAAgB,EAChB,iBAAwB,EACxB,WAAmB,EACnB,QAAQ,EACR,cAAqB,EACrB,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,EAAE,aAAa,+BA+Lf"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DashboardGridProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 2D packed dashboard grid with drag-to-reorder and resize handles.
|
|
4
|
+
* Supports fixed-column and responsive modes, `number | 'fill' | 'full'`
|
|
5
|
+
* widths, and multi-row tiles.
|
|
6
|
+
*
|
|
7
|
+
* Each child's `key` must match an entry in the `layout` array;
|
|
8
|
+
* children without a match are rendered outside the grid.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* const layout = [
|
|
13
|
+
* { key: 'a', width: 2 },
|
|
14
|
+
* { key: 'b', width: 'fill' },
|
|
15
|
+
* { key: 'c', width: 'full' },
|
|
16
|
+
* ];
|
|
17
|
+
*
|
|
18
|
+
* <DashboardGrid
|
|
19
|
+
* layout={ layout }
|
|
20
|
+
* columns={ 6 }
|
|
21
|
+
* editMode
|
|
22
|
+
* onChangeLayout={ setLayout }
|
|
23
|
+
* >
|
|
24
|
+
* <div key="a">A</div>
|
|
25
|
+
* <div key="b">B</div>
|
|
26
|
+
* <div key="c">C</div>
|
|
27
|
+
* </DashboardGrid>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param props Component props.
|
|
31
|
+
* @param ref Forwarded to the grid's root `<div>`.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DashboardGrid: import("react").ForwardRefExoticComponent<DashboardGridProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
34
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../src/grid.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAEX,kBAAkB,EAElB,MAAM,SAAS,CAAC;AAUjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,+GA8azB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ResizeHandleProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Renders a corner resize handle inside an isolated `<DndContext>`.
|
|
7
|
+
* Reports the cursor offset since the gesture started (in pixels)
|
|
8
|
+
* via `onResize`, throttled to one animation frame so the grid
|
|
9
|
+
* commit loop runs at most once per paint.
|
|
10
|
+
*
|
|
11
|
+
* Auto-scroll is enabled with a tight trigger zone and a low
|
|
12
|
+
* acceleration so a resize gesture near the viewport edge scrolls
|
|
13
|
+
* the page only when the user deliberately pushes against the very
|
|
14
|
+
* edge, and even then at a pace the user can interrupt by releasing.
|
|
15
|
+
* Default tuning would otherwise produce a runaway loop where the
|
|
16
|
+
* page scrolls fast, dnd-kit's document-coordinate `delta` inflates
|
|
17
|
+
* with the scroll, and the tile keeps growing without further user
|
|
18
|
+
* input.
|
|
19
|
+
*
|
|
20
|
+
* @param props Component props.
|
|
21
|
+
*/
|
|
22
|
+
export default function ResizeHandleWrapper(props: ResizeHandleProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=resize-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resize-handle.d.ts","sourceRoot":"","sources":["../src/resize-handle.tsx"],"names":[],"mappings":"AAaA;;GAEG;AACH,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAgE9D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAE,KAAK,EAAE,iBAAiB,+BAyCpE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { DashboardGridLayoutItem } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Resolves items with `width: 'fill'` by computing how many columns they
|
|
7
|
+
* should span. Simulates CSS Grid's row-sparse auto-flow placement so the
|
|
8
|
+
* resolved span matches the free run that CSS Grid will actually use.
|
|
9
|
+
*
|
|
10
|
+
* Two paths:
|
|
11
|
+
* - Fast path (no `height > 1` items): single-row column tracker, O(n).
|
|
12
|
+
* Each fixed item between two fills is visited at most once by a fill's
|
|
13
|
+
* look-ahead.
|
|
14
|
+
* - Multi-row path (any item with `height > 1`): per-column skyline that
|
|
15
|
+
* tracks shadow occupation of tall tiles. Placement scans rows in
|
|
16
|
+
* row-major order, so worst-case cost depends on both columns and rows
|
|
17
|
+
* scanned (rows bounded by the sum of item heights), not only on
|
|
18
|
+
* `maxColumns`.
|
|
19
|
+
*
|
|
20
|
+
* @param sortedKeys - Item keys in display order.
|
|
21
|
+
* @param layoutMap - Map of key to DashboardGridLayoutItem.
|
|
22
|
+
* @param maxColumns - Total columns in the grid.
|
|
23
|
+
* @return Map of fill item keys to their resolved column spans.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveFillWidths(sortedKeys: string[], layoutMap: Map<string, DashboardGridLayoutItem>, maxColumns: number): Map<string, number>;
|
|
26
|
+
//# sourceMappingURL=resolve-fill-widths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-fill-widths.d.ts","sourceRoot":"","sources":["../src/resolve-fill-widths.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAChC,UAAU,EAAE,MAAM,EAAE,EACpB,SAAS,EAAE,GAAG,CAAE,MAAM,EAAE,uBAAuB,CAAE,EACjD,UAAU,EAAE,MAAM,GAChB,GAAG,CAAE,MAAM,EAAE,MAAM,CAAE,CAkMvB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { DashboardGrid } from '../grid';
|
|
9
|
+
declare const meta: Meta<typeof DashboardGrid>;
|
|
10
|
+
export default meta;
|
|
11
|
+
type Story = StoryObj<typeof DashboardGrid>;
|
|
12
|
+
/**
|
|
13
|
+
* Static grid with a fixed number of columns. Each item declares its
|
|
14
|
+
* column span via `width`. Items flow left-to-right and wrap to new
|
|
15
|
+
* rows as the total exceeds `columns`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const Default: Story;
|
|
18
|
+
/**
|
|
19
|
+
* Responsive grid: the column count is derived from the container
|
|
20
|
+
* width using `minColumnWidth` as the lower bound per column. A
|
|
21
|
+
* `ResizeObserver` recomputes the count on container resize.
|
|
22
|
+
*/
|
|
23
|
+
export declare const Responsive: Story;
|
|
24
|
+
/**
|
|
25
|
+
* A `width: 'fill'` item expands to cover the remaining columns in
|
|
26
|
+
* its row. Mix it with fixed-width items on either side to build
|
|
27
|
+
* sidebar-like layouts that adapt to the column count.
|
|
28
|
+
*/
|
|
29
|
+
export declare const FillWidth: Story;
|
|
30
|
+
/**
|
|
31
|
+
* A `width: 'full'` item spans every column (`grid-column: 1 / -1`),
|
|
32
|
+
* forcing a row break around it. Useful for dividers, hero banners,
|
|
33
|
+
* or embedded content that should always take the full width.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FullWidth: Story;
|
|
36
|
+
/**
|
|
37
|
+
* Numeric `rowHeight` lets items span multiple rows via `height`.
|
|
38
|
+
* Combined with `width`, this produces tile-based dashboards where
|
|
39
|
+
* each cell can be tuned independently.
|
|
40
|
+
*/
|
|
41
|
+
export declare const RowHeight: Story;
|
|
42
|
+
/**
|
|
43
|
+
* Edit mode with drag, resize, and all width modes. A state panel
|
|
44
|
+
* shows the raw layout JSON. Drag items to reorder; resize from the
|
|
45
|
+
* bottom-right handle. Keyboard sensor is enabled: use Tab to focus
|
|
46
|
+
* an item, Space to grab, arrow keys to move, Space to drop.
|
|
47
|
+
*/
|
|
48
|
+
export declare const EditMode: Story;
|
|
49
|
+
export declare const CustomResizeHandleStory: Story;
|
|
50
|
+
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../src/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAU5D;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAMxC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,aAAa,CA4CrC,CAAC;eACa,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,aAAa,CAAE,CAAC;AA8L9C;;;;GAIG;AACH,eAAO,MAAM,OAAO,EAAE,KA4BrB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAiCxB,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;AAgEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,EAAE,KAyKtB,CAAC;AAyDF,eAAO,MAAM,uBAAuB,EAAE,KAoDrC,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { useDraggable } from '@dnd-kit/core';
|
|
5
|
+
type DraggableBindings = ReturnType<typeof useDraggable>;
|
|
6
|
+
/**
|
|
7
|
+
* Cursor offset reported by the resize handle, in pixels relative to
|
|
8
|
+
* the gesture start. Width and height are independent so the grid can
|
|
9
|
+
* step columns and rows separately.
|
|
10
|
+
*/
|
|
11
|
+
export type ResizeDelta = {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Dashboard grid layout item definition.
|
|
17
|
+
*
|
|
18
|
+
* `width` accepts either a numeric column span or a discriminated string:
|
|
19
|
+
* - `number` spans that many columns (clamped to the grid's column count).
|
|
20
|
+
* - `'fill'` spans the remaining columns in the current row.
|
|
21
|
+
* - `'full'` spans all columns (`grid-column: 1 / -1`).
|
|
22
|
+
*/
|
|
23
|
+
export type DashboardGridLayoutItem = {
|
|
24
|
+
/**
|
|
25
|
+
* Unique key that matches a child component key.
|
|
26
|
+
*/
|
|
27
|
+
key: string;
|
|
28
|
+
/**
|
|
29
|
+
* Number of columns this item spans, or a string discriminator
|
|
30
|
+
* (`'fill'` or `'full'`).
|
|
31
|
+
*/
|
|
32
|
+
width?: number | 'fill' | 'full';
|
|
33
|
+
/**
|
|
34
|
+
* Number of rows this item spans.
|
|
35
|
+
*
|
|
36
|
+
* @default 1
|
|
37
|
+
*/
|
|
38
|
+
height?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Display order for the item. Lower values render first. When
|
|
41
|
+
* omitted, the item falls back to its index in the `layout` array.
|
|
42
|
+
*/
|
|
43
|
+
order?: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Props received by a custom resize handle component. Spread `listeners`
|
|
47
|
+
* and `attributes` onto the element that should respond to the gesture,
|
|
48
|
+
* and assign `ref` to the same element so dnd-kit can track it.
|
|
49
|
+
*/
|
|
50
|
+
export interface ResizeHandleRenderProps {
|
|
51
|
+
/**
|
|
52
|
+
* Ref callback to attach to the gesture-bearing element.
|
|
53
|
+
*/
|
|
54
|
+
ref: DraggableBindings['setNodeRef'];
|
|
55
|
+
/**
|
|
56
|
+
* Pointer/keyboard event listeners that initiate the drag.
|
|
57
|
+
*/
|
|
58
|
+
listeners: DraggableBindings['listeners'];
|
|
59
|
+
/**
|
|
60
|
+
* Accessibility and dnd-kit attributes (role, aria-*, tabIndex…).
|
|
61
|
+
*/
|
|
62
|
+
attributes: DraggableBindings['attributes'];
|
|
63
|
+
/**
|
|
64
|
+
* Whether vertical resizing is allowed for this tile. Useful for
|
|
65
|
+
* adapting the cursor or visual cue.
|
|
66
|
+
*/
|
|
67
|
+
verticalResizable: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* True while the user is actively dragging this handle. Use it to
|
|
70
|
+
* swap colors, icons, or transforms during the gesture.
|
|
71
|
+
*/
|
|
72
|
+
isResizing: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Owning grid item's `key`. Available so consumers can render
|
|
75
|
+
* per-tile content if needed.
|
|
76
|
+
*/
|
|
77
|
+
itemId?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Props for the internal `<ResizeHandle />` wrapper.
|
|
81
|
+
*/
|
|
82
|
+
export interface ResizeHandleProps {
|
|
83
|
+
/**
|
|
84
|
+
* Owning grid item's `key`. Forwarded as `data.itemId` on the
|
|
85
|
+
* draggable so the parent can correlate the gesture with a tile
|
|
86
|
+
* if needed.
|
|
87
|
+
*/
|
|
88
|
+
itemId?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Whether the handle should track vertical movement. When false,
|
|
91
|
+
* the handle still appears but only emits horizontal deltas, and
|
|
92
|
+
* the cursor is constrained to the column resize axis.
|
|
93
|
+
*
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
verticalResizable?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Callback fired while the handle is being dragged. Receives the
|
|
99
|
+
* cursor offset from the gesture start in pixels.
|
|
100
|
+
*/
|
|
101
|
+
onResize?: (delta: ResizeDelta) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Callback fired when the gesture ends.
|
|
104
|
+
*/
|
|
105
|
+
onResizeEnd?: () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Component that overrides the default corner triangle with a
|
|
108
|
+
* custom element. Receives gesture wiring (`ref`, `listeners`,
|
|
109
|
+
* `attributes`) plus context. The grid keeps ownership of the
|
|
110
|
+
* `<DndContext>` and the throttled delta loop; consumers are only
|
|
111
|
+
* responsible for the visual.
|
|
112
|
+
*/
|
|
113
|
+
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Props for the internal `<GridItem />` wrapper.
|
|
117
|
+
*/
|
|
118
|
+
export type GridItemProps = {
|
|
119
|
+
/**
|
|
120
|
+
* The layout item containing grid positioning information.
|
|
121
|
+
*/
|
|
122
|
+
item: DashboardGridLayoutItem;
|
|
123
|
+
/**
|
|
124
|
+
* The maximum number of columns in the grid.
|
|
125
|
+
*/
|
|
126
|
+
maxColumns: number;
|
|
127
|
+
/**
|
|
128
|
+
* Whether drag and resize interactions are disabled.
|
|
129
|
+
*
|
|
130
|
+
* @default false
|
|
131
|
+
*/
|
|
132
|
+
disabled?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Whether the item can be resized vertically. Disabled when the
|
|
135
|
+
* grid uses `rowHeight: 'auto'`, where row height is driven by
|
|
136
|
+
* content rather than by the user.
|
|
137
|
+
*
|
|
138
|
+
* @default true
|
|
139
|
+
*/
|
|
140
|
+
verticalResizable?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Whether any tile in the grid is currently being dragged or
|
|
143
|
+
* resized. When true, the item mutes its `actionableArea` with
|
|
144
|
+
* `inert` so pointer hovers over buttons in other tiles do not
|
|
145
|
+
* steal the in-progress gesture.
|
|
146
|
+
*
|
|
147
|
+
* @default false
|
|
148
|
+
*/
|
|
149
|
+
interacting?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* The content to be displayed within the grid item.
|
|
152
|
+
*/
|
|
153
|
+
children: React.ReactNode;
|
|
154
|
+
/**
|
|
155
|
+
* Content rendered above the draggable area that stays interactive
|
|
156
|
+
* in edit mode — typically action buttons, menus, or links. While
|
|
157
|
+
* any tile in the grid is being dragged or resized, this content
|
|
158
|
+
* is set `inert` so hovers on other tiles can't steal the gesture.
|
|
159
|
+
*/
|
|
160
|
+
actionableArea?: React.ReactNode;
|
|
161
|
+
/**
|
|
162
|
+
* Callback fired while the item is being resized. Receives the
|
|
163
|
+
* item's `key` plus the cursor offset from the gesture start in
|
|
164
|
+
* pixels; the grid converts the offset to column/row spans.
|
|
165
|
+
*/
|
|
166
|
+
onResize: (id: string, delta: ResizeDelta) => void;
|
|
167
|
+
/**
|
|
168
|
+
* Callback fired when the resize gesture ends.
|
|
169
|
+
*/
|
|
170
|
+
onResizeEnd: () => void;
|
|
171
|
+
/**
|
|
172
|
+
* Component forwarded to `<ResizeHandle />` to override the default
|
|
173
|
+
* corner triangle. See `DashboardGridProps.renderResizeHandle`.
|
|
174
|
+
*/
|
|
175
|
+
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Props shared by fixed and responsive DashboardGrid variants. Extends
|
|
179
|
+
* the standard div props so consumers can pass `id`, `aria-*`, `data-*`,
|
|
180
|
+
* event handlers, etc., directly on the grid root.
|
|
181
|
+
*/
|
|
182
|
+
interface BaseDashboardGridProps extends Omit<React.ComponentPropsWithoutRef<'div'>, 'children' | 'className' | 'style'> {
|
|
183
|
+
/**
|
|
184
|
+
* Array of layout items.
|
|
185
|
+
*/
|
|
186
|
+
layout: DashboardGridLayoutItem[];
|
|
187
|
+
/**
|
|
188
|
+
* Grid children. Each child must carry a `key` that matches an
|
|
189
|
+
* entry in `layout`; children without a match are rendered outside
|
|
190
|
+
* the grid.
|
|
191
|
+
*/
|
|
192
|
+
children: React.ReactNode;
|
|
193
|
+
/**
|
|
194
|
+
* Additional CSS class on the grid root.
|
|
195
|
+
*/
|
|
196
|
+
className?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Inline styles applied to the grid root. Merged underneath the
|
|
199
|
+
* grid's own layout styles, so the layout (`gridTemplateColumns`,
|
|
200
|
+
* `gridAutoRows`, `gap`) always wins.
|
|
201
|
+
*/
|
|
202
|
+
style?: React.CSSProperties;
|
|
203
|
+
/**
|
|
204
|
+
* Grid gap multiplier size (e.g., a spacing of 2 results in a gap
|
|
205
|
+
* of 8px, it's multiplied by 4).
|
|
206
|
+
*
|
|
207
|
+
* @default 2
|
|
208
|
+
*/
|
|
209
|
+
spacing?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Height of each row in pixels, or `'auto'` to let the tallest
|
|
212
|
+
* tile in the row size it.
|
|
213
|
+
*
|
|
214
|
+
* @default 'auto'
|
|
215
|
+
*/
|
|
216
|
+
rowHeight?: number | 'auto';
|
|
217
|
+
/**
|
|
218
|
+
* Whether the grid is in edit mode (allows dragging and
|
|
219
|
+
* repositioning items).
|
|
220
|
+
*
|
|
221
|
+
* @default false
|
|
222
|
+
*/
|
|
223
|
+
editMode?: boolean;
|
|
224
|
+
/**
|
|
225
|
+
* Callback fired when the user commits a drag or resize. Receives
|
|
226
|
+
* the resulting layout.
|
|
227
|
+
*/
|
|
228
|
+
onChangeLayout?: (newLayout: DashboardGridLayoutItem[]) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Callback fired continuously during a drag or resize interaction
|
|
231
|
+
* with the in-progress layout. Useful for live feedback in the
|
|
232
|
+
* surface (e.g., displaying the current width/position). The final
|
|
233
|
+
* committed layout is still emitted via `onChangeLayout`.
|
|
234
|
+
*/
|
|
235
|
+
onPreviewLayout?: (previewLayout: DashboardGridLayoutItem[]) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Override the default corner-triangle resize handle with a custom
|
|
238
|
+
* component. The grid still owns the gesture (dnd-kit `<DndContext>`,
|
|
239
|
+
* throttled delta loop) and passes the wiring to the consumer:
|
|
240
|
+
* spread `listeners` and `attributes` and assign `ref` on the
|
|
241
|
+
* element that should receive the gesture. Use `disabled` and
|
|
242
|
+
* `verticalResizable` to adapt the visual to context.
|
|
243
|
+
*/
|
|
244
|
+
renderResizeHandle?: React.ComponentType<ResizeHandleRenderProps>;
|
|
245
|
+
}
|
|
246
|
+
interface FixedDashboardGridProps extends BaseDashboardGridProps {
|
|
247
|
+
/**
|
|
248
|
+
* Total number of columns in the grid.
|
|
249
|
+
*
|
|
250
|
+
* @default 6
|
|
251
|
+
*/
|
|
252
|
+
columns: number;
|
|
253
|
+
minColumnWidth?: never;
|
|
254
|
+
}
|
|
255
|
+
interface ResponsiveDashboardGridProps extends BaseDashboardGridProps {
|
|
256
|
+
/**
|
|
257
|
+
* Minimum width in pixels per column. Enables responsive mode:
|
|
258
|
+
* the column count is derived from container width, down to a
|
|
259
|
+
* minimum of 1 column. Mutually exclusive with `columns`.
|
|
260
|
+
*/
|
|
261
|
+
minColumnWidth?: number;
|
|
262
|
+
columns?: never;
|
|
263
|
+
}
|
|
264
|
+
export type DashboardGridProps = FixedDashboardGridProps | ResponsiveDashboardGridProps;
|
|
265
|
+
export {};
|
|
266
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -49,18 +49,18 @@
|
|
|
49
49
|
"@dnd-kit/core": "^6.3.1",
|
|
50
50
|
"@dnd-kit/sortable": "^10.0.0",
|
|
51
51
|
"@dnd-kit/utilities": "^3.2.2",
|
|
52
|
-
"@wordpress/compose": "^8.
|
|
53
|
-
"@wordpress/element": "^8.
|
|
54
|
-
"@wordpress/style-runtime": "^0.
|
|
52
|
+
"@wordpress/compose": "^8.5.0",
|
|
53
|
+
"@wordpress/element": "^8.4.0",
|
|
54
|
+
"@wordpress/style-runtime": "^0.8.0",
|
|
55
55
|
"clsx": "^2.1.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@storybook/react-vite": "^10.4.3",
|
|
59
59
|
"@testing-library/dom": "^10.4.1",
|
|
60
60
|
"@testing-library/react": "^16.3.2",
|
|
61
|
-
"@types/jest": "^
|
|
62
|
-
"@wordpress/icons": "^15.
|
|
63
|
-
"@wordpress/ui": "^0.
|
|
61
|
+
"@types/jest": "^30.0.0",
|
|
62
|
+
"@wordpress/icons": "^15.3.0",
|
|
63
|
+
"@wordpress/ui": "^0.19.0",
|
|
64
64
|
"storybook": "^10.4.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"publishConfig": {
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "7e8b17a983f9391d3ebc7717af2a1c9ed7efc7ab"
|
|
80
80
|
}
|