@dloizides/ui-feedback 1.14.0 → 1.15.1

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.js CHANGED
@@ -48,6 +48,7 @@ function useFeedbackUi() {
48
48
 
49
49
  // src/constants.ts
50
50
  var MODAL_OVERLAY_COLOR = "rgba(0, 0, 0, 0.5)";
51
+ var MIN_TOUCH_TARGET = 44;
51
52
  var DISABLED_OPACITY = 0.5;
52
53
  var FEEDBACK_TEST_IDS = {
53
54
  errorState: "error-state",
@@ -60,7 +61,8 @@ var FEEDBACK_TEST_IDS = {
60
61
  cancelConfirmButton: "cancel-confirm-button",
61
62
  notificationToast: "notification-toast",
62
63
  warmingOverlay: "warming-overlay",
63
- errorBoundary: "error-boundary"
64
+ errorBoundary: "error-boundary",
65
+ progressBar: "progress-bar"
64
66
  };
65
67
  var WELL_SIZE = 56;
66
68
  var WELL_MARGIN_BOTTOM = 16;
@@ -86,6 +88,9 @@ var styles = reactNative.StyleSheet.create({
86
88
  opacity: WELL_TINT_OPACITY
87
89
  },
88
90
  secondaryButton: {
91
+ minHeight: MIN_TOUCH_TARGET,
92
+ justifyContent: "center",
93
+ alignItems: "center",
89
94
  marginTop: BUTTON_MARGIN_TOP,
90
95
  paddingVertical: BUTTON_PADDING_V,
91
96
  paddingHorizontal: BUTTON_PADDING_H,
@@ -150,6 +155,9 @@ var styles2 = reactNative.StyleSheet.create({
150
155
  columnGap: ACTION_GAP
151
156
  },
152
157
  retryButton: {
158
+ minHeight: MIN_TOUCH_TARGET,
159
+ justifyContent: "center",
160
+ alignItems: "center",
153
161
  marginTop: BUTTON_MARGIN_TOP2,
154
162
  paddingVertical: BUTTON_PADDING_V2,
155
163
  paddingHorizontal: BUTTON_PADDING_H2,
@@ -1111,6 +1119,80 @@ var AppErrorBoundary = class extends react.Component {
1111
1119
  }
1112
1120
  };
1113
1121
 
1122
+ // src/ProgressBar/clampPercent.ts
1123
+ var MIN_PERCENT = 0;
1124
+ var MAX_PERCENT = 100;
1125
+ function clampPercent(value) {
1126
+ if (value === null || value === void 0 || !Number.isFinite(value)) return MIN_PERCENT;
1127
+ return Math.min(MAX_PERCENT, Math.max(MIN_PERCENT, value));
1128
+ }
1129
+ var BAR_HEIGHT = 8;
1130
+ var RADIUS = 999;
1131
+ var TRACK_MARGIN = 4;
1132
+ var INDET_FRACTION = 0.35;
1133
+ var INDET_DURATION_MS = 1300;
1134
+ var LABEL_FONT_SIZE = 12;
1135
+ var styles11 = reactNative.StyleSheet.create({
1136
+ track: { height: BAR_HEIGHT, borderRadius: RADIUS, overflow: "hidden", marginVertical: TRACK_MARGIN },
1137
+ fill: { height: "100%", borderRadius: RADIUS },
1138
+ label: { fontSize: LABEL_FONT_SIZE, textAlign: "right", fontVariant: ["tabular-nums"] }
1139
+ });
1140
+ function IndeterminateFill({ color, width, testID }) {
1141
+ const [anim] = react.useState(() => new reactNative.Animated.Value(0));
1142
+ react.useEffect(() => {
1143
+ const loop = reactNative.Animated.loop(
1144
+ reactNative.Animated.timing(anim, { toValue: 1, duration: INDET_DURATION_MS, useNativeDriver: false })
1145
+ );
1146
+ loop.start();
1147
+ return () => loop.stop();
1148
+ }, [anim]);
1149
+ const barWidth = width * INDET_FRACTION;
1150
+ const translateX = anim.interpolate({ inputRange: [0, 1], outputRange: [-barWidth, width] });
1151
+ return /* @__PURE__ */ jsxRuntime.jsx(
1152
+ reactNative.Animated.View,
1153
+ {
1154
+ style: [styles11.fill, { backgroundColor: color, width: barWidth, transform: [{ translateX }] }],
1155
+ testID
1156
+ }
1157
+ );
1158
+ }
1159
+ function ProgressBar(props) {
1160
+ const { theme } = useFeedbackUi();
1161
+ const {
1162
+ percent = null,
1163
+ label,
1164
+ indeterminate = false,
1165
+ accessibilityLabel,
1166
+ accessibilityHint,
1167
+ color = theme.palette.primary["500"],
1168
+ trackColor = theme.colors.border,
1169
+ textColor = theme.colors.textSecondary,
1170
+ testID = FEEDBACK_TEST_IDS.progressBar
1171
+ } = props;
1172
+ const [width, setWidth] = react.useState(0);
1173
+ const safePct = clampPercent(percent);
1174
+ const fillTestID = `${testID}-fill`;
1175
+ const onLayout = (e) => setWidth(e.nativeEvent.layout.width);
1176
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1177
+ reactNative.View,
1178
+ {
1179
+ accessibilityHint,
1180
+ accessibilityLabel: accessibilityLabel ?? label,
1181
+ "aria-busy": indeterminate,
1182
+ "aria-valuemax": MAX_PERCENT,
1183
+ "aria-valuemin": MIN_PERCENT,
1184
+ "aria-valuenow": indeterminate ? void 0 : safePct,
1185
+ "aria-valuetext": label,
1186
+ role: "progressbar",
1187
+ testID,
1188
+ children: [
1189
+ /* @__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 }) }),
1190
+ !indeterminate && label !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles11.label, { color: textColor }], children: label }) : null
1191
+ ]
1192
+ }
1193
+ );
1194
+ }
1195
+
1114
1196
  exports.AppErrorBoundary = AppErrorBoundary;
1115
1197
  exports.AsyncSurface = AsyncSurface;
1116
1198
  exports.ConfirmDialog = ConfirmDialog;
@@ -1123,10 +1205,12 @@ exports.FeedbackUiProvider = FeedbackUiProvider;
1123
1205
  exports.LoadingFallback = LoadingFallback;
1124
1206
  exports.MODAL_OVERLAY_COLOR = MODAL_OVERLAY_COLOR;
1125
1207
  exports.PageSkeleton = PageSkeleton;
1208
+ exports.ProgressBar = ProgressBar;
1126
1209
  exports.ToastHost = ToastHost;
1127
1210
  exports.UiProvider = FeedbackUiProvider;
1128
1211
  exports.WARMING_QUIET_PERIOD_MS = WARMING_QUIET_PERIOD_MS;
1129
1212
  exports.WarmingOverlay = WarmingOverlay;
1213
+ exports.clampPercent = clampPercent;
1130
1214
  exports.createToastBus = createToastBus;
1131
1215
  exports.getWarmingSnapshot = getWarmingSnapshot;
1132
1216
  exports.notifyWarming = notifyWarming;