react-grid-layout 2.0.0 → 2.1.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 +97 -25
- package/css/styles.css +0 -1
- package/dist/{ResponsiveGridLayout-D6lFRE3f.d.mts → ResponsiveGridLayout-BkHF9YHa.d.mts} +10 -1
- package/dist/{ResponsiveGridLayout-CH4s0tKj.d.ts → ResponsiveGridLayout-CLn16-X3.d.ts} +10 -1
- package/dist/{calculate-CwYDW8na.d.mts → calculate-DsVTldEE.d.ts} +30 -2
- package/dist/{calculate-mgLpNJ5O.d.ts → calculate-DwbL1D06.d.mts} +30 -2
- package/dist/{chunk-4HNUMWQK.mjs → chunk-2O3ZME4Q.mjs} +178 -297
- package/dist/chunk-2O3ZME4Q.mjs.map +1 -0
- package/dist/chunk-526JND3R.mjs +3 -0
- package/dist/{chunk-ZWN22PS2.mjs.map → chunk-526JND3R.mjs.map} +1 -1
- package/dist/chunk-7ELO5FRW.js +4 -0
- package/dist/{chunk-PBQSHIID.js.map → chunk-7ELO5FRW.js.map} +1 -1
- package/dist/chunk-AWM66AWF.mjs +422 -0
- package/dist/chunk-AWM66AWF.mjs.map +1 -0
- package/dist/chunk-BJFPTW5Q.js +449 -0
- package/dist/chunk-BJFPTW5Q.js.map +1 -0
- package/dist/{chunk-3WO4SAYB.js → chunk-FN6MIZ24.js} +221 -345
- package/dist/chunk-FN6MIZ24.js.map +1 -0
- package/dist/{chunk-H5KMDLY3.js → chunk-GPZBANOK.js} +40 -39
- package/dist/chunk-GPZBANOK.js.map +1 -0
- package/dist/{chunk-ZCXE6SR5.mjs → chunk-LWF5EYMO.mjs} +4 -3
- package/dist/chunk-LWF5EYMO.mjs.map +1 -0
- package/dist/{chunk-R35HZZTA.mjs → chunk-MXXN7GUE.mjs} +170 -62
- package/dist/chunk-MXXN7GUE.mjs.map +1 -0
- package/dist/{chunk-BFTKGAP3.js → chunk-QRW3ND4U.js} +230 -122
- package/dist/chunk-QRW3ND4U.js.map +1 -0
- package/dist/core.d.mts +159 -6
- package/dist/core.d.ts +159 -6
- package/dist/core.js +141 -85
- package/dist/core.mjs +3 -3
- package/dist/extras.d.mts +133 -3
- package/dist/extras.d.ts +133 -3
- package/dist/extras.js +373 -2
- package/dist/extras.js.map +1 -1
- package/dist/extras.mjs +367 -2
- package/dist/extras.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +64 -64
- package/dist/index.mjs +5 -5
- package/dist/legacy.d.mts +2 -2
- package/dist/legacy.d.ts +2 -2
- package/dist/legacy.js +26 -25
- package/dist/legacy.js.map +1 -1
- package/dist/legacy.mjs +16 -15
- package/dist/legacy.mjs.map +1 -1
- package/dist/{position-Dk2b4ZMS.d.ts → position-C8a5g6bb.d.mts} +11 -6
- package/dist/{position-BmN1z36J.d.mts → position-H8tBL91b.d.ts} +11 -6
- package/dist/react.d.mts +11 -5
- package/dist/react.d.ts +11 -5
- package/dist/react.js +38 -38
- package/dist/react.mjs +5 -5
- package/dist/{responsive-CJxefsYw.d.mts → responsive-BB5d98xz.d.mts} +1 -1
- package/dist/{responsive-C4L1ESlm.d.ts → responsive-BXI-GCXG.d.ts} +1 -1
- package/dist/{types-Cxf4nHNr.d.mts → types-CokovIMH.d.mts} +98 -4
- package/dist/{types-Cxf4nHNr.d.ts → types-CokovIMH.d.ts} +98 -4
- package/index-dev.js +16 -0
- package/package.json +2 -1
- package/dist/chunk-2KUHNJXF.mjs +0 -90
- package/dist/chunk-2KUHNJXF.mjs.map +0 -1
- package/dist/chunk-3WO4SAYB.js.map +0 -1
- package/dist/chunk-4HNUMWQK.mjs.map +0 -1
- package/dist/chunk-BFTKGAP3.js.map +0 -1
- package/dist/chunk-F6NQPYKT.js +0 -98
- package/dist/chunk-F6NQPYKT.js.map +0 -1
- package/dist/chunk-H5KMDLY3.js.map +0 -1
- package/dist/chunk-PBQSHIID.js +0 -4
- package/dist/chunk-R35HZZTA.mjs.map +0 -1
- package/dist/chunk-ZCXE6SR5.mjs.map +0 -1
- package/dist/chunk-ZWN22PS2.mjs +0 -3
package/README.md
CHANGED
|
@@ -57,15 +57,15 @@ Version 2 is a complete TypeScript rewrite with a modernized API:
|
|
|
57
57
|
|
|
58
58
|
See the [RFC](./rfcs/0001-v2-typescript-rewrite.md#breaking-changes-in-v2) for detailed migration examples.
|
|
59
59
|
|
|
60
|
-
| Change | Description
|
|
61
|
-
| -------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
-
| [`width` prop required](./rfcs/0001-v2-typescript-rewrite.md#breaking-changes-in-v2) | Use `useContainerWidth` hook or provide your own measurement
|
|
63
|
-
| [`onDragStart` threshold](./rfcs/0001-v2-typescript-rewrite.md#1-ondragstart-no-longer-fires-on-click-only-events) | Now fires after 3px movement, not on mousedown. Use `onMouseDown` for immediate response
|
|
64
|
-
| [Immutable callbacks](./rfcs/0001-v2-typescript-rewrite.md#2-immutable-callback-parameters) | Callback parameters are read-only. Use `onLayoutChange` or constraints instead of mutation
|
|
65
|
-
| [`data-grid` in legacy only](./rfcs/0001-v2-typescript-rewrite.md#3-data-grid-prop-only-available-in-legacy-wrapper) | v2 requires explicit `layout` prop. Use legacy wrapper for `data-grid`
|
|
66
|
-
| [
|
|
67
|
-
| UMD bundle removed | Use a bundler (Vite, webpack, esbuild)
|
|
68
|
-
| `verticalCompact` removed | Use `compactType={null}` or `compactor={noCompactor}`
|
|
60
|
+
| Change | Description |
|
|
61
|
+
| -------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
62
|
+
| [`width` prop required](./rfcs/0001-v2-typescript-rewrite.md#breaking-changes-in-v2) | Use `useContainerWidth` hook or provide your own measurement |
|
|
63
|
+
| [`onDragStart` threshold](./rfcs/0001-v2-typescript-rewrite.md#1-ondragstart-no-longer-fires-on-click-only-events) | Now fires after 3px movement, not on mousedown. Use `onMouseDown` for immediate response |
|
|
64
|
+
| [Immutable callbacks](./rfcs/0001-v2-typescript-rewrite.md#2-immutable-callback-parameters) | Callback parameters are read-only. Use `onLayoutChange` or constraints instead of mutation |
|
|
65
|
+
| [`data-grid` in legacy only](./rfcs/0001-v2-typescript-rewrite.md#3-data-grid-prop-only-available-in-legacy-wrapper) | v2 requires explicit `layout` prop. Use legacy wrapper for `data-grid` |
|
|
66
|
+
| [Pluggable compaction](./rfcs/0001-v2-typescript-rewrite.md#4-pluggable-compaction-algorithms) | Compaction is now pluggable via `Compactor` interface. Optional fast O(n log n) algorithm in `/extras` |
|
|
67
|
+
| UMD bundle removed | Use a bundler (Vite, webpack, esbuild) |
|
|
68
|
+
| `verticalCompact` removed | Use `compactType={null}` or `compactor={noCompactor}` |
|
|
69
69
|
|
|
70
70
|
## Migrating from v1
|
|
71
71
|
|
|
@@ -124,17 +124,17 @@ function MyGrid() {
|
|
|
124
124
|
1. [Saving a Responsive Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/08-localstorage-responsive.html)
|
|
125
125
|
1. [Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/09-min-max-wh.html)
|
|
126
126
|
1. [Dynamic Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/10-dynamic-min-max-wh.html)
|
|
127
|
-
1. [
|
|
128
|
-
1. [
|
|
129
|
-
1. [
|
|
130
|
-
1. [
|
|
131
|
-
1. [
|
|
132
|
-
1. [
|
|
133
|
-
1. [
|
|
134
|
-
1. [
|
|
135
|
-
1. [
|
|
136
|
-
1. [
|
|
137
|
-
1. [
|
|
127
|
+
1. [Toolbox](https://react-grid-layout.github.io/react-grid-layout/examples/11-toolbox.html)
|
|
128
|
+
1. [Drag From Outside](https://react-grid-layout.github.io/react-grid-layout/examples/12-drag-from-outside.html)
|
|
129
|
+
1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/13-bounded.html)
|
|
130
|
+
1. [Responsive Bootstrap-style Layout](https://react-grid-layout.github.io/react-grid-layout/examples/14-responsive-bootstrap-style.html)
|
|
131
|
+
1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/15-scale.html)
|
|
132
|
+
1. [Allow Overlap](https://react-grid-layout.github.io/react-grid-layout/examples/16-allow-overlap.html)
|
|
133
|
+
1. [All Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/17-resizable-handles.html)
|
|
134
|
+
1. [Compactor Showcase](https://react-grid-layout.github.io/react-grid-layout/examples/18-compactors.html)
|
|
135
|
+
1. [Pluggable Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/19-constraints.html)
|
|
136
|
+
1. [Aspect Ratio Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/20-aspect-ratio.html)
|
|
137
|
+
1. [Custom Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/21-custom-constraints.html)
|
|
138
138
|
|
|
139
139
|
#### Projects Using React-Grid-Layout
|
|
140
140
|
|
|
@@ -449,9 +449,9 @@ interface UseGridLayoutOptions {
|
|
|
449
449
|
cols: number;
|
|
450
450
|
/** Compaction type: 'vertical', 'horizontal', or null */
|
|
451
451
|
compactType?: CompactType;
|
|
452
|
-
/** Allow items to overlap */
|
|
452
|
+
/** Allow items to overlap (stack on top of each other) */
|
|
453
453
|
allowOverlap?: boolean;
|
|
454
|
-
/**
|
|
454
|
+
/** Block movement into occupied space instead of pushing items (no effect if allowOverlap is true) */
|
|
455
455
|
preventCollision?: boolean;
|
|
456
456
|
/** Called when layout changes */
|
|
457
457
|
onLayoutChange?: (layout: Layout) => void;
|
|
@@ -811,10 +811,30 @@ interface Compactor {
|
|
|
811
811
|
/** Identifies the compaction type */
|
|
812
812
|
type: "vertical" | "horizontal" | null | string;
|
|
813
813
|
|
|
814
|
-
/**
|
|
814
|
+
/**
|
|
815
|
+
* Whether items can overlap each other.
|
|
816
|
+
*
|
|
817
|
+
* When true:
|
|
818
|
+
* - Items can be placed on top of other items
|
|
819
|
+
* - Dragging into another item does NOT push it away
|
|
820
|
+
* - Compaction is skipped after drag/resize
|
|
821
|
+
*
|
|
822
|
+
* Use for: layered dashboards, free-form layouts
|
|
823
|
+
*/
|
|
815
824
|
allowOverlap: boolean;
|
|
816
825
|
|
|
817
|
-
/**
|
|
826
|
+
/**
|
|
827
|
+
* Whether to block movement that would cause collision.
|
|
828
|
+
*
|
|
829
|
+
* When true (and allowOverlap is false):
|
|
830
|
+
* - Dragging into another item is blocked (item snaps back)
|
|
831
|
+
* - Other items are NOT pushed away
|
|
832
|
+
* - Only affects movement, not compaction
|
|
833
|
+
*
|
|
834
|
+
* Use with noCompactor for: fixed grids, slot-based layouts
|
|
835
|
+
*
|
|
836
|
+
* Note: Has no effect when allowOverlap is true.
|
|
837
|
+
*/
|
|
818
838
|
preventCollision?: boolean;
|
|
819
839
|
|
|
820
840
|
/**
|
|
@@ -1090,7 +1110,7 @@ The `react-grid-layout/extras` entry point provides optional components that ext
|
|
|
1090
1110
|
|
|
1091
1111
|
Renders an SVG grid background that aligns with GridLayout cells. Use this to visualize the grid structure behind your layout.
|
|
1092
1112
|
|
|
1093
|
-
> Based on [PR #2175](https://github.com/react-grid-layout/react-grid-layout/pull/2175) by [@
|
|
1113
|
+
> Based on [PR #2175](https://github.com/react-grid-layout/react-grid-layout/pull/2175) by [@dmj900501](https://github.com/dmj900501).
|
|
1094
1114
|
|
|
1095
1115
|
```tsx
|
|
1096
1116
|
import { GridBackground } from "react-grid-layout/extras";
|
|
@@ -1146,6 +1166,58 @@ interface GridBackgroundProps {
|
|
|
1146
1166
|
}
|
|
1147
1167
|
```
|
|
1148
1168
|
|
|
1169
|
+
### Fast Compactors
|
|
1170
|
+
|
|
1171
|
+
For large layouts (200+ items), the standard compactors can become slow due to O(n²) collision resolution. The fast compactors use optimized algorithms with O(n log n) complexity.
|
|
1172
|
+
|
|
1173
|
+
> Based on the "rising tide" algorithm from [PR #2152](https://github.com/react-grid-layout/react-grid-layout/pull/2152) by [@morris](https://github.com/morris).
|
|
1174
|
+
|
|
1175
|
+
```tsx
|
|
1176
|
+
import {
|
|
1177
|
+
fastVerticalCompactor,
|
|
1178
|
+
fastHorizontalCompactor,
|
|
1179
|
+
fastVerticalOverlapCompactor,
|
|
1180
|
+
fastHorizontalOverlapCompactor
|
|
1181
|
+
} from "react-grid-layout/extras";
|
|
1182
|
+
|
|
1183
|
+
<ReactGridLayout
|
|
1184
|
+
compactor={fastVerticalCompactor}
|
|
1185
|
+
// or compactor={fastHorizontalCompactor}
|
|
1186
|
+
layout={layout}
|
|
1187
|
+
width={width}
|
|
1188
|
+
/>;
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
**Performance Benchmarks:**
|
|
1192
|
+
|
|
1193
|
+
| Items | Standard Vertical | Fast Vertical | Speedup |
|
|
1194
|
+
| ----- | ----------------- | ------------- | ------- |
|
|
1195
|
+
| 50 | 112 µs | 19 µs | **6x** |
|
|
1196
|
+
| 100 | 203 µs | 36 µs | **6x** |
|
|
1197
|
+
| 200 | 821 µs | 51 µs | **16x** |
|
|
1198
|
+
| 500 | 5.7 ms | 129 µs | **45x** |
|
|
1199
|
+
|
|
1200
|
+
| Items | Standard Horizontal | Fast Horizontal | Speedup |
|
|
1201
|
+
| ----- | ------------------- | --------------- | ------- |
|
|
1202
|
+
| 50 | 164 µs | 12 µs | **14x** |
|
|
1203
|
+
| 100 | 477 µs | 25 µs | **19x** |
|
|
1204
|
+
| 200 | 1.1 ms | 42 µs | **26x** |
|
|
1205
|
+
| 500 | 9.5 ms | 128 µs | **74x** |
|
|
1206
|
+
|
|
1207
|
+
**Correctness:**
|
|
1208
|
+
|
|
1209
|
+
The fast compactors produce layouts identical to the standard compactors:
|
|
1210
|
+
|
|
1211
|
+
- **Vertical**: 0% height difference on deterministic 100-item layouts
|
|
1212
|
+
- **Horizontal**: 0% width difference on deterministic 100-item layouts
|
|
1213
|
+
- Both pass all correctness tests: no overlaps, idempotent, static item handling
|
|
1214
|
+
|
|
1215
|
+
**When to use:**
|
|
1216
|
+
|
|
1217
|
+
- Use fast compactors for dashboards with 200+ widgets
|
|
1218
|
+
- For smaller layouts (<100 items), standard compactors work equally well
|
|
1219
|
+
- Both standard and fast compactors produce valid, non-overlapping layouts
|
|
1220
|
+
|
|
1149
1221
|
### calcGridCellDimensions (Core Utility)
|
|
1150
1222
|
|
|
1151
1223
|
For building custom grid overlays or backgrounds, use the `calcGridCellDimensions` utility from `react-grid-layout/core`:
|
package/css/styles.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { l as GridConfig, m as DragConfig, n as ResizeConfig, o as DropConfig, k as PositionStrategy, c as Compactor, f as LayoutConstraint, L as Layout, a as LayoutItem, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-CokovIMH.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* GridLayout component
|
|
@@ -45,6 +45,13 @@ interface GridLayoutProps {
|
|
|
45
45
|
* @see Compactor
|
|
46
46
|
*/
|
|
47
47
|
compactor?: Compactor;
|
|
48
|
+
/**
|
|
49
|
+
* Layout constraints for position and size limiting.
|
|
50
|
+
* Applied during drag/resize operations.
|
|
51
|
+
* Default: [gridBounds, minMaxSize]
|
|
52
|
+
* @see LayoutConstraint
|
|
53
|
+
*/
|
|
54
|
+
constraints?: LayoutConstraint[];
|
|
48
55
|
/** Layout definition */
|
|
49
56
|
layout?: Layout;
|
|
50
57
|
/** Item to use when dropping from outside */
|
|
@@ -77,6 +84,8 @@ interface GridLayoutProps {
|
|
|
77
84
|
onDropDragOver?: (e: DragEvent) => {
|
|
78
85
|
w?: number;
|
|
79
86
|
h?: number;
|
|
87
|
+
dragOffsetX?: number;
|
|
88
|
+
dragOffsetY?: number;
|
|
80
89
|
} | false | void;
|
|
81
90
|
}
|
|
82
91
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default, { CSSProperties, DragEvent, ReactElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { l as GridConfig, m as DragConfig, n as ResizeConfig, o as DropConfig, k as PositionStrategy, c as Compactor, f as LayoutConstraint, L as Layout, a as LayoutItem, B as Breakpoint, b as Breakpoints, R as ResponsiveLayouts } from './types-CokovIMH.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* GridLayout component
|
|
@@ -45,6 +45,13 @@ interface GridLayoutProps {
|
|
|
45
45
|
* @see Compactor
|
|
46
46
|
*/
|
|
47
47
|
compactor?: Compactor;
|
|
48
|
+
/**
|
|
49
|
+
* Layout constraints for position and size limiting.
|
|
50
|
+
* Applied during drag/resize operations.
|
|
51
|
+
* Default: [gridBounds, minMaxSize]
|
|
52
|
+
* @see LayoutConstraint
|
|
53
|
+
*/
|
|
54
|
+
constraints?: LayoutConstraint[];
|
|
48
55
|
/** Layout definition */
|
|
49
56
|
layout?: Layout;
|
|
50
57
|
/** Item to use when dropping from outside */
|
|
@@ -77,6 +84,8 @@ interface GridLayoutProps {
|
|
|
77
84
|
onDropDragOver?: (e: DragEvent) => {
|
|
78
85
|
w?: number;
|
|
79
86
|
h?: number;
|
|
87
|
+
dragOffsetX?: number;
|
|
88
|
+
dragOffsetY?: number;
|
|
80
89
|
} | false | void;
|
|
81
90
|
}
|
|
82
91
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Position, d as ResizeHandleAxis } from './types-
|
|
1
|
+
import { P as Position, d as ResizeHandleAxis } from './types-CokovIMH.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Grid calculation utilities.
|
|
@@ -74,6 +74,20 @@ declare function calcXY(positionParams: PositionParams, top: number, left: numbe
|
|
|
74
74
|
x: number;
|
|
75
75
|
y: number;
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Translate pixel coordinates to grid units without clamping.
|
|
79
|
+
*
|
|
80
|
+
* Use this with the constraint system for custom boundary control.
|
|
81
|
+
*
|
|
82
|
+
* @param positionParams - Grid parameters
|
|
83
|
+
* @param top - Top position in pixels (relative to parent)
|
|
84
|
+
* @param left - Left position in pixels (relative to parent)
|
|
85
|
+
* @returns x and y in grid units (unclamped)
|
|
86
|
+
*/
|
|
87
|
+
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
77
91
|
/**
|
|
78
92
|
* Calculate grid units from pixel dimensions.
|
|
79
93
|
*
|
|
@@ -89,6 +103,20 @@ declare function calcWH(positionParams: PositionParams, width: number, height: n
|
|
|
89
103
|
w: number;
|
|
90
104
|
h: number;
|
|
91
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Calculate grid units from pixel dimensions without clamping.
|
|
108
|
+
*
|
|
109
|
+
* Use this with the constraint system for custom size control.
|
|
110
|
+
*
|
|
111
|
+
* @param positionParams - Grid parameters
|
|
112
|
+
* @param width - Width in pixels
|
|
113
|
+
* @param height - Height in pixels
|
|
114
|
+
* @returns w, h in grid units (unclamped, minimum 1)
|
|
115
|
+
*/
|
|
116
|
+
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
|
|
117
|
+
w: number;
|
|
118
|
+
h: number;
|
|
119
|
+
};
|
|
92
120
|
/**
|
|
93
121
|
* Clamp a number between bounds.
|
|
94
122
|
*
|
|
@@ -165,4 +193,4 @@ interface GridCellConfig {
|
|
|
165
193
|
*/
|
|
166
194
|
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
|
|
167
195
|
|
|
168
|
-
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f,
|
|
196
|
+
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f, calcXYRaw as g, calcWHRaw as h, clamp as i, calcGridCellDimensions as j };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Position, d as ResizeHandleAxis } from './types-
|
|
1
|
+
import { P as Position, d as ResizeHandleAxis } from './types-CokovIMH.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Grid calculation utilities.
|
|
@@ -74,6 +74,20 @@ declare function calcXY(positionParams: PositionParams, top: number, left: numbe
|
|
|
74
74
|
x: number;
|
|
75
75
|
y: number;
|
|
76
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* Translate pixel coordinates to grid units without clamping.
|
|
79
|
+
*
|
|
80
|
+
* Use this with the constraint system for custom boundary control.
|
|
81
|
+
*
|
|
82
|
+
* @param positionParams - Grid parameters
|
|
83
|
+
* @param top - Top position in pixels (relative to parent)
|
|
84
|
+
* @param left - Left position in pixels (relative to parent)
|
|
85
|
+
* @returns x and y in grid units (unclamped)
|
|
86
|
+
*/
|
|
87
|
+
declare function calcXYRaw(positionParams: PositionParams, top: number, left: number): {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
77
91
|
/**
|
|
78
92
|
* Calculate grid units from pixel dimensions.
|
|
79
93
|
*
|
|
@@ -89,6 +103,20 @@ declare function calcWH(positionParams: PositionParams, width: number, height: n
|
|
|
89
103
|
w: number;
|
|
90
104
|
h: number;
|
|
91
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* Calculate grid units from pixel dimensions without clamping.
|
|
108
|
+
*
|
|
109
|
+
* Use this with the constraint system for custom size control.
|
|
110
|
+
*
|
|
111
|
+
* @param positionParams - Grid parameters
|
|
112
|
+
* @param width - Width in pixels
|
|
113
|
+
* @param height - Height in pixels
|
|
114
|
+
* @returns w, h in grid units (unclamped, minimum 1)
|
|
115
|
+
*/
|
|
116
|
+
declare function calcWHRaw(positionParams: PositionParams, width: number, height: number): {
|
|
117
|
+
w: number;
|
|
118
|
+
h: number;
|
|
119
|
+
};
|
|
92
120
|
/**
|
|
93
121
|
* Clamp a number between bounds.
|
|
94
122
|
*
|
|
@@ -165,4 +193,4 @@ interface GridCellConfig {
|
|
|
165
193
|
*/
|
|
166
194
|
declare function calcGridCellDimensions(config: GridCellConfig): GridCellDimensions;
|
|
167
195
|
|
|
168
|
-
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f,
|
|
196
|
+
export { type GridCellDimensions as G, type PositionParams as P, calcXY as a, calcWH as b, calcGridItemPosition as c, type GridCellConfig as d, calcGridColWidth as e, calcGridItemWHPx as f, calcXYRaw as g, calcWHRaw as h, clamp as i, calcGridCellDimensions as j };
|