@bsuite/page-builder 0.5.1 → 0.5.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"usePageGridLayout.d.ts","sourceRoot":"","sources":["../src/usePageGridLayout.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,0BAA0B,2IAM7B,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,cAAc,EACd,WAAgB,EAChB,aAAiB,EACjB,WAAkB,EAClB,gBAA6C,EAC7C,iBAA4C,GAC7C,EAAE,wBAAwB,GAAG,uBAAuB,CA8ZpD"}
1
+ {"version":3,"file":"usePageGridLayout.d.ts","sourceRoot":"","sources":["../src/usePageGridLayout.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAGV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,0BAA0B,2IAM7B,CAAC;AAEX;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,cAAc,EACd,WAAgB,EAChB,aAAiB,EACjB,WAAkB,EAClB,gBAA6C,EAC7C,iBAA4C,GAC7C,EAAE,wBAAwB,GAAG,uBAAuB,CA2cpD"}
@@ -1,5 +1,5 @@
1
1
  import { startTransition, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from 'react';
2
- import { noCompactor, verticalCompactor } from 'react-grid-layout';
2
+ import { verticalCompactor } from 'react-grid-layout';
3
3
  import { buildResponsiveLayouts } from './buildResponsiveLayouts.js';
4
4
  import { defaultPreferenceAdapter } from './preferences.js';
5
5
  import { rescaleLayout } from './rescaleLayout.js';
@@ -121,7 +121,55 @@ export function usePageGridLayout({ pageKey, defaultLayouts, defaultCols = 12, l
121
121
  }
122
122
  }, [baseCols, layoutCols, rawLayouts, setBaseCols, setSavedLayout]);
123
123
  const activeCols = useMemo(() => ({ lg: layoutCols, md: layoutCols, sm: layoutCols, xs: layoutCols, xxs: layoutCols }), [layoutCols]);
124
- const activeCompactor = useMemo(() => (isEditing ? { ...noCompactor, preventCollision: true } : verticalCompactor), [isEditing]);
124
+ /**
125
+ * The compactor handed to react-grid-layout — the SAME one in edit mode and
126
+ * view mode (bsuite#1588).
127
+ *
128
+ * Why this is NOT `{ ...noCompactor, preventCollision: true }` while editing
129
+ * -------------------------------------------------------------------------
130
+ * That was the original edit-mode config, present since this package's first
131
+ * commit, and it silently made drag/resize gestures unable to persist for
132
+ * any layout with adjacent cards. react-grid-layout derives three knobs
133
+ * straight off the compactor object:
134
+ *
135
+ * preventCollision = compactor.preventCollision ?? false // was true
136
+ * allowOverlap = compactor.allowOverlap // false
137
+ * compactType = compactor.type // was null
138
+ *
139
+ * and feeds them to `moveElement`, whose colliding-move branch is:
140
+ *
141
+ * if (hasCollisions && preventCollision) {
142
+ * l.x = oldX; l.y = oldY; l.moved = false; return layout; // full revert
143
+ * }
144
+ *
145
+ * With `compactType: null` there is NO compaction to displace the colliding
146
+ * neighbour, so the only outcome for a gesture landing on an occupied cell
147
+ * is a total revert. `onDragStop` then guards its emit with
148
+ * `if (oldLayout && !deepEqual(oldLayout, finalLayout)) onLayoutChange(...)`
149
+ * — a reverted gesture emits NOTHING, so the persisted layout could never
150
+ * change. Resize is rejected by the same lever (`if (preventCollision &&
151
+ * !allowOverlap)` restores the old w/h/x/y). The card still tracked the
152
+ * cursor because react-draggable/react-resizable transform the DOM node
153
+ * directly, independent of whether RGL accepted the move — which is why the
154
+ * gesture looked live while nothing ever saved.
155
+ *
156
+ * In a full-width stack (every card `w: cols` — the dominant archetype on
157
+ * /dashboard and /people/:id) EVERY reorder target is occupied, so EVERY
158
+ * gesture reverted.
159
+ *
160
+ * Why `verticalCompactor` in BOTH modes rather than another combination
161
+ * --------------------------------------------------------------------
162
+ * View mode always compacted vertically. An edit-mode compactor that allows
163
+ * free/overlapping placement therefore produces a layout the viewer
164
+ * immediately re-compacts away — the editor/viewer mismatch meant "free
165
+ * placement" was never deliverable, and Save & Exit re-compacted regardless.
166
+ * One compactor for both modes makes what the user arranges exactly what
167
+ * they get, lets `moveElement` displace neighbours (so reordering a stack
168
+ * works at all), and removes a spurious `onLayoutChange` that RGL fired on
169
+ * every edit-mode toggle purely because `compactType` changed — that echo
170
+ * carried the pre-gesture layout and was the only write reaching storage.
171
+ */
172
+ const activeCompactor = verticalCompactor;
125
173
  /**
126
174
  * Throttled layout-change handler.
127
175
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsuite/page-builder",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Shared BSuite responsive page-builder grid and layout persistence primitives",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",