react-grid-layout 1.5.3 → 2.0.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 +1074 -432
- package/css/styles.css +6 -4
- package/dist/ResponsiveGridLayout-CH4s0tKj.d.ts +124 -0
- package/dist/ResponsiveGridLayout-D6lFRE3f.d.mts +124 -0
- package/dist/calculate-CwYDW8na.d.mts +168 -0
- package/dist/calculate-mgLpNJ5O.d.ts +168 -0
- package/dist/chunk-2KUHNJXF.mjs +90 -0
- package/dist/chunk-2KUHNJXF.mjs.map +1 -0
- package/dist/chunk-3WO4SAYB.js +868 -0
- package/dist/chunk-3WO4SAYB.js.map +1 -0
- package/dist/chunk-4HNUMWQK.mjs +822 -0
- package/dist/chunk-4HNUMWQK.mjs.map +1 -0
- package/dist/chunk-BFTKGAP3.js +1309 -0
- package/dist/chunk-BFTKGAP3.js.map +1 -0
- package/dist/chunk-F6NQPYKT.js +98 -0
- package/dist/chunk-F6NQPYKT.js.map +1 -0
- package/dist/chunk-H5KMDLY3.js +434 -0
- package/dist/chunk-H5KMDLY3.js.map +1 -0
- package/dist/chunk-PBQSHIID.js +4 -0
- package/dist/chunk-PBQSHIID.js.map +1 -0
- package/dist/chunk-R35HZZTA.mjs +1300 -0
- package/dist/chunk-R35HZZTA.mjs.map +1 -0
- package/dist/chunk-ZCXE6SR5.mjs +428 -0
- package/dist/chunk-ZCXE6SR5.mjs.map +1 -0
- package/dist/chunk-ZWN22PS2.mjs +3 -0
- package/dist/chunk-ZWN22PS2.mjs.map +1 -0
- package/dist/core.d.mts +33 -0
- package/dist/core.d.ts +33 -0
- package/dist/core.js +218 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +5 -0
- package/dist/core.mjs.map +1 -0
- package/dist/extras.d.mts +78 -0
- package/dist/extras.d.ts +78 -0
- package/dist/extras.js +91 -0
- package/dist/extras.js.map +1 -0
- package/dist/extras.mjs +89 -0
- package/dist/extras.mjs.map +1 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/legacy.d.mts +163 -0
- package/dist/legacy.d.ts +163 -0
- package/dist/legacy.js +319 -0
- package/dist/legacy.js.map +1 -0
- package/dist/legacy.mjs +307 -0
- package/dist/legacy.mjs.map +1 -0
- package/dist/position-BmN1z36J.d.mts +319 -0
- package/dist/position-Dk2b4ZMS.d.ts +319 -0
- package/dist/react.d.mts +351 -0
- package/dist/react.d.ts +351 -0
- package/dist/react.js +96 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +7 -0
- package/dist/react.mjs.map +1 -0
- package/dist/responsive-C4L1ESlm.d.ts +145 -0
- package/dist/responsive-CJxefsYw.d.mts +145 -0
- package/dist/types-Cxf4nHNr.d.mts +375 -0
- package/dist/types-Cxf4nHNr.d.ts +375 -0
- package/index-dev.js +8 -0
- package/package.json +132 -40
- package/.babelrc.js +0 -22
- package/.browserslistrc +0 -3
- package/.eslintignore +0 -4
- package/.flowconfig +0 -20
- package/.prettierignore +0 -4
- package/.prettierrc +0 -17
- package/CHANGELOG.md +0 -985
- package/build/GridItem.js +0 -638
- package/build/ReactGridLayout.js +0 -741
- package/build/ReactGridLayoutPropTypes.js +0 -210
- package/build/ResponsiveReactGridLayout.js +0 -297
- package/build/calculateUtils.js +0 -165
- package/build/components/WidthProvider.js +0 -115
- package/build/fastRGLPropsEqual.js +0 -5
- package/build/responsiveUtils.js +0 -101
- package/build/utils.js +0 -842
- package/dist/react-grid-layout.min.js +0 -2
- package/dist/react-grid-layout.min.js.map +0 -1
- package/index.js.flow +0 -8
- package/ip_fetcher +0 -0
- package/ip_fetcher.c +0 -47
- package/lib/GridItem.jsx +0 -689
- package/lib/ReactGridLayout.jsx +0 -855
- package/lib/ReactGridLayoutPropTypes.js +0 -241
- package/lib/ResponsiveReactGridLayout.jsx +0 -349
- package/lib/calculateUtils.js +0 -169
- package/lib/components/WidthProvider.jsx +0 -110
- package/lib/fastRGLPropsEqual.js +0 -46
- package/lib/responsiveUtils.js +0 -118
- package/lib/utils.js +0 -995
- package/yarn-error.log +0 -7780
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extras/GridBackground.tsx"],"names":["useMemo","calcGridCellDimensions","jsx"],"mappings":";;;;;;AAkFO,SAAS,cAAA,CAAe;AAAA,EAC7B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA,GAAS,CAAC,EAAA,EAAI,EAAE,CAAA;AAAA,EAChB,gBAAA;AAAA,EACA,IAAA,GAAO,EAAA;AAAA,EACP,MAAA;AAAA,EACA,KAAA,GAAQ,SAAA;AAAA,EACR,YAAA,GAAe,CAAA;AAAA,EACf,SAAA;AAAA,EACA;AACF,CAAA,EAA4C;AAC1C,EAAA,MAAM,IAAA,GAAOA,aAAA;AAAA,IACX,MACEC,uCAAA,CAAuB;AAAA,MACrB,KAAA;AAAA,MACA,IAAA;AAAA,MACA,SAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA,KACD,CAAA;AAAA,IACH,CAAC,KAAA,EAAO,IAAA,EAAM,SAAA,EAAW,QAAQ,gBAAgB;AAAA,GACnD;AAGA,EAAA,MAAM,QAAA,GAAWD,cAAQ,MAAM;AAC7B,IAAA,IAAI,IAAA,KAAS,QAAQ,OAAO,IAAA;AAC5B,IAAA,IAAI,MAAA,EAAQ;AAEV,MAAA,MAAM,UAAU,gBAAA,IAAoB,MAAA;AACpC,MAAA,OAAO,IAAA,CAAK,IAAA;AAAA,QAAA,CACT,MAAA,GAAS,OAAA,CAAQ,CAAC,CAAA,GAAI,CAAA,GAAI,OAAO,CAAC,CAAA,KAAM,SAAA,GAAY,MAAA,CAAO,CAAC,CAAA;AAAA,OAC/D;AAAA,IACF;AACA,IAAA,OAAO,EAAA;AAAA,EACT,GAAG,CAAC,IAAA,EAAM,QAAQ,SAA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EA,IAAA,OAAO,KAAA;AAAA,EACT,GAAG,CAAC,IAAA,EAAM,UAAU,IAAA,EAAM,YAAA,EAAc,KAAK,CAAC,CAAA;AAE9C,EAAA,uBACEA,cAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,SAAA;AAAA,MACA,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,UAAA;AAAA,QACV,GAAA,EAAK,CAAA;AAAA,QACL,IAAA,EAAM,CAAA;AAAA,QACN,KAAA;AAAA,QACA,MAAA,EAAQ,WAAA;AAAA,QACR,aAAA,EAAe,MAAA;AAAA,QACf,GAAG;AAAA,OACL;AAAA,MACA,aAAA,EAAY,MAAA;AAAA,MAEX,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"extras.js","sourcesContent":["/**\n * GridBackground component\n *\n * Renders an SVG grid background that aligns with GridLayout cells.\n * Use this to visualize the grid structure behind your layout.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { calcGridCellDimensions } from \"../core/calculate.js\";\nimport type { GridCellConfig } from \"../core/calculate.js\";\n\nexport interface GridBackgroundProps extends GridCellConfig {\n /**\n * Number of rows to display. If \"auto\", calculates based on height.\n * @default 10\n */\n rows?: number | \"auto\";\n\n /**\n * Height of the background in pixels. Used when rows=\"auto\".\n */\n height?: number;\n\n /**\n * Color of the grid cell backgrounds.\n * @default \"#e0e0e0\"\n */\n color?: string;\n\n /**\n * Border radius of grid cells in pixels.\n * @default 4\n */\n borderRadius?: number;\n\n /**\n * Additional CSS class name.\n */\n className?: string;\n\n /**\n * Additional inline styles.\n */\n style?: React.CSSProperties;\n}\n\n/**\n * SVG grid background component.\n *\n * Renders a visual grid that aligns with GridLayout cells. Position this\n * behind your GridLayout using CSS positioning.\n *\n * @example\n * ```tsx\n * import { GridBackground } from 'react-grid-layout/extras';\n *\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef} style={{ position: 'relative' }}>\n * {mounted && (\n * <>\n * <GridBackground\n * width={width}\n * cols={12}\n * rowHeight={30}\n * margin={[10, 10]}\n * rows={10}\n * color=\"#f0f0f0\"\n * />\n * <GridLayout width={width} gridConfig={{ cols: 12, rowHeight: 30 }}>\n * {children}\n * </GridLayout>\n * </>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function GridBackground({\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding,\n rows = 10,\n height,\n color = \"#e0e0e0\",\n borderRadius = 4,\n className,\n style\n}: GridBackgroundProps): React.ReactElement {\n const dims = useMemo(\n () =>\n calcGridCellDimensions({\n width,\n cols,\n rowHeight,\n margin,\n containerPadding\n }),\n [width, cols, rowHeight, margin, containerPadding]\n );\n\n // Calculate number of rows\n const rowCount = useMemo(() => {\n if (rows !== \"auto\") return rows;\n if (height) {\n // Calculate rows that fit in the given height\n const padding = containerPadding ?? margin;\n return Math.ceil(\n (height - padding[1] * 2 + margin[1]) / (rowHeight + margin[1])\n );\n }\n return 10;\n }, [rows, height, rowHeight, margin, containerPadding]);\n\n // Calculate total height\n const totalHeight = useMemo(() => {\n const padding = containerPadding ?? margin;\n return padding[1] * 2 + rowCount * rowHeight + (rowCount - 1) * margin[1];\n }, [rowCount, rowHeight, margin, containerPadding]);\n\n // Generate cell rectangles\n const cells = useMemo(() => {\n const rects: React.ReactElement[] = [];\n const { cellWidth, cellHeight, offsetX, offsetY, gapX, gapY } = dims;\n\n for (let row = 0; row < rowCount; row++) {\n for (let col = 0; col < cols; col++) {\n const x = offsetX + col * (cellWidth + gapX);\n const y = offsetY + row * (cellHeight + gapY);\n\n rects.push(\n <rect\n key={`${row}-${col}`}\n x={x}\n y={y}\n width={cellWidth}\n height={cellHeight}\n rx={borderRadius}\n ry={borderRadius}\n fill={color}\n />\n );\n }\n }\n\n return rects;\n }, [dims, rowCount, cols, borderRadius, color]);\n\n return (\n <svg\n className={className}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: width,\n height: totalHeight,\n pointerEvents: \"none\",\n ...style\n }}\n aria-hidden=\"true\"\n >\n {cells}\n </svg>\n );\n}\n\nexport default GridBackground;\n"]}
|
package/dist/extras.mjs
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { calcGridCellDimensions } from './chunk-2KUHNJXF.mjs';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function GridBackground({
|
|
6
|
+
width,
|
|
7
|
+
cols,
|
|
8
|
+
rowHeight,
|
|
9
|
+
margin = [10, 10],
|
|
10
|
+
containerPadding,
|
|
11
|
+
rows = 10,
|
|
12
|
+
height,
|
|
13
|
+
color = "#e0e0e0",
|
|
14
|
+
borderRadius = 4,
|
|
15
|
+
className,
|
|
16
|
+
style
|
|
17
|
+
}) {
|
|
18
|
+
const dims = useMemo(
|
|
19
|
+
() => calcGridCellDimensions({
|
|
20
|
+
width,
|
|
21
|
+
cols,
|
|
22
|
+
rowHeight,
|
|
23
|
+
margin,
|
|
24
|
+
containerPadding
|
|
25
|
+
}),
|
|
26
|
+
[width, cols, rowHeight, margin, containerPadding]
|
|
27
|
+
);
|
|
28
|
+
const rowCount = useMemo(() => {
|
|
29
|
+
if (rows !== "auto") return rows;
|
|
30
|
+
if (height) {
|
|
31
|
+
const padding = containerPadding ?? margin;
|
|
32
|
+
return Math.ceil(
|
|
33
|
+
(height - padding[1] * 2 + margin[1]) / (rowHeight + margin[1])
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return 10;
|
|
37
|
+
}, [rows, height, rowHeight, margin, containerPadding]);
|
|
38
|
+
const totalHeight = useMemo(() => {
|
|
39
|
+
const padding = containerPadding ?? margin;
|
|
40
|
+
return padding[1] * 2 + rowCount * rowHeight + (rowCount - 1) * margin[1];
|
|
41
|
+
}, [rowCount, rowHeight, margin, containerPadding]);
|
|
42
|
+
const cells = useMemo(() => {
|
|
43
|
+
const rects = [];
|
|
44
|
+
const { cellWidth, cellHeight, offsetX, offsetY, gapX, gapY } = dims;
|
|
45
|
+
for (let row = 0; row < rowCount; row++) {
|
|
46
|
+
for (let col = 0; col < cols; col++) {
|
|
47
|
+
const x = offsetX + col * (cellWidth + gapX);
|
|
48
|
+
const y = offsetY + row * (cellHeight + gapY);
|
|
49
|
+
rects.push(
|
|
50
|
+
/* @__PURE__ */ jsx(
|
|
51
|
+
"rect",
|
|
52
|
+
{
|
|
53
|
+
x,
|
|
54
|
+
y,
|
|
55
|
+
width: cellWidth,
|
|
56
|
+
height: cellHeight,
|
|
57
|
+
rx: borderRadius,
|
|
58
|
+
ry: borderRadius,
|
|
59
|
+
fill: color
|
|
60
|
+
},
|
|
61
|
+
`${row}-${col}`
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return rects;
|
|
67
|
+
}, [dims, rowCount, cols, borderRadius, color]);
|
|
68
|
+
return /* @__PURE__ */ jsx(
|
|
69
|
+
"svg",
|
|
70
|
+
{
|
|
71
|
+
className,
|
|
72
|
+
style: {
|
|
73
|
+
position: "absolute",
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
width,
|
|
77
|
+
height: totalHeight,
|
|
78
|
+
pointerEvents: "none",
|
|
79
|
+
...style
|
|
80
|
+
},
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
children: cells
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { GridBackground };
|
|
88
|
+
//# sourceMappingURL=extras.mjs.map
|
|
89
|
+
//# sourceMappingURL=extras.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extras/GridBackground.tsx"],"names":[],"mappings":";;;;AAkFO,SAAS,cAAA,CAAe;AAAA,EAC7B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,SAAA;AAAA,EACA,MAAA,GAAS,CAAC,EAAA,EAAI,EAAE,CAAA;AAAA,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A,MACA,aAAA,EAAY,MAAA;AAAA,MAEX,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"extras.mjs","sourcesContent":["/**\n * GridBackground component\n *\n * Renders an SVG grid background that aligns with GridLayout cells.\n * Use this to visualize the grid structure behind your layout.\n */\n\nimport * as React from \"react\";\nimport { useMemo } from \"react\";\nimport { calcGridCellDimensions } from \"../core/calculate.js\";\nimport type { GridCellConfig } from \"../core/calculate.js\";\n\nexport interface GridBackgroundProps extends GridCellConfig {\n /**\n * Number of rows to display. If \"auto\", calculates based on height.\n * @default 10\n */\n rows?: number | \"auto\";\n\n /**\n * Height of the background in pixels. Used when rows=\"auto\".\n */\n height?: number;\n\n /**\n * Color of the grid cell backgrounds.\n * @default \"#e0e0e0\"\n */\n color?: string;\n\n /**\n * Border radius of grid cells in pixels.\n * @default 4\n */\n borderRadius?: number;\n\n /**\n * Additional CSS class name.\n */\n className?: string;\n\n /**\n * Additional inline styles.\n */\n style?: React.CSSProperties;\n}\n\n/**\n * SVG grid background component.\n *\n * Renders a visual grid that aligns with GridLayout cells. Position this\n * behind your GridLayout using CSS positioning.\n *\n * @example\n * ```tsx\n * import { GridBackground } from 'react-grid-layout/extras';\n *\n * function MyGrid() {\n * const { width, containerRef, mounted } = useContainerWidth();\n *\n * return (\n * <div ref={containerRef} style={{ position: 'relative' }}>\n * {mounted && (\n * <>\n * <GridBackground\n * width={width}\n * cols={12}\n * rowHeight={30}\n * margin={[10, 10]}\n * rows={10}\n * color=\"#f0f0f0\"\n * />\n * <GridLayout width={width} gridConfig={{ cols: 12, rowHeight: 30 }}>\n * {children}\n * </GridLayout>\n * </>\n * )}\n * </div>\n * );\n * }\n * ```\n */\nexport function GridBackground({\n width,\n cols,\n rowHeight,\n margin = [10, 10],\n containerPadding,\n rows = 10,\n height,\n color = \"#e0e0e0\",\n borderRadius = 4,\n className,\n style\n}: GridBackgroundProps): React.ReactElement {\n const dims = useMemo(\n () =>\n calcGridCellDimensions({\n width,\n cols,\n rowHeight,\n margin,\n containerPadding\n }),\n [width, cols, rowHeight, margin, containerPadding]\n );\n\n // Calculate number of rows\n const rowCount = useMemo(() => {\n if (rows !== \"auto\") return rows;\n if (height) {\n // Calculate rows that fit in the given height\n const padding = containerPadding ?? margin;\n return Math.ceil(\n (height - padding[1] * 2 + margin[1]) / (rowHeight + margin[1])\n );\n }\n return 10;\n }, [rows, height, rowHeight, margin, containerPadding]);\n\n // Calculate total height\n const totalHeight = useMemo(() => {\n const padding = containerPadding ?? margin;\n return padding[1] * 2 + rowCount * rowHeight + (rowCount - 1) * margin[1];\n }, [rowCount, rowHeight, margin, containerPadding]);\n\n // Generate cell rectangles\n const cells = useMemo(() => {\n const rects: React.ReactElement[] = [];\n const { cellWidth, cellHeight, offsetX, offsetY, gapX, gapY } = dims;\n\n for (let row = 0; row < rowCount; row++) {\n for (let col = 0; col < cols; col++) {\n const x = offsetX + col * (cellWidth + gapX);\n const y = offsetY + row * (cellHeight + gapY);\n\n rects.push(\n <rect\n key={`${row}-${col}`}\n x={x}\n y={y}\n width={cellWidth}\n height={cellHeight}\n rx={borderRadius}\n ry={borderRadius}\n fill={color}\n />\n );\n }\n }\n\n return rects;\n }, [dims, rowCount, cols, borderRadius, color]);\n\n return (\n <svg\n className={className}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: width,\n height: totalHeight,\n pointerEvents: \"none\",\n ...style\n }}\n aria-hidden=\"true\"\n >\n {cells}\n </svg>\n );\n}\n\nexport default GridBackground;\n"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, DefaultBreakpoints, DragState, DropState, GridItem, GridItemCallback, GridItemProps, ResizeHandle, ResizeState, UseContainerWidthOptions, UseContainerWidthResult, UseGridLayoutOptions, UseGridLayoutResult, UseResponsiveLayoutOptions, UseResponsiveLayoutResult, useContainerWidth, useGridLayout, useResponsiveLayout } from './react.mjs';
|
|
2
|
+
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-D6lFRE3f.mjs';
|
|
3
|
+
export { B as Breakpoint, b as Breakpoints, C as CompactType, c as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, e as GridResizeEvent, L as Layout, a as LayoutItem, P as Position, d as ResizeHandleAxis, R as ResponsiveLayouts } from './types-Cxf4nHNr.mjs';
|
|
4
|
+
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-CJxefsYw.mjs';
|
|
5
|
+
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, f as setTopLeft, s as setTransform, v as validateLayout, e as verticalCompactor } from './position-BmN1z36J.mjs';
|
|
6
|
+
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-CwYDW8na.mjs';
|
|
7
|
+
import 'react';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, DefaultBreakpoints, DragState, DropState, GridItem, GridItemCallback, GridItemProps, ResizeHandle, ResizeState, UseContainerWidthOptions, UseContainerWidthResult, UseGridLayoutOptions, UseGridLayoutResult, UseResponsiveLayoutOptions, UseResponsiveLayoutResult, useContainerWidth, useGridLayout, useResponsiveLayout } from './react.js';
|
|
2
|
+
export { G as GridLayout, a as GridLayoutProps, G as ReactGridLayout, a as ReactGridLayoutProps, R as Responsive, R as ResponsiveGridLayout, b as ResponsiveGridLayoutProps, b as ResponsiveProps, G as default } from './ResponsiveGridLayout-CH4s0tKj.js';
|
|
3
|
+
export { B as Breakpoint, b as Breakpoints, C as CompactType, c as Compactor, D as DroppingPosition, E as EventCallback, G as GridDragEvent, e as GridResizeEvent, L as Layout, a as LayoutItem, P as Position, d as ResizeHandleAxis, R as ResponsiveLayouts } from './types-Cxf4nHNr.js';
|
|
4
|
+
export { c as collides, h as findOrGenerateResponsiveLayout, a as getAllCollisions, e as getBreakpointFromWidth, f as getColsFromBreakpoint, g as getFirstCollision, s as sortLayoutItems, d as sortLayoutItemsByColRow, b as sortLayoutItemsByRowCol } from './responsive-C4L1ESlm.js';
|
|
5
|
+
export { b as bottom, c as cloneLayout, a as cloneLayoutItem, d as getCompactor, g as getLayoutItem, h as horizontalCompactor, m as moveElement, n as noCompactor, f as setTopLeft, s as setTransform, v as validateLayout, e as verticalCompactor } from './position-Dk2b4ZMS.js';
|
|
6
|
+
export { c as calcGridItemPosition, b as calcWH, a as calcXY } from './calculate-mgLpNJ5O.js';
|
|
7
|
+
import 'react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var chunkH5KMDLY3_js = require('./chunk-H5KMDLY3.js');
|
|
6
|
+
require('./chunk-PBQSHIID.js');
|
|
7
|
+
var chunkBFTKGAP3_js = require('./chunk-BFTKGAP3.js');
|
|
8
|
+
var chunk3WO4SAYB_js = require('./chunk-3WO4SAYB.js');
|
|
9
|
+
var chunkF6NQPYKT_js = require('./chunk-F6NQPYKT.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Object.defineProperty(exports, "DEFAULT_BREAKPOINTS", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkH5KMDLY3_js.DEFAULT_BREAKPOINTS; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_COLS", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkH5KMDLY3_js.DEFAULT_COLS; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "useContainerWidth", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkH5KMDLY3_js.useContainerWidth; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "useGridLayout", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkH5KMDLY3_js.useGridLayout; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "useResponsiveLayout", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkH5KMDLY3_js.useResponsiveLayout; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "GridItem", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunkBFTKGAP3_js.GridItem; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "GridLayout", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return chunkBFTKGAP3_js.GridLayout; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "ReactGridLayout", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return chunkBFTKGAP3_js.GridLayout; }
|
|
44
|
+
});
|
|
45
|
+
Object.defineProperty(exports, "Responsive", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function () { return chunkBFTKGAP3_js.ResponsiveGridLayout; }
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "ResponsiveGridLayout", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () { return chunkBFTKGAP3_js.ResponsiveGridLayout; }
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(exports, "default", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return chunkBFTKGAP3_js.GridLayout; }
|
|
56
|
+
});
|
|
57
|
+
Object.defineProperty(exports, "bottom", {
|
|
58
|
+
enumerable: true,
|
|
59
|
+
get: function () { return chunk3WO4SAYB_js.bottom; }
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(exports, "cloneLayout", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function () { return chunk3WO4SAYB_js.cloneLayout; }
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(exports, "cloneLayoutItem", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () { return chunk3WO4SAYB_js.cloneLayoutItem; }
|
|
68
|
+
});
|
|
69
|
+
Object.defineProperty(exports, "collides", {
|
|
70
|
+
enumerable: true,
|
|
71
|
+
get: function () { return chunk3WO4SAYB_js.collides; }
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(exports, "findOrGenerateResponsiveLayout", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () { return chunk3WO4SAYB_js.findOrGenerateResponsiveLayout; }
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(exports, "getAllCollisions", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () { return chunk3WO4SAYB_js.getAllCollisions; }
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(exports, "getBreakpointFromWidth", {
|
|
82
|
+
enumerable: true,
|
|
83
|
+
get: function () { return chunk3WO4SAYB_js.getBreakpointFromWidth; }
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(exports, "getColsFromBreakpoint", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () { return chunk3WO4SAYB_js.getColsFromBreakpoint; }
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "getCompactor", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () { return chunk3WO4SAYB_js.getCompactor; }
|
|
92
|
+
});
|
|
93
|
+
Object.defineProperty(exports, "getFirstCollision", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get: function () { return chunk3WO4SAYB_js.getFirstCollision; }
|
|
96
|
+
});
|
|
97
|
+
Object.defineProperty(exports, "getLayoutItem", {
|
|
98
|
+
enumerable: true,
|
|
99
|
+
get: function () { return chunk3WO4SAYB_js.getLayoutItem; }
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(exports, "horizontalCompactor", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () { return chunk3WO4SAYB_js.horizontalCompactor; }
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(exports, "moveElement", {
|
|
106
|
+
enumerable: true,
|
|
107
|
+
get: function () { return chunk3WO4SAYB_js.moveElement; }
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, "noCompactor", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () { return chunk3WO4SAYB_js.noCompactor; }
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(exports, "setTopLeft", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
get: function () { return chunk3WO4SAYB_js.setTopLeft; }
|
|
116
|
+
});
|
|
117
|
+
Object.defineProperty(exports, "setTransform", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
get: function () { return chunk3WO4SAYB_js.setTransform; }
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(exports, "sortLayoutItems", {
|
|
122
|
+
enumerable: true,
|
|
123
|
+
get: function () { return chunk3WO4SAYB_js.sortLayoutItems; }
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(exports, "sortLayoutItemsByColRow", {
|
|
126
|
+
enumerable: true,
|
|
127
|
+
get: function () { return chunk3WO4SAYB_js.sortLayoutItemsByColRow; }
|
|
128
|
+
});
|
|
129
|
+
Object.defineProperty(exports, "sortLayoutItemsByRowCol", {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () { return chunk3WO4SAYB_js.sortLayoutItemsByRowCol; }
|
|
132
|
+
});
|
|
133
|
+
Object.defineProperty(exports, "validateLayout", {
|
|
134
|
+
enumerable: true,
|
|
135
|
+
get: function () { return chunk3WO4SAYB_js.validateLayout; }
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(exports, "verticalCompactor", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
get: function () { return chunk3WO4SAYB_js.verticalCompactor; }
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(exports, "calcGridItemPosition", {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function () { return chunkF6NQPYKT_js.calcGridItemPosition; }
|
|
144
|
+
});
|
|
145
|
+
Object.defineProperty(exports, "calcWH", {
|
|
146
|
+
enumerable: true,
|
|
147
|
+
get: function () { return chunkF6NQPYKT_js.calcWH; }
|
|
148
|
+
});
|
|
149
|
+
Object.defineProperty(exports, "calcXY", {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get: function () { return chunkF6NQPYKT_js.calcXY; }
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DEFAULT_BREAKPOINTS, DEFAULT_COLS, useContainerWidth, useGridLayout, useResponsiveLayout } from './chunk-ZCXE6SR5.mjs';
|
|
2
|
+
import './chunk-ZWN22PS2.mjs';
|
|
3
|
+
export { GridItem, GridLayout, GridLayout as ReactGridLayout, ResponsiveGridLayout as Responsive, ResponsiveGridLayout, GridLayout as default } from './chunk-R35HZZTA.mjs';
|
|
4
|
+
export { bottom, cloneLayout, cloneLayoutItem, collides, findOrGenerateResponsiveLayout, getAllCollisions, getBreakpointFromWidth, getColsFromBreakpoint, getCompactor, getFirstCollision, getLayoutItem, horizontalCompactor, moveElement, noCompactor, setTopLeft, setTransform, sortLayoutItems, sortLayoutItemsByColRow, sortLayoutItemsByRowCol, validateLayout, verticalCompactor } from './chunk-4HNUMWQK.mjs';
|
|
5
|
+
export { calcGridItemPosition, calcWH, calcXY } from './chunk-2KUHNJXF.mjs';
|
|
6
|
+
//# sourceMappingURL=index.mjs.map
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { ComponentType } from 'react';
|
|
3
|
+
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-D6lFRE3f.mjs';
|
|
4
|
+
import { L as Layout, a as LayoutItem, C as CompactType, d as ResizeHandleAxis, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-Cxf4nHNr.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Legacy props interface for backwards compatibility with v1 API.
|
|
8
|
+
* These flat props are converted to composable interfaces internally.
|
|
9
|
+
*/
|
|
10
|
+
interface LegacyReactGridLayoutProps {
|
|
11
|
+
children: React__default.ReactNode;
|
|
12
|
+
width: number;
|
|
13
|
+
cols?: number;
|
|
14
|
+
rowHeight?: number;
|
|
15
|
+
maxRows?: number;
|
|
16
|
+
margin?: readonly [number, number];
|
|
17
|
+
containerPadding?: readonly [number, number] | null;
|
|
18
|
+
layout?: Layout;
|
|
19
|
+
droppingItem?: LayoutItem;
|
|
20
|
+
compactType?: CompactType;
|
|
21
|
+
preventCollision?: boolean;
|
|
22
|
+
allowOverlap?: boolean;
|
|
23
|
+
/** @deprecated Use compactType instead */
|
|
24
|
+
verticalCompact?: boolean;
|
|
25
|
+
isDraggable?: boolean;
|
|
26
|
+
isBounded?: boolean;
|
|
27
|
+
draggableHandle?: string;
|
|
28
|
+
draggableCancel?: string;
|
|
29
|
+
isResizable?: boolean;
|
|
30
|
+
resizeHandles?: ResizeHandleAxis[];
|
|
31
|
+
resizeHandle?: React__default.ReactElement | ((axis: ResizeHandleAxis, ref: React__default.Ref<HTMLElement>) => React__default.ReactElement);
|
|
32
|
+
isDroppable?: boolean;
|
|
33
|
+
useCSSTransforms?: boolean;
|
|
34
|
+
transformScale?: number;
|
|
35
|
+
autoSize?: boolean;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: React__default.CSSProperties;
|
|
38
|
+
innerRef?: React__default.Ref<HTMLDivElement>;
|
|
39
|
+
onLayoutChange?: (layout: Layout) => void;
|
|
40
|
+
onDragStart?: GridLayoutProps["onDragStart"];
|
|
41
|
+
onDrag?: GridLayoutProps["onDrag"];
|
|
42
|
+
onDragStop?: GridLayoutProps["onDragStop"];
|
|
43
|
+
onResizeStart?: GridLayoutProps["onResizeStart"];
|
|
44
|
+
onResize?: GridLayoutProps["onResize"];
|
|
45
|
+
onResizeStop?: GridLayoutProps["onResizeStop"];
|
|
46
|
+
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
|
|
47
|
+
onDropDragOver?: (e: React__default.DragEvent) => {
|
|
48
|
+
w?: number;
|
|
49
|
+
h?: number;
|
|
50
|
+
} | false | void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ReactGridLayout - Legacy wrapper component
|
|
54
|
+
*
|
|
55
|
+
* Converts v1 flat props to v2 composable interfaces for backwards compatibility.
|
|
56
|
+
*/
|
|
57
|
+
declare function ReactGridLayout(props: LegacyReactGridLayoutProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
declare namespace ReactGridLayout {
|
|
59
|
+
var displayName: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Legacy props interface for backwards compatibility with v1 API.
|
|
64
|
+
* These flat props are converted to composable interfaces internally.
|
|
65
|
+
*/
|
|
66
|
+
interface LegacyResponsiveReactGridLayoutProps<B extends Breakpoint = string> {
|
|
67
|
+
children: React__default.ReactNode;
|
|
68
|
+
width: number;
|
|
69
|
+
breakpoint?: B;
|
|
70
|
+
breakpoints?: Breakpoints<B>;
|
|
71
|
+
cols?: Breakpoints<B>;
|
|
72
|
+
layouts?: ResponsiveLayouts<B>;
|
|
73
|
+
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
|
|
74
|
+
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
|
|
75
|
+
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
|
|
76
|
+
rowHeight?: number;
|
|
77
|
+
maxRows?: number;
|
|
78
|
+
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
|
|
79
|
+
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
|
|
80
|
+
droppingItem?: LayoutItem;
|
|
81
|
+
compactType?: CompactType;
|
|
82
|
+
preventCollision?: boolean;
|
|
83
|
+
allowOverlap?: boolean;
|
|
84
|
+
/** @deprecated Use compactType instead */
|
|
85
|
+
verticalCompact?: boolean;
|
|
86
|
+
isDraggable?: boolean;
|
|
87
|
+
isBounded?: boolean;
|
|
88
|
+
draggableHandle?: string;
|
|
89
|
+
draggableCancel?: string;
|
|
90
|
+
isResizable?: boolean;
|
|
91
|
+
resizeHandles?: ResizeHandleAxis[];
|
|
92
|
+
resizeHandle?: React__default.ReactElement | ((axis: ResizeHandleAxis, ref: React__default.Ref<HTMLElement>) => React__default.ReactElement);
|
|
93
|
+
isDroppable?: boolean;
|
|
94
|
+
useCSSTransforms?: boolean;
|
|
95
|
+
transformScale?: number;
|
|
96
|
+
autoSize?: boolean;
|
|
97
|
+
className?: string;
|
|
98
|
+
style?: React__default.CSSProperties;
|
|
99
|
+
innerRef?: React__default.Ref<HTMLDivElement>;
|
|
100
|
+
onDragStart?: ResponsiveGridLayoutProps<B>["onDragStart"];
|
|
101
|
+
onDrag?: ResponsiveGridLayoutProps<B>["onDrag"];
|
|
102
|
+
onDragStop?: ResponsiveGridLayoutProps<B>["onDragStop"];
|
|
103
|
+
onResizeStart?: ResponsiveGridLayoutProps<B>["onResizeStart"];
|
|
104
|
+
onResize?: ResponsiveGridLayoutProps<B>["onResize"];
|
|
105
|
+
onResizeStop?: ResponsiveGridLayoutProps<B>["onResizeStop"];
|
|
106
|
+
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
|
|
107
|
+
onDropDragOver?: (e: React__default.DragEvent) => {
|
|
108
|
+
w?: number;
|
|
109
|
+
h?: number;
|
|
110
|
+
} | false | void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* ResponsiveReactGridLayout - Legacy wrapper component
|
|
114
|
+
*
|
|
115
|
+
* Converts v1 flat props to v2 composable interfaces for backwards compatibility.
|
|
116
|
+
*/
|
|
117
|
+
declare function ResponsiveReactGridLayout<B extends Breakpoint = string>(props: LegacyResponsiveReactGridLayoutProps<B>): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare namespace ResponsiveReactGridLayout {
|
|
119
|
+
var displayName: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* WidthProvider HOC
|
|
124
|
+
*
|
|
125
|
+
* A Higher-Order Component that provides width measurement to grid layouts.
|
|
126
|
+
* This wraps any component and provides the container width as a prop.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface WidthProviderProps {
|
|
130
|
+
/** If true, will not render children until mounted */
|
|
131
|
+
measureBeforeMount?: boolean;
|
|
132
|
+
/** Additional class name */
|
|
133
|
+
className?: string;
|
|
134
|
+
/** Additional styles */
|
|
135
|
+
style?: React__default.CSSProperties;
|
|
136
|
+
}
|
|
137
|
+
type WithWidthProps<P> = Omit<P, "width"> & WidthProviderProps;
|
|
138
|
+
/**
|
|
139
|
+
* WidthProvider - HOC that provides container width
|
|
140
|
+
*
|
|
141
|
+
* A simple HOC that provides facility for listening to container resizes.
|
|
142
|
+
* Wraps the provided component and passes down a `width` prop.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { GridLayout, WidthProvider } from 'react-grid-layout';
|
|
147
|
+
*
|
|
148
|
+
* const GridLayoutWithWidth = WidthProvider(GridLayout);
|
|
149
|
+
*
|
|
150
|
+
* function MyGrid() {
|
|
151
|
+
* return (
|
|
152
|
+
* <GridLayoutWithWidth cols={12} rowHeight={30}>
|
|
153
|
+
* <div key="a">a</div>
|
|
154
|
+
* </GridLayoutWithWidth>
|
|
155
|
+
* );
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function WidthProvider<P extends {
|
|
160
|
+
width: number;
|
|
161
|
+
}>(ComposedComponent: ComponentType<P>): ComponentType<WithWidthProps<P>>;
|
|
162
|
+
|
|
163
|
+
export { Breakpoint, Breakpoints, CompactType, Layout, LayoutItem, type LegacyReactGridLayoutProps, type LegacyResponsiveReactGridLayoutProps, ReactGridLayout, ResizeHandleAxis, ResponsiveReactGridLayout as Responsive, ResponsiveLayouts, ResponsiveReactGridLayout, WidthProvider, ReactGridLayout as default };
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { ComponentType } from 'react';
|
|
3
|
+
import { a as GridLayoutProps, b as ResponsiveGridLayoutProps } from './ResponsiveGridLayout-CH4s0tKj.js';
|
|
4
|
+
import { L as Layout, a as LayoutItem, C as CompactType, d as ResizeHandleAxis, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-Cxf4nHNr.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Legacy props interface for backwards compatibility with v1 API.
|
|
8
|
+
* These flat props are converted to composable interfaces internally.
|
|
9
|
+
*/
|
|
10
|
+
interface LegacyReactGridLayoutProps {
|
|
11
|
+
children: React__default.ReactNode;
|
|
12
|
+
width: number;
|
|
13
|
+
cols?: number;
|
|
14
|
+
rowHeight?: number;
|
|
15
|
+
maxRows?: number;
|
|
16
|
+
margin?: readonly [number, number];
|
|
17
|
+
containerPadding?: readonly [number, number] | null;
|
|
18
|
+
layout?: Layout;
|
|
19
|
+
droppingItem?: LayoutItem;
|
|
20
|
+
compactType?: CompactType;
|
|
21
|
+
preventCollision?: boolean;
|
|
22
|
+
allowOverlap?: boolean;
|
|
23
|
+
/** @deprecated Use compactType instead */
|
|
24
|
+
verticalCompact?: boolean;
|
|
25
|
+
isDraggable?: boolean;
|
|
26
|
+
isBounded?: boolean;
|
|
27
|
+
draggableHandle?: string;
|
|
28
|
+
draggableCancel?: string;
|
|
29
|
+
isResizable?: boolean;
|
|
30
|
+
resizeHandles?: ResizeHandleAxis[];
|
|
31
|
+
resizeHandle?: React__default.ReactElement | ((axis: ResizeHandleAxis, ref: React__default.Ref<HTMLElement>) => React__default.ReactElement);
|
|
32
|
+
isDroppable?: boolean;
|
|
33
|
+
useCSSTransforms?: boolean;
|
|
34
|
+
transformScale?: number;
|
|
35
|
+
autoSize?: boolean;
|
|
36
|
+
className?: string;
|
|
37
|
+
style?: React__default.CSSProperties;
|
|
38
|
+
innerRef?: React__default.Ref<HTMLDivElement>;
|
|
39
|
+
onLayoutChange?: (layout: Layout) => void;
|
|
40
|
+
onDragStart?: GridLayoutProps["onDragStart"];
|
|
41
|
+
onDrag?: GridLayoutProps["onDrag"];
|
|
42
|
+
onDragStop?: GridLayoutProps["onDragStop"];
|
|
43
|
+
onResizeStart?: GridLayoutProps["onResizeStart"];
|
|
44
|
+
onResize?: GridLayoutProps["onResize"];
|
|
45
|
+
onResizeStop?: GridLayoutProps["onResizeStop"];
|
|
46
|
+
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
|
|
47
|
+
onDropDragOver?: (e: React__default.DragEvent) => {
|
|
48
|
+
w?: number;
|
|
49
|
+
h?: number;
|
|
50
|
+
} | false | void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* ReactGridLayout - Legacy wrapper component
|
|
54
|
+
*
|
|
55
|
+
* Converts v1 flat props to v2 composable interfaces for backwards compatibility.
|
|
56
|
+
*/
|
|
57
|
+
declare function ReactGridLayout(props: LegacyReactGridLayoutProps): react_jsx_runtime.JSX.Element;
|
|
58
|
+
declare namespace ReactGridLayout {
|
|
59
|
+
var displayName: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Legacy props interface for backwards compatibility with v1 API.
|
|
64
|
+
* These flat props are converted to composable interfaces internally.
|
|
65
|
+
*/
|
|
66
|
+
interface LegacyResponsiveReactGridLayoutProps<B extends Breakpoint = string> {
|
|
67
|
+
children: React__default.ReactNode;
|
|
68
|
+
width: number;
|
|
69
|
+
breakpoint?: B;
|
|
70
|
+
breakpoints?: Breakpoints<B>;
|
|
71
|
+
cols?: Breakpoints<B>;
|
|
72
|
+
layouts?: ResponsiveLayouts<B>;
|
|
73
|
+
onBreakpointChange?: (newBreakpoint: B, cols: number) => void;
|
|
74
|
+
onLayoutChange?: (layout: Layout, layouts: ResponsiveLayouts<B>) => void;
|
|
75
|
+
onWidthChange?: (containerWidth: number, margin: readonly [number, number], cols: number, containerPadding: readonly [number, number] | null) => void;
|
|
76
|
+
rowHeight?: number;
|
|
77
|
+
maxRows?: number;
|
|
78
|
+
margin?: readonly [number, number] | Partial<Record<B, readonly [number, number]>>;
|
|
79
|
+
containerPadding?: readonly [number, number] | Partial<Record<B, readonly [number, number] | null>> | null;
|
|
80
|
+
droppingItem?: LayoutItem;
|
|
81
|
+
compactType?: CompactType;
|
|
82
|
+
preventCollision?: boolean;
|
|
83
|
+
allowOverlap?: boolean;
|
|
84
|
+
/** @deprecated Use compactType instead */
|
|
85
|
+
verticalCompact?: boolean;
|
|
86
|
+
isDraggable?: boolean;
|
|
87
|
+
isBounded?: boolean;
|
|
88
|
+
draggableHandle?: string;
|
|
89
|
+
draggableCancel?: string;
|
|
90
|
+
isResizable?: boolean;
|
|
91
|
+
resizeHandles?: ResizeHandleAxis[];
|
|
92
|
+
resizeHandle?: React__default.ReactElement | ((axis: ResizeHandleAxis, ref: React__default.Ref<HTMLElement>) => React__default.ReactElement);
|
|
93
|
+
isDroppable?: boolean;
|
|
94
|
+
useCSSTransforms?: boolean;
|
|
95
|
+
transformScale?: number;
|
|
96
|
+
autoSize?: boolean;
|
|
97
|
+
className?: string;
|
|
98
|
+
style?: React__default.CSSProperties;
|
|
99
|
+
innerRef?: React__default.Ref<HTMLDivElement>;
|
|
100
|
+
onDragStart?: ResponsiveGridLayoutProps<B>["onDragStart"];
|
|
101
|
+
onDrag?: ResponsiveGridLayoutProps<B>["onDrag"];
|
|
102
|
+
onDragStop?: ResponsiveGridLayoutProps<B>["onDragStop"];
|
|
103
|
+
onResizeStart?: ResponsiveGridLayoutProps<B>["onResizeStart"];
|
|
104
|
+
onResize?: ResponsiveGridLayoutProps<B>["onResize"];
|
|
105
|
+
onResizeStop?: ResponsiveGridLayoutProps<B>["onResizeStop"];
|
|
106
|
+
onDrop?: (layout: Layout, item: LayoutItem | undefined, e: Event) => void;
|
|
107
|
+
onDropDragOver?: (e: React__default.DragEvent) => {
|
|
108
|
+
w?: number;
|
|
109
|
+
h?: number;
|
|
110
|
+
} | false | void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* ResponsiveReactGridLayout - Legacy wrapper component
|
|
114
|
+
*
|
|
115
|
+
* Converts v1 flat props to v2 composable interfaces for backwards compatibility.
|
|
116
|
+
*/
|
|
117
|
+
declare function ResponsiveReactGridLayout<B extends Breakpoint = string>(props: LegacyResponsiveReactGridLayoutProps<B>): react_jsx_runtime.JSX.Element;
|
|
118
|
+
declare namespace ResponsiveReactGridLayout {
|
|
119
|
+
var displayName: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* WidthProvider HOC
|
|
124
|
+
*
|
|
125
|
+
* A Higher-Order Component that provides width measurement to grid layouts.
|
|
126
|
+
* This wraps any component and provides the container width as a prop.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface WidthProviderProps {
|
|
130
|
+
/** If true, will not render children until mounted */
|
|
131
|
+
measureBeforeMount?: boolean;
|
|
132
|
+
/** Additional class name */
|
|
133
|
+
className?: string;
|
|
134
|
+
/** Additional styles */
|
|
135
|
+
style?: React__default.CSSProperties;
|
|
136
|
+
}
|
|
137
|
+
type WithWidthProps<P> = Omit<P, "width"> & WidthProviderProps;
|
|
138
|
+
/**
|
|
139
|
+
* WidthProvider - HOC that provides container width
|
|
140
|
+
*
|
|
141
|
+
* A simple HOC that provides facility for listening to container resizes.
|
|
142
|
+
* Wraps the provided component and passes down a `width` prop.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```tsx
|
|
146
|
+
* import { GridLayout, WidthProvider } from 'react-grid-layout';
|
|
147
|
+
*
|
|
148
|
+
* const GridLayoutWithWidth = WidthProvider(GridLayout);
|
|
149
|
+
*
|
|
150
|
+
* function MyGrid() {
|
|
151
|
+
* return (
|
|
152
|
+
* <GridLayoutWithWidth cols={12} rowHeight={30}>
|
|
153
|
+
* <div key="a">a</div>
|
|
154
|
+
* </GridLayoutWithWidth>
|
|
155
|
+
* );
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
declare function WidthProvider<P extends {
|
|
160
|
+
width: number;
|
|
161
|
+
}>(ComposedComponent: ComponentType<P>): ComponentType<WithWidthProps<P>>;
|
|
162
|
+
|
|
163
|
+
export { Breakpoint, Breakpoints, CompactType, Layout, LayoutItem, type LegacyReactGridLayoutProps, type LegacyResponsiveReactGridLayoutProps, ReactGridLayout, ResizeHandleAxis, ResponsiveReactGridLayout as Responsive, ResponsiveLayouts, ResponsiveReactGridLayout, WidthProvider, ReactGridLayout as default };
|