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