@carlonicora/nextjs-jsonapi 1.117.0 → 1.118.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/{AssistantMessageInterface-Ca0G0vZw.d.mts → AssistantMessageInterface-DH1QwtC_.d.mts} +1 -0
- package/dist/{AssistantMessageInterface-DEZ5AnVl.d.ts → AssistantMessageInterface-giWvsOrX.d.ts} +1 -0
- package/dist/{BlockNoteEditor-6UREFUSJ.js → BlockNoteEditor-5FFVS7KW.js} +9 -9
- package/dist/{BlockNoteEditor-6UREFUSJ.js.map → BlockNoteEditor-5FFVS7KW.js.map} +1 -1
- package/dist/{BlockNoteEditor-UQOOX3UT.mjs → BlockNoteEditor-6GRZW6BL.mjs} +2 -2
- package/dist/billing/index.js +299 -299
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-SVEPL5J2.mjs → chunk-KXHEOLPZ.mjs} +287 -156
- package/dist/chunk-KXHEOLPZ.mjs.map +1 -0
- package/dist/{chunk-HXU2HDRN.js → chunk-M2ODDWY3.js} +372 -241
- package/dist/chunk-M2ODDWY3.js.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +73 -31
- package/dist/components/index.d.ts +73 -31
- package/dist/components/index.js +4 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +3 -1
- package/dist/contexts/index.d.mts +1 -1
- package/dist/contexts/index.d.ts +1 -1
- package/dist/contexts/index.js +2 -2
- package/dist/contexts/index.mjs +1 -1
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/features/help/index.js +30 -30
- package/dist/features/help/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/containers/RoundPageContainer.tsx +197 -76
- package/src/components/containers/TabsContainer.tsx +14 -0
- package/src/components/containers/__tests__/partitionTabs.spec.ts +51 -0
- package/src/components/containers/index.ts +1 -0
- package/src/components/containers/partitionTabs.ts +43 -0
- package/src/components/forms/EditorSheet.tsx +7 -2
- package/src/components/navigations/Breadcrumb.tsx +31 -5
- package/src/hooks/useSocket.ts +12 -1
- package/src/interfaces/breadcrumb.item.data.interface.ts +1 -0
- package/dist/chunk-HXU2HDRN.js.map +0 -1
- package/dist/chunk-SVEPL5J2.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-UQOOX3UT.mjs.map → BlockNoteEditor-6GRZW6BL.mjs.map} +0 -0
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import {
|
|
4
4
|
Select,
|
|
5
5
|
SelectContent,
|
|
6
|
+
SelectGroup,
|
|
6
7
|
SelectItem,
|
|
8
|
+
SelectLabel,
|
|
7
9
|
SelectTrigger,
|
|
8
10
|
SelectValue,
|
|
9
11
|
Sheet,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
TabsList,
|
|
16
18
|
TabsTrigger,
|
|
17
19
|
} from "@/components";
|
|
18
|
-
import { Tab } from "@/components/containers";
|
|
20
|
+
import { partitionTabs, Tab } from "@/components/containers";
|
|
19
21
|
import { RoundPageContainerTitle } from "@/components/containers/RoundPageContainerTitle";
|
|
20
22
|
import { Header } from "@/components/navigations";
|
|
21
23
|
import { useHeaderChildren, useHeaderLeftContent } from "@/contexts";
|
|
@@ -23,7 +25,7 @@ import { useUrlRewriter } from "@/hooks";
|
|
|
23
25
|
import { cn, useIsMobile } from "@/index";
|
|
24
26
|
import { ModuleWithPermissions } from "@/permissions";
|
|
25
27
|
import { useSearchParams } from "next/navigation";
|
|
26
|
-
import { ReactNode, useCallback, useEffect, useState } from "react";
|
|
28
|
+
import { Fragment, ReactNode, useCallback, useEffect, useMemo, useState } from "react";
|
|
27
29
|
|
|
28
30
|
const DETAILS_COOKIE_NAME = "round_page_details_state";
|
|
29
31
|
const DETAILS_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
@@ -37,8 +39,31 @@ type RoundPageContainerProps = {
|
|
|
37
39
|
fullWidth?: boolean;
|
|
38
40
|
forceHeader?: boolean;
|
|
39
41
|
header?: ReactNode;
|
|
42
|
+
/**
|
|
43
|
+
* Section-navigation layout for `tabs`.
|
|
44
|
+
* - `"tabs"` (default) — horizontal `TabsList` (desktop) / `Select` (mobile).
|
|
45
|
+
* Unchanged from prior behaviour; existing callers need no edits.
|
|
46
|
+
* - `"rail"` — vertical 220px left rail grouped by each tab's `group`, with a
|
|
47
|
+
* `<md` grouped `Select` fallback. Mirrors the retired
|
|
48
|
+
* `PageContainerContentDetails` rail.
|
|
49
|
+
*/
|
|
50
|
+
layout?: "tabs" | "rail";
|
|
40
51
|
};
|
|
41
52
|
|
|
53
|
+
// Rail trigger class: override the horizontal TabsTrigger defaults for a
|
|
54
|
+
// vertical, left-aligned, dark-filled active state. tailwind-merge inside cn()
|
|
55
|
+
// resolves the conflicts with the base classes.
|
|
56
|
+
const railTriggerClass = cn(
|
|
57
|
+
"flex w-full items-center justify-start rounded-md px-3 py-1.5 text-left text-sm leading-tight whitespace-normal",
|
|
58
|
+
"text-muted-foreground",
|
|
59
|
+
"hover:bg-muted hover:text-foreground",
|
|
60
|
+
"data-[state=active]:bg-foreground data-[state=active]:text-background",
|
|
61
|
+
"data-[state=active]:font-semibold data-[state=active]:shadow-none",
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/** Stable value for the URL `?section=` and active-tab matching. */
|
|
65
|
+
const tabValue = (tab: Tab): string => tab.sectionKey ?? tab.key?.name ?? tab.label;
|
|
66
|
+
|
|
42
67
|
export function RoundPageContainer({
|
|
43
68
|
module,
|
|
44
69
|
id,
|
|
@@ -48,6 +73,7 @@ export function RoundPageContainer({
|
|
|
48
73
|
fullWidth,
|
|
49
74
|
forceHeader,
|
|
50
75
|
header,
|
|
76
|
+
layout = "tabs",
|
|
51
77
|
}: RoundPageContainerProps) {
|
|
52
78
|
const headerChildren = useHeaderChildren();
|
|
53
79
|
const headerLeftContent = useHeaderLeftContent();
|
|
@@ -75,15 +101,14 @@ export function RoundPageContainer({
|
|
|
75
101
|
const rewriteUrl = useUrlRewriter();
|
|
76
102
|
|
|
77
103
|
const initialValue = tabs
|
|
78
|
-
? (section && tabs.find((i) => (i
|
|
79
|
-
(tabs[0].key?.name ?? tabs[0].label)
|
|
104
|
+
? (section && tabs.find((i) => tabValue(i) === section) ? section : null) || tabValue(tabs[0])
|
|
80
105
|
: undefined;
|
|
81
106
|
|
|
82
107
|
const [activeTab, setActiveTab] = useState(initialValue);
|
|
83
108
|
|
|
84
109
|
useEffect(() => {
|
|
85
110
|
if (tabs && section) {
|
|
86
|
-
const tab = tabs.find((i) => (i
|
|
111
|
+
const tab = tabs.find((i) => tabValue(i) === section);
|
|
87
112
|
if (tab) {
|
|
88
113
|
setActiveTab(section);
|
|
89
114
|
}
|
|
@@ -98,7 +123,10 @@ export function RoundPageContainer({
|
|
|
98
123
|
[module, id, rewriteUrl],
|
|
99
124
|
);
|
|
100
125
|
|
|
101
|
-
const activeFillHeight = tabs?.find((t) => (t
|
|
126
|
+
const activeFillHeight = tabs?.find((t) => tabValue(t) === activeTab)?.fillHeight === true;
|
|
127
|
+
|
|
128
|
+
// Rail partition — only consumed by `layout="rail"` but cheap to compute.
|
|
129
|
+
const { ungrouped, groups } = useMemo(() => partitionTabs(tabs ?? []), [tabs]);
|
|
102
130
|
|
|
103
131
|
const isReady = mounted && isMobile !== undefined;
|
|
104
132
|
|
|
@@ -135,85 +163,178 @@ export function RoundPageContainer({
|
|
|
135
163
|
/>
|
|
136
164
|
)}
|
|
137
165
|
<div className="flex h-full w-full overflow-hidden">
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
166
|
+
{layout === "rail" && tabs ? (
|
|
167
|
+
// Rail layout: the vertical-tab navigation is a flush-left
|
|
168
|
+
// sidebar of the card and the content fills the full remaining
|
|
169
|
+
// width (like `fullWidth`) — NOT the centred max-w-6xl column.
|
|
170
|
+
<Tabs
|
|
171
|
+
value={activeTab}
|
|
172
|
+
onValueChange={handleTabChange}
|
|
173
|
+
orientation="vertical"
|
|
174
|
+
className="flex h-full min-w-0 grow overflow-hidden"
|
|
175
|
+
>
|
|
176
|
+
{/* Flush-left section rail — md and up */}
|
|
177
|
+
<aside
|
|
178
|
+
data-testid="round-page-rail"
|
|
179
|
+
className="hidden shrink-0 border-r p-4 md:flex md:w-56 md:flex-col md:overflow-y-auto"
|
|
180
|
+
>
|
|
181
|
+
<TabsList className="flex h-auto flex-col items-stretch gap-0.5 bg-transparent p-0">
|
|
182
|
+
{ungrouped.map((tab) => (
|
|
183
|
+
<TabsTrigger key={tab.label} value={tabValue(tab)} className={railTriggerClass}>
|
|
184
|
+
{tab.contentLabel ?? tab.label}
|
|
185
|
+
</TabsTrigger>
|
|
186
|
+
))}
|
|
187
|
+
{groups.map((group) => (
|
|
188
|
+
<Fragment key={group.label}>
|
|
189
|
+
<div
|
|
190
|
+
role="presentation"
|
|
191
|
+
className="text-muted-foreground px-3 pt-3 pb-1 text-[10px] font-bold tracking-wider uppercase"
|
|
192
|
+
>
|
|
193
|
+
{group.label}
|
|
194
|
+
</div>
|
|
195
|
+
{group.items.map((tab) => (
|
|
196
|
+
<TabsTrigger key={tab.label} value={tabValue(tab)} className={railTriggerClass}>
|
|
197
|
+
{tab.contentLabel ?? tab.label}
|
|
198
|
+
</TabsTrigger>
|
|
199
|
+
))}
|
|
200
|
+
</Fragment>
|
|
201
|
+
))}
|
|
202
|
+
</TabsList>
|
|
203
|
+
</aside>
|
|
204
|
+
|
|
205
|
+
{/* Content — full width, fills the remaining space */}
|
|
206
|
+
<div className="flex min-w-0 grow flex-col overflow-hidden">
|
|
207
|
+
{/* Section Select — below md */}
|
|
208
|
+
<div data-testid="round-page-rail-select" className="p-2 md:hidden">
|
|
209
|
+
<Select
|
|
210
|
+
value={activeTab}
|
|
211
|
+
onValueChange={(value) => {
|
|
212
|
+
if (value) handleTabChange(value);
|
|
213
|
+
}}
|
|
214
|
+
>
|
|
215
|
+
<SelectTrigger className="w-full">
|
|
216
|
+
<SelectValue />
|
|
217
|
+
</SelectTrigger>
|
|
218
|
+
<SelectContent>
|
|
219
|
+
{ungrouped.map((tab) => (
|
|
220
|
+
<SelectItem key={tab.label} value={tabValue(tab)}>
|
|
221
|
+
{tab.contentLabel ?? tab.label}
|
|
222
|
+
</SelectItem>
|
|
223
|
+
))}
|
|
224
|
+
{groups.map((group) => (
|
|
225
|
+
<SelectGroup key={group.label}>
|
|
226
|
+
<SelectLabel>{group.label}</SelectLabel>
|
|
227
|
+
{group.items.map((tab) => (
|
|
228
|
+
<SelectItem key={tab.label} value={tabValue(tab)}>
|
|
229
|
+
{tab.contentLabel ?? tab.label}
|
|
230
|
+
</SelectItem>
|
|
231
|
+
))}
|
|
232
|
+
</SelectGroup>
|
|
233
|
+
))}
|
|
234
|
+
</SelectContent>
|
|
235
|
+
</Select>
|
|
236
|
+
</div>
|
|
237
|
+
<div
|
|
238
|
+
className={cn(
|
|
239
|
+
`min-w-0 grow`,
|
|
240
|
+
activeFillHeight ? `flex flex-col overflow-hidden` : `overflow-y-auto`,
|
|
241
|
+
)}
|
|
242
|
+
>
|
|
243
|
+
{header}
|
|
244
|
+
{tabs.map((tab) => (
|
|
245
|
+
<TabsContent
|
|
246
|
+
key={tab.label}
|
|
247
|
+
value={tabValue(tab)}
|
|
248
|
+
className={tab.fillHeight ? `flex min-h-0 w-full flex-1 flex-col` : ``}
|
|
249
|
+
>
|
|
250
|
+
{tab.content}
|
|
251
|
+
</TabsContent>
|
|
252
|
+
))}
|
|
253
|
+
{children && <div className="flex">{children}</div>}
|
|
254
|
+
</div>
|
|
255
|
+
</div>
|
|
256
|
+
</Tabs>
|
|
257
|
+
) : (
|
|
146
258
|
<div
|
|
147
259
|
className={cn(
|
|
148
|
-
`
|
|
149
|
-
|
|
150
|
-
|
|
260
|
+
`grow`,
|
|
261
|
+
isMobile ? `p-2` : `p-4`,
|
|
262
|
+
activeFillHeight ? `flex flex-col overflow-hidden` : `overflow-y-auto`,
|
|
263
|
+
fullWidth && `p-0`,
|
|
151
264
|
)}
|
|
152
265
|
>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
266
|
+
<div
|
|
267
|
+
className={cn(
|
|
268
|
+
`mx-auto max-w-6xl space-y-8`,
|
|
269
|
+
activeFillHeight && `flex w-full flex-1 min-h-0 flex-col space-y-0`,
|
|
270
|
+
fullWidth && `max-w-full w-full p-0 h-full`,
|
|
271
|
+
)}
|
|
272
|
+
>
|
|
273
|
+
{header}
|
|
274
|
+
{tabs ? (
|
|
275
|
+
<>
|
|
276
|
+
<Tabs
|
|
277
|
+
value={activeTab}
|
|
278
|
+
className={cn(`w-full`, activeFillHeight && `flex flex-1 min-h-0 flex-col`)}
|
|
279
|
+
onValueChange={handleTabChange}
|
|
280
|
+
>
|
|
281
|
+
{isMobile ? (
|
|
282
|
+
<div className="p-0">
|
|
283
|
+
<Select
|
|
284
|
+
value={activeTab}
|
|
285
|
+
onValueChange={(value) => {
|
|
286
|
+
if (value) handleTabChange(value);
|
|
287
|
+
}}
|
|
288
|
+
>
|
|
289
|
+
<SelectTrigger className="w-full">
|
|
290
|
+
<SelectValue />
|
|
291
|
+
</SelectTrigger>
|
|
292
|
+
<SelectContent>
|
|
293
|
+
{tabs.map((tab) => (
|
|
294
|
+
<SelectItem key={tab.label} value={tabValue(tab)}>
|
|
295
|
+
{tab.contentLabel ?? tab.label}
|
|
296
|
+
</SelectItem>
|
|
297
|
+
))}
|
|
298
|
+
</SelectContent>
|
|
299
|
+
</Select>
|
|
300
|
+
</div>
|
|
301
|
+
) : (
|
|
302
|
+
<div className="p-4">
|
|
303
|
+
<TabsList>
|
|
173
304
|
{tabs.map((tab) => (
|
|
174
|
-
<
|
|
305
|
+
<TabsTrigger key={tab.label} value={tabValue(tab)} className="px-4">
|
|
175
306
|
{tab.contentLabel ?? tab.label}
|
|
176
|
-
</
|
|
307
|
+
</TabsTrigger>
|
|
177
308
|
))}
|
|
178
|
-
</
|
|
179
|
-
</
|
|
180
|
-
</div>
|
|
181
|
-
) : (
|
|
182
|
-
<div className="p-4">
|
|
183
|
-
<TabsList>
|
|
184
|
-
{tabs.map((tab) => (
|
|
185
|
-
<TabsTrigger key={tab.label} value={tab.key?.name ?? tab.label} className="px-4">
|
|
186
|
-
{tab.contentLabel ?? tab.label}
|
|
187
|
-
</TabsTrigger>
|
|
188
|
-
))}
|
|
189
|
-
</TabsList>
|
|
190
|
-
</div>
|
|
191
|
-
)}
|
|
192
|
-
<div
|
|
193
|
-
className={cn(
|
|
194
|
-
`flex w-full `,
|
|
195
|
-
isMobile ? `` : `px-4`,
|
|
196
|
-
activeFillHeight ? `flex-1 min-h-0` : `overflow-y-auto`,
|
|
309
|
+
</TabsList>
|
|
310
|
+
</div>
|
|
197
311
|
)}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
312
|
+
<div
|
|
313
|
+
className={cn(
|
|
314
|
+
`flex w-full `,
|
|
315
|
+
isMobile ? `` : `px-4`,
|
|
316
|
+
activeFillHeight ? `flex-1 min-h-0` : `overflow-y-auto`,
|
|
317
|
+
)}
|
|
318
|
+
>
|
|
319
|
+
{tabs.map((tab) => (
|
|
320
|
+
<TabsContent
|
|
321
|
+
key={tab.label}
|
|
322
|
+
value={tabValue(tab)}
|
|
323
|
+
className={tab.fillHeight ? `flex flex-1 min-h-0 w-full flex-col` : `pb-20`}
|
|
324
|
+
>
|
|
325
|
+
{tab.content}
|
|
326
|
+
</TabsContent>
|
|
327
|
+
))}
|
|
328
|
+
</div>
|
|
329
|
+
</Tabs>
|
|
330
|
+
{children && <div className={cn(`flex`, isMobile ? `px-2` : `px-4`)}>{children}</div>}
|
|
331
|
+
</>
|
|
332
|
+
) : (
|
|
333
|
+
children
|
|
334
|
+
)}
|
|
335
|
+
</div>
|
|
215
336
|
</div>
|
|
216
|
-
|
|
337
|
+
)}
|
|
217
338
|
{details &&
|
|
218
339
|
(isMobile ? (
|
|
219
340
|
<Sheet open={showDetails} onOpenChange={setShowDetails}>
|
|
@@ -13,6 +13,20 @@ export type Tab = {
|
|
|
13
13
|
content: React.ReactNode;
|
|
14
14
|
modules?: ModuleWithPermissions[];
|
|
15
15
|
action?: Action;
|
|
16
|
+
/**
|
|
17
|
+
* Section header this tab clusters under in the `RoundPageContainer`
|
|
18
|
+
* `layout="rail"` navigation. Tabs without a `group` render at the top of the
|
|
19
|
+
* rail (the "pinned" stratum) in declared order; groups render in first-seen
|
|
20
|
+
* order. Ignored by the default `layout="tabs"` (flat) rendering.
|
|
21
|
+
*/
|
|
22
|
+
group?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Stable identifier used for the URL `?section=` value and active-tab
|
|
25
|
+
* matching. Defaults to `key?.name ?? label`. Provide this for tabs that have
|
|
26
|
+
* no `key` (no backing module) but still need a stable, locale-independent
|
|
27
|
+
* deep link — e.g. `"dashboard"`, `"analysis"`, `"timeline"`.
|
|
28
|
+
*/
|
|
29
|
+
sectionKey?: string;
|
|
16
30
|
/**
|
|
17
31
|
* When true, the tab content fills the available viewport height inside its
|
|
18
32
|
* container. The tab's wrapper chain switches to a flex-column layout with
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { partitionTabs } from "../partitionTabs";
|
|
3
|
+
import type { Tab } from "../TabsContainer";
|
|
4
|
+
|
|
5
|
+
const tab = (label: string, group?: string): Tab => ({
|
|
6
|
+
label,
|
|
7
|
+
content: null,
|
|
8
|
+
group,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe("partitionTabs", () => {
|
|
12
|
+
it("returns empty partition for empty input", () => {
|
|
13
|
+
expect(partitionTabs([])).toEqual({ ungrouped: [], groups: [] });
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("keeps tabs without a group in the ungrouped stratum, in declared order", () => {
|
|
17
|
+
const result = partitionTabs([tab("a"), tab("b"), tab("c")]);
|
|
18
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["a", "b", "c"]);
|
|
19
|
+
expect(result.groups).toEqual([]);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("clusters tabs by group label", () => {
|
|
23
|
+
const result = partitionTabs([tab("a", "Casebook"), tab("b", "Casebook"), tab("c", "Work")]);
|
|
24
|
+
expect(result.ungrouped).toEqual([]);
|
|
25
|
+
expect(result.groups).toEqual([
|
|
26
|
+
{ label: "Casebook", items: [expect.objectContaining({ label: "a" }), expect.objectContaining({ label: "b" })] },
|
|
27
|
+
{ label: "Work", items: [expect.objectContaining({ label: "c" })] },
|
|
28
|
+
]);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("renders groups in the order they first appear", () => {
|
|
32
|
+
const result = partitionTabs([tab("a", "Work"), tab("b", "Casebook"), tab("c", "Work"), tab("d", "Casebook")]);
|
|
33
|
+
expect(result.groups.map((g) => g.label)).toEqual(["Work", "Casebook"]);
|
|
34
|
+
expect(result.groups[0].items.map((t) => t.label)).toEqual(["a", "c"]);
|
|
35
|
+
expect(result.groups[1].items.map((t) => t.label)).toEqual(["b", "d"]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("preserves ungrouped tabs above grouped tabs regardless of array order", () => {
|
|
39
|
+
const result = partitionTabs([tab("one", "Work"), tab("two"), tab("three", "Work"), tab("four")]);
|
|
40
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["two", "four"]);
|
|
41
|
+
expect(result.groups).toHaveLength(1);
|
|
42
|
+
expect(result.groups[0].items.map((t) => t.label)).toEqual(["one", "three"]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("treats an empty-string group as 'no group'", () => {
|
|
46
|
+
const result = partitionTabs([tab("a", ""), tab("b", "Work")]);
|
|
47
|
+
expect(result.ungrouped.map((t) => t.label)).toEqual(["a"]);
|
|
48
|
+
expect(result.groups).toHaveLength(1);
|
|
49
|
+
expect(result.groups[0].label).toBe("Work");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Tab } from "./TabsContainer";
|
|
2
|
+
|
|
3
|
+
export type PartitionedTabs = {
|
|
4
|
+
ungrouped: Tab[];
|
|
5
|
+
groups: Array<{ label: string; items: Tab[] }>;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Split a `Tab[]` into ungrouped + grouped strata for the
|
|
10
|
+
* `RoundPageContainer` `layout="rail"` navigation.
|
|
11
|
+
*
|
|
12
|
+
* Tabs without a `group` land in `ungrouped` (the pinned stratum) in declared
|
|
13
|
+
* order. Grouped tabs cluster under their `group` label; groups appear in the
|
|
14
|
+
* order they first occur in the input array.
|
|
15
|
+
*
|
|
16
|
+
* Pure function — safe to call on every render. Complexity O(n).
|
|
17
|
+
*/
|
|
18
|
+
export function partitionTabs(tabs: Tab[]): PartitionedTabs {
|
|
19
|
+
const ungrouped: Tab[] = [];
|
|
20
|
+
const groupMap = new Map<string, Tab[]>();
|
|
21
|
+
const groupOrder: string[] = [];
|
|
22
|
+
|
|
23
|
+
for (const tab of tabs) {
|
|
24
|
+
if (!tab.group) {
|
|
25
|
+
ungrouped.push(tab);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!groupMap.has(tab.group)) {
|
|
29
|
+
groupMap.set(tab.group, []);
|
|
30
|
+
groupOrder.push(tab.group);
|
|
31
|
+
}
|
|
32
|
+
// The map entry is guaranteed to exist because we just initialized it.
|
|
33
|
+
groupMap.get(tab.group)!.push(tab);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
ungrouped,
|
|
38
|
+
groups: groupOrder.map((label) => ({
|
|
39
|
+
label,
|
|
40
|
+
items: groupMap.get(label)!,
|
|
41
|
+
})),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useTranslations } from "next-intl";
|
|
4
|
-
import { ReactNode, useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import { ReactElement, ReactNode, useCallback, useEffect, useRef } from "react";
|
|
5
5
|
import { FieldValues, UseFormReturn } from "react-hook-form";
|
|
6
6
|
import { PencilIcon } from "lucide-react";
|
|
7
7
|
import { ModuleWithPermissions } from "../../permissions/types";
|
|
@@ -161,7 +161,12 @@ export function EditorSheet<T extends FieldValues>({
|
|
|
161
161
|
{dialogOpen === undefined &&
|
|
162
162
|
forceShow === undefined &&
|
|
163
163
|
(trigger ? (
|
|
164
|
-
<
|
|
164
|
+
// Base UI: the trigger renders its own <button>. Pass the caller's
|
|
165
|
+
// element via `render` (NOT as children) so it BECOMES the trigger
|
|
166
|
+
// button — otherwise an interactive trigger (e.g. <Button>) nests a
|
|
167
|
+
// <button> inside SheetTrigger's <button> (invalid HTML / hydration
|
|
168
|
+
// error). `render` also preserves the element's native `disabled`.
|
|
169
|
+
<SheetTrigger render={trigger as ReactElement} />
|
|
165
170
|
) : (
|
|
166
171
|
<SheetTrigger>
|
|
167
172
|
{isEdit ? (
|
|
@@ -45,7 +45,13 @@ function BreadcrumbDesktop({
|
|
|
45
45
|
{items.length > ITEMS_TO_DISPLAY ? (
|
|
46
46
|
<>
|
|
47
47
|
<BreadcrumbItem>
|
|
48
|
-
{items[0].href ?
|
|
48
|
+
{items[0].href ? (
|
|
49
|
+
<Link href={items[0].href} onClick={items[0].onClick}>
|
|
50
|
+
{items[0].name}
|
|
51
|
+
</Link>
|
|
52
|
+
) : (
|
|
53
|
+
<>{items[0].name}</>
|
|
54
|
+
)}
|
|
49
55
|
</BreadcrumbItem>
|
|
50
56
|
<BreadcrumbSeparator />
|
|
51
57
|
<BreadcrumbItem>
|
|
@@ -56,7 +62,9 @@ function BreadcrumbDesktop({
|
|
|
56
62
|
<DropdownMenuContent align="start">
|
|
57
63
|
{items.slice(1, -ITEMS_TO_DISPLAY + 2).map((item, index) => (
|
|
58
64
|
<DropdownMenuItem key={index}>
|
|
59
|
-
<Link href={item.href ? item.href : "#"}
|
|
65
|
+
<Link href={item.href ? item.href : "#"} onClick={item.onClick}>
|
|
66
|
+
{item.name}
|
|
67
|
+
</Link>
|
|
60
68
|
</DropdownMenuItem>
|
|
61
69
|
))}
|
|
62
70
|
</DropdownMenuContent>
|
|
@@ -66,7 +74,13 @@ function BreadcrumbDesktop({
|
|
|
66
74
|
{items.slice(-ITEMS_TO_DISPLAY + 2).map((item, index) => (
|
|
67
75
|
<Fragment key={index}>
|
|
68
76
|
<BreadcrumbItem>
|
|
69
|
-
{item.href ?
|
|
77
|
+
{item.href ? (
|
|
78
|
+
<Link href={item.href} onClick={item.onClick}>
|
|
79
|
+
{item.name}
|
|
80
|
+
</Link>
|
|
81
|
+
) : (
|
|
82
|
+
<>{item.name}</>
|
|
83
|
+
)}
|
|
70
84
|
</BreadcrumbItem>
|
|
71
85
|
{index < items.slice(-ITEMS_TO_DISPLAY + 2).length - 1 && <BreadcrumbSeparator />}
|
|
72
86
|
</Fragment>
|
|
@@ -77,7 +91,13 @@ function BreadcrumbDesktop({
|
|
|
77
91
|
{items.map((item, index) => (
|
|
78
92
|
<Fragment key={index}>
|
|
79
93
|
<BreadcrumbItem>
|
|
80
|
-
{item.href ?
|
|
94
|
+
{item.href ? (
|
|
95
|
+
<Link href={item.href} onClick={item.onClick}>
|
|
96
|
+
{item.name}
|
|
97
|
+
</Link>
|
|
98
|
+
) : (
|
|
99
|
+
<>{item.name}</>
|
|
100
|
+
)}
|
|
81
101
|
</BreadcrumbItem>
|
|
82
102
|
{index < items.length - 1 && <BreadcrumbSeparator />}
|
|
83
103
|
</Fragment>
|
|
@@ -124,7 +144,13 @@ function BreadcrumbMobile({
|
|
|
124
144
|
<DropdownMenuContent align="start">
|
|
125
145
|
{allItems.map((item, index) => (
|
|
126
146
|
<DropdownMenuItem key={index}>
|
|
127
|
-
{item.href ?
|
|
147
|
+
{item.href ? (
|
|
148
|
+
<Link href={item.href} onClick={item.onClick}>
|
|
149
|
+
{item.name}
|
|
150
|
+
</Link>
|
|
151
|
+
) : (
|
|
152
|
+
<>{item.name}</>
|
|
153
|
+
)}
|
|
128
154
|
</DropdownMenuItem>
|
|
129
155
|
))}
|
|
130
156
|
</DropdownMenuContent>
|
package/src/hooks/useSocket.ts
CHANGED
|
@@ -114,7 +114,18 @@ export function useSocket({ token }: UseSocketOptions): UseSocketReturn {
|
|
|
114
114
|
};
|
|
115
115
|
|
|
116
116
|
const handleNotification = (data: any) => {
|
|
117
|
-
|
|
117
|
+
// The socket sends a JSON:API document { data, included }; rehydrate expects
|
|
118
|
+
// { jsonApi, included }. Map it (and guard against an unexpected shape so a
|
|
119
|
+
// malformed payload never throws an uncaught error that breaks the socket).
|
|
120
|
+
const resource = data?.data ?? data?.jsonApi;
|
|
121
|
+
if (!resource?.type) {
|
|
122
|
+
console.warn("[useSocket] ignoring notification with unexpected payload shape", data);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const notification = rehydrate(Modules.Notification, {
|
|
126
|
+
jsonApi: resource,
|
|
127
|
+
included: data?.included || [],
|
|
128
|
+
}) as NotificationInterface;
|
|
118
129
|
if (notification) {
|
|
119
130
|
setSocketNotifications((prev) => {
|
|
120
131
|
const newNotifications = [...prev, notification];
|