cpk-ui 0.1.11 → 0.1.13

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { cloneElement, forwardRef, useImperativeHandle, useState, } from 'react';
2
+ import { cloneElement, forwardRef, useEffect, useImperativeHandle, useState, } from 'react';
3
3
  import { Modal, Platform, StyleSheet, TouchableWithoutFeedback, View, } from 'react-native';
4
4
  import styled, { css } from '@emotion/native';
5
5
  import { useTheme } from '../../../providers/ThemeProvider';
@@ -37,6 +37,14 @@ function AlertDialog({ style }, ref) {
37
37
  const [options, setOptions] = useState(null);
38
38
  const [visible, setVisible] = useState(false);
39
39
  const { theme, themeType } = useTheme();
40
+ useEffect(() => {
41
+ if (!visible) {
42
+ setTimeout(() => {
43
+ setOptions(null);
44
+ // Run after modal has finished transition
45
+ }, 300);
46
+ }
47
+ }, [visible]);
40
48
  useImperativeHandle(ref, () => ({
41
49
  open: (alertDialogOptions) => {
42
50
  setVisible(true);
@@ -46,7 +54,6 @@ function AlertDialog({ style }, ref) {
46
54
  },
47
55
  close: () => {
48
56
  setVisible(false);
49
- setOptions(null);
50
57
  },
51
58
  }));
52
59
  const { backdropOpacity = 0.2, title, body, styles, actions, closeOnTouchOutside = true, showCloseButton = true, } = options ?? {};
@@ -1,6 +1,7 @@
1
1
  import React, {
2
2
  cloneElement,
3
3
  forwardRef,
4
+ useEffect,
4
5
  useImperativeHandle,
5
6
  useState,
6
7
  } from 'react';
@@ -86,6 +87,15 @@ function AlertDialog(
86
87
  const [visible, setVisible] = useState(false);
87
88
  const {theme, themeType} = useTheme();
88
89
 
90
+ useEffect(() => {
91
+ if (!visible) {
92
+ setTimeout(() => {
93
+ setOptions(null);
94
+ // Run after modal has finished transition
95
+ }, 300);
96
+ }
97
+ }, [visible]);
98
+
89
99
  useImperativeHandle(ref, () => ({
90
100
  open: (alertDialogOptions) => {
91
101
  setVisible(true);
@@ -95,7 +105,6 @@ function AlertDialog(
95
105
  },
96
106
  close: () => {
97
107
  setVisible(false);
98
- setOptions(null);
99
108
  },
100
109
  }));
101
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cpk-ui",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "main": "index",
5
5
  "react-native": "index",
6
6
  "module": "index",