@dloizides/ui-feedback 1.19.2 → 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/CHANGELOG.md +5 -0
- package/README.md +1 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.20.0
|
|
4
|
+
|
|
5
|
+
- `ToastHost`: new toast type `warning` (AML-TOAST-1 "Manual screening banner colour follows the result"), filled from `theme.semantic.warning` with an ink at 4.5:1 or better and its own glyph (▲), announced politely like success and info. A theme without a `warning` scale uses the `info` colours, never `error`.
|
|
6
|
+
- `createToastBus`: new `warning(text)`.
|
|
7
|
+
|
|
3
8
|
## 1.19.0
|
|
4
9
|
|
|
5
10
|
- Error reference (OBS-1 "Every app ships metrics, production-grade logs and alerts with working links", D-OBS-23 option A): `ErrorState` takes `error` and `AsyncSurface` passes its new `error` prop through; when the error carries a `traceId` (`@dloizides/bff-web-client` >= 1.4.0) a row "Error reference: <id>" + Copy (56x48 hit box, Copied / Copy failed for 1.5 s) sits below Retry / Back. Hidden without an id, so existing callers render the same tree.
|
package/README.md
CHANGED
|
@@ -98,6 +98,7 @@ export const toastBus = createToastBus();
|
|
|
98
98
|
// anywhere — no provider needed:
|
|
99
99
|
useMutation({ onSuccess: () => toastBus.success(FM('menu.saved')) });
|
|
100
100
|
toastBus.error(FM('menu.saveFailed'));
|
|
101
|
+
toastBus.warning(FM('menu.needsReview'));
|
|
101
102
|
toastBus.emit(FM('menu.queued'), 'info'); // explicit type; defaults to 'info'
|
|
102
103
|
```
|
|
103
104
|
|
package/dist/index.d.mts
CHANGED
|
@@ -252,7 +252,7 @@ declare const ConfirmDialog: ({ visible, title, message, onConfirm, onCancel, co
|
|
|
252
252
|
* `@dloizides/ui-forms` `menuPortal` and `@dloizides/ui-tables` `SizeDropdown`. Native stays in-tree.
|
|
253
253
|
*/
|
|
254
254
|
|
|
255
|
-
type ToastType = 'success' | 'info' | 'error';
|
|
255
|
+
type ToastType = 'success' | 'info' | 'error' | 'warning';
|
|
256
256
|
/** What the app pushes through the `subscribe` port. */
|
|
257
257
|
interface ToastInput {
|
|
258
258
|
text: string;
|
|
@@ -379,6 +379,8 @@ interface ToastBus {
|
|
|
379
379
|
error(text: string, cause?: unknown): void;
|
|
380
380
|
/** Emit an informational toast. */
|
|
381
381
|
info(text: string): void;
|
|
382
|
+
/** Emit a warning toast. */
|
|
383
|
+
warning(text: string): void;
|
|
382
384
|
}
|
|
383
385
|
/**
|
|
384
386
|
* Create an independent toast bus. Emitting with no subscriber is a silent no-op
|
|
@@ -435,6 +437,7 @@ declare const DEFAULT_ERROR_BOUNDARY_LABELS: ErrorBoundaryLabels;
|
|
|
435
437
|
|
|
436
438
|
/** What the `fallback` render-prop receives. */
|
|
437
439
|
interface ErrorFallbackState {
|
|
440
|
+
renderDefault: (logo?: ReactNode) => ReactNode;
|
|
438
441
|
/** The caught error, or `null` before anything has been caught. */
|
|
439
442
|
error: Error | null;
|
|
440
443
|
/** True while the caller's `recover` is handling the error. */
|
|
@@ -522,6 +525,7 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
|
|
|
522
525
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
523
526
|
private readonly handleRetry;
|
|
524
527
|
render(): ReactNode;
|
|
528
|
+
private renderDefaultFallback;
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
interface ErrorReferenceRowProps {
|
package/dist/index.d.ts
CHANGED
|
@@ -252,7 +252,7 @@ declare const ConfirmDialog: ({ visible, title, message, onConfirm, onCancel, co
|
|
|
252
252
|
* `@dloizides/ui-forms` `menuPortal` and `@dloizides/ui-tables` `SizeDropdown`. Native stays in-tree.
|
|
253
253
|
*/
|
|
254
254
|
|
|
255
|
-
type ToastType = 'success' | 'info' | 'error';
|
|
255
|
+
type ToastType = 'success' | 'info' | 'error' | 'warning';
|
|
256
256
|
/** What the app pushes through the `subscribe` port. */
|
|
257
257
|
interface ToastInput {
|
|
258
258
|
text: string;
|
|
@@ -379,6 +379,8 @@ interface ToastBus {
|
|
|
379
379
|
error(text: string, cause?: unknown): void;
|
|
380
380
|
/** Emit an informational toast. */
|
|
381
381
|
info(text: string): void;
|
|
382
|
+
/** Emit a warning toast. */
|
|
383
|
+
warning(text: string): void;
|
|
382
384
|
}
|
|
383
385
|
/**
|
|
384
386
|
* Create an independent toast bus. Emitting with no subscriber is a silent no-op
|
|
@@ -435,6 +437,7 @@ declare const DEFAULT_ERROR_BOUNDARY_LABELS: ErrorBoundaryLabels;
|
|
|
435
437
|
|
|
436
438
|
/** What the `fallback` render-prop receives. */
|
|
437
439
|
interface ErrorFallbackState {
|
|
440
|
+
renderDefault: (logo?: ReactNode) => ReactNode;
|
|
438
441
|
/** The caught error, or `null` before anything has been caught. */
|
|
439
442
|
error: Error | null;
|
|
440
443
|
/** True while the caller's `recover` is handling the error. */
|
|
@@ -522,6 +525,7 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
|
|
|
522
525
|
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
523
526
|
private readonly handleRetry;
|
|
524
527
|
render(): ReactNode;
|
|
528
|
+
private renderDefaultFallback;
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
interface ErrorReferenceRowProps {
|
package/dist/index.js
CHANGED
|
@@ -763,11 +763,13 @@ var TOAST_TOP_WEB = APP_HEADER_HEIGHT + HEADER_GAP;
|
|
|
763
763
|
var GLYPHS = {
|
|
764
764
|
success: "\u2713",
|
|
765
765
|
error: "!",
|
|
766
|
-
info: "i"
|
|
766
|
+
info: "i",
|
|
767
|
+
warning: "\u25B2"
|
|
767
768
|
};
|
|
768
769
|
function scaleFor(theme, type) {
|
|
769
770
|
if (type === "error") return theme.semantic.error;
|
|
770
771
|
if (type === "success") return theme.semantic.success ?? theme.palette.primary;
|
|
772
|
+
if (type === "warning") return theme.semantic.warning ?? theme.palette.primary;
|
|
771
773
|
return theme.palette.primary;
|
|
772
774
|
}
|
|
773
775
|
function readableInk(fill) {
|
|
@@ -919,7 +921,8 @@ var ToastHost = ({
|
|
|
919
921
|
() => ({
|
|
920
922
|
success: resolveToastTone(theme, "success"),
|
|
921
923
|
error: resolveToastTone(theme, "error"),
|
|
922
|
-
info: resolveToastTone(theme, "info")
|
|
924
|
+
info: resolveToastTone(theme, "info"),
|
|
925
|
+
warning: resolveToastTone(theme, "warning")
|
|
923
926
|
}),
|
|
924
927
|
[theme]
|
|
925
928
|
);
|
|
@@ -1108,6 +1111,9 @@ function createToastBus() {
|
|
|
1108
1111
|
},
|
|
1109
1112
|
info(text) {
|
|
1110
1113
|
emit2(text, "info");
|
|
1114
|
+
},
|
|
1115
|
+
warning(text) {
|
|
1116
|
+
emit2(text, "warning");
|
|
1111
1117
|
}
|
|
1112
1118
|
};
|
|
1113
1119
|
}
|
|
@@ -1138,6 +1144,10 @@ var styles10 = reactNative.StyleSheet.create({
|
|
|
1138
1144
|
maxWidth: CONTENT_MAX_WIDTH,
|
|
1139
1145
|
alignItems: "center"
|
|
1140
1146
|
},
|
|
1147
|
+
logo: {
|
|
1148
|
+
alignItems: "center",
|
|
1149
|
+
marginBottom: TITLE_MARGIN_BOTTOM2
|
|
1150
|
+
},
|
|
1141
1151
|
title: {
|
|
1142
1152
|
fontSize: TITLE_FONT_SIZE3,
|
|
1143
1153
|
fontWeight: "bold",
|
|
@@ -1179,7 +1189,8 @@ var ErrorBoundaryFallback = ({
|
|
|
1179
1189
|
showRetry,
|
|
1180
1190
|
reloadIsPrimary,
|
|
1181
1191
|
onRetry,
|
|
1182
|
-
onReload
|
|
1192
|
+
onReload,
|
|
1193
|
+
logo
|
|
1183
1194
|
}) => {
|
|
1184
1195
|
const { theme } = useFeedbackUi();
|
|
1185
1196
|
const warningColor = (theme.semantic.warning ?? theme.semantic.error)["500"];
|
|
@@ -1221,6 +1232,7 @@ var ErrorBoundaryFallback = ({
|
|
|
1221
1232
|
style: [styles10.container, { backgroundColor: theme.colors.background }],
|
|
1222
1233
|
testID: testIDPrefix,
|
|
1223
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,
|
|
1224
1236
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles10.title, { color: theme.colors.text }], children: labels.title }),
|
|
1225
1237
|
/* @__PURE__ */ jsxRuntime.jsx(ErrorState, { message: labels.message, testID: `${testIDPrefix}-message` }),
|
|
1226
1238
|
hasDetails ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1323,12 +1335,23 @@ var AppErrorBoundary = class extends react.Component {
|
|
|
1323
1335
|
if (isHandled) this.setState({ recovering: true });
|
|
1324
1336
|
}
|
|
1325
1337
|
render() {
|
|
1326
|
-
const { children, fallback
|
|
1338
|
+
const { children, fallback } = this.props;
|
|
1327
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;
|
|
1328
1353
|
const testIDPrefix = this.props.testIDPrefix ?? FEEDBACK_TEST_IDS.errorBoundary;
|
|
1329
1354
|
const resolvedLabels = resolveLabels(labels, labelsFor, error);
|
|
1330
|
-
if (!hasError) return children;
|
|
1331
|
-
if (typeof fallback === "function") return fallback({ error, recovering, retry: this.handleRetry });
|
|
1332
1355
|
if (recovering)
|
|
1333
1356
|
return /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundaryRecovering, { message: resolvedLabels.updating, testID: `${testIDPrefix}-updating` });
|
|
1334
1357
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1336,6 +1359,7 @@ var AppErrorBoundary = class extends react.Component {
|
|
|
1336
1359
|
{
|
|
1337
1360
|
error,
|
|
1338
1361
|
labels: resolvedLabels,
|
|
1362
|
+
logo,
|
|
1339
1363
|
reloadIsPrimary: this.props.reloadIsPrimary === true,
|
|
1340
1364
|
showDetails: resolveShowDetails(showDetails, error),
|
|
1341
1365
|
showRetry: resolveRetryable(this.props.retryable, error),
|