@bsuite/page-builder 2.8.0 → 2.8.1-next.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.
@@ -1 +1 @@
1
- {"version":3,"file":"usePageGridLayout.d.ts","sourceRoot":"","sources":["../src/usePageGridLayout.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAEV,WAAW,EACX,eAAe,EACf,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC,GACrE,wBAAwB,CAI1B;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,wBAAwB,CAI1B;AAED,eAAO,MAAM,0BAA0B,2IAM7B,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAiBzC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,EAAE,EACF,UAAU,GACX,EAAE;IACD,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,WAAW,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,IAAI,CAAC;CACzD,GAAG,WAAW,GAAG,IAAI,CA+BrB;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;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W,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,EAC5C,iBAAiB,EACjB,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,uBAAuB,CA83BpD"}
@@ -372,14 +372,26 @@ export function usePageGridLayout({ pageKey, defaultLayouts, defaultCols = 12, l
372
372
  const savedKeys = new Set(savedItems.map((item) => item.i));
373
373
  const bpDefaults = defaultLayouts[bp] ?? defaultLayouts.lg;
374
374
  const missingItems = bpDefaults.filter((item) => !savedKeys.has(item.i));
375
+ // `chrome` is authored, never chosen by the person: the editor has no
376
+ // frame control. A layout saved before a slot declared `chrome` (or by
377
+ // react-grid-layout, which drops custom props) carries none, and the
378
+ // saved item used to win outright, so `chrome={false}` on a CanvasCard
379
+ // did nothing for anyone who had ever arranged that page. The authored
380
+ // value now applies over the saved item; position and size stay theirs.
381
+ const authoredChrome = new Map(bpDefaults
382
+ .filter((item) => item.chrome !== undefined)
383
+ .map((item) => [item.i, item.chrome]));
384
+ const withAuthoredChrome = savedItems.map((item) => authoredChrome.has(item.i) && item.chrome !== authoredChrome.get(item.i)
385
+ ? { ...item, chrome: authoredChrome.get(item.i) }
386
+ : item);
375
387
  if (missingItems.length > 0) {
376
388
  const maxY = savedItems.reduce((max, item) => Math.max(max, item.y + item.h), 0);
377
389
  const offsetItems = missingItems.map((item, index) => ({ ...item, y: maxY + index * item.h }));
378
- merged[bp] = [...savedItems, ...offsetItems];
390
+ merged[bp] = [...withAuthoredChrome, ...offsetItems];
379
391
  changed = true;
380
392
  }
381
393
  else {
382
- merged[bp] = savedItems;
394
+ merged[bp] = withAuthoredChrome;
383
395
  }
384
396
  }
385
397
  // `merged` is always returned (never the raw `savedLayout`) because the
@@ -553,14 +565,12 @@ export function usePageGridLayout({ pageKey, defaultLayouts, defaultCols = 12, l
553
565
  * `autoHeight` branch, so it only ever protected autoHeight items.
554
566
  *
555
567
  * `chrome` cannot live in that branch. It is meaningful on items that
556
- * are NOT autoHeight, and losing it is not a cosmetic regression that
557
- * heals on reload: `rawLayouts` prefers a saved item over the authored
558
- * default for every key it already has, so the first drag on a page
559
- * writes a chrome-less layout to user_preferences and the slot falls
560
- * back to the app's `itemChrome` permanently, for that user only. A
561
- * marketing page deliberately set frameless would silently re-frame
562
- * itself the first time someone nudged a card, and nothing would ever
563
- * put it back.
568
+ * are NOT autoHeight. Since 2.8.1 `rawLayouts` re-applies the authored
569
+ * value on read for every slot that declares one, so a stored layout
570
+ * missing it no longer re-frames the slot. This restore keeps the
571
+ * PERSISTED layout carrying the authored value, so what a save writes
572
+ * agrees with what the next read produces, and a stored layout stays
573
+ * correct for any reader that does not re-apply it.
564
574
  *
565
575
  * Three-valued on purpose: `undefined` must stay ABSENT so
566
576
  * `layoutItem.chrome ?? itemChrome` still falls through to the app
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsuite/page-builder",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-next.0",
4
4
  "description": "Shared BSuite responsive page-builder grid and layout persistence primitives",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",