@carlonicora/nextjs-jsonapi 6.26.0 → 6.27.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/{BlockNoteEditor-RVDSB6TF.mjs → BlockNoteEditor-D2DXVXTJ.mjs} +2 -2
- package/dist/{BlockNoteEditor-JHXDOCS5.js → BlockNoteEditor-NQB75M47.js} +9 -9
- package/dist/{BlockNoteEditor-JHXDOCS5.js.map → BlockNoteEditor-NQB75M47.js.map} +1 -1
- package/dist/billing/index.js +378 -378
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-64REWDSK.mjs → chunk-HU3AGUFI.mjs} +26 -4
- package/dist/chunk-HU3AGUFI.mjs.map +1 -0
- package/dist/{chunk-JE6QWCNE.js → chunk-YGV27OAW.js} +26 -4
- package/dist/chunk-YGV27OAW.js.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/containers/RoundPageContainer.d.ts.map +1 -1
- package/dist/components/containers/detailsFitsByDefault.d.ts +19 -0
- package/dist/components/containers/detailsFitsByDefault.d.ts.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/index.mjs +1 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/email-automations/index.js +78 -78
- package/dist/email-automations/index.mjs +1 -1
- package/dist/features/analytics/index.js +107 -107
- package/dist/features/analytics/index.mjs +1 -1
- package/dist/features/blog/index.js +93 -93
- package/dist/features/blog/index.mjs +1 -1
- package/dist/features/help/index.js +31 -31
- package/dist/features/help/index.mjs +1 -1
- package/dist/features/tokenusage/index.js +102 -102
- package/dist/features/tokenusage/index.mjs +1 -1
- package/package.json +1 -1
- package/src/components/containers/RoundPageContainer.tsx +23 -2
- package/src/components/containers/__tests__/detailsFitsByDefault.spec.ts +25 -0
- package/src/components/containers/detailsFitsByDefault.ts +30 -0
- package/dist/chunk-64REWDSK.mjs.map +0 -1
- package/dist/chunk-JE6QWCNE.js.map +0 -1
- /package/dist/{BlockNoteEditor-RVDSB6TF.mjs.map → BlockNoteEditor-D2DXVXTJ.mjs.map} +0 -0
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
TabsTrigger,
|
|
19
19
|
} from "@/components";
|
|
20
20
|
import { partitionTabs, Tab } from "@/components/containers";
|
|
21
|
+
import { detailsFitsByDefault } from "@/components/containers/detailsFitsByDefault";
|
|
21
22
|
import { HEADER_ROW_MIN_H, RoundPageContainerTitle } from "@/components/containers/RoundPageContainerTitle";
|
|
22
23
|
import { Header, MobileNavigationBar } from "@/components/navigations";
|
|
23
24
|
import { MicroLabel } from "@/components/typography";
|
|
@@ -207,8 +208,13 @@ export function RoundPageContainer({
|
|
|
207
208
|
// without one (the customer portal) keeps the padding on both sides.
|
|
208
209
|
const hasSidebar = useOptionalSidebar() !== null;
|
|
209
210
|
const [mounted, setMounted] = useState(false);
|
|
211
|
+
// The page card; its inner width decides the details panel's default.
|
|
212
|
+
const cardRef = useRef<HTMLDivElement>(null);
|
|
210
213
|
|
|
214
|
+
// Runs once, on the first render after `mounted`: before that the container
|
|
215
|
+
// renders its placeholder and the card (measured below) does not exist yet.
|
|
211
216
|
useEffect(() => {
|
|
217
|
+
if (!mounted) return;
|
|
212
218
|
const match = document.cookie.split("; ").find((row) => row.startsWith(`${detailsCookieName}=`));
|
|
213
219
|
const stored = match?.split("=")[1];
|
|
214
220
|
// Apply the stored preference in BOTH directions. Previously this only ever
|
|
@@ -217,7 +223,22 @@ export function RoundPageContainer({
|
|
|
217
223
|
// who explicitly collapsed the panel must stay collapsed on the next load.
|
|
218
224
|
if (stored === "true") setShowDetailsState(true);
|
|
219
225
|
else if (stored === "false") setShowDetailsState(false);
|
|
220
|
-
|
|
226
|
+
// No stored choice yet: open when the page card fits the panel beside the
|
|
227
|
+
// centred content column. The card is measured, so the left sidebar's real
|
|
228
|
+
// state (open, minimised, absent) counts. Decided once, on load — resizing
|
|
229
|
+
// does not move it.
|
|
230
|
+
else if (
|
|
231
|
+
!defaultDetailsOpen &&
|
|
232
|
+
cardRef.current &&
|
|
233
|
+
detailsFitsByDefault({
|
|
234
|
+
cardInnerPx: cardRef.current.clientWidth,
|
|
235
|
+
remPx: parseFloat(getComputedStyle(document.documentElement).fontSize) || 16,
|
|
236
|
+
hasRail: layout === "rail" && !!tabs,
|
|
237
|
+
hasCentredColumn: !fullWidth && (!activeFillHeight || activeConstrainWidth),
|
|
238
|
+
})
|
|
239
|
+
)
|
|
240
|
+
setShowDetailsState(true);
|
|
241
|
+
}, [mounted]);
|
|
221
242
|
|
|
222
243
|
useEffect(() => {
|
|
223
244
|
setMounted(true);
|
|
@@ -433,7 +454,7 @@ export function RoundPageContainer({
|
|
|
433
454
|
sibling in this fixed-height flex column. `h-full` resolves to 100% of
|
|
434
455
|
the wrapper, leaving the bar no room and pushing it below the fold —
|
|
435
456
|
it then appears only after scrolling to the very end of the page. */}
|
|
436
|
-
<div className="bg-background flex min-h-0 w-full flex-1 rounded-lg border p-0">
|
|
457
|
+
<div ref={cardRef} className="bg-background flex min-h-0 w-full flex-1 rounded-lg border p-0">
|
|
437
458
|
{/* pb-16 under mobileFlow: room for the floating Help button, which
|
|
438
459
|
otherwise sits over the last lines of the page. */}
|
|
439
460
|
<div className={cn("flex w-full flex-col", mobileFlow && "min-h-0 overflow-y-auto pb-16")}>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { detailsFitsByDefault } from "../detailsFitsByDefault";
|
|
3
|
+
|
|
4
|
+
const base = { remPx: 16, hasRail: false, hasCentredColumn: true };
|
|
5
|
+
|
|
6
|
+
describe("detailsFitsByDefault", () => {
|
|
7
|
+
it("needs column + padding + panel inside the card (1569px)", () => {
|
|
8
|
+
expect(detailsFitsByDefault({ ...base, cardInnerPx: 1569 })).toBe(true);
|
|
9
|
+
expect(detailsFitsByDefault({ ...base, cardInnerPx: 1568 })).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("adds the section rail when the page has one (1793px)", () => {
|
|
13
|
+
expect(detailsFitsByDefault({ ...base, hasRail: true, cardInnerPx: 1793 })).toBe(true);
|
|
14
|
+
expect(detailsFitsByDefault({ ...base, hasRail: true, cardInnerPx: 1792 })).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("scales with the root font size", () => {
|
|
18
|
+
expect(detailsFitsByDefault({ ...base, remPx: 20, cardInnerPx: 1961 })).toBe(true);
|
|
19
|
+
expect(detailsFitsByDefault({ ...base, remPx: 20, cardInnerPx: 1960 })).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("stays closed on pages without a centred column", () => {
|
|
23
|
+
expect(detailsFitsByDefault({ ...base, hasCentredColumn: false, cardInnerPx: 4000 })).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Widths, in rem, of what has to fit INSIDE the page card next to each other.
|
|
2
|
+
// Each value mirrors a class in RoundPageContainer — change them together.
|
|
3
|
+
const RAIL_REM = 14; // section rail `md:w-56`, only on `layout="rail"` pages
|
|
4
|
+
const CONTENT_PADDING_REM = 2; // `p-4` on both sides of the content column
|
|
5
|
+
const CONTENT_COLUMN_REM = 72; // `max-w-6xl`
|
|
6
|
+
const DETAILS_REM = 24; // details panel `w-96`
|
|
7
|
+
const DETAILS_BORDER_PX = 1; // details panel `border-s`
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Whether the details panel fits beside the page's centred content column
|
|
11
|
+
* without squeezing it. Used only as the default when the user has never
|
|
12
|
+
* toggled the panel on this module.
|
|
13
|
+
*
|
|
14
|
+
* `cardInnerPx` is the measured inner width of the page card, so whatever sits
|
|
15
|
+
* outside it — the left sidebar open, minimised to icons or absent, the shell
|
|
16
|
+
* margins — is already accounted for.
|
|
17
|
+
*
|
|
18
|
+
* Pages without a centred column (`fullWidth`, or a full-bleed fill-height tab)
|
|
19
|
+
* have nothing to protect, so they return `false` and keep the closed default.
|
|
20
|
+
*/
|
|
21
|
+
export function detailsFitsByDefault(params: {
|
|
22
|
+
cardInnerPx: number;
|
|
23
|
+
remPx: number;
|
|
24
|
+
hasRail: boolean;
|
|
25
|
+
hasCentredColumn: boolean;
|
|
26
|
+
}): boolean {
|
|
27
|
+
if (!params.hasCentredColumn) return false;
|
|
28
|
+
const rem = (params.hasRail ? RAIL_REM : 0) + CONTENT_PADDING_REM + CONTENT_COLUMN_REM + DETAILS_REM;
|
|
29
|
+
return params.cardInnerPx >= rem * params.remPx + DETAILS_BORDER_PX;
|
|
30
|
+
}
|