@dloizides/ui-feedback 1.13.0 → 1.15.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,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.15.0
4
+
5
+ - **New `ProgressBar`** (promoted from aml-v2 `JobProgressBar`, RUPEP-5 "Upload a RuPEP file from the
6
+ Jobs tab"): determinate fill clamped to 0-100 (`clampPercent`, also exported) with an optional
7
+ right-aligned caption, or an indeterminate scanning bar. `role="progressbar"` with
8
+ `aria-valuemin/max/now/text` (`aria-valuenow` omitted and `aria-busy` set when indeterminate).
9
+ Colours default to the UiProvider theme (`palette.primary.500`, `colors.border`,
10
+ `colors.textSecondary`) and accept overrides. Default testID `progress-bar`, fill `<testID>-fill`.
11
+
12
+ ## 1.14.0
13
+
14
+ - **`ToastHost` portals to `document.body` on web (`position: fixed`, `Z_INDEX.toast`).** In-tree,
15
+ the layer sat inside RN-web Views that each carry `position: relative; z-index: 0`, so its 10100
16
+ was trapped and an open `ConfirmDialog` / RN `Modal` (9999, body-level) painted over the toast
17
+ (measured on ui.dloizides.com/feedback: `elementFromPoint` at the toast centre returned the
18
+ dialog). Same mechanism as `ui-forms` `menuPortal` and `ui-tables` `SizeDropdown`. Native is
19
+ unchanged (in-tree). `react-dom` is now an optional peer dependency.
20
+
3
21
  ## 1.13.0
4
22
 
5
23
  Overlay stacking now comes from the shared `@dloizides/design-tokens` `Z_INDEX` scale
package/dist/index.d.mts CHANGED
@@ -78,6 +78,7 @@ declare const FEEDBACK_TEST_IDS: {
78
78
  readonly notificationToast: "notification-toast";
79
79
  readonly warmingOverlay: "warming-overlay";
80
80
  readonly errorBoundary: "error-boundary";
81
+ readonly progressBar: "progress-bar";
81
82
  };
82
83
 
83
84
  /**
@@ -238,6 +239,12 @@ declare const ConfirmDialog: ({ visible, title, message, onConfirm, onCancel, co
238
239
  * toast emitter). The app wires the two together via the `subscribe` port: a
239
240
  * function that registers a push callback and returns an unsubscribe. Colours
240
241
  * come from the UiProvider theme (`useUi`) — nothing hardcoded.
242
+ *
243
+ * STACKING (web): react-native-web gives every `View` `position: relative; z-index: 0`, so an
244
+ * in-tree absolute layer's `Z_INDEX.toast` is trapped inside its ancestors' stacking contexts and a
245
+ * body-level RN `Modal` / ConfirmDialog (`Z_INDEX.modal`) paints over it. On web the layer is
246
+ * therefore portalled to `document.body` with `position: fixed`, the same mechanism as
247
+ * `@dloizides/ui-forms` `menuPortal` and `@dloizides/ui-tables` `SizeDropdown`. Native stays in-tree.
241
248
  */
242
249
 
243
250
  type ToastType = 'success' | 'info' | 'error';
@@ -536,4 +543,21 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
536
543
  render(): ReactNode;
537
544
  }
538
545
 
539
- 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 ErrorStateAction, 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 };
546
+ interface ProgressBarProps {
547
+ percent?: number | null;
548
+ label?: string;
549
+ indeterminate?: boolean;
550
+ accessibilityLabel?: string;
551
+ accessibilityHint?: string;
552
+ color?: string;
553
+ trackColor?: string;
554
+ textColor?: string;
555
+ testID?: string;
556
+ }
557
+ /** Determinate (0-100) or indeterminate progress bar with an optional caption; themed via UiProvider. */
558
+ declare function ProgressBar(props: ProgressBarProps): React.ReactElement;
559
+
560
+ /** Clamps a possibly missing or non-finite percent into the 0-100 range. */
561
+ declare function clampPercent(value: number | null | undefined): number;
562
+
563
+ 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 ErrorStateAction, 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, ProgressBar, type ProgressBarProps, 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, clampPercent, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
package/dist/index.d.ts CHANGED
@@ -78,6 +78,7 @@ declare const FEEDBACK_TEST_IDS: {
78
78
  readonly notificationToast: "notification-toast";
79
79
  readonly warmingOverlay: "warming-overlay";
80
80
  readonly errorBoundary: "error-boundary";
81
+ readonly progressBar: "progress-bar";
81
82
  };
82
83
 
83
84
  /**
@@ -238,6 +239,12 @@ declare const ConfirmDialog: ({ visible, title, message, onConfirm, onCancel, co
238
239
  * toast emitter). The app wires the two together via the `subscribe` port: a
239
240
  * function that registers a push callback and returns an unsubscribe. Colours
240
241
  * come from the UiProvider theme (`useUi`) — nothing hardcoded.
242
+ *
243
+ * STACKING (web): react-native-web gives every `View` `position: relative; z-index: 0`, so an
244
+ * in-tree absolute layer's `Z_INDEX.toast` is trapped inside its ancestors' stacking contexts and a
245
+ * body-level RN `Modal` / ConfirmDialog (`Z_INDEX.modal`) paints over it. On web the layer is
246
+ * therefore portalled to `document.body` with `position: fixed`, the same mechanism as
247
+ * `@dloizides/ui-forms` `menuPortal` and `@dloizides/ui-tables` `SizeDropdown`. Native stays in-tree.
241
248
  */
242
249
 
243
250
  type ToastType = 'success' | 'info' | 'error';
@@ -536,4 +543,21 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
536
543
  render(): ReactNode;
537
544
  }
538
545
 
539
- 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 ErrorStateAction, 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 };
546
+ interface ProgressBarProps {
547
+ percent?: number | null;
548
+ label?: string;
549
+ indeterminate?: boolean;
550
+ accessibilityLabel?: string;
551
+ accessibilityHint?: string;
552
+ color?: string;
553
+ trackColor?: string;
554
+ textColor?: string;
555
+ testID?: string;
556
+ }
557
+ /** Determinate (0-100) or indeterminate progress bar with an optional caption; themed via UiProvider. */
558
+ declare function ProgressBar(props: ProgressBarProps): React.ReactElement;
559
+
560
+ /** Clamps a possibly missing or non-finite percent into the 0-100 range. */
561
+ declare function clampPercent(value: number | null | undefined): number;
562
+
563
+ 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 ErrorStateAction, 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, ProgressBar, type ProgressBarProps, 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, clampPercent, createToastBus, getWarmingSnapshot, notifyWarming, settleWarming, subscribeWarming, useFeedbackUi, useFeedbackUi as useUi };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var reactNative = require('react-native');
6
6
  var uiMotion = require('@dloizides/ui-motion');
7
+ var reactDom = require('react-dom');
7
8
  var designTokens = require('@dloizides/design-tokens');
8
9
 
9
10
  // src/context/FeedbackUiContext.tsx
@@ -59,7 +60,8 @@ var FEEDBACK_TEST_IDS = {
59
60
  cancelConfirmButton: "cancel-confirm-button",
60
61
  notificationToast: "notification-toast",
61
62
  warmingOverlay: "warming-overlay",
62
- errorBoundary: "error-boundary"
63
+ errorBoundary: "error-boundary",
64
+ progressBar: "progress-bar"
63
65
  };
64
66
  var WELL_SIZE = 56;
65
67
  var WELL_MARGIN_BOTTOM = 16;
@@ -577,6 +579,8 @@ var ConfirmDialog = ({
577
579
  }
578
580
  );
579
581
  };
582
+ var IS_WEB = reactNative.Platform.OS === "web";
583
+ var WEB_FIXED_LAYER = { position: "fixed" };
580
584
  var DEFAULT_DURATION_MS = 3e3;
581
585
  var DEFAULT_FADE_MS = 200;
582
586
  var DEFAULT_MAX_LENGTH = 500;
@@ -700,7 +704,8 @@ var ToastHost = ({
700
704
  }, []);
701
705
  react.useEffect(() => subscribe(push), [subscribe, push]);
702
706
  if (messages.length === 0) return null;
703
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles7.container, children: messages.map((m) => /* @__PURE__ */ jsxRuntime.jsx(
707
+ const canPortal = IS_WEB && typeof document !== "undefined";
708
+ const layer = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles7.container, canPortal ? WEB_FIXED_LAYER : null], children: messages.map((m) => /* @__PURE__ */ jsxRuntime.jsx(
704
709
  ToastItem,
705
710
  {
706
711
  colors,
@@ -712,6 +717,7 @@ var ToastHost = ({
712
717
  },
713
718
  m.id
714
719
  )) });
720
+ return canPortal ? reactDom.createPortal(layer, document.body) : layer;
715
721
  };
716
722
 
717
723
  // src/Warming/warmingStore.ts
@@ -1106,6 +1112,80 @@ var AppErrorBoundary = class extends react.Component {
1106
1112
  }
1107
1113
  };
1108
1114
 
1115
+ // src/ProgressBar/clampPercent.ts
1116
+ var MIN_PERCENT = 0;
1117
+ var MAX_PERCENT = 100;
1118
+ function clampPercent(value) {
1119
+ if (value === null || value === void 0 || !Number.isFinite(value)) return MIN_PERCENT;
1120
+ return Math.min(MAX_PERCENT, Math.max(MIN_PERCENT, value));
1121
+ }
1122
+ var BAR_HEIGHT = 8;
1123
+ var RADIUS = 999;
1124
+ var TRACK_MARGIN = 4;
1125
+ var INDET_FRACTION = 0.35;
1126
+ var INDET_DURATION_MS = 1300;
1127
+ var LABEL_FONT_SIZE = 12;
1128
+ var styles11 = reactNative.StyleSheet.create({
1129
+ track: { height: BAR_HEIGHT, borderRadius: RADIUS, overflow: "hidden", marginVertical: TRACK_MARGIN },
1130
+ fill: { height: "100%", borderRadius: RADIUS },
1131
+ label: { fontSize: LABEL_FONT_SIZE, textAlign: "right", fontVariant: ["tabular-nums"] }
1132
+ });
1133
+ function IndeterminateFill({ color, width, testID }) {
1134
+ const [anim] = react.useState(() => new reactNative.Animated.Value(0));
1135
+ react.useEffect(() => {
1136
+ const loop = reactNative.Animated.loop(
1137
+ reactNative.Animated.timing(anim, { toValue: 1, duration: INDET_DURATION_MS, useNativeDriver: false })
1138
+ );
1139
+ loop.start();
1140
+ return () => loop.stop();
1141
+ }, [anim]);
1142
+ const barWidth = width * INDET_FRACTION;
1143
+ const translateX = anim.interpolate({ inputRange: [0, 1], outputRange: [-barWidth, width] });
1144
+ return /* @__PURE__ */ jsxRuntime.jsx(
1145
+ reactNative.Animated.View,
1146
+ {
1147
+ style: [styles11.fill, { backgroundColor: color, width: barWidth, transform: [{ translateX }] }],
1148
+ testID
1149
+ }
1150
+ );
1151
+ }
1152
+ function ProgressBar(props) {
1153
+ const { theme } = useFeedbackUi();
1154
+ const {
1155
+ percent = null,
1156
+ label,
1157
+ indeterminate = false,
1158
+ accessibilityLabel,
1159
+ accessibilityHint,
1160
+ color = theme.palette.primary["500"],
1161
+ trackColor = theme.colors.border,
1162
+ textColor = theme.colors.textSecondary,
1163
+ testID = FEEDBACK_TEST_IDS.progressBar
1164
+ } = props;
1165
+ const [width, setWidth] = react.useState(0);
1166
+ const safePct = clampPercent(percent);
1167
+ const fillTestID = `${testID}-fill`;
1168
+ const onLayout = (e) => setWidth(e.nativeEvent.layout.width);
1169
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1170
+ reactNative.View,
1171
+ {
1172
+ accessibilityHint,
1173
+ accessibilityLabel: accessibilityLabel ?? label,
1174
+ "aria-busy": indeterminate,
1175
+ "aria-valuemax": MAX_PERCENT,
1176
+ "aria-valuemin": MIN_PERCENT,
1177
+ "aria-valuenow": indeterminate ? void 0 : safePct,
1178
+ "aria-valuetext": label,
1179
+ role: "progressbar",
1180
+ testID,
1181
+ children: [
1182
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles11.track, { backgroundColor: trackColor }], onLayout, children: indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(IndeterminateFill, { color, testID: fillTestID, width }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles11.fill, { backgroundColor: color, width: `${safePct}%` }], testID: fillTestID }) }),
1183
+ !indeterminate && label !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles11.label, { color: textColor }], children: label }) : null
1184
+ ]
1185
+ }
1186
+ );
1187
+ }
1188
+
1109
1189
  exports.AppErrorBoundary = AppErrorBoundary;
1110
1190
  exports.AsyncSurface = AsyncSurface;
1111
1191
  exports.ConfirmDialog = ConfirmDialog;
@@ -1118,10 +1198,12 @@ exports.FeedbackUiProvider = FeedbackUiProvider;
1118
1198
  exports.LoadingFallback = LoadingFallback;
1119
1199
  exports.MODAL_OVERLAY_COLOR = MODAL_OVERLAY_COLOR;
1120
1200
  exports.PageSkeleton = PageSkeleton;
1201
+ exports.ProgressBar = ProgressBar;
1121
1202
  exports.ToastHost = ToastHost;
1122
1203
  exports.UiProvider = FeedbackUiProvider;
1123
1204
  exports.WARMING_QUIET_PERIOD_MS = WARMING_QUIET_PERIOD_MS;
1124
1205
  exports.WarmingOverlay = WarmingOverlay;
1206
+ exports.clampPercent = clampPercent;
1125
1207
  exports.createToastBus = createToastBus;
1126
1208
  exports.getWarmingSnapshot = getWarmingSnapshot;
1127
1209
  exports.notifyWarming = notifyWarming;