@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 +9 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +78 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -58,7 +58,8 @@ var FEEDBACK_TEST_IDS = {
|
|
|
58
58
|
cancelConfirmButton: "cancel-confirm-button",
|
|
59
59
|
notificationToast: "notification-toast",
|
|
60
60
|
warmingOverlay: "warming-overlay",
|
|
61
|
-
errorBoundary: "error-boundary"
|
|
61
|
+
errorBoundary: "error-boundary",
|
|
62
|
+
progressBar: "progress-bar"
|
|
62
63
|
};
|
|
63
64
|
var WELL_SIZE = 56;
|
|
64
65
|
var WELL_MARGIN_BOTTOM = 16;
|
|
@@ -1109,6 +1110,80 @@ var AppErrorBoundary = class extends Component {
|
|
|
1109
1110
|
}
|
|
1110
1111
|
};
|
|
1111
1112
|
|
|
1112
|
-
|
|
1113
|
+
// src/ProgressBar/clampPercent.ts
|
|
1114
|
+
var MIN_PERCENT = 0;
|
|
1115
|
+
var MAX_PERCENT = 100;
|
|
1116
|
+
function clampPercent(value) {
|
|
1117
|
+
if (value === null || value === void 0 || !Number.isFinite(value)) return MIN_PERCENT;
|
|
1118
|
+
return Math.min(MAX_PERCENT, Math.max(MIN_PERCENT, value));
|
|
1119
|
+
}
|
|
1120
|
+
var BAR_HEIGHT = 8;
|
|
1121
|
+
var RADIUS = 999;
|
|
1122
|
+
var TRACK_MARGIN = 4;
|
|
1123
|
+
var INDET_FRACTION = 0.35;
|
|
1124
|
+
var INDET_DURATION_MS = 1300;
|
|
1125
|
+
var LABEL_FONT_SIZE = 12;
|
|
1126
|
+
var styles11 = StyleSheet.create({
|
|
1127
|
+
track: { height: BAR_HEIGHT, borderRadius: RADIUS, overflow: "hidden", marginVertical: TRACK_MARGIN },
|
|
1128
|
+
fill: { height: "100%", borderRadius: RADIUS },
|
|
1129
|
+
label: { fontSize: LABEL_FONT_SIZE, textAlign: "right", fontVariant: ["tabular-nums"] }
|
|
1130
|
+
});
|
|
1131
|
+
function IndeterminateFill({ color, width, testID }) {
|
|
1132
|
+
const [anim] = useState(() => new Animated.Value(0));
|
|
1133
|
+
useEffect(() => {
|
|
1134
|
+
const loop = Animated.loop(
|
|
1135
|
+
Animated.timing(anim, { toValue: 1, duration: INDET_DURATION_MS, useNativeDriver: false })
|
|
1136
|
+
);
|
|
1137
|
+
loop.start();
|
|
1138
|
+
return () => loop.stop();
|
|
1139
|
+
}, [anim]);
|
|
1140
|
+
const barWidth = width * INDET_FRACTION;
|
|
1141
|
+
const translateX = anim.interpolate({ inputRange: [0, 1], outputRange: [-barWidth, width] });
|
|
1142
|
+
return /* @__PURE__ */ jsx(
|
|
1143
|
+
Animated.View,
|
|
1144
|
+
{
|
|
1145
|
+
style: [styles11.fill, { backgroundColor: color, width: barWidth, transform: [{ translateX }] }],
|
|
1146
|
+
testID
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
function ProgressBar(props) {
|
|
1151
|
+
const { theme } = useFeedbackUi();
|
|
1152
|
+
const {
|
|
1153
|
+
percent = null,
|
|
1154
|
+
label,
|
|
1155
|
+
indeterminate = false,
|
|
1156
|
+
accessibilityLabel,
|
|
1157
|
+
accessibilityHint,
|
|
1158
|
+
color = theme.palette.primary["500"],
|
|
1159
|
+
trackColor = theme.colors.border,
|
|
1160
|
+
textColor = theme.colors.textSecondary,
|
|
1161
|
+
testID = FEEDBACK_TEST_IDS.progressBar
|
|
1162
|
+
} = props;
|
|
1163
|
+
const [width, setWidth] = useState(0);
|
|
1164
|
+
const safePct = clampPercent(percent);
|
|
1165
|
+
const fillTestID = `${testID}-fill`;
|
|
1166
|
+
const onLayout = (e) => setWidth(e.nativeEvent.layout.width);
|
|
1167
|
+
return /* @__PURE__ */ jsxs(
|
|
1168
|
+
View,
|
|
1169
|
+
{
|
|
1170
|
+
accessibilityHint,
|
|
1171
|
+
accessibilityLabel: accessibilityLabel ?? label,
|
|
1172
|
+
"aria-busy": indeterminate,
|
|
1173
|
+
"aria-valuemax": MAX_PERCENT,
|
|
1174
|
+
"aria-valuemin": MIN_PERCENT,
|
|
1175
|
+
"aria-valuenow": indeterminate ? void 0 : safePct,
|
|
1176
|
+
"aria-valuetext": label,
|
|
1177
|
+
role: "progressbar",
|
|
1178
|
+
testID,
|
|
1179
|
+
children: [
|
|
1180
|
+
/* @__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 }) }),
|
|
1181
|
+
!indeterminate && label !== void 0 ? /* @__PURE__ */ jsx(Text, { style: [styles11.label, { color: textColor }], children: label }) : null
|
|
1182
|
+
]
|
|
1183
|
+
}
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
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
1188
|
//# sourceMappingURL=index.mjs.map
|
|
1114
1189
|
//# sourceMappingURL=index.mjs.map
|