@multiplatform.one/backoffice 7.69.2 → 7.71.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/i18n/en.cjs +2 -0
- package/dist/cjs/i18n/en.native.js +2 -0
- package/dist/cjs/i18n/en.native.js.map +1 -1
- package/dist/cjs/list/DoctypeListScreen.cjs +64 -26
- package/dist/cjs/list/DoctypeListScreen.native.js +72 -28
- package/dist/cjs/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/cjs/list/filter-sort.cjs +54 -0
- package/dist/cjs/list/filter-sort.native.js +69 -0
- package/dist/cjs/list/filter-sort.native.js.map +1 -1
- package/dist/cjs/list/list-tools-sheet.cjs +1 -1
- package/dist/cjs/list/list-tools-sheet.native.js +1 -1
- package/dist/cjs/list/list-tools-sheet.native.js.map +1 -1
- package/dist/esm/i18n/en.mjs +2 -0
- package/dist/esm/i18n/en.mjs.map +1 -1
- package/dist/esm/i18n/en.native.js +2 -0
- package/dist/esm/i18n/en.native.js.map +1 -1
- package/dist/esm/list/DoctypeListScreen.mjs +66 -28
- package/dist/esm/list/DoctypeListScreen.mjs.map +1 -1
- package/dist/esm/list/DoctypeListScreen.native.js +74 -30
- package/dist/esm/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/esm/list/filter-sort.mjs +54 -2
- package/dist/esm/list/filter-sort.mjs.map +1 -1
- package/dist/esm/list/filter-sort.native.js +69 -2
- package/dist/esm/list/filter-sort.native.js.map +1 -1
- package/dist/esm/list/list-tools-sheet.mjs +1 -1
- package/dist/esm/list/list-tools-sheet.mjs.map +1 -1
- package/dist/esm/list/list-tools-sheet.native.js +1 -1
- package/dist/esm/list/list-tools-sheet.native.js.map +1 -1
- package/dist/jsx/i18n/en.mjs +2 -0
- package/dist/jsx/i18n/en.mjs.map +1 -1
- package/dist/jsx/i18n/en.native.js +2 -0
- package/dist/jsx/i18n/en.native.js.map +1 -1
- package/dist/jsx/list/DoctypeListScreen.mjs +66 -28
- package/dist/jsx/list/DoctypeListScreen.mjs.map +1 -1
- package/dist/jsx/list/DoctypeListScreen.native.js +72 -28
- package/dist/jsx/list/DoctypeListScreen.native.js.map +1 -1
- package/dist/jsx/list/filter-sort.mjs +54 -2
- package/dist/jsx/list/filter-sort.mjs.map +1 -1
- package/dist/jsx/list/filter-sort.native.js +69 -0
- package/dist/jsx/list/filter-sort.native.js.map +1 -1
- package/dist/jsx/list/list-tools-sheet.mjs +1 -1
- package/dist/jsx/list/list-tools-sheet.mjs.map +1 -1
- package/dist/jsx/list/list-tools-sheet.native.js +1 -1
- package/dist/jsx/list/list-tools-sheet.native.js.map +1 -1
- package/package.json +12 -12
- package/src/i18n/en.ts +2 -0
- package/src/list/DoctypeListScreen.compactHead.screen.spec.tsx +37 -12
- package/src/list/DoctypeListScreen.guest.screen.spec.tsx +5 -2
- package/src/list/DoctypeListScreen.tsx +88 -38
- package/src/list/filter-sort.tsx +71 -2
- package/src/list/list-tools-sheet.tsx +3 -1
- package/types/i18n/en.d.ts +2 -0
- package/types/i18n/en.d.ts.map +1 -1
- package/types/list/DoctypeListScreen.d.ts.map +1 -1
- package/types/list/filter-sort.d.ts +5 -0
- package/types/list/filter-sort.d.ts.map +1 -1
- package/types/list/list-tools-sheet.d.ts.map +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// FZ-7974 (LC-128 amendment): on a phone the desk list spends ONE row on its
|
|
2
|
-
// controls. Search takes the row with Filter
|
|
2
|
+
// controls. Search takes the row with Filter, Sort and "…" inside its
|
|
3
|
+
// trailing edge (FZ-8039), New
|
|
3
4
|
// is the shell top bar's trailing action, and the view switcher, the sort
|
|
4
5
|
// selector and the Filter button no longer stack rows of their own. Wide
|
|
5
6
|
// keeps the page-header toolbar. Measured against a live-shaped bench like
|
|
@@ -90,19 +91,27 @@ function renderList({
|
|
|
90
91
|
const newLabel = `New ${doctype}`;
|
|
91
92
|
|
|
92
93
|
describe("DoctypeListScreen compact head (FZ-7974)", () => {
|
|
93
|
-
it("puts search, Filter
|
|
94
|
+
it("puts search, Filter, Sort and More on one row and nothing else above the rows", async () => {
|
|
94
95
|
renderList();
|
|
95
96
|
await waitFor(() => expect(screen.getByText("tackle")).toBeTruthy(), settle);
|
|
96
97
|
const row = screen.getByTestId("backoffice-list-controls");
|
|
97
98
|
expect(within(row).getByLabelText(`Search ${doctype}`)).toBeTruthy();
|
|
98
99
|
expect(within(row).getByTestId("backoffice-list-tools")).toBeTruthy();
|
|
100
|
+
expect(within(row).getByTestId("backoffice-list-sort")).toBeTruthy();
|
|
99
101
|
expect(within(row).getByTestId("backoffice-list-more")).toBeTruthy();
|
|
102
|
+
// FZ-8039: the glyphs sit inside the search field, as DataTable's do.
|
|
103
|
+
const field = row.querySelector("[data-search-trailing]")!;
|
|
104
|
+
for (const id of ["backoffice-list-tools", "backoffice-list-sort", "backoffice-list-more"]) {
|
|
105
|
+
expect(field.contains(screen.getByTestId(id))).toBe(true);
|
|
106
|
+
}
|
|
100
107
|
// The rows the head used to stack: the view switcher, the Filter text
|
|
101
108
|
// button and the sort selector.
|
|
102
109
|
expect(screen.queryByTestId("list-view-switcher")).toBeNull();
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
const wordedFilter = screen
|
|
111
|
+
.queryAllByText("Filter")
|
|
112
|
+
.filter((node) => node.closest('button, [role="button"]'));
|
|
113
|
+
expect(wordedFilter).toHaveLength(0);
|
|
114
|
+
// Sort is a glyph: no worded sort selector anywhere above the rows.
|
|
106
115
|
const sortLabels = screen
|
|
107
116
|
.queryAllByText("Last Updated On")
|
|
108
117
|
.filter(
|
|
@@ -174,26 +183,42 @@ describe("DoctypeListScreen compact head (FZ-7974)", () => {
|
|
|
174
183
|
expect(items).toContain("Open in Desk");
|
|
175
184
|
});
|
|
176
185
|
|
|
177
|
-
it("opens Filter
|
|
186
|
+
it("opens Filter from its glyph and counts the applied filters in its label", async () => {
|
|
178
187
|
renderList({ filtersParam: JSON.stringify([["kind", "=", "Physical"]]) });
|
|
179
188
|
await waitFor(() => expect(screen.getByText("tackle")).toBeTruthy(), settle);
|
|
180
189
|
const tools = screen.getByTestId("backoffice-list-tools");
|
|
181
|
-
expect(tools.getAttribute("aria-label")).toBe("Filter
|
|
182
|
-
expect(tools.textContent?.trim()).toBe("
|
|
190
|
+
expect(tools.getAttribute("aria-label")).toBe("Filter (1)");
|
|
191
|
+
expect(tools.textContent?.trim()).toBe("");
|
|
183
192
|
fireEvent.click(tools);
|
|
184
|
-
await waitFor(() => expect(screen.getByText("
|
|
185
|
-
expect(screen.getByText("Filters")).toBeTruthy();
|
|
193
|
+
await waitFor(() => expect(screen.getByText("Filters")).toBeTruthy(), settle);
|
|
186
194
|
expect(screen.getByText("Saved Filters")).toBeTruthy();
|
|
187
195
|
});
|
|
188
196
|
|
|
189
|
-
it("labels the
|
|
197
|
+
it("labels the Filter glyph without a count when no filter applies", async () => {
|
|
190
198
|
renderList();
|
|
191
199
|
await waitFor(() => expect(screen.getByText("tackle")).toBeTruthy(), settle);
|
|
192
200
|
const tools = screen.getByTestId("backoffice-list-tools");
|
|
193
|
-
expect(tools.getAttribute("aria-label")).toBe("Filter
|
|
201
|
+
expect(tools.getAttribute("aria-label")).toBe("Filter");
|
|
194
202
|
expect(tools.textContent?.trim()).toBe("");
|
|
195
203
|
});
|
|
196
204
|
|
|
205
|
+
it("sorts from the Sort glyph's menu: fields checked, then the order (FZ-8039)", async () => {
|
|
206
|
+
renderList();
|
|
207
|
+
await waitFor(() => expect(screen.getByText("tackle")).toBeTruthy(), settle);
|
|
208
|
+
const sort = screen.getByTestId("backoffice-list-sort");
|
|
209
|
+
expect(sort.getAttribute("aria-label")).toBe("Sort");
|
|
210
|
+
expect(sort.textContent?.trim()).toBe("");
|
|
211
|
+
fireEvent.click(sort);
|
|
212
|
+
await waitFor(() => expect(screen.getByRole("menu")).toBeTruthy(), settle);
|
|
213
|
+
const checks = Array.from(document.querySelectorAll('[role="menuitemcheckbox"]'));
|
|
214
|
+
const labels = checks.map((node) => node.textContent?.trim());
|
|
215
|
+
expect(labels).toContain("Last Updated On");
|
|
216
|
+
expect(labels).toContain("Ascending");
|
|
217
|
+
expect(labels).toContain("Descending");
|
|
218
|
+
const updated = checks.find((node) => node.textContent?.trim() === "Last Updated On")!;
|
|
219
|
+
expect(updated.getAttribute("aria-checked")).toBe("true");
|
|
220
|
+
});
|
|
221
|
+
|
|
197
222
|
it("keeps today's page-header toolbar at regular width", async () => {
|
|
198
223
|
layout.size = "wide";
|
|
199
224
|
renderList();
|
|
@@ -164,7 +164,7 @@ describe("DoctypeListScreen with DocType meta refused (LC-96)", () => {
|
|
|
164
164
|
async (size) => {
|
|
165
165
|
layout.size = size;
|
|
166
166
|
renderList();
|
|
167
|
-
await waitFor(() => expect(screen.getByText("
|
|
167
|
+
await waitFor(() => expect(screen.getByText("Seed monster")).toBeTruthy(), settle);
|
|
168
168
|
const region = screen.getByTestId("backoffice-list-scroll");
|
|
169
169
|
expect(["auto", "scroll"]).toContain(getComputedStyle(region).overflowY);
|
|
170
170
|
expect(getComputedStyle(region).minHeight).toBe("0px");
|
|
@@ -189,7 +189,10 @@ describe("DoctypeListScreen with DocType meta refused (LC-96)", () => {
|
|
|
189
189
|
it("keeps compact rows in a bounded document list", async () => {
|
|
190
190
|
layout.size = "compact";
|
|
191
191
|
renderList();
|
|
192
|
-
|
|
192
|
+
// LC-261: the record's name is the row title and its first text field
|
|
193
|
+
// the one subtitle; a second text field stays off the phone row.
|
|
194
|
+
await waitFor(() => expect(screen.getByText("bulbasaur")).toBeTruthy(), settle);
|
|
195
|
+
expect(screen.getByText("Seed monster")).toBeTruthy();
|
|
193
196
|
expect(screen.queryAllByRole("columnheader")).toEqual([]);
|
|
194
197
|
expect(screen.queryByText("/files/bulbasaur.png")).toBeNull();
|
|
195
198
|
expect(screen.queryByText("overgrow")).toBeNull();
|
|
@@ -25,8 +25,10 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
PageGutter,
|
|
27
27
|
Surface,
|
|
28
|
+
sizeRecipeForToken,
|
|
28
29
|
useLayoutSizeClass,
|
|
29
30
|
useResolvedKnobs,
|
|
31
|
+
useTouchSurface,
|
|
30
32
|
} from "@multiplatform.one/theme";
|
|
31
33
|
// Catalog action Button — `accent` renders the active accent intent, the
|
|
32
34
|
// house expression of the one page primary (LC-05 ONE-EMPHASIS; quick entry
|
|
@@ -35,6 +37,8 @@ import { Button as ActionButton, SearchInput } from "@multiplatform.one/forms";
|
|
|
35
37
|
import {
|
|
36
38
|
ArrowSquareOutIcon,
|
|
37
39
|
ArrowsClockwiseIcon,
|
|
40
|
+
CheckCircleIcon,
|
|
41
|
+
CheckIcon,
|
|
38
42
|
DotsThreeIcon,
|
|
39
43
|
FunnelIcon,
|
|
40
44
|
PlusIcon,
|
|
@@ -59,6 +63,7 @@ import type {
|
|
|
59
63
|
FilterableField,
|
|
60
64
|
TableFilter,
|
|
61
65
|
} from "@multiplatform.one/table";
|
|
66
|
+
import { ToolbarGlyphFieldHeight, useToolbarGlyphProps } from "@multiplatform.one/table";
|
|
62
67
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
63
68
|
import { useTranslation } from "react-i18next";
|
|
64
69
|
import {
|
|
@@ -102,6 +107,7 @@ import {
|
|
|
102
107
|
import { toggleFacetFilter } from "./sidebar-stats";
|
|
103
108
|
import { ListFilterBar } from "./ListFilterBar";
|
|
104
109
|
import { ListToolsButton } from "./list-tools-sheet";
|
|
110
|
+
import { SortMenu, sortOrderIcon } from "./filter-sort";
|
|
105
111
|
import { LIST_PAGE_SIZE, ListPaging } from "./list-paging";
|
|
106
112
|
import { ListSidebar } from "./ListSidebar";
|
|
107
113
|
import { useShellSidebarPanel } from "../shell/shellSidebarSlot";
|
|
@@ -181,6 +187,11 @@ type PendingDialog = {
|
|
|
181
187
|
// annotation transform; instantiate the type argument outside JSX instead.
|
|
182
188
|
const ListTable = FrappeTable<ListDoc>;
|
|
183
189
|
|
|
190
|
+
function SearchGlyph(props: React.ComponentProps<typeof ActionButton>) {
|
|
191
|
+
const glyph = useToolbarGlyphProps();
|
|
192
|
+
return <ActionButton {...glyph} {...props} />;
|
|
193
|
+
}
|
|
194
|
+
|
|
184
195
|
function sameFilters(a: FrappeFilters, b: FrappeFilters): boolean {
|
|
185
196
|
return a.length === b.length && a.every((tuple, index) => sameFilterTuple(tuple, b[index]));
|
|
186
197
|
}
|
|
@@ -220,8 +231,15 @@ export function DoctypeListScreen({
|
|
|
220
231
|
const sessionUser = useSessionUser();
|
|
221
232
|
// Compact list chrome below 640 (theme `compact` size class — matchMedia
|
|
222
233
|
// on web, window dimensions on native; BackofficeShell drawer precedent):
|
|
223
|
-
// one control row (search
|
|
234
|
+
// one control row (search holding Filter, Sort and "…"), New in the top bar.
|
|
224
235
|
const compactChrome = useLayoutSizeClass() === "compact";
|
|
236
|
+
const searchFieldHeight = sizeRecipeForToken(String(knobProps.sizeToken), {
|
|
237
|
+
touch: useTouchSurface(),
|
|
238
|
+
}).height;
|
|
239
|
+
// Phone select mode (LC-155): the "…" menu's Select shows every row's
|
|
240
|
+
// round mark, as in Files; a long press on a row enters it too.
|
|
241
|
+
const [selecting, setSelecting] = useState(false);
|
|
242
|
+
useEffect(() => setSelecting(false), [doctype]);
|
|
225
243
|
|
|
226
244
|
// Write-on-visit for the shared recents store (workspace "Continue where
|
|
227
245
|
// you left off" strip). Fixture mode (stories/tests) stays storage-free.
|
|
@@ -1055,14 +1073,31 @@ export function DoctypeListScreen({
|
|
|
1055
1073
|
|
|
1056
1074
|
// Phone chrome: ONE control row (FZ-7974, LC-128 amendment). The banner
|
|
1057
1075
|
// names the doctype and carries New as its trailing action; search takes
|
|
1058
|
-
// the row
|
|
1059
|
-
//
|
|
1076
|
+
// the row with Filter and Sort at its trailing edge, and Select, views,
|
|
1077
|
+
// refresh and Open in Desk ride the "…" menu. Pills
|
|
1060
1078
|
// follow only when a filter applies; the result count rides the list's
|
|
1061
1079
|
// own tail.
|
|
1062
1080
|
const filterCount = Array.isArray(baseFilters) ? baseFilters.length : 0;
|
|
1063
1081
|
const compactMoreEntries: DropdownMenuEntry[] = [
|
|
1064
1082
|
...viewEntries,
|
|
1065
1083
|
...(viewEntries.length > 0 ? [{ separator: true as const }] : []),
|
|
1084
|
+
...(bulkActionsEnabled
|
|
1085
|
+
? [
|
|
1086
|
+
selecting
|
|
1087
|
+
? {
|
|
1088
|
+
key: "select-done",
|
|
1089
|
+
label: t("list.selectDone", "Done"),
|
|
1090
|
+
icon: <CheckIcon />,
|
|
1091
|
+
onSelect: () => setSelecting(false),
|
|
1092
|
+
}
|
|
1093
|
+
: {
|
|
1094
|
+
key: "select",
|
|
1095
|
+
label: t("list.select", "Select"),
|
|
1096
|
+
icon: <CheckCircleIcon />,
|
|
1097
|
+
onSelect: () => setSelecting(true),
|
|
1098
|
+
},
|
|
1099
|
+
]
|
|
1100
|
+
: []),
|
|
1066
1101
|
{
|
|
1067
1102
|
key: "refresh",
|
|
1068
1103
|
label: t("list.refresh", "Refresh"),
|
|
@@ -1091,6 +1126,8 @@ export function DoctypeListScreen({
|
|
|
1091
1126
|
defaultValue=""
|
|
1092
1127
|
onSearch={setSearchText}
|
|
1093
1128
|
clearable
|
|
1129
|
+
filled
|
|
1130
|
+
size={knobProps.sizeToken}
|
|
1094
1131
|
placeholder={t("list.searchPlaceholder", {
|
|
1095
1132
|
defaultValue: "Search {{doctype}}",
|
|
1096
1133
|
doctype,
|
|
@@ -1099,43 +1136,55 @@ export function DoctypeListScreen({
|
|
|
1099
1136
|
defaultValue: "Search {{doctype}}",
|
|
1100
1137
|
doctype,
|
|
1101
1138
|
})}
|
|
1139
|
+
trailing={
|
|
1140
|
+
<ToolbarGlyphFieldHeight.Provider value={searchFieldHeight}>
|
|
1141
|
+
{!metaRefused && (
|
|
1142
|
+
<ListToolsButton
|
|
1143
|
+
doctype={doctype}
|
|
1144
|
+
meta={meta}
|
|
1145
|
+
filters={baseFilters}
|
|
1146
|
+
onFiltersChange={handleBaseFiltersChange}
|
|
1147
|
+
renderTrigger={(open) => (
|
|
1148
|
+
<SearchGlyph
|
|
1149
|
+
icon={filterCount ? <FunnelIcon weight="fill" /> : FunnelIcon}
|
|
1150
|
+
onPress={open}
|
|
1151
|
+
aria-label={
|
|
1152
|
+
filterCount
|
|
1153
|
+
? t("list.filters.filterCount", "Filter ({{count}})", {
|
|
1154
|
+
count: filterCount,
|
|
1155
|
+
})
|
|
1156
|
+
: t("list.filters.filter", "Filter")
|
|
1157
|
+
}
|
|
1158
|
+
testID="backoffice-list-tools"
|
|
1159
|
+
/>
|
|
1160
|
+
)}
|
|
1161
|
+
/>
|
|
1162
|
+
)}
|
|
1163
|
+
{!metaRefused && (
|
|
1164
|
+
<SortMenu
|
|
1165
|
+
meta={meta}
|
|
1166
|
+
sortField={sortField}
|
|
1167
|
+
sortOrder={sortOrder}
|
|
1168
|
+
onSortChange={handleSortChange}
|
|
1169
|
+
>
|
|
1170
|
+
<SearchGlyph
|
|
1171
|
+
icon={sortOrderIcon(meta, sortOrder)}
|
|
1172
|
+
aria-label={t("list.sortBy", "Sort")}
|
|
1173
|
+
testID="backoffice-list-sort"
|
|
1174
|
+
/>
|
|
1175
|
+
</SortMenu>
|
|
1176
|
+
)}
|
|
1177
|
+
<DropdownMenu items={compactMoreEntries} placement="bottom-end">
|
|
1178
|
+
<SearchGlyph
|
|
1179
|
+
icon={DotsThreeIcon}
|
|
1180
|
+
aria-label={t("list.more", "More actions")}
|
|
1181
|
+
testID="backoffice-list-more"
|
|
1182
|
+
/>
|
|
1183
|
+
</DropdownMenu>
|
|
1184
|
+
</ToolbarGlyphFieldHeight.Provider>
|
|
1185
|
+
}
|
|
1102
1186
|
/>
|
|
1103
1187
|
</YStack>
|
|
1104
|
-
{!metaRefused && (
|
|
1105
|
-
<ListToolsButton
|
|
1106
|
-
doctype={doctype}
|
|
1107
|
-
meta={meta}
|
|
1108
|
-
filters={baseFilters}
|
|
1109
|
-
onFiltersChange={handleBaseFiltersChange}
|
|
1110
|
-
sortField={sortField}
|
|
1111
|
-
sortOrder={sortOrder}
|
|
1112
|
-
onSortChange={handleSortChange}
|
|
1113
|
-
renderTrigger={(open) => (
|
|
1114
|
-
<ActionButton
|
|
1115
|
-
icon={FunnelIcon}
|
|
1116
|
-
onPress={open}
|
|
1117
|
-
aria-label={
|
|
1118
|
-
filterCount
|
|
1119
|
-
? t("list.tools.titleCount", {
|
|
1120
|
-
count: filterCount,
|
|
1121
|
-
defaultValue: "Filter & sort ({{count}})",
|
|
1122
|
-
})
|
|
1123
|
-
: t("list.tools.title", "Filter & sort")
|
|
1124
|
-
}
|
|
1125
|
-
testID="backoffice-list-tools"
|
|
1126
|
-
>
|
|
1127
|
-
{filterCount ? String(filterCount) : undefined}
|
|
1128
|
-
</ActionButton>
|
|
1129
|
-
)}
|
|
1130
|
-
/>
|
|
1131
|
-
)}
|
|
1132
|
-
<DropdownMenu items={compactMoreEntries} placement="bottom-end">
|
|
1133
|
-
<ActionButton
|
|
1134
|
-
icon={DotsThreeIcon}
|
|
1135
|
-
aria-label={t("list.more", "More actions")}
|
|
1136
|
-
testID="backoffice-list-more"
|
|
1137
|
-
/>
|
|
1138
|
-
</DropdownMenu>
|
|
1139
1188
|
{showNew && !shellTookNew ? compactNewButton : null}
|
|
1140
1189
|
</XStack>
|
|
1141
1190
|
</Surface>
|
|
@@ -1279,6 +1328,7 @@ export function DoctypeListScreen({
|
|
|
1279
1328
|
enableGlobalSearch={false}
|
|
1280
1329
|
enableSorting
|
|
1281
1330
|
enableRowSelection={bulkActionsEnabled}
|
|
1331
|
+
selectMode={compactChrome && selecting}
|
|
1282
1332
|
{...(bulkActionsEnabled ? { bulkActions } : {})}
|
|
1283
1333
|
onRowClick={handleRowClick}
|
|
1284
1334
|
onStateChange={handleStateChange}
|
package/src/list/filter-sort.tsx
CHANGED
|
@@ -14,8 +14,14 @@ import {
|
|
|
14
14
|
// house 44px press floor (LC-54 origin failure mode) — sort chrome takes the
|
|
15
15
|
// forms Button so the floor and the icon slot (LC-53) apply.
|
|
16
16
|
import { Button, Select } from "@multiplatform.one/forms";
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import {
|
|
18
|
+
ArrowDownIcon,
|
|
19
|
+
ArrowUpIcon,
|
|
20
|
+
CaretDownIcon,
|
|
21
|
+
SortAscendingIcon,
|
|
22
|
+
SortDescendingIcon,
|
|
23
|
+
} from "@phosphor-icons/react";
|
|
24
|
+
import { useMemo, type ReactElement } from "react";
|
|
19
25
|
import { useTranslation } from "react-i18next";
|
|
20
26
|
import { BACKOFFICE_I18N_NAMESPACE } from "../i18n";
|
|
21
27
|
import type { DoctypeMeta } from "../shared/useDoctypeMeta";
|
|
@@ -230,3 +236,66 @@ export function SortControl({
|
|
|
230
236
|
</XStack>
|
|
231
237
|
);
|
|
232
238
|
}
|
|
239
|
+
|
|
240
|
+
export function SortMenu({
|
|
241
|
+
meta,
|
|
242
|
+
sortField,
|
|
243
|
+
sortOrder,
|
|
244
|
+
onSortChange,
|
|
245
|
+
children,
|
|
246
|
+
}: Omit<SortControlProps, "inline"> & { children: ReactElement }) {
|
|
247
|
+
const { t } = useTranslation(BACKOFFICE_I18N_NAMESPACE);
|
|
248
|
+
const options = useMemo(
|
|
249
|
+
() =>
|
|
250
|
+
sortableFieldsFromMeta(meta).map((option) => ({
|
|
251
|
+
...option,
|
|
252
|
+
label: sortFieldLabel(meta, option.fieldname, t),
|
|
253
|
+
})),
|
|
254
|
+
[meta, t],
|
|
255
|
+
);
|
|
256
|
+
const field = sortField ?? metaDefaultSortField(meta);
|
|
257
|
+
const order = sortOrder ?? metaDefaultSortOrder(meta);
|
|
258
|
+
if (!onSortChange) return null;
|
|
259
|
+
const displayOptions = options.some((option) => option.fieldname === field)
|
|
260
|
+
? options
|
|
261
|
+
: [{ fieldname: field, label: sortFieldLabel(meta, field, t) }, ...options];
|
|
262
|
+
const items: DropdownMenuEntry[] = [
|
|
263
|
+
...displayOptions.map((option) => ({
|
|
264
|
+
key: option.fieldname,
|
|
265
|
+
label: option.label,
|
|
266
|
+
checked: option.fieldname === field,
|
|
267
|
+
onSelect: () => onSortChange(option.fieldname, order),
|
|
268
|
+
})),
|
|
269
|
+
{ separator: true as const },
|
|
270
|
+
{
|
|
271
|
+
key: "order-asc",
|
|
272
|
+
label: t("list.sort.ascending", "Ascending"),
|
|
273
|
+
icon: <ArrowUpIcon />,
|
|
274
|
+
checked: order === "asc",
|
|
275
|
+
onSelect: () => onSortChange(field, "asc"),
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
key: "order-desc",
|
|
279
|
+
label: t("list.sort.descending", "Descending"),
|
|
280
|
+
icon: <ArrowDownIcon />,
|
|
281
|
+
checked: order === "desc",
|
|
282
|
+
onSelect: () => onSortChange(field, "desc"),
|
|
283
|
+
},
|
|
284
|
+
];
|
|
285
|
+
return (
|
|
286
|
+
<DropdownMenu
|
|
287
|
+
items={items}
|
|
288
|
+
closeOnSelect
|
|
289
|
+
placement="bottom-end"
|
|
290
|
+
maxHeight={overlayListMaxHeight}
|
|
291
|
+
>
|
|
292
|
+
{children}
|
|
293
|
+
</DropdownMenu>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function sortOrderIcon(meta: DoctypeMeta | undefined, sortOrder?: "asc" | "desc") {
|
|
298
|
+
return (sortOrder ?? metaDefaultSortOrder(meta)) === "asc"
|
|
299
|
+
? SortAscendingIcon
|
|
300
|
+
: SortDescendingIcon;
|
|
301
|
+
}
|
|
@@ -112,7 +112,9 @@ export function ListToolsButton({
|
|
|
112
112
|
scrollable
|
|
113
113
|
header={
|
|
114
114
|
<SizableText {...knobProps.heading} size="$6">
|
|
115
|
-
{
|
|
115
|
+
{onSortChange
|
|
116
|
+
? t("list.tools.title", "Filter & sort")
|
|
117
|
+
: t("list.filters.filter", "Filter")}
|
|
116
118
|
</SizableText>
|
|
117
119
|
}
|
|
118
120
|
>
|
package/types/i18n/en.d.ts
CHANGED
|
@@ -505,6 +505,8 @@ export declare const en: {
|
|
|
505
505
|
readonly refresh: "Refresh";
|
|
506
506
|
readonly resultCount_one: "{{count}} result";
|
|
507
507
|
readonly resultCount_other: "{{count}} results";
|
|
508
|
+
readonly select: "Select";
|
|
509
|
+
readonly selectDone: "Done";
|
|
508
510
|
readonly selectedCount: "{{count}} selected";
|
|
509
511
|
readonly showSidebar: "Show sidebar";
|
|
510
512
|
readonly sidebarLabel: "List filters sidebar";
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAutBL,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":"AA8CA,OAAO,EAUL,KAAK,OAAO,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,0BAA0B,CAAC;AAIlC,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;AAoC5D,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;AAyBD,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,2CAirCxB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
1
2
|
import type { DoctypeMeta } from "../shared/useDoctypeMeta";
|
|
2
3
|
export interface SortControlProps {
|
|
3
4
|
meta?: DoctypeMeta;
|
|
@@ -28,5 +29,9 @@ type Translate = (key: string, fallback: string) => string;
|
|
|
28
29
|
*/
|
|
29
30
|
export declare function sortFieldLabel(meta: DoctypeMeta | undefined, fieldname: string, t: Translate): string;
|
|
30
31
|
export declare function SortControl({ meta, sortField, sortOrder, onSortChange, inline, }: SortControlProps): import("react/jsx-runtime").JSX.Element | null;
|
|
32
|
+
export declare function SortMenu({ meta, sortField, sortOrder, onSortChange, children, }: Omit<SortControlProps, "inline"> & {
|
|
33
|
+
children: ReactElement;
|
|
34
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
35
|
+
export declare function sortOrderIcon(meta: DoctypeMeta | undefined, sortOrder?: "asc" | "desc"): import("@phosphor-icons/react").Icon;
|
|
31
36
|
export {};
|
|
32
37
|
//# sourceMappingURL=filter-sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-sort.d.ts","sourceRoot":"","sources":["../../src/list/filter-sort.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter-sort.d.ts","sourceRoot":"","sources":["../../src/list/filter-sort.tsx"],"names":[],"mappings":"AAuBA,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAGnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAC9D;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAoBD,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,EAAE,CAcvE;AAQD,KAAK,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,EACjB,CAAC,EAAE,SAAS,GACX,MAAM,CAuBR;AAMD,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,GACP,EAAE,gBAAgB,kDAoGlB;AAED,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG;IAAE,QAAQ,EAAE,YAAY,CAAA;CAAE,kDAiD/D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,wCAItF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-tools-sheet.d.ts","sourceRoot":"","sources":["../../src/list/list-tools-sheet.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAY5D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAC9D,uEAAuE;IACvE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;CACjD;AAUD,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,OAAO,EACP,eAAe,EACf,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"list-tools-sheet.d.ts","sourceRoot":"","sources":["../../src/list/list-tools-sheet.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAY5D,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,KAAK,IAAI,CAAC;IAC9D,uEAAuE;IACvE,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,SAAS,CAAC;CACjD;AAUD,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,OAAO,EACP,eAAe,EACf,SAAS,EACT,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,EAAE,oBAAoB,2CAgHtB"}
|