@bsuite/page-builder 0.5.0 → 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.
package/dist/PageGridLayout.js
CHANGED
|
@@ -145,7 +145,7 @@ const GridItem = React.memo(React.forwardRef(function GridItem({ id, content, is
|
|
|
145
145
|
return (_jsxs("div", { ref: ref, className: outerClass, style: injectedStyle, ...rest, children: [_jsxs("div", { className: "h-full w-full relative", children: [isEditing && (_jsx("div", { className: "absolute inset-0 z-10 pointer-events-none rounded-3xl border-2 border-transparent group-hover:border-primary/50 transition-colors bg-black/5" })), isEditing && (_jsx("div", { className: "absolute top-2 left-2 z-30 flex items-center gap-1 pointer-events-none", children: _jsx("span", { className: "text-[10px] px-1.5 py-0.5 rounded-md opacity-80 font-medium bg-muted text-muted-foreground", children: label }) })), isEditing && (_jsx("button", { className: "absolute top-2 right-2 z-30 h-6 w-6 rounded-full flex items-center justify-center bg-destructive/80 hover:bg-destructive text-white shadow transition-colors", "data-no-drag": true, onPointerDown: (event) => event.stopPropagation(), onClick: (event) => {
|
|
146
146
|
event.stopPropagation();
|
|
147
147
|
onHide(id);
|
|
148
|
-
}, title: `Hide ${label}`, "aria-label": `Hide ${label}`, children: _jsx(EyeOff, { className: "h-3 w-3", "aria-hidden": "true" }) })), _jsx("div", { className: "h-full w-full rounded-3xl transition-all flex flex-col bg-card border border-border shadow-sm", style: { contain: 'layout style' }, children: _jsx("div", { className: cn('flex-1 min-h-0', autoHeight ? 'overflow-hidden' : 'overflow-auto'), children: autoHeight ? _jsx("div", { ref: measureRef, children: content }) : content }) })] }), injectedChildren] }));
|
|
148
|
+
}, title: `Hide ${label}`, "aria-label": `Hide ${label}`, children: _jsx(EyeOff, { className: "h-3 w-3", "aria-hidden": "true" }) })), _jsx("div", { className: "h-full w-full rounded-3xl transition-all flex flex-col bg-card border border-border shadow-sm dark:shadow-[var(--glow-card,none)]", style: { contain: 'layout style' }, children: _jsx("div", { className: cn('flex-1 min-h-0', autoHeight ? 'overflow-hidden' : 'overflow-auto'), children: autoHeight ? _jsx("div", { ref: measureRef, children: content }) : content }) })] }), injectedChildren] }));
|
|
149
149
|
}));
|
|
150
150
|
export function PageGridLayout({ pageKey, defaultLayouts, defaultCols, layoutVersion, canEditPage, editorEventNames, preferenceAdapter, widgets, widgetMeta, className,
|
|
151
151
|
// Resize default flipped 2026-05-12: rgl v2 dropped auto-handle rendering
|
|
@@ -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,
|
|
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 {
|
|
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
|
-
|
|
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.
|
|
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",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"prepublishOnly": "pnpm build"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"@bsuite/theme": ">=0.5.0",
|
|
35
36
|
"@dnd-kit/core": "^6",
|
|
36
37
|
"@dnd-kit/sortable": "^10",
|
|
37
38
|
"@dnd-kit/utilities": "^3",
|
|
@@ -42,6 +43,9 @@
|
|
|
42
43
|
"react-resizable": "^3 || ^4"
|
|
43
44
|
},
|
|
44
45
|
"peerDependenciesMeta": {
|
|
46
|
+
"@bsuite/theme": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
45
49
|
"@dnd-kit/core": {
|
|
46
50
|
"optional": true
|
|
47
51
|
},
|