@bsuite/page-builder 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/dist/CanvasCard.d.ts
CHANGED
|
@@ -35,6 +35,34 @@ export interface CanvasCardProps {
|
|
|
35
35
|
* and was swept. Do not reintroduce it on a plain card or table.
|
|
36
36
|
*/
|
|
37
37
|
autoHeight?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the GRID ITEM paints a card around this slot — border, radius,
|
|
40
|
+
* background, shadow. Threaded through to {@link GridLayoutItem.chrome} by
|
|
41
|
+
* `buildCanvasCardLayout`, and per-item always beats the page-level
|
|
42
|
+
* `itemChrome` prop in either direction.
|
|
43
|
+
*
|
|
44
|
+
* Leave it undefined and the app's `itemChrome` decides. Say `chrome={false}`
|
|
45
|
+
* on a slot whose content is NOT a card — a marketing section, a page
|
|
46
|
+
* heading, a chart that supplies its own surface — in an app that has set
|
|
47
|
+
* `itemChrome` true; say `chrome` on a BARE slot in an app that has not.
|
|
48
|
+
*
|
|
49
|
+
* WHY IT EXISTS AT ALL (2.1.0). 2.0.0 inverted the grid-item chrome default
|
|
50
|
+
* and offered `GridLayoutItem.chrome` as the per-slot escape hatch. That
|
|
51
|
+
* hatch was real for the handful of pages that hand-author a layout array,
|
|
52
|
+
* and UNREACHABLE for the ~1,700 CanvasCard usages that are how BSuite pages
|
|
53
|
+
* are actually written: `CanvasCardProps` did not declare the prop and
|
|
54
|
+
* `buildCanvasCardLayout` destructured a fixed set of fields, so a `chrome`
|
|
55
|
+
* written on a CanvasCard was dropped before it could reach a layout item.
|
|
56
|
+
* crm7's 2.0.0 adoption shipped a comment promising the opt-out and zero
|
|
57
|
+
* call sites able to use it. Declaring it here is what makes the promise
|
|
58
|
+
* true.
|
|
59
|
+
*
|
|
60
|
+
* Unlike `autoHeight`, this is not a hint the grid may override: a slot that
|
|
61
|
+
* says false is never framed. It also survives a drag — see the `chrome`
|
|
62
|
+
* restore in `stripAutoHeightRows`, which exists because react-grid-layout
|
|
63
|
+
* does not round-trip custom item props.
|
|
64
|
+
*/
|
|
65
|
+
chrome?: boolean;
|
|
38
66
|
/** Card body — typically a single card or page-header element. */
|
|
39
67
|
children: ReactNode;
|
|
40
68
|
}
|
package/dist/CanvasCard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanvasCard.d.ts","sourceRoot":"","sources":["../src/CanvasCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAC3B,qEAAqE;IACrE,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;IAC9B,4FAA4F;IAC5F,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kEAAkE;IAClE,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAExD;yBAFe,UAAU"}
|
|
1
|
+
{"version":3,"file":"CanvasCard.d.ts","sourceRoot":"","sources":["../src/CanvasCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,CAAC,CAAC,EAA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AAK,EAAE,SAAS,GAAG;IACpD,KAAK,EAAE,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAqBA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAI,EAAE,GAAG,SAAsB,UAE7E;AAED,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACnC,yEAAyE;IACzE,OAAO,EAAE,WAAW,CAAC;IACrB,+EAA+E;IAC/E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,EACnB,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACtC,sBAAsB,CAsDxB"}
|
package/dist/canvasCardLayout.js
CHANGED
|
@@ -115,7 +115,7 @@ export function buildCanvasCardLayout(children, options = {}) {
|
|
|
115
115
|
for (const child of cards) {
|
|
116
116
|
// autoHeight defaults to TRUE — cards track measured content height unless
|
|
117
117
|
// a card explicitly opts out for a virtualized list. See CanvasCardProps.
|
|
118
|
-
const { cardKey, h = 6, minH = 2, minW = 4, autoHeight = true, children: body, } = child.props;
|
|
118
|
+
const { cardKey, h = 6, minH = 2, minW = 4, autoHeight = true, chrome, children: body, } = child.props;
|
|
119
119
|
const normalizedMinW = clampColumns(minW);
|
|
120
120
|
const width = clampColumns(child.props.w ?? defaultWidth, normalizedMinW);
|
|
121
121
|
if (x + width > CANVAS_GRID_COLUMNS) {
|
|
@@ -133,6 +133,16 @@ export function buildCanvasCardLayout(children, options = {}) {
|
|
|
133
133
|
minW: normalizedMinW,
|
|
134
134
|
minH,
|
|
135
135
|
...(autoHeight ? { autoHeight: true } : {}),
|
|
136
|
+
// `chrome` is THREE-VALUED and only two of those values are the card's
|
|
137
|
+
// own: true and false both have to reach the layout item, and undefined
|
|
138
|
+
// has to stay absent so `layoutItem.chrome ?? itemChrome` can fall
|
|
139
|
+
// through to the app default. Writing `chrome: chrome` unconditionally
|
|
140
|
+
// would put an explicit `undefined` on every item, which is still absent
|
|
141
|
+
// to `??` but is NOT absent to a structural comparison — and
|
|
142
|
+
// `stripAutoHeightRows` compares items across a gesture. Spreading only
|
|
143
|
+
// when the author said something keeps the item shape identical to what
|
|
144
|
+
// 2.0.0 produced for the 1,729 cards that say nothing.
|
|
145
|
+
...(chrome === undefined ? {} : { chrome }),
|
|
136
146
|
});
|
|
137
147
|
x += width;
|
|
138
148
|
rowHeight = Math.max(rowHeight, h);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePageGridLayout.d.ts","sourceRoot":"","sources":["../src/usePageGridLayout.ts"],"names":[],"mappings":"AAiBA,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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAiBzC,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,EAC5C,iBAAiB,GAClB,EAAE,wBAAwB,GAAG,uBAAuB,
|
|
1
|
+
{"version":3,"file":"usePageGridLayout.d.ts","sourceRoot":"","sources":["../src/usePageGridLayout.ts"],"names":[],"mappings":"AAiBA,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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAiBzC,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,EAC5C,iBAAiB,GAClB,EAAE,wBAAwB,GAAG,uBAAuB,CAsuBpD"}
|
|
@@ -330,8 +330,32 @@ export function usePageGridLayout({ pageKey, defaultLayouts, defaultCols = 12, l
|
|
|
330
330
|
const baseByKey = new Map(baseItems.map((item) => [item.i, item]));
|
|
331
331
|
result[bp] = (layouts[bp] ?? []).map((item) => {
|
|
332
332
|
const baseItem = baseByKey.get(item.i);
|
|
333
|
+
/**
|
|
334
|
+
* Carry `chrome` back onto EVERY item, autoHeight or not.
|
|
335
|
+
*
|
|
336
|
+
* react-grid-layout hands `onLayoutChange` its own item objects, which
|
|
337
|
+
* carry only the fields it models (`i/x/y/w/h/minW/minH/…`). Every
|
|
338
|
+
* custom field is gone. The pre-existing `autoHeight`/`hUserSet`
|
|
339
|
+
* restore below is the same mechanism — it just lived inside the
|
|
340
|
+
* `autoHeight` branch, so it only ever protected autoHeight items.
|
|
341
|
+
*
|
|
342
|
+
* `chrome` cannot live in that branch. It is meaningful on items that
|
|
343
|
+
* are NOT autoHeight, and losing it is not a cosmetic regression that
|
|
344
|
+
* heals on reload: `rawLayouts` prefers a saved item over the authored
|
|
345
|
+
* default for every key it already has, so the first drag on a page
|
|
346
|
+
* writes a chrome-less layout to user_preferences and the slot falls
|
|
347
|
+
* back to the app's `itemChrome` permanently, for that user only. A
|
|
348
|
+
* marketing page deliberately set frameless would silently re-frame
|
|
349
|
+
* itself the first time someone nudged a card, and nothing would ever
|
|
350
|
+
* put it back.
|
|
351
|
+
*
|
|
352
|
+
* Three-valued on purpose: `undefined` must stay ABSENT so
|
|
353
|
+
* `layoutItem.chrome ?? itemChrome` still falls through to the app
|
|
354
|
+
* default. Only an explicit true/false is restored.
|
|
355
|
+
*/
|
|
356
|
+
const withChrome = (next) => baseItem?.chrome === undefined ? next : { ...next, chrome: baseItem.chrome };
|
|
333
357
|
if (!baseItem?.autoHeight)
|
|
334
|
-
return item;
|
|
358
|
+
return withChrome(item);
|
|
335
359
|
const measuredRows = measured[item.i];
|
|
336
360
|
// MUST mirror `activeLayouts` in PageGridLayout.tsx exactly, including
|
|
337
361
|
// its `hUserSet` test. This predicts what the grid was RENDERED with;
|
|
@@ -350,25 +374,25 @@ export function usePageGridLayout({ pageKey, defaultLayouts, defaultCols = 12, l
|
|
|
350
374
|
// for the same reason `autoHeight` is: react-grid-layout does not
|
|
351
375
|
// round-trip custom item props, so anything not restored here is
|
|
352
376
|
// silently dropped on the next commit.
|
|
353
|
-
return {
|
|
377
|
+
return withChrome({
|
|
354
378
|
...item,
|
|
355
379
|
autoHeight: true,
|
|
356
380
|
h: baseItem.h,
|
|
357
381
|
minH: baseItem.minH,
|
|
358
382
|
...(baseItem.hUserSet ? { hUserSet: true } : {}),
|
|
359
|
-
};
|
|
383
|
+
});
|
|
360
384
|
}
|
|
361
385
|
// A deliberate resize (bigger or smaller than the base) — keep it,
|
|
362
386
|
// still floored by the measured content height. This is the only
|
|
363
387
|
// moment in the system where a height is known to be a CHOICE rather
|
|
364
388
|
// than an authored seed, so it is where that fact gets recorded.
|
|
365
|
-
return {
|
|
389
|
+
return withChrome({
|
|
366
390
|
...item,
|
|
367
391
|
autoHeight: true,
|
|
368
392
|
hUserSet: true,
|
|
369
393
|
h: measuredRows === undefined ? item.h : Math.max(item.h, measuredRows),
|
|
370
394
|
minH: measuredRows ?? baseItem.minH,
|
|
371
|
-
};
|
|
395
|
+
});
|
|
372
396
|
});
|
|
373
397
|
}
|
|
374
398
|
return result;
|