@dloizides/ui-feedback 1.20.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -437,6 +437,7 @@ declare const DEFAULT_ERROR_BOUNDARY_LABELS: ErrorBoundaryLabels;
|
|
|
437
437
|
|
|
438
438
|
/** What the `fallback` render-prop receives. */
|
|
439
439
|
interface ErrorFallbackState {
|
|
440
|
+
renderDefault: (logo?: ReactNode) => ReactNode;
|
|
440
441
|
/** The caught error, or `null` before anything has been caught. */
|
|
441
442
|
error: Error | null;
|
|
442
443
|
/** True while the caller's `recover` is handling the error. */
|
|
@@ -524,6 +525,7 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
|
|
|
524
525
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
525
526
|
private readonly handleRetry;
|
|
526
527
|
render(): ReactNode;
|
|
528
|
+
private renderDefaultFallback;
|
|
527
529
|
}
|
|
528
530
|
|
|
529
531
|
interface ErrorReferenceRowProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -437,6 +437,7 @@ declare const DEFAULT_ERROR_BOUNDARY_LABELS: ErrorBoundaryLabels;
|
|
|
437
437
|
|
|
438
438
|
/** What the `fallback` render-prop receives. */
|
|
439
439
|
interface ErrorFallbackState {
|
|
440
|
+
renderDefault: (logo?: ReactNode) => ReactNode;
|
|
440
441
|
/** The caught error, or `null` before anything has been caught. */
|
|
441
442
|
error: Error | null;
|
|
442
443
|
/** True while the caller's `recover` is handling the error. */
|
|
@@ -524,6 +525,7 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
|
|
|
524
525
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
525
526
|
private readonly handleRetry;
|
|
526
527
|
render(): ReactNode;
|
|
528
|
+
private renderDefaultFallback;
|
|
527
529
|
}
|
|
528
530
|
|
|
529
531
|
interface ErrorReferenceRowProps {
|
package/dist/index.js
CHANGED
|
@@ -1144,6 +1144,10 @@ var styles10 = reactNative.StyleSheet.create({
|
|
|
1144
1144
|
maxWidth: CONTENT_MAX_WIDTH,
|
|
1145
1145
|
alignItems: "center"
|
|
1146
1146
|
},
|
|
1147
|
+
logo: {
|
|
1148
|
+
alignItems: "center",
|
|
1149
|
+
marginBottom: TITLE_MARGIN_BOTTOM2
|
|
1150
|
+
},
|
|
1147
1151
|
title: {
|
|
1148
1152
|
fontSize: TITLE_FONT_SIZE3,
|
|
1149
1153
|
fontWeight: "bold",
|
|
@@ -1185,7 +1189,8 @@ var ErrorBoundaryFallback = ({
|
|
|
1185
1189
|
showRetry,
|
|
1186
1190
|
reloadIsPrimary,
|
|
1187
1191
|
onRetry,
|
|
1188
|
-
onReload
|
|
1192
|
+
onReload,
|
|
1193
|
+
logo
|
|
1189
1194
|
}) => {
|
|
1190
1195
|
const { theme } = useFeedbackUi();
|
|
1191
1196
|
const warningColor = (theme.semantic.warning ?? theme.semantic.error)["500"];
|
|
@@ -1227,6 +1232,7 @@ var ErrorBoundaryFallback = ({
|
|
|
1227
1232
|
style: [styles10.container, { backgroundColor: theme.colors.background }],
|
|
1228
1233
|
testID: testIDPrefix,
|
|
1229
1234
|
children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles10.content, children: [
|
|
1235
|
+
logo !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles10.logo, testID: `${testIDPrefix}-logo`, children: logo }) : null,
|
|
1230
1236
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles10.title, { color: theme.colors.text }], children: labels.title }),
|
|
1231
1237
|
/* @__PURE__ */ jsxRuntime.jsx(ErrorState, { message: labels.message, testID: `${testIDPrefix}-message` }),
|
|
1232
1238
|
hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1329,12 +1335,23 @@ var AppErrorBoundary = class extends react.Component {
|
|
|
1329
1335
|
if (isHandled) this.setState({ recovering: true });
|
|
1330
1336
|
}
|
|
1331
1337
|
render() {
|
|
1332
|
-
const { children, fallback
|
|
1338
|
+
const { children, fallback } = this.props;
|
|
1333
1339
|
const { hasError, error, recovering } = this.state;
|
|
1340
|
+
if (!hasError) return children;
|
|
1341
|
+
if (typeof fallback === "function")
|
|
1342
|
+
return fallback({
|
|
1343
|
+
error,
|
|
1344
|
+
recovering,
|
|
1345
|
+
retry: this.handleRetry,
|
|
1346
|
+
renderDefault: (logo) => this.renderDefaultFallback(logo)
|
|
1347
|
+
});
|
|
1348
|
+
return this.renderDefaultFallback();
|
|
1349
|
+
}
|
|
1350
|
+
renderDefaultFallback(logo) {
|
|
1351
|
+
const { labels, labelsFor, showDetails, onReload } = this.props;
|
|
1352
|
+
const { error, recovering } = this.state;
|
|
1334
1353
|
const testIDPrefix = this.props.testIDPrefix ?? FEEDBACK_TEST_IDS.errorBoundary;
|
|
1335
1354
|
const resolvedLabels = resolveLabels(labels, labelsFor, error);
|
|
1336
|
-
if (!hasError) return children;
|
|
1337
|
-
if (typeof fallback === "function") return fallback({ error, recovering, retry: this.handleRetry });
|
|
1338
1355
|
if (recovering)
|
|
1339
1356
|
return /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundaryRecovering, { message: resolvedLabels.updating, testID: `${testIDPrefix}-updating` });
|
|
1340
1357
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1342,6 +1359,7 @@ var AppErrorBoundary = class extends react.Component {
|
|
|
1342
1359
|
{
|
|
1343
1360
|
error,
|
|
1344
1361
|
labels: resolvedLabels,
|
|
1362
|
+
logo,
|
|
1345
1363
|
reloadIsPrimary: this.props.reloadIsPrimary === true,
|
|
1346
1364
|
showDetails: resolveShowDetails(showDetails, error),
|
|
1347
1365
|
showRetry: resolveRetryable(this.props.retryable, error),
|