@carlonicora/nextjs-jsonapi 1.126.0 → 1.128.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-ZW6OHTBH.js → BlockNoteEditor-LAH2RUGP.js} +9 -9
- package/dist/{BlockNoteEditor-ZW6OHTBH.js.map → BlockNoteEditor-LAH2RUGP.js.map} +1 -1
- package/dist/{BlockNoteEditor-SONASOXF.mjs → BlockNoteEditor-LJY3X6F6.mjs} +2 -2
- package/dist/billing/index.js +299 -299
- package/dist/billing/index.mjs +1 -1
- package/dist/{chunk-DUPLW72K.mjs → chunk-PJGAR5F3.mjs} +162 -134
- package/dist/chunk-PJGAR5F3.mjs.map +1 -0
- package/dist/{chunk-CI4D76N6.js → chunk-QVRFFC2Q.js} +152 -124
- package/dist/chunk-QVRFFC2Q.js.map +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/index.mjs +1 -1
- package/dist/components/index.d.mts +9 -1
- package/dist/components/index.d.ts +9 -1
- 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/features/help/index.js +30 -30
- package/dist/features/help/index.mjs +1 -1
- package/package.json +1 -1
- package/src/components/containers/RoundPageContainer.tsx +28 -4
- package/src/components/containers/RoundPageContainerTitle.tsx +9 -3
- package/src/components/tables/ContentListTable.tsx +16 -4
- package/src/components/tables/__tests__/ContentListTable.test.tsx +38 -2
- package/src/features/company/components/lists/CompaniesList.tsx +1 -1
- package/src/features/content/components/lists/ContentsListById.tsx +1 -1
- package/src/features/content/components/lists/RelevantContentsList.tsx +1 -1
- package/src/features/user/components/lists/AdminUsersList.tsx +1 -1
- package/dist/chunk-CI4D76N6.js.map +0 -1
- package/dist/chunk-DUPLW72K.mjs.map +0 -1
- /package/dist/{BlockNoteEditor-SONASOXF.mjs.map → BlockNoteEditor-LJY3X6F6.mjs.map} +0 -0
|
@@ -5,6 +5,7 @@ import { ExpandedState, flexRender, getCoreRowModel, getExpandedRowModel, useRea
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@/index";
|
|
7
7
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
8
|
+
import { useTranslations } from "next-intl";
|
|
8
9
|
import React, { ReactNode, memo, useMemo, useState } from "react";
|
|
9
10
|
import { DataListRetriever, TableContent, useTableGenerator } from "../../hooks";
|
|
10
11
|
import { ModuleWithPermissions } from "../../permissions";
|
|
@@ -48,10 +49,12 @@ type ContentListTableProps = {
|
|
|
48
49
|
fullWidth?: boolean;
|
|
49
50
|
groupBy?: string;
|
|
50
51
|
emptyState?: ReactNode;
|
|
52
|
+
onRowClick?: (rowData: any) => void;
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
export const ContentListTable = memo(function ContentListTable(props: ContentListTableProps) {
|
|
54
|
-
const { data, fields, checkedIds, toggleId, allowSearch, filters: _filters, fullWidth } = props;
|
|
56
|
+
const { data, fields, checkedIds, toggleId, allowSearch, filters: _filters, fullWidth, onRowClick } = props;
|
|
57
|
+
const t = useTranslations();
|
|
55
58
|
const [expanded, setExpanded] = useState<ExpandedState>(
|
|
56
59
|
props.defaultExpanded === true ? true : typeof props.defaultExpanded === "object" ? props.defaultExpanded : {},
|
|
57
60
|
);
|
|
@@ -190,7 +193,11 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
190
193
|
</TableCell>
|
|
191
194
|
</TableRow>
|
|
192
195
|
{group.rows.map((row) => (
|
|
193
|
-
<TableRow
|
|
196
|
+
<TableRow
|
|
197
|
+
key={row.id}
|
|
198
|
+
onClick={() => onRowClick?.(row.original.jsonApiData)}
|
|
199
|
+
className={`group ${onRowClick ? "hover:bg-muted/50 cursor-pointer" : ""}`}
|
|
200
|
+
>
|
|
194
201
|
{row.getVisibleCells().map((cell) => {
|
|
195
202
|
const meta = cell.column.columnDef.meta as { className?: string } | undefined;
|
|
196
203
|
return (
|
|
@@ -205,7 +212,11 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
205
212
|
))
|
|
206
213
|
) : (
|
|
207
214
|
rowModel.rows.map((row) => (
|
|
208
|
-
<TableRow
|
|
215
|
+
<TableRow
|
|
216
|
+
key={row.id}
|
|
217
|
+
onClick={() => onRowClick?.(row.original.jsonApiData)}
|
|
218
|
+
className={`group ${onRowClick ? "hover:bg-muted/50 cursor-pointer" : ""}`}
|
|
219
|
+
>
|
|
209
220
|
{row.getVisibleCells().map((cell) => {
|
|
210
221
|
const meta = cell.column.columnDef.meta as { className?: string } | undefined;
|
|
211
222
|
return (
|
|
@@ -220,7 +231,8 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
220
231
|
) : (
|
|
221
232
|
<TableRow>
|
|
222
233
|
<TableCell colSpan={tableColumns.length} className="h-24 text-center">
|
|
223
|
-
{props.emptyState ??
|
|
234
|
+
{props.emptyState ??
|
|
235
|
+
(t.has("ui.empty_states.no_results") ? t("ui.empty_states.no_results") : "No results.")}
|
|
224
236
|
</TableCell>
|
|
225
237
|
</TableRow>
|
|
226
238
|
)}
|
|
@@ -132,7 +132,7 @@ describe("ContentListTable", () => {
|
|
|
132
132
|
|
|
133
133
|
render(<ContentListTable data={dataRetriever} tableGeneratorType={mockModule as any} fields={["id", "title"]} />);
|
|
134
134
|
|
|
135
|
-
expect(screen.getByText("
|
|
135
|
+
expect(screen.getByText("ui.empty_states.no_results")).toBeInTheDocument();
|
|
136
136
|
});
|
|
137
137
|
});
|
|
138
138
|
|
|
@@ -464,7 +464,7 @@ describe("ContentListTable", () => {
|
|
|
464
464
|
/>,
|
|
465
465
|
);
|
|
466
466
|
|
|
467
|
-
expect(screen.getByText("
|
|
467
|
+
expect(screen.getByText("ui.empty_states.no_results")).toBeInTheDocument();
|
|
468
468
|
});
|
|
469
469
|
|
|
470
470
|
it("should group by to-many relationship, duplicating rows across groups", () => {
|
|
@@ -512,4 +512,40 @@ describe("ContentListTable", () => {
|
|
|
512
512
|
expect(article3Count).toBe(2);
|
|
513
513
|
});
|
|
514
514
|
});
|
|
515
|
+
|
|
516
|
+
describe("onRowClick", () => {
|
|
517
|
+
it("calls onRowClick with the row's jsonApiData when a row is clicked", () => {
|
|
518
|
+
const onRowClick = vi.fn();
|
|
519
|
+
const dataRetriever = createMockDataRetriever({
|
|
520
|
+
data: [{ id: "1", title: "First Article" }],
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
render(
|
|
524
|
+
<ContentListTable
|
|
525
|
+
data={dataRetriever}
|
|
526
|
+
tableGeneratorType={mockModule as any}
|
|
527
|
+
fields={["id", "title"]}
|
|
528
|
+
onRowClick={onRowClick}
|
|
529
|
+
/>,
|
|
530
|
+
);
|
|
531
|
+
|
|
532
|
+
fireEvent.click(screen.getByText("First Article"));
|
|
533
|
+
expect(onRowClick).toHaveBeenCalledTimes(1);
|
|
534
|
+
expect(onRowClick).toHaveBeenCalledWith({ id: "1", title: "First Article" });
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
it("does not attach a row click handler when onRowClick is absent", () => {
|
|
538
|
+
const dataRetriever = createMockDataRetriever({
|
|
539
|
+
data: [{ id: "1", title: "First Article" }],
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
render(<ContentListTable data={dataRetriever} tableGeneratorType={mockModule as any} fields={["id", "title"]} />);
|
|
543
|
+
|
|
544
|
+
// No throw on click, and the row has no cursor-pointer affordance class.
|
|
545
|
+
const cell = screen.getByText("First Article");
|
|
546
|
+
const row = cell.closest("tr")!;
|
|
547
|
+
expect(row.className).not.toContain("cursor-pointer");
|
|
548
|
+
fireEvent.click(cell); // must not throw
|
|
549
|
+
});
|
|
550
|
+
});
|
|
515
551
|
});
|
|
@@ -23,7 +23,7 @@ export function CompaniesList() {
|
|
|
23
23
|
return (
|
|
24
24
|
<ContentListTable
|
|
25
25
|
data={data}
|
|
26
|
-
fields={[CompanyFields.name
|
|
26
|
+
fields={[CompanyFields.name]}
|
|
27
27
|
tableGeneratorType={Modules.Company}
|
|
28
28
|
functions={functions}
|
|
29
29
|
title={t(`entities.companies`, { count: 2 })}
|
|
@@ -23,7 +23,7 @@ export function ContentsListById({ contentIds }: ContentsListByIdProps) {
|
|
|
23
23
|
return (
|
|
24
24
|
<ContentListTable
|
|
25
25
|
data={data}
|
|
26
|
-
fields={[ContentFields.name, ContentFields.authors
|
|
26
|
+
fields={[ContentFields.name, ContentFields.authors]}
|
|
27
27
|
tableGeneratorType={Modules.Content}
|
|
28
28
|
title={t(`common.relevant`)}
|
|
29
29
|
/>
|
|
@@ -23,7 +23,7 @@ export function RelevantContentsList({ id }: RelevantContentsListProps) {
|
|
|
23
23
|
return (
|
|
24
24
|
<ContentListTable
|
|
25
25
|
data={data}
|
|
26
|
-
fields={[ContentFields.name, ContentFields.authors, ContentFields.relevance
|
|
26
|
+
fields={[ContentFields.name, ContentFields.authors, ContentFields.relevance]}
|
|
27
27
|
tableGeneratorType={Modules.Content}
|
|
28
28
|
title={t(`common.relevant`)}
|
|
29
29
|
/>
|
|
@@ -27,7 +27,7 @@ function AdminUsersListInternal({ company }: AdminUsersListProps) {
|
|
|
27
27
|
<ContentListTable
|
|
28
28
|
title={t(`entities.users`, { count: 2 })}
|
|
29
29
|
data={data}
|
|
30
|
-
fields={[UserFields.name, UserFields.email
|
|
30
|
+
fields={[UserFields.name, UserFields.email]}
|
|
31
31
|
tableGeneratorType={Modules.User}
|
|
32
32
|
functions={<UserEditor propagateChanges={data.refresh} adminCreated />}
|
|
33
33
|
/>
|