react-grid-layout 2.0.0 → 2.1.1
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 +117 -28
- 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-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-4HNUMWQK.mjs → chunk-FLITZMQC.mjs} +198 -311
- package/dist/chunk-FLITZMQC.mjs.map +1 -0
- package/dist/{chunk-ZCXE6SR5.mjs → chunk-LIKX67MZ.mjs} +7 -5
- package/dist/chunk-LIKX67MZ.mjs.map +1 -0
- package/dist/{chunk-R35HZZTA.mjs → chunk-PLWMASMX.mjs} +208 -90
- package/dist/chunk-PLWMASMX.mjs.map +1 -0
- package/dist/{chunk-BFTKGAP3.js → chunk-RB2IKK5B.js} +260 -142
- package/dist/chunk-RB2IKK5B.js.map +1 -0
- package/dist/{chunk-3WO4SAYB.js → chunk-WWS3M5Y3.js} +238 -355
- package/dist/chunk-WWS3M5Y3.js.map +1 -0
- package/dist/{chunk-H5KMDLY3.js → chunk-YQQYHEEG.js} +43 -41
- package/dist/chunk-YQQYHEEG.js.map +1 -0
- package/dist/core.d.mts +159 -6
- package/dist/core.d.ts +159 -6
- package/dist/core.js +145 -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-CXNzFxI0.d.mts} +18 -7
- package/dist/{position-BmN1z36J.d.mts → position-Dk0FRWA9.d.ts} +18 -7
- 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 +5 -3
- 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
|
@@ -15,7 +15,7 @@ RGL is React-only and does not require jQuery.
|
|
|
15
15
|
|
|
16
16
|
> GIF from production usage on [BitMEX.com](https://www.bitmex.com)
|
|
17
17
|
|
|
18
|
-
[**[Demo](https://react-grid-layout.github.io/react-grid-layout/) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/
|
|
18
|
+
[**[Demo](https://react-grid-layout.github.io/react-grid-layout/) | [Changelog](/CHANGELOG.md) | [CodeSandbox Editable demo](https://codesandbox.io/p/sandbox/5ywf7c)**]
|
|
19
19
|
|
|
20
20
|
## Table of Contents
|
|
21
21
|
|
|
@@ -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
|
|
|
@@ -76,7 +76,24 @@ See the [RFC](./rfcs/0001-v2-typescript-rewrite.md#breaking-changes-in-v2) for d
|
|
|
76
76
|
+ import GridLayout, { Responsive, WidthProvider } from 'react-grid-layout/legacy';
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
This provides **100% API compatibility** with v1.
|
|
79
|
+
This provides **100% runtime API compatibility** with v1.
|
|
80
|
+
|
|
81
|
+
**TypeScript users**: If you were using `@types/react-grid-layout`, note that v2 includes its own types with some naming changes:
|
|
82
|
+
|
|
83
|
+
| Old (`@types/react-grid-layout`) | New (v2) | Notes |
|
|
84
|
+
| -------------------------------- | ------------------- | ----------------------- |
|
|
85
|
+
| `RGL.Layout` | `LayoutItem` | Single grid item |
|
|
86
|
+
| `RGL.Layout[]` | `Layout` | Array of items |
|
|
87
|
+
| `RGL.Layouts` | `ResponsiveLayouts` | Breakpoint → layout map |
|
|
88
|
+
|
|
89
|
+
```diff
|
|
90
|
+
- import RGL from 'react-grid-layout';
|
|
91
|
+
- const item: RGL.Layout = { i: 'a', x: 0, y: 0, w: 1, h: 1 };
|
|
92
|
+
- const layouts: RGL.Layouts = { lg: [item] };
|
|
93
|
+
+ import { LayoutItem, ResponsiveLayouts } from 'react-grid-layout/legacy';
|
|
94
|
+
+ const item: LayoutItem = { i: 'a', x: 0, y: 0, w: 1, h: 1 };
|
|
95
|
+
+ const layouts: ResponsiveLayouts = { lg: [item] };
|
|
96
|
+
```
|
|
80
97
|
|
|
81
98
|
**Full migration** - adopt the v2 API for new features and better tree-shaking:
|
|
82
99
|
|
|
@@ -124,17 +141,17 @@ function MyGrid() {
|
|
|
124
141
|
1. [Saving a Responsive Layout to LocalStorage](https://react-grid-layout.github.io/react-grid-layout/examples/08-localstorage-responsive.html)
|
|
125
142
|
1. [Minimum and Maximum Width/Height](https://react-grid-layout.github.io/react-grid-layout/examples/09-min-max-wh.html)
|
|
126
143
|
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. [
|
|
144
|
+
1. [Toolbox](https://react-grid-layout.github.io/react-grid-layout/examples/11-toolbox.html)
|
|
145
|
+
1. [Drag From Outside](https://react-grid-layout.github.io/react-grid-layout/examples/12-drag-from-outside.html)
|
|
146
|
+
1. [Bounded Layout](https://react-grid-layout.github.io/react-grid-layout/examples/13-bounded.html)
|
|
147
|
+
1. [Responsive Bootstrap-style Layout](https://react-grid-layout.github.io/react-grid-layout/examples/14-responsive-bootstrap-style.html)
|
|
148
|
+
1. [Scaled Containers](https://react-grid-layout.github.io/react-grid-layout/examples/15-scale.html)
|
|
149
|
+
1. [Allow Overlap](https://react-grid-layout.github.io/react-grid-layout/examples/16-allow-overlap.html)
|
|
150
|
+
1. [All Resizable Handles](https://react-grid-layout.github.io/react-grid-layout/examples/17-resizable-handles.html)
|
|
151
|
+
1. [Compactor Showcase](https://react-grid-layout.github.io/react-grid-layout/examples/18-compactors.html)
|
|
152
|
+
1. [Pluggable Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/19-constraints.html)
|
|
153
|
+
1. [Aspect Ratio Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/20-aspect-ratio.html)
|
|
154
|
+
1. [Custom Constraints](https://react-grid-layout.github.io/react-grid-layout/examples/21-custom-constraints.html)
|
|
138
155
|
|
|
139
156
|
#### Projects Using React-Grid-Layout
|
|
140
157
|
|
|
@@ -449,9 +466,9 @@ interface UseGridLayoutOptions {
|
|
|
449
466
|
cols: number;
|
|
450
467
|
/** Compaction type: 'vertical', 'horizontal', or null */
|
|
451
468
|
compactType?: CompactType;
|
|
452
|
-
/** Allow items to overlap */
|
|
469
|
+
/** Allow items to overlap (stack on top of each other) */
|
|
453
470
|
allowOverlap?: boolean;
|
|
454
|
-
/**
|
|
471
|
+
/** Block movement into occupied space instead of pushing items (no effect if allowOverlap is true) */
|
|
455
472
|
preventCollision?: boolean;
|
|
456
473
|
/** Called when layout changes */
|
|
457
474
|
onLayoutChange?: (layout: Layout) => void;
|
|
@@ -811,10 +828,30 @@ interface Compactor {
|
|
|
811
828
|
/** Identifies the compaction type */
|
|
812
829
|
type: "vertical" | "horizontal" | null | string;
|
|
813
830
|
|
|
814
|
-
/**
|
|
831
|
+
/**
|
|
832
|
+
* Whether items can overlap each other.
|
|
833
|
+
*
|
|
834
|
+
* When true:
|
|
835
|
+
* - Items can be placed on top of other items
|
|
836
|
+
* - Dragging into another item does NOT push it away
|
|
837
|
+
* - Compaction is skipped after drag/resize
|
|
838
|
+
*
|
|
839
|
+
* Use for: layered dashboards, free-form layouts
|
|
840
|
+
*/
|
|
815
841
|
allowOverlap: boolean;
|
|
816
842
|
|
|
817
|
-
/**
|
|
843
|
+
/**
|
|
844
|
+
* Whether to block movement that would cause collision.
|
|
845
|
+
*
|
|
846
|
+
* When true (and allowOverlap is false):
|
|
847
|
+
* - Dragging into another item is blocked (item snaps back)
|
|
848
|
+
* - Other items are NOT pushed away
|
|
849
|
+
* - Only affects movement, not compaction
|
|
850
|
+
*
|
|
851
|
+
* Use with noCompactor for: fixed grids, slot-based layouts
|
|
852
|
+
*
|
|
853
|
+
* Note: Has no effect when allowOverlap is true.
|
|
854
|
+
*/
|
|
818
855
|
preventCollision?: boolean;
|
|
819
856
|
|
|
820
857
|
/**
|
|
@@ -1090,7 +1127,7 @@ The `react-grid-layout/extras` entry point provides optional components that ext
|
|
|
1090
1127
|
|
|
1091
1128
|
Renders an SVG grid background that aligns with GridLayout cells. Use this to visualize the grid structure behind your layout.
|
|
1092
1129
|
|
|
1093
|
-
> Based on [PR #2175](https://github.com/react-grid-layout/react-grid-layout/pull/2175) by [@
|
|
1130
|
+
> Based on [PR #2175](https://github.com/react-grid-layout/react-grid-layout/pull/2175) by [@dmj900501](https://github.com/dmj900501).
|
|
1094
1131
|
|
|
1095
1132
|
```tsx
|
|
1096
1133
|
import { GridBackground } from "react-grid-layout/extras";
|
|
@@ -1146,6 +1183,58 @@ interface GridBackgroundProps {
|
|
|
1146
1183
|
}
|
|
1147
1184
|
```
|
|
1148
1185
|
|
|
1186
|
+
### Fast Compactors
|
|
1187
|
+
|
|
1188
|
+
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.
|
|
1189
|
+
|
|
1190
|
+
> 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).
|
|
1191
|
+
|
|
1192
|
+
```tsx
|
|
1193
|
+
import {
|
|
1194
|
+
fastVerticalCompactor,
|
|
1195
|
+
fastHorizontalCompactor,
|
|
1196
|
+
fastVerticalOverlapCompactor,
|
|
1197
|
+
fastHorizontalOverlapCompactor
|
|
1198
|
+
} from "react-grid-layout/extras";
|
|
1199
|
+
|
|
1200
|
+
<ReactGridLayout
|
|
1201
|
+
compactor={fastVerticalCompactor}
|
|
1202
|
+
// or compactor={fastHorizontalCompactor}
|
|
1203
|
+
layout={layout}
|
|
1204
|
+
width={width}
|
|
1205
|
+
/>;
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
**Performance Benchmarks:**
|
|
1209
|
+
|
|
1210
|
+
| Items | Standard Vertical | Fast Vertical | Speedup |
|
|
1211
|
+
| ----- | ----------------- | ------------- | ------- |
|
|
1212
|
+
| 50 | 112 µs | 19 µs | **6x** |
|
|
1213
|
+
| 100 | 203 µs | 36 µs | **6x** |
|
|
1214
|
+
| 200 | 821 µs | 51 µs | **16x** |
|
|
1215
|
+
| 500 | 5.7 ms | 129 µs | **45x** |
|
|
1216
|
+
|
|
1217
|
+
| Items | Standard Horizontal | Fast Horizontal | Speedup |
|
|
1218
|
+
| ----- | ------------------- | --------------- | ------- |
|
|
1219
|
+
| 50 | 164 µs | 12 µs | **14x** |
|
|
1220
|
+
| 100 | 477 µs | 25 µs | **19x** |
|
|
1221
|
+
| 200 | 1.1 ms | 42 µs | **26x** |
|
|
1222
|
+
| 500 | 9.5 ms | 128 µs | **74x** |
|
|
1223
|
+
|
|
1224
|
+
**Correctness:**
|
|
1225
|
+
|
|
1226
|
+
The fast compactors produce layouts identical to the standard compactors:
|
|
1227
|
+
|
|
1228
|
+
- **Vertical**: 0% height difference on deterministic 100-item layouts
|
|
1229
|
+
- **Horizontal**: 0% width difference on deterministic 100-item layouts
|
|
1230
|
+
- Both pass all correctness tests: no overlaps, idempotent, static item handling
|
|
1231
|
+
|
|
1232
|
+
**When to use:**
|
|
1233
|
+
|
|
1234
|
+
- Use fast compactors for dashboards with 200+ widgets
|
|
1235
|
+
- For smaller layouts (<100 items), standard compactors work equally well
|
|
1236
|
+
- Both standard and fast compactors produce valid, non-overlapping layouts
|
|
1237
|
+
|
|
1149
1238
|
### calcGridCellDimensions (Core Utility)
|
|
1150
1239
|
|
|
1151
1240
|
For building custom grid overlays or backgrounds, use the `calcGridCellDimensions` utility from `react-grid-layout/core`:
|
|
@@ -1261,5 +1350,5 @@ const CustomItem = forwardRef<HTMLDivElement, CustomItemProps>(
|
|
|
1261
1350
|
|
|
1262
1351
|
If you have a feature request, please add it as an issue or make a pull request.
|
|
1263
1352
|
|
|
1264
|
-
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/
|
|
1353
|
+
If you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/p/sandbox/5ywf7c) to help
|
|
1265
1354
|
us easily isolate it.
|
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 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-526JND3R.mjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-7ELO5FRW.js"}
|