@dloizides/ui-feedback 1.6.0 → 1.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.7.0
4
+
5
+ Closes the API gap that kept `kefi-web`, `erevna-web` and `katalogos-web` on their
6
+ local `ErrorBoundary` copies. Those three vary the boundary **by error class** — a
7
+ stale-chunk failure after a deploy needs different wording, no retry button, and no
8
+ stack dump — which 1.6.0's static `labels` / boolean `showDetails` could not express.
9
+ Every addition is opt-in; the pre-1.7.0 test suite passes unmodified.
10
+
11
+ **The kit still does not know what a "chunk" is.** Apps inject the classification;
12
+ the boundary only learns *whether retry is meaningful* and *what to say*.
13
+
14
+ - **Add `retryable?: (error) => boolean`.** When it returns `false` the retry action is
15
+ not rendered at all. Offering a button that re-renders straight back into the same
16
+ missing chunk is worse than offering nothing. Default: every error is retryable
17
+ (1.6.0 behaviour).
18
+ - **Add `labelsFor?: (error) => Partial<ErrorBoundaryLabels>`,** merged OVER the static
19
+ `labels`. Lets an app say "Update available" for a stale chunk without the kit knowing
20
+ why — it sees only the resulting strings.
21
+ - **Widen `showDetails` to `boolean | ((error) => boolean)`.** A predicate can suppress
22
+ the dev-only block per error class (a hashed filename is noise, not signal). **A plain
23
+ boolean behaves exactly as before.**
24
+ - **Add `onMount?: () => void`,** called from `componentDidMount` ONLY when the mount was
25
+ clean. The three apps release their one-shot reload guard here: a clean mount proves the
26
+ current chunks loaded, so a FUTURE deploy may auto-recover again. Deliberately not called
27
+ on an errored mount — that would re-arm the guard during the very failure it bounds.
28
+ - **Add `reloadIsPrimary?: boolean`** (default `false`). Gives Reload the filled emphasis
29
+ and the first position instead of Try Again.
30
+
31
+ **Why a flag rather than an unconditional swap:** `agora-web` and `zygos-web` both pass
32
+ `onReload`, so simply inverting the priority would have silently restyled and reordered
33
+ their error screens too. They have no chunk-recovery path, so retry is still the right
34
+ primary there. The default preserves their rendering exactly; the three chunk-aware apps
35
+ opt in.
36
+
37
+ **Notably, `DEFAULT_ERROR_BOUNDARY_LABELS` gains no `updateTitle`/`updateMessage`.** Those
38
+ are domain vocabulary — "an update is available" is a fact about the app's deploy model, not
39
+ about error boundaries. `labelsFor` supplies them as ordinary `title`/`message` overrides,
40
+ which keeps the kit's label bag domain-free.
41
+
42
+ ### Fixed
43
+
44
+ - **`AppErrorBoundary.test.tsx` had never actually run.** `jest.setup.ts` imports
45
+ `@testing-library/jest-dom`, which registers matchers at runtime, but `tsconfig.test.json`
46
+ listed no `types`, so ts-jest failed every `toBeInTheDocument()` with TS2339 and aborted the
47
+ whole suite at compile time. It was the only suite using those matchers, so `npm test`
48
+ reported a red SUITE while the other five stayed green and the true test count read 34.
49
+ Adding `"types": ["jest", "node", "@testing-library/jest-dom"]` brings its 14 assertions
50
+ online for the first time — unmodified, and passing against the 1.7.0 source.
51
+
3
52
  ## 1.6.0
4
53
 
5
54
  Two fleet-wide duplicates extracted (W1.2 + W1.3). Both are purely additive — every
package/dist/index.d.mts CHANGED
@@ -139,6 +139,51 @@ interface PageSkeletonProps {
139
139
  }
140
140
  declare const PageSkeleton: React.FC<PageSkeletonProps>;
141
141
 
142
+ /**
143
+ * AsyncSurface — the load / error / loaded contract every data screen shares, resolved once.
144
+ *
145
+ * failed → the shared `<ErrorState>` WITH a retry button
146
+ * loading → the shared shimmer `<PageSkeleton>` (NOT a bare spinner on a blank page)
147
+ * ok → the screen's content
148
+ *
149
+ * Pure composition over this package's own `ErrorState` and `PageSkeleton`, so no screen
150
+ * hand-rolls a spinner or an error card and every one of them fails the same way.
151
+ *
152
+ * EMPTY states are deliberately NOT handled here — an empty list is a per-screen designed
153
+ * message + call-to-action (`<EmptyListState>`), not a generic card.
154
+ *
155
+ * ── Why the branch order is what it is, and why it is pinned by a test ──────────────────
156
+ * This component was duplicated in two portals with OPPOSITE branch order, and the
157
+ * difference was a live bug. React Query holds `isError` true while a retry refetch is in
158
+ * flight and raises `isLoading`/`isFetching` at the same time, so during a retry a surface
159
+ * is genuinely BOTH loading and failed. Checking `loading` first makes that overlap render
160
+ * as: error card → skeleton → error card. The retry button is unmounted from under the
161
+ * operator's cursor mid-click, and a user whose first retry failed cannot reach a second.
162
+ *
163
+ * Error therefore wins: a surface that is both loading and failed keeps saying it failed.
164
+ * `AsyncSurface.test.tsx` asserts the both-true case directly — the ordering is a
165
+ * behavioural contract, not an implementation detail, and it must not silently flip back.
166
+ */
167
+
168
+ interface AsyncSurfaceProps {
169
+ /** Truthy while the query is in flight. */
170
+ loading: boolean;
171
+ /** Truthy when the query failed. Takes precedence over `loading` — see the docblock. */
172
+ isError: boolean;
173
+ onRetry: () => void;
174
+ /** Skeleton rows while loading. Match the surface so the layout does not jump. */
175
+ skeletonRows?: number;
176
+ /** `'cards'` for dashboard tiles, `'list'` for tables and forms. */
177
+ variant?: 'list' | 'cards';
178
+ /**
179
+ * Failure message. Defaults to the `common.loadFailed` key from the provider's `t`, so the
180
+ * server's raw text is never shown to a user.
181
+ */
182
+ message?: string;
183
+ children: React.ReactNode;
184
+ }
185
+ declare const AsyncSurface: ({ loading, isError, onRetry, skeletonRows, variant, message, children, }: AsyncSurfaceProps) => React.ReactNode;
186
+
142
187
  /**
143
188
  * ConfirmDialog - modal confirm/cancel dialog with optional destructive + loading states.
144
189
  */
@@ -392,10 +437,48 @@ interface AppErrorBoundaryProps {
392
437
  * of the error screen. Return `false`/omit to fall through to the fallback.
393
438
  */
394
439
  recover?: (error: Error) => boolean;
395
- /** Render the error message in the fallback (dev-only stack). Default `false`. */
396
- showDetails?: boolean;
440
+ /**
441
+ * Render the error message in the fallback (dev-only stack). Default `false`.
442
+ *
443
+ * A predicate is asked per caught error, so an app can suppress the block for
444
+ * error classes where the stack is noise rather than signal (the three chunk-aware
445
+ * apps hide it for a stale-chunk failure: the message names a hashed filename the
446
+ * user can do nothing with). A plain boolean behaves exactly as it always has.
447
+ */
448
+ showDetails?: boolean | ((error: Error) => boolean);
397
449
  /** Pre-localized wording. Anything omitted falls back to the English defaults. */
398
450
  labels?: Partial<ErrorBoundaryLabels>;
451
+ /**
452
+ * Per-error wording, merged OVER `labels`. Lets a caller say something specific
453
+ * about a specific failure ("Update available" for a stale chunk) without the kit
454
+ * knowing why — it never sees the classification, only the resulting strings.
455
+ */
456
+ labelsFor?: (error: Error) => Partial<ErrorBoundaryLabels>;
457
+ /**
458
+ * Whether retrying could plausibly help. When this returns `false` the retry
459
+ * action is NOT rendered at all — offering a button that re-renders straight back
460
+ * into the same failure is worse than offering nothing. Default: every error is
461
+ * retryable, which is the behaviour before this prop existed.
462
+ */
463
+ retryable?: (error: Error) => boolean;
464
+ /**
465
+ * Called from `componentDidMount` ONLY when the mount was clean (nothing caught).
466
+ * The chunk-aware apps use it to release their one-shot reload guard: a clean mount
467
+ * proves the current chunks loaded, so a FUTURE deploy is allowed to auto-recover
468
+ * again. Deliberately NOT called on an errored mount — that would re-arm the guard
469
+ * during the very failure it is meant to bound, and reintroduce the reload loop.
470
+ */
471
+ onMount?: () => void;
472
+ /**
473
+ * Give the primary (filled) emphasis — and the first position — to **Reload**
474
+ * instead of **Try Again**. Default `false`, which preserves the emphasis every
475
+ * existing caller renders today.
476
+ *
477
+ * Apps with a stale-chunk failure mode set this: when the running bundle references
478
+ * a chunk that no longer exists, reloading is the action that actually works and
479
+ * re-rendering is the one that cannot.
480
+ */
481
+ reloadIsPrimary?: boolean;
399
482
  /** Prefix for every testID the boundary renders. Default `error-boundary`. */
400
483
  testIDPrefix?: string;
401
484
  /** Full escape hatch — replaces the built-in fallback entirely. */
@@ -415,9 +498,10 @@ interface AppErrorBoundaryState {
415
498
  declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppErrorBoundaryState> {
416
499
  constructor(props: AppErrorBoundaryProps);
417
500
  static getDerivedStateFromError(error: Error): Partial<AppErrorBoundaryState>;
501
+ componentDidMount(): void;
418
502
  componentDidCatch(error: Error, info: ErrorInfo): void;
419
503
  private readonly handleRetry;
420
504
  render(): ReactNode;
421
505
  }
422
506
 
423
- export { AppErrorBoundary, type AppErrorBoundaryProps, ConfirmDialog, type ConfirmDialogProps, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorState, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, LoadingFallback, type LoadingFallbackProps, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
507
+ export { AppErrorBoundary, type AppErrorBoundaryProps, AsyncSurface, type AsyncSurfaceProps, ConfirmDialog, type ConfirmDialogProps, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorState, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, LoadingFallback, type LoadingFallbackProps, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
package/dist/index.d.ts CHANGED
@@ -139,6 +139,51 @@ interface PageSkeletonProps {
139
139
  }
140
140
  declare const PageSkeleton: React.FC<PageSkeletonProps>;
141
141
 
142
+ /**
143
+ * AsyncSurface — the load / error / loaded contract every data screen shares, resolved once.
144
+ *
145
+ * failed → the shared `<ErrorState>` WITH a retry button
146
+ * loading → the shared shimmer `<PageSkeleton>` (NOT a bare spinner on a blank page)
147
+ * ok → the screen's content
148
+ *
149
+ * Pure composition over this package's own `ErrorState` and `PageSkeleton`, so no screen
150
+ * hand-rolls a spinner or an error card and every one of them fails the same way.
151
+ *
152
+ * EMPTY states are deliberately NOT handled here — an empty list is a per-screen designed
153
+ * message + call-to-action (`<EmptyListState>`), not a generic card.
154
+ *
155
+ * ── Why the branch order is what it is, and why it is pinned by a test ──────────────────
156
+ * This component was duplicated in two portals with OPPOSITE branch order, and the
157
+ * difference was a live bug. React Query holds `isError` true while a retry refetch is in
158
+ * flight and raises `isLoading`/`isFetching` at the same time, so during a retry a surface
159
+ * is genuinely BOTH loading and failed. Checking `loading` first makes that overlap render
160
+ * as: error card → skeleton → error card. The retry button is unmounted from under the
161
+ * operator's cursor mid-click, and a user whose first retry failed cannot reach a second.
162
+ *
163
+ * Error therefore wins: a surface that is both loading and failed keeps saying it failed.
164
+ * `AsyncSurface.test.tsx` asserts the both-true case directly — the ordering is a
165
+ * behavioural contract, not an implementation detail, and it must not silently flip back.
166
+ */
167
+
168
+ interface AsyncSurfaceProps {
169
+ /** Truthy while the query is in flight. */
170
+ loading: boolean;
171
+ /** Truthy when the query failed. Takes precedence over `loading` — see the docblock. */
172
+ isError: boolean;
173
+ onRetry: () => void;
174
+ /** Skeleton rows while loading. Match the surface so the layout does not jump. */
175
+ skeletonRows?: number;
176
+ /** `'cards'` for dashboard tiles, `'list'` for tables and forms. */
177
+ variant?: 'list' | 'cards';
178
+ /**
179
+ * Failure message. Defaults to the `common.loadFailed` key from the provider's `t`, so the
180
+ * server's raw text is never shown to a user.
181
+ */
182
+ message?: string;
183
+ children: React.ReactNode;
184
+ }
185
+ declare const AsyncSurface: ({ loading, isError, onRetry, skeletonRows, variant, message, children, }: AsyncSurfaceProps) => React.ReactNode;
186
+
142
187
  /**
143
188
  * ConfirmDialog - modal confirm/cancel dialog with optional destructive + loading states.
144
189
  */
@@ -392,10 +437,48 @@ interface AppErrorBoundaryProps {
392
437
  * of the error screen. Return `false`/omit to fall through to the fallback.
393
438
  */
394
439
  recover?: (error: Error) => boolean;
395
- /** Render the error message in the fallback (dev-only stack). Default `false`. */
396
- showDetails?: boolean;
440
+ /**
441
+ * Render the error message in the fallback (dev-only stack). Default `false`.
442
+ *
443
+ * A predicate is asked per caught error, so an app can suppress the block for
444
+ * error classes where the stack is noise rather than signal (the three chunk-aware
445
+ * apps hide it for a stale-chunk failure: the message names a hashed filename the
446
+ * user can do nothing with). A plain boolean behaves exactly as it always has.
447
+ */
448
+ showDetails?: boolean | ((error: Error) => boolean);
397
449
  /** Pre-localized wording. Anything omitted falls back to the English defaults. */
398
450
  labels?: Partial<ErrorBoundaryLabels>;
451
+ /**
452
+ * Per-error wording, merged OVER `labels`. Lets a caller say something specific
453
+ * about a specific failure ("Update available" for a stale chunk) without the kit
454
+ * knowing why — it never sees the classification, only the resulting strings.
455
+ */
456
+ labelsFor?: (error: Error) => Partial<ErrorBoundaryLabels>;
457
+ /**
458
+ * Whether retrying could plausibly help. When this returns `false` the retry
459
+ * action is NOT rendered at all — offering a button that re-renders straight back
460
+ * into the same failure is worse than offering nothing. Default: every error is
461
+ * retryable, which is the behaviour before this prop existed.
462
+ */
463
+ retryable?: (error: Error) => boolean;
464
+ /**
465
+ * Called from `componentDidMount` ONLY when the mount was clean (nothing caught).
466
+ * The chunk-aware apps use it to release their one-shot reload guard: a clean mount
467
+ * proves the current chunks loaded, so a FUTURE deploy is allowed to auto-recover
468
+ * again. Deliberately NOT called on an errored mount — that would re-arm the guard
469
+ * during the very failure it is meant to bound, and reintroduce the reload loop.
470
+ */
471
+ onMount?: () => void;
472
+ /**
473
+ * Give the primary (filled) emphasis — and the first position — to **Reload**
474
+ * instead of **Try Again**. Default `false`, which preserves the emphasis every
475
+ * existing caller renders today.
476
+ *
477
+ * Apps with a stale-chunk failure mode set this: when the running bundle references
478
+ * a chunk that no longer exists, reloading is the action that actually works and
479
+ * re-rendering is the one that cannot.
480
+ */
481
+ reloadIsPrimary?: boolean;
399
482
  /** Prefix for every testID the boundary renders. Default `error-boundary`. */
400
483
  testIDPrefix?: string;
401
484
  /** Full escape hatch — replaces the built-in fallback entirely. */
@@ -415,9 +498,10 @@ interface AppErrorBoundaryState {
415
498
  declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppErrorBoundaryState> {
416
499
  constructor(props: AppErrorBoundaryProps);
417
500
  static getDerivedStateFromError(error: Error): Partial<AppErrorBoundaryState>;
501
+ componentDidMount(): void;
418
502
  componentDidCatch(error: Error, info: ErrorInfo): void;
419
503
  private readonly handleRetry;
420
504
  render(): ReactNode;
421
505
  }
422
506
 
423
- export { AppErrorBoundary, type AppErrorBoundaryProps, ConfirmDialog, type ConfirmDialogProps, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorState, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, LoadingFallback, type LoadingFallbackProps, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
507
+ export { AppErrorBoundary, type AppErrorBoundaryProps, AsyncSurface, type AsyncSurfaceProps, ConfirmDialog, type ConfirmDialogProps, DEFAULT_ERROR_BOUNDARY_LABELS, DISABLED_OPACITY, EmptyListState, type EmptyListStateProps, type ErrorBoundaryLabels, type ErrorFallbackState, ErrorState, type ErrorStateProps, FEEDBACK_TEST_IDS, type FeedbackColorScale, type FeedbackNavigate, type FeedbackTheme, type FeedbackThemeColors, type FeedbackThemePalette, type FeedbackThemeSemantic, type FeedbackTranslate, FeedbackUiProvider, type FeedbackUiProviderProps, type FeedbackUiValue, LoadingFallback, type LoadingFallbackProps, MODAL_OVERLAY_COLOR, PageSkeleton, type PageSkeletonProps, type ToastBus, ToastHost, type ToastHostProps, type ToastInput, type ToastPush, type ToastType, type FeedbackColorScale as UiColorScale, type FeedbackNavigate as UiNavigate, FeedbackUiProvider as UiProvider, type FeedbackUiProviderProps as UiProviderProps, type FeedbackTheme as UiTheme, type FeedbackThemeColors as UiThemeColors, type FeedbackThemePalette as UiThemePalette, type FeedbackThemeSemantic as UiThemeSemantic, type FeedbackTranslate as UiTranslate, type FeedbackUiValue as UiValue, WARMING_QUIET_PERIOD_MS, type WarmingInfo, WarmingOverlay, type WarmingOverlayLabels, type WarmingOverlayProps, type WarmingSnapshot, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
package/dist/index.js CHANGED
@@ -308,6 +308,21 @@ var PageSkeleton = ({
308
308
  }
309
309
  );
310
310
  };
311
+ var DEFAULT_SKELETON_ROWS = 6;
312
+ var AsyncSurface = ({
313
+ loading,
314
+ isError,
315
+ onRetry,
316
+ skeletonRows = DEFAULT_SKELETON_ROWS,
317
+ variant = "list",
318
+ message,
319
+ children
320
+ }) => {
321
+ const { t } = useFeedbackUi();
322
+ if (isError) return /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { message: message ?? t("common.loadFailed"), onRetry });
323
+ if (loading) return /* @__PURE__ */ jsxRuntime.jsx(PageSkeleton, { showHeader: true, rows: skeletonRows, variant });
324
+ return children;
325
+ };
311
326
  var DIALOG_MAX_WIDTH = 400;
312
327
  var styles5 = reactNative.StyleSheet.create({
313
328
  overlay: {
@@ -825,6 +840,8 @@ var ErrorBoundaryFallback = ({
825
840
  testIDPrefix,
826
841
  error,
827
842
  showDetails,
843
+ showRetry,
844
+ reloadIsPrimary,
828
845
  onRetry,
829
846
  onReload
830
847
  }) => {
@@ -832,6 +849,34 @@ var ErrorBoundaryFallback = ({
832
849
  const warningColor = (theme.semantic.warning ?? theme.semantic.error)["500"];
833
850
  const primaryColor = theme.palette.primary["500"];
834
851
  const hasDetails = showDetails && error !== null;
852
+ const primaryFill = { backgroundColor: primaryColor };
853
+ const primaryInk = { color: theme.colors.surfaceElevated };
854
+ const secondaryFill = { backgroundColor: theme.colors.surface };
855
+ const secondaryInk = { color: theme.colors.text };
856
+ const retryButton = showRetry ? /* @__PURE__ */ jsxRuntime.jsx(
857
+ reactNative.TouchableOpacity,
858
+ {
859
+ accessibilityHint: labels.tryAgainHint,
860
+ accessibilityLabel: labels.tryAgain,
861
+ accessibilityRole: "button",
862
+ style: [styles8.button, reloadIsPrimary ? secondaryFill : primaryFill],
863
+ testID: `${testIDPrefix}-retry-button`,
864
+ onPress: onRetry,
865
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, reloadIsPrimary ? secondaryInk : primaryInk], children: labels.tryAgain })
866
+ }
867
+ ) : null;
868
+ const reloadButton = typeof onReload === "function" ? /* @__PURE__ */ jsxRuntime.jsx(
869
+ reactNative.TouchableOpacity,
870
+ {
871
+ accessibilityHint: labels.reloadHint,
872
+ accessibilityLabel: labels.reload,
873
+ accessibilityRole: "button",
874
+ style: [styles8.button, reloadIsPrimary ? primaryFill : secondaryFill],
875
+ testID: `${testIDPrefix}-reload-button`,
876
+ onPress: onReload,
877
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, reloadIsPrimary ? primaryInk : secondaryInk], children: labels.reload })
878
+ }
879
+ ) : null;
835
880
  return /* @__PURE__ */ jsxRuntime.jsx(
836
881
  reactNative.View,
837
882
  {
@@ -853,30 +898,8 @@ var ErrorBoundaryFallback = ({
853
898
  ]
854
899
  }
855
900
  ) : null,
856
- /* @__PURE__ */ jsxRuntime.jsx(
857
- reactNative.TouchableOpacity,
858
- {
859
- accessibilityHint: labels.tryAgainHint,
860
- accessibilityLabel: labels.tryAgain,
861
- accessibilityRole: "button",
862
- style: [styles8.button, { backgroundColor: primaryColor }],
863
- testID: `${testIDPrefix}-retry-button`,
864
- onPress: onRetry,
865
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, { color: theme.colors.surfaceElevated }], children: labels.tryAgain })
866
- }
867
- ),
868
- typeof onReload === "function" ? /* @__PURE__ */ jsxRuntime.jsx(
869
- reactNative.TouchableOpacity,
870
- {
871
- accessibilityHint: labels.reloadHint,
872
- accessibilityLabel: labels.reload,
873
- accessibilityRole: "button",
874
- style: [styles8.button, { backgroundColor: theme.colors.surface }],
875
- testID: `${testIDPrefix}-reload-button`,
876
- onPress: onReload,
877
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.buttonText, { color: theme.colors.text }], children: labels.reload })
878
- }
879
- ) : null
901
+ reloadIsPrimary ? reloadButton : retryButton,
902
+ reloadIsPrimary ? retryButton : reloadButton
880
903
  ] })
881
904
  }
882
905
  );
@@ -928,6 +951,20 @@ var DEFAULT_ERROR_BOUNDARY_LABELS = {
928
951
  updating: "Updating\u2026",
929
952
  errorDetails: "Error details"
930
953
  };
954
+
955
+ // src/AppErrorBoundary/resolve.ts
956
+ function resolveLabels(labels, labelsFor, error) {
957
+ const perError = typeof labelsFor === "function" && error !== null ? labelsFor(error) : {};
958
+ return { ...DEFAULT_ERROR_BOUNDARY_LABELS, ...labels, ...perError };
959
+ }
960
+ function resolveShowDetails(showDetails, error) {
961
+ if (typeof showDetails === "function") return error !== null && showDetails(error);
962
+ return showDetails === true;
963
+ }
964
+ function resolveRetryable(retryable, error) {
965
+ if (typeof retryable !== "function" || error === null) return true;
966
+ return retryable(error);
967
+ }
931
968
  var INITIAL_STATE = { hasError: false, error: null, recovering: false };
932
969
  var AppErrorBoundary = class extends React3.Component {
933
970
  constructor(props) {
@@ -940,16 +977,20 @@ var AppErrorBoundary = class extends React3.Component {
940
977
  static getDerivedStateFromError(error) {
941
978
  return { hasError: true, error };
942
979
  }
980
+ componentDidMount() {
981
+ const isCleanMount = !this.state.hasError;
982
+ if (isCleanMount && typeof this.props.onMount === "function") this.props.onMount();
983
+ }
943
984
  componentDidCatch(error, info) {
944
985
  if (typeof this.props.onError === "function") this.props.onError(error, info);
945
986
  const isHandled = typeof this.props.recover === "function" && this.props.recover(error);
946
987
  if (isHandled) this.setState({ recovering: true });
947
988
  }
948
989
  render() {
949
- const { children, fallback, labels, showDetails = false, onReload } = this.props;
990
+ const { children, fallback, labels, labelsFor, showDetails, onReload } = this.props;
950
991
  const { hasError, error, recovering } = this.state;
951
992
  const testIDPrefix = this.props.testIDPrefix ?? FEEDBACK_TEST_IDS.errorBoundary;
952
- const resolvedLabels = { ...DEFAULT_ERROR_BOUNDARY_LABELS, ...labels };
993
+ const resolvedLabels = resolveLabels(labels, labelsFor, error);
953
994
  if (!hasError) return children;
954
995
  if (typeof fallback === "function") return fallback({ error, recovering, retry: this.handleRetry });
955
996
  if (recovering)
@@ -959,7 +1000,9 @@ var AppErrorBoundary = class extends React3.Component {
959
1000
  {
960
1001
  error,
961
1002
  labels: resolvedLabels,
962
- showDetails,
1003
+ reloadIsPrimary: this.props.reloadIsPrimary === true,
1004
+ showDetails: resolveShowDetails(showDetails, error),
1005
+ showRetry: resolveRetryable(this.props.retryable, error),
963
1006
  testIDPrefix,
964
1007
  onReload,
965
1008
  onRetry: this.handleRetry
@@ -969,6 +1012,7 @@ var AppErrorBoundary = class extends React3.Component {
969
1012
  };
970
1013
 
971
1014
  exports.AppErrorBoundary = AppErrorBoundary;
1015
+ exports.AsyncSurface = AsyncSurface;
972
1016
  exports.ConfirmDialog = ConfirmDialog;
973
1017
  exports.DEFAULT_ERROR_BOUNDARY_LABELS = DEFAULT_ERROR_BOUNDARY_LABELS;
974
1018
  exports.DISABLED_OPACITY = DISABLED_OPACITY;