@dloizides/ui-feedback 1.8.0 → 1.11.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,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.10.0
4
+
5
+ Adopts `@dloizides/ui-motion` for `PageSkeleton`: the loader now shows a moving
6
+ **shimmer** (a highlight band sweeping across each block) instead of an opacity pulse,
7
+ so loading states read as modern/ant-design-like. There is now ONE shimmer
8
+ implementation in the kit — the ui-motion `<Skeleton>` primitive — and `PageSkeleton`
9
+ owns only the page LAYOUT (how many bars/blocks, their sizes and spacing).
10
+
11
+ - **Add runtime dependency `@dloizides/ui-motion` (`^1.0.1`).**
12
+ - **`PageSkeleton` internals reimplemented on ui-motion `<Skeleton>`.** Each placeholder
13
+ block (header bar, list-row avatar + text lines, card) is now a `<Skeleton>` with the
14
+ same `width`/`height`/`borderRadius`/base colour it had before. The bespoke
15
+ `Animated.loop` opacity pulse (and its `Animated`/`Easing`/`Platform` imports) is gone.
16
+ - **Reduced-motion is now handled by `<Skeleton>`** (via `@dloizides/rn-web-hooks`
17
+ `useReducedMotion`): the sweep is suppressed and a static block is shown.
18
+ - **Public API unchanged.** `PageSkeletonProps` (`rows`, `showHeader`, `variant`), the
19
+ rendered layout, and the `page-skeleton` testID are identical to 1.9.0. Only the
20
+ internal animated primitive was swapped.
21
+ - `ToastHost` (fade+slide) is intentionally left as-is — it remains the reference
22
+ enter/exit pattern.
23
+
3
24
  ## 1.7.0
4
25
 
5
26
  Closes the API gap that kept `kefi-web`, `erevna-web` and `katalogos-web` on their
package/dist/index.d.mts CHANGED
@@ -127,6 +127,12 @@ declare const LoadingFallback: React.FC<LoadingFallbackProps>;
127
127
  *
128
128
  * Improves perceived performance (Speed Index) by showing immediate visual
129
129
  * feedback while page content loads.
130
+ *
131
+ * Each placeholder block is a `@dloizides/ui-motion` <Skeleton> — a rounded block
132
+ * with a highlight band that sweeps across it (translateX shimmer). This is the ONE
133
+ * shimmer implementation in the kit: PageSkeleton owns only the page LAYOUT (how many
134
+ * bars/blocks, their sizes and spacing), not the animation. Under reduced-motion the
135
+ * <Skeleton> suppresses the sweep and renders a static block on its own.
130
136
  */
131
137
 
132
138
  interface PageSkeletonProps {
package/dist/index.d.ts CHANGED
@@ -127,6 +127,12 @@ declare const LoadingFallback: React.FC<LoadingFallbackProps>;
127
127
  *
128
128
  * Improves perceived performance (Speed Index) by showing immediate visual
129
129
  * feedback while page content loads.
130
+ *
131
+ * Each placeholder block is a `@dloizides/ui-motion` <Skeleton> — a rounded block
132
+ * with a highlight band that sweeps across it (translateX shimmer). This is the ONE
133
+ * shimmer implementation in the kit: PageSkeleton owns only the page LAYOUT (how many
134
+ * bars/blocks, their sizes and spacing), not the animation. Under reduced-motion the
135
+ * <Skeleton> suppresses the sweep and renders a static block on its own.
130
136
  */
131
137
 
132
138
  interface PageSkeletonProps {
package/dist/index.js CHANGED
@@ -1,12 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var React3 = require('react');
3
+ var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var reactNative = require('react-native');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
-
9
- var React3__default = /*#__PURE__*/_interopDefault(React3);
6
+ var uiMotion = require('@dloizides/ui-motion');
10
7
 
11
8
  // src/context/FeedbackUiContext.tsx
12
9
  var DEFAULT_FEEDBACK_VALUE = {
@@ -33,18 +30,18 @@ var DEFAULT_FEEDBACK_VALUE = {
33
30
  },
34
31
  t: (key) => key
35
32
  };
36
- var FeedbackUiContext = React3.createContext(DEFAULT_FEEDBACK_VALUE);
33
+ var FeedbackUiContext = react.createContext(DEFAULT_FEEDBACK_VALUE);
37
34
  var FeedbackUiProvider = ({
38
35
  theme,
39
36
  t,
40
37
  navigate,
41
38
  children
42
39
  }) => {
43
- const value = React3.useMemo(() => ({ theme, t, navigate }), [theme, t, navigate]);
40
+ const value = react.useMemo(() => ({ theme, t, navigate }), [theme, t, navigate]);
44
41
  return /* @__PURE__ */ jsxRuntime.jsx(FeedbackUiContext.Provider, { value, children });
45
42
  };
46
43
  function useFeedbackUi() {
47
- return React3.useContext(FeedbackUiContext);
44
+ return react.useContext(FeedbackUiContext);
48
45
  }
49
46
 
50
47
  // src/constants.ts
@@ -155,7 +152,7 @@ var EmptyListState = ({
155
152
  const { theme, t, navigate } = useFeedbackUi();
156
153
  const { colors } = theme;
157
154
  const primary = theme.palette.primary["500"];
158
- const handlePress = React3.useCallback(() => {
155
+ const handlePress = react.useCallback(() => {
159
156
  if (typeof ctaRoute === "string" && typeof navigate === "function") navigate(ctaRoute);
160
157
  }, [navigate, ctaRoute]);
161
158
  const showCta = typeof ctaTextKey === "string" && typeof ctaHintKey === "string" && typeof ctaRoute === "string";
@@ -204,30 +201,30 @@ var LoadingFallback = ({ fullScreen = false, size = "large" }) => {
204
201
  }
205
202
  );
206
203
  };
207
- var ANIMATION_DURATION_MS = 1200;
208
204
  var SKELETON_BORDER_RADIUS = 4;
209
- var SKELETON_OPACITY_START = 0.3;
210
- var SKELETON_OPACITY_END = 0.7;
205
+ var CARD_BORDER_RADIUS = 8;
211
206
  var DEFAULT_ROWS = 5;
207
+ var HEADER_HEIGHT = 32;
208
+ var HEADER_WIDTH = "60%";
209
+ var AVATAR_SIZE = 48;
210
+ var AVATAR_BORDER_RADIUS = 24;
211
+ var TEXT_LINE_HEIGHT = 16;
212
+ var TEXT_LINE_FULL_WIDTH = "100%";
213
+ var TEXT_LINE_SHORT_WIDTH = "70%";
214
+ var CARD_HEIGHT = 120;
212
215
  var styles4 = reactNative.StyleSheet.create({
213
216
  container: {
214
217
  flex: 1,
215
218
  padding: 16
216
219
  },
217
220
  header: {
218
- height: 32,
219
- borderRadius: SKELETON_BORDER_RADIUS,
220
- marginBottom: 24,
221
- width: "60%"
221
+ marginBottom: 24
222
222
  },
223
223
  row: {
224
224
  flexDirection: "row",
225
225
  marginBottom: 16
226
226
  },
227
227
  avatar: {
228
- width: 48,
229
- height: 48,
230
- borderRadius: 24,
231
228
  marginRight: 12
232
229
  },
233
230
  textContainer: {
@@ -235,19 +232,9 @@ var styles4 = reactNative.StyleSheet.create({
235
232
  justifyContent: "center"
236
233
  },
237
234
  textLine: {
238
- height: 16,
239
- borderRadius: SKELETON_BORDER_RADIUS,
240
235
  marginBottom: 8
241
236
  },
242
- textLineShort: {
243
- width: "70%"
244
- },
245
- textLineFull: {
246
- width: "100%"
247
- },
248
237
  card: {
249
- height: 120,
250
- borderRadius: 8,
251
238
  marginBottom: 16
252
239
  }
253
240
  });
@@ -258,40 +245,51 @@ var PageSkeleton = ({
258
245
  }) => {
259
246
  const { theme, t } = useFeedbackUi();
260
247
  const colors = theme.colors;
261
- const animatedValue = React3__default.default.useRef(new reactNative.Animated.Value(0)).current;
262
- React3__default.default.useEffect(() => {
263
- const animation = reactNative.Animated.loop(
264
- reactNative.Animated.sequence([
265
- reactNative.Animated.timing(animatedValue, {
266
- toValue: 1,
267
- duration: ANIMATION_DURATION_MS,
268
- easing: reactNative.Easing.inOut(reactNative.Easing.ease),
269
- useNativeDriver: reactNative.Platform.OS !== "web"
270
- }),
271
- reactNative.Animated.timing(animatedValue, {
272
- toValue: 0,
273
- duration: ANIMATION_DURATION_MS,
274
- easing: reactNative.Easing.inOut(reactNative.Easing.ease),
275
- useNativeDriver: reactNative.Platform.OS !== "web"
276
- })
277
- ])
278
- );
279
- animation.start();
280
- return () => animation.stop();
281
- }, [animatedValue]);
282
- const opacity = animatedValue.interpolate({
283
- inputRange: [0, 1],
284
- outputRange: [SKELETON_OPACITY_START, SKELETON_OPACITY_END]
285
- });
286
248
  const skeletonColor = String(colors.border);
287
249
  const renderListRow = (index) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles4.row, children: [
288
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles4.avatar, { backgroundColor: skeletonColor, opacity }] }),
250
+ /* @__PURE__ */ jsxRuntime.jsx(
251
+ uiMotion.Skeleton,
252
+ {
253
+ backgroundColor: skeletonColor,
254
+ borderRadius: AVATAR_BORDER_RADIUS,
255
+ height: AVATAR_SIZE,
256
+ style: styles4.avatar,
257
+ width: AVATAR_SIZE
258
+ }
259
+ ),
289
260
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles4.textContainer, children: [
290
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles4.textLine, styles4.textLineFull, { backgroundColor: skeletonColor, opacity }] }),
291
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles4.textLine, styles4.textLineShort, { backgroundColor: skeletonColor, opacity }] })
261
+ /* @__PURE__ */ jsxRuntime.jsx(
262
+ uiMotion.Skeleton,
263
+ {
264
+ backgroundColor: skeletonColor,
265
+ borderRadius: SKELETON_BORDER_RADIUS,
266
+ height: TEXT_LINE_HEIGHT,
267
+ style: styles4.textLine,
268
+ width: TEXT_LINE_FULL_WIDTH
269
+ }
270
+ ),
271
+ /* @__PURE__ */ jsxRuntime.jsx(
272
+ uiMotion.Skeleton,
273
+ {
274
+ backgroundColor: skeletonColor,
275
+ borderRadius: SKELETON_BORDER_RADIUS,
276
+ height: TEXT_LINE_HEIGHT,
277
+ style: styles4.textLine,
278
+ width: TEXT_LINE_SHORT_WIDTH
279
+ }
280
+ )
292
281
  ] })
293
282
  ] }, index);
294
- const renderCard = (index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles4.card, { backgroundColor: skeletonColor, opacity }] }, index);
283
+ const renderCard = (index) => /* @__PURE__ */ jsxRuntime.jsx(
284
+ uiMotion.Skeleton,
285
+ {
286
+ backgroundColor: skeletonColor,
287
+ borderRadius: CARD_BORDER_RADIUS,
288
+ height: CARD_HEIGHT,
289
+ style: styles4.card
290
+ },
291
+ index
292
+ );
295
293
  const rowElements = Array.from({ length: rows }, (_, i) => variant === "cards" ? renderCard(i) : renderListRow(i));
296
294
  return /* @__PURE__ */ jsxRuntime.jsxs(
297
295
  reactNative.View,
@@ -302,7 +300,16 @@ var PageSkeleton = ({
302
300
  style: [styles4.container, { backgroundColor: colors.background }],
303
301
  testID: FEEDBACK_TEST_IDS.pageSkeleton,
304
302
  children: [
305
- showHeader ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles4.header, { backgroundColor: skeletonColor, opacity }] }) : null,
303
+ showHeader ? /* @__PURE__ */ jsxRuntime.jsx(
304
+ uiMotion.Skeleton,
305
+ {
306
+ backgroundColor: skeletonColor,
307
+ borderRadius: SKELETON_BORDER_RADIUS,
308
+ height: HEADER_HEIGHT,
309
+ style: styles4.header,
310
+ width: HEADER_WIDTH
311
+ }
312
+ ) : null,
306
313
  rowElements
307
314
  ]
308
315
  }
@@ -388,7 +395,7 @@ var ConfirmDialog = ({
388
395
  destructive = false
389
396
  }) => {
390
397
  const { theme, t } = useFeedbackUi();
391
- const colorStyles = React3.useMemo(
398
+ const colorStyles = react.useMemo(
392
399
  () => ({
393
400
  dialog: { backgroundColor: theme.colors.surfaceElevated },
394
401
  title: { color: theme.colors.text },
@@ -532,19 +539,19 @@ function sanitizeToastText(input, maxLength) {
532
539
  return stripped.length > maxLength ? stripped.slice(0, maxLength) : stripped;
533
540
  }
534
541
  var ToastItem = ({ message, onDone, colors, durationMs, fadeMs, testID }) => {
535
- const opacityRef = React3.useRef(new reactNative.Animated.Value(0));
536
- const translateYRef = React3.useRef(new reactNative.Animated.Value(TOAST_INITIAL_TRANSLATE_Y));
542
+ const opacityRef = react.useRef(new reactNative.Animated.Value(0));
543
+ const translateYRef = react.useRef(new reactNative.Animated.Value(TOAST_INITIAL_TRANSLATE_Y));
537
544
  const opacity = opacityRef.current;
538
545
  const translateY = translateYRef.current;
539
- const backgroundColor = React3.useMemo(() => {
546
+ const backgroundColor = react.useMemo(() => {
540
547
  if (message.type === "success") return colors.success;
541
548
  if (message.type === "error") return colors.error;
542
549
  return colors.primary;
543
550
  }, [colors.error, colors.primary, colors.success, message.type]);
544
- const handleDone = React3.useCallback(() => {
551
+ const handleDone = react.useCallback(() => {
545
552
  onDone(message.id);
546
553
  }, [message.id, onDone]);
547
- React3.useEffect(() => {
554
+ react.useEffect(() => {
548
555
  const useNative = reactNative.Platform.OS !== "web";
549
556
  reactNative.Animated.parallel([
550
557
  reactNative.Animated.timing(opacity, { toValue: 1, duration: fadeMs, useNativeDriver: useNative }),
@@ -582,9 +589,9 @@ var ToastHost = ({
582
589
  maxLength = DEFAULT_MAX_LENGTH,
583
590
  toastTestID = FEEDBACK_TEST_IDS.notificationToast
584
591
  }) => {
585
- const [messages, setMessages] = React3.useState([]);
592
+ const [messages, setMessages] = react.useState([]);
586
593
  const { theme } = useFeedbackUi();
587
- const colors = React3.useMemo(
594
+ const colors = react.useMemo(
588
595
  () => ({
589
596
  primary: theme.palette.primary["500"],
590
597
  success: (theme.semantic.success ?? theme.semantic.error)["500"],
@@ -593,16 +600,16 @@ var ToastHost = ({
593
600
  }),
594
601
  [theme]
595
602
  );
596
- const push = React3.useCallback(
603
+ const push = react.useCallback(
597
604
  (toast) => {
598
605
  setMessages((s) => [...s, { id: nextId(), type: toast.type, text: sanitizeToastText(toast.text, maxLength) }]);
599
606
  },
600
607
  [maxLength]
601
608
  );
602
- const remove = React3.useCallback((id) => {
609
+ const remove = react.useCallback((id) => {
603
610
  setMessages((s) => s.filter((x) => x.id !== id));
604
611
  }, []);
605
- React3.useEffect(() => subscribe(push), [subscribe, push]);
612
+ react.useEffect(() => subscribe(push), [subscribe, push]);
606
613
  if (messages.length === 0) return null;
607
614
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles6.container, children: messages.map((m) => /* @__PURE__ */ jsxRuntime.jsx(
608
615
  ToastItem,
@@ -725,7 +732,7 @@ var WarmingOverlay = ({
725
732
  showAttempt = false
726
733
  }) => {
727
734
  const ctx = useFeedbackUi();
728
- const snapshot2 = React3.useSyncExternalStore(subscribeWarming, getWarmingSnapshot, getWarmingSnapshot);
735
+ const snapshot2 = react.useSyncExternalStore(subscribeWarming, getWarmingSnapshot, getWarmingSnapshot);
729
736
  const theme = themeOverride ?? ctx.theme;
730
737
  const mergedLabels = { ...DEFAULT_WARMING_LABELS, ...labels };
731
738
  if (!snapshot2.isWarming) return null;
@@ -966,7 +973,7 @@ function resolveRetryable(retryable, error) {
966
973
  return retryable(error);
967
974
  }
968
975
  var INITIAL_STATE = { hasError: false, error: null, recovering: false };
969
- var AppErrorBoundary = class extends React3.Component {
976
+ var AppErrorBoundary = class extends react.Component {
970
977
  constructor(props) {
971
978
  super(props);
972
979
  this.handleRetry = () => {