@marktiderman/genesis-ui-native 3.0.0 → 3.2.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.
@@ -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, Allowed, Viewer, ResolvedColumn, ResourceWorkspace } from '@marktiderman/genesis-core/resource-view';
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';
@@ -274,6 +274,10 @@ interface NativeFormField {
274
274
  required: boolean;
275
275
  /** Shown as text, never as an input, and never sent. */
276
276
  readOnly: boolean;
277
+ /** From the contract: the column takes null. Unset when the contract doesn't say. */
278
+ nullable?: boolean;
279
+ /** From the contract: the column has a default (or is generated). */
280
+ hasDefault?: boolean;
277
281
  max?: number;
278
282
  options?: {
279
283
  value: string;
@@ -306,14 +310,15 @@ declare function writableValues<T extends Row$3>(view: AnyResourceView<T>, mode:
306
310
  declare function validateValues(fields: readonly NativeFormField[], values: Readonly<Record<string, unknown>>, messages: NativeResourceViewMessages): Record<string, string>;
307
311
 
308
312
  type Row$2 = Record<string, unknown>;
309
- type Filter = Readonly<Record<string, string | number | boolean | null>>;
313
+ type Filter = Readonly<Record<string, string | number | boolean | null | readonly (string | number)[]>>;
310
314
  /** How long typing waits before the search goes to the server. */
311
315
  declare const SEARCH_DEBOUNCE_MS = 300;
312
316
  interface NativeResourceViewOptions<T extends Row$2 = Row$2> {
313
317
  /** A tab the view defines: its server filter. */
314
318
  preset?: string;
315
319
  /**
316
- * Equality filters sent to the server (`{ client_id: id }`); `null` means "is empty". A create
320
+ * Filters sent to the server (`{ client_id: id }`); `null` means "is empty" and a list means
321
+ * "any of" (`{ status: ["open", "blocked"] }`, sent as `in`; a create never takes a list). A create
317
322
  * also saves every non-null value here (a tab's filter too), even for read-only fields such as
318
323
  * a required link: they come from the screen, never from an input. An edit never sends them.
319
324
  */
@@ -526,13 +531,13 @@ declare function useNativeResourceViewMessages(): NativeResourceViewMessages;
526
531
  declare function useDisplayCell(): (column: ResolvedColumn<Record<string, unknown>>, row: Record<string, unknown>) => ReactNode;
527
532
 
528
533
  type Row = Record<string, unknown>;
529
- type AnyWorkspace<T extends Row> = ResourceWorkspace<ResourceContract<any>, T & DataRow>;
534
+ type AnyRecordView<T extends Row> = RecordView<ResourceContract<any>, T & DataRow>;
530
535
  /**
531
- * The words NativeResourceWorkspace shows. Override any of them with `messages`. The readiness
536
+ * The words NativeRecordView shows. Override any of them with `messages`. The readiness
532
537
  * chip's keys (`ready`, `empty`, `pending`, `problems`, `warnings`) are genesis-core/resource's
533
538
  * `readinessChip` labels: unset, they use its defaults.
534
539
  */
535
- interface NativeResourceWorkspaceMessages extends ReadinessLabels {
540
+ interface NativeRecordViewMessages extends ReadinessLabels {
536
541
  actions: string;
537
542
  cancel: string;
538
543
  save: string;
@@ -548,37 +553,37 @@ interface NativeResourceWorkspaceMessages extends ReadinessLabels {
548
553
  allSections: string;
549
554
  notANumber: string;
550
555
  }
551
- declare const defaultNativeResourceWorkspaceMessages: NativeResourceWorkspaceMessages;
556
+ declare const defaultNativeRecordViewMessages: NativeRecordViewMessages;
552
557
  /** Up to this many sections show as a segmented control; more are pushed rows. */
553
558
  declare const SEGMENTED_SECTIONS_MAX = 4;
554
- interface NativeResourceWorkspaceHeaderProps<T extends Row = Row> {
555
- workspace: AnyWorkspace<T>;
559
+ interface NativeRecordViewHeaderProps<T extends Row = Row> {
560
+ view: AnyRecordView<T>;
556
561
  row: T;
557
562
  /** Runs an allowed (and confirmed) action. Default: the provider's `runAction`. */
558
563
  onAction?: (name: string, row: T) => unknown;
559
564
  /** The screen's own rule: `false` hides an action, a sentence refuses it. Only narrows. */
560
565
  can?: (action: string, row: T) => Allowed | boolean;
561
- messages?: Partial<NativeResourceWorkspaceMessages>;
566
+ messages?: Partial<NativeRecordViewMessages>;
562
567
  }
563
568
  /**
564
- * The header menu: a button that lists the workspace's actions. On iOS an action sheet
569
+ * The header menu: a button that lists the record view's actions. On iOS an action sheet
565
570
  * (ActionSheetIOS, destructive ones in red); elsewhere a sheet of rows, since Android's alert
566
571
  * shows at most three buttons. A refused action stays listed and explains why when pressed.
567
572
  */
568
- declare function NativeResourceWorkspaceMenu<T extends Row = Row>(props: NativeResourceWorkspaceHeaderProps<T> & {
573
+ declare function NativeRecordViewMenu<T extends Row = Row>(props: NativeRecordViewHeaderProps<T> & {
569
574
  testID?: string;
570
575
  }): react.JSX.Element | null;
571
576
  /**
572
- * `<Stack.Screen options>` for a workspace: the record's title in the navigation bar and the
577
+ * `<Stack.Screen options>` for a record view: the record's title in the navigation bar and the
573
578
  * actions in the header menu.
574
579
  *
575
580
  * ```tsx
576
- * <Stack.Screen options={getNativeResourceWorkspaceStackOptions({ workspace: brandWorkspace, row: brand })} />
581
+ * <Stack.Screen options={getNativeRecordViewStackOptions({ view: brandRecordView, row: brand })} />
577
582
  * ```
578
583
  */
579
- declare function getNativeResourceWorkspaceStackOptions<T extends Row>(props: NativeResourceWorkspaceHeaderProps<T> & Omit<ScreenHeaderProps, "headerTitle">): Record<string, unknown>;
580
- interface NativeResourceWorkspaceProps<T extends Row = Row> {
581
- workspace: AnyWorkspace<T>;
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>;
582
587
  /** The record, as the screen loaded it. A save refreshes it through the cache. */
583
588
  row: T;
584
589
  /**
@@ -601,22 +606,43 @@ interface NativeResourceWorkspaceProps<T extends Row = Row> {
601
606
  slots?: Partial<Record<string, ReactNode>>;
602
607
  /** More props for a list section's NativeResourceView, by section id. */
603
608
  lists?: Partial<Record<string, Partial<Omit<NativeResourceViewProps, "view" | "filter">>>>;
604
- messages?: Partial<NativeResourceWorkspaceMessages>;
609
+ messages?: Partial<NativeRecordViewMessages>;
605
610
  testID?: string;
606
611
  }
607
612
  /**
608
- * One record's screen from a workspace:
613
+ * One record's screen, from its record view (defineRecordView):
609
614
  *
610
615
  * ```tsx
611
- * <Stack.Screen options={getNativeResourceWorkspaceStackOptions({ workspace: brandWorkspace, row: brand })} />
612
- * <NativeResourceWorkspace workspace={brandWorkspace} row={brand} />
616
+ * <Stack.Screen options={getNativeRecordViewStackOptions({ view: brandRecordView, row: brand })} />
617
+ * <NativeRecordView view={brandRecordView} row={brand} />
613
618
  * ```
614
619
  */
615
- declare function NativeResourceWorkspace<T extends Row = Row>(props: NativeResourceWorkspaceProps<T>): react.JSX.Element;
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;
616
642
  /**
617
643
  * A number as typed: "1.5" or, with a comma as the decimal mark, "1,5". Anything else (an empty
618
644
  * string aside) is an error, never NaN.
619
645
  */
620
646
  declare function parseSettingNumber(text: string): number | null;
621
647
 
622
- 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 };
@@ -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, FlatList, ActionSheetIOS } from 'react-native';
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';
@@ -1123,6 +1123,8 @@ function formFieldsFor(view, mode) {
1123
1123
  display: f.display,
1124
1124
  required: !readOnly && f.required,
1125
1125
  readOnly,
1126
+ ...typeof f.field.nullable === "boolean" ? { nullable: f.field.nullable } : {},
1127
+ ...f.field.hasDefault || f.field.generated ? { hasDefault: true } : {},
1126
1128
  ...f.max !== void 0 ? { max: f.max } : {},
1127
1129
  ...options ? { options } : {},
1128
1130
  ...f.field.references ? { references: f.field.references } : {},
@@ -1144,10 +1146,17 @@ function writableValues(view, mode, fields, values, dirty) {
1144
1146
  if (field.readOnly || !writable.has(field.key)) continue;
1145
1147
  if (dirty && !dirty.has(field.key)) continue;
1146
1148
  const value = values[field.key];
1147
- out[field.key] = (value === "" || value === void 0) && !field.required ? null : value;
1149
+ if (value !== "" && value !== void 0 || field.required) {
1150
+ out[field.key] = value;
1151
+ continue;
1152
+ }
1153
+ if (field.nullable === void 0) out[field.key] = null;
1154
+ else if (TEXT_KINDS.has(field.kind) && !field.nullable && !(mode === "create" && field.hasDefault)) out[field.key] = "";
1155
+ else if (mode === "edit") out[field.key] = null;
1148
1156
  }
1149
1157
  return out;
1150
1158
  }
1159
+ var TEXT_KINDS = /* @__PURE__ */ new Set(["text", "email", "url", "textarea"]);
1151
1160
  function validateValues(fields, values, messages) {
1152
1161
  const errors = {};
1153
1162
  for (const field of shownFields(fields, values)) {
@@ -1388,13 +1397,15 @@ function DateField({
1388
1397
  var SEARCH_DEBOUNCE_MS = 300;
1389
1398
  function filterParams(filter) {
1390
1399
  return Object.entries(filter ?? {}).map(
1391
- ([field, value]) => value === null ? { field, operator: "is_null" } : { field, operator: "eq", value }
1400
+ ([field, value]) => value === null ? { field, operator: "is_null" } : Array.isArray(value) ? { field, operator: "in", value: [...value] } : { field, operator: "eq", value }
1392
1401
  );
1393
1402
  }
1394
1403
  function screenValues(...filters) {
1395
1404
  const out = {};
1396
1405
  for (const filter of filters) {
1397
- for (const [field, value] of Object.entries(filter ?? {})) if (value !== null) out[field] = value;
1406
+ for (const [field, value] of Object.entries(filter ?? {})) {
1407
+ if (value !== null && !Array.isArray(value)) out[field] = value;
1408
+ }
1398
1409
  }
1399
1410
  return out;
1400
1411
  }
@@ -1416,7 +1427,11 @@ function useNativeResourceView(view, options = {}) {
1416
1427
  const tab = preset ? view.definition.presets?.[preset] : void 0;
1417
1428
  if (preset && !tab) throw new Error(`NativeResourceView(${view.resource}): no preset "${preset}"`);
1418
1429
  const tabFilter = tab?.filter;
1419
- const defaultFilters = useMemo(() => [...filterParams(tabFilter), ...filterParams(filter)], [tabFilter, filter]);
1430
+ const filterKey = JSON.stringify(filter ?? {});
1431
+ const defaultFilters = useMemo(
1432
+ () => [...filterParams(tabFilter), ...filterParams(JSON.parse(filterKey))],
1433
+ [tabFilter, filterKey]
1434
+ );
1420
1435
  const createKey = JSON.stringify(screenValues(tabFilter, filter));
1421
1436
  const createDefaults = useMemo(() => JSON.parse(createKey), [createKey]);
1422
1437
  const sorts = useMemo(() => serverSorts(view), [view]);
@@ -1878,7 +1893,7 @@ function Screen(props) {
1878
1893
  )
1879
1894
  ] });
1880
1895
  }
1881
- var defaultNativeResourceWorkspaceMessages = {
1896
+ var defaultNativeRecordViewMessages = {
1882
1897
  actions: "Actions",
1883
1898
  cancel: "Cancel",
1884
1899
  save: "Save",
@@ -1897,11 +1912,11 @@ var defaultNativeResourceWorkspaceMessages = {
1897
1912
  warnings: void 0
1898
1913
  };
1899
1914
  var SEGMENTED_SECTIONS_MAX = 4;
1900
- function useHeaderActions({ workspace, row, onAction, can, messages }) {
1901
- const words = { ...defaultNativeResourceWorkspaceMessages, ...messages };
1915
+ function useHeaderActions({ view: recordView, row, onAction, can, messages }) {
1916
+ const words = { ...defaultNativeRecordViewMessages, ...messages };
1902
1917
  const provider = useDataProvider();
1903
1918
  const queryClient = useQueryClient();
1904
- const view = workspace.view;
1919
+ const view = recordView.view;
1905
1920
  const capabilities = useCapabilities$1(view.resource, { enabled: !onAction && !!provider.capabilities });
1906
1921
  const described = useQuery({
1907
1922
  queryKey: ["__describe", view.resource],
@@ -1910,7 +1925,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
1910
1925
  staleTime: Infinity
1911
1926
  });
1912
1927
  const viewer = useViewer$1();
1913
- const actions = workspace.headerFor(row, {
1928
+ const actions = recordView.headerFor(row, {
1914
1929
  viewer,
1915
1930
  runnable: Boolean(onAction) || Boolean(provider.runAction) && capabilities.data?.actions !== false,
1916
1931
  ...!onAction && described.data?.actions ? { served: described.data.actions.map((a) => a.name) } : {},
@@ -1924,7 +1939,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
1924
1939
  setPending(true);
1925
1940
  try {
1926
1941
  if (onAction) await onAction(a.name, row);
1927
- else if (provider.runAction) await provider.runAction(view.resource, { id: workspace.recordId(row), action: a.name });
1942
+ else if (provider.runAction) await provider.runAction(view.resource, { id: recordView.recordId(row), action: a.name });
1928
1943
  else throw new DataWriteError("error", fill(words.noRunner, { name: a.label }));
1929
1944
  await queryClient.invalidateQueries({ queryKey: [...resourceKeys(view.resource).all] });
1930
1945
  } catch (error) {
@@ -1946,7 +1961,7 @@ function useHeaderActions({ workspace, row, onAction, can, messages }) {
1946
1961
  return { actions, press, pending, words };
1947
1962
  }
1948
1963
  var A11Y_PREFIX = "action:";
1949
- function NativeResourceWorkspaceMenu(props) {
1964
+ function NativeRecordViewMenu(props) {
1950
1965
  const { testID = "native-resource-workspace-menu" } = props;
1951
1966
  const { actions, press, pending, words } = useHeaderActions(props);
1952
1967
  const [open, setOpen] = useState(false);
@@ -1957,7 +1972,7 @@ function NativeResourceWorkspaceMenu(props) {
1957
1972
  const destructive = actions.flatMap((a, i) => a.destructive ? [i] : []);
1958
1973
  ActionSheetIOS.showActionSheetWithOptions(
1959
1974
  {
1960
- title: props.workspace.headerFor(props.row).title,
1975
+ title: props.view.headerFor(props.row).title,
1961
1976
  options: [...actions.map(labelOf), words.cancel],
1962
1977
  cancelButtonIndex: actions.length,
1963
1978
  ...destructive.length ? { destructiveButtonIndex: destructive } : {}
@@ -2015,28 +2030,28 @@ function NativeResourceWorkspaceMenu(props) {
2015
2030
  ] }) })
2016
2031
  ] });
2017
2032
  }
2018
- function getNativeResourceWorkspaceStackOptions(props) {
2019
- const { workspace, row, onAction, can, messages, ...header } = props;
2020
- const menu = { workspace, row, ...onAction ? { onAction } : {}, ...can ? { can } : {}, ...messages ? { messages } : {} };
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 } : {} };
2021
2036
  return composeHeaderOptions({
2022
2037
  ...header,
2023
- headerTitle: workspace.headerFor(row).title,
2024
- headerRight: header.headerRight ?? (workspace.headerActions.length ? () => /* @__PURE__ */ jsx(NativeResourceWorkspaceMenu, { ...menu }) : void 0)
2038
+ headerTitle: recordView.headerFor(row).title,
2039
+ headerRight: header.headerRight ?? (recordView.headerActions.length ? () => /* @__PURE__ */ jsx(NativeRecordViewMenu, { ...menu }) : void 0)
2025
2040
  });
2026
2041
  }
2027
- function NativeResourceWorkspace(props) {
2028
- const { workspace, row, section, onSectionChange, onOpenSection, onSaved, switcher, slots, lists, messages, testID = "native-resource-workspace" } = props;
2029
- const words = { ...defaultNativeResourceWorkspaceMessages, ...messages };
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 };
2030
2045
  const colors = useThemeRoles();
2031
2046
  const queryClient = useQueryClient();
2032
2047
  const record = row;
2033
- const sections = workspace.sections;
2048
+ const sections = recordView.sections;
2034
2049
  const many = sections.length > SEGMENTED_SECTIONS_MAX;
2035
2050
  const [local, setLocal] = useState(void 0);
2036
2051
  const activeId = section ?? local ?? (many ? void 0 : sections[0]?.id);
2037
- const active = activeId ? workspace.section(activeId) : void 0;
2038
- const readiness = workspace.readinessFor(record);
2039
- const summary = workspace.readinessSummary(record);
2052
+ const active = activeId ? recordView.section(activeId) : void 0;
2053
+ const readiness = recordView.readinessFor(record);
2054
+ const summary = recordView.readinessSummary(record);
2040
2055
  const chip = summary ? readinessChip(summary, words) : null;
2041
2056
  const choose = (id) => {
2042
2057
  if (many && onOpenSection) return onOpenSection(id);
@@ -2088,7 +2103,7 @@ function NativeResourceWorkspace(props) {
2088
2103
  testID: `${testID}-list`,
2089
2104
  ...lists?.[active.id],
2090
2105
  title: false,
2091
- filter: workspace.listFilter(active.id, record)
2106
+ filter: recordView.listFilter(active.id, record)
2092
2107
  },
2093
2108
  active.id
2094
2109
  );
@@ -2096,17 +2111,17 @@ function NativeResourceWorkspace(props) {
2096
2111
  body = /* @__PURE__ */ jsx(ScrollView, { contentContainerStyle: { padding: 16 }, keyboardShouldPersistTaps: "handled", children: /* @__PURE__ */ jsx(
2097
2112
  SettingsGroup,
2098
2113
  {
2099
- workspace,
2114
+ recordView,
2100
2115
  sectionId: active.id,
2101
2116
  row: record,
2102
2117
  words,
2103
2118
  onSaved: (saved) => {
2104
- void queryClient.invalidateQueries({ queryKey: [...resourceKeys(workspace.view.resource).all] });
2119
+ void queryClient.invalidateQueries({ queryKey: [...resourceKeys(recordView.view.resource).all] });
2105
2120
  onSaved?.(saved);
2106
2121
  },
2107
2122
  testID: `${testID}-settings`
2108
2123
  },
2109
- `${String(workspace.recordId(record))}:${active.id}`
2124
+ `${String(recordView.recordId(record))}:${active.id}`
2110
2125
  ) });
2111
2126
  } else if (active) {
2112
2127
  body = slots?.[active.id] ?? null;
@@ -2118,7 +2133,7 @@ function NativeResourceWorkspace(props) {
2118
2133
  ] });
2119
2134
  }
2120
2135
  function SettingsGroup({
2121
- workspace,
2136
+ recordView,
2122
2137
  sectionId,
2123
2138
  row,
2124
2139
  words,
@@ -2126,13 +2141,13 @@ function SettingsGroup({
2126
2141
  testID
2127
2142
  }) {
2128
2143
  const provider = useDataProvider();
2129
- const view = workspace.view;
2144
+ const view = recordView.view;
2130
2145
  const fields = useMemo(() => {
2131
2146
  const byKey = new Map(formFieldsFor(view, "edit").map((f) => [f.key, f]));
2132
- return workspace.settingsFields(sectionId).map((f) => byKey.get(f.field.name)).filter((f) => !!f && !f.readOnly);
2133
- }, [workspace, view, sectionId]);
2147
+ return recordView.settingsFields(sectionId).map((f) => byKey.get(f.field.name)).filter((f) => !!f && !f.readOnly);
2148
+ }, [recordView, view, sectionId]);
2134
2149
  const viewer = useViewer$1();
2135
- const locked = workspace.settingsLocked(row, viewer);
2150
+ const locked = recordView.settingsLocked(row, viewer);
2136
2151
  const [draft, setDraft] = useState(() => Object.fromEntries(fields.map((f) => [f.key, row[f.key]])));
2137
2152
  const [invalid, setInvalid] = useState({});
2138
2153
  const [saving, setSaving] = useState(false);
@@ -2150,7 +2165,7 @@ function SettingsGroup({
2150
2165
  setSaving(true);
2151
2166
  setRefusal(null);
2152
2167
  try {
2153
- const result = await provider.update(view.resource, { id: workspace.recordId(row), data: workspace.settingsPatch(sectionId, changed) });
2168
+ const result = await provider.update(view.resource, { id: recordView.recordId(row), data: recordView.settingsPatch(sectionId, changed) });
2154
2169
  if (!result || result.data === null || result.data === void 0) setRefusal(fill(words.notChanged, { noun: view.noun }));
2155
2170
  else onSaved(result.data);
2156
2171
  } catch (error) {
@@ -2162,7 +2177,7 @@ function SettingsGroup({
2162
2177
  return /* @__PURE__ */ jsxs(View, { style: { gap: 12 }, children: [
2163
2178
  refusal ? /* @__PURE__ */ jsx(NativeInlineAlert, { testID: `${testID}-refusal`, variant: "destructive", description: refusal }) : null,
2164
2179
  locked !== null ? /* @__PURE__ */ jsx(NativeInlineAlert, { testID: `${testID}-locked`, variant: "info", description: locked }) : null,
2165
- /* @__PURE__ */ jsx(Group, { testID: `${testID}-group`, title: workspace.section(sectionId)?.label, children: shown.map((f, i) => /* @__PURE__ */ jsx(Cell, { last: i === shown.length - 1, children: /* @__PURE__ */ jsx(
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(
2166
2181
  SettingRow,
2167
2182
  {
2168
2183
  field: f,
@@ -2178,6 +2193,19 @@ function SettingsGroup({
2178
2193
  locked === null ? /* @__PURE__ */ jsx(NativeButton, { testID: `${testID}-save`, disabled: !dirty || saving, loading: saving, onPress: () => void save(), children: words.save }) : null
2179
2194
  ] });
2180
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;
2181
2209
  function parseSettingNumber(text2) {
2182
2210
  const t = text2.trim();
2183
2211
  const normalised = /^-?\d+,\d+$/.test(t) ? t.replace(",", ".") : t;
@@ -2283,6 +2311,6 @@ function Cell({ last, children }) {
2283
2311
  ] });
2284
2312
  }
2285
2313
 
2286
- 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 };
2287
2315
  //# sourceMappingURL=index.js.map
2288
2316
  //# sourceMappingURL=index.js.map