@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 +18 -0
- package/dist/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +84 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createContext, useMemo, useContext, useCallback, useState, useEffect, u
|
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { StyleSheet, Platform, TouchableOpacity, Text, View, ActivityIndicator, Modal, Animated } from 'react-native';
|
|
4
4
|
import { Skeleton } from '@dloizides/ui-motion';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
5
6
|
import { Z_INDEX } from '@dloizides/design-tokens';
|
|
6
7
|
|
|
7
8
|
// src/context/FeedbackUiContext.tsx
|
|
@@ -57,7 +58,8 @@ var FEEDBACK_TEST_IDS = {
|
|
|
57
58
|
cancelConfirmButton: "cancel-confirm-button",
|
|
58
59
|
notificationToast: "notification-toast",
|
|
59
60
|
warmingOverlay: "warming-overlay",
|
|
60
|
-
errorBoundary: "error-boundary"
|
|
61
|
+
errorBoundary: "error-boundary",
|
|
62
|
+
progressBar: "progress-bar"
|
|
61
63
|
};
|
|
62
64
|
var WELL_SIZE = 56;
|
|
63
65
|
var WELL_MARGIN_BOTTOM = 16;
|
|
@@ -575,6 +577,8 @@ var ConfirmDialog = ({
|
|
|
575
577
|
}
|
|
576
578
|
);
|
|
577
579
|
};
|
|
580
|
+
var IS_WEB = Platform.OS === "web";
|
|
581
|
+
var WEB_FIXED_LAYER = { position: "fixed" };
|
|
578
582
|
var DEFAULT_DURATION_MS = 3e3;
|
|
579
583
|
var DEFAULT_FADE_MS = 200;
|
|
580
584
|
var DEFAULT_MAX_LENGTH = 500;
|
|
@@ -698,7 +702,8 @@ var ToastHost = ({
|
|
|
698
702
|
}, []);
|
|
699
703
|
useEffect(() => subscribe(push), [subscribe, push]);
|
|
700
704
|
if (messages.length === 0) return null;
|
|
701
|
-
|
|
705
|
+
const canPortal = IS_WEB && typeof document !== "undefined";
|
|
706
|
+
const layer = /* @__PURE__ */ jsx(View, { style: [styles7.container, canPortal ? WEB_FIXED_LAYER : null], children: messages.map((m) => /* @__PURE__ */ jsx(
|
|
702
707
|
ToastItem,
|
|
703
708
|
{
|
|
704
709
|
colors,
|
|
@@ -710,6 +715,7 @@ var ToastHost = ({
|
|
|
710
715
|
},
|
|
711
716
|
m.id
|
|
712
717
|
)) });
|
|
718
|
+
return canPortal ? createPortal(layer, document.body) : layer;
|
|
713
719
|
};
|
|
714
720
|
|
|
715
721
|
// src/Warming/warmingStore.ts
|
|
@@ -1104,6 +1110,80 @@ var AppErrorBoundary = class extends Component {
|
|
|
1104
1110
|
}
|
|
1105
1111
|
};
|
|
1106
1112
|
|
|
1107
|
-
|
|
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 };
|
|
1108
1188
|
//# sourceMappingURL=index.mjs.map
|
|
1109
1189
|
//# sourceMappingURL=index.mjs.map
|