@marktiderman/genesis-ui-native 3.12.1 → 3.14.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/{chunk-TUDJDIGC.js → chunk-DCCOZSGR.js} +4 -2
- package/dist/chunk-DCCOZSGR.js.map +1 -0
- package/dist/{chunk-47CDRP43.js → chunk-G5M2Q7OU.js} +77 -4
- package/dist/chunk-G5M2Q7OU.js.map +1 -0
- package/dist/{chunk-C2ARUGT7.js → chunk-SRCGQWE4.js} +3 -3
- package/dist/{chunk-C2ARUGT7.js.map → chunk-SRCGQWE4.js.map} +1 -1
- package/dist/{chunk-X5CPLUPZ.js → chunk-WTO3LIUS.js} +4 -77
- package/dist/chunk-WTO3LIUS.js.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/data/index.d.ts +170 -27
- package/dist/data/index.js +493 -24
- package/dist/data/index.js.map +1 -1
- package/dist/{inbox-page-BGqR_cBs.d.ts → inbox-page-DD1cQdF4.d.ts} +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/layouts/index.d.ts +2 -2
- package/dist/layouts/index.js +2 -2
- package/package.json +3 -3
- package/src/data/NativeRecordPeek.tsx +12 -1
- package/src/data/__tests__/parity-data.test.tsx +26 -0
- package/src/data/resource-view/NativeRecordView.tsx +15 -2
- package/src/data/resource-view/NativeResourceView.tsx +153 -16
- package/src/data/resource-view/__tests__/native-record-view.test.tsx +24 -0
- package/src/data/resource-view/__tests__/native-resource-inbox.test.tsx +59 -0
- package/src/data/resource-view/__tests__/native-resource-lists.test.tsx +281 -0
- package/src/data/resource-view/index.ts +12 -1
- package/src/data/resource-view/list-controls.tsx +508 -0
- package/src/data/resource-view/mapping.ts +10 -0
- package/src/data/resource-view/messages.ts +70 -0
- package/src/data/resource-view/use-native-resource-view.ts +13 -3
- package/src/layouts/__tests__/inbox-page-start.test.tsx +39 -0
- package/src/layouts/inbox-page.tsx +7 -0
- package/dist/chunk-47CDRP43.js.map +0 -1
- package/dist/chunk-TUDJDIGC.js.map +0 -1
- package/dist/chunk-X5CPLUPZ.js.map +0 -1
package/dist/data/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { NativeAvatar, NativeCard, NativeCardContent, NativeSeparator, NativeLabel, NativeProgress, NativeSwitch, NativeCheckbox, NativeSelect, NativeSelectTrigger, NativeSelectContent, NativeSelectItem, NativeTextarea, NativeAlert, NativeAlertTitle, NativeAlertDescription, NativeSegmentedControl, NativeDatePicker, NativeTimePicker, NativeSearchBar, NativeGalleryGrid, NativeCardHeader, NativeCardTitle } from '../chunk-
|
|
2
|
-
import { showInboxActions, NavBarSaveButton, composeHeaderOptions } from '../chunk-
|
|
3
|
-
import { NativeListItem, NativeBadge, NativeText, NativeImage, NativeButton, NativeInput, NativeSheet, NativeSheetScrollView, NativeLoadingState, NativeInlineAlert,
|
|
1
|
+
import { NativeAvatar, NativeCard, NativeCardContent, NativeSeparator, NativeLabel, NativeProgress, NativeSwitch, NativeCheckbox, NativeSelect, NativeSelectTrigger, NativeSelectContent, NativeSelectItem, NativeTextarea, NativeAlert, NativeAlertTitle, NativeAlertDescription, NativeSegmentedControl, NativeDatePicker, NativeTimePicker, NativeChipGroup, NativeChip, NativeSearchBar, NativeGalleryGrid, NativeCardHeader, NativeCardTitle } from '../chunk-G5M2Q7OU.js';
|
|
2
|
+
import { showInboxActions, NavBarSaveButton, InboxPage, composeHeaderOptions } from '../chunk-DCCOZSGR.js';
|
|
3
|
+
import { NativeListItem, NativeBadge, NativeText, NativeImage, NativeButton, NativeInput, NativeSheet, NativeSheetScrollView, NativeLoadingState, NativeInlineAlert, NativeEmptyState, NativeSectionListHeader, NativeRefreshControl, NativeIcon, NativeSkeleton } from '../chunk-D4UU6KIF.js';
|
|
4
4
|
import { useGenesisModules, useThemeRoles, useReducedMotion } from '../chunk-VHUUOH46.js';
|
|
5
5
|
import '../chunk-OHZD7KRO.js';
|
|
6
6
|
import '../chunk-DGUM43GV.js';
|
|
7
|
-
import { Platform, View, Pressable, Text, Linking, ScrollView, AccessibilityInfo,
|
|
7
|
+
import { Platform, View, Pressable, Text, Linking, ScrollView, AccessibilityInfo, SectionList, Alert, ActionSheetIOS, FlatList } from 'react-native';
|
|
8
8
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
import { createContext, memo, useState, useCallback, useContext, useMemo, useRef, useEffect, useLayoutEffect } from 'react';
|
|
11
11
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
12
|
-
import { encodeRecordKey, titleCase, useResourceForm,
|
|
12
|
+
import { encodeRecordKey, titleCase, useResourceForm, useDataProvider, useViewer as useViewer$1, resourceKeys, useCapabilities as useCapabilities$1, useResource as useResource$1, writeConflict, isDataWriteError, NO_ROWS_MATCHED, DataWriteError } from '@marktiderman/genesis-core';
|
|
13
13
|
import { useFieldArray, useWatch, Controller, useForm } from 'react-hook-form';
|
|
14
|
-
import { useRelationLabel, useViewer, buildArrayItemDefaults, useWizard, useResource, useInfiniteResource, useCapabilities, useOptionalViewerScope, scopeClock, useOne, useLinkOptions } from '@marktiderman/genesis-core/hooks';
|
|
14
|
+
import { useRelationLabel, useViewer, buildArrayItemDefaults, useWizard, useResource, useSegmentCounts, useViewBoard, useViewCalendarRange, useInfiniteResource, useCapabilities, useOptionalViewerScope, scopeClock, useListState, useOne, useLinkOptions } from '@marktiderman/genesis-core/hooks';
|
|
15
15
|
import { fieldArrayLimits, fieldArrayAddLabel, fieldAccept, formatFileSize, wizardStepFields, wizardProgressLabel, customViewStatus, fileProblem } from '@marktiderman/genesis-core/headless';
|
|
16
|
-
import { personTimeZone, isTimeZone, wallClock } from '@marktiderman/genesis-core/dates';
|
|
16
|
+
import { personTimeZone, isTimeZone, wallClock, dayIn } from '@marktiderman/genesis-core/dates';
|
|
17
17
|
import { isSafeUrl } from '@marktiderman/genesis-core/urls';
|
|
18
|
-
import { valueText, sameFormValue, groupRows, rowPicture, filterParams as filterParams$1 } from '@marktiderman/genesis-core/resource-view';
|
|
18
|
+
import { valueText, displayZone, calendarWindow, calendarEvents, placeEvents, sameFormValue, groupRows, shiftAnchor, rowPicture, filterParams as filterParams$1 } from '@marktiderman/genesis-core/resource-view';
|
|
19
19
|
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
20
20
|
import { readinessChip } from '@marktiderman/genesis-core/resource';
|
|
21
21
|
|
|
@@ -234,6 +234,32 @@ function NativeDetailPanel({
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// src/data/resource-view/messages.ts
|
|
237
|
+
var defaultNativeListMessages = {
|
|
238
|
+
segments: "Segments",
|
|
239
|
+
filters: "Filters",
|
|
240
|
+
filtersSet: "Filters ({count})",
|
|
241
|
+
clear: "Clear",
|
|
242
|
+
done: "Done",
|
|
243
|
+
from: "From",
|
|
244
|
+
to: "To",
|
|
245
|
+
types: { list: "List", table: "List", grid: "Grid", gallery: "Gallery", inbox: "Inbox", board: "Board", calendar: "Calendar" },
|
|
246
|
+
type: "View",
|
|
247
|
+
noValue: "No value",
|
|
248
|
+
notAllowed: "You can't move this card.",
|
|
249
|
+
stillSaving: "{name} is still moving. Try again in a moment.",
|
|
250
|
+
notChanged: "This {noun} was not changed.",
|
|
251
|
+
moveFailed: "Couldn\u2019t move {name}.",
|
|
252
|
+
moveTo: "Move to {column}",
|
|
253
|
+
loadMore: "Load more",
|
|
254
|
+
today: "Today",
|
|
255
|
+
previous: "Previous",
|
|
256
|
+
next: "Next",
|
|
257
|
+
agenda: "Agenda",
|
|
258
|
+
month: "Month",
|
|
259
|
+
noEvents: "Nothing on this day",
|
|
260
|
+
allDay: "All day",
|
|
261
|
+
more: "{count} more not shown"
|
|
262
|
+
};
|
|
237
263
|
var defaultNativeResourceViewMessages = {
|
|
238
264
|
common: {
|
|
239
265
|
empty: "\u2014",
|
|
@@ -1525,6 +1551,11 @@ function swipeActionsFor(view, row, options) {
|
|
|
1525
1551
|
});
|
|
1526
1552
|
};
|
|
1527
1553
|
if (editable) add("edit", messages.common.edit, "edit", allowed(view, "update", row, screen, viewer), () => onEdit(row));
|
|
1554
|
+
if (options.onAction) {
|
|
1555
|
+
for (const action of view.actions()) {
|
|
1556
|
+
add(action.name, action.label, "bolt", view.canAction(action.name, row, viewer), () => options.onAction(action.name, row), !!action.destructive);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1528
1559
|
add(
|
|
1529
1560
|
"delete",
|
|
1530
1561
|
softDelete ? messages.bin.action : messages.delete.action,
|
|
@@ -1891,6 +1922,328 @@ function DateField({
|
|
|
1891
1922
|
clearable ? /* @__PURE__ */ jsx(NativeButton, { variant: "ghost", size: "sm", testID: `${testID}-clear`, onPress: () => onChange(null), children: fill(messages.form.clear, { label: label.toLowerCase() }) }) : null
|
|
1892
1923
|
] });
|
|
1893
1924
|
}
|
|
1925
|
+
function useNativeListMessages() {
|
|
1926
|
+
const own = useNativeResourceViewMessages().lists;
|
|
1927
|
+
return useMemo(() => ({ ...defaultNativeListMessages, ...own, types: { ...defaultNativeListMessages.types, ...own?.types } }), [own]);
|
|
1928
|
+
}
|
|
1929
|
+
var NATIVE_VIEW_TYPES = ["list", "grid", "gallery", "inbox", "board", "calendar"];
|
|
1930
|
+
function nativeSwitchableTypes(view) {
|
|
1931
|
+
const out = [];
|
|
1932
|
+
for (const t of view.types()) {
|
|
1933
|
+
const shown = t === "table" ? "list" : t;
|
|
1934
|
+
if (NATIVE_VIEW_TYPES.includes(shown) && !out.includes(shown)) out.push(shown);
|
|
1935
|
+
}
|
|
1936
|
+
return out;
|
|
1937
|
+
}
|
|
1938
|
+
function NativeViewTypeSwitcher({ state, types, testID = "native-view-types" }) {
|
|
1939
|
+
const words = useNativeListMessages();
|
|
1940
|
+
if (types.length < 2) return null;
|
|
1941
|
+
return /* @__PURE__ */ jsx(
|
|
1942
|
+
NativeSegmentedControl,
|
|
1943
|
+
{
|
|
1944
|
+
testID,
|
|
1945
|
+
options: types.map((t) => ({ value: t, label: words.types[t] ?? t })),
|
|
1946
|
+
value: state.type ?? types[0],
|
|
1947
|
+
onChange: (t) => state.setType(t)
|
|
1948
|
+
}
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1951
|
+
function NativeViewSegments({
|
|
1952
|
+
view,
|
|
1953
|
+
state,
|
|
1954
|
+
baseFilters = [],
|
|
1955
|
+
enabled = true,
|
|
1956
|
+
testID = "native-view-segments"
|
|
1957
|
+
}) {
|
|
1958
|
+
const words = useNativeListMessages();
|
|
1959
|
+
const segments = view.segments();
|
|
1960
|
+
const counts = useSegmentCounts(view, useMemo(() => [...baseFilters, ...state.valueFilters], [baseFilters, state.valueFilters]), { enabled });
|
|
1961
|
+
if (!segments.length) return null;
|
|
1962
|
+
return /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, accessibilityLabel: words.segments, children: /* @__PURE__ */ jsx(NativeChipGroup, { mode: "single", value: state.segment ?? "", onChange: (id) => state.setSegment(String(id)), testID, className: "flex-nowrap", children: segments.map((s) => /* @__PURE__ */ jsx(NativeChip, { value: s.id, testID: `${testID}-${s.id}`, children: counts[s.id] !== void 0 ? `${s.label} ${counts[s.id].toLocaleString()}` : s.label }, s.id)) }) });
|
|
1963
|
+
}
|
|
1964
|
+
function NativeViewFilterControls({ view, state, testID = "native-view-filters" }) {
|
|
1965
|
+
const words = useNativeListMessages();
|
|
1966
|
+
const filters = view.filters();
|
|
1967
|
+
const [open, setOpen] = useState(false);
|
|
1968
|
+
const set = Object.values(state.values).length;
|
|
1969
|
+
if (!filters.length) return null;
|
|
1970
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1971
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: 8 }, children: [
|
|
1972
|
+
/* @__PURE__ */ jsx(NativeButton, { size: "sm", variant: "outline", testID, onPress: () => setOpen(true), children: set ? fill(words.filtersSet, { count: set }) : words.filters }),
|
|
1973
|
+
state.active ? /* @__PURE__ */ jsx(NativeButton, { size: "sm", variant: "ghost", testID: `${testID}-clear`, onPress: state.clear, children: words.clear }) : null
|
|
1974
|
+
] }),
|
|
1975
|
+
/* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, testID: `${testID}-sheet`, children: /* @__PURE__ */ jsx(NativeSheetScrollView, { children: /* @__PURE__ */ jsxs(View, { style: { gap: 16, padding: 16 }, children: [
|
|
1976
|
+
filters.map((f) => {
|
|
1977
|
+
const value = state.values[f.field];
|
|
1978
|
+
const put = (next) => state.setValue(f.field, next);
|
|
1979
|
+
return /* @__PURE__ */ jsxs(View, { style: { gap: 6 }, testID: `${testID}-${f.field}`, children: [
|
|
1980
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", children: f.label }),
|
|
1981
|
+
f.kind === "choice" ? /* @__PURE__ */ jsx(NativeChipGroup, { mode: "multiple", value: Array.isArray(value) ? [...value] : [], onChange: (v) => put(Array.isArray(v) ? v : [v]), children: f.options.map((o) => /* @__PURE__ */ jsx(NativeChip, { value: o.value, testID: `${testID}-${f.field}-${o.value}`, children: o.label }, o.value)) }) : f.kind === "range" ? /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", gap: 8 }, children: ["gte", "lte"].map((end) => {
|
|
1982
|
+
const range = value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1983
|
+
return /* @__PURE__ */ jsx(
|
|
1984
|
+
NativeInput,
|
|
1985
|
+
{
|
|
1986
|
+
className: "flex-1",
|
|
1987
|
+
label: end === "gte" ? words.from : words.to,
|
|
1988
|
+
testID: `${testID}-${f.field}-${end}`,
|
|
1989
|
+
value: range[end] ?? "",
|
|
1990
|
+
keyboardType: f.input === "number" ? "numeric" : "default",
|
|
1991
|
+
placeholder: f.input === "date" ? "YYYY-MM-DD" : f.input === "datetime" ? "YYYY-MM-DDTHH:MM" : void 0,
|
|
1992
|
+
onChangeText: (text2) => put({ ...range, [end]: text2 })
|
|
1993
|
+
},
|
|
1994
|
+
end
|
|
1995
|
+
);
|
|
1996
|
+
}) }) : /* @__PURE__ */ jsx(NativeInput, { testID: `${testID}-${f.field}-text`, value: typeof value === "string" ? value : "", onChangeText: (text2) => put(text2) })
|
|
1997
|
+
] }, f.field);
|
|
1998
|
+
}),
|
|
1999
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: 8 }, children: [
|
|
2000
|
+
/* @__PURE__ */ jsx(NativeButton, { variant: "outline", onPress: state.clear, testID: `${testID}-sheet-clear`, children: words.clear }),
|
|
2001
|
+
/* @__PURE__ */ jsx(NativeButton, { onPress: () => setOpen(false), testID: `${testID}-sheet-done`, children: words.done })
|
|
2002
|
+
] })
|
|
2003
|
+
] }) }) })
|
|
2004
|
+
] });
|
|
2005
|
+
}
|
|
2006
|
+
function NativeListControls({
|
|
2007
|
+
view,
|
|
2008
|
+
state,
|
|
2009
|
+
baseFilters,
|
|
2010
|
+
types,
|
|
2011
|
+
testID,
|
|
2012
|
+
enabled = true
|
|
2013
|
+
}) {
|
|
2014
|
+
if (!view.segments().length && !view.filters().length && types.length < 2) return null;
|
|
2015
|
+
return /* @__PURE__ */ jsxs(View, { style: { gap: 8 }, testID: `${testID}-controls`, children: [
|
|
2016
|
+
/* @__PURE__ */ jsx(NativeViewTypeSwitcher, { state, types, testID: `${testID}-types` }),
|
|
2017
|
+
/* @__PURE__ */ jsx(NativeViewSegments, { view, state, baseFilters, enabled, testID: `${testID}-segment` }),
|
|
2018
|
+
/* @__PURE__ */ jsx(NativeViewFilterControls, { view, state, testID: `${testID}-filters` })
|
|
2019
|
+
] });
|
|
2020
|
+
}
|
|
2021
|
+
var COLUMN_WIDTH = 280;
|
|
2022
|
+
function NativeResourceBoard({
|
|
2023
|
+
view,
|
|
2024
|
+
filters,
|
|
2025
|
+
can,
|
|
2026
|
+
onOpen,
|
|
2027
|
+
header,
|
|
2028
|
+
testID,
|
|
2029
|
+
enabled = true
|
|
2030
|
+
}) {
|
|
2031
|
+
const words = useNativeListMessages();
|
|
2032
|
+
const colors = useThemeRoles();
|
|
2033
|
+
const board = useViewBoard(view, {
|
|
2034
|
+
filters,
|
|
2035
|
+
enabled,
|
|
2036
|
+
// The screen's rule, in the board's words: a card moves only when the screen allows `update`.
|
|
2037
|
+
...can ? {
|
|
2038
|
+
can: (action, row) => {
|
|
2039
|
+
const verdict = can(action === "edit" ? "update" : action, row);
|
|
2040
|
+
return verdict !== false && typeof verdict !== "string";
|
|
2041
|
+
}
|
|
2042
|
+
} : {},
|
|
2043
|
+
words: {
|
|
2044
|
+
notAllowed: words.notAllowed,
|
|
2045
|
+
noValue: words.noValue,
|
|
2046
|
+
stillSaving: (name) => fill(words.stillSaving, { name }),
|
|
2047
|
+
notChanged: (noun) => fill(words.notChanged, { noun }),
|
|
2048
|
+
moveFailed: (name) => fill(words.moveFailed, { name })
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
const cancel = useNativeResourceViewMessages().common.cancel;
|
|
2052
|
+
const showMoves = (row) => {
|
|
2053
|
+
const verdict = board.movable ? board.canMove(row) : words.notAllowed;
|
|
2054
|
+
const from = String(row[board.field] ?? "");
|
|
2055
|
+
showInboxActions(
|
|
2056
|
+
board.titleOf(row),
|
|
2057
|
+
board.columns.filter((c) => c.value !== from).map((c) => ({
|
|
2058
|
+
id: c.value,
|
|
2059
|
+
label: fill(words.moveTo, { column: c.label }),
|
|
2060
|
+
onPress: () => {
|
|
2061
|
+
if (verdict !== true) {
|
|
2062
|
+
showInboxActions(verdict, [], cancel);
|
|
2063
|
+
return;
|
|
2064
|
+
}
|
|
2065
|
+
void board.move(row, c.value).catch(() => void 0);
|
|
2066
|
+
}
|
|
2067
|
+
})),
|
|
2068
|
+
cancel
|
|
2069
|
+
);
|
|
2070
|
+
};
|
|
2071
|
+
return /* @__PURE__ */ jsxs(View, { style: { flex: 1 }, testID: `${testID}-board`, children: [
|
|
2072
|
+
header,
|
|
2073
|
+
board.refusal ? /* @__PURE__ */ jsx(NativeInlineAlert, { variant: "destructive", description: board.refusal, onDismiss: board.clearRefusal, testID: `${testID}-board-refusal` }) : null,
|
|
2074
|
+
/* @__PURE__ */ jsx(ScrollView, { horizontal: true, contentContainerStyle: { gap: 12, paddingHorizontal: 16, paddingBottom: 16 }, children: board.columns.map((column) => /* @__PURE__ */ jsxs(View, { testID: `${testID}-board-column-${column.value}`, style: { width: COLUMN_WIDTH, gap: 8 }, children: [
|
|
2075
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", gap: 8, paddingTop: 8 }, children: [
|
|
2076
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", accessibilityRole: "header", children: column.label }),
|
|
2077
|
+
/* @__PURE__ */ jsx(NativeBadge, { variant: badgeVariant(column.tone), children: String(column.total ?? column.items.length) })
|
|
2078
|
+
] }),
|
|
2079
|
+
/* @__PURE__ */ jsxs(ScrollView, { style: { maxHeight: "100%" }, contentContainerStyle: { gap: 8 }, children: [
|
|
2080
|
+
column.items.map((row) => {
|
|
2081
|
+
const key = board.keyOf(row);
|
|
2082
|
+
const summary = view.summary(row);
|
|
2083
|
+
return /* @__PURE__ */ jsx(
|
|
2084
|
+
Pressable,
|
|
2085
|
+
{
|
|
2086
|
+
testID: `${testID}-board-card-${key}`,
|
|
2087
|
+
accessibilityRole: "button",
|
|
2088
|
+
accessibilityLabel: summary.title,
|
|
2089
|
+
accessibilityActions: [{ name: "move", label: words.moveTo.replace(" {column}", "") }],
|
|
2090
|
+
onAccessibilityAction: () => showMoves(row),
|
|
2091
|
+
onPress: () => onOpen(row),
|
|
2092
|
+
onLongPress: () => showMoves(row),
|
|
2093
|
+
style: { backgroundColor: colors.surface, borderRadius: 12, opacity: board.saving.has(key) ? 0.5 : 1 },
|
|
2094
|
+
children: /* @__PURE__ */ jsx(NativeListItem, { title: summary.title, subtitle: summary.subtitle, className: "bg-transparent" })
|
|
2095
|
+
},
|
|
2096
|
+
key
|
|
2097
|
+
);
|
|
2098
|
+
}),
|
|
2099
|
+
column.loading ? /* @__PURE__ */ jsx(NativeLoadingState, { fullScreen: false, size: "small" }) : null,
|
|
2100
|
+
column.hasMore ? /* @__PURE__ */ jsx(NativeButton, { size: "sm", variant: "ghost", onPress: () => board.loadMore(column.value), testID: `${testID}-board-more-${column.value}`, children: words.loadMore }) : null
|
|
2101
|
+
] })
|
|
2102
|
+
] }, column.value)) })
|
|
2103
|
+
] });
|
|
2104
|
+
}
|
|
2105
|
+
function NativeResourceCalendar({
|
|
2106
|
+
view,
|
|
2107
|
+
filters,
|
|
2108
|
+
onOpen,
|
|
2109
|
+
header,
|
|
2110
|
+
testID,
|
|
2111
|
+
enabled = true
|
|
2112
|
+
}) {
|
|
2113
|
+
const words = useNativeListMessages();
|
|
2114
|
+
const listWords = useNativeResourceViewMessages().list;
|
|
2115
|
+
const colors = useThemeRoles();
|
|
2116
|
+
const block = view.definition.calendar;
|
|
2117
|
+
if (!block?.field) throw new Error(`NativeResourceView(${view.resource}): type="calendar" needs the view's calendar block (calendar.field)`);
|
|
2118
|
+
const [layout, setLayout] = useState(block.phoneLayout === "month" || block.layout === "month" ? "month" : "agenda");
|
|
2119
|
+
const weekStartsOn = block.weekStartsOn ?? 1;
|
|
2120
|
+
const zones = useDisplayTimeZones();
|
|
2121
|
+
const zone = displayZone(view.definition.fields?.[block.field]?.timeZone, zones.viewer, zones.scope);
|
|
2122
|
+
const [anchor, setAnchor] = useState(() => dayIn(zone));
|
|
2123
|
+
const [picked, setPicked] = useState(() => dayIn(zone));
|
|
2124
|
+
const range = calendarWindow(layout === "month" ? "month" : "agenda", anchor, { weeks: 2, weekStartsOn });
|
|
2125
|
+
const data = useViewCalendarRange(view, range, { filters, timeZone: zone, enabled });
|
|
2126
|
+
const events = useMemo(
|
|
2127
|
+
() => calendarEvents(view, data.rows, { field: block.field, endField: block.endField, durationField: block.durationField, durationUnit: block.durationUnit, allDayField: block.allDayField, laneBy: block.laneBy, timeZone: zone }),
|
|
2128
|
+
[view, data.rows, block, zone]
|
|
2129
|
+
);
|
|
2130
|
+
const byDay = useMemo(() => placeEvents(events, range, zone), [events, range.start, range.end, zone]);
|
|
2131
|
+
const step = (n) => setAnchor((a) => shiftAnchor(layout === "month" ? "month" : "agenda", a, n, 2));
|
|
2132
|
+
const time = (at) => typeof at === "string" ? words.allDay : at.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit", timeZone: zone });
|
|
2133
|
+
const eventRow = (placed) => /* @__PURE__ */ jsx(
|
|
2134
|
+
Pressable,
|
|
2135
|
+
{
|
|
2136
|
+
testID: `${testID}-calendar-event-${placed.event.key}`,
|
|
2137
|
+
accessibilityRole: "button",
|
|
2138
|
+
onPress: () => placed.event.row && onOpen(placed.event.row),
|
|
2139
|
+
style: { backgroundColor: colors.surface, borderRadius: 10, marginHorizontal: 16 },
|
|
2140
|
+
children: /* @__PURE__ */ jsx(NativeListItem, { title: placed.event.title, subtitle: placed.allDay ? words.allDay : time(placed.event.start), className: "bg-transparent" })
|
|
2141
|
+
},
|
|
2142
|
+
`${placed.day}:${placed.event.key}`
|
|
2143
|
+
);
|
|
2144
|
+
const toolbar = /* @__PURE__ */ jsxs(View, { style: { gap: 8, paddingHorizontal: 16 }, children: [
|
|
2145
|
+
/* @__PURE__ */ jsx(
|
|
2146
|
+
NativeSegmentedControl,
|
|
2147
|
+
{
|
|
2148
|
+
testID: `${testID}-calendar-layout`,
|
|
2149
|
+
options: [
|
|
2150
|
+
{ value: "agenda", label: words.agenda },
|
|
2151
|
+
{ value: "month", label: words.month }
|
|
2152
|
+
],
|
|
2153
|
+
value: layout,
|
|
2154
|
+
onChange: (l) => setLayout(l)
|
|
2155
|
+
}
|
|
2156
|
+
),
|
|
2157
|
+
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: 8, alignItems: "center" }, children: [
|
|
2158
|
+
/* @__PURE__ */ jsx(NativeButton, { size: "sm", variant: "outline", accessibilityLabel: words.previous, onPress: () => step(-1), testID: `${testID}-calendar-previous`, children: "\u2039" }),
|
|
2159
|
+
/* @__PURE__ */ jsx(
|
|
2160
|
+
NativeButton,
|
|
2161
|
+
{
|
|
2162
|
+
size: "sm",
|
|
2163
|
+
variant: "outline",
|
|
2164
|
+
onPress: () => {
|
|
2165
|
+
setAnchor(dayIn(zone));
|
|
2166
|
+
setPicked(dayIn(zone));
|
|
2167
|
+
},
|
|
2168
|
+
testID: `${testID}-calendar-today`,
|
|
2169
|
+
children: words.today
|
|
2170
|
+
}
|
|
2171
|
+
),
|
|
2172
|
+
/* @__PURE__ */ jsx(NativeButton, { size: "sm", variant: "outline", accessibilityLabel: words.next, onPress: () => step(1), testID: `${testID}-calendar-next`, children: "\u203A" }),
|
|
2173
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", className: "ml-2", children: anchor.slice(0, 7) })
|
|
2174
|
+
] }),
|
|
2175
|
+
data.total > data.rows.length ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", children: fill(words.more, { count: data.total - data.rows.length }) }) : null
|
|
2176
|
+
] });
|
|
2177
|
+
const failed = data.error ? /* @__PURE__ */ jsx(
|
|
2178
|
+
NativeEmptyState,
|
|
2179
|
+
{
|
|
2180
|
+
testID: `${testID}-calendar-error`,
|
|
2181
|
+
variant: "error",
|
|
2182
|
+
title: fill(listWords.loadFailed, { nounPlural: view.nounPlural }),
|
|
2183
|
+
primaryAction: /* @__PURE__ */ jsx(NativeButton, { variant: "outline", size: "sm", onPress: () => data.refetch(), testID: `${testID}-calendar-retry`, children: listWords.retry })
|
|
2184
|
+
}
|
|
2185
|
+
) : null;
|
|
2186
|
+
if (failed) {
|
|
2187
|
+
return /* @__PURE__ */ jsxs(ScrollView, { testID: `${testID}-calendar-failed`, contentContainerStyle: { gap: 12, paddingBottom: 32 }, children: [
|
|
2188
|
+
header,
|
|
2189
|
+
toolbar,
|
|
2190
|
+
failed
|
|
2191
|
+
] });
|
|
2192
|
+
}
|
|
2193
|
+
if (layout === "agenda") {
|
|
2194
|
+
const sections = [...byDay.entries()].filter(([, list]) => list.length).map(([day, list]) => ({ key: day, title: day, data: list }));
|
|
2195
|
+
return /* @__PURE__ */ jsx(
|
|
2196
|
+
SectionList,
|
|
2197
|
+
{
|
|
2198
|
+
testID: `${testID}-calendar-agenda`,
|
|
2199
|
+
sections,
|
|
2200
|
+
keyExtractor: (p) => `${p.day}:${p.event.key}`,
|
|
2201
|
+
renderItem: ({ item }) => eventRow(item),
|
|
2202
|
+
renderSectionHeader: ({ section }) => /* @__PURE__ */ jsx(NativeText, { preset: "label", className: "px-4 pt-4 pb-1", accessibilityRole: "header", children: section.title }),
|
|
2203
|
+
ItemSeparatorComponent: () => /* @__PURE__ */ jsx(View, { style: { height: 8 } }),
|
|
2204
|
+
ListHeaderComponent: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2205
|
+
header,
|
|
2206
|
+
toolbar
|
|
2207
|
+
] }),
|
|
2208
|
+
ListEmptyComponent: data.loading ? /* @__PURE__ */ jsx(NativeLoadingState, { fullScreen: false }) : /* @__PURE__ */ jsx(NativeText, { className: "px-4 pt-4 text-muted-foreground", children: words.noEvents }),
|
|
2209
|
+
stickySectionHeadersEnabled: false
|
|
2210
|
+
}
|
|
2211
|
+
);
|
|
2212
|
+
}
|
|
2213
|
+
const days = [...byDay.keys()];
|
|
2214
|
+
const weeks = [];
|
|
2215
|
+
for (let i = 0; i < days.length; i += 7) weeks.push(days.slice(i, i + 7));
|
|
2216
|
+
const month = anchor.slice(0, 7);
|
|
2217
|
+
const today = dayIn(zone);
|
|
2218
|
+
const ofPicked = byDay.get(picked) ?? [];
|
|
2219
|
+
return /* @__PURE__ */ jsxs(ScrollView, { testID: `${testID}-calendar-month`, contentContainerStyle: { gap: 12, paddingBottom: 32 }, children: [
|
|
2220
|
+
header,
|
|
2221
|
+
toolbar,
|
|
2222
|
+
/* @__PURE__ */ jsx(View, { style: { paddingHorizontal: 16 }, children: weeks.map((week) => /* @__PURE__ */ jsx(View, { style: { flexDirection: "row" }, children: week.map((day) => {
|
|
2223
|
+
const list = byDay.get(day) ?? [];
|
|
2224
|
+
const selected = day === picked;
|
|
2225
|
+
return /* @__PURE__ */ jsxs(
|
|
2226
|
+
Pressable,
|
|
2227
|
+
{
|
|
2228
|
+
testID: `${testID}-calendar-day-${day}`,
|
|
2229
|
+
accessibilityRole: "button",
|
|
2230
|
+
accessibilityState: { selected },
|
|
2231
|
+
accessibilityLabel: `${day}${list.length ? `, ${list.length}` : ""}`,
|
|
2232
|
+
onPress: () => setPicked(day),
|
|
2233
|
+
style: { flex: 1, alignItems: "center", paddingVertical: 6, borderRadius: 8, backgroundColor: selected ? colors.surface : void 0 },
|
|
2234
|
+
children: [
|
|
2235
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "body-sm", className: day.slice(0, 7) !== month ? "text-muted-foreground" : day === today ? "font-semibold" : void 0, children: String(Number(day.slice(8))) }),
|
|
2236
|
+
/* @__PURE__ */ jsx(View, { style: { flexDirection: "row", gap: 2, height: 6 }, children: list.slice(0, 3).map((p) => /* @__PURE__ */ jsx(View, { style: { width: 4, height: 4, borderRadius: 2, backgroundColor: colors.tint } }, p.event.key)) })
|
|
2237
|
+
]
|
|
2238
|
+
},
|
|
2239
|
+
day
|
|
2240
|
+
);
|
|
2241
|
+
}) }, week[0])) }),
|
|
2242
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", className: "px-4", accessibilityRole: "header", children: picked }),
|
|
2243
|
+
ofPicked.length ? /* @__PURE__ */ jsx(View, { style: { gap: 8 }, children: ofPicked.map((p) => eventRow(p)) }) : /* @__PURE__ */ jsx(NativeText, { className: "px-4 text-muted-foreground", children: words.noEvents }),
|
|
2244
|
+
data.loading ? /* @__PURE__ */ jsx(NativeLoadingState, { fullScreen: false, size: "small" }) : null
|
|
2245
|
+
] });
|
|
2246
|
+
}
|
|
1894
2247
|
var recordKey = (view, row) => {
|
|
1895
2248
|
try {
|
|
1896
2249
|
return String(encodeRecordKey(view.contract, row));
|
|
@@ -1934,7 +2287,7 @@ function serverSort(view) {
|
|
|
1934
2287
|
return serverSorts(view)[0];
|
|
1935
2288
|
}
|
|
1936
2289
|
function useNativeResourceView(view, options = {}) {
|
|
1937
|
-
const { preset, filter, perPage, maxPages = DEFAULT_MAX_PAGES, searchFields: searchOption, can, live } = options;
|
|
2290
|
+
const { preset, filter, perPage, maxPages = DEFAULT_MAX_PAGES, searchFields: searchOption, can, live, listFilters, enabled = true } = options;
|
|
1938
2291
|
const messages = useNativeResourceViewMessages();
|
|
1939
2292
|
const tab = preset ? view.definition.presets?.[preset] : void 0;
|
|
1940
2293
|
if (preset && !tab) throw new Error(`NativeResourceView(${view.resource}): no preset "${preset}"`);
|
|
@@ -1953,13 +2306,16 @@ function useNativeResourceView(view, options = {}) {
|
|
|
1953
2306
|
() => searchOption ?? (view.labelField ? [view.labelField] : void 0),
|
|
1954
2307
|
[searchOption, view.labelField]
|
|
1955
2308
|
);
|
|
2309
|
+
const listStateKey = JSON.stringify(listFilters ?? []);
|
|
2310
|
+
const readFilters = useMemo(() => [...defaultFilters, ...JSON.parse(listStateKey)], [defaultFilters, listStateKey]);
|
|
1956
2311
|
const pages = useInfiniteResource(view.resource, {
|
|
1957
|
-
defaultFilters,
|
|
2312
|
+
defaultFilters: readFilters,
|
|
1958
2313
|
...sorts.length ? { defaultSorts: sorts } : {},
|
|
1959
2314
|
...perPage ? { perPage } : {},
|
|
1960
2315
|
maxPages,
|
|
1961
2316
|
...searchFields ? { searchFields } : {},
|
|
1962
2317
|
keepPreviousData: true,
|
|
2318
|
+
enabled,
|
|
1963
2319
|
...live ? { live } : {}
|
|
1964
2320
|
});
|
|
1965
2321
|
const [search, setSearchText] = useState("");
|
|
@@ -2088,7 +2444,8 @@ function useNativeResourceView(view, options = {}) {
|
|
|
2088
2444
|
formFields,
|
|
2089
2445
|
save,
|
|
2090
2446
|
remove,
|
|
2091
|
-
softDelete
|
|
2447
|
+
softDelete,
|
|
2448
|
+
baseFilters: defaultFilters
|
|
2092
2449
|
};
|
|
2093
2450
|
}
|
|
2094
2451
|
var IOS_GROUP_MARGIN = 16;
|
|
@@ -2287,13 +2644,67 @@ function Screen(props) {
|
|
|
2287
2644
|
renderCard,
|
|
2288
2645
|
scopeTimeZone: _zone,
|
|
2289
2646
|
testID = "native-resource-view",
|
|
2647
|
+
switcher,
|
|
2648
|
+
savedViews,
|
|
2649
|
+
defaultSegment,
|
|
2650
|
+
onAction,
|
|
2290
2651
|
...options
|
|
2291
2652
|
} = props;
|
|
2292
|
-
const
|
|
2293
|
-
|
|
2653
|
+
const switchTypes = useMemo(() => nativeSwitchableTypes(view), [view]);
|
|
2654
|
+
const switcherOn = (switcher ?? (type === void 0 && props.mode === void 0 && !!view.definition.types)) && switchTypes.length >= 2;
|
|
2655
|
+
const list = useListState({
|
|
2656
|
+
view,
|
|
2657
|
+
store: savedViews,
|
|
2658
|
+
types: switchTypes,
|
|
2659
|
+
defaultType: type ?? (switcherOn ? switchTypes[0] : void 0) ?? modeProp,
|
|
2660
|
+
rememberType: switcherOn,
|
|
2661
|
+
defaultSegment
|
|
2662
|
+
});
|
|
2663
|
+
const shown = (switcherOn ? list.type : void 0) ?? type;
|
|
2664
|
+
const inbox = shown === "inbox";
|
|
2665
|
+
const board = shown === "board";
|
|
2666
|
+
const calendar = shown === "calendar";
|
|
2667
|
+
const mode = shown === "gallery" ? "grid" : shown === "grid" ? "grid" : shown === void 0 ? modeProp : "list";
|
|
2668
|
+
if (shown === "gallery" && !view.definition.gallery && !screenGallery?.image) {
|
|
2294
2669
|
throw new Error(`NativeResourceView(${view.resource}): type="gallery" needs a gallery block: the view's gallery.image, or gallery={{ image }}`);
|
|
2295
2670
|
}
|
|
2296
|
-
|
|
2671
|
+
if (inbox && !view.definition.inbox) {
|
|
2672
|
+
throw new Error(`NativeResourceView(${view.resource}): type="inbox" needs the view's inbox block (which field is the title, the time, unread)`);
|
|
2673
|
+
}
|
|
2674
|
+
const state = useNativeResourceView(view, { ...options, listFilters: list.filters, enabled: options.enabled !== false && !board && !calendar });
|
|
2675
|
+
const provider = useDataProvider();
|
|
2676
|
+
const queryClient = useQueryClient();
|
|
2677
|
+
const viewer = useViewer$1();
|
|
2678
|
+
const askCaps = !onAction && !!provider.runAction && !!provider.capabilities;
|
|
2679
|
+
const actionCaps = useCapabilities(view.resource, { enabled: askCaps });
|
|
2680
|
+
const runAction = useCallback(
|
|
2681
|
+
async (name, row) => {
|
|
2682
|
+
if (onAction) await onAction(name, row);
|
|
2683
|
+
else if (provider.runAction) {
|
|
2684
|
+
const field = actionCaps.data?.version?.field;
|
|
2685
|
+
const value = field ? row[field] : void 0;
|
|
2686
|
+
await provider.runAction(view.resource, {
|
|
2687
|
+
id: recordKey(view, row),
|
|
2688
|
+
action: name,
|
|
2689
|
+
...value == null ? {} : { expectedVersion: String(value) }
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
await queryClient.invalidateQueries({ queryKey: resourceKeys(view.resource).all });
|
|
2693
|
+
},
|
|
2694
|
+
[onAction, provider, view, queryClient, actionCaps.data]
|
|
2695
|
+
);
|
|
2696
|
+
const actionsOn = !!onAction || !!provider.runAction && (!askCaps || actionCaps.isSuccess) && actionCaps.data?.actions !== false;
|
|
2697
|
+
const cancelWord = useNativeResourceViewMessages().common.cancel;
|
|
2698
|
+
const confirmAction = useCallback(
|
|
2699
|
+
(name, row) => {
|
|
2700
|
+
const action = view.actions().find((a) => a.name === name);
|
|
2701
|
+
const run = () => void runAction(name, row).catch((error) => Alert.alert(action?.label ?? name, error instanceof Error ? error.message : String(error)));
|
|
2702
|
+
if (action?.confirm) Alert.alert(action.confirm, void 0, [{ text: cancelWord, style: "cancel" }, { text: action.label, style: action.destructive ? "destructive" : "default", onPress: run }]);
|
|
2703
|
+
else run();
|
|
2704
|
+
},
|
|
2705
|
+
[view, runAction, cancelWord]
|
|
2706
|
+
);
|
|
2707
|
+
const markRead = view.inboxActions().markRead;
|
|
2297
2708
|
const keyExtractor = useCallback((row) => recordKey(view, row), [view]);
|
|
2298
2709
|
const messages = useNativeResourceViewMessages();
|
|
2299
2710
|
const colors = useThemeRoles();
|
|
@@ -2324,7 +2735,10 @@ function Screen(props) {
|
|
|
2324
2735
|
setPeekId(null);
|
|
2325
2736
|
setSheet({ mode: "edit", row });
|
|
2326
2737
|
}, []);
|
|
2327
|
-
const handlers = useMemo(
|
|
2738
|
+
const handlers = useMemo(
|
|
2739
|
+
() => ({ onEdit: edit, onDelete: confirmDelete, onRefused: refused, ...actionsOn ? { onAction: confirmAction } : {} }),
|
|
2740
|
+
[edit, confirmDelete, refused, actionsOn, confirmAction]
|
|
2741
|
+
);
|
|
2328
2742
|
const rowPress = useRef(onRowPress);
|
|
2329
2743
|
rowPress.current = onRowPress;
|
|
2330
2744
|
const press = useCallback((row) => rowPress.current ? rowPress.current(row) : setPeekId({ row }), []);
|
|
@@ -2399,7 +2813,7 @@ function Screen(props) {
|
|
|
2399
2813
|
if (state.canCreate === true) setSheet({ mode: "create" });
|
|
2400
2814
|
else if (typeof state.canCreate === "string") refused(fill(messages.common.create, { noun: view.noun }), state.canCreate);
|
|
2401
2815
|
};
|
|
2402
|
-
const showSearch = searchable ?? !!(options.searchFields?.length || view.labelField);
|
|
2816
|
+
const showSearch = !board && !calendar && (searchable ?? !!(options.searchFields?.length || view.labelField));
|
|
2403
2817
|
const heading = title === false ? null : title ?? view.title;
|
|
2404
2818
|
const hasRows = state.rows.length > 0;
|
|
2405
2819
|
const listHeader = /* @__PURE__ */ jsxs(View, { style: { paddingHorizontal: 16, paddingTop: 8, paddingBottom: 8, gap: 12 }, children: [
|
|
@@ -2435,6 +2849,7 @@ function Screen(props) {
|
|
|
2435
2849
|
onDismiss: state.dismissRefusal
|
|
2436
2850
|
}
|
|
2437
2851
|
) : null,
|
|
2852
|
+
/* @__PURE__ */ jsx(NativeListControls, { view, state: list, baseFilters: state.baseFilters, types: switcherOn ? switchTypes : [], enabled: options.enabled !== false, testID }),
|
|
2438
2853
|
header,
|
|
2439
2854
|
state.loadingPrevious ? /* @__PURE__ */ jsx(NativeLoadingState, { fullScreen: false, size: "small", label: messages.list.loadingMore, testID: `${testID}-previous` }) : null
|
|
2440
2855
|
] });
|
|
@@ -2454,8 +2869,9 @@ function Screen(props) {
|
|
|
2454
2869
|
body: view.definition.copy?.empty?.body ?? messages.list.emptyBody
|
|
2455
2870
|
}
|
|
2456
2871
|
));
|
|
2457
|
-
const
|
|
2458
|
-
const
|
|
2872
|
+
const recordScope = useMemo(() => [...state.baseFilters, ...list.filters], [state.baseFilters, list.filters]);
|
|
2873
|
+
const peekRow = useOne(view.resource, peekId ? peekId.row.id : null, { scope: recordScope });
|
|
2874
|
+
const editRow = useOne(view.resource, sheet?.mode === "edit" ? sheet.row.id : null, { scope: recordScope });
|
|
2459
2875
|
const peek = peekId ? peekRow.data ?? peekId.row : null;
|
|
2460
2876
|
const peekFields = useMemo(
|
|
2461
2877
|
() => view.columns().map((column) => ({
|
|
@@ -2487,7 +2903,50 @@ function Screen(props) {
|
|
|
2487
2903
|
const peekActions = peek ? actionsFor(peek, handlers) : [];
|
|
2488
2904
|
const editLoading = sheet?.mode === "edit" && editRow.data === void 0 && !editRow.isError;
|
|
2489
2905
|
return /* @__PURE__ */ jsxs(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: [
|
|
2490
|
-
|
|
2906
|
+
board ? /* @__PURE__ */ jsx(
|
|
2907
|
+
NativeResourceBoard,
|
|
2908
|
+
{
|
|
2909
|
+
view,
|
|
2910
|
+
filters: [...state.baseFilters, ...list.filters],
|
|
2911
|
+
enabled: options.enabled !== false,
|
|
2912
|
+
...options.can ? { can: options.can } : {},
|
|
2913
|
+
onOpen: (row) => press(row),
|
|
2914
|
+
header: listHeader,
|
|
2915
|
+
testID
|
|
2916
|
+
}
|
|
2917
|
+
) : calendar ? /* @__PURE__ */ jsx(NativeResourceCalendar, { view, filters: [...state.baseFilters, ...list.filters], enabled: options.enabled !== false, onOpen: (row) => press(row), header: listHeader, testID }) : inbox ? /* @__PURE__ */ jsx(
|
|
2918
|
+
InboxPage,
|
|
2919
|
+
{
|
|
2920
|
+
testID: `${testID}-inbox`,
|
|
2921
|
+
items: state.rows.map((row) => {
|
|
2922
|
+
const r = view.inboxRow(row);
|
|
2923
|
+
return {
|
|
2924
|
+
id: r.id,
|
|
2925
|
+
title: r.title,
|
|
2926
|
+
unread: r.unread,
|
|
2927
|
+
...r.preview ? { preview: r.preview } : {},
|
|
2928
|
+
...r.time ? { timestamp: r.time } : {},
|
|
2929
|
+
...r.from || r.badge ? { meta: [r.from, r.badge?.label].filter(Boolean).join(" \xB7 ") } : {},
|
|
2930
|
+
onPress: () => {
|
|
2931
|
+
if (r.unread && markRead && actionsOn && view.canAction(markRead, row, viewer) === true) void runAction(markRead, row).catch(() => void 0);
|
|
2932
|
+
press(row);
|
|
2933
|
+
},
|
|
2934
|
+
// The view's swipe actions (edit, delete, its own), as the list's rows have them.
|
|
2935
|
+
swipeActions: actionsFor(row, handlers).map((a) => ({ id: a.id, label: a.label, onPress: a.onPress, ...a.destructive ? { destructive: true } : {} }))
|
|
2936
|
+
};
|
|
2937
|
+
}),
|
|
2938
|
+
header: listHeader,
|
|
2939
|
+
loading: state.loading,
|
|
2940
|
+
error: Boolean(state.error),
|
|
2941
|
+
refreshing: state.refreshing,
|
|
2942
|
+
onRefresh: () => state.refresh(),
|
|
2943
|
+
loadingMore: state.loadingMore,
|
|
2944
|
+
...state.hasMore ? { onEndReached: state.loadMore } : {},
|
|
2945
|
+
...state.hasPrevious ? { onStartReached: state.loadPrevious } : {},
|
|
2946
|
+
...view.definition.copy?.empty?.title ? { emptyTitle: view.definition.copy.empty.title } : {},
|
|
2947
|
+
...view.definition.copy?.empty?.body ? { emptyBody: view.definition.copy.empty.body } : {}
|
|
2948
|
+
}
|
|
2949
|
+
) : photos ? /* @__PURE__ */ jsx(
|
|
2491
2950
|
NativeGalleryGrid,
|
|
2492
2951
|
{
|
|
2493
2952
|
testID: `${testID}-gallery`,
|
|
@@ -2604,7 +3063,9 @@ function useHeaderActions({ view: recordView, row, onAction, can, messages }) {
|
|
|
2604
3063
|
const viewer = useViewer$1();
|
|
2605
3064
|
const actions = recordView.headerFor(row, {
|
|
2606
3065
|
viewer,
|
|
2607
|
-
runnable
|
|
3066
|
+
// Not runnable until the provider has answered (an action run before then, or after a failed
|
|
3067
|
+
// answer, would go without its version).
|
|
3068
|
+
runnable: Boolean(onAction) || Boolean(provider.runAction) && (!provider.capabilities || capabilities.isSuccess) && capabilities.data?.actions !== false,
|
|
2608
3069
|
...!onAction && described.data?.actions ? { served: described.data.actions.map((a) => a.name) } : {},
|
|
2609
3070
|
...can ? { can: (name) => can(name, row) } : {}
|
|
2610
3071
|
}).actions;
|
|
@@ -2616,8 +3077,15 @@ function useHeaderActions({ view: recordView, row, onAction, can, messages }) {
|
|
|
2616
3077
|
setPending(true);
|
|
2617
3078
|
try {
|
|
2618
3079
|
if (onAction) await onAction(a.name, row);
|
|
2619
|
-
else if (provider.runAction)
|
|
2620
|
-
|
|
3080
|
+
else if (provider.runAction) {
|
|
3081
|
+
const field = capabilities.data?.version?.field;
|
|
3082
|
+
const value = field ? row[field] : void 0;
|
|
3083
|
+
await provider.runAction(view.resource, {
|
|
3084
|
+
id: recordView.recordId(row),
|
|
3085
|
+
action: a.name,
|
|
3086
|
+
...value == null ? {} : { expectedVersion: String(value) }
|
|
3087
|
+
});
|
|
3088
|
+
} else throw new DataWriteError("error", fill(words.noRunner, { name: a.label }));
|
|
2621
3089
|
await queryClient.invalidateQueries({ queryKey: [...resourceKeys(view.resource).all] });
|
|
2622
3090
|
} catch (error) {
|
|
2623
3091
|
Alert.alert(a.label, refusalMessage(error, words.failed));
|
|
@@ -3123,6 +3591,7 @@ function NativeRecordPeek({
|
|
|
3123
3591
|
onClose,
|
|
3124
3592
|
onEdit,
|
|
3125
3593
|
onDelete,
|
|
3594
|
+
confirmDelete: confirmFirst = true,
|
|
3126
3595
|
can,
|
|
3127
3596
|
header,
|
|
3128
3597
|
snapPoints = ["60%", "92%"],
|
|
@@ -3153,7 +3622,7 @@ function NativeRecordPeek({
|
|
|
3153
3622
|
setDeleting(false);
|
|
3154
3623
|
}
|
|
3155
3624
|
};
|
|
3156
|
-
const confirmDelete = (r) => Alert.alert(labels.deleteTitle ?? fill(words.confirmTitle, { name: title }), labels.deleteBody ?? words.confirmBody, [
|
|
3625
|
+
const confirmDelete = (r) => !confirmFirst ? void onDelete?.(r) : Alert.alert(labels.deleteTitle ?? fill(words.confirmTitle, { name: title }), labels.deleteBody ?? words.confirmBody, [
|
|
3157
3626
|
{ text: labels.cancel ?? messages.common.cancel, style: "cancel" },
|
|
3158
3627
|
{ text: deleteLabel, style: "destructive", onPress: () => void runDelete(r) }
|
|
3159
3628
|
]);
|
|
@@ -3190,6 +3659,6 @@ function NativeRecordPeek({
|
|
|
3190
3659
|
] }) : null });
|
|
3191
3660
|
}
|
|
3192
3661
|
|
|
3193
|
-
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NativeConflictSheet, NativeCustomView, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeFieldArrayRenderer, NativeFileUploadField, NativeRecordPeek, NativeRecordView, NativeRecordViewMenu, NativeRelationField, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, NativeWizardForm, SEARCH_DEBOUNCE_MS2 as SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, allowed, dateToDay, dayToDate, defaultNativeRecordViewMessages, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeRecordViewStackOptions, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeCustomView, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
3662
|
+
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NATIVE_VIEW_TYPES, NativeConflictSheet, NativeCustomView, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeFieldArrayRenderer, NativeFileUploadField, NativeRecordPeek, NativeRecordView, NativeRecordViewMenu, NativeRelationField, NativeResourceBoard, NativeResourceCalendar, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, NativeViewFilterControls, NativeViewSegments, NativeViewTypeSwitcher, NativeWizardForm, SEARCH_DEBOUNCE_MS2 as SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, allowed, dateToDay, dayToDate, defaultNativeListMessages, defaultNativeRecordViewMessages, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeRecordViewStackOptions, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, nativeSwitchableTypes, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeCustomView, useNativeListMessages, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
3194
3663
|
//# sourceMappingURL=index.js.map
|
|
3195
3664
|
//# sourceMappingURL=index.js.map
|