@multiplatform.one/backoffice 7.40.0 → 7.42.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/cjs/form/DocFormScreen.cjs +1 -0
- package/dist/cjs/form/DocFormScreen.native.js +1 -0
- package/dist/cjs/form/DocFormScreen.native.js.map +1 -1
- package/dist/cjs/i18n/en.cjs +4 -0
- package/dist/cjs/i18n/en.native.js +4 -0
- package/dist/cjs/i18n/en.native.js.map +1 -1
- package/dist/cjs/list/DoctypeListScreen.cjs +91 -72
- package/dist/cjs/list/DoctypeListScreen.native.js +101 -74
- package/dist/cjs/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/cjs/list/list-paging.cjs +94 -0
- package/dist/cjs/list/list-paging.native.js +103 -0
- package/dist/cjs/list/list-paging.native.js.map +1 -0
- package/dist/esm/form/DocFormScreen.mjs +1 -0
- package/dist/esm/form/DocFormScreen.mjs.map +1 -1
- package/dist/esm/form/DocFormScreen.native.js +1 -0
- package/dist/esm/form/DocFormScreen.native.js.map +1 -1
- package/dist/esm/i18n/en.mjs +4 -0
- package/dist/esm/i18n/en.mjs.map +1 -1
- package/dist/esm/i18n/en.native.js +4 -0
- package/dist/esm/i18n/en.native.js.map +1 -1
- package/dist/esm/list/DoctypeListScreen.mjs +93 -74
- package/dist/esm/list/DoctypeListScreen.mjs.map +1 -1
- package/dist/esm/list/DoctypeListScreen.native.js +103 -76
- package/dist/esm/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/esm/list/list-paging.mjs +68 -0
- package/dist/esm/list/list-paging.mjs.map +1 -0
- package/dist/esm/list/list-paging.native.js +74 -0
- package/dist/esm/list/list-paging.native.js.map +1 -0
- package/dist/jsx/form/DocFormScreen.mjs +1 -0
- package/dist/jsx/form/DocFormScreen.mjs.map +1 -1
- package/dist/jsx/form/DocFormScreen.native.js +1 -0
- package/dist/jsx/form/DocFormScreen.native.js.map +1 -1
- package/dist/jsx/i18n/en.mjs +4 -0
- package/dist/jsx/i18n/en.mjs.map +1 -1
- package/dist/jsx/i18n/en.native.js +4 -0
- package/dist/jsx/i18n/en.native.js.map +1 -1
- package/dist/jsx/list/DoctypeListScreen.mjs +93 -74
- package/dist/jsx/list/DoctypeListScreen.mjs.map +1 -1
- package/dist/jsx/list/DoctypeListScreen.native.js +101 -74
- package/dist/jsx/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/jsx/list/list-paging.mjs +68 -0
- package/dist/jsx/list/list-paging.mjs.map +1 -0
- package/dist/jsx/list/list-paging.native.js +103 -0
- package/dist/jsx/list/list-paging.native.js.map +1 -0
- package/package.json +12 -12
- package/src/design/DeskPhoneBoard.stories.tsx +356 -0
- package/src/form/DocFormScreen.chrome.spec.ts +4 -0
- package/src/form/DocFormScreen.tsx +1 -0
- package/src/i18n/en.ts +4 -0
- package/src/list/DoctypeListScreen.tsx +122 -84
- package/src/list/list-paging.screen.spec.tsx +55 -0
- package/src/list/list-paging.tsx +78 -0
- package/types/form/DocFormScreen.d.ts.map +1 -1
- package/types/i18n/en.d.ts +4 -0
- package/types/i18n/en.d.ts.map +1 -1
- package/types/list/DoctypeListScreen.d.ts.map +1 -1
- package/types/list/list-paging.d.ts +13 -0
- package/types/list/list-paging.d.ts.map +1 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import React from "react";
|
|
10
10
|
import {
|
|
11
11
|
AsyncBoundary,
|
|
12
|
-
|
|
12
|
+
DropdownMenu,
|
|
13
13
|
EmptyState,
|
|
14
14
|
H1,
|
|
15
15
|
PageHeader,
|
|
@@ -28,6 +28,8 @@ import { Button as ActionButton, SearchInput } from "@multiplatform.one/forms";
|
|
|
28
28
|
import {
|
|
29
29
|
ArrowSquareOutIcon,
|
|
30
30
|
ArrowsClockwiseIcon,
|
|
31
|
+
DotsThreeIcon,
|
|
32
|
+
FunnelIcon,
|
|
31
33
|
PlusIcon,
|
|
32
34
|
SidebarSimpleIcon,
|
|
33
35
|
} from "@phosphor-icons/react";
|
|
@@ -93,6 +95,7 @@ import {
|
|
|
93
95
|
import { toggleFacetFilter } from "./sidebar-stats";
|
|
94
96
|
import { ListFilterBar } from "./ListFilterBar";
|
|
95
97
|
import { ListToolsButton } from "./list-tools-sheet";
|
|
98
|
+
import { LIST_PAGE_SIZES, ListPaging } from "./list-paging";
|
|
96
99
|
import { SortControl } from "./filter-sort";
|
|
97
100
|
import { ListSidebar } from "./ListSidebar";
|
|
98
101
|
import { useShellSidebarPanel } from "../shell/shellSidebarSlot";
|
|
@@ -167,8 +170,6 @@ type PendingDialog = {
|
|
|
167
170
|
clear: () => void;
|
|
168
171
|
} | null;
|
|
169
172
|
|
|
170
|
-
const PAGE_SIZES = [20, 100, 500];
|
|
171
|
-
|
|
172
173
|
// Generic JSX (`<FrappeTable<ListDoc> …/>`) breaks one-dev's source
|
|
173
174
|
// annotation transform; instantiate the type argument outside JSX instead.
|
|
174
175
|
const ListTable = FrappeTable<ListDoc>;
|
|
@@ -281,7 +282,9 @@ export function DoctypeListScreen({
|
|
|
281
282
|
const [searchText, setSearchText] = useState("");
|
|
282
283
|
const [loadedCount, setLoadedCount] = useState(0);
|
|
283
284
|
// Last page size the user picked — survives the filter/sort remounts.
|
|
284
|
-
const pageSizeRef = useRef(pageSize ??
|
|
285
|
+
const pageSizeRef = useRef<number>(pageSize ?? LIST_PAGE_SIZES[0]);
|
|
286
|
+
// Desk paging: the size Load More adds, and the one the toggle shows.
|
|
287
|
+
const [pageStep, setPageStep] = useState<number>(pageSize ?? LIST_PAGE_SIZES[0]);
|
|
285
288
|
|
|
286
289
|
// Always-ANDed host filters: joined into every query (table injection,
|
|
287
290
|
// live count, facet stats) but invisible to the user filter chrome —
|
|
@@ -436,6 +439,7 @@ export function DoctypeListScreen({
|
|
|
436
439
|
likeOverrides,
|
|
437
440
|
permMatrix,
|
|
438
441
|
getDocHref: (name) => paths.form(doctype, name),
|
|
442
|
+
baseURL: config?.baseURL,
|
|
439
443
|
onFilterClick: (fieldname, value) => {
|
|
440
444
|
const next = toggleFacetFilter(baseFiltersRef.current, [fieldname, "=", value]);
|
|
441
445
|
setBaseFilters(next);
|
|
@@ -457,6 +461,7 @@ export function DoctypeListScreen({
|
|
|
457
461
|
doctype,
|
|
458
462
|
withFixed,
|
|
459
463
|
writeUrlState,
|
|
464
|
+
config?.baseURL,
|
|
460
465
|
]);
|
|
461
466
|
|
|
462
467
|
const fields = useMemo(() => listFieldsToFetch(layoutMeta, permMatrix), [layoutMeta, permMatrix]);
|
|
@@ -1024,88 +1029,101 @@ export function DoctypeListScreen({
|
|
|
1024
1029
|
</XStack>
|
|
1025
1030
|
);
|
|
1026
1031
|
|
|
1027
|
-
// Phone chrome: the banner already names the doctype
|
|
1028
|
-
//
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
shown: Math.min(loadedCount, count.value),
|
|
1033
|
-
count: count.value,
|
|
1034
|
-
defaultValue: "1–{{shown}} of {{count}}",
|
|
1035
|
-
})
|
|
1036
|
-
: countText;
|
|
1032
|
+
// Phone chrome (FZ-7684 board): the banner already names the doctype.
|
|
1033
|
+
// Views, More and New lead; search runs full width; Filter and the sort
|
|
1034
|
+
// selector share the next row (desk's filter area); pills follow only
|
|
1035
|
+
// when a filter applies. The result count rides the list's own tail.
|
|
1036
|
+
const filterCount = Array.isArray(baseFilters) ? baseFilters.length : 0;
|
|
1037
1037
|
const compactHeader = (
|
|
1038
1038
|
<YStack gap="$3">
|
|
1039
1039
|
<XStack gap="$2" alignItems="center">
|
|
1040
|
-
<
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
meta={meta}
|
|
1079
|
-
filters={baseFilters}
|
|
1080
|
-
onFiltersChange={handleBaseFiltersChange}
|
|
1081
|
-
sortField={sortField}
|
|
1082
|
-
sortOrder={sortOrder}
|
|
1083
|
-
onSortChange={handleSortChange}
|
|
1084
|
-
renderTrigger={(open) => (
|
|
1085
|
-
<Chip size="$4" variant="outlined" color="gray" icon={<PlusIcon />} onPress={open}>
|
|
1086
|
-
{t("list.filters.filter", "Filter")}
|
|
1087
|
-
</Chip>
|
|
1088
|
-
)}
|
|
1089
|
-
/>
|
|
1090
|
-
}
|
|
1091
|
-
/>
|
|
1092
|
-
)}
|
|
1093
|
-
<XStack alignItems="center" gap="$2">
|
|
1094
|
-
<Paragraph size="$3" color="$color10" margin={0} flexShrink={1} numberOfLines={1}>
|
|
1095
|
-
{rangeText ?? ""}
|
|
1096
|
-
</Paragraph>
|
|
1097
|
-
<XStack alignItems="center" gap="$1" flexShrink={0}>
|
|
1098
|
-
<ViewSwitcherMenu views={availableViews} current="list" onViewChange={handleViewChange} />
|
|
1099
|
-
{!metaRefused && (
|
|
1100
|
-
<SortControl
|
|
1101
|
-
meta={meta}
|
|
1102
|
-
sortField={sortField}
|
|
1103
|
-
sortOrder={sortOrder}
|
|
1104
|
-
onSortChange={handleSortChange}
|
|
1105
|
-
/>
|
|
1040
|
+
<ViewSwitcherMenu views={availableViews} current="list" onViewChange={handleViewChange} />
|
|
1041
|
+
<XStack gap="$2" alignItems="center">
|
|
1042
|
+
<DropdownMenu placement="bottom-end">
|
|
1043
|
+
<DropdownMenu.Trigger asChild>
|
|
1044
|
+
<ActionButton
|
|
1045
|
+
outlined
|
|
1046
|
+
icon={DotsThreeIcon}
|
|
1047
|
+
aria-label={t("list.more", "More actions")}
|
|
1048
|
+
testID="backoffice-list-more"
|
|
1049
|
+
/>
|
|
1050
|
+
</DropdownMenu.Trigger>
|
|
1051
|
+
<DropdownMenu.Content>
|
|
1052
|
+
<DropdownMenu.Item icon={<ArrowsClockwiseIcon />} onSelect={handleRefresh}>
|
|
1053
|
+
{t("list.refresh", "Refresh")}
|
|
1054
|
+
</DropdownMenu.Item>
|
|
1055
|
+
{deskHref ? (
|
|
1056
|
+
<DropdownMenu.Item
|
|
1057
|
+
icon={<ArrowSquareOutIcon />}
|
|
1058
|
+
onSelect={() => openInNewTab(deskHref)}
|
|
1059
|
+
>
|
|
1060
|
+
{t("list.openInDesk", "Open in Desk")}
|
|
1061
|
+
</DropdownMenu.Item>
|
|
1062
|
+
) : null}
|
|
1063
|
+
</DropdownMenu.Content>
|
|
1064
|
+
</DropdownMenu>
|
|
1065
|
+
{showNew && (
|
|
1066
|
+
<ActionButton
|
|
1067
|
+
accent
|
|
1068
|
+
icon={PlusIcon}
|
|
1069
|
+
onPress={() => setQuickEntryOpen(true)}
|
|
1070
|
+
aria-label={t("list.new", {
|
|
1071
|
+
defaultValue: "New {{doctype}}",
|
|
1072
|
+
doctype,
|
|
1073
|
+
})}
|
|
1074
|
+
testID="backoffice-list-new"
|
|
1075
|
+
>
|
|
1076
|
+
{t("list.newShort", "New")}
|
|
1077
|
+
</ActionButton>
|
|
1106
1078
|
)}
|
|
1107
1079
|
</XStack>
|
|
1108
1080
|
</XStack>
|
|
1081
|
+
<SearchInput
|
|
1082
|
+
key={doctype}
|
|
1083
|
+
defaultValue=""
|
|
1084
|
+
onSearch={setSearchText}
|
|
1085
|
+
clearable
|
|
1086
|
+
placeholder={t("list.searchPlaceholder", {
|
|
1087
|
+
defaultValue: "Search {{doctype}}",
|
|
1088
|
+
doctype,
|
|
1089
|
+
})}
|
|
1090
|
+
aria-label={t("list.searchPlaceholder", {
|
|
1091
|
+
defaultValue: "Search {{doctype}}",
|
|
1092
|
+
doctype,
|
|
1093
|
+
})}
|
|
1094
|
+
/>
|
|
1095
|
+
{!metaRefused && (
|
|
1096
|
+
<XStack gap="$2" alignItems="center">
|
|
1097
|
+
<ListToolsButton
|
|
1098
|
+
doctype={doctype}
|
|
1099
|
+
meta={meta}
|
|
1100
|
+
filters={baseFilters}
|
|
1101
|
+
onFiltersChange={handleBaseFiltersChange}
|
|
1102
|
+
sortField={sortField}
|
|
1103
|
+
sortOrder={sortOrder}
|
|
1104
|
+
onSortChange={handleSortChange}
|
|
1105
|
+
renderTrigger={(open) => (
|
|
1106
|
+
<ActionButton outlined icon={FunnelIcon} onPress={open}>
|
|
1107
|
+
{filterCount
|
|
1108
|
+
? t("list.filters.filterCount", {
|
|
1109
|
+
count: filterCount,
|
|
1110
|
+
defaultValue: "Filter ({{count}})",
|
|
1111
|
+
})
|
|
1112
|
+
: t("list.filters.filter", "Filter")}
|
|
1113
|
+
</ActionButton>
|
|
1114
|
+
)}
|
|
1115
|
+
/>
|
|
1116
|
+
<SortControl
|
|
1117
|
+
meta={meta}
|
|
1118
|
+
sortField={sortField}
|
|
1119
|
+
sortOrder={sortOrder}
|
|
1120
|
+
onSortChange={handleSortChange}
|
|
1121
|
+
/>
|
|
1122
|
+
</XStack>
|
|
1123
|
+
)}
|
|
1124
|
+
{!metaRefused && filterCount > 0 && (
|
|
1125
|
+
<FilterChips meta={meta} filters={baseFilters} onFiltersChange={handleBaseFiltersChange} />
|
|
1126
|
+
)}
|
|
1109
1127
|
</YStack>
|
|
1110
1128
|
);
|
|
1111
1129
|
|
|
@@ -1194,18 +1212,38 @@ export function DoctypeListScreen({
|
|
|
1194
1212
|
filters: initialTableFilters,
|
|
1195
1213
|
pagination: {
|
|
1196
1214
|
pageIndex: 0,
|
|
1197
|
-
pageSize:
|
|
1215
|
+
pageSize: pageSizeRef.current,
|
|
1216
|
+
},
|
|
1217
|
+
columnVisibility: {
|
|
1218
|
+
modified: false,
|
|
1219
|
+
// The image leads the phone list's rows; desktop's grid has no image column.
|
|
1220
|
+
...(layoutMeta?.image_field && !compactChrome
|
|
1221
|
+
? { [layoutMeta.image_field]: false }
|
|
1222
|
+
: {}),
|
|
1198
1223
|
},
|
|
1199
|
-
columnVisibility: { modified: false },
|
|
1200
1224
|
}}
|
|
1201
1225
|
// Keep-rows-and-reconcile (no remount): filter/sort changes
|
|
1202
1226
|
// adopt in place; refresh re-runs the current query in
|
|
1203
1227
|
// place. Rows stay rendered while the server reconciles.
|
|
1204
1228
|
controlledState={controlledTableState}
|
|
1205
1229
|
refreshToken={refreshGen}
|
|
1206
|
-
enablePagination
|
|
1207
|
-
paginationMode="
|
|
1230
|
+
enablePagination
|
|
1231
|
+
paginationMode="pages"
|
|
1232
|
+
// The list's own count (one get_count per filter state)
|
|
1233
|
+
// feeds the paging readout; the table asks for none.
|
|
1208
1234
|
fetchTotalCount={false}
|
|
1235
|
+
// Desk's paging (base_list.js setup_paging_area), not an
|
|
1236
|
+
// endless scroll: the readout, page sizes and Load More.
|
|
1237
|
+
showPageRange={false}
|
|
1238
|
+
renderPagination={(paging) => (
|
|
1239
|
+
<ListPaging
|
|
1240
|
+
{...paging}
|
|
1241
|
+
step={pageStep}
|
|
1242
|
+
onStepChange={setPageStep}
|
|
1243
|
+
shown={loadedCount}
|
|
1244
|
+
total={count.value}
|
|
1245
|
+
/>
|
|
1246
|
+
)}
|
|
1209
1247
|
// ONE FILTER SYSTEM (MOD-04 / LC-16): the list chrome is
|
|
1210
1248
|
// the single filtering authority; tuples reach the table
|
|
1211
1249
|
// through controlledState (in-place adoption — no remount).
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Desk's list paging (FZ-7684): the "20 of 151" readout, the 20 / 100 / 500
|
|
2
|
+
// page sizes and Load More, in place of the endless scroll.
|
|
3
|
+
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
4
|
+
import { fireEvent, screen } from "@testing-library/react";
|
|
5
|
+
import { beforeAll, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { registerBackofficeTranslations } from "../i18n";
|
|
7
|
+
import { ListPaging } from "./list-paging";
|
|
8
|
+
|
|
9
|
+
beforeAll(() => registerBackofficeTranslations());
|
|
10
|
+
|
|
11
|
+
function renderPaging(props: Partial<Parameters<typeof ListPaging>[0]> = {}) {
|
|
12
|
+
const onPaginationChange = vi.fn();
|
|
13
|
+
const onStepChange = vi.fn();
|
|
14
|
+
renderWithProviders(
|
|
15
|
+
<ListPaging
|
|
16
|
+
pagination={{ pageIndex: 0, pageSize: 20 }}
|
|
17
|
+
onPaginationChange={onPaginationChange}
|
|
18
|
+
step={20}
|
|
19
|
+
onStepChange={onStepChange}
|
|
20
|
+
shown={20}
|
|
21
|
+
total={151}
|
|
22
|
+
{...props}
|
|
23
|
+
/>,
|
|
24
|
+
);
|
|
25
|
+
return { onPaginationChange, onStepChange };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe("ListPaging", () => {
|
|
29
|
+
it("states how many rows are shown of the total", () => {
|
|
30
|
+
renderPaging();
|
|
31
|
+
expect(screen.getByTestId("backoffice-list-range").textContent).toBe("20 of 151");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("asks for one more page of the picked size on Load More", () => {
|
|
35
|
+
const { onPaginationChange } = renderPaging({
|
|
36
|
+
pagination: { pageIndex: 0, pageSize: 40 },
|
|
37
|
+
shown: 40,
|
|
38
|
+
});
|
|
39
|
+
fireEvent.click(screen.getByTestId("backoffice-list-load-more"));
|
|
40
|
+
expect(onPaginationChange).toHaveBeenCalledWith({ pageIndex: 0, pageSize: 60 });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("reloads at a new page size and makes it the Load More step", () => {
|
|
44
|
+
const { onPaginationChange, onStepChange } = renderPaging();
|
|
45
|
+
fireEvent.click(screen.getByText("100"));
|
|
46
|
+
expect(onStepChange).toHaveBeenCalledWith(100);
|
|
47
|
+
expect(onPaginationChange).toHaveBeenCalledWith({ pageIndex: 0, pageSize: 100 });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("drops Load More once every row is shown", () => {
|
|
51
|
+
renderPaging({ shown: 7, total: 7 });
|
|
52
|
+
expect(screen.queryByTestId("backoffice-list-load-more")).toBeNull();
|
|
53
|
+
expect(screen.getByTestId("backoffice-list-range").textContent).toBe("7 of 7");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desk's list paging (base_list.js `setup_paging_area`): the "20 of 151"
|
|
3
|
+
* readout, then the 20 / 100 / 500 page sizes and Load More. A page size
|
|
4
|
+
* reloads the list at that length; Load More asks for one more page of the
|
|
5
|
+
* same size on top of what is shown. It fills the table's pagination slot
|
|
6
|
+
* (the table's own range readout is off), so the table keeps its query state.
|
|
7
|
+
*/
|
|
8
|
+
import { Paragraph, XStack, YStack } from "@multiplatform.one/components";
|
|
9
|
+
import { Button, ToggleGroup } from "@multiplatform.one/forms";
|
|
10
|
+
import type { DataTablePaginationProps } from "@multiplatform.one/table";
|
|
11
|
+
import { useTranslation } from "react-i18next";
|
|
12
|
+
import { BACKOFFICE_I18N_NAMESPACE } from "../i18n";
|
|
13
|
+
|
|
14
|
+
export const LIST_PAGE_SIZES = [20, 100, 500] as const;
|
|
15
|
+
|
|
16
|
+
export interface ListPagingProps extends DataTablePaginationProps {
|
|
17
|
+
/** The page size Load More adds (the last size picked). */
|
|
18
|
+
step: number;
|
|
19
|
+
onStepChange: (step: number) => void;
|
|
20
|
+
/** Rows the list holds right now. */
|
|
21
|
+
shown: number;
|
|
22
|
+
/** Matching documents, when the table has no total of its own. */
|
|
23
|
+
total?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ListPaging({
|
|
27
|
+
pagination,
|
|
28
|
+
onPaginationChange,
|
|
29
|
+
step,
|
|
30
|
+
onStepChange,
|
|
31
|
+
shown,
|
|
32
|
+
total,
|
|
33
|
+
}: ListPagingProps) {
|
|
34
|
+
const { t } = useTranslation(BACKOFFICE_I18N_NAMESPACE);
|
|
35
|
+
const known = Math.max(pagination.totalCount ?? 0, total ?? 0) || undefined;
|
|
36
|
+
// A client-side list reports no row count back; the page it asked for
|
|
37
|
+
// is what it holds, capped by the total.
|
|
38
|
+
const held = shown > 0 ? shown : Math.min(pagination.pageSize, known ?? pagination.pageSize);
|
|
39
|
+
const more = known === undefined ? held >= pagination.pageSize : held < known;
|
|
40
|
+
return (
|
|
41
|
+
<YStack gap="$3" flexGrow={1} testID="backoffice-list-paging">
|
|
42
|
+
{known !== undefined ? (
|
|
43
|
+
<Paragraph color="$color11" margin="$0" testID="backoffice-list-range">
|
|
44
|
+
{t("list.rangeOf", {
|
|
45
|
+
shown: Math.min(held, known),
|
|
46
|
+
total: known,
|
|
47
|
+
defaultValue: "{{shown}} of {{total}}",
|
|
48
|
+
})}
|
|
49
|
+
</Paragraph>
|
|
50
|
+
) : null}
|
|
51
|
+
<XStack gap="$3" alignItems="center" flexWrap="wrap">
|
|
52
|
+
<ToggleGroup
|
|
53
|
+
aria-label={t("list.pageSize", "Page size")}
|
|
54
|
+
type="single"
|
|
55
|
+
value={String(step)}
|
|
56
|
+
options={LIST_PAGE_SIZES.map((size) => ({ label: String(size), value: String(size) }))}
|
|
57
|
+
onChange={(value) => {
|
|
58
|
+
const next = Number(Array.isArray(value) ? value[0] : value);
|
|
59
|
+
if (!next || next === step) return;
|
|
60
|
+
onStepChange(next);
|
|
61
|
+
onPaginationChange({ pageIndex: 0, pageSize: next });
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
{more ? (
|
|
65
|
+
<Button
|
|
66
|
+
outlined
|
|
67
|
+
testID="backoffice-list-load-more"
|
|
68
|
+
onPress={() =>
|
|
69
|
+
onPaginationChange({ pageIndex: 0, pageSize: pagination.pageSize + step })
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
{t("list.loadMore", "Load More")}
|
|
73
|
+
</Button>
|
|
74
|
+
) : null}
|
|
75
|
+
</XStack>
|
|
76
|
+
</YStack>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocFormScreen.d.ts","sourceRoot":"","sources":["../../src/form/DocFormScreen.tsx"],"names":[],"mappings":"AA8CA,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAmCtC,oDAAoD;AACpD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,sCAAsC;IACtC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wDAAwD;IACxD,eAAe,CAAC,EAAE,sBAAsB,CAAC;CAC1C;AAMD,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAe,GAChB,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"DocFormScreen.d.ts","sourceRoot":"","sources":["../../src/form/DocFormScreen.tsx"],"names":[],"mappings":"AA8CA,OAAO,EAML,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAmCtC,oDAAoD;AACpD,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACrC;AAED,MAAM,WAAW,kBAAkB;IACjC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,sCAAsC;IACtC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACpE,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wDAAwD;IACxD,eAAe,CAAC,EAAE,sBAAsB,CAAC;CAC1C;AAMD,wBAAgB,aAAa,CAAC,EAC5B,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,SAAS,EACT,eAAe,GAChB,EAAE,kBAAkB,2CAk7BpB"}
|
package/types/i18n/en.d.ts
CHANGED
|
@@ -493,9 +493,13 @@ export declare const en: {
|
|
|
493
493
|
readonly likedBy: "Liked By";
|
|
494
494
|
readonly likedColumn: "Liked";
|
|
495
495
|
readonly me: "Me";
|
|
496
|
+
readonly loadMore: "Load More";
|
|
496
497
|
readonly metaError: "Could not load {{doctype}}";
|
|
498
|
+
readonly more: "More actions";
|
|
497
499
|
readonly new: "New {{doctype}}";
|
|
498
500
|
readonly newShort: "New";
|
|
501
|
+
readonly pageSize: "Page size";
|
|
502
|
+
readonly rangeOf: "{{shown}} of {{total}}";
|
|
499
503
|
readonly noTags: "No Tags";
|
|
500
504
|
readonly notPermitted: "You can't open the {{doctype}} list";
|
|
501
505
|
readonly refresh: "Refresh";
|
package/types/i18n/en.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAotBL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoctypeListScreen.d.ts","sourceRoot":"","sources":["../../src/list/DoctypeListScreen.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DoctypeListScreen.d.ts","sourceRoot":"","sources":["../../src/list/DoctypeListScreen.tsx"],"names":[],"mappings":"AAmCA,OAAO,EAUL,KAAK,OAAO,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAOL,KAAK,gBAAgB,EACtB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAS1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAmC5D,MAAM,WAAW,sBAAsB;IACrC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC;;;OAGG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,8EAA8E;IAC9E,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,KAAK,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;IACtF,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gFAAgF;IAChF,cAAc,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAC9C;AAoBD,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,KAAK,EAAE,cAAc,EACrB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,GACf,EAAE,sBAAsB,2CAymCxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DataTablePaginationProps } from "@multiplatform.one/table";
|
|
2
|
+
export declare const LIST_PAGE_SIZES: readonly [20, 100, 500];
|
|
3
|
+
export interface ListPagingProps extends DataTablePaginationProps {
|
|
4
|
+
/** The page size Load More adds (the last size picked). */
|
|
5
|
+
step: number;
|
|
6
|
+
onStepChange: (step: number) => void;
|
|
7
|
+
/** Rows the list holds right now. */
|
|
8
|
+
shown: number;
|
|
9
|
+
/** Matching documents, when the table has no total of its own. */
|
|
10
|
+
total?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function ListPaging({ pagination, onPaginationChange, step, onStepChange, shown, total, }: ListPagingProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=list-paging.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-paging.d.ts","sourceRoot":"","sources":["../../src/list/list-paging.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAIzE,eAAO,MAAM,eAAe,yBAA0B,CAAC;AAEvD,MAAM,WAAW,eAAgB,SAAQ,wBAAwB;IAC/D,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,UAAU,CAAC,EACzB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,GACN,EAAE,eAAe,2CA6CjB"}
|