@rific/auto-paper 0.9.4 → 0.9.5

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
@@ -691,7 +691,9 @@ function Provider({ children, defaults, expoBlur, initialValue, navigationBar, o
691
691
  setSettings((prev) => ({ ...prev, ...patch }));
692
692
  }, []);
693
693
  const onChangeRef = (0, import_react7.useRef)(onChange);
694
- onChangeRef.current = onChange;
694
+ (0, import_react7.useEffect)(() => {
695
+ onChangeRef.current = onChange;
696
+ });
695
697
  const prevSettings = (0, import_react7.useRef)(settings);
696
698
  (0, import_react7.useEffect)(() => {
697
699
  if (prevSettings.current !== settings) {
@@ -756,18 +758,20 @@ function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, di
756
758
  const { colors, isV3, roundness } = theme;
757
759
  const { scale } = theme.animation;
758
760
  const { bottom, left, right, top } = (0, import_react_native_safe_area_context.useSafeAreaInsets)();
759
- const opacity = (0, import_react9.useRef)(new import_react_native5.Animated.Value(visible ? 1 : 0)).current;
761
+ const [opacity] = (0, import_react9.useState)(() => new import_react_native5.Animated.Value(visible ? 1 : 0));
760
762
  const [mounted, setMounted] = (0, import_react9.useState)(visible);
763
+ if (visible && !mounted) {
764
+ setMounted(true);
765
+ }
761
766
  (0, import_react9.useEffect)(() => {
762
767
  if (visible) {
763
- setMounted(true);
764
768
  import_react_native5.Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: import_react_native5.Easing.out(import_react_native5.Easing.cubic), toValue: 1, useNativeDriver: true }).start();
765
769
  } else {
766
770
  import_react_native5.Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: import_react_native5.Easing.out(import_react_native5.Easing.cubic), toValue: 0, useNativeDriver: true }).start(({ finished }) => {
767
771
  if (finished) setMounted(false);
768
772
  });
769
773
  }
770
- }, [visible]);
774
+ }, [visible, opacity, scale]);
771
775
  (0, import_react9.useEffect)(() => {
772
776
  if (!visible) return void 0;
773
777
  const onHardwareBackPress = () => {
package/dist/index.mjs CHANGED
@@ -417,7 +417,7 @@ import { StyleSheet as StyleSheet4, TouchableOpacity, View as View4 } from "reac
417
417
  import { Icon, TouchableRipple, useTheme as useTheme4 } from "react-native-paper";
418
418
 
419
419
  // src/components/Dialog.tsx
420
- import React, { useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
420
+ import React, { useEffect as useEffect3, useState as useState4 } from "react";
421
421
  import { Animated, BackHandler, Easing, Pressable, StyleSheet as StyleSheet3, View as View3 } from "react-native";
422
422
  import { Dialog as PaperDialog, Portal, useTheme as useTheme3 } from "react-native-paper";
423
423
  import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -609,7 +609,9 @@ function Provider({ children, defaults, expoBlur, initialValue, navigationBar, o
609
609
  setSettings((prev) => ({ ...prev, ...patch }));
610
610
  }, []);
611
611
  const onChangeRef = useRef(onChange);
612
- onChangeRef.current = onChange;
612
+ useEffect2(() => {
613
+ onChangeRef.current = onChange;
614
+ });
613
615
  const prevSettings = useRef(settings);
614
616
  useEffect2(() => {
615
617
  if (prevSettings.current !== settings) {
@@ -674,18 +676,20 @@ function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, di
674
676
  const { colors, isV3, roundness } = theme;
675
677
  const { scale } = theme.animation;
676
678
  const { bottom, left, right, top } = useSafeAreaInsets();
677
- const opacity = useRef2(new Animated.Value(visible ? 1 : 0)).current;
679
+ const [opacity] = useState4(() => new Animated.Value(visible ? 1 : 0));
678
680
  const [mounted, setMounted] = useState4(visible);
681
+ if (visible && !mounted) {
682
+ setMounted(true);
683
+ }
679
684
  useEffect3(() => {
680
685
  if (visible) {
681
- setMounted(true);
682
686
  Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: Easing.out(Easing.cubic), toValue: 1, useNativeDriver: true }).start();
683
687
  } else {
684
688
  Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: Easing.out(Easing.cubic), toValue: 0, useNativeDriver: true }).start(({ finished }) => {
685
689
  if (finished) setMounted(false);
686
690
  });
687
691
  }
688
- }, [visible]);
692
+ }, [visible, opacity, scale]);
689
693
  useEffect3(() => {
690
694
  if (!visible) return void 0;
691
695
  const onHardwareBackPress = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rific/auto-paper",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Adaptive react-native-paper theming: triadic palette from a seed color + system/light/dark appearance",
5
5
  "keywords": [
6
6
  "react-native",
@@ -76,6 +76,7 @@
76
76
  "eslint-config-prettier": "^10.1.8",
77
77
  "eslint-plugin-package-json": "^1.0.0",
78
78
  "eslint-plugin-prettier": "^5.5.5",
79
+ "eslint-plugin-react-hooks": "^7.1.1",
79
80
  "eslint-plugin-react-native": "^5.0.0",
80
81
  "eslint-plugin-simple-import-sort": "^13.0.0",
81
82
  "expo-blur": "^56.0.3",
@@ -49,7 +49,9 @@ export function Provider({ children, defaults, expoBlur, initialValue, navigatio
49
49
  }, [])
50
50
 
51
51
  const onChangeRef = useRef(onChange)
52
- onChangeRef.current = onChange
52
+ useEffect(() => {
53
+ onChangeRef.current = onChange
54
+ })
53
55
  const prevSettings = useRef(settings)
54
56
  useEffect(() => {
55
57
  if (prevSettings.current !== settings) {
@@ -1,4 +1,4 @@
1
- import React, { type ComponentType, type ReactNode, useEffect, useRef, useState } from 'react'
1
+ import React, { type ComponentType, type ReactNode, useEffect, useState } from 'react'
2
2
  import { Animated, BackHandler, Easing, Pressable, type StyleProp, StyleSheet, View, type ViewStyle } from 'react-native'
3
3
  import { Dialog as PaperDialog, type DialogActionsProps, type DialogContentProps, type DialogProps as PaperDialogProps, type DialogScrollAreaProps, type DialogTitleProps, Portal, useTheme } from 'react-native-paper'
4
4
  import { useSafeAreaInsets } from 'react-native-safe-area-context'
@@ -46,19 +46,22 @@ function DialogComponent({ animatedStyle, blur: blurProp, dismissable = true, di
46
46
  const { colors, isV3, roundness } = theme
47
47
  const { scale } = theme.animation
48
48
  const { bottom, left, right, top } = useSafeAreaInsets()
49
- const opacity = useRef(new Animated.Value(visible ? 1 : 0)).current
49
+ const [opacity] = useState(() => new Animated.Value(visible ? 1 : 0))
50
50
  const [mounted, setMounted] = useState(visible)
51
51
 
52
+ if (visible && !mounted) {
53
+ setMounted(true)
54
+ }
55
+
52
56
  useEffect(() => {
53
57
  if (visible) {
54
- setMounted(true)
55
58
  Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: Easing.out(Easing.cubic), toValue: 1, useNativeDriver: true }).start()
56
59
  } else {
57
60
  Animated.timing(opacity, { duration: scale * ANIMATION_DURATION, easing: Easing.out(Easing.cubic), toValue: 0, useNativeDriver: true }).start(({ finished }) => {
58
61
  if (finished) setMounted(false)
59
62
  })
60
63
  }
61
- }, [visible])
64
+ }, [visible, opacity, scale])
62
65
 
63
66
  useEffect(() => {
64
67
  if (!visible) return undefined
@@ -147,6 +147,7 @@ export function useComputedTheme(appearance: ThemeAppearance, color: string | Tr
147
147
  }, [appearance, primaryInput, secondaryInput, tertiaryInput, harmony])
148
148
 
149
149
  useEffect(() => {
150
+ // eslint-disable-next-line react-hooks/set-state-in-effect -- intentional: first render must stay theme-less (README's onReady/splash-screen contract) and Appearance must not be read during render (SSR/hydration risk)
150
151
  computeTheme()
151
152
  }, [computeTheme])
152
153