@marktiderman/genesis-ui-native 2.9.0 → 3.0.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.
@@ -431,10 +431,11 @@ interface NativeResourceViewProps<T extends Row$1 = Row$1> extends NativeResourc
431
431
  /** Hide the search box. Shown by default when the view has something to search. */
432
432
  searchable?: boolean;
433
433
  /**
434
- * The practice's IANA zone, for columns with `timeZone: "practice"`. Timestamps otherwise read
435
- * on the viewer's clock (ViewerScope's zone, else the device's).
434
+ * The IANA zone of whatever this screen is scoped to (a location, a league, a team), for columns
435
+ * with `timeZone: "scope"`. Default: ViewerScope's `scopeTimeZone`, else the viewer's clock.
436
+ * Timestamps on other columns read on the viewer's clock (ViewerScope's zone, else the device's).
436
437
  */
437
- practiceTimeZone?: string;
438
+ scopeTimeZone?: string;
438
439
  testID?: string;
439
440
  }
440
441
  /**
@@ -465,10 +466,11 @@ interface NativeResourceFormSheetProps {
465
466
  }
466
467
  declare function NativeResourceFormSheet({ open, mode, title, fields, initial, loading, recordKey, onCancel, onSave, testID, }: NativeResourceFormSheetProps): react.JSX.Element;
467
468
 
468
- /** The clocks a timestamp can be read on: the viewer's and the practice's (IANA names). */
469
+ /** The clocks a timestamp can be read on: the viewer's and the scope's (IANA names). */
469
470
  interface DisplayTimeZones {
470
471
  viewer: string;
471
- practice: string;
472
+ /** The zone of whatever the screen is scoped to (a location, a league, a team): `timeZone: "scope"`. */
473
+ scope: string;
472
474
  }
473
475
  /** What a renderer gets besides the value (as on the web, with native's messages and clocks). */
474
476
  interface DisplayContext {
@@ -489,7 +491,11 @@ declare function dateToDay(date: Date): string;
489
491
  * clock (core's `wallClock`), so an 8pm edit in New York isn't tomorrow's (its UTC day).
490
492
  */
491
493
  declare function formatDay(value: unknown, zone?: string): string;
492
- /** A column's clock: "viewer" (the default) and "practice" from `zones`, else a valid IANA name. */
494
+ /**
495
+ * A column's clock: "viewer" (the default) and "scope" from `zones`, else a valid IANA name.
496
+ * Anything else throws (`defineView` refuses it first): drawing it on the viewer's clock instead
497
+ * would show the wrong times with nothing to say so.
498
+ */
493
499
  declare function resolveZone(zone: string | undefined, zones: DisplayTimeZones): string;
494
500
  /** A timestamp as the clock on the wall in `zone` shows it (core's `wallClock`), not the device's. */
495
501
  declare function formatInstant(value: unknown, zone: string): string;
@@ -12,7 +12,7 @@ import { createContext, memo, useState, useCallback, useMemo, useEffect, useCont
12
12
  import { SafeAreaView } from 'react-native-safe-area-context';
13
13
  import { titleCase, useResourceForm, resourceKeys, useDataProvider, useViewer as useViewer$1, encodeRecordKey, useCapabilities as useCapabilities$1, DataWriteError } from '@marktiderman/genesis-core';
14
14
  import { Controller, useForm } from 'react-hook-form';
15
- import { useRelationLabel, useResource, useViewer, useInfiniteResource, useCapabilities, useOptionalViewerScope, useOne } from '@marktiderman/genesis-core/hooks';
15
+ import { useRelationLabel, useResource, useViewer, useInfiniteResource, useCapabilities, useOptionalViewerScope, scopeClock, useOne } from '@marktiderman/genesis-core/hooks';
16
16
  import { personTimeZone, isTimeZone, wallClock } from '@marktiderman/genesis-core/dates';
17
17
  import { isSafeUrl } from '@marktiderman/genesis-core/urls';
18
18
  import { valueText, rowPicture } from '@marktiderman/genesis-core/resource-view';
@@ -882,8 +882,11 @@ function formatDay(value, zone = personTimeZone()) {
882
882
  }
883
883
  function resolveZone(zone, zones) {
884
884
  if (!zone || zone === "viewer") return zones.viewer;
885
- if (zone === "practice") return zones.practice;
886
- return isTimeZone(zone) ? zone : zones.viewer;
885
+ if (zone === "scope") return zones.scope;
886
+ if (isTimeZone(zone)) return zone;
887
+ throw new RangeError(
888
+ zone === "practice" ? `[genesis-ui-native] timeZone "practice" was renamed "scope" in genesis-core 2; run \`genesis codemod genesis-core-2-scope-names\`` : `[genesis-ui-native] timeZone "${zone}" isn't "viewer", "scope" or a time zone this runtime knows`
889
+ );
887
890
  }
888
891
  var WALL = new Intl.DateTimeFormat(void 0, { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" });
889
892
  function formatInstant(value, zone) {
@@ -986,7 +989,7 @@ var TimeZonesContext = createContext(null);
986
989
  var DisplayTimeZonesProvider = TimeZonesContext.Provider;
987
990
  function useDisplayTimeZones() {
988
991
  const zones = useContext(TimeZonesContext);
989
- return useMemo(() => zones ?? { viewer: personTimeZone(), practice: personTimeZone() }, [zones]);
992
+ return useMemo(() => zones ?? { viewer: personTimeZone(), scope: personTimeZone() }, [zones]);
990
993
  }
991
994
  function DisplayRenderersProvider({
992
995
  renderers,
@@ -1554,11 +1557,11 @@ var recordKey = (view, row) => {
1554
1557
  function NativeResourceView(props) {
1555
1558
  const scope = useOptionalViewerScope();
1556
1559
  const viewer = scope?.timeZone;
1557
- const { practiceTimeZone } = props;
1560
+ const scopeZone = props.scopeTimeZone ?? scope?.scopeTimeZone;
1558
1561
  const zones = useMemo(() => {
1559
1562
  const own = personTimeZone({ timeZone: viewer });
1560
- return { viewer: own, practice: practiceTimeZone && isTimeZone(practiceTimeZone) ? practiceTimeZone : own };
1561
- }, [viewer, practiceTimeZone]);
1563
+ return { viewer: own, scope: scopeClock(scopeZone, own) };
1564
+ }, [viewer, scopeZone]);
1562
1565
  return /* @__PURE__ */ jsx(DisplayTimeZonesProvider, { value: zones, children: /* @__PURE__ */ jsx(Screen, { ...props }) });
1563
1566
  }
1564
1567
  var PICTURE_SIZE = 40;
@@ -1661,7 +1664,7 @@ function Screen(props) {
1661
1664
  header,
1662
1665
  emptyState,
1663
1666
  searchable,
1664
- practiceTimeZone: _zone,
1667
+ scopeTimeZone: _zone,
1665
1668
  testID = "native-resource-view",
1666
1669
  ...options
1667
1670
  } = props;