@carlonicora/nextjs-jsonapi 1.127.0 → 1.129.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-PGTAPCQF.js → BlockNoteEditor-RG2YQDMQ.js} +20 -20
- package/dist/{BlockNoteEditor-PGTAPCQF.js.map → BlockNoteEditor-RG2YQDMQ.js.map} +1 -1
- package/dist/{BlockNoteEditor-SMZNQ4CX.mjs → BlockNoteEditor-WIAQJ5HM.mjs} +5 -5
- package/dist/{JsonApiRequest-4ISXX7PC.mjs → JsonApiRequest-F5LBESSA.mjs} +2 -2
- package/dist/JsonApiRequest-YAPUG4ND.js +26 -0
- package/dist/{JsonApiRequest-P3VQ2WIS.js.map → JsonApiRequest-YAPUG4ND.js.map} +1 -1
- package/dist/billing/index.js +347 -347
- package/dist/billing/index.mjs +4 -4
- package/dist/{chunk-T2FFT7JT.mjs → chunk-5MNE72ZE.mjs} +9 -5
- package/dist/{chunk-T2FFT7JT.mjs.map → chunk-5MNE72ZE.mjs.map} +1 -1
- package/dist/{chunk-JGVMZYAO.mjs → chunk-F54XZKPY.mjs} +149 -130
- package/dist/chunk-F54XZKPY.mjs.map +1 -0
- package/dist/{chunk-PQBKPWBY.js → chunk-LBMNRFCY.js} +34 -30
- package/dist/chunk-LBMNRFCY.js.map +1 -0
- package/dist/{chunk-6VNRUTZR.mjs → chunk-NATPK5ME.mjs} +3 -3
- package/dist/{chunk-EIOEYXY3.js → chunk-QWCAOLBD.js} +6 -5
- package/dist/chunk-QWCAOLBD.js.map +1 -0
- package/dist/{chunk-JO5BLONK.js → chunk-XTLTQQ7X.js} +9 -9
- package/dist/{chunk-JO5BLONK.js.map → chunk-XTLTQQ7X.js.map} +1 -1
- package/dist/{chunk-24RSNGD2.js → chunk-YQTMNZQB.js} +808 -789
- package/dist/chunk-YQTMNZQB.js.map +1 -0
- package/dist/{chunk-DKFXGCG2.mjs → chunk-Z2CB63VG.mjs} +6 -5
- package/dist/{chunk-DKFXGCG2.mjs.map → chunk-Z2CB63VG.mjs.map} +1 -1
- package/dist/client/index.js +5 -5
- package/dist/client/index.mjs +4 -4
- package/dist/components/index.d.mts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +5 -5
- package/dist/components/index.mjs +4 -4
- package/dist/contexts/index.js +5 -5
- package/dist/contexts/index.mjs +4 -4
- package/dist/core/index.js +3 -3
- package/dist/core/index.mjs +2 -2
- package/dist/features/help/index.js +37 -37
- package/dist/features/help/index.mjs +4 -4
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/dist/server/index.js +12 -12
- package/dist/server/index.mjs +2 -2
- package/package.json +2 -2
- package/src/components/tables/ContentListTable.tsx +18 -4
- package/src/components/tables/__tests__/ContentListTable.test.tsx +38 -2
- package/src/core/abstracts/AbstractService.ts +4 -0
- 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/src/unified/JsonApiRequest.ts +9 -4
- package/dist/JsonApiRequest-P3VQ2WIS.js +0 -26
- package/dist/chunk-24RSNGD2.js.map +0 -1
- package/dist/chunk-EIOEYXY3.js.map +0 -1
- package/dist/chunk-JGVMZYAO.mjs.map +0 -1
- package/dist/chunk-PQBKPWBY.js.map +0 -1
- /package/dist/{BlockNoteEditor-SMZNQ4CX.mjs.map → BlockNoteEditor-WIAQJ5HM.mjs.map} +0 -0
- /package/dist/{JsonApiRequest-4ISXX7PC.mjs.map → JsonApiRequest-F5LBESSA.mjs.map} +0 -0
- /package/dist/{chunk-6VNRUTZR.mjs.map → chunk-NATPK5ME.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";
|
|
@@ -32,6 +33,7 @@ export type GenerateTableStructureParams = {
|
|
|
32
33
|
|
|
33
34
|
type ContentListTableProps = {
|
|
34
35
|
title?: string;
|
|
36
|
+
titleActions?: ReactNode;
|
|
35
37
|
data: DataListRetriever<any>;
|
|
36
38
|
tableGenerator?: never;
|
|
37
39
|
tableGeneratorType: ModuleWithPermissions;
|
|
@@ -48,10 +50,12 @@ type ContentListTableProps = {
|
|
|
48
50
|
fullWidth?: boolean;
|
|
49
51
|
groupBy?: string;
|
|
50
52
|
emptyState?: ReactNode;
|
|
53
|
+
onRowClick?: (rowData: any) => void;
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
export const ContentListTable = memo(function ContentListTable(props: ContentListTableProps) {
|
|
54
|
-
const { data, fields, checkedIds, toggleId, allowSearch, filters: _filters, fullWidth } = props;
|
|
57
|
+
const { data, fields, checkedIds, toggleId, allowSearch, filters: _filters, fullWidth, onRowClick } = props;
|
|
58
|
+
const t = useTranslations();
|
|
55
59
|
const [expanded, setExpanded] = useState<ExpandedState>(
|
|
56
60
|
props.defaultExpanded === true ? true : typeof props.defaultExpanded === "object" ? props.defaultExpanded : {},
|
|
57
61
|
);
|
|
@@ -144,6 +148,7 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
144
148
|
fullWidth ? `text-lg` : `text-sm`,
|
|
145
149
|
)}
|
|
146
150
|
>
|
|
151
|
+
{props.titleActions}
|
|
147
152
|
{props.tableGeneratorType.icon && (
|
|
148
153
|
<props.tableGeneratorType.icon
|
|
149
154
|
className={cn(`text-primary`, fullWidth ? `h-6 w-6` : `h-4 w-4`)}
|
|
@@ -190,7 +195,11 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
190
195
|
</TableCell>
|
|
191
196
|
</TableRow>
|
|
192
197
|
{group.rows.map((row) => (
|
|
193
|
-
<TableRow
|
|
198
|
+
<TableRow
|
|
199
|
+
key={row.id}
|
|
200
|
+
onClick={() => onRowClick?.(row.original.jsonApiData)}
|
|
201
|
+
className={`group ${onRowClick ? "hover:bg-muted/50 cursor-pointer" : ""}`}
|
|
202
|
+
>
|
|
194
203
|
{row.getVisibleCells().map((cell) => {
|
|
195
204
|
const meta = cell.column.columnDef.meta as { className?: string } | undefined;
|
|
196
205
|
return (
|
|
@@ -205,7 +214,11 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
205
214
|
))
|
|
206
215
|
) : (
|
|
207
216
|
rowModel.rows.map((row) => (
|
|
208
|
-
<TableRow
|
|
217
|
+
<TableRow
|
|
218
|
+
key={row.id}
|
|
219
|
+
onClick={() => onRowClick?.(row.original.jsonApiData)}
|
|
220
|
+
className={`group ${onRowClick ? "hover:bg-muted/50 cursor-pointer" : ""}`}
|
|
221
|
+
>
|
|
209
222
|
{row.getVisibleCells().map((cell) => {
|
|
210
223
|
const meta = cell.column.columnDef.meta as { className?: string } | undefined;
|
|
211
224
|
return (
|
|
@@ -220,7 +233,8 @@ export const ContentListTable = memo(function ContentListTable(props: ContentLis
|
|
|
220
233
|
) : (
|
|
221
234
|
<TableRow>
|
|
222
235
|
<TableCell colSpan={tableColumns.length} className="h-24 text-center">
|
|
223
|
-
{props.emptyState ??
|
|
236
|
+
{props.emptyState ??
|
|
237
|
+
(t.has("ui.empty_states.no_results") ? t("ui.empty_states.no_results") : "No results.")}
|
|
224
238
|
</TableCell>
|
|
225
239
|
</TableRow>
|
|
226
240
|
)}
|
|
@@ -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
|
});
|
|
@@ -177,6 +177,7 @@ export abstract class AbstractService {
|
|
|
177
177
|
endpoint: params.endpoint,
|
|
178
178
|
companyId: params.companyId,
|
|
179
179
|
language: language,
|
|
180
|
+
token: params.token,
|
|
180
181
|
baseUrl: params.baseUrl,
|
|
181
182
|
});
|
|
182
183
|
break;
|
|
@@ -203,6 +204,7 @@ export abstract class AbstractService {
|
|
|
203
204
|
language: language,
|
|
204
205
|
responseType: params.responseType,
|
|
205
206
|
files: params.files,
|
|
207
|
+
token: params.token,
|
|
206
208
|
baseUrl: params.baseUrl,
|
|
207
209
|
});
|
|
208
210
|
break;
|
|
@@ -216,6 +218,7 @@ export abstract class AbstractService {
|
|
|
216
218
|
language: language,
|
|
217
219
|
responseType: params.responseType,
|
|
218
220
|
files: params.files,
|
|
221
|
+
token: params.token,
|
|
219
222
|
baseUrl: params.baseUrl,
|
|
220
223
|
});
|
|
221
224
|
break;
|
|
@@ -226,6 +229,7 @@ export abstract class AbstractService {
|
|
|
226
229
|
companyId: params.companyId,
|
|
227
230
|
language: language,
|
|
228
231
|
responseType: params.responseType,
|
|
232
|
+
token: params.token,
|
|
229
233
|
baseUrl: params.baseUrl,
|
|
230
234
|
});
|
|
231
235
|
break;
|
|
@@ -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
|
/>
|
|
@@ -185,10 +185,11 @@ export async function JsonApiGet(params: {
|
|
|
185
185
|
endpoint: string;
|
|
186
186
|
companyId?: string;
|
|
187
187
|
language: string;
|
|
188
|
+
token?: string;
|
|
188
189
|
baseUrl?: string;
|
|
189
190
|
}): Promise<ApiResponseInterface> {
|
|
190
191
|
runBootstrapper();
|
|
191
|
-
const token = await getToken();
|
|
192
|
+
const token = params.token ?? (await getToken());
|
|
192
193
|
|
|
193
194
|
const apiResponse = await makeRequest({
|
|
194
195
|
method: "GET",
|
|
@@ -211,6 +212,7 @@ export async function JsonApiGet(params: {
|
|
|
211
212
|
endpoint,
|
|
212
213
|
companyId: params.companyId,
|
|
213
214
|
language: params.language,
|
|
215
|
+
token: params.token,
|
|
214
216
|
baseUrl: params.baseUrl,
|
|
215
217
|
}),
|
|
216
218
|
});
|
|
@@ -265,10 +267,11 @@ export async function JsonApiPut(params: {
|
|
|
265
267
|
files?: { [key: string]: File | Blob } | File | Blob;
|
|
266
268
|
language: string;
|
|
267
269
|
responseType?: ApiRequestDataTypeInterface;
|
|
270
|
+
token?: string;
|
|
268
271
|
baseUrl?: string;
|
|
269
272
|
}): Promise<ApiResponseInterface> {
|
|
270
273
|
runBootstrapper();
|
|
271
|
-
const token = await getToken();
|
|
274
|
+
const token = params.token ?? (await getToken());
|
|
272
275
|
|
|
273
276
|
let body = params.body;
|
|
274
277
|
if (!body) {
|
|
@@ -305,10 +308,11 @@ export async function JsonApiPatch(params: {
|
|
|
305
308
|
overridesJsonApiCreation?: boolean;
|
|
306
309
|
responseType?: ApiRequestDataTypeInterface;
|
|
307
310
|
language: string;
|
|
311
|
+
token?: string;
|
|
308
312
|
baseUrl?: string;
|
|
309
313
|
}): Promise<ApiResponseInterface> {
|
|
310
314
|
runBootstrapper();
|
|
311
|
-
const token = await getToken();
|
|
315
|
+
const token = params.token ?? (await getToken());
|
|
312
316
|
|
|
313
317
|
let body = params.body;
|
|
314
318
|
if (!body) {
|
|
@@ -342,10 +346,11 @@ export async function JsonApiDelete(params: {
|
|
|
342
346
|
companyId?: string;
|
|
343
347
|
language: string;
|
|
344
348
|
responseType?: ApiRequestDataTypeInterface;
|
|
349
|
+
token?: string;
|
|
345
350
|
baseUrl?: string;
|
|
346
351
|
}): Promise<ApiResponseInterface> {
|
|
347
352
|
runBootstrapper();
|
|
348
|
-
const token = await getToken();
|
|
353
|
+
const token = params.token ?? (await getToken());
|
|
349
354
|
|
|
350
355
|
const apiResponse = await makeRequest({
|
|
351
356
|
method: "DELETE",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkEIOEYXY3js = require('./chunk-EIOEYXY3.js');
|
|
13
|
-
require('./chunk-7QVYU63E.js');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.JsonApiDelete = _chunkEIOEYXY3js.JsonApiDelete; exports.JsonApiGet = _chunkEIOEYXY3js.JsonApiGet; exports.JsonApiPatch = _chunkEIOEYXY3js.JsonApiPatch; exports.JsonApiPost = _chunkEIOEYXY3js.JsonApiPost; exports.JsonApiPut = _chunkEIOEYXY3js.JsonApiPut; exports.buildUrl = _chunkEIOEYXY3js.buildUrl; exports.configureJsonApi = _chunkEIOEYXY3js.configureJsonApi; exports.getApiUrl = _chunkEIOEYXY3js.getApiUrl; exports.getAppUrl = _chunkEIOEYXY3js.getAppUrl; exports.getTrackablePages = _chunkEIOEYXY3js.getTrackablePages;
|
|
26
|
-
//# sourceMappingURL=JsonApiRequest-P3VQ2WIS.js.map
|