@wordpress/grid 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -14
- package/build/dashboard-grid/grid-item.cjs +232 -295
- package/build/dashboard-grid/grid-item.cjs.map +1 -7
- package/build/dashboard-grid/index.cjs +526 -633
- package/build/dashboard-grid/index.cjs.map +1 -7
- package/build/dashboard-grid/resolve-fill-widths.cjs +159 -203
- package/build/dashboard-grid/resolve-fill-widths.cjs.map +1 -7
- package/build/dashboard-grid/types.cjs +4 -18
- package/build/dashboard-lanes/index.cjs +495 -577
- package/build/dashboard-lanes/index.cjs.map +1 -7
- package/build/dashboard-lanes/lane-placement.cjs +77 -100
- package/build/dashboard-lanes/lane-placement.cjs.map +1 -7
- package/build/dashboard-lanes/lanes-item.cjs +222 -278
- package/build/dashboard-lanes/lanes-item.cjs.map +1 -7
- package/build/dashboard-lanes/types.cjs +4 -18
- package/build/dashboard-lanes/use-lane-placement.cjs +172 -198
- package/build/dashboard-lanes/use-lane-placement.cjs.map +1 -7
- package/build/index.cjs +16 -31
- package/build/shared/array-move-with-pinned.cjs +29 -45
- package/build/shared/array-move-with-pinned.cjs.map +1 -7
- package/build/shared/column-policy.cjs +58 -0
- package/build/shared/column-policy.cjs.map +1 -0
- package/build/shared/drag-overlay-drop-animation.cjs +40 -66
- package/build/shared/drag-overlay-drop-animation.cjs.map +1 -7
- package/build/shared/grid-item-key.cjs +12 -29
- package/build/shared/grid-item-key.cjs.map +1 -7
- package/build/shared/grid-overlay.cjs +163 -164
- package/build/shared/grid-overlay.cjs.map +1 -7
- package/build/shared/item-exit-overlay.cjs +132 -134
- package/build/shared/item-exit-overlay.cjs.map +1 -7
- package/build/shared/resize-handle.cjs +213 -197
- package/build/shared/resize-handle.cjs.map +1 -7
- package/build/shared/resize-snap.cjs +116 -121
- package/build/shared/resize-snap.cjs.map +1 -7
- package/build/shared/types.cjs +4 -18
- package/build/shared/use-item-exit-animation.cjs +96 -143
- package/build/shared/use-item-exit-animation.cjs.map +1 -7
- package/build/shared/use-layout-shift-animation.cjs +121 -150
- package/build/shared/use-layout-shift-animation.cjs.map +1 -7
- package/build/shared/use-span-bounds.cjs +65 -79
- package/build/shared/use-span-bounds.cjs.map +1 -7
- package/build-module/dashboard-grid/grid-item.mjs +209 -265
- package/build-module/dashboard-grid/grid-item.mjs.map +1 -7
- package/build-module/dashboard-grid/index.mjs +502 -623
- package/build-module/dashboard-grid/index.mjs.map +1 -7
- package/build-module/dashboard-grid/resolve-fill-widths.mjs +155 -179
- package/build-module/dashboard-grid/resolve-fill-widths.mjs.map +1 -7
- package/build-module/dashboard-grid/types.mjs +0 -1
- package/build-module/dashboard-lanes/index.mjs +470 -567
- package/build-module/dashboard-lanes/index.mjs.map +1 -7
- package/build-module/dashboard-lanes/lane-placement.mjs +73 -76
- package/build-module/dashboard-lanes/lane-placement.mjs.map +1 -7
- package/build-module/dashboard-lanes/lanes-item.mjs +199 -248
- package/build-module/dashboard-lanes/lanes-item.mjs.map +1 -7
- package/build-module/dashboard-lanes/types.mjs +0 -1
- package/build-module/dashboard-lanes/use-lane-placement.mjs +167 -173
- package/build-module/dashboard-lanes/use-lane-placement.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/shared/array-move-with-pinned.mjs +25 -21
- package/build-module/shared/array-move-with-pinned.mjs.map +1 -7
- package/build-module/shared/column-policy.mjs +52 -0
- package/build-module/shared/column-policy.mjs.map +1 -0
- package/build-module/shared/drag-overlay-drop-animation.mjs +35 -44
- package/build-module/shared/drag-overlay-drop-animation.mjs.map +1 -7
- package/build-module/shared/grid-item-key.mjs +8 -5
- package/build-module/shared/grid-item-key.mjs.map +1 -7
- package/build-module/shared/grid-overlay.mjs +143 -136
- package/build-module/shared/grid-overlay.mjs.map +1 -7
- package/build-module/shared/item-exit-overlay.mjs +128 -110
- package/build-module/shared/item-exit-overlay.mjs.map +1 -7
- package/build-module/shared/resize-handle.mjs +191 -171
- package/build-module/shared/resize-handle.mjs.map +1 -7
- package/build-module/shared/resize-snap.mjs +108 -93
- package/build-module/shared/resize-snap.mjs.map +1 -7
- package/build-module/shared/types.mjs +0 -1
- package/build-module/shared/use-item-exit-animation.mjs +92 -124
- package/build-module/shared/use-item-exit-animation.mjs.map +1 -7
- package/build-module/shared/use-layout-shift-animation.mjs +114 -123
- package/build-module/shared/use-layout-shift-animation.mjs.map +1 -7
- package/build-module/shared/use-span-bounds.mjs +60 -57
- package/build-module/shared/use-span-bounds.mjs.map +1 -7
- package/build-types/dashboard-grid/index.d.ts.map +1 -1
- package/build-types/dashboard-grid/types.d.ts +9 -5
- package/build-types/dashboard-grid/types.d.ts.map +1 -1
- package/build-types/dashboard-lanes/index.d.ts.map +1 -1
- package/build-types/dashboard-lanes/types.d.ts +9 -5
- package/build-types/dashboard-lanes/types.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/shared/column-policy.d.ts +43 -0
- package/build-types/shared/column-policy.d.ts.map +1 -0
- package/package.json +14 -12
- package/src/dashboard-grid/grid-item.tsx +1 -1
- package/src/dashboard-grid/{grid.module.css → grid.module.scss} +10 -19
- package/src/dashboard-grid/index.tsx +12 -13
- package/src/dashboard-grid/stories/index.story.tsx +129 -50
- package/src/dashboard-grid/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-grid/types.ts +9 -5
- package/src/dashboard-lanes/index.tsx +13 -13
- package/src/dashboard-lanes/lanes-item.tsx +1 -1
- package/src/dashboard-lanes/{lanes.module.css → lanes.module.scss} +10 -19
- package/src/dashboard-lanes/stories/index.story.tsx +124 -28
- package/src/dashboard-lanes/test/item-interactions.browser.test.tsx +1 -1
- package/src/dashboard-lanes/types.ts +9 -5
- package/src/index.ts +1 -0
- package/src/shared/column-policy.ts +100 -0
- package/src/shared/test/column-policy.test.ts +215 -0
- package/src/shared/test/sortable-semantics.browser.test.tsx +122 -0
- package/build/dashboard-grid/types.cjs.map +0 -7
- package/build/dashboard-lanes/types.cjs.map +0 -7
- package/build/index.cjs.map +0 -7
- package/build/shared/types.cjs.map +0 -7
- package/build-module/dashboard-grid/types.mjs.map +0 -7
- package/build-module/dashboard-lanes/types.mjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/shared/types.mjs.map +0 -7
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { screen } from '@testing-library/react';
|
|
2
|
+
import { userEvent } from 'vitest/browser';
|
|
3
|
+
import { render } from 'vitest-browser-react';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { useId } from '@wordpress/element';
|
|
6
|
+
import { DashboardGrid } from '../../dashboard-grid';
|
|
7
|
+
import { DashboardLanes } from '../../dashboard-lanes';
|
|
8
|
+
|
|
9
|
+
function Tile( {
|
|
10
|
+
children,
|
|
11
|
+
}: {
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
actionableArea?: React.ReactNode;
|
|
14
|
+
} ) {
|
|
15
|
+
return <section>{ children }</section>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function MetricControl() {
|
|
19
|
+
const id = useId();
|
|
20
|
+
return (
|
|
21
|
+
<label htmlFor={ id }>
|
|
22
|
+
Metric
|
|
23
|
+
<select id={ id }>
|
|
24
|
+
<option>Views</option>
|
|
25
|
+
<option>Clicks</option>
|
|
26
|
+
</select>
|
|
27
|
+
</label>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* eslint-disable testing-library/no-node-access */
|
|
32
|
+
describe.each( [
|
|
33
|
+
[ 'DashboardGrid', DashboardGrid ],
|
|
34
|
+
[ 'DashboardLanes', DashboardLanes ],
|
|
35
|
+
] as const )( '%s sortable semantics', ( _, Dashboard ) => {
|
|
36
|
+
it.each( [
|
|
37
|
+
[ 'read mode', false, true ],
|
|
38
|
+
[ 'a pinned item', true, false ],
|
|
39
|
+
] as const )(
|
|
40
|
+
'preserves interactive content semantics in %s',
|
|
41
|
+
async ( __, editMode, draggable ) => {
|
|
42
|
+
const { container } = await render(
|
|
43
|
+
<Dashboard
|
|
44
|
+
layout={ [ { key: 'a', width: 1, draggable } ] }
|
|
45
|
+
columns={ 2 }
|
|
46
|
+
editMode={ editMode }
|
|
47
|
+
>
|
|
48
|
+
<Tile
|
|
49
|
+
key="a"
|
|
50
|
+
actionableArea={
|
|
51
|
+
<button type="button">Settings</button>
|
|
52
|
+
}
|
|
53
|
+
>
|
|
54
|
+
<a href="#details">Details</a>
|
|
55
|
+
<button type="button">Refresh</button>
|
|
56
|
+
<MetricControl />
|
|
57
|
+
</Tile>
|
|
58
|
+
</Dashboard>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
for ( const control of [
|
|
62
|
+
screen.getByRole( 'link', { name: 'Details' } ),
|
|
63
|
+
screen.getByRole( 'button', { name: 'Refresh' } ),
|
|
64
|
+
screen.getByRole( 'combobox', { name: 'Metric' } ),
|
|
65
|
+
] ) {
|
|
66
|
+
expect(
|
|
67
|
+
control.closest( '[aria-disabled="true"]' )
|
|
68
|
+
).toBeNull();
|
|
69
|
+
expect(
|
|
70
|
+
control.parentElement?.closest( '[role="button"]' )
|
|
71
|
+
).toBeNull();
|
|
72
|
+
expect(
|
|
73
|
+
control.parentElement?.closest( '[tabindex]' )
|
|
74
|
+
).toBeNull();
|
|
75
|
+
}
|
|
76
|
+
expect(
|
|
77
|
+
container.querySelector( '[aria-roledescription="sortable"]' )
|
|
78
|
+
).toBeNull();
|
|
79
|
+
const settings = screen.getByRole( 'button', { name: 'Settings' } );
|
|
80
|
+
expect( settings ).toBeEnabled();
|
|
81
|
+
expect(
|
|
82
|
+
settings.closest( '[inert], [aria-disabled="true"]' )
|
|
83
|
+
).toBeNull();
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
it.each( [
|
|
88
|
+
[ 'a draggable item', true, 'sortable' ],
|
|
89
|
+
[ 'a pinned item resize handle', false, 'draggable' ],
|
|
90
|
+
] as const )(
|
|
91
|
+
'retains keyboard activation and focus for %s',
|
|
92
|
+
async ( __, draggable, roleDescription ) => {
|
|
93
|
+
const { container } = await render(
|
|
94
|
+
<Dashboard
|
|
95
|
+
layout={ [ { key: 'a', width: 1, draggable } ] }
|
|
96
|
+
columns={ 2 }
|
|
97
|
+
editMode
|
|
98
|
+
>
|
|
99
|
+
<div key="a">A</div>
|
|
100
|
+
</Dashboard>
|
|
101
|
+
);
|
|
102
|
+
const activator = container.querySelector< HTMLElement >(
|
|
103
|
+
`[aria-roledescription="${ roleDescription }"]`
|
|
104
|
+
)!;
|
|
105
|
+
expect( activator ).toHaveAttribute( 'role', 'button' );
|
|
106
|
+
expect( activator ).toHaveAttribute( 'tabindex', '0' );
|
|
107
|
+
expect( activator ).toHaveAttribute( 'aria-disabled', 'false' );
|
|
108
|
+
expect( activator ).toHaveAttribute( 'aria-describedby' );
|
|
109
|
+
activator.focus();
|
|
110
|
+
await userEvent.keyboard( '[Space]' );
|
|
111
|
+
await expect
|
|
112
|
+
.poll( () => activator.getAttribute( 'aria-pressed' ) )
|
|
113
|
+
.toBe( 'true' );
|
|
114
|
+
await userEvent.keyboard( '[Escape]' );
|
|
115
|
+
await expect
|
|
116
|
+
.poll( () => activator.hasAttribute( 'aria-pressed' ) )
|
|
117
|
+
.toBe( false );
|
|
118
|
+
expect( activator ).toHaveFocus();
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
} );
|
|
122
|
+
/* eslint-enable testing-library/no-node-access */
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dashboard-grid/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n\tDragPreviewRenderProps,\n\tGridItemLimits,\n\tGridOverlayRenderProps,\n\tResizeDelta,\n\tResizeHandleRenderProps,\n} from '../shared/types';\nimport type { ResizeSnapSize } from '../shared/resize-snap';\n\n/**\n * Dashboard grid layout item definition.\n *\n * `width` accepts either a numeric column span or a discriminated string:\n * - `number` spans that many columns (clamped to the grid's column count).\n * - `'fill'` spans the remaining columns in the current row.\n * - `'full'` spans all columns (`grid-column: 1 / -1`).\n */\nexport type DashboardGridLayoutItem = {\n\t/**\n\t * Unique key that matches a child component key.\n\t */\n\tkey: string;\n\n\t/**\n\t * Number of columns this item spans, or a string discriminator\n\t * (`'fill'` or `'full'`).\n\t */\n\twidth?: number | 'fill' | 'full';\n\n\t/**\n\t * Number of rows this item spans.\n\t *\n\t * @default 1\n\t */\n\theight?: number;\n\n\t/**\n\t * Display order for the item. Lower values render first. When\n\t * omitted, the item falls back to its index in the `layout` array.\n\t */\n\torder?: number;\n\n\t/**\n\t * Whether the item can be dragged while the surface is in edit mode.\n\t * When `false`, the item is pinned: it also holds its index while the\n\t * other items reorder around it.\n\t *\n\t * @default true\n\t */\n\tdraggable?: boolean;\n\n\t/**\n\t * Whether the item can be resized while the surface is in edit mode.\n\t *\n\t * @default true\n\t */\n\tresizable?: boolean;\n};\n\n/**\n * Props for the internal `<GridItem />` wrapper.\n */\nexport type GridItemProps = {\n\t/**\n\t * The layout item containing grid positioning information.\n\t */\n\titem: DashboardGridLayoutItem;\n\n\t/**\n\t * The maximum number of columns in the grid.\n\t */\n\tmaxColumns: number;\n\n\t/**\n\t * Whether drag and resize interactions are disabled.\n\t *\n\t * @default false\n\t */\n\tdisabled?: boolean;\n\n\t/**\n\t * Whether the item can be dragged. Combined with `disabled`.\n\t *\n\t * @default true\n\t */\n\tdraggable?: boolean;\n\n\t/**\n\t * Whether the item can be resized. Combined with `disabled`.\n\t *\n\t * @default true\n\t */\n\tresizable?: boolean;\n\n\t/**\n\t * Whether the item can be resized vertically. Disabled when the\n\t * grid uses `rowHeight: 'auto'`, where row height is driven by\n\t * content rather than by the user.\n\t *\n\t * @default true\n\t */\n\tverticalResizable?: boolean;\n\n\t/**\n\t * Whether any tile in the grid is currently being dragged or\n\t * resized. Drives the drag activator cursor.\n\t *\n\t * @default false\n\t */\n\tinteracting?: boolean;\n\n\t/**\n\t * Whether a tile drag is in progress. Mutes each tile's\n\t * `actionableArea` with `inert` so hovers on other tiles' controls\n\t * do not steal the gesture.\n\t *\n\t * @default false\n\t */\n\tdragging?: boolean;\n\n\t/**\n\t * The content to be displayed within the grid item.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Content rendered above the draggable area that stays interactive\n\t * in edit mode, typically action buttons, menus, or links. While\n\t * a tile drag is in progress, this content is set `inert` so hovers\n\t * on other tiles can't steal the gesture. During resize, visibility\n\t * is controlled by grid-level CSS hooks.\n\t */\n\tactionableArea?: React.ReactNode;\n\n\t/**\n\t * Callback fired while the item is being resized. Receives the\n\t * item's `key` plus the cursor offset from the gesture start in\n\t * pixels. The grid derives snapped spans from the delta and passes\n\t * them back through `resizeSnapPreview`.\n\t */\n\tonResize: ( id: string, delta: ResizeDelta ) => void;\n\n\t/**\n\t * Snapped grid size in pixels for the resize-preview outline. The\n\t * tile content resizes continuously with the cursor; this outline\n\t * shows the span the layout will commit to on release.\n\t */\n\tresizeSnapPreview?: ResizeSnapSize | null;\n\n\t/**\n\t * Minimum tile width while resizing, in pixels (one column track).\n\t */\n\tminResizeWidthPx: number;\n\n\t/**\n\t * Minimum tile height while resizing, in pixels (one row track).\n\t * Omitted when vertical resize is disabled.\n\t */\n\tminResizeHeightPx?: number;\n\n\t/**\n\t * Maximum tile width while resizing, in pixels. Omitted when the\n\t * item declares no width limit.\n\t */\n\tmaxResizeWidthPx?: number;\n\n\t/**\n\t * Maximum tile height while resizing, in pixels. Omitted when\n\t * vertical resize is disabled or the item declares no height limit.\n\t */\n\tmaxResizeHeightPx?: number;\n\n\t/**\n\t * Callback fired when the resize gesture ends.\n\t */\n\tonResizeEnd: () => void;\n\n\t/**\n\t * Component forwarded to `<ResizeHandle />` to override the default\n\t * corner triangle. See `DashboardGridProps.renderResizeHandle`.\n\t */\n\trenderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;\n};\n\n/**\n * Props for `DashboardGrid`. Extends the standard div props so consumers\n * can pass `id`, `aria-*`, `data-*`, event handlers, etc., directly on\n * the grid root.\n *\n * `columns` and `minColumnWidth` compose as a layered model:\n * - `columns` alone: fixed N columns; each tile scales with the container.\n * - `minColumnWidth` alone: column count derives from container width,\n * floored by the per-tile minimum, down to 1 column.\n * - Both together: `columns` caps the count, `minColumnWidth` enforces a\n * per-tile width floor that can reduce the count below the cap on\n * narrow containers (\"up to N columns, but never narrower than W px\").\n */\nexport interface DashboardGridProps extends Omit<\n\tReact.ComponentPropsWithoutRef< 'div' >,\n\t'children' | 'className' | 'style'\n> {\n\t/**\n\t * Array of layout items.\n\t */\n\tlayout: DashboardGridLayoutItem[];\n\n\t/**\n\t * Grid children. Each child must carry a `key` that matches an\n\t * entry in `layout`; children without a match render at the end\n\t * of the grid without explicit placement and fall through CSS\n\t * Grid's auto-flow.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Additional CSS class on the grid root.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Inline styles applied to the grid root. Merged underneath the\n\t * grid's own layout styles, so the layout (`gridTemplateColumns`,\n\t * `gridAutoRows`) always wins. The gap between tiles is owned by\n\t * the design-system gap token and is not configurable per\n\t * instance; override it via a theme or density change.\n\t */\n\tstyle?: React.CSSProperties;\n\n\t/**\n\t * Height of each row in pixels, or `'auto'` to let the tallest\n\t * tile in the row size it.\n\t *\n\t * @default 'auto'\n\t */\n\trowHeight?: number | 'auto';\n\n\t/**\n\t * Whether the grid is in edit mode (allows dragging and\n\t * repositioning items).\n\t *\n\t * @default false\n\t */\n\teditMode?: boolean;\n\n\t/**\n\t * Callback fired when the user commits a drag or resize. Receives\n\t * the resulting layout.\n\t */\n\tonChangeLayout?: ( newLayout: DashboardGridLayoutItem[] ) => void;\n\n\t/**\n\t * Callback fired continuously during a drag or resize interaction\n\t * with the in-progress layout. Useful for live feedback in the\n\t * surface (e.g., displaying the current width/position). The final\n\t * committed layout is still emitted via `onChangeLayout`.\n\t */\n\tonPreviewLayout?: ( previewLayout: DashboardGridLayoutItem[] ) => void;\n\n\t/**\n\t * Override the default corner-triangle resize handle with a custom\n\t * component. The grid still owns the gesture (dnd-kit `<DndContext>`,\n\t * throttled delta loop) and passes the wiring to the consumer:\n\t * spread `listeners` and `attributes` and assign `ref` on the\n\t * element that should receive the gesture. Use `disabled` and\n\t * `verticalResizable` to adapt the visual to context.\n\t */\n\trenderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;\n\n\t/**\n\t * Custom wrapper for the dragged-clone visual mounted inside\n\t * `<DragOverlay>`. The surface always wraps the clone with a thin\n\t * functional frame (lift scale, grabbing cursor, pointer pass-\n\t * through) and mounts this component inside it; the consumer\n\t * owns the visual chrome (shadow, radius, padding).\n\t *\n\t * When omitted, the cloned children render directly inside the\n\t * functional frame so any chrome the consumer applied to the\n\t * persistent tile carries through unchanged.\n\t *\n\t * Token-only adjustments (lift scale, placeholder opacity,\n\t * outline color, placeholder radius) flow through CSS custom\n\t * properties documented in the README.\n\t */\n\trenderDragPreview?: React.ComponentType< DragPreviewRenderProps >;\n\n\t/**\n\t * Override the default edit-mode overlay (row-marker tiles per\n\t * column) with a custom component. The grid supplies the resolved\n\t * column count, row height, and row count; the consumer is\n\t * responsible for the visual.\n\t *\n\t * The overlay only renders when `editMode` is true. When omitted,\n\t * the package's default visual is used.\n\t */\n\trenderGridOverlay?: React.ComponentType< GridOverlayRenderProps >;\n\n\t/**\n\t * Target column count, used as a cap. Defaults to six when neither\n\t * `columns` nor `minColumnWidth` is set; with `minColumnWidth` set\n\t * it can resolve lower on narrow containers.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Per-tile minimum width in pixels. Enables responsive mode: the\n\t * column count derives from container width, floored by this value,\n\t * down to 1.\n\t */\n\tminColumnWidth?: number;\n\n\t/**\n\t * Per-item size limits in pixels, keyed by layout item key. Width\n\t * bounds saturate at the column count; `'full'` and `'fill'` widths\n\t * respect a maximum.\n\t */\n\titemLimits?: Record< string, GridItemLimits >;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dashboard-lanes/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n\tDragPreviewRenderProps,\n\tGridItemWidthLimits,\n\tGridOverlayRenderProps,\n\tResizeHandleRenderProps,\n} from '../shared/types';\n\n/**\n * Lanes layout item definition.\n *\n * Mirrors the public surface of `display: grid-lanes`: column span,\n * an optional pinned lane, and an optional source order. Heights are\n * content-driven; there is no `height` field. There is no `'fill'`\n * (lanes pack their items by skyline; nothing is \"left over\").\n * `'full'` is expressed by setting `width` to the lane count.\n */\nexport type DashboardLanesLayoutItem = {\n\t/**\n\t * Unique key that matches a child component key.\n\t */\n\tkey: string;\n\n\t/**\n\t * Number of lanes this item spans (`grid-column: span N`). Clamped\n\t * to the surface's lane count.\n\t *\n\t * @default 1\n\t */\n\twidth?: number;\n\n\t/**\n\t * Pin the item to a specific 0-indexed lane. Pinned items are\n\t * placed before auto items, so the auto flow runs around them.\n\t * Out-of-range values (negative, or beyond `columns - width`) are\n\t * clamped to the available range.\n\t */\n\tlane?: number;\n\n\t/**\n\t * Whether the item can be dragged while the surface is in edit mode.\n\t * When `false`, the item is pinned: it also holds its index while the\n\t * other items reorder around it.\n\t *\n\t * @default true\n\t */\n\tdraggable?: boolean;\n\n\t/**\n\t * Whether the item can be resized while the surface is in edit mode.\n\t *\n\t * @default true\n\t */\n\tresizable?: boolean;\n\n\t/**\n\t * Display order. Lower values render first. When omitted, the\n\t * item falls back to its index in the `layout` array.\n\t */\n\torder?: number;\n};\n\n/**\n * Props for `DashboardLanes`.\n *\n * `columns` and `minColumnWidth` compose as a layered model:\n * - `columns` alone: fixed N lanes; tiles scale with the container.\n * - `minColumnWidth` alone: lane count derives from container width,\n * floored by the per-tile minimum, down to 1.\n * - Both together: `columns` caps the count, `minColumnWidth` enforces\n * a per-tile width floor that can reduce the count below the cap.\n */\nexport interface DashboardLanesProps extends Omit<\n\tReact.ComponentPropsWithoutRef< 'div' >,\n\t'children' | 'className' | 'style'\n> {\n\t/**\n\t * Array of layout items.\n\t */\n\tlayout: DashboardLanesLayoutItem[];\n\n\t/**\n\t * Surface children. Each child must carry a `key` matching an\n\t * entry in `layout`; children without a match render at the end\n\t * of the surface without explicit placement and fall through the\n\t * lanes auto-flow.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Additional CSS class on the surface root.\n\t */\n\tclassName?: string;\n\n\t/**\n\t * Inline styles on the surface root. Merged underneath the\n\t * surface's own layout styles, so `display` and\n\t * `gridTemplateColumns` always win. The gap between tiles is\n\t * owned by the design-system gap token and is not configurable\n\t * per instance; override it via a theme or density change.\n\t */\n\tstyle?: React.CSSProperties;\n\n\t/**\n\t * `flow-tolerance` value in pixels. When two candidate lanes\n\t * differ in baseline by no more than this, the earlier lane wins\n\t * to preserve source order. Larger values keep tiles closer to\n\t * reading order at the cost of bigger empty regions.\n\t *\n\t * @default 16\n\t */\n\tflowTolerance?: number;\n\n\t/**\n\t * Snap unit for the polyfill's `grid-row-start` / `grid-row-end:\n\t * span N` math. Smaller values produce sharper placement at the\n\t * cost of a larger implicit row count. Ignored on browsers with\n\t * native `display: grid-lanes` support.\n\t *\n\t * @default 4\n\t */\n\trowUnit?: number;\n\n\t/**\n\t * Whether the surface is in edit mode (drag-to-reorder, resize).\n\t *\n\t * @default false\n\t */\n\teditMode?: boolean;\n\n\t/**\n\t * Fired when the user commits a drag or resize.\n\t */\n\tonChangeLayout?: ( newLayout: DashboardLanesLayoutItem[] ) => void;\n\n\t/**\n\t * Fired continuously during a gesture with the in-progress\n\t * layout. The committed result still emits via `onChangeLayout`.\n\t */\n\tonPreviewLayout?: ( previewLayout: DashboardLanesLayoutItem[] ) => void;\n\n\t/**\n\t * Override the default corner resize handle. See `DashboardGrid`\n\t * for the full contract; on lanes the handle is horizontal-only\n\t * because heights are content-driven.\n\t */\n\trenderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;\n\n\t/**\n\t * Custom wrapper for the dragged-clone visual mounted inside\n\t * `<DragOverlay>`. The surface always wraps the clone with a thin\n\t * functional frame (lift scale, grabbing cursor, pointer pass-\n\t * through) and mounts this component inside it; the consumer\n\t * owns the visual chrome (shadow, radius, padding).\n\t *\n\t * When omitted, the cloned children render directly inside the\n\t * functional frame so any chrome the consumer applied to the\n\t * persistent tile carries through unchanged.\n\t *\n\t * Token-only adjustments (lift scale, placeholder opacity,\n\t * outline color, placeholder radius) flow through CSS custom\n\t * properties documented in the README.\n\t */\n\trenderDragPreview?: React.ComponentType< DragPreviewRenderProps >;\n\n\t/**\n\t * Override the default edit-mode overlay (empty column tracks) with\n\t * a custom component. Lanes are content-driven vertically, so no\n\t * `rowHeight` or `rows` is supplied and the default visual paints\n\t * columns only.\n\t *\n\t * The overlay only renders when `editMode` is true. When omitted,\n\t * the package's default visual is used.\n\t */\n\trenderGridOverlay?: React.ComponentType< GridOverlayRenderProps >;\n\n\t/**\n\t * Target lane count, used as a cap. Defaults to six when neither\n\t * `columns` nor `minColumnWidth` is set; with `minColumnWidth` set\n\t * it can resolve lower on narrow containers.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Per-tile minimum width in pixels. Enables responsive mode: the\n\t * lane count derives from container width, floored by this value,\n\t * down to 1.\n\t */\n\tminColumnWidth?: number;\n\n\t/**\n\t * Per-item width limits in pixels, keyed by layout item key. Lane\n\t * heights are content-driven, so there is no height axis.\n\t */\n\titemLimits?: Record< string, GridItemWidthLimits >;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/build/index.cjs.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { DashboardGrid } from './dashboard-grid';\nexport { DashboardLanes } from './dashboard-lanes';\n\nexport type {\n\tDashboardGridLayoutItem,\n\tDashboardGridProps,\n} from './dashboard-grid/types';\nexport type {\n\tDashboardLanesLayoutItem,\n\tDashboardLanesProps,\n} from './dashboard-lanes/types';\nexport type {\n\tDragPreviewRenderProps,\n\tGridItemLimits,\n\tGridItemWidthLimits,\n\tGridOverlayRenderProps,\n\tResizeDelta,\n\tResizeHandleRenderProps,\n} from './shared/types';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAA8B;AAC9B,6BAA+B;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/shared/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type { useDraggable } from '@dnd-kit/core';\n\n// `useDraggable`'s `listeners` and `attributes` types are not exported\n// from `@dnd-kit/core`'s public surface, so derive them from the hook\n// itself rather than via a deep import.\ntype DraggableBindings = ReturnType< typeof useDraggable >;\n\n/**\n * Cursor offset reported by the resize handle, in pixels relative to\n * the gesture start. Width and height are independent so the surface\n * can step columns and rows separately.\n */\nexport type ResizeDelta = {\n\twidth: number;\n\theight: number;\n};\n\n/**\n * Props received by a custom resize handle component. Spread `listeners`\n * and `attributes` onto the element that should respond to the gesture,\n * and assign `ref` to the same element so dnd-kit can track it.\n */\nexport interface ResizeHandleRenderProps {\n\t/**\n\t * Ref callback to attach to the gesture-bearing element.\n\t */\n\tref: DraggableBindings[ 'setNodeRef' ];\n\n\t/**\n\t * Pointer/keyboard event listeners that initiate the drag.\n\t */\n\tlisteners: DraggableBindings[ 'listeners' ];\n\n\t/**\n\t * Accessibility and dnd-kit attributes (role, aria-*, tabIndex…).\n\t */\n\tattributes: DraggableBindings[ 'attributes' ];\n\n\t/**\n\t * Whether vertical resizing is allowed for this tile. Useful for\n\t * adapting the cursor or visual cue.\n\t */\n\tverticalResizable: boolean;\n\n\t/**\n\t * True while the user is actively dragging this handle. Use it to\n\t * swap colors, icons, or transforms during the gesture.\n\t */\n\tisResizing: boolean;\n\n\t/**\n\t * Owning item's `key`. Available so consumers can render per-tile\n\t * content if needed.\n\t */\n\titemId?: string;\n}\n\n/**\n * Props received by a custom drag-preview component. The surface mounts\n * the component inside `<DragOverlay>` and supplies the active tile's\n * cloned children plus its `key`. The component is responsible for the\n * visual chrome of the dragged clone (shadow, radius, padding); the\n * surface keeps a thin functional wrapper around it that owns the lift\n * cue, the cursor, and pointer pass-through during the gesture.\n */\nexport interface DragPreviewRenderProps {\n\t/**\n\t * The cloned tile content the surface mounts inside the\n\t * `<DragOverlay>` portal. Render it where the visual wrapper\n\t * expects the tile body.\n\t */\n\tchildren: React.ReactNode;\n\n\t/**\n\t * Owning tile's `key`. Useful when the visual chrome needs to\n\t * vary by which tile is being dragged.\n\t */\n\titemId: string;\n}\n\n/**\n * Props received by a custom grid overlay component. The overlay\n * paints behind the tiles in edit mode to visualize the column tracks\n * and (when `rowHeight` is defined) the row tracks. Receives a\n * snapshot of the surface's resolved layout parameters so the visual\n * can reproduce the tracks pixel-accurately without re-deriving them.\n *\n * Reused by both `DashboardGrid` and `DashboardLanes`: lanes pass no\n * `rowHeight` because heights are content-driven.\n */\nexport interface GridOverlayRenderProps {\n\t/**\n\t * Number of column tracks in the active surface. In responsive\n\t * mode (`minColumnWidth`), this is the count derived from the\n\t * container width, not the prop value.\n\t */\n\tcolumns: number;\n\n\t/**\n\t * Row height in pixels for surfaces with uniform rows. Omitted on\n\t * surfaces with content-driven heights (lanes) or when row height\n\t * is `'auto'`; in those cases row markers are omitted.\n\t */\n\trowHeight?: number;\n\n\t/**\n\t * Number of row tracks to mirror in each column. Derived from the\n\t * grid container height when `rowHeight` is numeric; omitted when\n\t * row height is unknown.\n\t */\n\trows?: number;\n\n\t/**\n\t * Whether the overlay should be visible. Surfaces render the\n\t * overlay even when `false` so the implementation can transition\n\t * opacity in and out; while `false`, the overlay must hide itself\n\t * (and ideally release paint cost via `visibility: hidden` or an\n\t * equivalent).\n\t */\n\tisActive: boolean;\n}\n\n/**\n * Props for the internal `<ResizeHandle />` wrapper.\n */\nexport interface ResizeHandleProps {\n\t/**\n\t * Owning item's `key`. Forwarded as `data.itemId` on the draggable\n\t * so the parent can correlate the gesture with a tile if needed.\n\t */\n\titemId?: string;\n\n\t/**\n\t * Whether the handle should track vertical movement. When false,\n\t * the handle still appears but only emits horizontal deltas, and\n\t * the cursor is constrained to the column resize axis.\n\t *\n\t * @default true\n\t */\n\tverticalResizable?: boolean;\n\n\t/**\n\t * Callback fired while the handle is being dragged. Receives the\n\t * cursor offset from the gesture start in pixels.\n\t */\n\tonResize?: ( delta: ResizeDelta ) => void;\n\n\t/**\n\t * Callback fired when the gesture ends.\n\t */\n\tonResizeEnd?: () => void;\n\n\t/**\n\t * Component that overrides the default corner triangle with a\n\t * custom element. Receives gesture wiring (`ref`, `listeners`,\n\t * `attributes`) plus context. The surface keeps ownership of the\n\t * `<DndContext>` and the throttled delta loop; consumers are only\n\t * responsible for the visual.\n\t */\n\trenderResizeHandle?: React.ComponentType< ResizeHandleRenderProps >;\n}\n\n/**\n * Per-item width limits, in pixels. Surfaces quantize each limit to\n * whole tracks (minimums round up, maximums round down), bound rendered\n * spans and resize gestures at the result, and never write it into the\n * layout. A quantized minimum wins over a smaller quantized maximum.\n */\nexport type GridItemWidthLimits = {\n\t/**\n\t * Minimum tile width in pixels.\n\t */\n\tminWidth?: number;\n\n\t/**\n\t * Maximum tile width in pixels.\n\t */\n\tmaxWidth?: number;\n};\n\n/**\n * Per-item size limits on both axes, in pixels, for surfaces with row\n * tracks. Height limits quantize against the row track when `rowHeight`\n * is numeric and stay open otherwise.\n */\nexport type GridItemLimits = GridItemWidthLimits & {\n\t/**\n\t * Minimum tile height in pixels.\n\t */\n\tminHeight?: number;\n\n\t/**\n\t * Maximum tile height in pixels.\n\t */\n\tmaxHeight?: number;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { DashboardGrid } from './dashboard-grid';\nexport { DashboardLanes } from './dashboard-lanes';\n\nexport type {\n\tDashboardGridLayoutItem,\n\tDashboardGridProps,\n} from './dashboard-grid/types';\nexport type {\n\tDashboardLanesLayoutItem,\n\tDashboardLanesProps,\n} from './dashboard-lanes/types';\nexport type {\n\tDragPreviewRenderProps,\n\tGridItemLimits,\n\tGridItemWidthLimits,\n\tGridOverlayRenderProps,\n\tResizeDelta,\n\tResizeHandleRenderProps,\n} from './shared/types';\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|