@marktiderman/genesis-ui-native 3.1.0 → 3.2.1
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/data/index.d.ts +42 -21
- package/dist/data/index.js +46 -33
- package/dist/data/index.js.map +1 -1
- package/package.json +23 -9
- package/src/__tests__/fake-modules.tsx +10 -3
- package/src/data/resource-view/{NativeResourceWorkspace.tsx → NativeRecordView.tsx} +91 -56
- package/src/data/resource-view/__tests__/{native-resource-workspace.test.tsx → native-record-view.test.tsx} +34 -34
- package/src/data/resource-view/index.ts +10 -3
package/dist/data/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ResourceFormFieldDef, BaseRecord, DataRow, FieldReference, ResourceCont
|
|
|
4
4
|
import { Control, UseFormReturn } from 'react-hook-form';
|
|
5
5
|
import { UseResourceOptions } from '@marktiderman/genesis-core/hooks';
|
|
6
6
|
import { d as InboxSwipeAction, c as InboxPageSlotMap, g as ScreenHeaderProps } from '../inbox-page-DZUR-PJ1.js';
|
|
7
|
-
import { ResourceView, DisplayHint, RowSummary, RowPicture,
|
|
7
|
+
import { ResourceView, DisplayHint, Allowed, RowSummary, RowPicture, Viewer, ResolvedColumn, RecordView } from '@marktiderman/genesis-core/resource-view';
|
|
8
8
|
import { ReadinessLabels } from '@marktiderman/genesis-core/resource';
|
|
9
9
|
import '@marktiderman/genesis-core/slots';
|
|
10
10
|
import 'react-native';
|
|
@@ -531,13 +531,13 @@ declare function useNativeResourceViewMessages(): NativeResourceViewMessages;
|
|
|
531
531
|
declare function useDisplayCell(): (column: ResolvedColumn<Record<string, unknown>>, row: Record<string, unknown>) => ReactNode;
|
|
532
532
|
|
|
533
533
|
type Row = Record<string, unknown>;
|
|
534
|
-
type
|
|
534
|
+
type AnyRecordView<T extends Row> = RecordView<ResourceContract<any>, T & DataRow>;
|
|
535
535
|
/**
|
|
536
|
-
* The words
|
|
536
|
+
* The words NativeRecordView shows. Override any of them with `messages`. The readiness
|
|
537
537
|
* chip's keys (`ready`, `empty`, `pending`, `problems`, `warnings`) are genesis-core/resource's
|
|
538
538
|
* `readinessChip` labels: unset, they use its defaults.
|
|
539
539
|
*/
|
|
540
|
-
interface
|
|
540
|
+
interface NativeRecordViewMessages extends ReadinessLabels {
|
|
541
541
|
actions: string;
|
|
542
542
|
cancel: string;
|
|
543
543
|
save: string;
|
|
@@ -553,37 +553,37 @@ interface NativeResourceWorkspaceMessages extends ReadinessLabels {
|
|
|
553
553
|
allSections: string;
|
|
554
554
|
notANumber: string;
|
|
555
555
|
}
|
|
556
|
-
declare const
|
|
556
|
+
declare const defaultNativeRecordViewMessages: NativeRecordViewMessages;
|
|
557
557
|
/** Up to this many sections show as a segmented control; more are pushed rows. */
|
|
558
558
|
declare const SEGMENTED_SECTIONS_MAX = 4;
|
|
559
|
-
interface
|
|
560
|
-
|
|
559
|
+
interface NativeRecordViewHeaderProps<T extends Row = Row> {
|
|
560
|
+
view: AnyRecordView<T>;
|
|
561
561
|
row: T;
|
|
562
562
|
/** Runs an allowed (and confirmed) action. Default: the provider's `runAction`. */
|
|
563
563
|
onAction?: (name: string, row: T) => unknown;
|
|
564
564
|
/** The screen's own rule: `false` hides an action, a sentence refuses it. Only narrows. */
|
|
565
565
|
can?: (action: string, row: T) => Allowed | boolean;
|
|
566
|
-
messages?: Partial<
|
|
566
|
+
messages?: Partial<NativeRecordViewMessages>;
|
|
567
567
|
}
|
|
568
568
|
/**
|
|
569
|
-
* The header menu: a button that lists the
|
|
569
|
+
* The header menu: a button that lists the record view's actions. On iOS an action sheet
|
|
570
570
|
* (ActionSheetIOS, destructive ones in red); elsewhere a sheet of rows, since Android's alert
|
|
571
571
|
* shows at most three buttons. A refused action stays listed and explains why when pressed.
|
|
572
572
|
*/
|
|
573
|
-
declare function
|
|
573
|
+
declare function NativeRecordViewMenu<T extends Row = Row>(props: NativeRecordViewHeaderProps<T> & {
|
|
574
574
|
testID?: string;
|
|
575
575
|
}): react.JSX.Element | null;
|
|
576
576
|
/**
|
|
577
|
-
* `<Stack.Screen options>` for a
|
|
577
|
+
* `<Stack.Screen options>` for a record view: the record's title in the navigation bar and the
|
|
578
578
|
* actions in the header menu.
|
|
579
579
|
*
|
|
580
580
|
* ```tsx
|
|
581
|
-
* <Stack.Screen options={
|
|
581
|
+
* <Stack.Screen options={getNativeRecordViewStackOptions({ view: brandRecordView, row: brand })} />
|
|
582
582
|
* ```
|
|
583
583
|
*/
|
|
584
|
-
declare function
|
|
585
|
-
interface
|
|
586
|
-
|
|
584
|
+
declare function getNativeRecordViewStackOptions<T extends Row>(props: NativeRecordViewHeaderProps<T> & Omit<ScreenHeaderProps, "headerTitle">): Record<string, unknown>;
|
|
585
|
+
interface NativeRecordViewProps<T extends Row = Row> {
|
|
586
|
+
view: AnyRecordView<T>;
|
|
587
587
|
/** The record, as the screen loaded it. A save refreshes it through the cache. */
|
|
588
588
|
row: T;
|
|
589
589
|
/**
|
|
@@ -606,22 +606,43 @@ interface NativeResourceWorkspaceProps<T extends Row = Row> {
|
|
|
606
606
|
slots?: Partial<Record<string, ReactNode>>;
|
|
607
607
|
/** More props for a list section's NativeResourceView, by section id. */
|
|
608
608
|
lists?: Partial<Record<string, Partial<Omit<NativeResourceViewProps, "view" | "filter">>>>;
|
|
609
|
-
messages?: Partial<
|
|
609
|
+
messages?: Partial<NativeRecordViewMessages>;
|
|
610
610
|
testID?: string;
|
|
611
611
|
}
|
|
612
612
|
/**
|
|
613
|
-
* One record's screen from
|
|
613
|
+
* One record's screen, from its record view (defineRecordView):
|
|
614
614
|
*
|
|
615
615
|
* ```tsx
|
|
616
|
-
* <Stack.Screen options={
|
|
617
|
-
* <
|
|
616
|
+
* <Stack.Screen options={getNativeRecordViewStackOptions({ view: brandRecordView, row: brand })} />
|
|
617
|
+
* <NativeRecordView view={brandRecordView} row={brand} />
|
|
618
618
|
* ```
|
|
619
619
|
*/
|
|
620
|
-
declare function
|
|
620
|
+
declare function NativeRecordView<T extends Row = Row>(props: NativeRecordViewProps<T>): react.JSX.Element;
|
|
621
|
+
type OldPage<P extends {
|
|
622
|
+
view: unknown;
|
|
623
|
+
}> = Omit<P, "view"> & {
|
|
624
|
+
workspace: P["view"];
|
|
625
|
+
};
|
|
626
|
+
/** @deprecated Renamed `NativeRecordViewProps`; its `workspace` prop is now `view`. */
|
|
627
|
+
type NativeResourceWorkspaceProps<T extends Row = Row> = OldPage<NativeRecordViewProps<T>>;
|
|
628
|
+
/** @deprecated Renamed `NativeRecordView`, with `view` in place of `workspace`. */
|
|
629
|
+
declare function NativeResourceWorkspace<T extends Row = Row>({ workspace, ...props }: NativeResourceWorkspaceProps<T>): react.JSX.Element;
|
|
630
|
+
/** @deprecated Renamed `NativeRecordViewMenu`, with `view` in place of `workspace`. */
|
|
631
|
+
declare function NativeResourceWorkspaceMenu<T extends Row = Row>({ workspace, ...props }: OldPage<NativeRecordViewHeaderProps<T>> & {
|
|
632
|
+
testID?: string;
|
|
633
|
+
}): react.JSX.Element;
|
|
634
|
+
/** @deprecated Renamed `getNativeRecordViewStackOptions`, with `view` in place of `workspace`. */
|
|
635
|
+
declare function getNativeResourceWorkspaceStackOptions<T extends Row>({ workspace, ...props }: OldPage<NativeRecordViewHeaderProps<T>> & Omit<ScreenHeaderProps, "headerTitle">): Record<string, unknown>;
|
|
636
|
+
/** @deprecated Renamed `NativeRecordViewHeaderProps`; its `workspace` prop is now `view`. */
|
|
637
|
+
type NativeResourceWorkspaceHeaderProps<T extends Row = Row> = OldPage<NativeRecordViewHeaderProps<T>>;
|
|
638
|
+
/** @deprecated Renamed `NativeRecordViewMessages`. */
|
|
639
|
+
type NativeResourceWorkspaceMessages = NativeRecordViewMessages;
|
|
640
|
+
/** @deprecated Renamed `defaultNativeRecordViewMessages`. */
|
|
641
|
+
declare const defaultNativeResourceWorkspaceMessages: NativeRecordViewMessages;
|
|
621
642
|
/**
|
|
622
643
|
* A number as typed: "1.5" or, with a comma as the decimal mark, "1,5". Anything else (an empty
|
|
623
644
|
* string aside) is an error, never NaN.
|
|
624
645
|
*/
|
|
625
646
|
declare function parseSettingNumber(text: string): number | null;
|
|
626
647
|
|
|
627
|
-
export { type AnyResourceView, DEFAULT_MAX_PAGES, type DisplayContext, type DisplayRenderer, type DisplayRenderers, DisplayRenderersProvider, type DisplayTimeZones, DisplayTimeZonesProvider, type NativeCardFieldDef, NativeDataFilters, type NativeDataFiltersProps, NativeDataPageShell, type NativeDataPageShellProps, type NativeDetailField, NativeDetailPanel, type NativeDetailPanelProps, NativeEmptyState, type NativeEmptyStateProps, type NativeFormField, type NativeFormFieldKind, NativeResourceForm, NativeResourceFormFieldRenderer, type NativeResourceFormFieldRendererProps, type NativeResourceFormProps, NativeResourceFormSheet, type NativeResourceFormSheetProps, NativeResourcePage, type NativeResourcePageProps, type NativeResourceRowItem, type NativeResourceScreenCan, type NativeResourceSection, type NativeResourceSwipeAction, type NativeResourceSwipeableProps, NativeResourceView, type NativeResourceViewMessages, NativeResourceViewMessagesProvider, type NativeResourceViewOptions, type NativeResourceViewProps, NativeResourceWorkspace, type NativeResourceWorkspaceHeaderProps, NativeResourceWorkspaceMenu, type NativeResourceWorkspaceMessages, type NativeResourceWorkspaceProps, SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, type SaveResult, type UseNativeResourceViewReturn, allowed, dateToDay, dayToDate, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
648
|
+
export { type AnyResourceView, DEFAULT_MAX_PAGES, type DisplayContext, type DisplayRenderer, type DisplayRenderers, DisplayRenderersProvider, type DisplayTimeZones, DisplayTimeZonesProvider, type NativeCardFieldDef, NativeDataFilters, type NativeDataFiltersProps, NativeDataPageShell, type NativeDataPageShellProps, type NativeDetailField, NativeDetailPanel, type NativeDetailPanelProps, NativeEmptyState, type NativeEmptyStateProps, type NativeFormField, type NativeFormFieldKind, NativeRecordView, type NativeRecordViewHeaderProps, NativeRecordViewMenu, type NativeRecordViewMessages, type NativeRecordViewProps, NativeResourceForm, NativeResourceFormFieldRenderer, type NativeResourceFormFieldRendererProps, type NativeResourceFormProps, NativeResourceFormSheet, type NativeResourceFormSheetProps, NativeResourcePage, type NativeResourcePageProps, type NativeResourceRowItem, type NativeResourceScreenCan, type NativeResourceSection, type NativeResourceSwipeAction, type NativeResourceSwipeableProps, NativeResourceView, type NativeResourceViewMessages, NativeResourceViewMessagesProvider, type NativeResourceViewOptions, type NativeResourceViewProps, NativeResourceWorkspace, type NativeResourceWorkspaceHeaderProps, NativeResourceWorkspaceMenu, type NativeResourceWorkspaceMessages, type NativeResourceWorkspaceProps, SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, type SaveResult, type UseNativeResourceViewReturn, allowed, dateToDay, dayToDate, defaultNativeRecordViewMessages, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeRecordViewStackOptions, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
package/dist/data/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { NativeListItem, NativeBadge, NativeText, NativeButton, NativeInput, use
|
|
|
5
5
|
import { useThemeRoles } from '../chunk-Z3AQYVUA.js';
|
|
6
6
|
import '../chunk-OHZD7KRO.js';
|
|
7
7
|
import '../chunk-DGUM43GV.js';
|
|
8
|
-
import { Platform, View, Pressable, Text, Linking, ScrollView, Alert, SectionList,
|
|
8
|
+
import { Platform, View, Pressable, Text, Linking, ScrollView, Alert, SectionList, ActionSheetIOS, FlatList } from 'react-native';
|
|
9
9
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
import { createContext, memo, useState, useCallback, useMemo, useEffect, useContext, useRef } from 'react';
|
|
@@ -1893,7 +1893,7 @@ function Screen(props) {
|
|
|
1893
1893
|
)
|
|
1894
1894
|
] });
|
|
1895
1895
|
}
|
|
1896
|
-
var
|
|
1896
|
+
var defaultNativeRecordViewMessages = {
|
|
1897
1897
|
actions: "Actions",
|
|
1898
1898
|
cancel: "Cancel",
|
|
1899
1899
|
save: "Save",
|
|
@@ -1912,11 +1912,11 @@ var defaultNativeResourceWorkspaceMessages = {
|
|
|
1912
1912
|
warnings: void 0
|
|
1913
1913
|
};
|
|
1914
1914
|
var SEGMENTED_SECTIONS_MAX = 4;
|
|
1915
|
-
function useHeaderActions({
|
|
1916
|
-
const words = { ...
|
|
1915
|
+
function useHeaderActions({ view: recordView, row, onAction, can, messages }) {
|
|
1916
|
+
const words = { ...defaultNativeRecordViewMessages, ...messages };
|
|
1917
1917
|
const provider = useDataProvider();
|
|
1918
1918
|
const queryClient = useQueryClient();
|
|
1919
|
-
const view =
|
|
1919
|
+
const view = recordView.view;
|
|
1920
1920
|
const capabilities = useCapabilities$1(view.resource, { enabled: !onAction && !!provider.capabilities });
|
|
1921
1921
|
const described = useQuery({
|
|
1922
1922
|
queryKey: ["__describe", view.resource],
|
|
@@ -1925,7 +1925,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
|
|
|
1925
1925
|
staleTime: Infinity
|
|
1926
1926
|
});
|
|
1927
1927
|
const viewer = useViewer$1();
|
|
1928
|
-
const actions =
|
|
1928
|
+
const actions = recordView.headerFor(row, {
|
|
1929
1929
|
viewer,
|
|
1930
1930
|
runnable: Boolean(onAction) || Boolean(provider.runAction) && capabilities.data?.actions !== false,
|
|
1931
1931
|
...!onAction && described.data?.actions ? { served: described.data.actions.map((a) => a.name) } : {},
|
|
@@ -1939,7 +1939,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
|
|
|
1939
1939
|
setPending(true);
|
|
1940
1940
|
try {
|
|
1941
1941
|
if (onAction) await onAction(a.name, row);
|
|
1942
|
-
else if (provider.runAction) await provider.runAction(view.resource, { id:
|
|
1942
|
+
else if (provider.runAction) await provider.runAction(view.resource, { id: recordView.recordId(row), action: a.name });
|
|
1943
1943
|
else throw new DataWriteError("error", fill(words.noRunner, { name: a.label }));
|
|
1944
1944
|
await queryClient.invalidateQueries({ queryKey: [...resourceKeys(view.resource).all] });
|
|
1945
1945
|
} catch (error) {
|
|
@@ -1961,7 +1961,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
|
|
|
1961
1961
|
return { actions, press, pending, words };
|
|
1962
1962
|
}
|
|
1963
1963
|
var A11Y_PREFIX = "action:";
|
|
1964
|
-
function
|
|
1964
|
+
function NativeRecordViewMenu(props) {
|
|
1965
1965
|
const { testID = "native-resource-workspace-menu" } = props;
|
|
1966
1966
|
const { actions, press, pending, words } = useHeaderActions(props);
|
|
1967
1967
|
const [open, setOpen] = useState(false);
|
|
@@ -1972,7 +1972,7 @@ function NativeResourceWorkspaceMenu(props) {
|
|
|
1972
1972
|
const destructive = actions.flatMap((a, i) => a.destructive ? [i] : []);
|
|
1973
1973
|
ActionSheetIOS.showActionSheetWithOptions(
|
|
1974
1974
|
{
|
|
1975
|
-
title: props.
|
|
1975
|
+
title: props.view.headerFor(props.row).title,
|
|
1976
1976
|
options: [...actions.map(labelOf), words.cancel],
|
|
1977
1977
|
cancelButtonIndex: actions.length,
|
|
1978
1978
|
...destructive.length ? { destructiveButtonIndex: destructive } : {}
|
|
@@ -2030,28 +2030,28 @@ function NativeResourceWorkspaceMenu(props) {
|
|
|
2030
2030
|
] }) })
|
|
2031
2031
|
] });
|
|
2032
2032
|
}
|
|
2033
|
-
function
|
|
2034
|
-
const {
|
|
2035
|
-
const menu = {
|
|
2033
|
+
function getNativeRecordViewStackOptions(props) {
|
|
2034
|
+
const { view: recordView, row, onAction, can, messages, ...header } = props;
|
|
2035
|
+
const menu = { view: recordView, row, ...onAction ? { onAction } : {}, ...can ? { can } : {}, ...messages ? { messages } : {} };
|
|
2036
2036
|
return composeHeaderOptions({
|
|
2037
2037
|
...header,
|
|
2038
|
-
headerTitle:
|
|
2039
|
-
headerRight: header.headerRight ?? (
|
|
2038
|
+
headerTitle: recordView.headerFor(row).title,
|
|
2039
|
+
headerRight: header.headerRight ?? (recordView.headerActions.length ? () => /* @__PURE__ */ jsx(NativeRecordViewMenu, { ...menu }) : void 0)
|
|
2040
2040
|
});
|
|
2041
2041
|
}
|
|
2042
|
-
function
|
|
2043
|
-
const {
|
|
2044
|
-
const words = { ...
|
|
2042
|
+
function NativeRecordView(props) {
|
|
2043
|
+
const { view: recordView, row, section, onSectionChange, onOpenSection, onSaved, switcher, slots, lists, messages, testID = "native-resource-workspace" } = props;
|
|
2044
|
+
const words = { ...defaultNativeRecordViewMessages, ...messages };
|
|
2045
2045
|
const colors = useThemeRoles();
|
|
2046
2046
|
const queryClient = useQueryClient();
|
|
2047
2047
|
const record = row;
|
|
2048
|
-
const sections =
|
|
2048
|
+
const sections = recordView.sections;
|
|
2049
2049
|
const many = sections.length > SEGMENTED_SECTIONS_MAX;
|
|
2050
2050
|
const [local, setLocal] = useState(void 0);
|
|
2051
2051
|
const activeId = section ?? local ?? (many ? void 0 : sections[0]?.id);
|
|
2052
|
-
const active = activeId ?
|
|
2053
|
-
const readiness =
|
|
2054
|
-
const summary =
|
|
2052
|
+
const active = activeId ? recordView.section(activeId) : void 0;
|
|
2053
|
+
const readiness = recordView.readinessFor(record);
|
|
2054
|
+
const summary = recordView.readinessSummary(record);
|
|
2055
2055
|
const chip = summary ? readinessChip(summary, words) : null;
|
|
2056
2056
|
const choose = (id) => {
|
|
2057
2057
|
if (many && onOpenSection) return onOpenSection(id);
|
|
@@ -2103,7 +2103,7 @@ function NativeResourceWorkspace(props) {
|
|
|
2103
2103
|
testID: `${testID}-list`,
|
|
2104
2104
|
...lists?.[active.id],
|
|
2105
2105
|
title: false,
|
|
2106
|
-
filter:
|
|
2106
|
+
filter: recordView.listFilter(active.id, record)
|
|
2107
2107
|
},
|
|
2108
2108
|
active.id
|
|
2109
2109
|
);
|
|
@@ -2111,17 +2111,17 @@ function NativeResourceWorkspace(props) {
|
|
|
2111
2111
|
body = /* @__PURE__ */ jsx(ScrollView, { contentContainerStyle: { padding: 16 }, keyboardShouldPersistTaps: "handled", children: /* @__PURE__ */ jsx(
|
|
2112
2112
|
SettingsGroup,
|
|
2113
2113
|
{
|
|
2114
|
-
|
|
2114
|
+
recordView,
|
|
2115
2115
|
sectionId: active.id,
|
|
2116
2116
|
row: record,
|
|
2117
2117
|
words,
|
|
2118
2118
|
onSaved: (saved) => {
|
|
2119
|
-
void queryClient.invalidateQueries({ queryKey: [...resourceKeys(
|
|
2119
|
+
void queryClient.invalidateQueries({ queryKey: [...resourceKeys(recordView.view.resource).all] });
|
|
2120
2120
|
onSaved?.(saved);
|
|
2121
2121
|
},
|
|
2122
2122
|
testID: `${testID}-settings`
|
|
2123
2123
|
},
|
|
2124
|
-
`${String(
|
|
2124
|
+
`${String(recordView.recordId(record))}:${active.id}`
|
|
2125
2125
|
) });
|
|
2126
2126
|
} else if (active) {
|
|
2127
2127
|
body = slots?.[active.id] ?? null;
|
|
@@ -2133,7 +2133,7 @@ function NativeResourceWorkspace(props) {
|
|
|
2133
2133
|
] });
|
|
2134
2134
|
}
|
|
2135
2135
|
function SettingsGroup({
|
|
2136
|
-
|
|
2136
|
+
recordView,
|
|
2137
2137
|
sectionId,
|
|
2138
2138
|
row,
|
|
2139
2139
|
words,
|
|
@@ -2141,13 +2141,13 @@ function SettingsGroup({
|
|
|
2141
2141
|
testID
|
|
2142
2142
|
}) {
|
|
2143
2143
|
const provider = useDataProvider();
|
|
2144
|
-
const view =
|
|
2144
|
+
const view = recordView.view;
|
|
2145
2145
|
const fields = useMemo(() => {
|
|
2146
2146
|
const byKey = new Map(formFieldsFor(view, "edit").map((f) => [f.key, f]));
|
|
2147
|
-
return
|
|
2148
|
-
}, [
|
|
2147
|
+
return recordView.settingsFields(sectionId).map((f) => byKey.get(f.field.name)).filter((f) => !!f && !f.readOnly);
|
|
2148
|
+
}, [recordView, view, sectionId]);
|
|
2149
2149
|
const viewer = useViewer$1();
|
|
2150
|
-
const locked =
|
|
2150
|
+
const locked = recordView.settingsLocked(row, viewer);
|
|
2151
2151
|
const [draft, setDraft] = useState(() => Object.fromEntries(fields.map((f) => [f.key, row[f.key]])));
|
|
2152
2152
|
const [invalid, setInvalid] = useState({});
|
|
2153
2153
|
const [saving, setSaving] = useState(false);
|
|
@@ -2165,7 +2165,7 @@ function SettingsGroup({
|
|
|
2165
2165
|
setSaving(true);
|
|
2166
2166
|
setRefusal(null);
|
|
2167
2167
|
try {
|
|
2168
|
-
const result = await provider.update(view.resource, { id:
|
|
2168
|
+
const result = await provider.update(view.resource, { id: recordView.recordId(row), data: recordView.settingsPatch(sectionId, changed) });
|
|
2169
2169
|
if (!result || result.data === null || result.data === void 0) setRefusal(fill(words.notChanged, { noun: view.noun }));
|
|
2170
2170
|
else onSaved(result.data);
|
|
2171
2171
|
} catch (error) {
|
|
@@ -2177,7 +2177,7 @@ function SettingsGroup({
|
|
|
2177
2177
|
return /* @__PURE__ */ jsxs(View, { style: { gap: 12 }, children: [
|
|
2178
2178
|
refusal ? /* @__PURE__ */ jsx(NativeInlineAlert, { testID: `${testID}-refusal`, variant: "destructive", description: refusal }) : null,
|
|
2179
2179
|
locked !== null ? /* @__PURE__ */ jsx(NativeInlineAlert, { testID: `${testID}-locked`, variant: "info", description: locked }) : null,
|
|
2180
|
-
/* @__PURE__ */ jsx(Group, { testID: `${testID}-group`, title:
|
|
2180
|
+
/* @__PURE__ */ jsx(Group, { testID: `${testID}-group`, title: recordView.section(sectionId)?.label, children: shown.map((f, i) => /* @__PURE__ */ jsx(Cell, { last: i === shown.length - 1, children: /* @__PURE__ */ jsx(
|
|
2181
2181
|
SettingRow,
|
|
2182
2182
|
{
|
|
2183
2183
|
field: f,
|
|
@@ -2193,6 +2193,19 @@ function SettingsGroup({
|
|
|
2193
2193
|
locked === null ? /* @__PURE__ */ jsx(NativeButton, { testID: `${testID}-save`, disabled: !dirty || saving, loading: saving, onPress: () => void save(), children: words.save }) : null
|
|
2194
2194
|
] });
|
|
2195
2195
|
}
|
|
2196
|
+
function NativeResourceWorkspace({ workspace, ...props }) {
|
|
2197
|
+
return /* @__PURE__ */ jsx(NativeRecordView, { ...props, view: workspace });
|
|
2198
|
+
}
|
|
2199
|
+
function NativeResourceWorkspaceMenu({ workspace, ...props }) {
|
|
2200
|
+
return /* @__PURE__ */ jsx(NativeRecordViewMenu, { ...props, view: workspace });
|
|
2201
|
+
}
|
|
2202
|
+
function getNativeResourceWorkspaceStackOptions({
|
|
2203
|
+
workspace,
|
|
2204
|
+
...props
|
|
2205
|
+
}) {
|
|
2206
|
+
return getNativeRecordViewStackOptions({ ...props, view: workspace });
|
|
2207
|
+
}
|
|
2208
|
+
var defaultNativeResourceWorkspaceMessages = defaultNativeRecordViewMessages;
|
|
2196
2209
|
function parseSettingNumber(text2) {
|
|
2197
2210
|
const t = text2.trim();
|
|
2198
2211
|
const normalised = /^-?\d+,\d+$/.test(t) ? t.replace(",", ".") : t;
|
|
@@ -2298,6 +2311,6 @@ function Cell({ last, children }) {
|
|
|
2298
2311
|
] });
|
|
2299
2312
|
}
|
|
2300
2313
|
|
|
2301
|
-
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, SEARCH_DEBOUNCE_MS, SEGMENTED_SECTIONS_MAX, allowed, dateToDay, dayToDate, defaultNativeResourceViewMessages, defaultNativeResourceWorkspaceMessages, displayText, formFieldsFor, formatDay, formatInstant, getNativeResourceWorkspaceStackOptions, nativeDisplayRenderers, openableUrl, parseSettingNumber, resolveZone, rowItem, screenValues, sectionsFor, serverSort, serverSorts, swipeActionsFor, useDisplayCell, useDisplayTimeZones, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
2314
|
+
export { DEFAULT_MAX_PAGES, DisplayRenderersProvider, DisplayTimeZonesProvider, NativeDataFilters, NativeDataPageShell, NativeDetailPanel, NativeEmptyState2 as NativeEmptyState, NativeRecordView, NativeRecordViewMenu, NativeResourceForm, NativeResourceFormFieldRenderer, NativeResourceFormSheet, NativeResourcePage, NativeResourceView, NativeResourceViewMessagesProvider, NativeResourceWorkspace, NativeResourceWorkspaceMenu, 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, useNativeResourceView, useNativeResourceViewMessages, validateValues, writableValues };
|
|
2302
2315
|
//# sourceMappingURL=index.js.map
|
|
2303
2316
|
//# sourceMappingURL=index.js.map
|