@dloizides/ui-feedback 1.14.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,14 @@
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
+
3
12
  ## 1.14.0
4
13
 
5
14
  - **`ToastHost` portals to `document.body` on web (`position: fixed`, `Z_INDEX.toast`).** In-tree,
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
  /**
@@ -542,4 +543,21 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
542
543
  render(): ReactNode;
543
544
  }
544
545
 
545
- 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
  /**
@@ -542,4 +543,21 @@ declare class AppErrorBoundary extends Component<AppErrorBoundaryProps, AppError
542
543
  render(): ReactNode;
543
544
  }
544
545
 
545
- 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
@@ -60,7 +60,8 @@ var FEEDBACK_TEST_IDS = {
60
60
  cancelConfirmButton: "cancel-confirm-button",
61
61
  notificationToast: "notification-toast",
62
62
  warmingOverlay: "warming-overlay",
63
- errorBoundary: "error-boundary"
63
+ errorBoundary: "error-boundary",
64
+ progressBar: "progress-bar"
64
65
  };
65
66
  var WELL_SIZE = 56;
66
67
  var WELL_MARGIN_BOTTOM = 16;
@@ -1111,6 +1112,80 @@ var AppErrorBoundary = class extends react.Component {
1111
1112
  }
1112
1113
  };
1113
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
+
1114
1189
  exports.AppErrorBoundary = AppErrorBoundary;
1115
1190
  exports.AsyncSurface = AsyncSurface;
1116
1191
  exports.ConfirmDialog = ConfirmDialog;
@@ -1123,10 +1198,12 @@ exports.FeedbackUiProvider = FeedbackUiProvider;
1123
1198
  exports.LoadingFallback = LoadingFallback;
1124
1199
  exports.MODAL_OVERLAY_COLOR = MODAL_OVERLAY_COLOR;
1125
1200
  exports.PageSkeleton = PageSkeleton;
1201
+ exports.ProgressBar = ProgressBar;
1126
1202
  exports.ToastHost = ToastHost;
1127
1203
  exports.UiProvider = FeedbackUiProvider;
1128
1204
  exports.WARMING_QUIET_PERIOD_MS = WARMING_QUIET_PERIOD_MS;
1129
1205
  exports.WarmingOverlay = WarmingOverlay;
1206
+ exports.clampPercent = clampPercent;
1130
1207
  exports.createToastBus = createToastBus;
1131
1208
  exports.getWarmingSnapshot = getWarmingSnapshot;
1132
1209
  exports.notifyWarming = notifyWarming;